]> git.pld-linux.org Git - packages/kernel.git/blob - kernel-vserver-2.3.patch
- real 3.0.6
[packages/kernel.git] / kernel-vserver-2.3.patch
1 diff -NurpP --minimal linux-3.0.4/.config.inet linux-3.0.4-vs2.3.1/.config.inet
2 --- linux-3.0.4/.config.inet    1970-01-01 01:00:00.000000000 +0100
3 +++ linux-3.0.4-vs2.3.1/.config.inet    2011-06-13 14:55:18.000000000 +0200
4 @@ -0,0 +1,1620 @@
5 +#
6 +# Automatically generated make config: don't edit
7 +# Linux/x86_64 3.0.0-rc2-vs2.3.x Kernel Configuration
8 +#
9 +CONFIG_64BIT=y
10 +# CONFIG_X86_32 is not set
11 +CONFIG_X86_64=y
12 +CONFIG_X86=y
13 +CONFIG_INSTRUCTION_DECODER=y
14 +CONFIG_OUTPUT_FORMAT="elf64-x86-64"
15 +CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig"
16 +CONFIG_GENERIC_CMOS_UPDATE=y
17 +CONFIG_CLOCKSOURCE_WATCHDOG=y
18 +CONFIG_GENERIC_CLOCKEVENTS=y
19 +CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
20 +CONFIG_LOCKDEP_SUPPORT=y
21 +CONFIG_STACKTRACE_SUPPORT=y
22 +CONFIG_HAVE_LATENCYTOP_SUPPORT=y
23 +CONFIG_MMU=y
24 +CONFIG_ZONE_DMA=y
25 +CONFIG_NEED_DMA_MAP_STATE=y
26 +CONFIG_NEED_SG_DMA_LENGTH=y
27 +CONFIG_GENERIC_ISA_DMA=y
28 +CONFIG_GENERIC_IOMAP=y
29 +CONFIG_GENERIC_BUG=y
30 +CONFIG_GENERIC_BUG_RELATIVE_POINTERS=y
31 +CONFIG_GENERIC_HWEIGHT=y
32 +CONFIG_ARCH_MAY_HAVE_PC_FDC=y
33 +# CONFIG_RWSEM_GENERIC_SPINLOCK is not set
34 +CONFIG_RWSEM_XCHGADD_ALGORITHM=y
35 +CONFIG_ARCH_HAS_CPU_IDLE_WAIT=y
36 +CONFIG_GENERIC_CALIBRATE_DELAY=y
37 +CONFIG_GENERIC_TIME_VSYSCALL=y
38 +CONFIG_ARCH_HAS_CPU_RELAX=y
39 +CONFIG_ARCH_HAS_DEFAULT_IDLE=y
40 +CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y
41 +CONFIG_HAVE_SETUP_PER_CPU_AREA=y
42 +CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK=y
43 +CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK=y
44 +CONFIG_HAVE_CPUMASK_OF_CPU_MAP=y
45 +CONFIG_ARCH_HIBERNATION_POSSIBLE=y
46 +CONFIG_ARCH_SUSPEND_POSSIBLE=y
47 +CONFIG_ZONE_DMA32=y
48 +CONFIG_ARCH_POPULATES_NODE_MAP=y
49 +CONFIG_AUDIT_ARCH=y
50 +CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y
51 +CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
52 +CONFIG_X86_64_SMP=y
53 +CONFIG_X86_HT=y
54 +CONFIG_ARCH_HWEIGHT_CFLAGS="-fcall-saved-rdi -fcall-saved-rsi -fcall-saved-rdx -fcall-saved-rcx -fcall-saved-r8 -fcall-saved-r9 -fcall-saved-r10 -fcall-saved-r11"
55 +# CONFIG_KTIME_SCALAR is not set
56 +CONFIG_ARCH_CPU_PROBE_RELEASE=y
57 +CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
58 +CONFIG_CONSTRUCTORS=y
59 +CONFIG_HAVE_IRQ_WORK=y
60 +CONFIG_IRQ_WORK=y
61 +
62 +#
63 +# General setup
64 +#
65 +CONFIG_EXPERIMENTAL=y
66 +CONFIG_INIT_ENV_ARG_LIMIT=32
67 +CONFIG_CROSS_COMPILE=""
68 +CONFIG_LOCALVERSION=""
69 +# CONFIG_LOCALVERSION_AUTO is not set
70 +CONFIG_HAVE_KERNEL_GZIP=y
71 +CONFIG_HAVE_KERNEL_BZIP2=y
72 +CONFIG_HAVE_KERNEL_LZMA=y
73 +CONFIG_HAVE_KERNEL_XZ=y
74 +CONFIG_HAVE_KERNEL_LZO=y
75 +# CONFIG_KERNEL_GZIP is not set
76 +# CONFIG_KERNEL_BZIP2 is not set
77 +CONFIG_KERNEL_LZMA=y
78 +# CONFIG_KERNEL_XZ is not set
79 +# CONFIG_KERNEL_LZO is not set
80 +CONFIG_SWAP=y
81 +CONFIG_SYSVIPC=y
82 +CONFIG_SYSVIPC_SYSCTL=y
83 +CONFIG_POSIX_MQUEUE=y
84 +CONFIG_POSIX_MQUEUE_SYSCTL=y
85 +CONFIG_BSD_PROCESS_ACCT=y
86 +# CONFIG_BSD_PROCESS_ACCT_V3 is not set
87 +# CONFIG_FHANDLE is not set
88 +CONFIG_TASKSTATS=y
89 +CONFIG_TASK_DELAY_ACCT=y
90 +CONFIG_TASK_XACCT=y
91 +CONFIG_TASK_IO_ACCOUNTING=y
92 +# CONFIG_AUDIT is not set
93 +CONFIG_HAVE_GENERIC_HARDIRQS=y
94 +
95 +#
96 +# IRQ subsystem
97 +#
98 +CONFIG_GENERIC_HARDIRQS=y
99 +CONFIG_HAVE_SPARSE_IRQ=y
100 +CONFIG_GENERIC_IRQ_PROBE=y
101 +CONFIG_GENERIC_IRQ_SHOW=y
102 +CONFIG_GENERIC_PENDING_IRQ=y
103 +CONFIG_IRQ_FORCED_THREADING=y
104 +# CONFIG_SPARSE_IRQ is not set
105 +
106 +#
107 +# RCU Subsystem
108 +#
109 +CONFIG_TREE_RCU=y
110 +# CONFIG_PREEMPT_RCU is not set
111 +# CONFIG_RCU_TRACE is not set
112 +CONFIG_RCU_FANOUT=64
113 +# CONFIG_RCU_FANOUT_EXACT is not set
114 +# CONFIG_TREE_RCU_TRACE is not set
115 +CONFIG_IKCONFIG=y
116 +CONFIG_IKCONFIG_PROC=y
117 +CONFIG_LOG_BUF_SHIFT=18
118 +CONFIG_HAVE_UNSTABLE_SCHED_CLOCK=y
119 +CONFIG_CGROUPS=y
120 +# CONFIG_CGROUP_DEBUG is not set
121 +# CONFIG_CGROUP_FREEZER is not set
122 +# CONFIG_CGROUP_DEVICE is not set
123 +# CONFIG_CPUSETS is not set
124 +# CONFIG_CGROUP_CPUACCT is not set
125 +CONFIG_RESOURCE_COUNTERS=y
126 +CONFIG_CGROUP_MEM_RES_CTLR=y
127 +CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y
128 +CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED=y
129 +# CONFIG_CGROUP_PERF is not set
130 +CONFIG_CGROUP_SCHED=y
131 +CONFIG_FAIR_GROUP_SCHED=y
132 +# CONFIG_RT_GROUP_SCHED is not set
133 +# CONFIG_BLK_CGROUP is not set
134 +CONFIG_NAMESPACES=y
135 +CONFIG_UTS_NS=y
136 +CONFIG_IPC_NS=y
137 +CONFIG_USER_NS=y
138 +# CONFIG_PID_NS is not set
139 +# CONFIG_NET_NS is not set
140 +CONFIG_SCHED_AUTOGROUP=y
141 +CONFIG_MM_OWNER=y
142 +# CONFIG_SYSFS_DEPRECATED is not set
143 +# CONFIG_RELAY is not set
144 +# CONFIG_BLK_DEV_INITRD is not set
145 +CONFIG_CC_OPTIMIZE_FOR_SIZE=y
146 +CONFIG_SYSCTL=y
147 +CONFIG_ANON_INODES=y
148 +CONFIG_EXPERT=y
149 +CONFIG_UID16=y
150 +CONFIG_SYSCTL_SYSCALL=y
151 +CONFIG_KALLSYMS=y
152 +CONFIG_KALLSYMS_ALL=y
153 +CONFIG_HOTPLUG=y
154 +CONFIG_PRINTK=y
155 +CONFIG_BUG=y
156 +CONFIG_ELF_CORE=y
157 +CONFIG_PCSPKR_PLATFORM=y
158 +CONFIG_BASE_FULL=y
159 +CONFIG_FUTEX=y
160 +CONFIG_EPOLL=y
161 +CONFIG_SIGNALFD=y
162 +CONFIG_TIMERFD=y
163 +CONFIG_EVENTFD=y
164 +CONFIG_SHMEM=y
165 +CONFIG_AIO=y
166 +# CONFIG_EMBEDDED is not set
167 +CONFIG_HAVE_PERF_EVENTS=y
168 +
169 +#
170 +# Kernel Performance Events And Counters
171 +#
172 +CONFIG_PERF_EVENTS=y
173 +# CONFIG_PERF_COUNTERS is not set
174 +# CONFIG_DEBUG_PERF_USE_VMALLOC is not set
175 +CONFIG_VM_EVENT_COUNTERS=y
176 +CONFIG_PCI_QUIRKS=y
177 +CONFIG_SLUB_DEBUG=y
178 +# CONFIG_COMPAT_BRK is not set
179 +# CONFIG_SLAB is not set
180 +CONFIG_SLUB=y
181 +# CONFIG_SLOB is not set
182 +# CONFIG_PROFILING is not set
183 +CONFIG_HAVE_OPROFILE=y
184 +# CONFIG_JUMP_LABEL is not set
185 +CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y
186 +CONFIG_HAVE_IOREMAP_PROT=y
187 +CONFIG_HAVE_KPROBES=y
188 +CONFIG_HAVE_KRETPROBES=y
189 +CONFIG_HAVE_OPTPROBES=y
190 +CONFIG_HAVE_ARCH_TRACEHOOK=y
191 +CONFIG_HAVE_DMA_ATTRS=y
192 +CONFIG_USE_GENERIC_SMP_HELPERS=y
193 +CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y
194 +CONFIG_HAVE_DMA_API_DEBUG=y
195 +CONFIG_HAVE_HW_BREAKPOINT=y
196 +CONFIG_HAVE_MIXED_BREAKPOINTS_REGS=y
197 +CONFIG_HAVE_USER_RETURN_NOTIFIER=y
198 +CONFIG_HAVE_PERF_EVENTS_NMI=y
199 +CONFIG_HAVE_ARCH_JUMP_LABEL=y
200 +
201 +#
202 +# GCOV-based kernel profiling
203 +#
204 +# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
205 +CONFIG_SLABINFO=y
206 +CONFIG_RT_MUTEXES=y
207 +CONFIG_BASE_SMALL=0
208 +# CONFIG_MODULES is not set
209 +CONFIG_STOP_MACHINE=y
210 +CONFIG_BLOCK=y
211 +# CONFIG_BLK_DEV_BSG is not set
212 +# CONFIG_BLK_DEV_INTEGRITY is not set
213 +CONFIG_BLOCK_COMPAT=y
214 +
215 +#
216 +# IO Schedulers
217 +#
218 +CONFIG_IOSCHED_NOOP=y
219 +# CONFIG_IOSCHED_DEADLINE is not set
220 +CONFIG_IOSCHED_CFQ=y
221 +CONFIG_DEFAULT_CFQ=y
222 +# CONFIG_DEFAULT_NOOP is not set
223 +CONFIG_DEFAULT_IOSCHED="cfq"
224 +# CONFIG_INLINE_SPIN_TRYLOCK is not set
225 +# CONFIG_INLINE_SPIN_TRYLOCK_BH is not set
226 +# CONFIG_INLINE_SPIN_LOCK is not set
227 +# CONFIG_INLINE_SPIN_LOCK_BH is not set
228 +# CONFIG_INLINE_SPIN_LOCK_IRQ is not set
229 +# CONFIG_INLINE_SPIN_LOCK_IRQSAVE is not set
230 +CONFIG_INLINE_SPIN_UNLOCK=y
231 +# CONFIG_INLINE_SPIN_UNLOCK_BH is not set
232 +CONFIG_INLINE_SPIN_UNLOCK_IRQ=y
233 +# CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE is not set
234 +# CONFIG_INLINE_READ_TRYLOCK is not set
235 +# CONFIG_INLINE_READ_LOCK is not set
236 +# CONFIG_INLINE_READ_LOCK_BH is not set
237 +# CONFIG_INLINE_READ_LOCK_IRQ is not set
238 +# CONFIG_INLINE_READ_LOCK_IRQSAVE is not set
239 +CONFIG_INLINE_READ_UNLOCK=y
240 +# CONFIG_INLINE_READ_UNLOCK_BH is not set
241 +CONFIG_INLINE_READ_UNLOCK_IRQ=y
242 +# CONFIG_INLINE_READ_UNLOCK_IRQRESTORE is not set
243 +# CONFIG_INLINE_WRITE_TRYLOCK is not set
244 +# CONFIG_INLINE_WRITE_LOCK is not set
245 +# CONFIG_INLINE_WRITE_LOCK_BH is not set
246 +# CONFIG_INLINE_WRITE_LOCK_IRQ is not set
247 +# CONFIG_INLINE_WRITE_LOCK_IRQSAVE is not set
248 +CONFIG_INLINE_WRITE_UNLOCK=y
249 +# CONFIG_INLINE_WRITE_UNLOCK_BH is not set
250 +CONFIG_INLINE_WRITE_UNLOCK_IRQ=y
251 +# CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE is not set
252 +CONFIG_MUTEX_SPIN_ON_OWNER=y
253 +CONFIG_FREEZER=y
254 +
255 +#
256 +# Processor type and features
257 +#
258 +CONFIG_TICK_ONESHOT=y
259 +# CONFIG_NO_HZ is not set
260 +CONFIG_HIGH_RES_TIMERS=y
261 +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
262 +CONFIG_SMP=y
263 +CONFIG_X86_MPPARSE=y
264 +# CONFIG_X86_EXTENDED_PLATFORM is not set
265 +CONFIG_X86_SUPPORTS_MEMORY_FAILURE=y
266 +CONFIG_SCHED_OMIT_FRAME_POINTER=y
267 +# CONFIG_PARAVIRT_GUEST is not set
268 +CONFIG_NO_BOOTMEM=y
269 +# CONFIG_MEMTEST is not set
270 +# CONFIG_MK8 is not set
271 +# CONFIG_MPSC is not set
272 +CONFIG_MCORE2=y
273 +# CONFIG_MATOM is not set
274 +# CONFIG_GENERIC_CPU is not set
275 +CONFIG_X86_INTERNODE_CACHE_SHIFT=6
276 +CONFIG_X86_CMPXCHG=y
277 +CONFIG_CMPXCHG_LOCAL=y
278 +CONFIG_X86_L1_CACHE_SHIFT=6
279 +CONFIG_X86_XADD=y
280 +CONFIG_X86_WP_WORKS_OK=y
281 +CONFIG_X86_INTEL_USERCOPY=y
282 +CONFIG_X86_USE_PPRO_CHECKSUM=y
283 +CONFIG_X86_P6_NOP=y
284 +CONFIG_X86_TSC=y
285 +CONFIG_X86_CMPXCHG64=y
286 +CONFIG_X86_CMOV=y
287 +CONFIG_X86_MINIMUM_CPU_FAMILY=64
288 +CONFIG_X86_DEBUGCTLMSR=y
289 +# CONFIG_PROCESSOR_SELECT is not set
290 +CONFIG_CPU_SUP_INTEL=y
291 +CONFIG_CPU_SUP_AMD=y
292 +CONFIG_CPU_SUP_CENTAUR=y
293 +CONFIG_HPET_TIMER=y
294 +CONFIG_HPET_EMULATE_RTC=y
295 +CONFIG_DMI=y
296 +CONFIG_GART_IOMMU=y
297 +# CONFIG_CALGARY_IOMMU is not set
298 +# CONFIG_AMD_IOMMU is not set
299 +CONFIG_SWIOTLB=y
300 +CONFIG_IOMMU_HELPER=y
301 +# CONFIG_IOMMU_API is not set
302 +# CONFIG_MAXSMP is not set
303 +CONFIG_NR_CPUS=32
304 +CONFIG_SCHED_SMT=y
305 +CONFIG_SCHED_MC=y
306 +# CONFIG_IRQ_TIME_ACCOUNTING is not set
307 +CONFIG_PREEMPT_NONE=y
308 +# CONFIG_PREEMPT_VOLUNTARY is not set
309 +# CONFIG_PREEMPT is not set
310 +CONFIG_X86_LOCAL_APIC=y
311 +CONFIG_X86_IO_APIC=y
312 +# CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS is not set
313 +CONFIG_X86_MCE=y
314 +CONFIG_X86_MCE_INTEL=y
315 +CONFIG_X86_MCE_AMD=y
316 +CONFIG_X86_MCE_THRESHOLD=y
317 +# CONFIG_X86_MCE_INJECT is not set
318 +CONFIG_X86_THERMAL_VECTOR=y
319 +# CONFIG_I8K is not set
320 +# CONFIG_MICROCODE is not set
321 +CONFIG_X86_MSR=y
322 +CONFIG_X86_CPUID=y
323 +CONFIG_ARCH_PHYS_ADDR_T_64BIT=y
324 +CONFIG_ARCH_DMA_ADDR_T_64BIT=y
325 +CONFIG_DIRECT_GBPAGES=y
326 +# CONFIG_NUMA is not set
327 +CONFIG_ARCH_SPARSEMEM_ENABLE=y
328 +CONFIG_ARCH_SPARSEMEM_DEFAULT=y
329 +CONFIG_ARCH_SELECT_MEMORY_MODEL=y
330 +CONFIG_ILLEGAL_POINTER_VALUE=0xdead000000000000
331 +CONFIG_SELECT_MEMORY_MODEL=y
332 +CONFIG_SPARSEMEM_MANUAL=y
333 +CONFIG_SPARSEMEM=y
334 +CONFIG_HAVE_MEMORY_PRESENT=y
335 +CONFIG_SPARSEMEM_EXTREME=y
336 +CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y
337 +CONFIG_SPARSEMEM_ALLOC_MEM_MAP_TOGETHER=y
338 +CONFIG_SPARSEMEM_VMEMMAP=y
339 +CONFIG_HAVE_MEMBLOCK=y
340 +# CONFIG_MEMORY_HOTPLUG is not set
341 +CONFIG_PAGEFLAGS_EXTENDED=y
342 +CONFIG_SPLIT_PTLOCK_CPUS=4
343 +CONFIG_COMPACTION=y
344 +CONFIG_MIGRATION=y
345 +CONFIG_PHYS_ADDR_T_64BIT=y
346 +CONFIG_ZONE_DMA_FLAG=1
347 +CONFIG_BOUNCE=y
348 +CONFIG_VIRT_TO_BUS=y
349 +# CONFIG_KSM is not set
350 +CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
351 +CONFIG_ARCH_SUPPORTS_MEMORY_FAILURE=y
352 +# CONFIG_MEMORY_FAILURE is not set
353 +CONFIG_TRANSPARENT_HUGEPAGE=y
354 +CONFIG_TRANSPARENT_HUGEPAGE_ALWAYS=y
355 +# CONFIG_TRANSPARENT_HUGEPAGE_MADVISE is not set
356 +CONFIG_CLEANCACHE=y
357 +# CONFIG_X86_CHECK_BIOS_CORRUPTION is not set
358 +CONFIG_X86_RESERVE_LOW=4
359 +CONFIG_MTRR=y
360 +CONFIG_MTRR_SANITIZER=y
361 +CONFIG_MTRR_SANITIZER_ENABLE_DEFAULT=0
362 +CONFIG_MTRR_SANITIZER_SPARE_REG_NR_DEFAULT=1
363 +CONFIG_X86_PAT=y
364 +CONFIG_ARCH_USES_PG_UNCACHED=y
365 +# CONFIG_EFI is not set
366 +CONFIG_SECCOMP=y
367 +# CONFIG_CC_STACKPROTECTOR is not set
368 +CONFIG_HZ_100=y
369 +# CONFIG_HZ_250 is not set
370 +# CONFIG_HZ_300 is not set
371 +# CONFIG_HZ_1000 is not set
372 +CONFIG_HZ=100
373 +CONFIG_SCHED_HRTICK=y
374 +# CONFIG_KEXEC is not set
375 +# CONFIG_CRASH_DUMP is not set
376 +CONFIG_PHYSICAL_START=0x1000000
377 +# CONFIG_RELOCATABLE is not set
378 +CONFIG_PHYSICAL_ALIGN=0x1000000
379 +CONFIG_HOTPLUG_CPU=y
380 +# CONFIG_COMPAT_VDSO is not set
381 +# CONFIG_CMDLINE_BOOL is not set
382 +CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
383 +
384 +#
385 +# Power management and ACPI options
386 +#
387 +CONFIG_SUSPEND=y
388 +CONFIG_SUSPEND_FREEZER=y
389 +# CONFIG_HIBERNATION is not set
390 +CONFIG_PM_SLEEP=y
391 +CONFIG_PM_SLEEP_SMP=y
392 +# CONFIG_PM_RUNTIME is not set
393 +CONFIG_PM=y
394 +# CONFIG_PM_DEBUG is not set
395 +CONFIG_ACPI=y
396 +CONFIG_ACPI_SLEEP=y
397 +# CONFIG_ACPI_PROCFS is not set
398 +# CONFIG_ACPI_PROCFS_POWER is not set
399 +# CONFIG_ACPI_EC_DEBUGFS is not set
400 +CONFIG_ACPI_PROC_EVENT=y
401 +CONFIG_ACPI_AC=y
402 +CONFIG_ACPI_BATTERY=y
403 +CONFIG_ACPI_BUTTON=y
404 +CONFIG_ACPI_FAN=y
405 +# CONFIG_ACPI_DOCK is not set
406 +CONFIG_ACPI_PROCESSOR=y
407 +CONFIG_ACPI_HOTPLUG_CPU=y
408 +# CONFIG_ACPI_PROCESSOR_AGGREGATOR is not set
409 +CONFIG_ACPI_THERMAL=y
410 +# CONFIG_ACPI_CUSTOM_DSDT is not set
411 +CONFIG_ACPI_BLACKLIST_YEAR=0
412 +# CONFIG_ACPI_DEBUG is not set
413 +# CONFIG_ACPI_PCI_SLOT is not set
414 +CONFIG_X86_PM_TIMER=y
415 +CONFIG_ACPI_CONTAINER=y
416 +# CONFIG_ACPI_SBS is not set
417 +# CONFIG_ACPI_HED is not set
418 +# CONFIG_ACPI_APEI is not set
419 +# CONFIG_SFI is not set
420 +
421 +#
422 +# CPU Frequency scaling
423 +#
424 +# CONFIG_CPU_FREQ is not set
425 +CONFIG_CPU_IDLE=y
426 +CONFIG_CPU_IDLE_GOV_LADDER=y
427 +# CONFIG_INTEL_IDLE is not set
428 +
429 +#
430 +# Memory power savings
431 +#
432 +# CONFIG_I7300_IDLE is not set
433 +
434 +#
435 +# Bus options (PCI etc.)
436 +#
437 +CONFIG_PCI=y
438 +CONFIG_PCI_DIRECT=y
439 +# CONFIG_PCI_MMCONFIG is not set
440 +CONFIG_PCI_DOMAINS=y
441 +# CONFIG_PCI_CNB20LE_QUIRK is not set
442 +CONFIG_PCIEPORTBUS=y
443 +# CONFIG_PCIEAER is not set
444 +CONFIG_PCIEASPM=y
445 +# CONFIG_PCIEASPM_DEBUG is not set
446 +CONFIG_ARCH_SUPPORTS_MSI=y
447 +# CONFIG_PCI_MSI is not set
448 +# CONFIG_PCI_DEBUG is not set
449 +# CONFIG_PCI_STUB is not set
450 +CONFIG_HT_IRQ=y
451 +# CONFIG_PCI_IOV is not set
452 +CONFIG_PCI_IOAPIC=y
453 +CONFIG_PCI_LABEL=y
454 +CONFIG_ISA_DMA_API=y
455 +CONFIG_AMD_NB=y
456 +# CONFIG_PCCARD is not set
457 +# CONFIG_HOTPLUG_PCI is not set
458 +# CONFIG_RAPIDIO is not set
459 +
460 +#
461 +# Executable file formats / Emulations
462 +#
463 +CONFIG_BINFMT_ELF=y
464 +CONFIG_COMPAT_BINFMT_ELF=y
465 +# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
466 +# CONFIG_HAVE_AOUT is not set
467 +# CONFIG_BINFMT_MISC is not set
468 +CONFIG_IA32_EMULATION=y
469 +# CONFIG_IA32_AOUT is not set
470 +CONFIG_COMPAT=y
471 +CONFIG_COMPAT_FOR_U64_ALIGNMENT=y
472 +CONFIG_SYSVIPC_COMPAT=y
473 +CONFIG_HAVE_TEXT_POKE_SMP=y
474 +CONFIG_NET=y
475 +
476 +#
477 +# Networking options
478 +#
479 +CONFIG_PACKET=y
480 +CONFIG_UNIX=y
481 +CONFIG_XFRM=y
482 +CONFIG_XFRM_USER=y
483 +# CONFIG_XFRM_SUB_POLICY is not set
484 +# CONFIG_XFRM_MIGRATE is not set
485 +# CONFIG_XFRM_STATISTICS is not set
486 +CONFIG_XFRM_IPCOMP=y
487 +# CONFIG_NET_KEY is not set
488 +CONFIG_IP_MULTICAST=y
489 +# CONFIG_IP_ADVANCED_ROUTER is not set
490 +# CONFIG_IP_PNP is not set
491 +# CONFIG_NET_IPIP is not set
492 +# CONFIG_NET_IPGRE_DEMUX is not set
493 +# CONFIG_IP_MROUTE is not set
494 +# CONFIG_ARPD is not set
495 +CONFIG_SYN_COOKIES=y
496 +# CONFIG_INET_AH is not set
497 +# CONFIG_INET_ESP is not set
498 +# CONFIG_INET_IPCOMP is not set
499 +# CONFIG_INET_XFRM_TUNNEL is not set
500 +CONFIG_INET_TUNNEL=y
501 +# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
502 +# CONFIG_INET_XFRM_MODE_TUNNEL is not set
503 +# CONFIG_INET_XFRM_MODE_BEET is not set
504 +CONFIG_INET_LRO=y
505 +CONFIG_INET_DIAG=y
506 +CONFIG_INET_TCP_DIAG=y
507 +# CONFIG_TCP_CONG_ADVANCED is not set
508 +CONFIG_TCP_CONG_CUBIC=y
509 +CONFIG_DEFAULT_TCP_CONG="cubic"
510 +# CONFIG_TCP_MD5SIG is not set
511 +CONFIG_IPV6=y
512 +# CONFIG_IPV6_PRIVACY is not set
513 +# CONFIG_IPV6_ROUTER_PREF is not set
514 +# CONFIG_IPV6_OPTIMISTIC_DAD is not set
515 +CONFIG_INET6_AH=y
516 +CONFIG_INET6_ESP=y
517 +CONFIG_INET6_IPCOMP=y
518 +# CONFIG_IPV6_MIP6 is not set
519 +CONFIG_INET6_XFRM_TUNNEL=y
520 +CONFIG_INET6_TUNNEL=y
521 +CONFIG_INET6_XFRM_MODE_TRANSPORT=y
522 +CONFIG_INET6_XFRM_MODE_TUNNEL=y
523 +CONFIG_INET6_XFRM_MODE_BEET=y
524 +# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
525 +CONFIG_IPV6_SIT=y
526 +# CONFIG_IPV6_SIT_6RD is not set
527 +CONFIG_IPV6_NDISC_NODETYPE=y
528 +# CONFIG_IPV6_TUNNEL is not set
529 +# CONFIG_IPV6_MULTIPLE_TABLES is not set
530 +# CONFIG_IPV6_MROUTE is not set
531 +# CONFIG_NETWORK_SECMARK is not set
532 +# CONFIG_NETWORK_PHY_TIMESTAMPING is not set
533 +CONFIG_NETFILTER=y
534 +# CONFIG_NETFILTER_DEBUG is not set
535 +# CONFIG_NETFILTER_ADVANCED is not set
536 +
537 +#
538 +# Core Netfilter Configuration
539 +#
540 +CONFIG_NETFILTER_NETLINK=y
541 +CONFIG_NETFILTER_NETLINK_LOG=y
542 +CONFIG_NF_CONNTRACK=y
543 +CONFIG_NF_CONNTRACK_FTP=y
544 +CONFIG_NF_CONNTRACK_IRC=y
545 +CONFIG_NF_CONNTRACK_SIP=y
546 +CONFIG_NF_CT_NETLINK=y
547 +CONFIG_NETFILTER_XTABLES=y
548 +
549 +#
550 +# Xtables combined modules
551 +#
552 +CONFIG_NETFILTER_XT_MARK=y
553 +
554 +#
555 +# Xtables targets
556 +#
557 +CONFIG_NETFILTER_XT_TARGET_NFLOG=y
558 +CONFIG_NETFILTER_XT_TARGET_TCPMSS=y
559 +
560 +#
561 +# Xtables matches
562 +#
563 +CONFIG_NETFILTER_XT_MATCH_CONNTRACK=y
564 +CONFIG_NETFILTER_XT_MATCH_POLICY=y
565 +CONFIG_NETFILTER_XT_MATCH_STATE=y
566 +# CONFIG_IP_SET is not set
567 +CONFIG_IP_VS=y
568 +CONFIG_IP_VS_IPV6=y
569 +# CONFIG_IP_VS_DEBUG is not set
570 +CONFIG_IP_VS_TAB_BITS=12
571 +
572 +#
573 +# IPVS transport protocol load balancing support
574 +#
575 +# CONFIG_IP_VS_PROTO_TCP is not set
576 +# CONFIG_IP_VS_PROTO_UDP is not set
577 +# CONFIG_IP_VS_PROTO_AH_ESP is not set
578 +# CONFIG_IP_VS_PROTO_ESP is not set
579 +# CONFIG_IP_VS_PROTO_AH is not set
580 +# CONFIG_IP_VS_PROTO_SCTP is not set
581 +
582 +#
583 +# IPVS scheduler
584 +#
585 +# CONFIG_IP_VS_RR is not set
586 +# CONFIG_IP_VS_WRR is not set
587 +# CONFIG_IP_VS_LC is not set
588 +# CONFIG_IP_VS_WLC is not set
589 +# CONFIG_IP_VS_LBLC is not set
590 +# CONFIG_IP_VS_LBLCR is not set
591 +# CONFIG_IP_VS_DH is not set
592 +# CONFIG_IP_VS_SH is not set
593 +# CONFIG_IP_VS_SED is not set
594 +# CONFIG_IP_VS_NQ is not set
595 +
596 +#
597 +# IPVS application helper
598 +#
599 +# CONFIG_IP_VS_NFCT is not set
600 +
601 +#
602 +# IP: Netfilter Configuration
603 +#
604 +CONFIG_NF_DEFRAG_IPV4=y
605 +CONFIG_NF_CONNTRACK_IPV4=y
606 +# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set
607 +CONFIG_IP_NF_IPTABLES=y
608 +CONFIG_IP_NF_FILTER=y
609 +CONFIG_IP_NF_TARGET_REJECT=y
610 +CONFIG_IP_NF_TARGET_LOG=y
611 +CONFIG_IP_NF_TARGET_ULOG=y
612 +CONFIG_NF_NAT=y
613 +CONFIG_NF_NAT_NEEDED=y
614 +CONFIG_IP_NF_TARGET_MASQUERADE=y
615 +CONFIG_NF_NAT_FTP=y
616 +CONFIG_NF_NAT_IRC=y
617 +# CONFIG_NF_NAT_TFTP is not set
618 +# CONFIG_NF_NAT_AMANDA is not set
619 +# CONFIG_NF_NAT_PPTP is not set
620 +# CONFIG_NF_NAT_H323 is not set
621 +CONFIG_NF_NAT_SIP=y
622 +CONFIG_IP_NF_MANGLE=y
623 +
624 +#
625 +# IPv6: Netfilter Configuration
626 +#
627 +# CONFIG_NF_DEFRAG_IPV6 is not set
628 +# CONFIG_NF_CONNTRACK_IPV6 is not set
629 +CONFIG_IP6_NF_IPTABLES=y
630 +CONFIG_IP6_NF_MATCH_IPV6HEADER=y
631 +CONFIG_IP6_NF_TARGET_LOG=y
632 +CONFIG_IP6_NF_FILTER=y
633 +CONFIG_IP6_NF_TARGET_REJECT=y
634 +CONFIG_IP6_NF_MANGLE=y
635 +# CONFIG_IP_DCCP is not set
636 +CONFIG_IP_SCTP=y
637 +# CONFIG_SCTP_DBG_MSG is not set
638 +# CONFIG_SCTP_DBG_OBJCNT is not set
639 +# CONFIG_SCTP_HMAC_NONE is not set
640 +# CONFIG_SCTP_HMAC_SHA1 is not set
641 +CONFIG_SCTP_HMAC_MD5=y
642 +# CONFIG_RDS is not set
643 +# CONFIG_TIPC is not set
644 +# CONFIG_ATM is not set
645 +# CONFIG_L2TP is not set
646 +# CONFIG_BRIDGE is not set
647 +# CONFIG_NET_DSA is not set
648 +# CONFIG_VLAN_8021Q is not set
649 +# CONFIG_DECNET is not set
650 +# CONFIG_LLC2 is not set
651 +# CONFIG_IPX is not set
652 +# CONFIG_ATALK is not set
653 +CONFIG_X25=y
654 +# CONFIG_LAPB is not set
655 +# CONFIG_ECONET is not set
656 +# CONFIG_WAN_ROUTER is not set
657 +# CONFIG_PHONET is not set
658 +# CONFIG_IEEE802154 is not set
659 +# CONFIG_NET_SCHED is not set
660 +# CONFIG_DCB is not set
661 +# CONFIG_BATMAN_ADV is not set
662 +CONFIG_RPS=y
663 +CONFIG_RFS_ACCEL=y
664 +CONFIG_XPS=y
665 +CONFIG_HAVE_BPF_JIT=y
666 +
667 +#
668 +# Network testing
669 +#
670 +# CONFIG_NET_PKTGEN is not set
671 +# CONFIG_HAMRADIO is not set
672 +# CONFIG_CAN is not set
673 +# CONFIG_IRDA is not set
674 +# CONFIG_BT is not set
675 +# CONFIG_AF_RXRPC is not set
676 +# CONFIG_WIRELESS is not set
677 +# CONFIG_WIMAX is not set
678 +# CONFIG_RFKILL is not set
679 +# CONFIG_NET_9P is not set
680 +# CONFIG_CAIF is not set
681 +# CONFIG_CEPH_LIB is not set
682 +
683 +#
684 +# Device Drivers
685 +#
686 +
687 +#
688 +# Generic Driver Options
689 +#
690 +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
691 +CONFIG_DEVTMPFS=y
692 +# CONFIG_DEVTMPFS_MOUNT is not set
693 +CONFIG_STANDALONE=y
694 +CONFIG_PREVENT_FIRMWARE_BUILD=y
695 +CONFIG_FW_LOADER=y
696 +CONFIG_FIRMWARE_IN_KERNEL=y
697 +CONFIG_EXTRA_FIRMWARE=""
698 +# CONFIG_DEBUG_DRIVER is not set
699 +# CONFIG_DEBUG_DEVRES is not set
700 +# CONFIG_SYS_HYPERVISOR is not set
701 +# CONFIG_CONNECTOR is not set
702 +# CONFIG_MTD is not set
703 +# CONFIG_PARPORT is not set
704 +CONFIG_PNP=y
705 +CONFIG_PNP_DEBUG_MESSAGES=y
706 +
707 +#
708 +# Protocols
709 +#
710 +CONFIG_PNPACPI=y
711 +CONFIG_BLK_DEV=y
712 +# CONFIG_BLK_DEV_FD is not set
713 +# CONFIG_BLK_CPQ_DA is not set
714 +# CONFIG_BLK_CPQ_CISS_DA is not set
715 +# CONFIG_BLK_DEV_DAC960 is not set
716 +# CONFIG_BLK_DEV_UMEM is not set
717 +# CONFIG_BLK_DEV_COW_COMMON is not set
718 +CONFIG_BLK_DEV_LOOP=y
719 +# CONFIG_BLK_DEV_CRYPTOLOOP is not set
720 +
721 +#
722 +# DRBD disabled because PROC_FS, INET or CONNECTOR not selected
723 +#
724 +CONFIG_BLK_DEV_VROOT=y
725 +# CONFIG_BLK_DEV_NBD is not set
726 +# CONFIG_BLK_DEV_SX8 is not set
727 +# CONFIG_BLK_DEV_RAM is not set
728 +# CONFIG_CDROM_PKTCDVD is not set
729 +# CONFIG_ATA_OVER_ETH is not set
730 +# CONFIG_BLK_DEV_HD is not set
731 +# CONFIG_BLK_DEV_RBD is not set
732 +# CONFIG_SENSORS_LIS3LV02D is not set
733 +# CONFIG_MISC_DEVICES is not set
734 +CONFIG_HAVE_IDE=y
735 +CONFIG_IDE=y
736 +
737 +#
738 +# Please see Documentation/ide/ide.txt for help/info on IDE drives
739 +#
740 +CONFIG_IDE_XFER_MODE=y
741 +# CONFIG_BLK_DEV_IDE_SATA is not set
742 +CONFIG_IDE_GD=y
743 +CONFIG_IDE_GD_ATA=y
744 +# CONFIG_IDE_GD_ATAPI is not set
745 +# CONFIG_BLK_DEV_IDECD is not set
746 +# CONFIG_BLK_DEV_IDETAPE is not set
747 +# CONFIG_BLK_DEV_IDEACPI is not set
748 +CONFIG_IDE_TASK_IOCTL=y
749 +CONFIG_IDE_PROC_FS=y
750 +
751 +#
752 +# IDE chipset support/bugfixes
753 +#
754 +CONFIG_IDE_GENERIC=y
755 +CONFIG_BLK_DEV_PLATFORM=y
756 +# CONFIG_BLK_DEV_CMD640 is not set
757 +# CONFIG_BLK_DEV_IDEPNP is not set
758 +CONFIG_BLK_DEV_IDEDMA_SFF=y
759 +
760 +#
761 +# PCI IDE chipsets support
762 +#
763 +CONFIG_BLK_DEV_IDEPCI=y
764 +CONFIG_IDEPCI_PCIBUS_ORDER=y
765 +# CONFIG_BLK_DEV_OFFBOARD is not set
766 +CONFIG_BLK_DEV_GENERIC=y
767 +# CONFIG_BLK_DEV_OPTI621 is not set
768 +# CONFIG_BLK_DEV_RZ1000 is not set
769 +CONFIG_BLK_DEV_IDEDMA_PCI=y
770 +# CONFIG_BLK_DEV_AEC62XX is not set
771 +# CONFIG_BLK_DEV_ALI15X3 is not set
772 +# CONFIG_BLK_DEV_AMD74XX is not set
773 +# CONFIG_BLK_DEV_ATIIXP is not set
774 +# CONFIG_BLK_DEV_CMD64X is not set
775 +# CONFIG_BLK_DEV_TRIFLEX is not set
776 +# CONFIG_BLK_DEV_CS5520 is not set
777 +# CONFIG_BLK_DEV_CS5530 is not set
778 +# CONFIG_BLK_DEV_HPT366 is not set
779 +# CONFIG_BLK_DEV_JMICRON is not set
780 +# CONFIG_BLK_DEV_SC1200 is not set
781 +CONFIG_BLK_DEV_PIIX=y
782 +# CONFIG_BLK_DEV_IT8172 is not set
783 +# CONFIG_BLK_DEV_IT8213 is not set
784 +# CONFIG_BLK_DEV_IT821X is not set
785 +# CONFIG_BLK_DEV_NS87415 is not set
786 +# CONFIG_BLK_DEV_PDC202XX_OLD is not set
787 +# CONFIG_BLK_DEV_PDC202XX_NEW is not set
788 +# CONFIG_BLK_DEV_SVWKS is not set
789 +# CONFIG_BLK_DEV_SIIMAGE is not set
790 +# CONFIG_BLK_DEV_SIS5513 is not set
791 +# CONFIG_BLK_DEV_SLC90E66 is not set
792 +# CONFIG_BLK_DEV_TRM290 is not set
793 +# CONFIG_BLK_DEV_VIA82CXXX is not set
794 +# CONFIG_BLK_DEV_TC86C001 is not set
795 +CONFIG_BLK_DEV_IDEDMA=y
796 +
797 +#
798 +# SCSI device support
799 +#
800 +CONFIG_SCSI_MOD=y
801 +# CONFIG_RAID_ATTRS is not set
802 +CONFIG_SCSI=y
803 +CONFIG_SCSI_DMA=y
804 +# CONFIG_SCSI_TGT is not set
805 +# CONFIG_SCSI_NETLINK is not set
806 +# CONFIG_SCSI_PROC_FS is not set
807 +
808 +#
809 +# SCSI support type (disk, tape, CD-ROM)
810 +#
811 +CONFIG_BLK_DEV_SD=y
812 +# CONFIG_CHR_DEV_ST is not set
813 +# CONFIG_CHR_DEV_OSST is not set
814 +# CONFIG_BLK_DEV_SR is not set
815 +# CONFIG_CHR_DEV_SG is not set
816 +# CONFIG_CHR_DEV_SCH is not set
817 +# CONFIG_SCSI_MULTI_LUN is not set
818 +# CONFIG_SCSI_CONSTANTS is not set
819 +# CONFIG_SCSI_LOGGING is not set
820 +# CONFIG_SCSI_SCAN_ASYNC is not set
821 +
822 +#
823 +# SCSI Transports
824 +#
825 +# CONFIG_SCSI_SPI_ATTRS is not set
826 +# CONFIG_SCSI_FC_ATTRS is not set
827 +# CONFIG_SCSI_ISCSI_ATTRS is not set
828 +# CONFIG_SCSI_SAS_ATTRS is not set
829 +# CONFIG_SCSI_SAS_LIBSAS is not set
830 +# CONFIG_SCSI_SRP_ATTRS is not set
831 +# CONFIG_SCSI_LOWLEVEL is not set
832 +# CONFIG_SCSI_DH is not set
833 +# CONFIG_SCSI_OSD_INITIATOR is not set
834 +CONFIG_ATA=y
835 +# CONFIG_ATA_NONSTANDARD is not set
836 +CONFIG_ATA_VERBOSE_ERROR=y
837 +CONFIG_ATA_ACPI=y
838 +CONFIG_SATA_PMP=y
839 +
840 +#
841 +# Controllers with non-SFF native interface
842 +#
843 +CONFIG_SATA_AHCI=y
844 +# CONFIG_SATA_AHCI_PLATFORM is not set
845 +# CONFIG_SATA_INIC162X is not set
846 +# CONFIG_SATA_ACARD_AHCI is not set
847 +# CONFIG_SATA_SIL24 is not set
848 +# CONFIG_ATA_SFF is not set
849 +CONFIG_MD=y
850 +CONFIG_BLK_DEV_MD=y
851 +CONFIG_MD_AUTODETECT=y
852 +# CONFIG_MD_LINEAR is not set
853 +CONFIG_MD_RAID0=y
854 +CONFIG_MD_RAID1=y
855 +CONFIG_MD_RAID10=y
856 +CONFIG_MD_RAID456=y
857 +# CONFIG_MULTICORE_RAID456 is not set
858 +# CONFIG_MD_MULTIPATH is not set
859 +# CONFIG_MD_FAULTY is not set
860 +CONFIG_BLK_DEV_DM=y
861 +# CONFIG_DM_DEBUG is not set
862 +# CONFIG_DM_CRYPT is not set
863 +CONFIG_DM_SNAPSHOT=y
864 +CONFIG_DM_MIRROR=y
865 +CONFIG_DM_RAID=y
866 +# CONFIG_DM_LOG_USERSPACE is not set
867 +# CONFIG_DM_ZERO is not set
868 +# CONFIG_DM_MULTIPATH is not set
869 +# CONFIG_DM_DELAY is not set
870 +# CONFIG_DM_UEVENT is not set
871 +# CONFIG_DM_FLAKEY is not set
872 +# CONFIG_TARGET_CORE is not set
873 +# CONFIG_FUSION is not set
874 +
875 +#
876 +# IEEE 1394 (FireWire) support
877 +#
878 +# CONFIG_FIREWIRE is not set
879 +# CONFIG_FIREWIRE_NOSY is not set
880 +# CONFIG_I2O is not set
881 +# CONFIG_MACINTOSH_DRIVERS is not set
882 +CONFIG_NETDEVICES=y
883 +# CONFIG_DUMMY is not set
884 +# CONFIG_BONDING is not set
885 +# CONFIG_MACVLAN is not set
886 +# CONFIG_EQUALIZER is not set
887 +CONFIG_TUN=y
888 +# CONFIG_VETH is not set
889 +# CONFIG_NET_SB1000 is not set
890 +# CONFIG_ARCNET is not set
891 +CONFIG_MII=y
892 +# CONFIG_PHYLIB is not set
893 +# CONFIG_NET_ETHERNET is not set
894 +CONFIG_NETDEV_1000=y
895 +# CONFIG_ACENIC is not set
896 +# CONFIG_DL2K is not set
897 +# CONFIG_E1000 is not set
898 +# CONFIG_E1000E is not set
899 +# CONFIG_IP1000 is not set
900 +# CONFIG_IGB is not set
901 +# CONFIG_IGBVF is not set
902 +# CONFIG_NS83820 is not set
903 +# CONFIG_HAMACHI is not set
904 +# CONFIG_YELLOWFIN is not set
905 +CONFIG_R8169=y
906 +# CONFIG_SIS190 is not set
907 +# CONFIG_SKGE is not set
908 +# CONFIG_SKY2 is not set
909 +# CONFIG_VIA_VELOCITY is not set
910 +# CONFIG_TIGON3 is not set
911 +# CONFIG_BNX2 is not set
912 +# CONFIG_CNIC is not set
913 +# CONFIG_QLA3XXX is not set
914 +# CONFIG_ATL1 is not set
915 +# CONFIG_ATL1E is not set
916 +# CONFIG_ATL1C is not set
917 +# CONFIG_JME is not set
918 +# CONFIG_STMMAC_ETH is not set
919 +# CONFIG_PCH_GBE is not set
920 +# CONFIG_NETDEV_10000 is not set
921 +# CONFIG_TR is not set
922 +# CONFIG_WLAN is not set
923 +
924 +#
925 +# Enable WiMAX (Networking options) to see the WiMAX drivers
926 +#
927 +# CONFIG_WAN is not set
928 +
929 +#
930 +# CAIF transport drivers
931 +#
932 +# CONFIG_FDDI is not set
933 +# CONFIG_HIPPI is not set
934 +# CONFIG_PPP is not set
935 +# CONFIG_SLIP is not set
936 +# CONFIG_NET_FC is not set
937 +# CONFIG_NETCONSOLE is not set
938 +# CONFIG_NETPOLL is not set
939 +# CONFIG_NET_POLL_CONTROLLER is not set
940 +# CONFIG_VMXNET3 is not set
941 +# CONFIG_ISDN is not set
942 +# CONFIG_PHONE is not set
943 +
944 +#
945 +# Input device support
946 +#
947 +CONFIG_INPUT=y
948 +# CONFIG_INPUT_FF_MEMLESS is not set
949 +# CONFIG_INPUT_POLLDEV is not set
950 +# CONFIG_INPUT_SPARSEKMAP is not set
951 +
952 +#
953 +# Userland interfaces
954 +#
955 +CONFIG_INPUT_MOUSEDEV=y
956 +# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
957 +CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
958 +CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
959 +# CONFIG_INPUT_JOYDEV is not set
960 +# CONFIG_INPUT_EVDEV is not set
961 +# CONFIG_INPUT_EVBUG is not set
962 +
963 +#
964 +# Input Device Drivers
965 +#
966 +CONFIG_INPUT_KEYBOARD=y
967 +CONFIG_KEYBOARD_ATKBD=y
968 +# CONFIG_KEYBOARD_LKKBD is not set
969 +# CONFIG_KEYBOARD_NEWTON is not set
970 +# CONFIG_KEYBOARD_OPENCORES is not set
971 +# CONFIG_KEYBOARD_STOWAWAY is not set
972 +# CONFIG_KEYBOARD_SUNKBD is not set
973 +# CONFIG_KEYBOARD_XTKBD is not set
974 +# CONFIG_INPUT_MOUSE is not set
975 +# CONFIG_INPUT_JOYSTICK is not set
976 +# CONFIG_INPUT_TABLET is not set
977 +# CONFIG_INPUT_TOUCHSCREEN is not set
978 +# CONFIG_INPUT_MISC is not set
979 +
980 +#
981 +# Hardware I/O ports
982 +#
983 +CONFIG_SERIO=y
984 +CONFIG_SERIO_I8042=y
985 +# CONFIG_SERIO_SERPORT is not set
986 +# CONFIG_SERIO_CT82C710 is not set
987 +# CONFIG_SERIO_PCIPS2 is not set
988 +CONFIG_SERIO_LIBPS2=y
989 +# CONFIG_SERIO_RAW is not set
990 +# CONFIG_SERIO_ALTERA_PS2 is not set
991 +# CONFIG_SERIO_PS2MULT is not set
992 +# CONFIG_GAMEPORT is not set
993 +
994 +#
995 +# Character devices
996 +#
997 +CONFIG_VT=y
998 +CONFIG_CONSOLE_TRANSLATIONS=y
999 +CONFIG_VT_CONSOLE=y
1000 +CONFIG_HW_CONSOLE=y
1001 +# CONFIG_VT_HW_CONSOLE_BINDING is not set
1002 +CONFIG_UNIX98_PTYS=y
1003 +CONFIG_DEVPTS_MULTIPLE_INSTANCES=y
1004 +CONFIG_LEGACY_PTYS=y
1005 +CONFIG_LEGACY_PTY_COUNT=0
1006 +# CONFIG_SERIAL_NONSTANDARD is not set
1007 +# CONFIG_NOZOMI is not set
1008 +# CONFIG_N_GSM is not set
1009 +# CONFIG_TRACE_SINK is not set
1010 +# CONFIG_DEVKMEM is not set
1011 +
1012 +#
1013 +# Serial drivers
1014 +#
1015 +CONFIG_SERIAL_8250=y
1016 +CONFIG_SERIAL_8250_CONSOLE=y
1017 +CONFIG_FIX_EARLYCON_MEM=y
1018 +CONFIG_SERIAL_8250_PCI=y
1019 +CONFIG_SERIAL_8250_PNP=y
1020 +CONFIG_SERIAL_8250_NR_UARTS=4
1021 +CONFIG_SERIAL_8250_RUNTIME_UARTS=4
1022 +# CONFIG_SERIAL_8250_EXTENDED is not set
1023 +
1024 +#
1025 +# Non-8250 serial port support
1026 +#
1027 +# CONFIG_SERIAL_MFD_HSU is not set
1028 +CONFIG_SERIAL_CORE=y
1029 +CONFIG_SERIAL_CORE_CONSOLE=y
1030 +# CONFIG_SERIAL_JSM is not set
1031 +# CONFIG_SERIAL_TIMBERDALE is not set
1032 +# CONFIG_SERIAL_ALTERA_JTAGUART is not set
1033 +# CONFIG_SERIAL_ALTERA_UART is not set
1034 +# CONFIG_SERIAL_PCH_UART is not set
1035 +# CONFIG_SERIAL_XILINX_PS_UART is not set
1036 +CONFIG_TTY_PRINTK=y
1037 +# CONFIG_IPMI_HANDLER is not set
1038 +# CONFIG_HW_RANDOM is not set
1039 +# CONFIG_NVRAM is not set
1040 +CONFIG_RTC=y
1041 +# CONFIG_R3964 is not set
1042 +# CONFIG_APPLICOM is not set
1043 +# CONFIG_MWAVE is not set
1044 +# CONFIG_RAW_DRIVER is not set
1045 +# CONFIG_HPET is not set
1046 +# CONFIG_HANGCHECK_TIMER is not set
1047 +# CONFIG_TCG_TPM is not set
1048 +# CONFIG_TELCLOCK is not set
1049 +CONFIG_DEVPORT=y
1050 +CONFIG_RAMOOPS=y
1051 +# CONFIG_I2C is not set
1052 +# CONFIG_SPI is not set
1053 +
1054 +#
1055 +# PPS support
1056 +#
1057 +# CONFIG_PPS is not set
1058 +
1059 +#
1060 +# PPS generators support
1061 +#
1062 +
1063 +#
1064 +# PTP clock support
1065 +#
1066 +
1067 +#
1068 +# Enable Device Drivers -> PPS to see the PTP clock options.
1069 +#
1070 +CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
1071 +# CONFIG_GPIOLIB is not set
1072 +# CONFIG_W1 is not set
1073 +CONFIG_POWER_SUPPLY=y
1074 +# CONFIG_POWER_SUPPLY_DEBUG is not set
1075 +# CONFIG_PDA_POWER is not set
1076 +# CONFIG_TEST_POWER is not set
1077 +# CONFIG_BATTERY_DS2780 is not set
1078 +# CONFIG_BATTERY_BQ27x00 is not set
1079 +# CONFIG_CHARGER_MAX8903 is not set
1080 +# CONFIG_HWMON is not set
1081 +CONFIG_THERMAL=y
1082 +# CONFIG_WATCHDOG is not set
1083 +CONFIG_SSB_POSSIBLE=y
1084 +
1085 +#
1086 +# Sonics Silicon Backplane
1087 +#
1088 +# CONFIG_SSB is not set
1089 +CONFIG_BCMA_POSSIBLE=y
1090 +
1091 +#
1092 +# Broadcom specific AMBA
1093 +#
1094 +# CONFIG_BCMA is not set
1095 +# CONFIG_MFD_SUPPORT is not set
1096 +# CONFIG_REGULATOR is not set
1097 +# CONFIG_MEDIA_SUPPORT is not set
1098 +
1099 +#
1100 +# Graphics support
1101 +#
1102 +# CONFIG_AGP is not set
1103 +CONFIG_VGA_ARB=y
1104 +CONFIG_VGA_ARB_MAX_GPUS=2
1105 +# CONFIG_VGA_SWITCHEROO is not set
1106 +# CONFIG_DRM is not set
1107 +# CONFIG_STUB_POULSBO is not set
1108 +# CONFIG_VGASTATE is not set
1109 +# CONFIG_VIDEO_OUTPUT_CONTROL is not set
1110 +# CONFIG_FB is not set
1111 +# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
1112 +
1113 +#
1114 +# Display device support
1115 +#
1116 +# CONFIG_DISPLAY_SUPPORT is not set
1117 +
1118 +#
1119 +# Console display driver support
1120 +#
1121 +CONFIG_VGA_CONSOLE=y
1122 +# CONFIG_VGACON_SOFT_SCROLLBACK is not set
1123 +CONFIG_DUMMY_CONSOLE=y
1124 +# CONFIG_SOUND is not set
1125 +# CONFIG_HID_SUPPORT is not set
1126 +# CONFIG_USB_SUPPORT is not set
1127 +# CONFIG_UWB is not set
1128 +# CONFIG_MMC is not set
1129 +# CONFIG_MEMSTICK is not set
1130 +# CONFIG_NEW_LEDS is not set
1131 +# CONFIG_NFC_DEVICES is not set
1132 +# CONFIG_ACCESSIBILITY is not set
1133 +# CONFIG_INFINIBAND is not set
1134 +# CONFIG_EDAC is not set
1135 +# CONFIG_RTC_CLASS is not set
1136 +# CONFIG_DMADEVICES is not set
1137 +# CONFIG_AUXDISPLAY is not set
1138 +# CONFIG_UIO is not set
1139 +# CONFIG_STAGING is not set
1140 +# CONFIG_X86_PLATFORM_DEVICES is not set
1141 +
1142 +#
1143 +# Firmware Drivers
1144 +#
1145 +# CONFIG_EDD is not set
1146 +CONFIG_FIRMWARE_MEMMAP=y
1147 +# CONFIG_DELL_RBU is not set
1148 +# CONFIG_DCDBAS is not set
1149 +# CONFIG_DMIID is not set
1150 +# CONFIG_DMI_SYSFS is not set
1151 +# CONFIG_ISCSI_IBFT_FIND is not set
1152 +# CONFIG_GOOGLE_FIRMWARE is not set
1153 +
1154 +#
1155 +# File systems
1156 +#
1157 +CONFIG_EXT2_FS=y
1158 +CONFIG_EXT2_FS_XATTR=y
1159 +CONFIG_EXT2_FS_POSIX_ACL=y
1160 +CONFIG_EXT2_FS_SECURITY=y
1161 +CONFIG_EXT2_FS_XIP=y
1162 +CONFIG_EXT3_FS=y
1163 +CONFIG_EXT3_DEFAULTS_TO_ORDERED=y
1164 +CONFIG_EXT3_FS_XATTR=y
1165 +CONFIG_EXT3_FS_POSIX_ACL=y
1166 +CONFIG_EXT3_FS_SECURITY=y
1167 +CONFIG_EXT4_FS=y
1168 +CONFIG_EXT4_FS_XATTR=y
1169 +CONFIG_EXT4_FS_POSIX_ACL=y
1170 +CONFIG_EXT4_FS_SECURITY=y
1171 +# CONFIG_EXT4_DEBUG is not set
1172 +CONFIG_FS_XIP=y
1173 +CONFIG_JBD=y
1174 +CONFIG_JBD2=y
1175 +CONFIG_FS_MBCACHE=y
1176 +CONFIG_REISERFS_FS=y
1177 +CONFIG_REISERFS_CHECK=y
1178 +CONFIG_REISERFS_PROC_INFO=y
1179 +CONFIG_REISERFS_FS_XATTR=y
1180 +CONFIG_REISERFS_FS_POSIX_ACL=y
1181 +CONFIG_REISERFS_FS_SECURITY=y
1182 +CONFIG_JFS_FS=y
1183 +CONFIG_JFS_POSIX_ACL=y
1184 +CONFIG_JFS_SECURITY=y
1185 +CONFIG_JFS_DEBUG=y
1186 +CONFIG_JFS_STATISTICS=y
1187 +CONFIG_XFS_FS=y
1188 +CONFIG_XFS_QUOTA=y
1189 +CONFIG_XFS_POSIX_ACL=y
1190 +CONFIG_XFS_RT=y
1191 +# CONFIG_XFS_DEBUG is not set
1192 +CONFIG_GFS2_FS=y
1193 +CONFIG_GFS2_FS_LOCKING_DLM=y
1194 +CONFIG_OCFS2_FS=y
1195 +CONFIG_OCFS2_FS_O2CB=y
1196 +CONFIG_OCFS2_FS_USERSPACE_CLUSTER=y
1197 +CONFIG_OCFS2_DEBUG_MASKLOG=y
1198 +CONFIG_OCFS2_DEBUG_FS=y
1199 +CONFIG_BTRFS_FS=y
1200 +CONFIG_BTRFS_FS_POSIX_ACL=y
1201 +# CONFIG_NILFS2_FS is not set
1202 +CONFIG_FS_POSIX_ACL=y
1203 +CONFIG_EXPORTFS=y
1204 +CONFIG_FILE_LOCKING=y
1205 +CONFIG_FSNOTIFY=y
1206 +CONFIG_DNOTIFY=y
1207 +CONFIG_INOTIFY_USER=y
1208 +CONFIG_FANOTIFY=y
1209 +CONFIG_QUOTA=y
1210 +CONFIG_QUOTA_NETLINK_INTERFACE=y
1211 +CONFIG_PRINT_QUOTA_WARNING=y
1212 +# CONFIG_QUOTA_DEBUG is not set
1213 +CONFIG_QUOTA_TREE=y
1214 +CONFIG_QFMT_V1=y
1215 +CONFIG_QFMT_V2=y
1216 +CONFIG_QUOTACTL=y
1217 +CONFIG_QUOTACTL_COMPAT=y
1218 +# CONFIG_AUTOFS4_FS is not set
1219 +# CONFIG_FUSE_FS is not set
1220 +CONFIG_GENERIC_ACL=y
1221 +
1222 +#
1223 +# Caches
1224 +#
1225 +# CONFIG_FSCACHE is not set
1226 +
1227 +#
1228 +# CD-ROM/DVD Filesystems
1229 +#
1230 +# CONFIG_ISO9660_FS is not set
1231 +# CONFIG_UDF_FS is not set
1232 +
1233 +#
1234 +# DOS/FAT/NT Filesystems
1235 +#
1236 +# CONFIG_MSDOS_FS is not set
1237 +# CONFIG_VFAT_FS is not set
1238 +# CONFIG_NTFS_FS is not set
1239 +
1240 +#
1241 +# Pseudo filesystems
1242 +#
1243 +CONFIG_PROC_FS=y
1244 +# CONFIG_PROC_KCORE is not set
1245 +CONFIG_PROC_SYSCTL=y
1246 +CONFIG_PROC_PAGE_MONITOR=y
1247 +CONFIG_SYSFS=y
1248 +CONFIG_TMPFS=y
1249 +CONFIG_TMPFS_POSIX_ACL=y
1250 +CONFIG_TMPFS_XATTR=y
1251 +# CONFIG_HUGETLBFS is not set
1252 +# CONFIG_HUGETLB_PAGE is not set
1253 +CONFIG_CONFIGFS_FS=y
1254 +# CONFIG_MISC_FILESYSTEMS is not set
1255 +CONFIG_NETWORK_FILESYSTEMS=y
1256 +CONFIG_NFS_FS=y
1257 +CONFIG_NFS_V3=y
1258 +# CONFIG_NFS_V3_ACL is not set
1259 +# CONFIG_NFS_V4 is not set
1260 +CONFIG_NFSD=y
1261 +CONFIG_NFSD_DEPRECATED=y
1262 +CONFIG_NFSD_V3=y
1263 +# CONFIG_NFSD_V3_ACL is not set
1264 +# CONFIG_NFSD_V4 is not set
1265 +CONFIG_LOCKD=y
1266 +CONFIG_LOCKD_V4=y
1267 +CONFIG_NFS_COMMON=y
1268 +CONFIG_SUNRPC=y
1269 +# CONFIG_CEPH_FS is not set
1270 +# CONFIG_CIFS is not set
1271 +# CONFIG_NCP_FS is not set
1272 +# CONFIG_CODA_FS is not set
1273 +# CONFIG_AFS_FS is not set
1274 +
1275 +#
1276 +# Partition Types
1277 +#
1278 +# CONFIG_PARTITION_ADVANCED is not set
1279 +CONFIG_MSDOS_PARTITION=y
1280 +CONFIG_NLS=y
1281 +CONFIG_NLS_DEFAULT="iso8859-1"
1282 +# CONFIG_NLS_CODEPAGE_437 is not set
1283 +# CONFIG_NLS_CODEPAGE_737 is not set
1284 +# CONFIG_NLS_CODEPAGE_775 is not set
1285 +# CONFIG_NLS_CODEPAGE_850 is not set
1286 +# CONFIG_NLS_CODEPAGE_852 is not set
1287 +# CONFIG_NLS_CODEPAGE_855 is not set
1288 +# CONFIG_NLS_CODEPAGE_857 is not set
1289 +# CONFIG_NLS_CODEPAGE_860 is not set
1290 +# CONFIG_NLS_CODEPAGE_861 is not set
1291 +# CONFIG_NLS_CODEPAGE_862 is not set
1292 +# CONFIG_NLS_CODEPAGE_863 is not set
1293 +# CONFIG_NLS_CODEPAGE_864 is not set
1294 +# CONFIG_NLS_CODEPAGE_865 is not set
1295 +# CONFIG_NLS_CODEPAGE_866 is not set
1296 +# CONFIG_NLS_CODEPAGE_869 is not set
1297 +# CONFIG_NLS_CODEPAGE_936 is not set
1298 +# CONFIG_NLS_CODEPAGE_950 is not set
1299 +# CONFIG_NLS_CODEPAGE_932 is not set
1300 +# CONFIG_NLS_CODEPAGE_949 is not set
1301 +# CONFIG_NLS_CODEPAGE_874 is not set
1302 +# CONFIG_NLS_ISO8859_8 is not set
1303 +# CONFIG_NLS_CODEPAGE_1250 is not set
1304 +# CONFIG_NLS_CODEPAGE_1251 is not set
1305 +# CONFIG_NLS_ASCII is not set
1306 +# CONFIG_NLS_ISO8859_1 is not set
1307 +# CONFIG_NLS_ISO8859_2 is not set
1308 +# CONFIG_NLS_ISO8859_3 is not set
1309 +# CONFIG_NLS_ISO8859_4 is not set
1310 +# CONFIG_NLS_ISO8859_5 is not set
1311 +# CONFIG_NLS_ISO8859_6 is not set
1312 +# CONFIG_NLS_ISO8859_7 is not set
1313 +# CONFIG_NLS_ISO8859_9 is not set
1314 +# CONFIG_NLS_ISO8859_13 is not set
1315 +# CONFIG_NLS_ISO8859_14 is not set
1316 +# CONFIG_NLS_ISO8859_15 is not set
1317 +# CONFIG_NLS_KOI8_R is not set
1318 +# CONFIG_NLS_KOI8_U is not set
1319 +# CONFIG_NLS_UTF8 is not set
1320 +CONFIG_DLM=y
1321 +# CONFIG_DLM_DEBUG is not set
1322 +
1323 +#
1324 +# Kernel hacking
1325 +#
1326 +CONFIG_TRACE_IRQFLAGS_SUPPORT=y
1327 +CONFIG_PRINTK_TIME=y
1328 +CONFIG_DEFAULT_MESSAGE_LOGLEVEL=4
1329 +# CONFIG_ENABLE_WARN_DEPRECATED is not set
1330 +# CONFIG_ENABLE_MUST_CHECK is not set
1331 +CONFIG_FRAME_WARN=2048
1332 +CONFIG_MAGIC_SYSRQ=y
1333 +# CONFIG_STRIP_ASM_SYMS is not set
1334 +# CONFIG_UNUSED_SYMBOLS is not set
1335 +# CONFIG_DEBUG_FS is not set
1336 +# CONFIG_HEADERS_CHECK is not set
1337 +# CONFIG_DEBUG_SECTION_MISMATCH is not set
1338 +CONFIG_DEBUG_KERNEL=y
1339 +# CONFIG_DEBUG_SHIRQ is not set
1340 +# CONFIG_LOCKUP_DETECTOR is not set
1341 +# CONFIG_HARDLOCKUP_DETECTOR is not set
1342 +CONFIG_DETECT_HUNG_TASK=y
1343 +CONFIG_DEFAULT_HUNG_TASK_TIMEOUT=120
1344 +# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
1345 +CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
1346 +# CONFIG_SCHED_DEBUG is not set
1347 +# CONFIG_SCHEDSTATS is not set
1348 +# CONFIG_TIMER_STATS is not set
1349 +# CONFIG_DEBUG_OBJECTS is not set
1350 +# CONFIG_SLUB_DEBUG_ON is not set
1351 +# CONFIG_SLUB_STATS is not set
1352 +# CONFIG_DEBUG_KMEMLEAK is not set
1353 +# CONFIG_DEBUG_RT_MUTEXES is not set
1354 +# CONFIG_RT_MUTEX_TESTER is not set
1355 +# CONFIG_DEBUG_SPINLOCK is not set
1356 +# CONFIG_DEBUG_MUTEXES is not set
1357 +# CONFIG_DEBUG_LOCK_ALLOC is not set
1358 +# CONFIG_PROVE_LOCKING is not set
1359 +# CONFIG_SPARSE_RCU_POINTER is not set
1360 +# CONFIG_LOCK_STAT is not set
1361 +# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1362 +# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1363 +# CONFIG_DEBUG_STACK_USAGE is not set
1364 +# CONFIG_DEBUG_KOBJECT is not set
1365 +CONFIG_DEBUG_BUGVERBOSE=y
1366 +CONFIG_DEBUG_INFO=y
1367 +# CONFIG_DEBUG_INFO_REDUCED is not set
1368 +# CONFIG_DEBUG_VM is not set
1369 +# CONFIG_DEBUG_VIRTUAL is not set
1370 +# CONFIG_DEBUG_WRITECOUNT is not set
1371 +CONFIG_DEBUG_MEMORY_INIT=y
1372 +# CONFIG_DEBUG_LIST is not set
1373 +# CONFIG_TEST_LIST_SORT is not set
1374 +# CONFIG_DEBUG_SG is not set
1375 +# CONFIG_DEBUG_NOTIFIERS is not set
1376 +# CONFIG_DEBUG_CREDENTIALS is not set
1377 +CONFIG_ARCH_WANT_FRAME_POINTERS=y
1378 +# CONFIG_FRAME_POINTER is not set
1379 +# CONFIG_BOOT_PRINTK_DELAY is not set
1380 +# CONFIG_RCU_TORTURE_TEST is not set
1381 +CONFIG_RCU_CPU_STALL_TIMEOUT=60
1382 +# CONFIG_BACKTRACE_SELF_TEST is not set
1383 +# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
1384 +# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
1385 +# CONFIG_DEBUG_PER_CPU_MAPS is not set
1386 +# CONFIG_CPU_NOTIFIER_ERROR_INJECT is not set
1387 +# CONFIG_FAULT_INJECTION is not set
1388 +# CONFIG_LATENCYTOP is not set
1389 +# CONFIG_SYSCTL_SYSCALL_CHECK is not set
1390 +# CONFIG_DEBUG_PAGEALLOC is not set
1391 +CONFIG_USER_STACKTRACE_SUPPORT=y
1392 +CONFIG_HAVE_FUNCTION_TRACER=y
1393 +CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
1394 +CONFIG_HAVE_FUNCTION_GRAPH_FP_TEST=y
1395 +CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST=y
1396 +CONFIG_HAVE_DYNAMIC_FTRACE=y
1397 +CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
1398 +CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
1399 +CONFIG_HAVE_C_RECORDMCOUNT=y
1400 +CONFIG_TRACING_SUPPORT=y
1401 +# CONFIG_FTRACE is not set
1402 +# CONFIG_PROVIDE_OHCI1394_DMA_INIT is not set
1403 +# CONFIG_DMA_API_DEBUG is not set
1404 +CONFIG_ATOMIC64_SELFTEST=y
1405 +# CONFIG_ASYNC_RAID6_TEST is not set
1406 +# CONFIG_SAMPLES is not set
1407 +CONFIG_HAVE_ARCH_KGDB=y
1408 +# CONFIG_KGDB is not set
1409 +CONFIG_HAVE_ARCH_KMEMCHECK=y
1410 +# CONFIG_TEST_KSTRTOX is not set
1411 +# CONFIG_STRICT_DEVMEM is not set
1412 +# CONFIG_X86_VERBOSE_BOOTUP is not set
1413 +CONFIG_EARLY_PRINTK=y
1414 +# CONFIG_EARLY_PRINTK_DBGP is not set
1415 +# CONFIG_DEBUG_STACKOVERFLOW is not set
1416 +# CONFIG_X86_PTDUMP is not set
1417 +CONFIG_DEBUG_RODATA=y
1418 +CONFIG_DEBUG_RODATA_TEST=y
1419 +# CONFIG_IOMMU_DEBUG is not set
1420 +# CONFIG_IOMMU_STRESS is not set
1421 +CONFIG_HAVE_MMIOTRACE_SUPPORT=y
1422 +CONFIG_IO_DELAY_TYPE_0X80=0
1423 +CONFIG_IO_DELAY_TYPE_0XED=1
1424 +CONFIG_IO_DELAY_TYPE_UDELAY=2
1425 +CONFIG_IO_DELAY_TYPE_NONE=3
1426 +CONFIG_IO_DELAY_0X80=y
1427 +# CONFIG_IO_DELAY_0XED is not set
1428 +# CONFIG_IO_DELAY_UDELAY is not set
1429 +# CONFIG_IO_DELAY_NONE is not set
1430 +CONFIG_DEFAULT_IO_DELAY_TYPE=0
1431 +# CONFIG_CPA_DEBUG is not set
1432 +# CONFIG_OPTIMIZE_INLINING is not set
1433 +# CONFIG_DEBUG_STRICT_USER_COPY_CHECKS is not set
1434 +
1435 +#
1436 +# Linux VServer
1437 +#
1438 +CONFIG_VSERVER_AUTO_LBACK=y
1439 +# CONFIG_VSERVER_AUTO_SINGLE is not set
1440 +CONFIG_VSERVER_COWBL=y
1441 +CONFIG_VSERVER_VTIME=y
1442 +# CONFIG_VSERVER_DEVICE is not set
1443 +CONFIG_VSERVER_PROC_SECURE=y
1444 +# CONFIG_TAGGING_NONE is not set
1445 +# CONFIG_TAGGING_UID16 is not set
1446 +# CONFIG_TAGGING_GID16 is not set
1447 +CONFIG_TAGGING_ID24=y
1448 +# CONFIG_TAGGING_INTERN is not set
1449 +# CONFIG_TAG_NFSD is not set
1450 +# CONFIG_VSERVER_PRIVACY is not set
1451 +CONFIG_VSERVER_CONTEXTS=768
1452 +CONFIG_VSERVER_WARN=y
1453 +CONFIG_VSERVER_WARN_DEVPTS=y
1454 +CONFIG_VSERVER_DEBUG=y
1455 +CONFIG_VSERVER_HISTORY=y
1456 +CONFIG_VSERVER_HISTORY_SIZE=64
1457 +CONFIG_VSERVER_LEGACY_MEM=y
1458 +# CONFIG_QUOTES_ISO8859 is not set
1459 +# CONFIG_QUOTES_UTF8 is not set
1460 +CONFIG_QUOTES_ASCII=y
1461 +CONFIG_VSERVER=y
1462 +
1463 +#
1464 +# Security options
1465 +#
1466 +# CONFIG_KEYS is not set
1467 +CONFIG_SECURITY_DMESG_RESTRICT=y
1468 +# CONFIG_SECURITY is not set
1469 +# CONFIG_SECURITYFS is not set
1470 +CONFIG_DEFAULT_SECURITY_DAC=y
1471 +CONFIG_DEFAULT_SECURITY=""
1472 +CONFIG_XOR_BLOCKS=y
1473 +CONFIG_ASYNC_CORE=y
1474 +CONFIG_ASYNC_MEMCPY=y
1475 +CONFIG_ASYNC_XOR=y
1476 +CONFIG_ASYNC_PQ=y
1477 +CONFIG_ASYNC_RAID6_RECOV=y
1478 +CONFIG_CRYPTO=y
1479 +
1480 +#
1481 +# Crypto core or helper
1482 +#
1483 +CONFIG_CRYPTO_ALGAPI=y
1484 +CONFIG_CRYPTO_ALGAPI2=y
1485 +CONFIG_CRYPTO_AEAD=y
1486 +CONFIG_CRYPTO_AEAD2=y
1487 +CONFIG_CRYPTO_BLKCIPHER=y
1488 +CONFIG_CRYPTO_BLKCIPHER2=y
1489 +CONFIG_CRYPTO_HASH=y
1490 +CONFIG_CRYPTO_HASH2=y
1491 +CONFIG_CRYPTO_RNG=y
1492 +CONFIG_CRYPTO_RNG2=y
1493 +CONFIG_CRYPTO_PCOMP2=y
1494 +CONFIG_CRYPTO_MANAGER=y
1495 +CONFIG_CRYPTO_MANAGER2=y
1496 +CONFIG_CRYPTO_MANAGER_DISABLE_TESTS=y
1497 +# CONFIG_CRYPTO_GF128MUL is not set
1498 +# CONFIG_CRYPTO_NULL is not set
1499 +# CONFIG_CRYPTO_PCRYPT is not set
1500 +CONFIG_CRYPTO_WORKQUEUE=y
1501 +# CONFIG_CRYPTO_CRYPTD is not set
1502 +CONFIG_CRYPTO_AUTHENC=y
1503 +
1504 +#
1505 +# Authenticated Encryption with Associated Data
1506 +#
1507 +# CONFIG_CRYPTO_CCM is not set
1508 +# CONFIG_CRYPTO_GCM is not set
1509 +# CONFIG_CRYPTO_SEQIV is not set
1510 +
1511 +#
1512 +# Block modes
1513 +#
1514 +CONFIG_CRYPTO_CBC=y
1515 +# CONFIG_CRYPTO_CTR is not set
1516 +# CONFIG_CRYPTO_CTS is not set
1517 +# CONFIG_CRYPTO_ECB is not set
1518 +# CONFIG_CRYPTO_LRW is not set
1519 +# CONFIG_CRYPTO_PCBC is not set
1520 +# CONFIG_CRYPTO_XTS is not set
1521 +
1522 +#
1523 +# Hash modes
1524 +#
1525 +CONFIG_CRYPTO_HMAC=y
1526 +# CONFIG_CRYPTO_XCBC is not set
1527 +# CONFIG_CRYPTO_VMAC is not set
1528 +
1529 +#
1530 +# Digest
1531 +#
1532 +CONFIG_CRYPTO_CRC32C=y
1533 +# CONFIG_CRYPTO_CRC32C_INTEL is not set
1534 +# CONFIG_CRYPTO_GHASH is not set
1535 +# CONFIG_CRYPTO_MD4 is not set
1536 +CONFIG_CRYPTO_MD5=y
1537 +# CONFIG_CRYPTO_MICHAEL_MIC is not set
1538 +# CONFIG_CRYPTO_RMD128 is not set
1539 +# CONFIG_CRYPTO_RMD160 is not set
1540 +# CONFIG_CRYPTO_RMD256 is not set
1541 +# CONFIG_CRYPTO_RMD320 is not set
1542 +CONFIG_CRYPTO_SHA1=y
1543 +# CONFIG_CRYPTO_SHA256 is not set
1544 +# CONFIG_CRYPTO_SHA512 is not set
1545 +# CONFIG_CRYPTO_TGR192 is not set
1546 +# CONFIG_CRYPTO_WP512 is not set
1547 +# CONFIG_CRYPTO_GHASH_CLMUL_NI_INTEL is not set
1548 +
1549 +#
1550 +# Ciphers
1551 +#
1552 +CONFIG_CRYPTO_AES=y
1553 +# CONFIG_CRYPTO_AES_X86_64 is not set
1554 +# CONFIG_CRYPTO_AES_NI_INTEL is not set
1555 +# CONFIG_CRYPTO_ANUBIS is not set
1556 +# CONFIG_CRYPTO_ARC4 is not set
1557 +# CONFIG_CRYPTO_BLOWFISH is not set
1558 +# CONFIG_CRYPTO_CAMELLIA is not set
1559 +# CONFIG_CRYPTO_CAST5 is not set
1560 +# CONFIG_CRYPTO_CAST6 is not set
1561 +CONFIG_CRYPTO_DES=y
1562 +# CONFIG_CRYPTO_FCRYPT is not set
1563 +# CONFIG_CRYPTO_KHAZAD is not set
1564 +# CONFIG_CRYPTO_SALSA20 is not set
1565 +# CONFIG_CRYPTO_SALSA20_X86_64 is not set
1566 +# CONFIG_CRYPTO_SEED is not set
1567 +# CONFIG_CRYPTO_SERPENT is not set
1568 +# CONFIG_CRYPTO_TEA is not set
1569 +# CONFIG_CRYPTO_TWOFISH is not set
1570 +# CONFIG_CRYPTO_TWOFISH_X86_64 is not set
1571 +
1572 +#
1573 +# Compression
1574 +#
1575 +CONFIG_CRYPTO_DEFLATE=y
1576 +# CONFIG_CRYPTO_ZLIB is not set
1577 +# CONFIG_CRYPTO_LZO is not set
1578 +
1579 +#
1580 +# Random Number Generation
1581 +#
1582 +CONFIG_CRYPTO_ANSI_CPRNG=y
1583 +CONFIG_CRYPTO_USER_API=y
1584 +CONFIG_CRYPTO_USER_API_HASH=y
1585 +CONFIG_CRYPTO_USER_API_SKCIPHER=y
1586 +CONFIG_CRYPTO_HW=y
1587 +# CONFIG_CRYPTO_DEV_PADLOCK is not set
1588 +# CONFIG_CRYPTO_DEV_HIFN_795X is not set
1589 +CONFIG_HAVE_KVM=y
1590 +# CONFIG_VIRTUALIZATION is not set
1591 +# CONFIG_BINARY_PRINTF is not set
1592 +
1593 +#
1594 +# Library routines
1595 +#
1596 +CONFIG_RAID6_PQ=y
1597 +CONFIG_BITREVERSE=y
1598 +CONFIG_GENERIC_FIND_FIRST_BIT=y
1599 +# CONFIG_CRC_CCITT is not set
1600 +CONFIG_CRC16=y
1601 +# CONFIG_CRC_T10DIF is not set
1602 +# CONFIG_CRC_ITU_T is not set
1603 +CONFIG_CRC32=y
1604 +# CONFIG_CRC7 is not set
1605 +CONFIG_LIBCRC32C=y
1606 +CONFIG_ZLIB_INFLATE=y
1607 +CONFIG_ZLIB_DEFLATE=y
1608 +CONFIG_LZO_COMPRESS=y
1609 +CONFIG_LZO_DECOMPRESS=y
1610 +CONFIG_XZ_DEC=y
1611 +CONFIG_XZ_DEC_X86=y
1612 +# CONFIG_XZ_DEC_POWERPC is not set
1613 +# CONFIG_XZ_DEC_IA64 is not set
1614 +# CONFIG_XZ_DEC_ARM is not set
1615 +# CONFIG_XZ_DEC_ARMTHUMB is not set
1616 +# CONFIG_XZ_DEC_SPARC is not set
1617 +CONFIG_XZ_DEC_BCJ=y
1618 +# CONFIG_XZ_DEC_TEST is not set
1619 +CONFIG_HAS_IOMEM=y
1620 +CONFIG_HAS_IOPORT=y
1621 +CONFIG_HAS_DMA=y
1622 +CONFIG_CPU_RMAP=y
1623 +CONFIG_NLATTR=y
1624 +# CONFIG_AVERAGE is not set
1625 diff -NurpP --minimal linux-3.0.4/Documentation/vserver/debug.txt linux-3.0.4-vs2.3.1/Documentation/vserver/debug.txt
1626 --- linux-3.0.4/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
1627 +++ linux-3.0.4-vs2.3.1/Documentation/vserver/debug.txt 2011-06-10 22:11:24.000000000 +0200
1628 @@ -0,0 +1,154 @@
1629 +
1630 +debug_cvirt:
1631 +
1632 + 2   4 "vx_map_tgid: %p/%llx: %d -> %d"
1633 +       "vx_rmap_tgid: %p/%llx: %d -> %d"
1634 +
1635 +debug_dlim:
1636 +
1637 + 0   1 "ALLOC (%p,#%d)%c inode (%d)"
1638 +       "FREE  (%p,#%d)%c inode"
1639 + 1   2 "ALLOC (%p,#%d)%c %lld bytes (%d)"
1640 +       "FREE  (%p,#%d)%c %lld bytes"
1641 + 2   4 "ADJUST: %lld,%lld on %ld,%ld [mult=%d]"
1642 + 3   8 "ext3_has_free_blocks(%p): %lu<%lu+1, %c, %u!=%u r=%d"
1643 +       "ext3_has_free_blocks(%p): free=%lu, root=%lu"
1644 +       "rcu_free_dl_info(%p)"
1645 + 4  10 "alloc_dl_info(%p,%d) = %p"
1646 +       "dealloc_dl_info(%p)"
1647 +       "get_dl_info(%p[#%d.%d])"
1648 +       "put_dl_info(%p[#%d.%d])"
1649 + 5  20 "alloc_dl_info(%p,%d)*"
1650 + 6  40 "__hash_dl_info: %p[#%d]"
1651 +       "__unhash_dl_info: %p[#%d]"
1652 + 7  80 "locate_dl_info(%p,#%d) = %p"
1653 +
1654 +debug_misc:
1655 +
1656 + 0   1 "destroy_dqhash: %p [#0x%08x] c=%d"
1657 +       "new_dqhash: %p [#0x%08x]"
1658 +       "vroot[%d]_clr_dev: dev=%p[%lu,%d:%d]"
1659 +       "vroot[%d]_get_real_bdev: dev=%p[%lu,%d:%d]"
1660 +       "vroot[%d]_set_dev: dev=%p[%lu,%d:%d]"
1661 +       "vroot_get_real_bdev not set"
1662 + 1   2 "cow_break_link(»%s«)"
1663 +       "temp copy Â»%s«"
1664 + 2   4 "dentry_open(new): %p"
1665 +       "dentry_open(old): %p"
1666 +       "lookup_create(new): %p"
1667 +       "old path Â»%s«"
1668 +       "path_lookup(old): %d"
1669 +       "vfs_create(new): %d"
1670 +       "vfs_rename: %d"
1671 +       "vfs_sendfile: %d"
1672 + 3   8 "fput(new_file=%p[#%d])"
1673 +       "fput(old_file=%p[#%d])"
1674 + 4  10 "vx_info_kill(%p[#%d],%d,%d) = %d"
1675 +       "vx_info_kill(%p[#%d],%d,%d)*"
1676 + 5  20 "vs_reboot(%p[#%d],%d)"
1677 + 6  40 "dropping task %p[#%u,%u] for %p[#%u,%u]"
1678 +
1679 +debug_net:
1680 +
1681 + 2   4 "nx_addr_conflict(%p,%p) %d.%d,%d.%d"
1682 + 3   8 "inet_bind(%p) %d.%d.%d.%d, %d.%d.%d.%d, %d.%d.%d.%d"
1683 +       "inet_bind(%p)* %p,%p;%lx %d.%d.%d.%d"
1684 + 4  10 "ip_route_connect(%p) %p,%p;%lx"
1685 + 5  20 "__addr_in_socket(%p,%d.%d.%d.%d) %p:%d.%d.%d.%d %p;%lx"
1686 + 6  40 "sk,egf: %p [#%d] (from %d)"
1687 +       "sk,egn: %p [#%d] (from %d)"
1688 +       "sk,req: %p [#%d] (from %d)"
1689 +       "sk: %p [#%d] (from %d)"
1690 +       "tw: %p [#%d] (from %d)"
1691 + 7  80 "__sock_recvmsg: %p[%p,%p,%p;%d]:%d/%d"
1692 +       "__sock_sendmsg: %p[%p,%p,%p;%d]:%d/%d"
1693 +
1694 +debug_nid:
1695 +
1696 + 0   1 "__lookup_nx_info(#%u): %p[#%u]"
1697 +       "alloc_nx_info(%d) = %p"
1698 +       "create_nx_info(%d) (dynamic rejected)"
1699 +       "create_nx_info(%d) = %p (already there)"
1700 +       "create_nx_info(%d) = %p (new)"
1701 +       "dealloc_nx_info(%p)"
1702 + 1   2 "alloc_nx_info(%d)*"
1703 +       "create_nx_info(%d)*"
1704 + 2   4 "get_nx_info(%p[#%d.%d])"
1705 +       "put_nx_info(%p[#%d.%d])"
1706 + 3   8 "claim_nx_info(%p[#%d.%d.%d]) %p"
1707 +       "clr_nx_info(%p[#%d.%d])"
1708 +       "init_nx_info(%p[#%d.%d])"
1709 +       "release_nx_info(%p[#%d.%d.%d]) %p"
1710 +       "set_nx_info(%p[#%d.%d])"
1711 + 4  10 "__hash_nx_info: %p[#%d]"
1712 +       "__nx_dynamic_id: [#%d]"
1713 +       "__unhash_nx_info: %p[#%d.%d.%d]"
1714 + 5  20 "moved task %p into nxi:%p[#%d]"
1715 +       "nx_migrate_task(%p,%p[#%d.%d.%d])"
1716 +       "task_get_nx_info(%p)"
1717 + 6  40 "nx_clear_persistent(%p[#%d])"
1718 +
1719 +debug_quota:
1720 +
1721 + 0   1 "quota_sync_dqh(%p,%d) discard inode %p"
1722 + 1   2 "quota_sync_dqh(%p,%d)"
1723 +       "sync_dquots(%p,%d)"
1724 +       "sync_dquots_dqh(%p,%d)"
1725 + 3   8 "do_quotactl(%p,%d,cmd=%d,id=%d,%p)"
1726 +
1727 +debug_switch:
1728 +
1729 + 0   1 "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]"
1730 + 1   2 "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]"
1731 + 4  10 "%s: (%s %s) returned %s with %d"
1732 +
1733 +debug_tag:
1734 +
1735 + 7  80 "dx_parse_tag(»%s«): %d:#%d"
1736 +       "dx_propagate_tag(%p[#%lu.%d]): %d,%d"
1737 +
1738 +debug_xid:
1739 +
1740 + 0   1 "__lookup_vx_info(#%u): %p[#%u]"
1741 +       "alloc_vx_info(%d) = %p"
1742 +       "alloc_vx_info(%d)*"
1743 +       "create_vx_info(%d) (dynamic rejected)"
1744 +       "create_vx_info(%d) = %p (already there)"
1745 +       "create_vx_info(%d) = %p (new)"
1746 +       "dealloc_vx_info(%p)"
1747 +       "loc_vx_info(%d) = %p (found)"
1748 +       "loc_vx_info(%d) = %p (new)"
1749 +       "loc_vx_info(%d) = %p (not available)"
1750 + 1   2 "create_vx_info(%d)*"
1751 +       "loc_vx_info(%d)*"
1752 + 2   4 "get_vx_info(%p[#%d.%d])"
1753 +       "put_vx_info(%p[#%d.%d])"
1754 + 3   8 "claim_vx_info(%p[#%d.%d.%d]) %p"
1755 +       "clr_vx_info(%p[#%d.%d])"
1756 +       "init_vx_info(%p[#%d.%d])"
1757 +       "release_vx_info(%p[#%d.%d.%d]) %p"
1758 +       "set_vx_info(%p[#%d.%d])"
1759 + 4  10 "__hash_vx_info: %p[#%d]"
1760 +       "__unhash_vx_info: %p[#%d.%d.%d]"
1761 +       "__vx_dynamic_id: [#%d]"
1762 + 5  20 "enter_vx_info(%p[#%d],%p) %p[#%d,%p]"
1763 +       "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]"
1764 +       "moved task %p into vxi:%p[#%d]"
1765 +       "task_get_vx_info(%p)"
1766 +       "vx_migrate_task(%p,%p[#%d.%d])"
1767 + 6  40 "vx_clear_persistent(%p[#%d])"
1768 +       "vx_exit_init(%p[#%d],%p[#%d,%d,%d])"
1769 +       "vx_set_init(%p[#%d],%p[#%d,%d,%d])"
1770 +       "vx_set_persistent(%p[#%d])"
1771 +       "vx_set_reaper(%p[#%d],%p[#%d,%d])"
1772 + 7  80 "vx_child_reaper(%p[#%u,%u]) = %p[#%u,%u]"
1773 +
1774 +
1775 +debug_limit:
1776 +
1777 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
1778 +       "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
1779 +
1780 + m 2^m "vx_acc_page[%5d,%s,%2d]: %5d%s"
1781 +       "vx_acc_pages[%5d,%s,%2d]: %5d += %5d"
1782 +       "vx_pages_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
1783 diff -NurpP --minimal linux-3.0.4/arch/alpha/Kconfig linux-3.0.4-vs2.3.1/arch/alpha/Kconfig
1784 --- linux-3.0.4/arch/alpha/Kconfig      2011-07-22 11:17:32.000000000 +0200
1785 +++ linux-3.0.4-vs2.3.1/arch/alpha/Kconfig      2011-06-10 22:11:24.000000000 +0200
1786 @@ -668,6 +668,8 @@ config DUMMY_CONSOLE
1787         depends on VGA_HOSE
1788         default y
1789  
1790 +source "kernel/vserver/Kconfig"
1791 +
1792  source "security/Kconfig"
1793  
1794  source "crypto/Kconfig"
1795 diff -NurpP --minimal linux-3.0.4/arch/alpha/kernel/entry.S linux-3.0.4-vs2.3.1/arch/alpha/kernel/entry.S
1796 --- linux-3.0.4/arch/alpha/kernel/entry.S       2010-10-21 13:06:45.000000000 +0200
1797 +++ linux-3.0.4-vs2.3.1/arch/alpha/kernel/entry.S       2011-06-10 22:11:24.000000000 +0200
1798 @@ -860,24 +860,15 @@ sys_getxgid:
1799         .globl  sys_getxpid
1800         .ent    sys_getxpid
1801  sys_getxpid:
1802 +       lda     $sp, -16($sp)
1803 +       stq     $26, 0($sp)
1804         .prologue 0
1805 -       ldq     $2, TI_TASK($8)
1806  
1807 -       /* See linux/kernel/timer.c sys_getppid for discussion
1808 -          about this loop.  */
1809 -       ldq     $3, TASK_GROUP_LEADER($2)
1810 -       ldq     $4, TASK_REAL_PARENT($3)
1811 -       ldl     $0, TASK_TGID($2)
1812 -1:     ldl     $1, TASK_TGID($4)
1813 -#ifdef CONFIG_SMP
1814 -       mov     $4, $5
1815 -       mb
1816 -       ldq     $3, TASK_GROUP_LEADER($2)
1817 -       ldq     $4, TASK_REAL_PARENT($3)
1818 -       cmpeq   $4, $5, $5
1819 -       beq     $5, 1b
1820 -#endif
1821 -       stq     $1, 80($sp)
1822 +       lda     $16, 96($sp)
1823 +       jsr     $26, do_getxpid
1824 +       ldq     $26, 0($sp)
1825 +
1826 +       lda     $sp, 16($sp)
1827         ret
1828  .end sys_getxpid
1829  
1830 diff -NurpP --minimal linux-3.0.4/arch/alpha/kernel/ptrace.c linux-3.0.4-vs2.3.1/arch/alpha/kernel/ptrace.c
1831 --- linux-3.0.4/arch/alpha/kernel/ptrace.c      2011-01-05 21:48:40.000000000 +0100
1832 +++ linux-3.0.4-vs2.3.1/arch/alpha/kernel/ptrace.c      2011-06-10 22:11:24.000000000 +0200
1833 @@ -13,6 +13,7 @@
1834  #include <linux/user.h>
1835  #include <linux/security.h>
1836  #include <linux/signal.h>
1837 +#include <linux/vs_base.h>
1838  
1839  #include <asm/uaccess.h>
1840  #include <asm/pgtable.h>
1841 diff -NurpP --minimal linux-3.0.4/arch/alpha/kernel/systbls.S linux-3.0.4-vs2.3.1/arch/alpha/kernel/systbls.S
1842 --- linux-3.0.4/arch/alpha/kernel/systbls.S     2011-07-22 11:17:32.000000000 +0200
1843 +++ linux-3.0.4-vs2.3.1/arch/alpha/kernel/systbls.S     2011-06-10 22:11:24.000000000 +0200
1844 @@ -446,7 +446,7 @@ sys_call_table:
1845         .quad sys_stat64                        /* 425 */
1846         .quad sys_lstat64
1847         .quad sys_fstat64
1848 -       .quad sys_ni_syscall                    /* sys_vserver */
1849 +       .quad sys_vserver                       /* sys_vserver */
1850         .quad sys_ni_syscall                    /* sys_mbind */
1851         .quad sys_ni_syscall                    /* sys_get_mempolicy */
1852         .quad sys_ni_syscall                    /* sys_set_mempolicy */
1853 diff -NurpP --minimal linux-3.0.4/arch/alpha/kernel/traps.c linux-3.0.4-vs2.3.1/arch/alpha/kernel/traps.c
1854 --- linux-3.0.4/arch/alpha/kernel/traps.c       2010-10-21 13:06:46.000000000 +0200
1855 +++ linux-3.0.4-vs2.3.1/arch/alpha/kernel/traps.c       2011-06-10 22:11:24.000000000 +0200
1856 @@ -183,7 +183,8 @@ die_if_kernel(char * str, struct pt_regs
1857  #ifdef CONFIG_SMP
1858         printk("CPU %d ", hard_smp_processor_id());
1859  #endif
1860 -       printk("%s(%d): %s %ld\n", current->comm, task_pid_nr(current), str, err);
1861 +       printk("%s(%d[#%u]): %s %ld\n", current->comm,
1862 +               task_pid_nr(current), current->xid, str, err);
1863         dik_show_regs(regs, r9_15);
1864         add_taint(TAINT_DIE);
1865         dik_show_trace((unsigned long *)(regs+1));
1866 diff -NurpP --minimal linux-3.0.4/arch/arm/Kconfig linux-3.0.4-vs2.3.1/arch/arm/Kconfig
1867 --- linux-3.0.4/arch/arm/Kconfig        2011-07-22 11:17:32.000000000 +0200
1868 +++ linux-3.0.4-vs2.3.1/arch/arm/Kconfig        2011-06-10 22:11:24.000000000 +0200
1869 @@ -2035,6 +2035,8 @@ source "fs/Kconfig"
1870  
1871  source "arch/arm/Kconfig.debug"
1872  
1873 +source "kernel/vserver/Kconfig"
1874 +
1875  source "security/Kconfig"
1876  
1877  source "crypto/Kconfig"
1878 diff -NurpP --minimal linux-3.0.4/arch/arm/kernel/calls.S linux-3.0.4-vs2.3.1/arch/arm/kernel/calls.S
1879 --- linux-3.0.4/arch/arm/kernel/calls.S 2011-07-22 11:17:32.000000000 +0200
1880 +++ linux-3.0.4-vs2.3.1/arch/arm/kernel/calls.S 2011-06-10 22:11:24.000000000 +0200
1881 @@ -322,7 +322,7 @@
1882  /* 310 */      CALL(sys_request_key)
1883                 CALL(sys_keyctl)
1884                 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
1885 -/* vserver */  CALL(sys_ni_syscall)
1886 +               CALL(sys_vserver)
1887                 CALL(sys_ioprio_set)
1888  /* 315 */      CALL(sys_ioprio_get)
1889                 CALL(sys_inotify_init)
1890 diff -NurpP --minimal linux-3.0.4/arch/arm/kernel/process.c linux-3.0.4-vs2.3.1/arch/arm/kernel/process.c
1891 --- linux-3.0.4/arch/arm/kernel/process.c       2011-05-22 16:16:47.000000000 +0200
1892 +++ linux-3.0.4-vs2.3.1/arch/arm/kernel/process.c       2011-06-10 22:11:24.000000000 +0200
1893 @@ -315,7 +315,8 @@ void __show_regs(struct pt_regs *regs)
1894  void show_regs(struct pt_regs * regs)
1895  {
1896         printk("\n");
1897 -       printk("Pid: %d, comm: %20s\n", task_pid_nr(current), current->comm);
1898 +       printk("Pid: %d[#%u], comm: %20s\n",
1899 +               task_pid_nr(current), current->xid, current->comm);
1900         __show_regs(regs);
1901         __backtrace();
1902  }
1903 diff -NurpP --minimal linux-3.0.4/arch/arm/kernel/traps.c linux-3.0.4-vs2.3.1/arch/arm/kernel/traps.c
1904 --- linux-3.0.4/arch/arm/kernel/traps.c 2011-07-22 11:17:32.000000000 +0200
1905 +++ linux-3.0.4-vs2.3.1/arch/arm/kernel/traps.c 2011-06-22 12:39:12.000000000 +0200
1906 @@ -242,8 +242,8 @@ static int __die(const char *str, int er
1907  
1908         print_modules();
1909         __show_regs(regs);
1910 -       printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n",
1911 -               TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1);
1912 +       printk(KERN_EMERG "Process %.*s (pid: %d:#%u, stack limit = 0x%p)\n",
1913 +               TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), tsk->xid, thread + 1);
1914  
1915         if (!user_mode(regs) || in_interrupt()) {
1916                 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
1917 diff -NurpP --minimal linux-3.0.4/arch/cris/Kconfig linux-3.0.4-vs2.3.1/arch/cris/Kconfig
1918 --- linux-3.0.4/arch/cris/Kconfig       2011-07-22 11:17:35.000000000 +0200
1919 +++ linux-3.0.4-vs2.3.1/arch/cris/Kconfig       2011-06-10 22:11:24.000000000 +0200
1920 @@ -678,6 +678,8 @@ source "drivers/staging/Kconfig"
1921  
1922  source "arch/cris/Kconfig.debug"
1923  
1924 +source "kernel/vserver/Kconfig"
1925 +
1926  source "security/Kconfig"
1927  
1928  source "crypto/Kconfig"
1929 diff -NurpP --minimal linux-3.0.4/arch/frv/kernel/kernel_thread.S linux-3.0.4-vs2.3.1/arch/frv/kernel/kernel_thread.S
1930 --- linux-3.0.4/arch/frv/kernel/kernel_thread.S 2008-12-25 00:26:37.000000000 +0100
1931 +++ linux-3.0.4-vs2.3.1/arch/frv/kernel/kernel_thread.S 2011-06-10 22:11:24.000000000 +0200
1932 @@ -37,7 +37,7 @@ kernel_thread:
1933  
1934         # start by forking the current process, but with shared VM
1935         setlos.p        #__NR_clone,gr7         ; syscall number
1936 -       ori             gr10,#CLONE_VM,gr8      ; first syscall arg     [clone_flags]
1937 +       ori             gr10,#CLONE_KT,gr8      ; first syscall arg     [clone_flags]
1938         sethi.p         #0xe4e4,gr9             ; second syscall arg    [newsp]
1939         setlo           #0xe4e4,gr9
1940         setlos.p        #0,gr10                 ; third syscall arg     [parent_tidptr]
1941 diff -NurpP --minimal linux-3.0.4/arch/h8300/Kconfig linux-3.0.4-vs2.3.1/arch/h8300/Kconfig
1942 --- linux-3.0.4/arch/h8300/Kconfig      2011-07-22 11:17:35.000000000 +0200
1943 +++ linux-3.0.4-vs2.3.1/arch/h8300/Kconfig      2011-06-10 22:11:24.000000000 +0200
1944 @@ -213,6 +213,8 @@ source "fs/Kconfig"
1945  
1946  source "arch/h8300/Kconfig.debug"
1947  
1948 +source "kernel/vserver/Kconfig"
1949 +
1950  source "security/Kconfig"
1951  
1952  source "crypto/Kconfig"
1953 diff -NurpP --minimal linux-3.0.4/arch/ia64/Kconfig linux-3.0.4-vs2.3.1/arch/ia64/Kconfig
1954 --- linux-3.0.4/arch/ia64/Kconfig       2011-07-22 11:17:35.000000000 +0200
1955 +++ linux-3.0.4-vs2.3.1/arch/ia64/Kconfig       2011-06-10 22:11:24.000000000 +0200
1956 @@ -671,6 +671,8 @@ source "fs/Kconfig"
1957  
1958  source "arch/ia64/Kconfig.debug"
1959  
1960 +source "kernel/vserver/Kconfig"
1961 +
1962  source "security/Kconfig"
1963  
1964  source "crypto/Kconfig"
1965 diff -NurpP --minimal linux-3.0.4/arch/ia64/include/asm/tlb.h linux-3.0.4-vs2.3.1/arch/ia64/include/asm/tlb.h
1966 --- linux-3.0.4/arch/ia64/include/asm/tlb.h     2011-07-22 11:17:35.000000000 +0200
1967 +++ linux-3.0.4-vs2.3.1/arch/ia64/include/asm/tlb.h     2011-06-10 22:11:24.000000000 +0200
1968 @@ -40,6 +40,7 @@
1969  #include <linux/mm.h>
1970  #include <linux/pagemap.h>
1971  #include <linux/swap.h>
1972 +#include <linux/vs_memory.h>
1973  
1974  #include <asm/pgalloc.h>
1975  #include <asm/processor.h>
1976 diff -NurpP --minimal linux-3.0.4/arch/ia64/kernel/entry.S linux-3.0.4-vs2.3.1/arch/ia64/kernel/entry.S
1977 --- linux-3.0.4/arch/ia64/kernel/entry.S        2011-07-22 11:17:35.000000000 +0200
1978 +++ linux-3.0.4-vs2.3.1/arch/ia64/kernel/entry.S        2011-06-10 22:11:24.000000000 +0200
1979 @@ -1714,7 +1714,7 @@ sys_call_table:
1980         data8 sys_mq_notify
1981         data8 sys_mq_getsetattr
1982         data8 sys_kexec_load
1983 -       data8 sys_ni_syscall                    // reserved for vserver
1984 +       data8 sys_vserver
1985         data8 sys_waitid                        // 1270
1986         data8 sys_add_key
1987         data8 sys_request_key
1988 diff -NurpP --minimal linux-3.0.4/arch/ia64/kernel/perfmon.c linux-3.0.4-vs2.3.1/arch/ia64/kernel/perfmon.c
1989 --- linux-3.0.4/arch/ia64/kernel/perfmon.c      2011-03-15 18:06:39.000000000 +0100
1990 +++ linux-3.0.4-vs2.3.1/arch/ia64/kernel/perfmon.c      2011-06-10 22:11:24.000000000 +0200
1991 @@ -42,6 +42,7 @@
1992  #include <linux/completion.h>
1993  #include <linux/tracehook.h>
1994  #include <linux/slab.h>
1995 +#include <linux/vs_memory.h>
1996  
1997  #include <asm/errno.h>
1998  #include <asm/intrinsics.h>
1999 diff -NurpP --minimal linux-3.0.4/arch/ia64/kernel/process.c linux-3.0.4-vs2.3.1/arch/ia64/kernel/process.c
2000 --- linux-3.0.4/arch/ia64/kernel/process.c      2011-03-15 18:06:39.000000000 +0100
2001 +++ linux-3.0.4-vs2.3.1/arch/ia64/kernel/process.c      2011-06-10 22:11:24.000000000 +0200
2002 @@ -109,8 +109,8 @@ show_regs (struct pt_regs *regs)
2003         unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
2004  
2005         print_modules();
2006 -       printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
2007 -                       smp_processor_id(), current->comm);
2008 +       printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
2009 +                       current->xid, smp_processor_id(), current->comm);
2010         printk("psr : %016lx ifs : %016lx ip  : [<%016lx>]    %s (%s)\n",
2011                regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
2012                init_utsname()->release);
2013 diff -NurpP --minimal linux-3.0.4/arch/ia64/kernel/ptrace.c linux-3.0.4-vs2.3.1/arch/ia64/kernel/ptrace.c
2014 --- linux-3.0.4/arch/ia64/kernel/ptrace.c       2011-01-05 21:48:59.000000000 +0100
2015 +++ linux-3.0.4-vs2.3.1/arch/ia64/kernel/ptrace.c       2011-06-10 22:11:24.000000000 +0200
2016 @@ -21,6 +21,7 @@
2017  #include <linux/regset.h>
2018  #include <linux/elf.h>
2019  #include <linux/tracehook.h>
2020 +#include <linux/vs_base.h>
2021  
2022  #include <asm/pgtable.h>
2023  #include <asm/processor.h>
2024 diff -NurpP --minimal linux-3.0.4/arch/ia64/kernel/traps.c linux-3.0.4-vs2.3.1/arch/ia64/kernel/traps.c
2025 --- linux-3.0.4/arch/ia64/kernel/traps.c        2010-07-07 18:31:01.000000000 +0200
2026 +++ linux-3.0.4-vs2.3.1/arch/ia64/kernel/traps.c        2011-06-10 22:11:24.000000000 +0200
2027 @@ -59,8 +59,9 @@ die (const char *str, struct pt_regs *re
2028         put_cpu();
2029  
2030         if (++die.lock_owner_depth < 3) {
2031 -               printk("%s[%d]: %s %ld [%d]\n",
2032 -               current->comm, task_pid_nr(current), str, err, ++die_counter);
2033 +               printk("%s[%d[#%u]]: %s %ld [%d]\n",
2034 +                       current->comm, task_pid_nr(current), current->xid,
2035 +                       str, err, ++die_counter);
2036                 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
2037                     != NOTIFY_STOP)
2038                         show_regs(regs);
2039 @@ -323,8 +324,9 @@ handle_fpu_swa (int fp_fault, struct pt_
2040                         if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
2041                                 last.time = current_jiffies + 5 * HZ;
2042                                 printk(KERN_WARNING
2043 -                                       "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
2044 -                                       current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
2045 +                                       "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
2046 +                                       current->comm, task_pid_nr(current), current->xid,
2047 +                                       regs->cr_iip + ia64_psr(regs)->ri, isr);
2048                         }
2049                 }
2050         }
2051 diff -NurpP --minimal linux-3.0.4/arch/ia64/mm/fault.c linux-3.0.4-vs2.3.1/arch/ia64/mm/fault.c
2052 --- linux-3.0.4/arch/ia64/mm/fault.c    2011-07-22 11:17:35.000000000 +0200
2053 +++ linux-3.0.4-vs2.3.1/arch/ia64/mm/fault.c    2011-06-10 22:28:23.000000000 +0200
2054 @@ -11,6 +11,7 @@
2055  #include <linux/kprobes.h>
2056  #include <linux/kdebug.h>
2057  #include <linux/prefetch.h>
2058 +#include <linux/vs_memory.h>
2059  
2060  #include <asm/pgtable.h>
2061  #include <asm/processor.h>
2062 diff -NurpP --minimal linux-3.0.4/arch/m32r/kernel/traps.c linux-3.0.4-vs2.3.1/arch/m32r/kernel/traps.c
2063 --- linux-3.0.4/arch/m32r/kernel/traps.c        2009-12-03 20:01:57.000000000 +0100
2064 +++ linux-3.0.4-vs2.3.1/arch/m32r/kernel/traps.c        2011-06-10 22:11:24.000000000 +0200
2065 @@ -196,8 +196,9 @@ static void show_registers(struct pt_reg
2066         } else {
2067                 printk("SPI: %08lx\n", sp);
2068         }
2069 -       printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
2070 -               current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
2071 +       printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
2072 +               current->comm, task_pid_nr(current), current->xid,
2073 +               0xffff & i, 4096+(unsigned long)current);
2074  
2075         /*
2076          * When in-kernel, we also print out the stack and code at the
2077 diff -NurpP --minimal linux-3.0.4/arch/m68k/Kconfig linux-3.0.4-vs2.3.1/arch/m68k/Kconfig
2078 --- linux-3.0.4/arch/m68k/Kconfig       2011-07-22 11:17:35.000000000 +0200
2079 +++ linux-3.0.4-vs2.3.1/arch/m68k/Kconfig       2011-06-10 22:11:24.000000000 +0200
2080 @@ -241,6 +241,8 @@ source "fs/Kconfig"
2081  
2082  source "arch/m68k/Kconfig.debug"
2083  
2084 +source "kernel/vserver/Kconfig"
2085 +
2086  source "security/Kconfig"
2087  
2088  source "crypto/Kconfig"
2089 diff -NurpP --minimal linux-3.0.4/arch/mips/Kconfig linux-3.0.4-vs2.3.1/arch/mips/Kconfig
2090 --- linux-3.0.4/arch/mips/Kconfig       2011-07-22 11:17:35.000000000 +0200
2091 +++ linux-3.0.4-vs2.3.1/arch/mips/Kconfig       2011-06-10 22:11:24.000000000 +0200
2092 @@ -2485,6 +2485,8 @@ source "fs/Kconfig"
2093  
2094  source "arch/mips/Kconfig.debug"
2095  
2096 +source "kernel/vserver/Kconfig"
2097 +
2098  source "security/Kconfig"
2099  
2100  source "crypto/Kconfig"
2101 diff -NurpP --minimal linux-3.0.4/arch/mips/kernel/ptrace.c linux-3.0.4-vs2.3.1/arch/mips/kernel/ptrace.c
2102 --- linux-3.0.4/arch/mips/kernel/ptrace.c       2011-07-22 11:17:36.000000000 +0200
2103 +++ linux-3.0.4-vs2.3.1/arch/mips/kernel/ptrace.c       2011-06-10 22:11:24.000000000 +0200
2104 @@ -25,6 +25,7 @@
2105  #include <linux/security.h>
2106  #include <linux/audit.h>
2107  #include <linux/seccomp.h>
2108 +#include <linux/vs_base.h>
2109  
2110  #include <asm/byteorder.h>
2111  #include <asm/cpu.h>
2112 @@ -263,6 +264,9 @@ long arch_ptrace(struct task_struct *chi
2113         void __user *datavp = (void __user *) data;
2114         unsigned long __user *datalp = (void __user *) data;
2115  
2116 +       if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
2117 +               goto out;
2118 +
2119         switch (request) {
2120         /* when I and D space are separate, these will need to be fixed. */
2121         case PTRACE_PEEKTEXT: /* read word at location addr. */
2122 diff -NurpP --minimal linux-3.0.4/arch/mips/kernel/scall32-o32.S linux-3.0.4-vs2.3.1/arch/mips/kernel/scall32-o32.S
2123 --- linux-3.0.4/arch/mips/kernel/scall32-o32.S  2011-07-22 11:17:36.000000000 +0200
2124 +++ linux-3.0.4-vs2.3.1/arch/mips/kernel/scall32-o32.S  2011-06-10 22:11:24.000000000 +0200
2125 @@ -523,7 +523,7 @@ einval:     li      v0, -ENOSYS
2126         sys     sys_mq_timedreceive     5
2127         sys     sys_mq_notify           2       /* 4275 */
2128         sys     sys_mq_getsetattr       3
2129 -       sys     sys_ni_syscall          0       /* sys_vserver */
2130 +       sys     sys_vserver             3
2131         sys     sys_waitid              5
2132         sys     sys_ni_syscall          0       /* available, was setaltroot */
2133         sys     sys_add_key             5       /* 4280 */
2134 diff -NurpP --minimal linux-3.0.4/arch/mips/kernel/scall64-64.S linux-3.0.4-vs2.3.1/arch/mips/kernel/scall64-64.S
2135 --- linux-3.0.4/arch/mips/kernel/scall64-64.S   2011-07-22 11:17:36.000000000 +0200
2136 +++ linux-3.0.4-vs2.3.1/arch/mips/kernel/scall64-64.S   2011-06-10 22:11:24.000000000 +0200
2137 @@ -362,7 +362,7 @@ sys_call_table:
2138         PTR     sys_mq_timedreceive
2139         PTR     sys_mq_notify
2140         PTR     sys_mq_getsetattr               /* 5235 */
2141 -       PTR     sys_ni_syscall                  /* sys_vserver */
2142 +       PTR     sys_vserver
2143         PTR     sys_waitid
2144         PTR     sys_ni_syscall                  /* available, was setaltroot */
2145         PTR     sys_add_key
2146 diff -NurpP --minimal linux-3.0.4/arch/mips/kernel/scall64-n32.S linux-3.0.4-vs2.3.1/arch/mips/kernel/scall64-n32.S
2147 --- linux-3.0.4/arch/mips/kernel/scall64-n32.S  2011-07-22 11:17:36.000000000 +0200
2148 +++ linux-3.0.4-vs2.3.1/arch/mips/kernel/scall64-n32.S  2011-06-10 22:11:24.000000000 +0200
2149 @@ -361,7 +361,7 @@ EXPORT(sysn32_call_table)
2150         PTR     compat_sys_mq_timedreceive
2151         PTR     compat_sys_mq_notify
2152         PTR     compat_sys_mq_getsetattr
2153 -       PTR     sys_ni_syscall                  /* 6240, sys_vserver */
2154 +       PTR     sys32_vserver                   /* 6240 */
2155         PTR     compat_sys_waitid
2156         PTR     sys_ni_syscall                  /* available, was setaltroot */
2157         PTR     sys_add_key
2158 diff -NurpP --minimal linux-3.0.4/arch/mips/kernel/scall64-o32.S linux-3.0.4-vs2.3.1/arch/mips/kernel/scall64-o32.S
2159 --- linux-3.0.4/arch/mips/kernel/scall64-o32.S  2011-07-22 11:17:36.000000000 +0200
2160 +++ linux-3.0.4-vs2.3.1/arch/mips/kernel/scall64-o32.S  2011-06-10 22:11:24.000000000 +0200
2161 @@ -480,7 +480,7 @@ sys_call_table:
2162         PTR     compat_sys_mq_timedreceive
2163         PTR     compat_sys_mq_notify            /* 4275 */
2164         PTR     compat_sys_mq_getsetattr
2165 -       PTR     sys_ni_syscall                  /* sys_vserver */
2166 +       PTR     sys32_vserver
2167         PTR     sys_32_waitid
2168         PTR     sys_ni_syscall                  /* available, was setaltroot */
2169         PTR     sys_add_key                     /* 4280 */
2170 diff -NurpP --minimal linux-3.0.4/arch/mips/kernel/traps.c linux-3.0.4-vs2.3.1/arch/mips/kernel/traps.c
2171 --- linux-3.0.4/arch/mips/kernel/traps.c        2011-05-22 16:17:00.000000000 +0200
2172 +++ linux-3.0.4-vs2.3.1/arch/mips/kernel/traps.c        2011-06-10 22:11:24.000000000 +0200
2173 @@ -343,9 +343,10 @@ void show_registers(struct pt_regs *regs
2174  
2175         __show_regs(regs);
2176         print_modules();
2177 -       printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
2178 -              current->comm, current->pid, current_thread_info(), current,
2179 -             field, current_thread_info()->tp_value);
2180 +       printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
2181 +               current->comm, task_pid_nr(current), current->xid,
2182 +               current_thread_info(), current,
2183 +               field, current_thread_info()->tp_value);
2184         if (cpu_has_userlocal) {
2185                 unsigned long tls;
2186  
2187 diff -NurpP --minimal linux-3.0.4/arch/parisc/Kconfig linux-3.0.4-vs2.3.1/arch/parisc/Kconfig
2188 --- linux-3.0.4/arch/parisc/Kconfig     2011-07-22 11:17:36.000000000 +0200
2189 +++ linux-3.0.4-vs2.3.1/arch/parisc/Kconfig     2011-06-10 22:11:24.000000000 +0200
2190 @@ -279,6 +279,8 @@ source "fs/Kconfig"
2191  
2192  source "arch/parisc/Kconfig.debug"
2193  
2194 +source "kernel/vserver/Kconfig"
2195 +
2196  source "security/Kconfig"
2197  
2198  source "crypto/Kconfig"
2199 diff -NurpP --minimal linux-3.0.4/arch/parisc/kernel/syscall_table.S linux-3.0.4-vs2.3.1/arch/parisc/kernel/syscall_table.S
2200 --- linux-3.0.4/arch/parisc/kernel/syscall_table.S      2011-08-31 18:56:40.000000000 +0200
2201 +++ linux-3.0.4-vs2.3.1/arch/parisc/kernel/syscall_table.S      2011-08-29 03:45:07.000000000 +0200
2202 @@ -361,7 +361,7 @@
2203         ENTRY_COMP(mbind)               /* 260 */
2204         ENTRY_COMP(get_mempolicy)
2205         ENTRY_COMP(set_mempolicy)
2206 -       ENTRY_SAME(ni_syscall)  /* 263: reserved for vserver */
2207 +       ENTRY_DIFF(vserver)
2208         ENTRY_SAME(add_key)
2209         ENTRY_SAME(request_key)         /* 265 */
2210         ENTRY_SAME(keyctl)
2211 diff -NurpP --minimal linux-3.0.4/arch/parisc/kernel/traps.c linux-3.0.4-vs2.3.1/arch/parisc/kernel/traps.c
2212 --- linux-3.0.4/arch/parisc/kernel/traps.c      2009-09-10 15:25:40.000000000 +0200
2213 +++ linux-3.0.4-vs2.3.1/arch/parisc/kernel/traps.c      2011-06-10 22:11:24.000000000 +0200
2214 @@ -236,8 +236,9 @@ void die_if_kernel(char *str, struct pt_
2215                 if (err == 0)
2216                         return; /* STFU */
2217  
2218 -               printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
2219 -                       current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
2220 +               printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
2221 +                       current->comm, task_pid_nr(current), current->xid,
2222 +                       str, err, regs->iaoq[0]);
2223  #ifdef PRINT_USER_FAULTS
2224                 /* XXX for debugging only */
2225                 show_regs(regs);
2226 @@ -270,8 +271,8 @@ void die_if_kernel(char *str, struct pt_
2227                 pdc_console_restart();
2228         
2229         if (err)
2230 -               printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
2231 -                       current->comm, task_pid_nr(current), str, err);
2232 +               printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
2233 +                       current->comm, task_pid_nr(current), current->xid, str, err);
2234  
2235         /* Wot's wrong wif bein' racy? */
2236         if (current->thread.flags & PARISC_KERNEL_DEATH) {
2237 diff -NurpP --minimal linux-3.0.4/arch/parisc/mm/fault.c linux-3.0.4-vs2.3.1/arch/parisc/mm/fault.c
2238 --- linux-3.0.4/arch/parisc/mm/fault.c  2010-08-02 16:52:06.000000000 +0200
2239 +++ linux-3.0.4-vs2.3.1/arch/parisc/mm/fault.c  2011-06-10 22:11:24.000000000 +0200
2240 @@ -237,8 +237,9 @@ bad_area:
2241  
2242  #ifdef PRINT_USER_FAULTS
2243                 printk(KERN_DEBUG "\n");
2244 -               printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
2245 -                   task_pid_nr(tsk), tsk->comm, code, address);
2246 +               printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
2247 +                   "command='%s' type=%lu address=0x%08lx\n",
2248 +                   task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
2249                 if (vma) {
2250                         printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
2251                                         vma->vm_start, vma->vm_end);
2252 diff -NurpP --minimal linux-3.0.4/arch/powerpc/Kconfig linux-3.0.4-vs2.3.1/arch/powerpc/Kconfig
2253 --- linux-3.0.4/arch/powerpc/Kconfig    2011-07-22 11:17:36.000000000 +0200
2254 +++ linux-3.0.4-vs2.3.1/arch/powerpc/Kconfig    2011-06-10 22:11:24.000000000 +0200
2255 @@ -978,6 +978,8 @@ source "lib/Kconfig"
2256  
2257  source "arch/powerpc/Kconfig.debug"
2258  
2259 +source "kernel/vserver/Kconfig"
2260 +
2261  source "security/Kconfig"
2262  
2263  config KEYS_COMPAT
2264 diff -NurpP --minimal linux-3.0.4/arch/powerpc/include/asm/unistd.h linux-3.0.4-vs2.3.1/arch/powerpc/include/asm/unistd.h
2265 --- linux-3.0.4/arch/powerpc/include/asm/unistd.h       2011-07-22 11:17:40.000000000 +0200
2266 +++ linux-3.0.4-vs2.3.1/arch/powerpc/include/asm/unistd.h       2011-06-10 22:11:24.000000000 +0200
2267 @@ -275,7 +275,7 @@
2268  #endif
2269  #define __NR_rtas              255
2270  #define __NR_sys_debug_setcontext 256
2271 -/* Number 257 is reserved for vserver */
2272 +#define __NR_vserver           257
2273  #define __NR_migrate_pages     258
2274  #define __NR_mbind             259
2275  #define __NR_get_mempolicy     260
2276 diff -NurpP --minimal linux-3.0.4/arch/powerpc/kernel/process.c linux-3.0.4-vs2.3.1/arch/powerpc/kernel/process.c
2277 --- linux-3.0.4/arch/powerpc/kernel/process.c   2011-07-22 11:17:40.000000000 +0200
2278 +++ linux-3.0.4-vs2.3.1/arch/powerpc/kernel/process.c   2011-06-10 22:11:24.000000000 +0200
2279 @@ -656,8 +656,9 @@ void show_regs(struct pt_regs * regs)
2280  #else
2281                 printk("DAR: "REG", DSISR: %08lx\n", regs->dar, regs->dsisr);
2282  #endif
2283 -       printk("TASK = %p[%d] '%s' THREAD: %p",
2284 -              current, task_pid_nr(current), current->comm, task_thread_info(current));
2285 +       printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
2286 +              current, task_pid_nr(current), current->xid,
2287 +              current->comm, task_thread_info(current));
2288  
2289  #ifdef CONFIG_SMP
2290         printk(" CPU: %d", raw_smp_processor_id());
2291 diff -NurpP --minimal linux-3.0.4/arch/powerpc/kernel/traps.c linux-3.0.4-vs2.3.1/arch/powerpc/kernel/traps.c
2292 --- linux-3.0.4/arch/powerpc/kernel/traps.c     2011-07-22 11:17:40.000000000 +0200
2293 +++ linux-3.0.4-vs2.3.1/arch/powerpc/kernel/traps.c     2011-07-19 00:44:39.000000000 +0200
2294 @@ -1075,8 +1075,9 @@ void nonrecoverable_exception(struct pt_
2295  
2296  void trace_syscall(struct pt_regs *regs)
2297  {
2298 -       printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld    %s\n",
2299 -              current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
2300 +       printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld    %s\n",
2301 +              current, task_pid_nr(current), current->xid,
2302 +              regs->nip, regs->link, regs->gpr[0],
2303                regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
2304  }
2305  
2306 diff -NurpP --minimal linux-3.0.4/arch/powerpc/kernel/vdso.c linux-3.0.4-vs2.3.1/arch/powerpc/kernel/vdso.c
2307 --- linux-3.0.4/arch/powerpc/kernel/vdso.c      2011-05-22 16:17:02.000000000 +0200
2308 +++ linux-3.0.4-vs2.3.1/arch/powerpc/kernel/vdso.c      2011-06-10 22:11:24.000000000 +0200
2309 @@ -23,6 +23,7 @@
2310  #include <linux/security.h>
2311  #include <linux/bootmem.h>
2312  #include <linux/memblock.h>
2313 +#include <linux/vs_memory.h>
2314  
2315  #include <asm/pgtable.h>
2316  #include <asm/system.h>
2317 diff -NurpP --minimal linux-3.0.4/arch/s390/Kconfig linux-3.0.4-vs2.3.1/arch/s390/Kconfig
2318 --- linux-3.0.4/arch/s390/Kconfig       2011-07-22 11:17:41.000000000 +0200
2319 +++ linux-3.0.4-vs2.3.1/arch/s390/Kconfig       2011-07-01 11:35:34.000000000 +0200
2320 @@ -628,6 +628,8 @@ source "fs/Kconfig"
2321  
2322  source "arch/s390/Kconfig.debug"
2323  
2324 +source "kernel/vserver/Kconfig"
2325 +
2326  source "security/Kconfig"
2327  
2328  source "crypto/Kconfig"
2329 diff -NurpP --minimal linux-3.0.4/arch/s390/include/asm/tlb.h linux-3.0.4-vs2.3.1/arch/s390/include/asm/tlb.h
2330 --- linux-3.0.4/arch/s390/include/asm/tlb.h     2011-07-22 11:17:41.000000000 +0200
2331 +++ linux-3.0.4-vs2.3.1/arch/s390/include/asm/tlb.h     2011-06-15 02:40:14.000000000 +0200
2332 @@ -24,6 +24,8 @@
2333  #include <linux/mm.h>
2334  #include <linux/pagemap.h>
2335  #include <linux/swap.h>
2336 +#include <linux/vs_memory.h>
2337 +
2338  #include <asm/processor.h>
2339  #include <asm/pgalloc.h>
2340  #include <asm/tlbflush.h>
2341 diff -NurpP --minimal linux-3.0.4/arch/s390/include/asm/unistd.h linux-3.0.4-vs2.3.1/arch/s390/include/asm/unistd.h
2342 --- linux-3.0.4/arch/s390/include/asm/unistd.h  2011-07-22 11:17:41.000000000 +0200
2343 +++ linux-3.0.4-vs2.3.1/arch/s390/include/asm/unistd.h  2011-06-10 22:11:24.000000000 +0200
2344 @@ -202,7 +202,7 @@
2345  #define __NR_clock_gettime     (__NR_timer_create+6)
2346  #define __NR_clock_getres      (__NR_timer_create+7)
2347  #define __NR_clock_nanosleep   (__NR_timer_create+8)
2348 -/* Number 263 is reserved for vserver */
2349 +#define __NR_vserver           263
2350  #define __NR_statfs64          265
2351  #define __NR_fstatfs64         266
2352  #define __NR_remap_file_pages  267
2353 diff -NurpP --minimal linux-3.0.4/arch/s390/kernel/ptrace.c linux-3.0.4-vs2.3.1/arch/s390/kernel/ptrace.c
2354 --- linux-3.0.4/arch/s390/kernel/ptrace.c       2011-03-15 18:06:45.000000000 +0100
2355 +++ linux-3.0.4-vs2.3.1/arch/s390/kernel/ptrace.c       2011-06-10 22:11:24.000000000 +0200
2356 @@ -20,6 +20,7 @@
2357  #include <linux/regset.h>
2358  #include <linux/tracehook.h>
2359  #include <linux/seccomp.h>
2360 +#include <linux/vs_base.h>
2361  #include <trace/syscall.h>
2362  #include <asm/compat.h>
2363  #include <asm/segment.h>
2364 diff -NurpP --minimal linux-3.0.4/arch/s390/kernel/syscalls.S linux-3.0.4-vs2.3.1/arch/s390/kernel/syscalls.S
2365 --- linux-3.0.4/arch/s390/kernel/syscalls.S     2011-07-22 11:17:41.000000000 +0200
2366 +++ linux-3.0.4-vs2.3.1/arch/s390/kernel/syscalls.S     2011-06-10 22:11:24.000000000 +0200
2367 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
2368  SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper)       /* 260 */
2369  SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
2370  SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
2371 -NI_SYSCALL                                                     /* reserved for vserver */
2372 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
2373  SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
2374  SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
2375  SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
2376 diff -NurpP --minimal linux-3.0.4/arch/sh/Kconfig linux-3.0.4-vs2.3.1/arch/sh/Kconfig
2377 --- linux-3.0.4/arch/sh/Kconfig 2011-07-22 11:17:41.000000000 +0200
2378 +++ linux-3.0.4-vs2.3.1/arch/sh/Kconfig 2011-07-19 00:44:39.000000000 +0200
2379 @@ -893,6 +893,8 @@ source "fs/Kconfig"
2380  
2381  source "arch/sh/Kconfig.debug"
2382  
2383 +source "kernel/vserver/Kconfig"
2384 +
2385  source "security/Kconfig"
2386  
2387  source "crypto/Kconfig"
2388 diff -NurpP --minimal linux-3.0.4/arch/sh/kernel/irq.c linux-3.0.4-vs2.3.1/arch/sh/kernel/irq.c
2389 --- linux-3.0.4/arch/sh/kernel/irq.c    2011-07-22 11:17:41.000000000 +0200
2390 +++ linux-3.0.4-vs2.3.1/arch/sh/kernel/irq.c    2011-07-19 00:45:06.000000000 +0200
2391 @@ -14,6 +14,7 @@
2392  #include <linux/ftrace.h>
2393  #include <linux/delay.h>
2394  #include <linux/ratelimit.h>
2395 +// #include <linux/vs_context.h>
2396  #include <asm/processor.h>
2397  #include <asm/machvec.h>
2398  #include <asm/uaccess.h>
2399 diff -NurpP --minimal linux-3.0.4/arch/sh/kernel/vsyscall/vsyscall.c linux-3.0.4-vs2.3.1/arch/sh/kernel/vsyscall/vsyscall.c
2400 --- linux-3.0.4/arch/sh/kernel/vsyscall/vsyscall.c      2011-05-22 16:17:07.000000000 +0200
2401 +++ linux-3.0.4-vs2.3.1/arch/sh/kernel/vsyscall/vsyscall.c      2011-06-10 22:11:24.000000000 +0200
2402 @@ -18,6 +18,7 @@
2403  #include <linux/elf.h>
2404  #include <linux/sched.h>
2405  #include <linux/err.h>
2406 +#include <linux/vs_memory.h>
2407  
2408  /*
2409   * Should the kernel map a VDSO page into processes and pass its
2410 diff -NurpP --minimal linux-3.0.4/arch/sparc/Kconfig linux-3.0.4-vs2.3.1/arch/sparc/Kconfig
2411 --- linux-3.0.4/arch/sparc/Kconfig      2011-07-22 11:17:41.000000000 +0200
2412 +++ linux-3.0.4-vs2.3.1/arch/sparc/Kconfig      2011-06-15 02:40:14.000000000 +0200
2413 @@ -601,6 +601,8 @@ source "fs/Kconfig"
2414  
2415  source "arch/sparc/Kconfig.debug"
2416  
2417 +source "kernel/vserver/Kconfig"
2418 +
2419  source "security/Kconfig"
2420  
2421  source "crypto/Kconfig"
2422 diff -NurpP --minimal linux-3.0.4/arch/sparc/include/asm/tlb_64.h linux-3.0.4-vs2.3.1/arch/sparc/include/asm/tlb_64.h
2423 --- linux-3.0.4/arch/sparc/include/asm/tlb_64.h 2011-07-22 11:17:42.000000000 +0200
2424 +++ linux-3.0.4-vs2.3.1/arch/sparc/include/asm/tlb_64.h 2011-06-10 22:11:24.000000000 +0200
2425 @@ -3,6 +3,7 @@
2426  
2427  #include <linux/swap.h>
2428  #include <linux/pagemap.h>
2429 +#include <linux/vs_memory.h>
2430  #include <asm/pgalloc.h>
2431  #include <asm/tlbflush.h>
2432  #include <asm/mmu_context.h>
2433 diff -NurpP --minimal linux-3.0.4/arch/sparc/include/asm/unistd.h linux-3.0.4-vs2.3.1/arch/sparc/include/asm/unistd.h
2434 --- linux-3.0.4/arch/sparc/include/asm/unistd.h 2011-07-22 11:17:42.000000000 +0200
2435 +++ linux-3.0.4-vs2.3.1/arch/sparc/include/asm/unistd.h 2011-06-10 22:11:24.000000000 +0200
2436 @@ -335,7 +335,7 @@
2437  #define __NR_timer_getoverrun  264
2438  #define __NR_timer_delete      265
2439  #define __NR_timer_create      266
2440 -/* #define __NR_vserver                267 Reserved for VSERVER */
2441 +#define __NR_vserver           267
2442  #define __NR_io_setup          268
2443  #define __NR_io_destroy                269
2444  #define __NR_io_submit         270
2445 diff -NurpP --minimal linux-3.0.4/arch/sparc/kernel/systbls_32.S linux-3.0.4-vs2.3.1/arch/sparc/kernel/systbls_32.S
2446 --- linux-3.0.4/arch/sparc/kernel/systbls_32.S  2011-07-22 11:17:42.000000000 +0200
2447 +++ linux-3.0.4-vs2.3.1/arch/sparc/kernel/systbls_32.S  2011-06-10 22:11:24.000000000 +0200
2448 @@ -70,7 +70,7 @@ sys_call_table:
2449  /*250*/        .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
2450  /*255*/        .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
2451  /*260*/        .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
2452 -/*265*/        .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
2453 +/*265*/        .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
2454  /*270*/        .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
2455  /*275*/        .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
2456  /*280*/        .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
2457 diff -NurpP --minimal linux-3.0.4/arch/sparc/kernel/systbls_64.S linux-3.0.4-vs2.3.1/arch/sparc/kernel/systbls_64.S
2458 --- linux-3.0.4/arch/sparc/kernel/systbls_64.S  2011-07-22 11:17:42.000000000 +0200
2459 +++ linux-3.0.4-vs2.3.1/arch/sparc/kernel/systbls_64.S  2011-06-10 22:11:24.000000000 +0200
2460 @@ -71,7 +71,7 @@ sys_call_table32:
2461  /*250*/        .word sys_mremap, compat_sys_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
2462         .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
2463  /*260*/        .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
2464 -       .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
2465 +       .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
2466  /*270*/        .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
2467         .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
2468  /*280*/        .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
2469 @@ -148,7 +148,7 @@ sys_call_table:
2470  /*250*/        .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
2471         .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
2472  /*260*/        .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
2473 -       .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
2474 +       .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
2475  /*270*/        .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
2476         .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
2477  /*280*/        .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
2478 diff -NurpP --minimal linux-3.0.4/arch/um/Kconfig.rest linux-3.0.4-vs2.3.1/arch/um/Kconfig.rest
2479 --- linux-3.0.4/arch/um/Kconfig.rest    2009-06-11 17:12:19.000000000 +0200
2480 +++ linux-3.0.4-vs2.3.1/arch/um/Kconfig.rest    2011-06-10 22:11:24.000000000 +0200
2481 @@ -18,6 +18,8 @@ source "drivers/connector/Kconfig"
2482  
2483  source "fs/Kconfig"
2484  
2485 +source "kernel/vserver/Kconfig"
2486 +
2487  source "security/Kconfig"
2488  
2489  source "crypto/Kconfig"
2490 diff -NurpP --minimal linux-3.0.4/arch/um/include/asm/tlb.h linux-3.0.4-vs2.3.1/arch/um/include/asm/tlb.h
2491 --- linux-3.0.4/arch/um/include/asm/tlb.h       2011-07-22 11:17:42.000000000 +0200
2492 +++ linux-3.0.4-vs2.3.1/arch/um/include/asm/tlb.h       2011-06-10 22:11:24.000000000 +0200
2493 @@ -3,6 +3,7 @@
2494  
2495  #include <linux/pagemap.h>
2496  #include <linux/swap.h>
2497 +#include <linux/vs_memory.h>
2498  #include <asm/percpu.h>
2499  #include <asm/pgalloc.h>
2500  #include <asm/tlbflush.h>
2501 diff -NurpP --minimal linux-3.0.4/arch/um/include/shared/kern_constants.h linux-3.0.4-vs2.3.1/arch/um/include/shared/kern_constants.h
2502 --- linux-3.0.4/arch/um/include/shared/kern_constants.h 1970-01-01 01:00:00.000000000 +0100
2503 +++ linux-3.0.4-vs2.3.1/arch/um/include/shared/kern_constants.h 2011-06-10 22:11:24.000000000 +0200
2504 @@ -0,0 +1 @@
2505 +#include "../../../../include/generated/asm-offsets.h"
2506 diff -NurpP --minimal linux-3.0.4/arch/um/include/shared/user_constants.h linux-3.0.4-vs2.3.1/arch/um/include/shared/user_constants.h
2507 --- linux-3.0.4/arch/um/include/shared/user_constants.h 1970-01-01 01:00:00.000000000 +0100
2508 +++ linux-3.0.4-vs2.3.1/arch/um/include/shared/user_constants.h 2011-06-10 22:11:24.000000000 +0200
2509 @@ -0,0 +1,40 @@
2510 +/*
2511 + * DO NOT MODIFY.
2512 + *
2513 + * This file was generated by arch/um/Makefile
2514 + *
2515 + */
2516 +
2517 +#define HOST_SC_CR2 176 /* offsetof(struct sigcontext, cr2)    # */
2518 +#define HOST_SC_ERR 152 /* offsetof(struct sigcontext, err)    # */
2519 +#define HOST_SC_TRAPNO 160 /* offsetof(struct sigcontext, trapno)      # */
2520 +#define HOST_FP_SIZE 64 /* sizeof(struct _fpstate) / sizeof(unsigned long)     # */
2521 +#define HOST_RBX 5 /* RBX      # */
2522 +#define HOST_RCX 11 /* RCX     # */
2523 +#define HOST_RDI 14 /* RDI     # */
2524 +#define HOST_RSI 13 /* RSI     # */
2525 +#define HOST_RDX 12 /* RDX     # */
2526 +#define HOST_RBP 4 /* RBP      # */
2527 +#define HOST_RAX 10 /* RAX     # */
2528 +#define HOST_R8 9 /* R8        # */
2529 +#define HOST_R9 8 /* R9        # */
2530 +#define HOST_R10 7 /* R10      # */
2531 +#define HOST_R11 6 /* R11      # */
2532 +#define HOST_R12 3 /* R12      # */
2533 +#define HOST_R13 2 /* R13      # */
2534 +#define HOST_R14 1 /* R14      # */
2535 +#define HOST_R15 0 /* R15      # */
2536 +#define HOST_ORIG_RAX 15 /* ORIG_RAX   # */
2537 +#define HOST_CS 17 /* CS       # */
2538 +#define HOST_SS 20 /* SS       # */
2539 +#define HOST_EFLAGS 18 /* EFLAGS       # */
2540 +#define HOST_IP 16 /* RIP      # */
2541 +#define HOST_SP 19 /* RSP      # */
2542 +#define UM_FRAME_SIZE 216 /* sizeof(struct user_regs_struct)   # */
2543 +#define UM_POLLIN 1 /* POLLIN  # */
2544 +#define UM_POLLPRI 2 /* POLLPRI        # */
2545 +#define UM_POLLOUT 4 /* POLLOUT        # */
2546 +#define UM_PROT_READ 1 /* PROT_READ    # */
2547 +#define UM_PROT_WRITE 2 /* PROT_WRITE  # */
2548 +#define UM_PROT_EXEC 4 /* PROT_EXEC    # */
2549 +
2550 diff -NurpP --minimal linux-3.0.4/arch/x86/Kconfig linux-3.0.4-vs2.3.1/arch/x86/Kconfig
2551 --- linux-3.0.4/arch/x86/Kconfig        2011-07-22 11:17:42.000000000 +0200
2552 +++ linux-3.0.4-vs2.3.1/arch/x86/Kconfig        2011-07-22 11:20:39.000000000 +0200
2553 @@ -2159,6 +2159,8 @@ source "fs/Kconfig"
2554  
2555  source "arch/x86/Kconfig.debug"
2556  
2557 +source "kernel/vserver/Kconfig"
2558 +
2559  source "security/Kconfig"
2560  
2561  source "crypto/Kconfig"
2562 diff -NurpP --minimal linux-3.0.4/arch/x86/ia32/ia32entry.S linux-3.0.4-vs2.3.1/arch/x86/ia32/ia32entry.S
2563 --- linux-3.0.4/arch/x86/ia32/ia32entry.S       2011-07-22 11:17:42.000000000 +0200
2564 +++ linux-3.0.4-vs2.3.1/arch/x86/ia32/ia32entry.S       2011-06-10 22:11:24.000000000 +0200
2565 @@ -776,7 +776,7 @@ ia32_sys_call_table:
2566         .quad sys_tgkill                /* 270 */
2567         .quad compat_sys_utimes
2568         .quad sys32_fadvise64_64
2569 -       .quad quiet_ni_syscall  /* sys_vserver */
2570 +       .quad sys32_vserver
2571         .quad sys_mbind
2572         .quad compat_sys_get_mempolicy  /* 275 */
2573         .quad sys_set_mempolicy
2574 diff -NurpP --minimal linux-3.0.4/arch/x86/include/asm/unistd_64.h linux-3.0.4-vs2.3.1/arch/x86/include/asm/unistd_64.h
2575 --- linux-3.0.4/arch/x86/include/asm/unistd_64.h        2011-07-22 11:17:43.000000000 +0200
2576 +++ linux-3.0.4-vs2.3.1/arch/x86/include/asm/unistd_64.h        2011-06-10 22:11:24.000000000 +0200
2577 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
2578  #define __NR_utimes                            235
2579  __SYSCALL(__NR_utimes, sys_utimes)
2580  #define __NR_vserver                           236
2581 -__SYSCALL(__NR_vserver, sys_ni_syscall)
2582 +__SYSCALL(__NR_vserver, sys_vserver)
2583  #define __NR_mbind                             237
2584  __SYSCALL(__NR_mbind, sys_mbind)
2585  #define __NR_set_mempolicy                     238
2586 diff -NurpP --minimal linux-3.0.4/arch/x86/kernel/syscall_table_32.S linux-3.0.4-vs2.3.1/arch/x86/kernel/syscall_table_32.S
2587 --- linux-3.0.4/arch/x86/kernel/syscall_table_32.S      2011-07-22 11:17:43.000000000 +0200
2588 +++ linux-3.0.4-vs2.3.1/arch/x86/kernel/syscall_table_32.S      2011-06-10 22:11:24.000000000 +0200
2589 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
2590         .long sys_tgkill        /* 270 */
2591         .long sys_utimes
2592         .long sys_fadvise64_64
2593 -       .long sys_ni_syscall    /* sys_vserver */
2594 +       .long sys_vserver
2595         .long sys_mbind
2596         .long sys_get_mempolicy
2597         .long sys_set_mempolicy
2598 diff -NurpP --minimal linux-3.0.4/block/genhd.c linux-3.0.4-vs2.3.1/block/genhd.c
2599 --- linux-3.0.4/block/genhd.c   2011-07-22 11:17:43.000000000 +0200
2600 +++ linux-3.0.4-vs2.3.1/block/genhd.c   2011-07-01 11:35:34.000000000 +0200
2601 @@ -1154,17 +1154,17 @@ static int diskstats_show(struct seq_fil
2602                 cpu = part_stat_lock();
2603                 part_round_stats(cpu, hd);
2604                 part_stat_unlock();
2605 -               seq_printf(seqf, "%4d %7d %s %lu %lu %llu "
2606 -                          "%u %lu %lu %llu %u %u %u %u\n",
2607 +               seq_printf(seqf, "%4d %7d %s %lu %lu %lu "
2608 +                          "%u %lu %lu %lu %u %u %u %u\n",
2609                            MAJOR(part_devt(hd)), MINOR(part_devt(hd)),
2610                            disk_name(gp, hd->partno, buf),
2611                            part_stat_read(hd, ios[READ]),
2612                            part_stat_read(hd, merges[READ]),
2613 -                          (unsigned long long)part_stat_read(hd, sectors[READ]),
2614 +                          part_stat_read(hd, sectors[READ]),
2615                            jiffies_to_msecs(part_stat_read(hd, ticks[READ])),
2616                            part_stat_read(hd, ios[WRITE]),
2617                            part_stat_read(hd, merges[WRITE]),
2618 -                          (unsigned long long)part_stat_read(hd, sectors[WRITE]),
2619 +                          part_stat_read(hd, sectors[WRITE]),
2620                            jiffies_to_msecs(part_stat_read(hd, ticks[WRITE])),
2621                            part_in_flight(hd),
2622                            jiffies_to_msecs(part_stat_read(hd, io_ticks)),
2623 diff -NurpP --minimal linux-3.0.4/drivers/block/Kconfig linux-3.0.4-vs2.3.1/drivers/block/Kconfig
2624 --- linux-3.0.4/drivers/block/Kconfig   2011-07-22 11:17:44.000000000 +0200
2625 +++ linux-3.0.4-vs2.3.1/drivers/block/Kconfig   2011-06-10 22:11:24.000000000 +0200
2626 @@ -273,6 +273,13 @@ config BLK_DEV_CRYPTOLOOP
2627  
2628  source "drivers/block/drbd/Kconfig"
2629  
2630 +config BLK_DEV_VROOT
2631 +       tristate "Virtual Root device support"
2632 +       depends on QUOTACTL
2633 +       ---help---
2634 +         Saying Y here will allow you to use quota/fs ioctls on a shared
2635 +         partition within a virtual server without compromising security.
2636 +
2637  config BLK_DEV_NBD
2638         tristate "Network block device support"
2639         depends on NET
2640 diff -NurpP --minimal linux-3.0.4/drivers/block/Makefile linux-3.0.4-vs2.3.1/drivers/block/Makefile
2641 --- linux-3.0.4/drivers/block/Makefile  2011-07-22 11:17:44.000000000 +0200
2642 +++ linux-3.0.4-vs2.3.1/drivers/block/Makefile  2011-06-10 22:11:24.000000000 +0200
2643 @@ -34,6 +34,7 @@ obj-$(CONFIG_VIODASD)         += viodasd.o
2644  obj-$(CONFIG_BLK_DEV_SX8)      += sx8.o
2645  obj-$(CONFIG_BLK_DEV_UB)       += ub.o
2646  obj-$(CONFIG_BLK_DEV_HD)       += hd.o
2647 +obj-$(CONFIG_BLK_DEV_VROOT)    += vroot.o
2648  
2649  obj-$(CONFIG_XEN_BLKDEV_FRONTEND)      += xen-blkfront.o
2650  obj-$(CONFIG_XEN_BLKDEV_BACKEND)       += xen-blkback/
2651 diff -NurpP --minimal linux-3.0.4/drivers/block/loop.c linux-3.0.4-vs2.3.1/drivers/block/loop.c
2652 --- linux-3.0.4/drivers/block/loop.c    2011-08-31 18:56:40.000000000 +0200
2653 +++ linux-3.0.4-vs2.3.1/drivers/block/loop.c    2011-08-31 19:37:44.000000000 +0200
2654 @@ -75,6 +75,7 @@
2655  #include <linux/kthread.h>
2656  #include <linux/splice.h>
2657  #include <linux/sysfs.h>
2658 +#include <linux/vs_context.h>
2659  
2660  #include <asm/uaccess.h>
2661  
2662 @@ -891,6 +892,7 @@ static int loop_set_fd(struct loop_devic
2663         lo->lo_blocksize = lo_blocksize;
2664         lo->lo_device = bdev;
2665         lo->lo_flags = lo_flags;
2666 +       lo->lo_xid = vx_current_xid();
2667         lo->lo_backing_file = file;
2668         lo->transfer = transfer_none;
2669         lo->ioctl = NULL;
2670 @@ -1021,6 +1023,7 @@ static int loop_clr_fd(struct loop_devic
2671         lo->lo_encrypt_key_size = 0;
2672         lo->lo_flags = 0;
2673         lo->lo_thread = NULL;
2674 +       lo->lo_xid = 0;
2675         memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
2676         memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
2677         memset(lo->lo_file_name, 0, LO_NAME_SIZE);
2678 @@ -1059,7 +1062,7 @@ loop_set_status(struct loop_device *lo, 
2679  
2680         if (lo->lo_encrypt_key_size &&
2681             lo->lo_key_owner != uid &&
2682 -           !capable(CAP_SYS_ADMIN))
2683 +           !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
2684                 return -EPERM;
2685         if (lo->lo_state != Lo_bound)
2686                 return -ENXIO;
2687 @@ -1143,7 +1146,8 @@ loop_get_status(struct loop_device *lo, 
2688         memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
2689         info->lo_encrypt_type =
2690                 lo->lo_encryption ? lo->lo_encryption->number : 0;
2691 -       if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
2692 +       if (lo->lo_encrypt_key_size &&
2693 +               vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
2694                 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
2695                 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
2696                        lo->lo_encrypt_key_size);
2697 @@ -1489,6 +1493,9 @@ static int lo_open(struct block_device *
2698  {
2699         struct loop_device *lo = bdev->bd_disk->private_data;
2700  
2701 +       if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P))
2702 +               return -EACCES;
2703 +
2704         mutex_lock(&lo->lo_ctl_mutex);
2705         lo->lo_refcnt++;
2706         mutex_unlock(&lo->lo_ctl_mutex);
2707 diff -NurpP --minimal linux-3.0.4/drivers/block/vroot.c linux-3.0.4-vs2.3.1/drivers/block/vroot.c
2708 --- linux-3.0.4/drivers/block/vroot.c   1970-01-01 01:00:00.000000000 +0100
2709 +++ linux-3.0.4-vs2.3.1/drivers/block/vroot.c   2011-06-10 22:11:24.000000000 +0200
2710 @@ -0,0 +1,292 @@
2711 +/*
2712 + *  linux/drivers/block/vroot.c
2713 + *
2714 + *  written by Herbert Pötzl, 9/11/2002
2715 + *  ported to 2.6.10 by Herbert Pötzl, 30/12/2004
2716 + *
2717 + *  based on the loop.c code by Theodore Ts'o.
2718 + *
2719 + * Copyright (C) 2002-2007 by Herbert Pötzl.
2720 + * Redistribution of this file is permitted under the
2721 + * GNU General Public License.
2722 + *
2723 + */
2724 +
2725 +#include <linux/module.h>
2726 +#include <linux/moduleparam.h>
2727 +#include <linux/file.h>
2728 +#include <linux/major.h>
2729 +#include <linux/blkdev.h>
2730 +#include <linux/slab.h>
2731 +
2732 +#include <linux/vroot.h>
2733 +#include <linux/vs_context.h>
2734 +
2735 +
2736 +static int max_vroot = 8;
2737 +
2738 +static struct vroot_device *vroot_dev;
2739 +static struct gendisk **disks;
2740 +
2741 +
2742 +static int vroot_set_dev(
2743 +       struct vroot_device *vr,
2744 +       struct block_device *bdev,
2745 +       unsigned int arg)
2746 +{
2747 +       struct block_device *real_bdev;
2748 +       struct file *file;
2749 +       struct inode *inode;
2750 +       int error;
2751 +
2752 +       error = -EBUSY;
2753 +       if (vr->vr_state != Vr_unbound)
2754 +               goto out;
2755 +
2756 +       error = -EBADF;
2757 +       file = fget(arg);
2758 +       if (!file)
2759 +               goto out;
2760 +
2761 +       error = -EINVAL;
2762 +       inode = file->f_dentry->d_inode;
2763 +
2764 +
2765 +       if (S_ISBLK(inode->i_mode)) {
2766 +               real_bdev = inode->i_bdev;
2767 +               vr->vr_device = real_bdev;
2768 +               __iget(real_bdev->bd_inode);
2769 +       } else
2770 +               goto out_fput;
2771 +
2772 +       vxdprintk(VXD_CBIT(misc, 0),
2773 +               "vroot[%d]_set_dev: dev=" VXF_DEV,
2774 +               vr->vr_number, VXD_DEV(real_bdev));
2775 +
2776 +       vr->vr_state = Vr_bound;
2777 +       error = 0;
2778 +
2779 + out_fput:
2780 +       fput(file);
2781 + out:
2782 +       return error;
2783 +}
2784 +
2785 +static int vroot_clr_dev(
2786 +       struct vroot_device *vr,
2787 +       struct block_device *bdev)
2788 +{
2789 +       struct block_device *real_bdev;
2790 +
2791 +       if (vr->vr_state != Vr_bound)
2792 +               return -ENXIO;
2793 +       if (vr->vr_refcnt > 1)  /* we needed one fd for the ioctl */
2794 +               return -EBUSY;
2795 +
2796 +       real_bdev = vr->vr_device;
2797 +
2798 +       vxdprintk(VXD_CBIT(misc, 0),
2799 +               "vroot[%d]_clr_dev: dev=" VXF_DEV,
2800 +               vr->vr_number, VXD_DEV(real_bdev));
2801 +
2802 +       bdput(real_bdev);
2803 +       vr->vr_state = Vr_unbound;
2804 +       vr->vr_device = NULL;
2805 +       return 0;
2806 +}
2807 +
2808 +
2809 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
2810 +       unsigned int cmd, unsigned long arg)
2811 +{
2812 +       struct vroot_device *vr = bdev->bd_disk->private_data;
2813 +       int err;
2814 +
2815 +       down(&vr->vr_ctl_mutex);
2816 +       switch (cmd) {
2817 +       case VROOT_SET_DEV:
2818 +               err = vroot_set_dev(vr, bdev, arg);
2819 +               break;
2820 +       case VROOT_CLR_DEV:
2821 +               err = vroot_clr_dev(vr, bdev);
2822 +               break;
2823 +       default:
2824 +               err = -EINVAL;
2825 +               break;
2826 +       }
2827 +       up(&vr->vr_ctl_mutex);
2828 +       return err;
2829 +}
2830 +
2831 +static int vr_open(struct block_device *bdev, fmode_t mode)
2832 +{
2833 +       struct vroot_device *vr = bdev->bd_disk->private_data;
2834 +
2835 +       down(&vr->vr_ctl_mutex);
2836 +       vr->vr_refcnt++;
2837 +       up(&vr->vr_ctl_mutex);
2838 +       return 0;
2839 +}
2840 +
2841 +static int vr_release(struct gendisk *disk, fmode_t mode)
2842 +{
2843 +       struct vroot_device *vr = disk->private_data;
2844 +
2845 +       down(&vr->vr_ctl_mutex);
2846 +       --vr->vr_refcnt;
2847 +       up(&vr->vr_ctl_mutex);
2848 +       return 0;
2849 +}
2850 +
2851 +static struct block_device_operations vr_fops = {
2852 +       .owner =        THIS_MODULE,
2853 +       .open =         vr_open,
2854 +       .release =      vr_release,
2855 +       .ioctl =        vr_ioctl,
2856 +};
2857 +
2858 +static int vroot_make_request(struct request_queue *q, struct bio *bio)
2859 +{
2860 +       printk("vroot_make_request %p, %p\n", q, bio);
2861 +       bio_io_error(bio);
2862 +       return 0;
2863 +}
2864 +
2865 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
2866 +{
2867 +       struct inode *inode = bdev->bd_inode;
2868 +       struct vroot_device *vr;
2869 +       struct block_device *real_bdev;
2870 +       int minor = iminor(inode);
2871 +
2872 +       vr = &vroot_dev[minor];
2873 +       real_bdev = vr->vr_device;
2874 +
2875 +       vxdprintk(VXD_CBIT(misc, 0),
2876 +               "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
2877 +               vr->vr_number, VXD_DEV(real_bdev));
2878 +
2879 +       if (vr->vr_state != Vr_bound)
2880 +               return ERR_PTR(-ENXIO);
2881 +
2882 +       __iget(real_bdev->bd_inode);
2883 +       return real_bdev;
2884 +}
2885 +
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 +               blk_queue_make_request(disks[i]->queue, vroot_make_request);
2934 +       }
2935 +
2936 +       for (i = 0; i < max_vroot; i++) {
2937 +               struct vroot_device *vr = &vroot_dev[i];
2938 +               struct gendisk *disk = disks[i];
2939 +
2940 +               memset(vr, 0, sizeof(*vr));
2941 +               sema_init(&vr->vr_ctl_mutex, 1);
2942 +               vr->vr_number = i;
2943 +               disk->major = VROOT_MAJOR;
2944 +               disk->first_minor = i;
2945 +               disk->fops = &vr_fops;
2946 +               sprintf(disk->disk_name, "vroot%d", i);
2947 +               disk->private_data = vr;
2948 +       }
2949 +
2950 +       err = register_vroot_grb(&__vroot_get_real_bdev);
2951 +       if (err)
2952 +               goto out_mem3;
2953 +
2954 +       for (i = 0; i < max_vroot; i++)
2955 +               add_disk(disks[i]);
2956 +       printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
2957 +       return 0;
2958 +
2959 +out_mem3:
2960 +       while (i--)
2961 +               put_disk(disks[i]);
2962 +       kfree(disks);
2963 +out_mem2:
2964 +       kfree(vroot_dev);
2965 +out_mem1:
2966 +       unregister_blkdev(VROOT_MAJOR, "vroot");
2967 +       printk(KERN_ERR "vroot: ran out of memory\n");
2968 +       return err;
2969 +}
2970 +
2971 +void vroot_exit(void)
2972 +{
2973 +       int i;
2974 +
2975 +       if (unregister_vroot_grb(&__vroot_get_real_bdev))
2976 +               printk(KERN_WARNING "vroot: cannot unregister grb\n");
2977 +
2978 +       for (i = 0; i < max_vroot; i++) {
2979 +               del_gendisk(disks[i]);
2980 +               put_disk(disks[i]);
2981 +       }
2982 +       unregister_blkdev(VROOT_MAJOR, "vroot");
2983 +
2984 +       kfree(disks);
2985 +       kfree(vroot_dev);
2986 +}
2987 +
2988 +module_init(vroot_init);
2989 +module_exit(vroot_exit);
2990 +
2991 +#ifndef MODULE
2992 +
2993 +static int __init max_vroot_setup(char *str)
2994 +{
2995 +       max_vroot = simple_strtol(str, NULL, 0);
2996 +       return 1;
2997 +}
2998 +
2999 +__setup("max_vroot=", max_vroot_setup);
3000 +
3001 +#endif
3002 +
3003 diff -NurpP --minimal linux-3.0.4/drivers/gpu/drm/radeon/r100_reg_safe.h linux-3.0.4-vs2.3.1/drivers/gpu/drm/radeon/r100_reg_safe.h
3004 --- linux-3.0.4/drivers/gpu/drm/radeon/r100_reg_safe.h  1970-01-01 01:00:00.000000000 +0100
3005 +++ linux-3.0.4-vs2.3.1/drivers/gpu/drm/radeon/r100_reg_safe.h  2011-06-10 22:11:24.000000000 +0200
3006 @@ -0,0 +1,28 @@
3007 +static const unsigned r100_reg_safe_bm[102] = {
3008 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3009 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3010 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3011 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3012 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3013 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3014 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3015 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3016 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3017 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3018 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3019 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3020 +       0xFFFFFFCF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3021 +       0xFFFFFF9F, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3022 +       0x38E7FE1F, 0xFFC3FF8E, 0x7FF8FFFF, 0xFFFF803C,
3023 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3024 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFEFFFF, 0xFFFFFFFF,
3025 +       0x00000000, 0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFF,
3026 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3027 +       0xFFFFFFFF, 0xFFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3028 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3029 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3030 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3031 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3032 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3033 +       0xFFFFFFFF, 0xFFFFFFEF,
3034 +};
3035 diff -NurpP --minimal linux-3.0.4/drivers/gpu/drm/radeon/r200_reg_safe.h linux-3.0.4-vs2.3.1/drivers/gpu/drm/radeon/r200_reg_safe.h
3036 --- linux-3.0.4/drivers/gpu/drm/radeon/r200_reg_safe.h  1970-01-01 01:00:00.000000000 +0100
3037 +++ linux-3.0.4-vs2.3.1/drivers/gpu/drm/radeon/r200_reg_safe.h  2011-06-10 22:11:24.000000000 +0200
3038 @@ -0,0 +1,28 @@
3039 +static const unsigned r200_reg_safe_bm[102] = {
3040 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3041 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3042 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3043 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3044 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3045 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3046 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3047 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3048 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3049 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3050 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3051 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3052 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3053 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3054 +       0xFFE7FE1F, 0xF003FFFF, 0x7EFFFFFF, 0xFFFF803C,
3055 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3056 +       0xFFFFFFFF, 0xFFFFEFCE, 0xFFFEFFFF, 0xFFFFFFFE,
3057 +       0x020E0FF0, 0xFFCC83FD, 0xFFFFFFFF, 0xFFFFFFFF,
3058 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3059 +       0xFFFBFFFF, 0xEFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3060 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3061 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3062 +       0xDFDFDFDF, 0x3FFDDFDF, 0xFFFFFFFF, 0xFFFFFF7F,
3063 +       0xFFFFFFFF, 0x00FFFFFF, 0x00000000, 0x00000000,
3064 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3065 +       0xFFFFFE3F, 0xFFFFFFEF,
3066 +};
3067 diff -NurpP --minimal linux-3.0.4/drivers/gpu/drm/radeon/r300_reg_safe.h linux-3.0.4-vs2.3.1/drivers/gpu/drm/radeon/r300_reg_safe.h
3068 --- linux-3.0.4/drivers/gpu/drm/radeon/r300_reg_safe.h  1970-01-01 01:00:00.000000000 +0100
3069 +++ linux-3.0.4-vs2.3.1/drivers/gpu/drm/radeon/r300_reg_safe.h  2011-06-10 22:11:24.000000000 +0200
3070 @@ -0,0 +1,42 @@
3071 +static const unsigned r300_reg_safe_bm[159] = {
3072 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3073 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3074 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3075 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3076 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3077 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3078 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3079 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3080 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3081 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3082 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3083 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3084 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3085 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3086 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
3087 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3088 +       0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
3089 +       0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
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 +       0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3099 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3100 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3101 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3102 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3103 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3104 +       0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
3105 +       0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
3106 +       0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3107 +       0x00000000, 0x0000C100, 0x00000000, 0x00000000,
3108 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3109 +       0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0xFF80FFFF,
3110 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3111 +       0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
3112 +};
3113 diff -NurpP --minimal linux-3.0.4/drivers/gpu/drm/radeon/r420_reg_safe.h linux-3.0.4-vs2.3.1/drivers/gpu/drm/radeon/r420_reg_safe.h
3114 --- linux-3.0.4/drivers/gpu/drm/radeon/r420_reg_safe.h  1970-01-01 01:00:00.000000000 +0100
3115 +++ linux-3.0.4-vs2.3.1/drivers/gpu/drm/radeon/r420_reg_safe.h  2011-06-10 22:11:24.000000000 +0200
3116 @@ -0,0 +1,42 @@
3117 +static const unsigned r420_reg_safe_bm[159] = {
3118 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3119 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3120 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3121 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
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 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3129 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3130 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3131 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3132 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
3133 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3134 +       0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
3135 +       0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
3136 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3137 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3138 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3139 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3140 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3141 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3142 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3143 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3144 +       0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3145 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3146 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3147 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3148 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3149 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3150 +       0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
3151 +       0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
3152 +       0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3153 +       0x00000000, 0x00000100, 0x00000000, 0x00000000,
3154 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3155 +       0x00000000, 0x00000000, 0x00000000, 0xFF800000,
3156 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3157 +       0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
3158 +};
3159 diff -NurpP --minimal linux-3.0.4/drivers/gpu/drm/radeon/rn50_reg_safe.h linux-3.0.4-vs2.3.1/drivers/gpu/drm/radeon/rn50_reg_safe.h
3160 --- linux-3.0.4/drivers/gpu/drm/radeon/rn50_reg_safe.h  1970-01-01 01:00:00.000000000 +0100
3161 +++ linux-3.0.4-vs2.3.1/drivers/gpu/drm/radeon/rn50_reg_safe.h  2011-06-10 22:11:24.000000000 +0200
3162 @@ -0,0 +1,28 @@
3163 +static const unsigned rn50_reg_safe_bm[102] = {
3164 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3165 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3166 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3167 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3168 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3169 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3170 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3171 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3172 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3173 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3174 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3175 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3176 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3177 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3178 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3179 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3180 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3181 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3182 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3183 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3184 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3185 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3186 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3187 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3188 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3189 +       0xFFFFFFFF, 0xFFFFFFFF,
3190 +};
3191 diff -NurpP --minimal linux-3.0.4/drivers/gpu/drm/radeon/rs600_reg_safe.h linux-3.0.4-vs2.3.1/drivers/gpu/drm/radeon/rs600_reg_safe.h
3192 --- linux-3.0.4/drivers/gpu/drm/radeon/rs600_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
3193 +++ linux-3.0.4-vs2.3.1/drivers/gpu/drm/radeon/rs600_reg_safe.h 2011-06-10 22:11:24.000000000 +0200
3194 @@ -0,0 +1,57 @@
3195 +static const unsigned rs600_reg_safe_bm[219] = {
3196 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3197 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3198 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3199 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3200 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3201 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3202 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3203 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3204 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3205 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3206 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3207 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3208 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3209 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3210 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
3211 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3212 +       0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
3213 +       0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
3214 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3215 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3216 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3217 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3218 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3219 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3220 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3221 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3222 +       0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3223 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3224 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3225 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3226 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3227 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3228 +       0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
3229 +       0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
3230 +       0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3231 +       0x00000000, 0x00000100, 0x00000000, 0x00000000,
3232 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3233 +       0x00000000, 0x00000000, 0x00000000, 0xFF800000,
3234 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3235 +       0x0003FC01, 0xFFFFFCF8, 0xFF800B19, 0xFFFFFFFF,
3236 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3237 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3238 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3239 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3240 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3241 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3242 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3243 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3244 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3245 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3246 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3247 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3248 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3249 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3250 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3251 +};
3252 diff -NurpP --minimal linux-3.0.4/drivers/gpu/drm/radeon/rv515_reg_safe.h linux-3.0.4-vs2.3.1/drivers/gpu/drm/radeon/rv515_reg_safe.h
3253 --- linux-3.0.4/drivers/gpu/drm/radeon/rv515_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
3254 +++ linux-3.0.4-vs2.3.1/drivers/gpu/drm/radeon/rv515_reg_safe.h 2011-06-10 22:11:24.000000000 +0200
3255 @@ -0,0 +1,57 @@
3256 +static const unsigned rv515_reg_safe_bm[219] = {
3257 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 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 +       0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3268 +       0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3269 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3270 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3271 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
3272 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3273 +       0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
3274 +       0xF0000038, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
3275 +       0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
3276 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3277 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3278 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3279 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3280 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3281 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3282 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3283 +       0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3284 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3285 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3286 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3287 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3288 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3289 +       0x1FFFF878, 0xFFFFE000, 0xFFFFFE1E, 0xFFFFFFFF,
3290 +       0x388F8F50, 0xFFF88082, 0xFF0000FC, 0xFAE009FF,
3291 +       0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3292 +       0xFFFF8CFC, 0xFFFFC1FF, 0xFFFFFFFF, 0xFFFFFFFF,
3293 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3294 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF80FFFF,
3295 +       0x00000000, 0x00000000, 0x00000000, 0x00000000,
3296 +       0x0003FC01, 0x3FFFFCF8, 0xFF800B19, 0xFFDFFFFF,
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 +       0xFFFFFFFF, 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 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3311 +       0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3312 +};
3313 diff -NurpP --minimal linux-3.0.4/drivers/infiniband/core/addr.c linux-3.0.4-vs2.3.1/drivers/infiniband/core/addr.c
3314 --- linux-3.0.4/drivers/infiniband/core/addr.c  2011-07-22 11:17:45.000000000 +0200
3315 +++ linux-3.0.4-vs2.3.1/drivers/infiniband/core/addr.c  2011-06-16 14:16:51.000000000 +0200
3316 @@ -252,7 +252,7 @@ static int addr6_resolve(struct sockaddr
3317  
3318         if (ipv6_addr_any(&fl6.saddr)) {
3319                 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
3320 -                                        &fl6.daddr, 0, &fl6.saddr);
3321 +                                        &fl6.daddr, 0, &fl6.saddr, NULL);
3322                 if (ret)
3323                         goto put;
3324  
3325 diff -NurpP --minimal linux-3.0.4/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-3.0.4-vs2.3.1/drivers/infiniband/hw/ipath/ipath_user_pages.c
3326 --- linux-3.0.4/drivers/infiniband/hw/ipath/ipath_user_pages.c  2011-05-22 16:17:16.000000000 +0200
3327 +++ linux-3.0.4-vs2.3.1/drivers/infiniband/hw/ipath/ipath_user_pages.c  2011-06-10 22:11:24.000000000 +0200
3328 @@ -35,6 +35,7 @@
3329  #include <linux/device.h>
3330  #include <linux/slab.h>
3331  #include <linux/sched.h>
3332 +#include <linux/vs_memory.h>
3333  
3334  #include "ipath_kernel.h"
3335  
3336 diff -NurpP --minimal linux-3.0.4/drivers/md/dm-ioctl.c linux-3.0.4-vs2.3.1/drivers/md/dm-ioctl.c
3337 --- linux-3.0.4/drivers/md/dm-ioctl.c   2011-05-22 16:17:18.000000000 +0200
3338 +++ linux-3.0.4-vs2.3.1/drivers/md/dm-ioctl.c   2011-06-10 22:11:24.000000000 +0200
3339 @@ -16,6 +16,7 @@
3340  #include <linux/dm-ioctl.h>
3341  #include <linux/hdreg.h>
3342  #include <linux/compat.h>
3343 +#include <linux/vs_context.h>
3344  
3345  #include <asm/uaccess.h>
3346  
3347 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
3348         unsigned int h = hash_str(str);
3349  
3350         list_for_each_entry (hc, _name_buckets + h, name_list)
3351 -               if (!strcmp(hc->name, str)) {
3352 +               if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
3353 +                       !strcmp(hc->name, str)) {
3354                         dm_get(hc->md);
3355                         return hc;
3356                 }
3357 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
3358         unsigned int h = hash_str(str);
3359  
3360         list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
3361 -               if (!strcmp(hc->uuid, str)) {
3362 +               if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
3363 +                       !strcmp(hc->uuid, str)) {
3364                         dm_get(hc->md);
3365                         return hc;
3366                 }
3367 @@ -427,6 +430,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl 
3368  
3369  static int remove_all(struct dm_ioctl *param, size_t param_size)
3370  {
3371 +       if (!vx_check(0, VS_ADMIN))
3372 +               return -EPERM;
3373 +
3374         dm_hash_remove_all(1);
3375         param->data_size = 0;
3376         return 0;
3377 @@ -474,6 +480,8 @@ static int list_devices(struct dm_ioctl 
3378          */
3379         for (i = 0; i < NUM_BUCKETS; i++) {
3380                 list_for_each_entry (hc, _name_buckets + i, name_list) {
3381 +                       if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
3382 +                               continue;
3383                         needed += sizeof(struct dm_name_list);
3384                         needed += strlen(hc->name) + 1;
3385                         needed += ALIGN_MASK;
3386 @@ -497,6 +505,8 @@ static int list_devices(struct dm_ioctl 
3387          */
3388         for (i = 0; i < NUM_BUCKETS; i++) {
3389                 list_for_each_entry (hc, _name_buckets + i, name_list) {
3390 +                       if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
3391 +                               continue;
3392                         if (old_nl)
3393                                 old_nl->next = (uint32_t) ((void *) nl -
3394                                                            (void *) old_nl);
3395 @@ -731,10 +741,11 @@ static struct hash_cell *__find_device_h
3396         if (!md)
3397                 goto out;
3398  
3399 -       mdptr = dm_get_mdptr(md);
3400 +       if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
3401 +               mdptr = dm_get_mdptr(md);
3402 +
3403         if (!mdptr)
3404                 dm_put(md);
3405 -
3406  out:
3407         return mdptr;
3408  }
3409 @@ -1577,8 +1588,8 @@ static int ctl_ioctl(uint command, struc
3410         ioctl_fn fn = NULL;
3411         size_t input_param_size;
3412  
3413 -       /* only root can play with this */
3414 -       if (!capable(CAP_SYS_ADMIN))
3415 +       /* only root and certain contexts can play with this */
3416 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
3417                 return -EACCES;
3418  
3419         if (_IOC_TYPE(command) != DM_IOCTL)
3420 diff -NurpP --minimal linux-3.0.4/drivers/md/dm.c linux-3.0.4-vs2.3.1/drivers/md/dm.c
3421 --- linux-3.0.4/drivers/md/dm.c 2011-08-31 18:56:41.000000000 +0200
3422 +++ linux-3.0.4-vs2.3.1/drivers/md/dm.c 2011-08-08 23:04:47.000000000 +0200
3423 @@ -20,6 +20,7 @@
3424  #include <linux/idr.h>
3425  #include <linux/hdreg.h>
3426  #include <linux/delay.h>
3427 +#include <linux/vs_base.h>
3428  
3429  #include <trace/events/block.h>
3430  
3431 @@ -121,6 +122,7 @@ struct mapped_device {
3432         rwlock_t map_lock;
3433         atomic_t holders;
3434         atomic_t open_count;
3435 +       xid_t xid;
3436  
3437         unsigned long flags;
3438  
3439 @@ -334,6 +336,7 @@ int dm_deleting_md(struct mapped_device 
3440  static int dm_blk_open(struct block_device *bdev, fmode_t mode)
3441  {
3442         struct mapped_device *md;
3443 +       int ret = -ENXIO;
3444  
3445         spin_lock(&_minor_lock);
3446  
3447 @@ -342,18 +345,19 @@ static int dm_blk_open(struct block_devi
3448                 goto out;
3449  
3450         if (test_bit(DMF_FREEING, &md->flags) ||
3451 -           dm_deleting_md(md)) {
3452 -               md = NULL;
3453 +           dm_deleting_md(md))
3454 +               goto out;
3455 +
3456 +       ret = -EACCES;
3457 +       if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
3458                 goto out;
3459 -       }
3460  
3461         dm_get(md);
3462         atomic_inc(&md->open_count);
3463 -
3464 +       ret = 0;
3465  out:
3466         spin_unlock(&_minor_lock);
3467 -
3468 -       return md ? 0 : -ENXIO;
3469 +       return ret;
3470  }
3471  
3472  static int dm_blk_close(struct gendisk *disk, fmode_t mode)
3473 @@ -574,6 +578,14 @@ int dm_set_geometry(struct mapped_device
3474         return 0;
3475  }
3476  
3477 +/*
3478 + * Get the xid associated with a dm device
3479 + */
3480 +xid_t dm_get_xid(struct mapped_device *md)
3481 +{
3482 +       return md->xid;
3483 +}
3484 +
3485  /*-----------------------------------------------------------------
3486   * CRUD START:
3487   *   A more elegant soln is in the works that uses the queue
3488 @@ -1847,6 +1859,7 @@ static struct mapped_device *alloc_dev(i
3489         INIT_LIST_HEAD(&md->uevent_list);
3490         spin_lock_init(&md->uevent_lock);
3491  
3492 +       md->xid = vx_current_xid();
3493         md->queue = blk_alloc_queue(GFP_KERNEL);
3494         if (!md->queue)
3495                 goto bad_queue;
3496 diff -NurpP --minimal linux-3.0.4/drivers/md/dm.h linux-3.0.4-vs2.3.1/drivers/md/dm.h
3497 --- linux-3.0.4/drivers/md/dm.h 2011-05-22 16:17:18.000000000 +0200
3498 +++ linux-3.0.4-vs2.3.1/drivers/md/dm.h 2011-06-10 22:11:24.000000000 +0200
3499 @@ -41,6 +41,8 @@ struct dm_dev_internal {
3500  struct dm_table;
3501  struct dm_md_mempools;
3502  
3503 +xid_t dm_get_xid(struct mapped_device *md);
3504 +
3505  /*-----------------------------------------------------------------
3506   * Internal table functions.
3507   *---------------------------------------------------------------*/
3508 diff -NurpP --minimal linux-3.0.4/drivers/net/tun.c linux-3.0.4-vs2.3.1/drivers/net/tun.c
3509 --- linux-3.0.4/drivers/net/tun.c       2011-08-31 18:56:41.000000000 +0200
3510 +++ linux-3.0.4-vs2.3.1/drivers/net/tun.c       2011-08-29 03:45:08.000000000 +0200
3511 @@ -64,6 +64,7 @@
3512  #include <linux/nsproxy.h>
3513  #include <linux/virtio_net.h>
3514  #include <linux/rcupdate.h>
3515 +#include <linux/vs_network.h>
3516  #include <net/net_namespace.h>
3517  #include <net/netns/generic.h>
3518  #include <net/rtnetlink.h>
3519 @@ -121,6 +122,7 @@ struct tun_struct {
3520         unsigned int            flags;
3521         uid_t                   owner;
3522         gid_t                   group;
3523 +       nid_t                   nid;
3524  
3525         struct net_device       *dev;
3526         u32                     set_features;
3527 @@ -905,6 +907,7 @@ static void tun_setup(struct net_device 
3528  
3529         tun->owner = -1;
3530         tun->group = -1;
3531 +       tun->nid = current->nid;
3532  
3533         dev->ethtool_ops = &tun_ethtool_ops;
3534         dev->destructor = tun_free_netdev;
3535 @@ -1055,7 +1058,7 @@ static int tun_set_iff(struct net *net, 
3536  
3537                 if (((tun->owner != -1 && cred->euid != tun->owner) ||
3538                      (tun->group != -1 && !in_egroup_p(tun->group))) &&
3539 -                   !capable(CAP_NET_ADMIN))
3540 +               !cap_raised(current_cap(), CAP_NET_ADMIN))
3541                         return -EPERM;
3542                 err = security_tun_dev_attach(tun->socket.sk);
3543                 if (err < 0)
3544 @@ -1069,7 +1072,7 @@ static int tun_set_iff(struct net *net, 
3545                 char *name;
3546                 unsigned long flags = 0;
3547  
3548 -               if (!capable(CAP_NET_ADMIN))
3549 +               if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
3550                         return -EPERM;
3551                 err = security_tun_dev_create();
3552                 if (err < 0)
3553 @@ -1137,6 +1140,9 @@ static int tun_set_iff(struct net *net, 
3554  
3555                 sk->sk_destruct = tun_sock_destruct;
3556  
3557 +               if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
3558 +                       return -EPERM;
3559 +
3560                 err = tun_attach(tun, file);
3561                 if (err < 0)
3562                         goto failed;
3563 @@ -1318,6 +1324,16 @@ static long __tun_chr_ioctl(struct file 
3564                 tun_debug(KERN_INFO, tun, "group set to %d\n", tun->group);
3565                 break;
3566  
3567 +       case TUNSETNID:
3568 +               if (!capable(CAP_CONTEXT))
3569 +                       return -EPERM;
3570 +
3571 +               /* Set nid owner of the device */
3572 +               tun->nid = (nid_t) arg;
3573 +
3574 +               tun_debug(KERN_INFO, tun, "nid owner set to %u\n", tun->nid);
3575 +               break;
3576 +
3577         case TUNSETLINK:
3578                 /* Only allow setting the type when the interface is down */
3579                 if (tun->dev->flags & IFF_UP) {
3580 diff -NurpP --minimal linux-3.0.4/drivers/tty/sysrq.c linux-3.0.4-vs2.3.1/drivers/tty/sysrq.c
3581 --- linux-3.0.4/drivers/tty/sysrq.c     2011-05-22 16:17:44.000000000 +0200
3582 +++ linux-3.0.4-vs2.3.1/drivers/tty/sysrq.c     2011-06-10 22:11:24.000000000 +0200
3583 @@ -41,6 +41,7 @@
3584  #include <linux/oom.h>
3585  #include <linux/slab.h>
3586  #include <linux/input.h>
3587 +#include <linux/vserver/debug.h>
3588  
3589  #include <asm/ptrace.h>
3590  #include <asm/irq_regs.h>
3591 @@ -395,6 +396,21 @@ static struct sysrq_key_op sysrq_unrt_op
3592         .enable_mask    = SYSRQ_ENABLE_RTNICE,
3593  };
3594  
3595 +
3596 +#ifdef CONFIG_VSERVER_DEBUG
3597 +static void sysrq_handle_vxinfo(int key)
3598 +{
3599 +       dump_vx_info_inactive((key == 'x') ? 0 : 1);
3600 +}
3601 +
3602 +static struct sysrq_key_op sysrq_showvxinfo_op = {
3603 +       .handler        = sysrq_handle_vxinfo,
3604 +       .help_msg       = "conteXt",
3605 +       .action_msg     = "Show Context Info",
3606 +       .enable_mask    = SYSRQ_ENABLE_DUMP,
3607 +};
3608 +#endif
3609 +
3610  /* Key Operations table and lock */
3611  static DEFINE_SPINLOCK(sysrq_key_table_lock);
3612  
3613 @@ -449,7 +465,11 @@ static struct sysrq_key_op *sysrq_key_ta
3614         NULL,                           /* v */
3615         &sysrq_showstate_blocked_op,    /* w */
3616         /* x: May be registered on ppc/powerpc for xmon */
3617 +#ifdef CONFIG_VSERVER_DEBUG
3618 +       &sysrq_showvxinfo_op,           /* x */
3619 +#else
3620         NULL,                           /* x */
3621 +#endif
3622         /* y: May be registered on sparc64 for global register dump */
3623         NULL,                           /* y */
3624         &sysrq_ftrace_dump_op,          /* z */
3625 @@ -464,6 +484,8 @@ static int sysrq_key_table_key2index(int
3626                 retval = key - '0';
3627         else if ((key >= 'a') && (key <= 'z'))
3628                 retval = key + 10 - 'a';
3629 +       else if ((key >= 'A') && (key <= 'Z'))
3630 +               retval = key + 10 - 'A';
3631         else
3632                 retval = -1;
3633         return retval;
3634 diff -NurpP --minimal linux-3.0.4/drivers/tty/tty_io.c linux-3.0.4-vs2.3.1/drivers/tty/tty_io.c
3635 --- linux-3.0.4/drivers/tty/tty_io.c    2011-07-22 11:18:03.000000000 +0200
3636 +++ linux-3.0.4-vs2.3.1/drivers/tty/tty_io.c    2011-06-10 22:11:24.000000000 +0200
3637 @@ -104,6 +104,7 @@
3638  
3639  #include <linux/kmod.h>
3640  #include <linux/nsproxy.h>
3641 +#include <linux/vs_pid.h>
3642  
3643  #undef TTY_DEBUG_HANGUP
3644  
3645 @@ -2057,7 +2058,8 @@ static int tiocsti(struct tty_struct *tt
3646         char ch, mbz = 0;
3647         struct tty_ldisc *ld;
3648  
3649 -       if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
3650 +       if (((current->signal->tty != tty) &&
3651 +               !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
3652                 return -EPERM;
3653         if (get_user(ch, p))
3654                 return -EFAULT;
3655 @@ -2345,6 +2347,7 @@ static int tiocspgrp(struct tty_struct *
3656                 return -ENOTTY;
3657         if (get_user(pgrp_nr, p))
3658                 return -EFAULT;
3659 +       pgrp_nr = vx_rmap_pid(pgrp_nr);
3660         if (pgrp_nr < 0)
3661                 return -EINVAL;
3662         rcu_read_lock();
3663 diff -NurpP --minimal linux-3.0.4/fs/attr.c linux-3.0.4-vs2.3.1/fs/attr.c
3664 --- linux-3.0.4/fs/attr.c       2011-07-22 11:18:05.000000000 +0200
3665 +++ linux-3.0.4-vs2.3.1/fs/attr.c       2011-06-10 22:11:24.000000000 +0200
3666 @@ -13,6 +13,9 @@
3667  #include <linux/fsnotify.h>
3668  #include <linux/fcntl.h>
3669  #include <linux/security.h>
3670 +#include <linux/proc_fs.h>
3671 +#include <linux/devpts_fs.h>
3672 +#include <linux/vs_tag.h>
3673  
3674  /**
3675   * inode_change_ok - check if attribute changes to an inode are allowed
3676 @@ -73,6 +76,10 @@ int inode_change_ok(const struct inode *
3677                         return -EPERM;
3678         }
3679  
3680 +       /* check for inode tag permission */
3681 +       if (dx_permission(inode, MAY_WRITE))
3682 +               return -EACCES;
3683 +
3684         return 0;
3685  }
3686  EXPORT_SYMBOL(inode_change_ok);
3687 @@ -143,6 +150,8 @@ void setattr_copy(struct inode *inode, c
3688                 inode->i_uid = attr->ia_uid;
3689         if (ia_valid & ATTR_GID)
3690                 inode->i_gid = attr->ia_gid;
3691 +       if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3692 +               inode->i_tag = attr->ia_tag;
3693         if (ia_valid & ATTR_ATIME)
3694                 inode->i_atime = timespec_trunc(attr->ia_atime,
3695                                                 inode->i_sb->s_time_gran);
3696 @@ -170,7 +179,8 @@ int notify_change(struct dentry * dentry
3697         struct timespec now;
3698         unsigned int ia_valid = attr->ia_valid;
3699  
3700 -       if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
3701 +       if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
3702 +               ATTR_TAG | ATTR_TIMES_SET)) {
3703                 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
3704                         return -EPERM;
3705         }
3706 diff -NurpP --minimal linux-3.0.4/fs/binfmt_aout.c linux-3.0.4-vs2.3.1/fs/binfmt_aout.c
3707 --- linux-3.0.4/fs/binfmt_aout.c        2010-10-21 13:07:47.000000000 +0200
3708 +++ linux-3.0.4-vs2.3.1/fs/binfmt_aout.c        2011-06-10 22:11:24.000000000 +0200
3709 @@ -25,6 +25,7 @@
3710  #include <linux/init.h>
3711  #include <linux/coredump.h>
3712  #include <linux/slab.h>
3713 +#include <linux/vs_memory.h>
3714  
3715  #include <asm/system.h>
3716  #include <asm/uaccess.h>
3717 diff -NurpP --minimal linux-3.0.4/fs/binfmt_elf.c linux-3.0.4-vs2.3.1/fs/binfmt_elf.c
3718 --- linux-3.0.4/fs/binfmt_elf.c 2011-05-22 16:17:48.000000000 +0200
3719 +++ linux-3.0.4-vs2.3.1/fs/binfmt_elf.c 2011-06-10 22:11:24.000000000 +0200
3720 @@ -32,6 +32,7 @@
3721  #include <linux/elf.h>
3722  #include <linux/utsname.h>
3723  #include <linux/coredump.h>
3724 +#include <linux/vs_memory.h>
3725  #include <asm/uaccess.h>
3726  #include <asm/param.h>
3727  #include <asm/page.h>
3728 diff -NurpP --minimal linux-3.0.4/fs/binfmt_flat.c linux-3.0.4-vs2.3.1/fs/binfmt_flat.c
3729 --- linux-3.0.4/fs/binfmt_flat.c        2011-07-22 11:18:05.000000000 +0200
3730 +++ linux-3.0.4-vs2.3.1/fs/binfmt_flat.c        2011-06-10 22:11:24.000000000 +0200
3731 @@ -35,6 +35,7 @@
3732  #include <linux/init.h>
3733  #include <linux/flat.h>
3734  #include <linux/syscalls.h>
3735 +#include <linux/vs_memory.h>
3736  
3737  #include <asm/byteorder.h>
3738  #include <asm/system.h>
3739 diff -NurpP --minimal linux-3.0.4/fs/binfmt_som.c linux-3.0.4-vs2.3.1/fs/binfmt_som.c
3740 --- linux-3.0.4/fs/binfmt_som.c 2010-02-25 11:52:04.000000000 +0100
3741 +++ linux-3.0.4-vs2.3.1/fs/binfmt_som.c 2011-06-10 22:11:24.000000000 +0200
3742 @@ -28,6 +28,7 @@
3743  #include <linux/shm.h>
3744  #include <linux/personality.h>
3745  #include <linux/init.h>
3746 +#include <linux/vs_memory.h>
3747  
3748  #include <asm/uaccess.h>
3749  #include <asm/pgtable.h>
3750 diff -NurpP --minimal linux-3.0.4/fs/block_dev.c linux-3.0.4-vs2.3.1/fs/block_dev.c
3751 --- linux-3.0.4/fs/block_dev.c  2011-07-22 11:18:05.000000000 +0200
3752 +++ linux-3.0.4-vs2.3.1/fs/block_dev.c  2011-07-01 11:35:34.000000000 +0200
3753 @@ -25,6 +25,7 @@
3754  #include <linux/namei.h>
3755  #include <linux/log2.h>
3756  #include <linux/kmemleak.h>
3757 +#include <linux/vs_device.h>
3758  #include <asm/uaccess.h>
3759  #include "internal.h"
3760  
3761 @@ -553,6 +554,7 @@ struct block_device *bdget(dev_t dev)
3762                 bdev->bd_invalidated = 0;
3763                 inode->i_mode = S_IFBLK;
3764                 inode->i_rdev = dev;
3765 +               inode->i_mdev = dev;
3766                 inode->i_bdev = bdev;
3767                 inode->i_data.a_ops = &def_blk_aops;
3768                 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
3769 @@ -599,6 +601,11 @@ EXPORT_SYMBOL(bdput);
3770  static struct block_device *bd_acquire(struct inode *inode)
3771  {
3772         struct block_device *bdev;
3773 +       dev_t mdev;
3774 +
3775 +       if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
3776 +               return NULL;
3777 +       inode->i_mdev = mdev;
3778  
3779         spin_lock(&bdev_lock);
3780         bdev = inode->i_bdev;
3781 @@ -609,7 +616,7 @@ static struct block_device *bd_acquire(s
3782         }
3783         spin_unlock(&bdev_lock);
3784  
3785 -       bdev = bdget(inode->i_rdev);
3786 +       bdev = bdget(mdev);
3787         if (bdev) {
3788                 spin_lock(&bdev_lock);
3789                 if (!inode->i_bdev) {
3790 diff -NurpP --minimal linux-3.0.4/fs/btrfs/ctree.h linux-3.0.4-vs2.3.1/fs/btrfs/ctree.h
3791 --- linux-3.0.4/fs/btrfs/ctree.h        2011-07-22 11:18:05.000000000 +0200
3792 +++ linux-3.0.4-vs2.3.1/fs/btrfs/ctree.h        2011-07-19 00:44:39.000000000 +0200
3793 @@ -600,11 +600,14 @@ struct btrfs_inode_item {
3794         /* modification sequence number for NFS */
3795         __le64 sequence;
3796  
3797 +       __le16 tag;
3798         /*
3799          * a little future expansion, for more than this we can
3800          * just grow the inode item and version it
3801          */
3802 -       __le64 reserved[4];
3803 +       __le16 reserved16;
3804 +       __le32 reserved32;
3805 +       __le64 reserved[3];
3806         struct btrfs_timespec atime;
3807         struct btrfs_timespec ctime;
3808         struct btrfs_timespec mtime;
3809 @@ -1359,6 +1362,8 @@ struct btrfs_ioctl_defrag_range_args {
3810  #define BTRFS_MOUNT_AUTO_DEFRAG                (1 << 16)
3811  #define BTRFS_MOUNT_INODE_MAP_CACHE    (1 << 17)
3812  
3813 +#define BTRFS_MOUNT_TAGGED             (1 << 24)
3814 +
3815  #define btrfs_clear_opt(o, opt)                ((o) &= ~BTRFS_MOUNT_##opt)
3816  #define btrfs_set_opt(o, opt)          ((o) |= BTRFS_MOUNT_##opt)
3817  #define btrfs_test_opt(root, opt)      ((root)->fs_info->mount_opt & \
3818 @@ -1568,6 +1573,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
3819  BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
3820  BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
3821  BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
3822 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
3823  BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
3824  BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
3825  BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
3826 @@ -1621,6 +1627,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct 
3827  
3828  BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
3829  
3830 +#define BTRFS_INODE_IXUNLINK           (1 << 24)
3831 +#define BTRFS_INODE_BARRIER            (1 << 25)
3832 +#define BTRFS_INODE_COW                        (1 << 26)
3833 +
3834  
3835  BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
3836  
3837 @@ -2595,6 +2605,7 @@ extern const struct dentry_operations bt
3838  long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
3839  void btrfs_update_iflags(struct inode *inode);
3840  void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
3841 +int btrfs_sync_flags(struct inode *inode, int, int);
3842  int btrfs_defrag_file(struct inode *inode, struct file *file,
3843                       struct btrfs_ioctl_defrag_range_args *range,
3844                       u64 newer_than, unsigned long max_pages);
3845 diff -NurpP --minimal linux-3.0.4/fs/btrfs/disk-io.c linux-3.0.4-vs2.3.1/fs/btrfs/disk-io.c
3846 --- linux-3.0.4/fs/btrfs/disk-io.c      2011-07-22 11:18:05.000000000 +0200
3847 +++ linux-3.0.4-vs2.3.1/fs/btrfs/disk-io.c      2011-06-22 12:39:15.000000000 +0200
3848 @@ -1765,6 +1765,9 @@ struct btrfs_root *open_ctree(struct sup
3849                 goto fail_alloc;
3850         }
3851  
3852 +       if (btrfs_test_opt(tree_root, TAGGED))
3853 +               sb->s_flags |= MS_TAGGED;
3854 +
3855         features = btrfs_super_incompat_flags(disk_super) &
3856                 ~BTRFS_FEATURE_INCOMPAT_SUPP;
3857         if (features) {
3858 diff -NurpP --minimal linux-3.0.4/fs/btrfs/inode.c linux-3.0.4-vs2.3.1/fs/btrfs/inode.c
3859 --- linux-3.0.4/fs/btrfs/inode.c        2011-07-22 11:18:05.000000000 +0200
3860 +++ linux-3.0.4-vs2.3.1/fs/btrfs/inode.c        2011-07-19 00:44:39.000000000 +0200
3861 @@ -38,6 +38,7 @@
3862  #include <linux/falloc.h>
3863  #include <linux/slab.h>
3864  #include <linux/ratelimit.h>
3865 +#include <linux/vs_tag.h>
3866  #include "compat.h"
3867  #include "ctree.h"
3868  #include "disk-io.h"
3869 @@ -2508,6 +2509,8 @@ static void btrfs_read_locked_inode(stru
3870         struct btrfs_key location;
3871         int maybe_acls;
3872         u32 rdev;
3873 +       uid_t uid;
3874 +       gid_t gid;
3875         int ret;
3876         bool filled = false;
3877  
3878 @@ -2540,8 +2543,13 @@ static void btrfs_read_locked_inode(stru
3879  
3880         inode->i_mode = btrfs_inode_mode(leaf, inode_item);
3881         inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);
3882 -       inode->i_uid = btrfs_inode_uid(leaf, inode_item);
3883 -       inode->i_gid = btrfs_inode_gid(leaf, inode_item);
3884 +
3885 +       uid = btrfs_inode_uid(leaf, inode_item);
3886 +       gid = btrfs_inode_gid(leaf, inode_item);
3887 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3888 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3889 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3890 +               btrfs_inode_tag(leaf, inode_item));
3891         btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
3892  
3893         tspec = btrfs_inode_atime(inode_item);
3894 @@ -2624,6 +2632,9 @@ static void fill_inode_item(struct btrfs
3895                             struct btrfs_inode_item *item,
3896                             struct inode *inode)
3897  {
3898 +       uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3899 +       gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3900 +
3901         if (!leaf->map_token)
3902                 map_private_extent_buffer(leaf, (unsigned long)item,
3903                                           sizeof(struct btrfs_inode_item),
3904 @@ -2631,8 +2642,11 @@ static void fill_inode_item(struct btrfs
3905                                           &leaf->map_start, &leaf->map_len,
3906                                           KM_USER1);
3907  
3908 -       btrfs_set_inode_uid(leaf, item, inode->i_uid);
3909 -       btrfs_set_inode_gid(leaf, item, inode->i_gid);
3910 +       btrfs_set_inode_uid(leaf, item, uid);
3911 +       btrfs_set_inode_gid(leaf, item, gid);
3912 +#ifdef CONFIG_TAGGING_INTERN
3913 +       btrfs_set_inode_tag(leaf, item, inode->i_tag);
3914 +#endif
3915         btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
3916         btrfs_set_inode_mode(leaf, item, inode->i_mode);
3917         btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
3918 @@ -7359,6 +7373,7 @@ static const struct inode_operations btr
3919         .listxattr      = btrfs_listxattr,
3920         .removexattr    = btrfs_removexattr,
3921         .permission     = btrfs_permission,
3922 +       .sync_flags     = btrfs_sync_flags,
3923  };
3924  static const struct inode_operations btrfs_dir_ro_inode_operations = {
3925         .lookup         = btrfs_lookup,
3926 @@ -7431,6 +7446,7 @@ static const struct inode_operations btr
3927         .removexattr    = btrfs_removexattr,
3928         .permission     = btrfs_permission,
3929         .fiemap         = btrfs_fiemap,
3930 +       .sync_flags     = btrfs_sync_flags,
3931  };
3932  static const struct inode_operations btrfs_special_inode_operations = {
3933         .getattr        = btrfs_getattr,
3934 diff -NurpP --minimal linux-3.0.4/fs/btrfs/ioctl.c linux-3.0.4-vs2.3.1/fs/btrfs/ioctl.c
3935 --- linux-3.0.4/fs/btrfs/ioctl.c        2011-07-22 11:18:05.000000000 +0200
3936 +++ linux-3.0.4-vs2.3.1/fs/btrfs/ioctl.c        2011-06-22 12:39:15.000000000 +0200
3937 @@ -70,10 +70,13 @@ static unsigned int btrfs_flags_to_ioctl
3938  {
3939         unsigned int iflags = 0;
3940  
3941 -       if (flags & BTRFS_INODE_SYNC)
3942 -               iflags |= FS_SYNC_FL;
3943         if (flags & BTRFS_INODE_IMMUTABLE)
3944                 iflags |= FS_IMMUTABLE_FL;
3945 +       if (flags & BTRFS_INODE_IXUNLINK)
3946 +               iflags |= FS_IXUNLINK_FL;
3947 +
3948 +       if (flags & BTRFS_INODE_SYNC)
3949 +               iflags |= FS_SYNC_FL;
3950         if (flags & BTRFS_INODE_APPEND)
3951                 iflags |= FS_APPEND_FL;
3952         if (flags & BTRFS_INODE_NODUMP)
3953 @@ -90,28 +93,78 @@ static unsigned int btrfs_flags_to_ioctl
3954         else if (flags & BTRFS_INODE_NOCOMPRESS)
3955                 iflags |= FS_NOCOMP_FL;
3956  
3957 +       if (flags & BTRFS_INODE_BARRIER)
3958 +               iflags |= FS_BARRIER_FL;
3959 +       if (flags & BTRFS_INODE_COW)
3960 +               iflags |= FS_COW_FL;
3961         return iflags;
3962  }
3963  
3964  /*
3965 - * Update inode->i_flags based on the btrfs internal flags.
3966 + * Update inode->i_(v)flags based on the btrfs internal flags.
3967   */
3968  void btrfs_update_iflags(struct inode *inode)
3969  {
3970         struct btrfs_inode *ip = BTRFS_I(inode);
3971  
3972 -       inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3973 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3974 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3975  
3976 -       if (ip->flags & BTRFS_INODE_SYNC)
3977 -               inode->i_flags |= S_SYNC;
3978         if (ip->flags & BTRFS_INODE_IMMUTABLE)
3979                 inode->i_flags |= S_IMMUTABLE;
3980 +       if (ip->flags & BTRFS_INODE_IXUNLINK)
3981 +               inode->i_flags |= S_IXUNLINK;
3982 +
3983 +       if (ip->flags & BTRFS_INODE_SYNC)
3984 +               inode->i_flags |= S_SYNC;
3985         if (ip->flags & BTRFS_INODE_APPEND)
3986                 inode->i_flags |= S_APPEND;
3987         if (ip->flags & BTRFS_INODE_NOATIME)
3988                 inode->i_flags |= S_NOATIME;
3989         if (ip->flags & BTRFS_INODE_DIRSYNC)
3990                 inode->i_flags |= S_DIRSYNC;
3991 +
3992 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
3993 +
3994 +       if (ip->flags & BTRFS_INODE_BARRIER)
3995 +               inode->i_vflags |= V_BARRIER;
3996 +       if (ip->flags & BTRFS_INODE_COW)
3997 +               inode->i_vflags |= V_COW;
3998 +}
3999 +
4000 +/*
4001 + * Update btrfs internal flags from inode->i_(v)flags.
4002 + */
4003 +void btrfs_update_flags(struct inode *inode)
4004 +{
4005 +       struct btrfs_inode *ip = BTRFS_I(inode);
4006 +
4007 +       unsigned int flags = inode->i_flags;
4008 +       unsigned int vflags = inode->i_vflags;
4009 +
4010 +       ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
4011 +                       BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
4012 +                       BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
4013 +                       BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
4014 +
4015 +       if (flags & S_IMMUTABLE)
4016 +               ip->flags |= BTRFS_INODE_IMMUTABLE;
4017 +       if (flags & S_IXUNLINK)
4018 +               ip->flags |= BTRFS_INODE_IXUNLINK;
4019 +
4020 +       if (flags & S_SYNC)
4021 +               ip->flags |= BTRFS_INODE_SYNC;
4022 +       if (flags & S_APPEND)
4023 +               ip->flags |= BTRFS_INODE_APPEND;
4024 +       if (flags & S_NOATIME)
4025 +               ip->flags |= BTRFS_INODE_NOATIME;
4026 +       if (flags & S_DIRSYNC)
4027 +               ip->flags |= BTRFS_INODE_DIRSYNC;
4028 +
4029 +       if (vflags & V_BARRIER)
4030 +               ip->flags |= BTRFS_INODE_BARRIER;
4031 +       if (vflags & V_COW)
4032 +               ip->flags |= BTRFS_INODE_COW;
4033  }
4034  
4035  /*
4036 @@ -129,7 +182,7 @@ void btrfs_inherit_iflags(struct inode *
4037         flags = BTRFS_I(dir)->flags;
4038  
4039         if (S_ISREG(inode->i_mode))
4040 -               flags &= ~BTRFS_INODE_DIRSYNC;
4041 +               flags &= ~(BTRFS_INODE_DIRSYNC | BTRFS_INODE_BARRIER);
4042         else if (!S_ISDIR(inode->i_mode))
4043                 flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
4044  
4045 @@ -137,6 +190,30 @@ void btrfs_inherit_iflags(struct inode *
4046         btrfs_update_iflags(inode);
4047  }
4048  
4049 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
4050 +{
4051 +       struct btrfs_inode *ip = BTRFS_I(inode);
4052 +       struct btrfs_root *root = ip->root;
4053 +       struct btrfs_trans_handle *trans;
4054 +       int ret;
4055 +
4056 +       trans = btrfs_join_transaction(root);
4057 +       BUG_ON(!trans);
4058 +
4059 +       inode->i_flags = flags;
4060 +       inode->i_vflags = vflags;
4061 +       btrfs_update_flags(inode);
4062 +
4063 +       ret = btrfs_update_inode(trans, root, inode);
4064 +       BUG_ON(ret);
4065 +
4066 +       btrfs_update_iflags(inode);
4067 +       inode->i_ctime = CURRENT_TIME;
4068 +       btrfs_end_transaction(trans, root);
4069 +
4070 +       return 0;
4071 +}
4072 +
4073  static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
4074  {
4075         struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
4076 @@ -188,7 +265,8 @@ static int btrfs_ioctl_setflags(struct f
4077  
4078         flags = btrfs_mask_flags(inode->i_mode, flags);
4079         oldflags = btrfs_flags_to_ioctl(ip->flags);
4080 -       if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
4081 +       if ((flags ^ oldflags) & (FS_APPEND_FL |
4082 +               FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
4083                 if (!capable(CAP_LINUX_IMMUTABLE)) {
4084                         ret = -EPERM;
4085                         goto out_unlock;
4086 @@ -199,14 +277,19 @@ static int btrfs_ioctl_setflags(struct f
4087         if (ret)
4088                 goto out_unlock;
4089  
4090 -       if (flags & FS_SYNC_FL)
4091 -               ip->flags |= BTRFS_INODE_SYNC;
4092 -       else
4093 -               ip->flags &= ~BTRFS_INODE_SYNC;
4094         if (flags & FS_IMMUTABLE_FL)
4095                 ip->flags |= BTRFS_INODE_IMMUTABLE;
4096         else
4097                 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
4098 +       if (flags & FS_IXUNLINK_FL)
4099 +               ip->flags |= BTRFS_INODE_IXUNLINK;
4100 +       else
4101 +               ip->flags &= ~BTRFS_INODE_IXUNLINK;
4102 +
4103 +       if (flags & FS_SYNC_FL)
4104 +               ip->flags |= BTRFS_INODE_SYNC;
4105 +       else
4106 +               ip->flags &= ~BTRFS_INODE_SYNC;
4107         if (flags & FS_APPEND_FL)
4108                 ip->flags |= BTRFS_INODE_APPEND;
4109         else
4110 diff -NurpP --minimal linux-3.0.4/fs/btrfs/super.c linux-3.0.4-vs2.3.1/fs/btrfs/super.c
4111 --- linux-3.0.4/fs/btrfs/super.c        2011-07-22 11:18:05.000000000 +0200
4112 +++ linux-3.0.4-vs2.3.1/fs/btrfs/super.c        2011-07-19 00:44:39.000000000 +0200
4113 @@ -162,7 +162,7 @@ enum {
4114         Opt_notreelog, Opt_ratio, Opt_flushoncommit, Opt_discard,
4115         Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed,
4116         Opt_enospc_debug, Opt_subvolrootid, Opt_defrag,
4117 -       Opt_inode_cache, Opt_err,
4118 +       Opt_inode_cache, Opt_tag, Opt_notag, Opt_tagid, Opt_err,
4119  };
4120  
4121  static match_table_t tokens = {
4122 @@ -195,6 +195,9 @@ static match_table_t tokens = {
4123         {Opt_subvolrootid, "subvolrootid=%d"},
4124         {Opt_defrag, "autodefrag"},
4125         {Opt_inode_cache, "inode_cache"},
4126 +       {Opt_tag, "tag"},
4127 +       {Opt_notag, "notag"},
4128 +       {Opt_tagid, "tagid=%u"},
4129         {Opt_err, NULL},
4130  };
4131  
4132 @@ -381,6 +384,22 @@ int btrfs_parse_options(struct btrfs_roo
4133                         printk(KERN_INFO "btrfs: enabling auto defrag");
4134                         btrfs_set_opt(info->mount_opt, AUTO_DEFRAG);
4135                         break;
4136 +#ifndef CONFIG_TAGGING_NONE
4137 +               case Opt_tag:
4138 +                       printk(KERN_INFO "btrfs: use tagging\n");
4139 +                       btrfs_set_opt(info->mount_opt, TAGGED);
4140 +                       break;
4141 +               case Opt_notag:
4142 +                       printk(KERN_INFO "btrfs: disabled tagging\n");
4143 +                       btrfs_clear_opt(info->mount_opt, TAGGED);
4144 +                       break;
4145 +#endif
4146 +#ifdef CONFIG_PROPAGATE
4147 +               case Opt_tagid:
4148 +                       /* use args[0] */
4149 +                       btrfs_set_opt(info->mount_opt, TAGGED);
4150 +                       break;
4151 +#endif
4152                 case Opt_err:
4153                         printk(KERN_INFO "btrfs: unrecognized mount option "
4154                                "'%s'\n", p);
4155 @@ -907,6 +926,12 @@ static int btrfs_remount(struct super_bl
4156         if (ret)
4157                 return -EINVAL;
4158  
4159 +       if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4160 +               printk("btrfs: %s: tagging not permitted on remount.\n",
4161 +                       sb->s_id);
4162 +               return -EINVAL;
4163 +       }
4164 +
4165         if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
4166                 return 0;
4167  
4168 diff -NurpP --minimal linux-3.0.4/fs/char_dev.c linux-3.0.4-vs2.3.1/fs/char_dev.c
4169 --- linux-3.0.4/fs/char_dev.c   2011-03-15 18:07:31.000000000 +0100
4170 +++ linux-3.0.4-vs2.3.1/fs/char_dev.c   2011-06-10 22:11:24.000000000 +0200
4171 @@ -21,6 +21,8 @@
4172  #include <linux/mutex.h>
4173  #include <linux/backing-dev.h>
4174  #include <linux/tty.h>
4175 +#include <linux/vs_context.h>
4176 +#include <linux/vs_device.h>
4177  
4178  #include "internal.h"
4179  
4180 @@ -371,14 +373,21 @@ static int chrdev_open(struct inode *ino
4181         struct cdev *p;
4182         struct cdev *new = NULL;
4183         int ret = 0;
4184 +       dev_t mdev;
4185 +
4186 +       if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
4187 +               return -EPERM;
4188 +       inode->i_mdev = mdev;
4189  
4190         spin_lock(&cdev_lock);
4191         p = inode->i_cdev;
4192         if (!p) {
4193                 struct kobject *kobj;
4194                 int idx;
4195 +
4196                 spin_unlock(&cdev_lock);
4197 -               kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
4198 +
4199 +               kobj = kobj_lookup(cdev_map, mdev, &idx);
4200                 if (!kobj)
4201                         return -ENXIO;
4202                 new = container_of(kobj, struct cdev, kobj);
4203 diff -NurpP --minimal linux-3.0.4/fs/dcache.c linux-3.0.4-vs2.3.1/fs/dcache.c
4204 --- linux-3.0.4/fs/dcache.c     2011-07-22 11:18:05.000000000 +0200
4205 +++ linux-3.0.4-vs2.3.1/fs/dcache.c     2011-07-22 11:20:39.000000000 +0200
4206 @@ -36,6 +36,7 @@
4207  #include <linux/bit_spinlock.h>
4208  #include <linux/rculist_bl.h>
4209  #include <linux/prefetch.h>
4210 +#include <linux/vs_limit.h>
4211  #include "internal.h"
4212  
4213  /*
4214 @@ -479,6 +480,8 @@ int d_invalidate(struct dentry * dentry)
4215                 spin_lock(&dentry->d_lock);
4216         }
4217  
4218 +       vx_dentry_dec(dentry);
4219 +
4220         /*
4221          * Somebody else still using it?
4222          *
4223 @@ -506,6 +509,7 @@ EXPORT_SYMBOL(d_invalidate);
4224  static inline void __dget_dlock(struct dentry *dentry)
4225  {
4226         dentry->d_count++;
4227 +       vx_dentry_inc(dentry);
4228  }
4229  
4230  static inline void __dget(struct dentry *dentry)
4231 @@ -1266,6 +1270,9 @@ struct dentry *d_alloc(struct dentry * p
4232         struct dentry *dentry;
4233         char *dname;
4234  
4235 +       if (!vx_dentry_avail(1))
4236 +               return NULL;
4237 +
4238         dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
4239         if (!dentry)
4240                 return NULL;
4241 @@ -1288,6 +1295,7 @@ struct dentry *d_alloc(struct dentry * p
4242  
4243         dentry->d_count = 1;
4244         dentry->d_flags = 0;
4245 +       vx_dentry_inc(dentry);
4246         spin_lock_init(&dentry->d_lock);
4247         seqcount_init(&dentry->d_seq);
4248         dentry->d_inode = NULL;
4249 @@ -1945,6 +1953,7 @@ struct dentry *__d_lookup(struct dentry 
4250                 }
4251  
4252                 dentry->d_count++;
4253 +               vx_dentry_inc(dentry);
4254                 found = dentry;
4255                 spin_unlock(&dentry->d_lock);
4256                 break;
4257 diff -NurpP --minimal linux-3.0.4/fs/devpts/inode.c linux-3.0.4-vs2.3.1/fs/devpts/inode.c
4258 --- linux-3.0.4/fs/devpts/inode.c       2011-05-22 16:17:50.000000000 +0200
4259 +++ linux-3.0.4-vs2.3.1/fs/devpts/inode.c       2011-06-10 22:11:24.000000000 +0200
4260 @@ -25,6 +25,7 @@
4261  #include <linux/parser.h>
4262  #include <linux/fsnotify.h>
4263  #include <linux/seq_file.h>
4264 +#include <linux/vs_base.h>
4265  
4266  #define DEVPTS_DEFAULT_MODE 0600
4267  /*
4268 @@ -36,6 +37,20 @@
4269  #define DEVPTS_DEFAULT_PTMX_MODE 0000
4270  #define PTMX_MINOR     2
4271  
4272 +static int devpts_permission(struct inode *inode, int mask, unsigned int flags)
4273 +{
4274 +       int ret = -EACCES;
4275 +
4276 +       /* devpts is xid tagged */
4277 +       if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
4278 +               ret = generic_permission(inode, mask, flags, NULL);
4279 +       return ret;
4280 +}
4281 +
4282 +static struct inode_operations devpts_file_inode_operations = {
4283 +       .permission     = devpts_permission,
4284 +};
4285 +
4286  extern int pty_limit;                  /* Config limit on Unix98 ptys */
4287  static DEFINE_MUTEX(allocated_ptys_lock);
4288  
4289 @@ -263,6 +278,34 @@ static int devpts_show_options(struct se
4290         return 0;
4291  }
4292  
4293 +static int devpts_filter(struct dentry *de)
4294 +{
4295 +       xid_t xid = 0;
4296 +
4297 +       /* devpts is xid tagged */
4298 +       if (de && de->d_inode)
4299 +               xid = (xid_t)de->d_inode->i_tag;
4300 +#ifdef CONFIG_VSERVER_WARN_DEVPTS
4301 +       else
4302 +               vxwprintk_task(1, "devpts " VS_Q("%.*s") " without inode.",
4303 +                       de->d_name.len, de->d_name.name);
4304 +#endif
4305 +       return vx_check(xid, VS_WATCH_P | VS_IDENT);
4306 +}
4307 +
4308 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
4309 +{
4310 +       return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
4311 +}
4312 +
4313 +static struct file_operations devpts_dir_operations = {
4314 +       .open           = dcache_dir_open,
4315 +       .release        = dcache_dir_close,
4316 +       .llseek         = dcache_dir_lseek,
4317 +       .read           = generic_read_dir,
4318 +       .readdir        = devpts_readdir,
4319 +};
4320 +
4321  static const struct super_operations devpts_sops = {
4322         .statfs         = simple_statfs,
4323         .remount_fs     = devpts_remount,
4324 @@ -302,12 +345,15 @@ devpts_fill_super(struct super_block *s,
4325         inode = new_inode(s);
4326         if (!inode)
4327                 goto free_fsi;
4328 +
4329         inode->i_ino = 1;
4330         inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
4331         inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
4332         inode->i_op = &simple_dir_inode_operations;
4333 -       inode->i_fop = &simple_dir_operations;
4334 +       inode->i_fop = &devpts_dir_operations;
4335         inode->i_nlink = 2;
4336 +       /* devpts is xid tagged */
4337 +       inode->i_tag = (tag_t)vx_current_xid();
4338  
4339         s->s_root = d_alloc_root(inode);
4340         if (s->s_root)
4341 @@ -494,6 +540,9 @@ int devpts_pty_new(struct inode *ptmx_in
4342         inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
4343         inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
4344         init_special_inode(inode, S_IFCHR|opts->mode, device);
4345 +       /* devpts is xid tagged */
4346 +       inode->i_tag = (tag_t)vx_current_xid();
4347 +       inode->i_op = &devpts_file_inode_operations;
4348         inode->i_private = tty;
4349         tty->driver_data = inode;
4350  
4351 diff -NurpP --minimal linux-3.0.4/fs/ext2/balloc.c linux-3.0.4-vs2.3.1/fs/ext2/balloc.c
4352 --- linux-3.0.4/fs/ext2/balloc.c        2011-05-22 16:17:51.000000000 +0200
4353 +++ linux-3.0.4-vs2.3.1/fs/ext2/balloc.c        2011-06-10 22:11:24.000000000 +0200
4354 @@ -701,7 +701,6 @@ ext2_try_to_allocate(struct super_block 
4355                         start = 0;
4356                 end = EXT2_BLOCKS_PER_GROUP(sb);
4357         }
4358 -
4359         BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
4360  
4361  repeat:
4362 diff -NurpP --minimal linux-3.0.4/fs/ext2/ext2.h linux-3.0.4-vs2.3.1/fs/ext2/ext2.h
4363 --- linux-3.0.4/fs/ext2/ext2.h  2011-05-22 16:17:51.000000000 +0200
4364 +++ linux-3.0.4-vs2.3.1/fs/ext2/ext2.h  2011-06-10 22:11:24.000000000 +0200
4365 @@ -126,6 +126,7 @@ extern void ext2_set_inode_flags(struct 
4366  extern void ext2_get_inode_flags(struct ext2_inode_info *);
4367  extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
4368                        u64 start, u64 len);
4369 +extern int ext2_sync_flags(struct inode *, int, int);
4370  
4371  /* ioctl.c */
4372  extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
4373 diff -NurpP --minimal linux-3.0.4/fs/ext2/file.c linux-3.0.4-vs2.3.1/fs/ext2/file.c
4374 --- linux-3.0.4/fs/ext2/file.c  2010-08-02 16:52:48.000000000 +0200
4375 +++ linux-3.0.4-vs2.3.1/fs/ext2/file.c  2011-06-10 22:11:24.000000000 +0200
4376 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
4377         .setattr        = ext2_setattr,
4378         .check_acl      = ext2_check_acl,
4379         .fiemap         = ext2_fiemap,
4380 +       .sync_flags     = ext2_sync_flags,
4381  };
4382 diff -NurpP --minimal linux-3.0.4/fs/ext2/ialloc.c linux-3.0.4-vs2.3.1/fs/ext2/ialloc.c
4383 --- linux-3.0.4/fs/ext2/ialloc.c        2011-05-22 16:17:51.000000000 +0200
4384 +++ linux-3.0.4-vs2.3.1/fs/ext2/ialloc.c        2011-06-10 22:11:24.000000000 +0200
4385 @@ -17,6 +17,7 @@
4386  #include <linux/backing-dev.h>
4387  #include <linux/buffer_head.h>
4388  #include <linux/random.h>
4389 +#include <linux/vs_tag.h>
4390  #include "ext2.h"
4391  #include "xattr.h"
4392  #include "acl.h"
4393 @@ -549,6 +550,7 @@ got:
4394                 inode->i_mode = mode;
4395                 inode->i_uid = current_fsuid();
4396                 inode->i_gid = dir->i_gid;
4397 +               inode->i_tag = dx_current_fstag(sb);
4398         } else
4399                 inode_init_owner(inode, dir, mode);
4400  
4401 diff -NurpP --minimal linux-3.0.4/fs/ext2/inode.c linux-3.0.4-vs2.3.1/fs/ext2/inode.c
4402 --- linux-3.0.4/fs/ext2/inode.c 2011-05-22 16:17:51.000000000 +0200
4403 +++ linux-3.0.4-vs2.3.1/fs/ext2/inode.c 2011-06-10 22:11:24.000000000 +0200
4404 @@ -32,6 +32,7 @@
4405  #include <linux/mpage.h>
4406  #include <linux/fiemap.h>
4407  #include <linux/namei.h>
4408 +#include <linux/vs_tag.h>
4409  #include "ext2.h"
4410  #include "acl.h"
4411  #include "xip.h"
4412 @@ -1167,7 +1168,7 @@ static void ext2_truncate_blocks(struct 
4413                 return;
4414         if (ext2_inode_is_fast_symlink(inode))
4415                 return;
4416 -       if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4417 +       if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4418                 return;
4419         __ext2_truncate_blocks(inode, offset);
4420  }
4421 @@ -1256,36 +1257,61 @@ void ext2_set_inode_flags(struct inode *
4422  {
4423         unsigned int flags = EXT2_I(inode)->i_flags;
4424  
4425 -       inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4426 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4427 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4428 +
4429 +
4430 +       if (flags & EXT2_IMMUTABLE_FL)
4431 +               inode->i_flags |= S_IMMUTABLE;
4432 +       if (flags & EXT2_IXUNLINK_FL)
4433 +               inode->i_flags |= S_IXUNLINK;
4434 +
4435         if (flags & EXT2_SYNC_FL)
4436                 inode->i_flags |= S_SYNC;
4437         if (flags & EXT2_APPEND_FL)
4438                 inode->i_flags |= S_APPEND;
4439 -       if (flags & EXT2_IMMUTABLE_FL)
4440 -               inode->i_flags |= S_IMMUTABLE;
4441         if (flags & EXT2_NOATIME_FL)
4442                 inode->i_flags |= S_NOATIME;
4443         if (flags & EXT2_DIRSYNC_FL)
4444                 inode->i_flags |= S_DIRSYNC;
4445 +
4446 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
4447 +
4448 +       if (flags & EXT2_BARRIER_FL)
4449 +               inode->i_vflags |= V_BARRIER;
4450 +       if (flags & EXT2_COW_FL)
4451 +               inode->i_vflags |= V_COW;
4452  }
4453  
4454  /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
4455  void ext2_get_inode_flags(struct ext2_inode_info *ei)
4456  {
4457         unsigned int flags = ei->vfs_inode.i_flags;
4458 +       unsigned int vflags = ei->vfs_inode.i_vflags;
4459 +
4460 +       ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
4461 +                       EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
4462 +                       EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
4463 +                       EXT2_BARRIER_FL | EXT2_COW_FL);
4464 +
4465 +       if (flags & S_IMMUTABLE)
4466 +               ei->i_flags |= EXT2_IMMUTABLE_FL;
4467 +       if (flags & S_IXUNLINK)
4468 +               ei->i_flags |= EXT2_IXUNLINK_FL;
4469  
4470 -       ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
4471 -                       EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
4472         if (flags & S_SYNC)
4473                 ei->i_flags |= EXT2_SYNC_FL;
4474         if (flags & S_APPEND)
4475                 ei->i_flags |= EXT2_APPEND_FL;
4476 -       if (flags & S_IMMUTABLE)
4477 -               ei->i_flags |= EXT2_IMMUTABLE_FL;
4478         if (flags & S_NOATIME)
4479                 ei->i_flags |= EXT2_NOATIME_FL;
4480         if (flags & S_DIRSYNC)
4481                 ei->i_flags |= EXT2_DIRSYNC_FL;
4482 +
4483 +       if (vflags & V_BARRIER)
4484 +               ei->i_flags |= EXT2_BARRIER_FL;
4485 +       if (vflags & V_COW)
4486 +               ei->i_flags |= EXT2_COW_FL;
4487  }
4488  
4489  struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
4490 @@ -1295,6 +1321,8 @@ struct inode *ext2_iget (struct super_bl
4491         struct ext2_inode *raw_inode;
4492         struct inode *inode;
4493         long ret = -EIO;
4494 +       uid_t uid;
4495 +       gid_t gid;
4496         int n;
4497  
4498         inode = iget_locked(sb, ino);
4499 @@ -1313,12 +1341,17 @@ struct inode *ext2_iget (struct super_bl
4500         }
4501  
4502         inode->i_mode = le16_to_cpu(raw_inode->i_mode);
4503 -       inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4504 -       inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4505 +       uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4506 +       gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4507         if (!(test_opt (inode->i_sb, NO_UID32))) {
4508 -               inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4509 -               inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4510 +               uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4511 +               gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4512         }
4513 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
4514 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
4515 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
4516 +               le16_to_cpu(raw_inode->i_raw_tag));
4517 +
4518         inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
4519         inode->i_size = le32_to_cpu(raw_inode->i_size);
4520         inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
4521 @@ -1416,8 +1449,8 @@ static int __ext2_write_inode(struct ino
4522         struct ext2_inode_info *ei = EXT2_I(inode);
4523         struct super_block *sb = inode->i_sb;
4524         ino_t ino = inode->i_ino;
4525 -       uid_t uid = inode->i_uid;
4526 -       gid_t gid = inode->i_gid;
4527 +       uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
4528 +       gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
4529         struct buffer_head * bh;
4530         struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
4531         int n;
4532 @@ -1453,6 +1486,9 @@ static int __ext2_write_inode(struct ino
4533                 raw_inode->i_uid_high = 0;
4534                 raw_inode->i_gid_high = 0;
4535         }
4536 +#ifdef CONFIG_TAGGING_INTERN
4537 +       raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4538 +#endif
4539         raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4540         raw_inode->i_size = cpu_to_le32(inode->i_size);
4541         raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
4542 @@ -1533,7 +1569,8 @@ int ext2_setattr(struct dentry *dentry, 
4543         if (is_quota_modification(inode, iattr))
4544                 dquot_initialize(inode);
4545         if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
4546 -           (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
4547 +           (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
4548 +           (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
4549                 error = dquot_transfer(inode, iattr);
4550                 if (error)
4551                         return error;
4552 diff -NurpP --minimal linux-3.0.4/fs/ext2/ioctl.c linux-3.0.4-vs2.3.1/fs/ext2/ioctl.c
4553 --- linux-3.0.4/fs/ext2/ioctl.c 2011-05-22 16:17:51.000000000 +0200
4554 +++ linux-3.0.4-vs2.3.1/fs/ext2/ioctl.c 2011-06-10 22:11:24.000000000 +0200
4555 @@ -17,6 +17,16 @@
4556  #include <asm/uaccess.h>
4557  
4558  
4559 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
4560 +{
4561 +       inode->i_flags = flags;
4562 +       inode->i_vflags = vflags;
4563 +       ext2_get_inode_flags(EXT2_I(inode));
4564 +       inode->i_ctime = CURRENT_TIME_SEC;
4565 +       mark_inode_dirty(inode);
4566 +       return 0;
4567 +}
4568 +
4569  long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4570  {
4571         struct inode *inode = filp->f_dentry->d_inode;
4572 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
4573  
4574                 flags = ext2_mask_flags(inode->i_mode, flags);
4575  
4576 +               if (IS_BARRIER(inode)) {
4577 +                       vxwprintk_task(1, "messing with the barrier.");
4578 +                       return -EACCES;
4579 +               }
4580 +
4581                 mutex_lock(&inode->i_mutex);
4582                 /* Is it quota file? Do not allow user to mess with it */
4583                 if (IS_NOQUOTA(inode)) {
4584 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
4585                  *
4586                  * This test looks nicer. Thanks to Pauline Middelink
4587                  */
4588 -               if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
4589 +               if ((oldflags & EXT2_IMMUTABLE_FL) ||
4590 +                       ((flags ^ oldflags) & (EXT2_APPEND_FL |
4591 +                       EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
4592                         if (!capable(CAP_LINUX_IMMUTABLE)) {
4593                                 mutex_unlock(&inode->i_mutex);
4594                                 ret = -EPERM;
4595 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
4596                         }
4597                 }
4598  
4599 -               flags = flags & EXT2_FL_USER_MODIFIABLE;
4600 +               flags &= EXT2_FL_USER_MODIFIABLE;
4601                 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
4602                 ei->i_flags = flags;
4603                 mutex_unlock(&inode->i_mutex);
4604 diff -NurpP --minimal linux-3.0.4/fs/ext2/namei.c linux-3.0.4-vs2.3.1/fs/ext2/namei.c
4605 --- linux-3.0.4/fs/ext2/namei.c 2011-05-22 16:17:51.000000000 +0200
4606 +++ linux-3.0.4-vs2.3.1/fs/ext2/namei.c 2011-06-10 22:11:24.000000000 +0200
4607 @@ -32,6 +32,7 @@
4608  
4609  #include <linux/pagemap.h>
4610  #include <linux/quotaops.h>
4611 +#include <linux/vs_tag.h>
4612  #include "ext2.h"
4613  #include "xattr.h"
4614  #include "acl.h"
4615 @@ -75,6 +76,7 @@ static struct dentry *ext2_lookup(struct
4616                                 return ERR_PTR(-EIO);
4617                         } else {
4618                                 return ERR_CAST(inode);
4619 +               dx_propagate_tag(nd, inode);
4620                         }
4621                 }
4622         }
4623 @@ -413,6 +415,7 @@ const struct inode_operations ext2_dir_i
4624  #endif
4625         .setattr        = ext2_setattr,
4626         .check_acl      = ext2_check_acl,
4627 +       .sync_flags     = ext2_sync_flags,
4628  };
4629  
4630  const struct inode_operations ext2_special_inode_operations = {
4631 diff -NurpP --minimal linux-3.0.4/fs/ext2/super.c linux-3.0.4-vs2.3.1/fs/ext2/super.c
4632 --- linux-3.0.4/fs/ext2/super.c 2011-07-22 11:18:05.000000000 +0200
4633 +++ linux-3.0.4-vs2.3.1/fs/ext2/super.c 2011-06-10 22:11:24.000000000 +0200
4634 @@ -394,7 +394,8 @@ enum {
4635         Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
4636         Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
4637         Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
4638 -       Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
4639 +       Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
4640 +       Opt_tag, Opt_notag, Opt_tagid
4641  };
4642  
4643  static const match_table_t tokens = {
4644 @@ -422,6 +423,9 @@ static const match_table_t tokens = {
4645         {Opt_acl, "acl"},
4646         {Opt_noacl, "noacl"},
4647         {Opt_xip, "xip"},
4648 +       {Opt_tag, "tag"},
4649 +       {Opt_notag, "notag"},
4650 +       {Opt_tagid, "tagid=%u"},
4651         {Opt_grpquota, "grpquota"},
4652         {Opt_ignore, "noquota"},
4653         {Opt_quota, "quota"},
4654 @@ -492,6 +496,20 @@ static int parse_options(char *options, 
4655                 case Opt_nouid32:
4656                         set_opt (sbi->s_mount_opt, NO_UID32);
4657                         break;
4658 +#ifndef CONFIG_TAGGING_NONE
4659 +               case Opt_tag:
4660 +                       set_opt (sbi->s_mount_opt, TAGGED);
4661 +                       break;
4662 +               case Opt_notag:
4663 +                       clear_opt (sbi->s_mount_opt, TAGGED);
4664 +                       break;
4665 +#endif
4666 +#ifdef CONFIG_PROPAGATE
4667 +               case Opt_tagid:
4668 +                       /* use args[0] */
4669 +                       set_opt (sbi->s_mount_opt, TAGGED);
4670 +                       break;
4671 +#endif
4672                 case Opt_nocheck:
4673                         clear_opt (sbi->s_mount_opt, CHECK);
4674                         break;
4675 @@ -850,6 +868,8 @@ static int ext2_fill_super(struct super_
4676         if (!parse_options((char *) data, sb))
4677                 goto failed_mount;
4678  
4679 +       if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
4680 +               sb->s_flags |= MS_TAGGED;
4681         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4682                 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
4683                  MS_POSIXACL : 0);
4684 @@ -1224,6 +1244,14 @@ static int ext2_remount (struct super_bl
4685                 goto restore_opts;
4686         }
4687  
4688 +       if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
4689 +               !(sb->s_flags & MS_TAGGED)) {
4690 +               printk("EXT2-fs: %s: tagging not permitted on remount.\n",
4691 +                      sb->s_id);
4692 +               err = -EINVAL;
4693 +               goto restore_opts;
4694 +       }
4695 +
4696         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4697                 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4698  
4699 diff -NurpP --minimal linux-3.0.4/fs/ext3/file.c linux-3.0.4-vs2.3.1/fs/ext3/file.c
4700 --- linux-3.0.4/fs/ext3/file.c  2010-07-07 18:31:51.000000000 +0200
4701 +++ linux-3.0.4-vs2.3.1/fs/ext3/file.c  2011-06-10 22:11:24.000000000 +0200
4702 @@ -81,5 +81,6 @@ const struct inode_operations ext3_file_
4703  #endif
4704         .check_acl      = ext3_check_acl,
4705         .fiemap         = ext3_fiemap,
4706 +       .sync_flags     = ext3_sync_flags,
4707  };
4708  
4709 diff -NurpP --minimal linux-3.0.4/fs/ext3/ialloc.c linux-3.0.4-vs2.3.1/fs/ext3/ialloc.c
4710 --- linux-3.0.4/fs/ext3/ialloc.c        2011-05-22 16:17:52.000000000 +0200
4711 +++ linux-3.0.4-vs2.3.1/fs/ext3/ialloc.c        2011-06-10 22:11:24.000000000 +0200
4712 @@ -23,6 +23,7 @@
4713  #include <linux/buffer_head.h>
4714  #include <linux/random.h>
4715  #include <linux/bitops.h>
4716 +#include <linux/vs_tag.h>
4717  
4718  #include <asm/byteorder.h>
4719  
4720 @@ -532,6 +533,7 @@ got:
4721                 inode->i_mode = mode;
4722                 inode->i_uid = current_fsuid();
4723                 inode->i_gid = dir->i_gid;
4724 +               inode->i_tag = dx_current_fstag(sb);
4725         } else
4726                 inode_init_owner(inode, dir, mode);
4727  
4728 diff -NurpP --minimal linux-3.0.4/fs/ext3/inode.c linux-3.0.4-vs2.3.1/fs/ext3/inode.c
4729 --- linux-3.0.4/fs/ext3/inode.c 2011-07-22 11:18:05.000000000 +0200
4730 +++ linux-3.0.4-vs2.3.1/fs/ext3/inode.c 2011-06-10 22:11:24.000000000 +0200
4731 @@ -38,6 +38,7 @@
4732  #include <linux/bio.h>
4733  #include <linux/fiemap.h>
4734  #include <linux/namei.h>
4735 +#include <linux/vs_tag.h>
4736  #include "xattr.h"
4737  #include "acl.h"
4738  
4739 @@ -2391,7 +2392,7 @@ static void ext3_free_branches(handle_t 
4740  
4741  int ext3_can_truncate(struct inode *inode)
4742  {
4743 -       if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4744 +       if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4745                 return 0;
4746         if (S_ISREG(inode->i_mode))
4747                 return 1;
4748 @@ -2775,36 +2776,60 @@ void ext3_set_inode_flags(struct inode *
4749  {
4750         unsigned int flags = EXT3_I(inode)->i_flags;
4751  
4752 -       inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4753 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4754 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4755 +
4756 +       if (flags & EXT3_IMMUTABLE_FL)
4757 +               inode->i_flags |= S_IMMUTABLE;
4758 +       if (flags & EXT3_IXUNLINK_FL)
4759 +               inode->i_flags |= S_IXUNLINK;
4760 +
4761         if (flags & EXT3_SYNC_FL)
4762                 inode->i_flags |= S_SYNC;
4763         if (flags & EXT3_APPEND_FL)
4764                 inode->i_flags |= S_APPEND;
4765 -       if (flags & EXT3_IMMUTABLE_FL)
4766 -               inode->i_flags |= S_IMMUTABLE;
4767         if (flags & EXT3_NOATIME_FL)
4768                 inode->i_flags |= S_NOATIME;
4769         if (flags & EXT3_DIRSYNC_FL)
4770                 inode->i_flags |= S_DIRSYNC;
4771 +
4772 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
4773 +
4774 +       if (flags & EXT3_BARRIER_FL)
4775 +               inode->i_vflags |= V_BARRIER;
4776 +       if (flags & EXT3_COW_FL)
4777 +               inode->i_vflags |= V_COW;
4778  }
4779  
4780  /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
4781  void ext3_get_inode_flags(struct ext3_inode_info *ei)
4782  {
4783         unsigned int flags = ei->vfs_inode.i_flags;
4784 +       unsigned int vflags = ei->vfs_inode.i_vflags;
4785 +
4786 +       ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
4787 +                       EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
4788 +                       EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
4789 +                       EXT3_BARRIER_FL | EXT3_COW_FL);
4790 +
4791 +       if (flags & S_IMMUTABLE)
4792 +               ei->i_flags |= EXT3_IMMUTABLE_FL;
4793 +       if (flags & S_IXUNLINK)
4794 +               ei->i_flags |= EXT3_IXUNLINK_FL;
4795  
4796 -       ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
4797 -                       EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
4798         if (flags & S_SYNC)
4799                 ei->i_flags |= EXT3_SYNC_FL;
4800         if (flags & S_APPEND)
4801                 ei->i_flags |= EXT3_APPEND_FL;
4802 -       if (flags & S_IMMUTABLE)
4803 -               ei->i_flags |= EXT3_IMMUTABLE_FL;
4804         if (flags & S_NOATIME)
4805                 ei->i_flags |= EXT3_NOATIME_FL;
4806         if (flags & S_DIRSYNC)
4807                 ei->i_flags |= EXT3_DIRSYNC_FL;
4808 +
4809 +       if (vflags & V_BARRIER)
4810 +               ei->i_flags |= EXT3_BARRIER_FL;
4811 +       if (vflags & V_COW)
4812 +               ei->i_flags |= EXT3_COW_FL;
4813  }
4814  
4815  struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
4816 @@ -2818,6 +2843,8 @@ struct inode *ext3_iget(struct super_blo
4817         transaction_t *transaction;
4818         long ret;
4819         int block;
4820 +       uid_t uid;
4821 +       gid_t gid;
4822  
4823         inode = iget_locked(sb, ino);
4824         if (!inode)
4825 @@ -2834,12 +2861,17 @@ struct inode *ext3_iget(struct super_blo
4826         bh = iloc.bh;
4827         raw_inode = ext3_raw_inode(&iloc);
4828         inode->i_mode = le16_to_cpu(raw_inode->i_mode);
4829 -       inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4830 -       inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4831 +       uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4832 +       gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4833         if(!(test_opt (inode->i_sb, NO_UID32))) {
4834 -               inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4835 -               inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4836 +               uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4837 +               gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4838         }
4839 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
4840 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
4841 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
4842 +               le16_to_cpu(raw_inode->i_raw_tag));
4843 +
4844         inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
4845         inode->i_size = le32_to_cpu(raw_inode->i_size);
4846         inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
4847 @@ -2994,6 +3026,8 @@ static int ext3_do_update_inode(handle_t
4848         struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
4849         struct ext3_inode_info *ei = EXT3_I(inode);
4850         struct buffer_head *bh = iloc->bh;
4851 +       uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
4852 +       gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
4853         int err = 0, rc, block;
4854  
4855  again:
4856 @@ -3008,29 +3042,32 @@ again:
4857         ext3_get_inode_flags(ei);
4858         raw_inode->i_mode = cpu_to_le16(inode->i_mode);
4859         if(!(test_opt(inode->i_sb, NO_UID32))) {
4860 -               raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
4861 -               raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
4862 +               raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
4863 +               raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
4864  /*
4865   * Fix up interoperability with old kernels. Otherwise, old inodes get
4866   * re-used with the upper 16 bits of the uid/gid intact
4867   */
4868                 if(!ei->i_dtime) {
4869                         raw_inode->i_uid_high =
4870 -                               cpu_to_le16(high_16_bits(inode->i_uid));
4871 +                               cpu_to_le16(high_16_bits(uid));
4872                         raw_inode->i_gid_high =
4873 -                               cpu_to_le16(high_16_bits(inode->i_gid));
4874 +                               cpu_to_le16(high_16_bits(gid));
4875                 } else {
4876                         raw_inode->i_uid_high = 0;
4877                         raw_inode->i_gid_high = 0;
4878                 }
4879         } else {
4880                 raw_inode->i_uid_low =
4881 -                       cpu_to_le16(fs_high2lowuid(inode->i_uid));
4882 +                       cpu_to_le16(fs_high2lowuid(uid));
4883                 raw_inode->i_gid_low =
4884 -                       cpu_to_le16(fs_high2lowgid(inode->i_gid));
4885 +                       cpu_to_le16(fs_high2lowgid(gid));
4886                 raw_inode->i_uid_high = 0;
4887                 raw_inode->i_gid_high = 0;
4888         }
4889 +#ifdef CONFIG_TAGGING_INTERN
4890 +       raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4891 +#endif
4892         raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4893         raw_inode->i_size = cpu_to_le32(ei->i_disksize);
4894         raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
4895 @@ -3190,7 +3227,8 @@ int ext3_setattr(struct dentry *dentry, 
4896         if (is_quota_modification(inode, attr))
4897                 dquot_initialize(inode);
4898         if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
4899 -               (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
4900 +               (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
4901 +               (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
4902                 handle_t *handle;
4903  
4904                 /* (user+group)*(old+new) structure, inode write (sb,
4905 @@ -3212,6 +3250,8 @@ int ext3_setattr(struct dentry *dentry, 
4906                         inode->i_uid = attr->ia_uid;
4907                 if (attr->ia_valid & ATTR_GID)
4908                         inode->i_gid = attr->ia_gid;
4909 +               if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
4910 +                       inode->i_tag = attr->ia_tag;
4911                 error = ext3_mark_inode_dirty(handle, inode);
4912                 ext3_journal_stop(handle);
4913         }
4914 diff -NurpP --minimal linux-3.0.4/fs/ext3/ioctl.c linux-3.0.4-vs2.3.1/fs/ext3/ioctl.c
4915 --- linux-3.0.4/fs/ext3/ioctl.c 2011-05-22 16:17:52.000000000 +0200
4916 +++ linux-3.0.4-vs2.3.1/fs/ext3/ioctl.c 2011-06-10 22:11:24.000000000 +0200
4917 @@ -8,6 +8,7 @@
4918   */
4919  
4920  #include <linux/fs.h>
4921 +#include <linux/mount.h>
4922  #include <linux/jbd.h>
4923  #include <linux/capability.h>
4924  #include <linux/ext3_fs.h>
4925 @@ -17,6 +18,34 @@
4926  #include <linux/compat.h>
4927  #include <asm/uaccess.h>
4928  
4929 +
4930 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
4931 +{
4932 +       handle_t *handle = NULL;
4933 +       struct ext3_iloc iloc;
4934 +       int err;
4935 +
4936 +       handle = ext3_journal_start(inode, 1);
4937 +       if (IS_ERR(handle))
4938 +               return PTR_ERR(handle);
4939 +
4940 +       if (IS_SYNC(inode))
4941 +               handle->h_sync = 1;
4942 +       err = ext3_reserve_inode_write(handle, inode, &iloc);
4943 +       if (err)
4944 +               goto flags_err;
4945 +
4946 +       inode->i_flags = flags;
4947 +       inode->i_vflags = vflags;
4948 +       ext3_get_inode_flags(EXT3_I(inode));
4949 +       inode->i_ctime = CURRENT_TIME_SEC;
4950 +
4951 +       err = ext3_mark_iloc_dirty(handle, inode, &iloc);
4952 +flags_err:
4953 +       ext3_journal_stop(handle);
4954 +       return err;
4955 +}
4956 +
4957  long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4958  {
4959         struct inode *inode = filp->f_dentry->d_inode;
4960 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
4961  
4962                 flags = ext3_mask_flags(inode->i_mode, flags);
4963  
4964 +               if (IS_BARRIER(inode)) {
4965 +                       vxwprintk_task(1, "messing with the barrier.");
4966 +                       return -EACCES;
4967 +               }
4968 +
4969                 mutex_lock(&inode->i_mutex);
4970  
4971                 /* Is it quota file? Do not allow user to mess with it */
4972 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
4973                  *
4974                  * This test looks nicer. Thanks to Pauline Middelink
4975                  */
4976 -               if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
4977 +               if ((oldflags & EXT3_IMMUTABLE_FL) ||
4978 +                       ((flags ^ oldflags) & (EXT3_APPEND_FL |
4979 +                       EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
4980                         if (!capable(CAP_LINUX_IMMUTABLE))
4981                                 goto flags_out;
4982                 }
4983 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
4984                 if (err)
4985                         goto flags_err;
4986  
4987 -               flags = flags & EXT3_FL_USER_MODIFIABLE;
4988 +               flags &= EXT3_FL_USER_MODIFIABLE;
4989                 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
4990                 ei->i_flags = flags;
4991  
4992 diff -NurpP --minimal linux-3.0.4/fs/ext3/namei.c linux-3.0.4-vs2.3.1/fs/ext3/namei.c
4993 --- linux-3.0.4/fs/ext3/namei.c 2011-08-31 18:56:42.000000000 +0200
4994 +++ linux-3.0.4-vs2.3.1/fs/ext3/namei.c 2011-08-29 03:45:09.000000000 +0200
4995 @@ -36,6 +36,7 @@
4996  #include <linux/quotaops.h>
4997  #include <linux/buffer_head.h>
4998  #include <linux/bio.h>
4999 +#include <linux/vs_tag.h>
5000  
5001  #include "namei.h"
5002  #include "xattr.h"
5003 @@ -923,6 +924,7 @@ restart:
5004                                 if (bh)
5005                                         ll_rw_block(READ_META, 1, &bh);
5006                         }
5007 +               dx_propagate_tag(nd, inode);
5008                 }
5009                 if ((bh = bh_use[ra_ptr++]) == NULL)
5010                         goto next;
5011 @@ -2536,6 +2538,7 @@ const struct inode_operations ext3_dir_i
5012         .removexattr    = generic_removexattr,
5013  #endif
5014         .check_acl      = ext3_check_acl,
5015 +       .sync_flags     = ext3_sync_flags,
5016  };
5017  
5018  const struct inode_operations ext3_special_inode_operations = {
5019 diff -NurpP --minimal linux-3.0.4/fs/ext3/super.c linux-3.0.4-vs2.3.1/fs/ext3/super.c
5020 --- linux-3.0.4/fs/ext3/super.c 2011-07-22 11:18:05.000000000 +0200
5021 +++ linux-3.0.4-vs2.3.1/fs/ext3/super.c 2011-06-10 22:11:24.000000000 +0200
5022 @@ -821,7 +821,8 @@ enum {
5023         Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
5024         Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
5025         Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
5026 -       Opt_resize, Opt_usrquota, Opt_grpquota
5027 +       Opt_resize, Opt_usrquota, Opt_grpquota,
5028 +       Opt_tag, Opt_notag, Opt_tagid
5029  };
5030  
5031  static const match_table_t tokens = {
5032 @@ -878,6 +879,9 @@ static const match_table_t tokens = {
5033         {Opt_barrier, "barrier"},
5034         {Opt_nobarrier, "nobarrier"},
5035         {Opt_resize, "resize"},
5036 +       {Opt_tag, "tag"},
5037 +       {Opt_notag, "notag"},
5038 +       {Opt_tagid, "tagid=%u"},
5039         {Opt_err, NULL},
5040  };
5041  
5042 @@ -1030,6 +1034,20 @@ static int parse_options (char *options,
5043                 case Opt_nouid32:
5044                         set_opt (sbi->s_mount_opt, NO_UID32);
5045                         break;
5046 +#ifndef CONFIG_TAGGING_NONE
5047 +               case Opt_tag:
5048 +                       set_opt (sbi->s_mount_opt, TAGGED);
5049 +                       break;
5050 +               case Opt_notag:
5051 +                       clear_opt (sbi->s_mount_opt, TAGGED);
5052 +                       break;
5053 +#endif
5054 +#ifdef CONFIG_PROPAGATE
5055 +               case Opt_tagid:
5056 +                       /* use args[0] */
5057 +                       set_opt (sbi->s_mount_opt, TAGGED);
5058 +                       break;
5059 +#endif
5060                 case Opt_nocheck:
5061                         clear_opt (sbi->s_mount_opt, CHECK);
5062                         break;
5063 @@ -1724,6 +1742,9 @@ static int ext3_fill_super (struct super
5064                             NULL, 0))
5065                 goto failed_mount;
5066  
5067 +       if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
5068 +               sb->s_flags |= MS_TAGGED;
5069 +
5070         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
5071                 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
5072  
5073 @@ -2604,6 +2625,14 @@ static int ext3_remount (struct super_bl
5074         if (test_opt(sb, ABORT))
5075                 ext3_abort(sb, __func__, "Abort forced by user");
5076  
5077 +       if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
5078 +               !(sb->s_flags & MS_TAGGED)) {
5079 +               printk("EXT3-fs: %s: tagging not permitted on remount.\n",
5080 +                       sb->s_id);
5081 +               err = -EINVAL;
5082 +               goto restore_opts;
5083 +       }
5084 +
5085         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
5086                 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
5087  
5088 diff -NurpP --minimal linux-3.0.4/fs/ext4/ext4.h linux-3.0.4-vs2.3.1/fs/ext4/ext4.h
5089 --- linux-3.0.4/fs/ext4/ext4.h  2011-08-31 18:56:42.000000000 +0200
5090 +++ linux-3.0.4-vs2.3.1/fs/ext4/ext4.h  2011-08-08 23:04:47.000000000 +0200
5091 @@ -350,8 +350,12 @@ struct flex_groups {
5092  #define EXT4_EXTENTS_FL                        0x00080000 /* Inode uses extents */
5093  #define EXT4_EA_INODE_FL               0x00200000 /* Inode used for large EA */
5094  #define EXT4_EOFBLOCKS_FL              0x00400000 /* Blocks allocated beyond EOF */
5095 +#define EXT4_IXUNLINK_FL               0x08000000 /* Immutable invert on unlink */
5096  #define EXT4_RESERVED_FL               0x80000000 /* reserved for ext4 lib */
5097  
5098 +#define EXT4_BARRIER_FL                        0x04000000 /* Barrier for chroot() */
5099 +#define EXT4_COW_FL                    0x20000000 /* Copy on Write marker */
5100 +
5101  #define EXT4_FL_USER_VISIBLE           0x004BDFFF /* User visible flags */
5102  #define EXT4_FL_USER_MODIFIABLE                0x004B80FF /* User modifiable flags */
5103  
5104 @@ -609,7 +613,8 @@ struct ext4_inode {
5105                         __le16  l_i_file_acl_high;
5106                         __le16  l_i_uid_high;   /* these 2 fields */
5107                         __le16  l_i_gid_high;   /* were reserved2[0] */
5108 -                       __u32   l_i_reserved2;
5109 +                       __le16  l_i_tag;        /* Context Tag */
5110 +                       __u16   l_i_reserved2;
5111                 } linux2;
5112                 struct {
5113                         __le16  h_i_reserved1;  /* Obsoleted fragment number/size which are removed in ext4 */
5114 @@ -727,6 +732,7 @@ do {                                                                               \
5115  #define i_gid_low      i_gid
5116  #define i_uid_high     osd2.linux2.l_i_uid_high
5117  #define i_gid_high     osd2.linux2.l_i_gid_high
5118 +#define i_raw_tag      osd2.linux2.l_i_tag
5119  #define i_reserved2    osd2.linux2.l_i_reserved2
5120  
5121  #elif defined(__GNU__)
5122 @@ -903,6 +909,7 @@ struct ext4_inode_info {
5123  #define EXT4_MOUNT_POSIX_ACL           0x08000 /* POSIX Access Control Lists */
5124  #define EXT4_MOUNT_NO_AUTO_DA_ALLOC    0x10000 /* No auto delalloc mapping */
5125  #define EXT4_MOUNT_BARRIER             0x20000 /* Use block barriers */
5126 +#define EXT4_MOUNT_TAGGED              0x40000 /* Enable Context Tags */
5127  #define EXT4_MOUNT_QUOTA               0x80000 /* Some quota option set */
5128  #define EXT4_MOUNT_USRQUOTA            0x100000 /* "old" user quota */
5129  #define EXT4_MOUNT_GRPQUOTA            0x200000 /* "old" group quota */
5130 @@ -2173,6 +2180,7 @@ extern int ext4_map_blocks(handle_t *han
5131                            struct ext4_map_blocks *map, int flags);
5132  extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
5133                         __u64 start, __u64 len);
5134 +extern int ext4_sync_flags(struct inode *, int, int);
5135  /* move_extent.c */
5136  extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
5137                              __u64 start_orig, __u64 start_donor,
5138 diff -NurpP --minimal linux-3.0.4/fs/ext4/file.c linux-3.0.4-vs2.3.1/fs/ext4/file.c
5139 --- linux-3.0.4/fs/ext4/file.c  2011-07-22 11:18:05.000000000 +0200
5140 +++ linux-3.0.4-vs2.3.1/fs/ext4/file.c  2011-06-10 22:11:24.000000000 +0200
5141 @@ -282,5 +282,6 @@ const struct inode_operations ext4_file_
5142  #endif
5143         .check_acl      = ext4_check_acl,
5144         .fiemap         = ext4_fiemap,
5145 +       .sync_flags     = ext4_sync_flags,
5146  };
5147  
5148 diff -NurpP --minimal linux-3.0.4/fs/ext4/ialloc.c linux-3.0.4-vs2.3.1/fs/ext4/ialloc.c
5149 --- linux-3.0.4/fs/ext4/ialloc.c        2011-05-22 16:17:52.000000000 +0200
5150 +++ linux-3.0.4-vs2.3.1/fs/ext4/ialloc.c        2011-06-10 22:11:24.000000000 +0200
5151 @@ -22,6 +22,7 @@
5152  #include <linux/random.h>
5153  #include <linux/bitops.h>
5154  #include <linux/blkdev.h>
5155 +#include <linux/vs_tag.h>
5156  #include <asm/byteorder.h>
5157  
5158  #include "ext4.h"
5159 @@ -992,6 +993,7 @@ got:
5160                 inode->i_mode = mode;
5161                 inode->i_uid = current_fsuid();
5162                 inode->i_gid = dir->i_gid;
5163 +               inode->i_tag = dx_current_fstag(sb);
5164         } else
5165                 inode_init_owner(inode, dir, mode);
5166  
5167 diff -NurpP --minimal linux-3.0.4/fs/ext4/inode.c linux-3.0.4-vs2.3.1/fs/ext4/inode.c
5168 --- linux-3.0.4/fs/ext4/inode.c 2011-08-31 18:56:42.000000000 +0200
5169 +++ linux-3.0.4-vs2.3.1/fs/ext4/inode.c 2011-08-31 19:37:44.000000000 +0200
5170 @@ -42,6 +42,7 @@
5171  #include <linux/printk.h>
5172  #include <linux/slab.h>
5173  #include <linux/ratelimit.h>
5174 +#include <linux/vs_tag.h>
5175  
5176  #include "ext4_jbd2.h"
5177  #include "xattr.h"
5178 @@ -4819,41 +4820,64 @@ void ext4_set_inode_flags(struct inode *
5179  {
5180         unsigned int flags = EXT4_I(inode)->i_flags;
5181  
5182 -       inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
5183 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5184 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5185 +
5186 +       if (flags & EXT4_IMMUTABLE_FL)
5187 +               inode->i_flags |= S_IMMUTABLE;
5188 +       if (flags & EXT4_IXUNLINK_FL)
5189 +               inode->i_flags |= S_IXUNLINK;
5190 +
5191         if (flags & EXT4_SYNC_FL)
5192                 inode->i_flags |= S_SYNC;
5193         if (flags & EXT4_APPEND_FL)
5194                 inode->i_flags |= S_APPEND;
5195 -       if (flags & EXT4_IMMUTABLE_FL)
5196 -               inode->i_flags |= S_IMMUTABLE;
5197         if (flags & EXT4_NOATIME_FL)
5198                 inode->i_flags |= S_NOATIME;
5199         if (flags & EXT4_DIRSYNC_FL)
5200                 inode->i_flags |= S_DIRSYNC;
5201 +
5202 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
5203 +
5204 +       if (flags & EXT4_BARRIER_FL)
5205 +               inode->i_vflags |= V_BARRIER;
5206 +       if (flags & EXT4_COW_FL)
5207 +               inode->i_vflags |= V_COW;
5208  }
5209  
5210  /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
5211  void ext4_get_inode_flags(struct ext4_inode_info *ei)
5212  {
5213 -       unsigned int vfs_fl;
5214 +       unsigned int vfs_fl, vfs_vf;
5215         unsigned long old_fl, new_fl;
5216  
5217         do {
5218                 vfs_fl = ei->vfs_inode.i_flags;
5219 +               vfs_vf = ei->vfs_inode.i_vflags;
5220                 old_fl = ei->i_flags;
5221                 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
5222                                 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
5223 -                               EXT4_DIRSYNC_FL);
5224 +                               EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
5225 +                               EXT4_COW_FL);
5226 +
5227 +               if (vfs_fl & S_IMMUTABLE)
5228 +                       new_fl |= EXT4_IMMUTABLE_FL;
5229 +               if (vfs_fl & S_IXUNLINK)
5230 +                       new_fl |= EXT4_IXUNLINK_FL;
5231 +
5232                 if (vfs_fl & S_SYNC)
5233                         new_fl |= EXT4_SYNC_FL;
5234                 if (vfs_fl & S_APPEND)
5235                         new_fl |= EXT4_APPEND_FL;
5236 -               if (vfs_fl & S_IMMUTABLE)
5237 -                       new_fl |= EXT4_IMMUTABLE_FL;
5238                 if (vfs_fl & S_NOATIME)
5239                         new_fl |= EXT4_NOATIME_FL;
5240                 if (vfs_fl & S_DIRSYNC)
5241                         new_fl |= EXT4_DIRSYNC_FL;
5242 +
5243 +               if (vfs_vf & V_BARRIER)
5244 +                       new_fl |= EXT4_BARRIER_FL;
5245 +               if (vfs_vf & V_COW)
5246 +                       new_fl |= EXT4_COW_FL;
5247         } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
5248  }
5249  
5250 @@ -4889,6 +4913,8 @@ struct inode *ext4_iget(struct super_blo
5251         journal_t *journal = EXT4_SB(sb)->s_journal;
5252         long ret;
5253         int block;
5254 +       uid_t uid;
5255 +       gid_t gid;
5256  
5257         inode = iget_locked(sb, ino);
5258         if (!inode)
5259 @@ -4904,12 +4930,16 @@ struct inode *ext4_iget(struct super_blo
5260                 goto bad_inode;
5261         raw_inode = ext4_raw_inode(&iloc);
5262         inode->i_mode = le16_to_cpu(raw_inode->i_mode);
5263 -       inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
5264 -       inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
5265 +       uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
5266 +       gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
5267         if (!(test_opt(inode->i_sb, NO_UID32))) {
5268 -               inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
5269 -               inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
5270 +               uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
5271 +               gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
5272         }
5273 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5274 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5275 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
5276 +               le16_to_cpu(raw_inode->i_raw_tag));
5277         inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
5278  
5279         ext4_clear_state_flags(ei);     /* Only relevant on 32-bit archs */
5280 @@ -5128,6 +5158,8 @@ static int ext4_do_update_inode(handle_t
5281         struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
5282         struct ext4_inode_info *ei = EXT4_I(inode);
5283         struct buffer_head *bh = iloc->bh;
5284 +       uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
5285 +       gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
5286         int err = 0, rc, block;
5287  
5288         /* For fields not not tracking in the in-memory inode,
5289 @@ -5138,29 +5170,32 @@ static int ext4_do_update_inode(handle_t
5290         ext4_get_inode_flags(ei);
5291         raw_inode->i_mode = cpu_to_le16(inode->i_mode);
5292         if (!(test_opt(inode->i_sb, NO_UID32))) {
5293 -               raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
5294 -               raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
5295 +               raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
5296 +               raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
5297  /*
5298   * Fix up interoperability with old kernels. Otherwise, old inodes get
5299   * re-used with the upper 16 bits of the uid/gid intact
5300   */
5301                 if (!ei->i_dtime) {
5302                         raw_inode->i_uid_high =
5303 -                               cpu_to_le16(high_16_bits(inode->i_uid));
5304 +                               cpu_to_le16(high_16_bits(uid));
5305                         raw_inode->i_gid_high =
5306 -                               cpu_to_le16(high_16_bits(inode->i_gid));
5307 +                               cpu_to_le16(high_16_bits(gid));
5308                 } else {
5309                         raw_inode->i_uid_high = 0;
5310                         raw_inode->i_gid_high = 0;
5311                 }
5312         } else {
5313                 raw_inode->i_uid_low =
5314 -                       cpu_to_le16(fs_high2lowuid(inode->i_uid));
5315 +                       cpu_to_le16(fs_high2lowuid(uid));
5316                 raw_inode->i_gid_low =
5317 -                       cpu_to_le16(fs_high2lowgid(inode->i_gid));
5318 +                       cpu_to_le16(fs_high2lowgid(gid));
5319                 raw_inode->i_uid_high = 0;
5320                 raw_inode->i_gid_high = 0;
5321         }
5322 +#ifdef CONFIG_TAGGING_INTERN
5323 +       raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
5324 +#endif
5325         raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
5326  
5327         EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
5328 @@ -5346,7 +5381,8 @@ int ext4_setattr(struct dentry *dentry, 
5329         if (is_quota_modification(inode, attr))
5330                 dquot_initialize(inode);
5331         if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
5332 -               (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
5333 +               (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
5334 +               (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
5335                 handle_t *handle;
5336  
5337                 /* (user+group)*(old+new) structure, inode write (sb,
5338 @@ -5368,6 +5404,8 @@ int ext4_setattr(struct dentry *dentry, 
5339                         inode->i_uid = attr->ia_uid;
5340                 if (attr->ia_valid & ATTR_GID)
5341                         inode->i_gid = attr->ia_gid;
5342 +               if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5343 +                       inode->i_tag = attr->ia_tag;
5344                 error = ext4_mark_inode_dirty(handle, inode);
5345                 ext4_journal_stop(handle);
5346         }
5347 diff -NurpP --minimal linux-3.0.4/fs/ext4/ioctl.c linux-3.0.4-vs2.3.1/fs/ext4/ioctl.c
5348 --- linux-3.0.4/fs/ext4/ioctl.c 2011-05-22 16:17:52.000000000 +0200
5349 +++ linux-3.0.4-vs2.3.1/fs/ext4/ioctl.c 2011-06-10 22:11:24.000000000 +0200
5350 @@ -14,10 +14,39 @@
5351  #include <linux/compat.h>
5352  #include <linux/mount.h>
5353  #include <linux/file.h>
5354 +#include <linux/vs_tag.h>
5355  #include <asm/uaccess.h>
5356  #include "ext4_jbd2.h"
5357  #include "ext4.h"
5358  
5359 +
5360 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
5361 +{
5362 +       handle_t *handle = NULL;
5363 +       struct ext4_iloc iloc;
5364 +       int err;
5365 +
5366 +       handle = ext4_journal_start(inode, 1);
5367 +       if (IS_ERR(handle))
5368 +               return PTR_ERR(handle);
5369 +
5370 +       if (IS_SYNC(inode))
5371 +               ext4_handle_sync(handle);
5372 +       err = ext4_reserve_inode_write(handle, inode, &iloc);
5373 +       if (err)
5374 +               goto flags_err;
5375 +
5376 +       inode->i_flags = flags;
5377 +       inode->i_vflags = vflags;
5378 +       ext4_get_inode_flags(EXT4_I(inode));
5379 +       inode->i_ctime = ext4_current_time(inode);
5380 +
5381 +       err = ext4_mark_iloc_dirty(handle, inode, &iloc);
5382 +flags_err:
5383 +       ext4_journal_stop(handle);
5384 +       return err;
5385 +}
5386 +
5387  long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5388  {
5389         struct inode *inode = filp->f_dentry->d_inode;
5390 @@ -50,6 +79,11 @@ long ext4_ioctl(struct file *filp, unsig
5391  
5392                 flags = ext4_mask_flags(inode->i_mode, flags);
5393  
5394 +               if (IS_BARRIER(inode)) {
5395 +                       vxwprintk_task(1, "messing with the barrier.");
5396 +                       return -EACCES;
5397 +               }
5398 +
5399                 err = -EPERM;
5400                 mutex_lock(&inode->i_mutex);
5401                 /* Is it quota file? Do not allow user to mess with it */
5402 @@ -67,7 +101,9 @@ long ext4_ioctl(struct file *filp, unsig
5403                  *
5404                  * This test looks nicer. Thanks to Pauline Middelink
5405                  */
5406 -               if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
5407 +               if ((oldflags & EXT4_IMMUTABLE_FL) ||
5408 +                       ((flags ^ oldflags) & (EXT4_APPEND_FL |
5409 +                       EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
5410                         if (!capable(CAP_LINUX_IMMUTABLE))
5411                                 goto flags_out;
5412                 }
5413 diff -NurpP --minimal linux-3.0.4/fs/ext4/namei.c linux-3.0.4-vs2.3.1/fs/ext4/namei.c
5414 --- linux-3.0.4/fs/ext4/namei.c 2011-08-31 18:56:42.000000000 +0200
5415 +++ linux-3.0.4-vs2.3.1/fs/ext4/namei.c 2011-08-29 03:45:09.000000000 +0200
5416 @@ -34,6 +34,7 @@
5417  #include <linux/quotaops.h>
5418  #include <linux/buffer_head.h>
5419  #include <linux/bio.h>
5420 +#include <linux/vs_tag.h>
5421  #include "ext4.h"
5422  #include "ext4_jbd2.h"
5423  
5424 @@ -924,6 +925,7 @@ restart:
5425                                 if (bh)
5426                                         ll_rw_block(READ_META, 1, &bh);
5427                         }
5428 +               dx_propagate_tag(nd, inode);
5429                 }
5430                 if ((bh = bh_use[ra_ptr++]) == NULL)
5431                         goto next;
5432 @@ -2598,6 +2600,7 @@ const struct inode_operations ext4_dir_i
5433  #endif
5434         .check_acl      = ext4_check_acl,
5435         .fiemap         = ext4_fiemap,
5436 +       .sync_flags     = ext4_sync_flags,
5437  };
5438  
5439  const struct inode_operations ext4_special_inode_operations = {
5440 diff -NurpP --minimal linux-3.0.4/fs/ext4/super.c linux-3.0.4-vs2.3.1/fs/ext4/super.c
5441 --- linux-3.0.4/fs/ext4/super.c 2011-08-31 18:56:42.000000000 +0200
5442 +++ linux-3.0.4-vs2.3.1/fs/ext4/super.c 2011-08-31 19:37:44.000000000 +0200
5443 @@ -1293,6 +1293,7 @@ enum {
5444         Opt_dioread_nolock, Opt_dioread_lock,
5445         Opt_discard, Opt_nodiscard,
5446         Opt_init_inode_table, Opt_noinit_inode_table,
5447 +       Opt_tag, Opt_notag, Opt_tagid
5448  };
5449  
5450  static const match_table_t tokens = {
5451 @@ -1368,6 +1369,9 @@ static const match_table_t tokens = {
5452         {Opt_init_inode_table, "init_itable=%u"},
5453         {Opt_init_inode_table, "init_itable"},
5454         {Opt_noinit_inode_table, "noinit_itable"},
5455 +       {Opt_tag, "tag"},
5456 +       {Opt_notag, "notag"},
5457 +       {Opt_tagid, "tagid=%u"},
5458         {Opt_err, NULL},
5459  };
5460  
5461 @@ -1536,6 +1540,20 @@ static int parse_options(char *options, 
5462                 case Opt_nouid32:
5463                         set_opt(sb, NO_UID32);
5464                         break;
5465 +#ifndef CONFIG_TAGGING_NONE
5466 +               case Opt_tag:
5467 +                       set_opt(sb, TAGGED);
5468 +                       break;
5469 +               case Opt_notag:
5470 +                       clear_opt(sb, TAGGED);
5471 +                       break;
5472 +#endif
5473 +#ifdef CONFIG_PROPAGATE
5474 +               case Opt_tagid:
5475 +                       /* use args[0] */
5476 +                       set_opt(sb, TAGGED);
5477 +                       break;
5478 +#endif
5479                 case Opt_debug:
5480                         set_opt(sb, DEBUG);
5481                         break;
5482 @@ -3193,6 +3211,9 @@ static int ext4_fill_super(struct super_
5483                            &journal_ioprio, NULL, 0))
5484                 goto failed_mount;
5485  
5486 +       if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
5487 +               sb->s_flags |= MS_TAGGED;
5488 +
5489         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
5490                 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
5491  
5492 @@ -4323,6 +4344,14 @@ static int ext4_remount(struct super_blo
5493         if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
5494                 ext4_abort(sb, "Abort forced by user");
5495  
5496 +       if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
5497 +               !(sb->s_flags & MS_TAGGED)) {
5498 +               printk("EXT4-fs: %s: tagging not permitted on remount.\n",
5499 +                       sb->s_id);
5500 +               err = -EINVAL;
5501 +               goto restore_opts;
5502 +       }
5503 +
5504         sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
5505                 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
5506  
5507 diff -NurpP --minimal linux-3.0.4/fs/fcntl.c linux-3.0.4-vs2.3.1/fs/fcntl.c
5508 --- linux-3.0.4/fs/fcntl.c      2011-05-22 16:17:52.000000000 +0200
5509 +++ linux-3.0.4-vs2.3.1/fs/fcntl.c      2011-06-10 22:11:24.000000000 +0200
5510 @@ -20,6 +20,7 @@
5511  #include <linux/signal.h>
5512  #include <linux/rcupdate.h>
5513  #include <linux/pid_namespace.h>
5514 +#include <linux/vs_limit.h>
5515  
5516  #include <asm/poll.h>
5517  #include <asm/siginfo.h>
5518 @@ -103,6 +104,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
5519  
5520         if (tofree)
5521                 filp_close(tofree, files);
5522 +       else
5523 +               vx_openfd_inc(newfd);   /* fd was unused */
5524  
5525         return newfd;
5526  
5527 @@ -447,6 +450,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
5528         filp = fget_raw(fd);
5529         if (!filp)
5530                 goto out;
5531 +       if (!vx_files_avail(1))
5532 +               goto out;
5533  
5534         if (unlikely(filp->f_mode & FMODE_PATH)) {
5535                 if (!check_fcntl_cmd(cmd)) {
5536 diff -NurpP --minimal linux-3.0.4/fs/file.c linux-3.0.4-vs2.3.1/fs/file.c
5537 --- linux-3.0.4/fs/file.c       2011-05-22 16:17:52.000000000 +0200
5538 +++ linux-3.0.4-vs2.3.1/fs/file.c       2011-06-10 22:11:24.000000000 +0200
5539 @@ -21,6 +21,7 @@
5540  #include <linux/spinlock.h>
5541  #include <linux/rcupdate.h>
5542  #include <linux/workqueue.h>
5543 +#include <linux/vs_limit.h>
5544  
5545  struct fdtable_defer {
5546         spinlock_t lock;
5547 @@ -359,6 +360,8 @@ struct files_struct *dup_fd(struct files
5548                 struct file *f = *old_fds++;
5549                 if (f) {
5550                         get_file(f);
5551 +                       /* TODO: sum it first for check and performance */
5552 +                       vx_openfd_inc(open_files - i);
5553                 } else {
5554                         /*
5555                          * The fd may be claimed in the fd bitmap but not yet
5556 @@ -466,6 +469,7 @@ repeat:
5557         else
5558                 FD_CLR(fd, fdt->close_on_exec);
5559         error = fd;
5560 +       vx_openfd_inc(fd);
5561  #if 1
5562         /* Sanity check */
5563         if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
5564 diff -NurpP --minimal linux-3.0.4/fs/file_table.c linux-3.0.4-vs2.3.1/fs/file_table.c
5565 --- linux-3.0.4/fs/file_table.c 2011-05-22 16:17:52.000000000 +0200
5566 +++ linux-3.0.4-vs2.3.1/fs/file_table.c 2011-06-10 22:11:24.000000000 +0200
5567 @@ -24,6 +24,8 @@
5568  #include <linux/percpu_counter.h>
5569  #include <linux/percpu.h>
5570  #include <linux/ima.h>
5571 +#include <linux/vs_limit.h>
5572 +#include <linux/vs_context.h>
5573  
5574  #include <asm/atomic.h>
5575  
5576 @@ -135,6 +137,8 @@ struct file *get_empty_filp(void)
5577         spin_lock_init(&f->f_lock);
5578         eventpoll_init_file(f);
5579         /* f->f_version: 0 */
5580 +       f->f_xid = vx_current_xid();
5581 +       vx_files_inc(f);
5582         return f;
5583  
5584  over:
5585 @@ -253,6 +257,8 @@ static void __fput(struct file *file)
5586         }
5587         fops_put(file->f_op);
5588         put_pid(file->f_owner.pid);
5589 +       vx_files_dec(file);
5590 +       file->f_xid = 0;
5591         file_sb_list_del(file);
5592         if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
5593                 i_readcount_dec(inode);
5594 @@ -383,6 +389,8 @@ void put_filp(struct file *file)
5595  {
5596         if (atomic_long_dec_and_test(&file->f_count)) {
5597                 security_file_free(file);
5598 +               vx_files_dec(file);
5599 +               file->f_xid = 0;
5600                 file_sb_list_del(file);
5601                 file_free(file);
5602         }
5603 diff -NurpP --minimal linux-3.0.4/fs/fs_struct.c linux-3.0.4-vs2.3.1/fs/fs_struct.c
5604 --- linux-3.0.4/fs/fs_struct.c  2011-03-15 18:07:31.000000000 +0100
5605 +++ linux-3.0.4-vs2.3.1/fs/fs_struct.c  2011-06-10 22:11:24.000000000 +0200
5606 @@ -4,6 +4,7 @@
5607  #include <linux/path.h>
5608  #include <linux/slab.h>
5609  #include <linux/fs_struct.h>
5610 +#include <linux/vserver/global.h>
5611  #include "internal.h"
5612  
5613  static inline void path_get_longterm(struct path *path)
5614 @@ -96,6 +97,7 @@ void free_fs_struct(struct fs_struct *fs
5615  {
5616         path_put_longterm(&fs->root);
5617         path_put_longterm(&fs->pwd);
5618 +       atomic_dec(&vs_global_fs);
5619         kmem_cache_free(fs_cachep, fs);
5620  }
5621  
5622 @@ -135,6 +137,7 @@ struct fs_struct *copy_fs_struct(struct 
5623                 fs->pwd = old->pwd;
5624                 path_get_longterm(&fs->pwd);
5625                 spin_unlock(&old->lock);
5626 +               atomic_inc(&vs_global_fs);
5627         }
5628         return fs;
5629  }
5630 diff -NurpP --minimal linux-3.0.4/fs/gfs2/file.c linux-3.0.4-vs2.3.1/fs/gfs2/file.c
5631 --- linux-3.0.4/fs/gfs2/file.c  2011-07-22 11:18:05.000000000 +0200
5632 +++ linux-3.0.4-vs2.3.1/fs/gfs2/file.c  2011-06-10 22:11:24.000000000 +0200
5633 @@ -134,6 +134,9 @@ static const u32 fsflags_to_gfs2[32] = {
5634         [7] = GFS2_DIF_NOATIME,
5635         [12] = GFS2_DIF_EXHASH,
5636         [14] = GFS2_DIF_INHERIT_JDATA,
5637 +       [27] = GFS2_DIF_IXUNLINK,
5638 +       [26] = GFS2_DIF_BARRIER,
5639 +       [29] = GFS2_DIF_COW,
5640  };
5641  
5642  static const u32 gfs2_to_fsflags[32] = {
5643 @@ -143,6 +146,9 @@ static const u32 gfs2_to_fsflags[32] = {
5644         [gfs2fl_NoAtime] = FS_NOATIME_FL,
5645         [gfs2fl_ExHash] = FS_INDEX_FL,
5646         [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
5647 +       [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
5648 +       [gfs2fl_Barrier] = FS_BARRIER_FL,
5649 +       [gfs2fl_Cow] = FS_COW_FL,
5650  };
5651  
5652  static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
5653 @@ -173,10 +179,16 @@ void gfs2_set_inode_flags(struct inode *
5654  {
5655         struct gfs2_inode *ip = GFS2_I(inode);
5656         unsigned int flags = inode->i_flags;
5657 +       unsigned int vflags = inode->i_vflags;
5658 +
5659 +       flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5660 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5661  
5662 -       flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
5663         if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
5664                 flags |= S_IMMUTABLE;
5665 +       if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
5666 +               flags |= S_IXUNLINK;
5667 +
5668         if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
5669                 flags |= S_APPEND;
5670         if (ip->i_diskflags & GFS2_DIF_NOATIME)
5671 @@ -184,6 +196,43 @@ void gfs2_set_inode_flags(struct inode *
5672         if (ip->i_diskflags & GFS2_DIF_SYNC)
5673                 flags |= S_SYNC;
5674         inode->i_flags = flags;
5675 +
5676 +       vflags &= ~(V_BARRIER | V_COW);
5677 +
5678 +       if (ip->i_diskflags & GFS2_DIF_BARRIER)
5679 +               vflags |= V_BARRIER;
5680 +       if (ip->i_diskflags & GFS2_DIF_COW)
5681 +               vflags |= V_COW;
5682 +       inode->i_vflags = vflags;
5683 +}
5684 +
5685 +void gfs2_get_inode_flags(struct inode *inode)
5686 +{
5687 +       struct gfs2_inode *ip = GFS2_I(inode);
5688 +       unsigned int flags = inode->i_flags;
5689 +       unsigned int vflags = inode->i_vflags;
5690 +
5691 +       ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
5692 +                       GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
5693 +                       GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
5694 +                       GFS2_DIF_BARRIER | GFS2_DIF_COW);
5695 +
5696 +       if (flags & S_IMMUTABLE)
5697 +               ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
5698 +       if (flags & S_IXUNLINK)
5699 +               ip->i_diskflags |= GFS2_DIF_IXUNLINK;
5700 +
5701 +       if (flags & S_APPEND)
5702 +               ip->i_diskflags |= GFS2_DIF_APPENDONLY;
5703 +       if (flags & S_NOATIME)
5704 +               ip->i_diskflags |= GFS2_DIF_NOATIME;
5705 +       if (flags & S_SYNC)
5706 +               ip->i_diskflags |= GFS2_DIF_SYNC;
5707 +
5708 +       if (vflags & V_BARRIER)
5709 +               ip->i_diskflags |= GFS2_DIF_BARRIER;
5710 +       if (vflags & V_COW)
5711 +               ip->i_diskflags |= GFS2_DIF_COW;
5712  }
5713  
5714  /* Flags that can be set by user space */
5715 @@ -295,6 +344,37 @@ static int gfs2_set_flags(struct file *f
5716         return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
5717  }
5718  
5719 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
5720 +{
5721 +       struct gfs2_inode *ip = GFS2_I(inode);
5722 +       struct gfs2_sbd *sdp = GFS2_SB(inode);
5723 +       struct buffer_head *bh;
5724 +       struct gfs2_holder gh;
5725 +       int error;
5726 +
5727 +       error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
5728 +       if (error)
5729 +               return error;
5730 +       error = gfs2_trans_begin(sdp, RES_DINODE, 0);
5731 +       if (error)
5732 +               goto out;
5733 +       error = gfs2_meta_inode_buffer(ip, &bh);
5734 +       if (error)
5735 +               goto out_trans_end;
5736 +       gfs2_trans_add_bh(ip->i_gl, bh, 1);
5737 +       inode->i_flags = flags;
5738 +       inode->i_vflags = vflags;
5739 +       gfs2_get_inode_flags(inode);
5740 +       gfs2_dinode_out(ip, bh->b_data);
5741 +       brelse(bh);
5742 +       gfs2_set_aops(inode);
5743 +out_trans_end:
5744 +       gfs2_trans_end(sdp);
5745 +out:
5746 +       gfs2_glock_dq_uninit(&gh);
5747 +       return error;
5748 +}
5749 +
5750  static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5751  {
5752         switch(cmd) {
5753 diff -NurpP --minimal linux-3.0.4/fs/gfs2/inode.h linux-3.0.4-vs2.3.1/fs/gfs2/inode.h
5754 --- linux-3.0.4/fs/gfs2/inode.h 2011-07-22 11:18:05.000000000 +0200
5755 +++ linux-3.0.4-vs2.3.1/fs/gfs2/inode.h 2011-06-10 22:11:24.000000000 +0200
5756 @@ -120,6 +120,7 @@ extern const struct file_operations gfs2
5757  extern const struct file_operations gfs2_dir_fops_nolock;
5758  
5759  extern void gfs2_set_inode_flags(struct inode *inode);
5760 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
5761   
5762  #ifdef CONFIG_GFS2_FS_LOCKING_DLM
5763  extern const struct file_operations gfs2_file_fops;
5764 diff -NurpP --minimal linux-3.0.4/fs/inode.c linux-3.0.4-vs2.3.1/fs/inode.c
5765 --- linux-3.0.4/fs/inode.c      2011-07-22 11:18:05.000000000 +0200
5766 +++ linux-3.0.4-vs2.3.1/fs/inode.c      2011-07-01 11:35:34.000000000 +0200
5767 @@ -26,6 +26,7 @@
5768  #include <linux/ima.h>
5769  #include <linux/cred.h>
5770  #include <linux/buffer_head.h> /* for inode_has_buffers */
5771 +#include <linux/vs_tag.h>
5772  #include "internal.h"
5773  
5774  /*
5775 @@ -146,6 +147,9 @@ int inode_init_always(struct super_block
5776         struct address_space *const mapping = &inode->i_data;
5777  
5778         inode->i_sb = sb;
5779 +
5780 +       /* essential because of inode slab reuse */
5781 +       inode->i_tag = 0;
5782         inode->i_blkbits = sb->s_blocksize_bits;
5783         inode->i_flags = 0;
5784         atomic_set(&inode->i_count, 1);
5785 @@ -166,6 +170,7 @@ int inode_init_always(struct super_block
5786         inode->i_bdev = NULL;
5787         inode->i_cdev = NULL;
5788         inode->i_rdev = 0;
5789 +       inode->i_mdev = 0;
5790         inode->dirtied_when = 0;
5791  
5792         if (security_inode_alloc(inode))
5793 @@ -404,6 +409,8 @@ void __insert_inode_hash(struct inode *i
5794  }
5795  EXPORT_SYMBOL(__insert_inode_hash);
5796  
5797 +EXPORT_SYMBOL_GPL(__iget);
5798 +
5799  /**
5800   *     remove_inode_hash - remove an inode from the hash
5801   *     @inode: inode to unhash
5802 @@ -1643,9 +1650,11 @@ void init_special_inode(struct inode *in
5803         if (S_ISCHR(mode)) {
5804                 inode->i_fop = &def_chr_fops;
5805                 inode->i_rdev = rdev;
5806 +               inode->i_mdev = rdev;
5807         } else if (S_ISBLK(mode)) {
5808                 inode->i_fop = &def_blk_fops;
5809                 inode->i_rdev = rdev;
5810 +               inode->i_mdev = rdev;
5811         } else if (S_ISFIFO(mode))
5812                 inode->i_fop = &def_fifo_fops;
5813         else if (S_ISSOCK(mode))
5814 @@ -1674,6 +1683,7 @@ void inode_init_owner(struct inode *inod
5815         } else
5816                 inode->i_gid = current_fsgid();
5817         inode->i_mode = mode;
5818 +       inode->i_tag = dx_current_fstag(inode->i_sb);
5819  }
5820  EXPORT_SYMBOL(inode_init_owner);
5821  
5822 diff -NurpP --minimal linux-3.0.4/fs/ioctl.c linux-3.0.4-vs2.3.1/fs/ioctl.c
5823 --- linux-3.0.4/fs/ioctl.c      2011-05-22 16:17:52.000000000 +0200
5824 +++ linux-3.0.4-vs2.3.1/fs/ioctl.c      2011-06-10 22:11:24.000000000 +0200
5825 @@ -15,6 +15,9 @@
5826  #include <linux/writeback.h>
5827  #include <linux/buffer_head.h>
5828  #include <linux/falloc.h>
5829 +#include <linux/proc_fs.h>
5830 +#include <linux/vserver/inode.h>
5831 +#include <linux/vs_tag.h>
5832  
5833  #include <asm/ioctls.h>
5834  
5835 diff -NurpP --minimal linux-3.0.4/fs/ioprio.c linux-3.0.4-vs2.3.1/fs/ioprio.c
5836 --- linux-3.0.4/fs/ioprio.c     2011-01-05 21:50:24.000000000 +0100
5837 +++ linux-3.0.4-vs2.3.1/fs/ioprio.c     2011-06-10 22:11:24.000000000 +0200
5838 @@ -27,6 +27,7 @@
5839  #include <linux/syscalls.h>
5840  #include <linux/security.h>
5841  #include <linux/pid_namespace.h>
5842 +#include <linux/vs_base.h>
5843  
5844  int set_task_ioprio(struct task_struct *task, int ioprio)
5845  {
5846 @@ -119,6 +120,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which, 
5847                         else
5848                                 pgrp = find_vpid(who);
5849                         do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
5850 +                               if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5851 +                                       continue;
5852                                 ret = set_task_ioprio(p, ioprio);
5853                                 if (ret)
5854                                         break;
5855 @@ -208,6 +211,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which, 
5856                         else
5857                                 pgrp = find_vpid(who);
5858                         do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
5859 +                               if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5860 +                                       continue;
5861                                 tmpio = get_task_ioprio(p);
5862                                 if (tmpio < 0)
5863                                         continue;
5864 diff -NurpP --minimal linux-3.0.4/fs/jfs/file.c linux-3.0.4-vs2.3.1/fs/jfs/file.c
5865 --- linux-3.0.4/fs/jfs/file.c   2011-07-22 11:18:05.000000000 +0200
5866 +++ linux-3.0.4-vs2.3.1/fs/jfs/file.c   2011-07-01 11:35:34.000000000 +0200
5867 @@ -102,7 +102,8 @@ int jfs_setattr(struct dentry *dentry, s
5868         if (is_quota_modification(inode, iattr))
5869                 dquot_initialize(inode);
5870         if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
5871 -           (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
5872 +           (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
5873 +           (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
5874                 rc = dquot_transfer(inode, iattr);
5875                 if (rc)
5876                         return rc;
5877 @@ -133,6 +134,7 @@ const struct inode_operations jfs_file_i
5878  #ifdef CONFIG_JFS_POSIX_ACL
5879         .check_acl      = jfs_check_acl,
5880  #endif
5881 +       .sync_flags     = jfs_sync_flags,
5882  };
5883  
5884  const struct file_operations jfs_file_operations = {
5885 diff -NurpP --minimal linux-3.0.4/fs/jfs/ioctl.c linux-3.0.4-vs2.3.1/fs/jfs/ioctl.c
5886 --- linux-3.0.4/fs/jfs/ioctl.c  2011-05-22 16:17:52.000000000 +0200
5887 +++ linux-3.0.4-vs2.3.1/fs/jfs/ioctl.c  2011-06-10 22:11:24.000000000 +0200
5888 @@ -11,6 +11,7 @@
5889  #include <linux/mount.h>
5890  #include <linux/time.h>
5891  #include <linux/sched.h>
5892 +#include <linux/mount.h>
5893  #include <asm/current.h>
5894  #include <asm/uaccess.h>
5895  
5896 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
5897  }
5898  
5899  
5900 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
5901 +{
5902 +       inode->i_flags = flags;
5903 +       inode->i_vflags = vflags;
5904 +       jfs_get_inode_flags(JFS_IP(inode));
5905 +       inode->i_ctime = CURRENT_TIME_SEC;
5906 +       mark_inode_dirty(inode);
5907 +       return 0;
5908 +}
5909 +
5910  long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5911  {
5912         struct inode *inode = filp->f_dentry->d_inode;
5913 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
5914                 if (!S_ISDIR(inode->i_mode))
5915                         flags &= ~JFS_DIRSYNC_FL;
5916  
5917 +               if (IS_BARRIER(inode)) {
5918 +                       vxwprintk_task(1, "messing with the barrier.");
5919 +                       return -EACCES;
5920 +               }
5921 +
5922                 /* Is it quota file? Do not allow user to mess with it */
5923                 if (IS_NOQUOTA(inode)) {
5924                         err = -EPERM;
5925 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
5926                  * the relevant capability.
5927                  */
5928                 if ((oldflags & JFS_IMMUTABLE_FL) ||
5929 -                       ((flags ^ oldflags) &
5930 -                       (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
5931 +                       ((flags ^ oldflags) & (JFS_APPEND_FL |
5932 +                       JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
5933                         if (!capable(CAP_LINUX_IMMUTABLE)) {
5934                                 mutex_unlock(&inode->i_mutex);
5935                                 err = -EPERM;
5936 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
5937                         }
5938                 }
5939  
5940 -               flags = flags & JFS_FL_USER_MODIFIABLE;
5941 +               flags &= JFS_FL_USER_MODIFIABLE;
5942                 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
5943                 jfs_inode->mode2 = flags;
5944  
5945 diff -NurpP --minimal linux-3.0.4/fs/jfs/jfs_dinode.h linux-3.0.4-vs2.3.1/fs/jfs/jfs_dinode.h
5946 --- linux-3.0.4/fs/jfs/jfs_dinode.h     2008-12-25 00:26:37.000000000 +0100
5947 +++ linux-3.0.4-vs2.3.1/fs/jfs/jfs_dinode.h     2011-06-10 22:11:24.000000000 +0200
5948 @@ -161,9 +161,13 @@ struct dinode {
5949  
5950  #define JFS_APPEND_FL          0x01000000 /* writes to file may only append */
5951  #define JFS_IMMUTABLE_FL       0x02000000 /* Immutable file */
5952 +#define JFS_IXUNLINK_FL                0x08000000 /* Immutable invert on unlink */
5953  
5954 -#define JFS_FL_USER_VISIBLE    0x03F80000
5955 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
5956 +#define JFS_BARRIER_FL         0x04000000 /* Barrier for chroot() */
5957 +#define JFS_COW_FL             0x20000000 /* Copy on Write marker */
5958 +
5959 +#define JFS_FL_USER_VISIBLE    0x07F80000
5960 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
5961  #define JFS_FL_INHERIT         0x03C80000
5962  
5963  /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
5964 diff -NurpP --minimal linux-3.0.4/fs/jfs/jfs_filsys.h linux-3.0.4-vs2.3.1/fs/jfs/jfs_filsys.h
5965 --- linux-3.0.4/fs/jfs/jfs_filsys.h     2008-12-25 00:26:37.000000000 +0100
5966 +++ linux-3.0.4-vs2.3.1/fs/jfs/jfs_filsys.h     2011-06-10 22:11:24.000000000 +0200
5967 @@ -263,6 +263,7 @@
5968  #define JFS_NAME_MAX   255
5969  #define JFS_PATH_MAX   BPSIZE
5970  
5971 +#define JFS_TAGGED             0x00800000      /* Context Tagging */
5972  
5973  /*
5974   *     file system state (superblock state)
5975 diff -NurpP --minimal linux-3.0.4/fs/jfs/jfs_imap.c linux-3.0.4-vs2.3.1/fs/jfs/jfs_imap.c
5976 --- linux-3.0.4/fs/jfs/jfs_imap.c       2011-07-22 11:18:05.000000000 +0200
5977 +++ linux-3.0.4-vs2.3.1/fs/jfs/jfs_imap.c       2011-07-01 11:35:34.000000000 +0200
5978 @@ -46,6 +46,7 @@
5979  #include <linux/pagemap.h>
5980  #include <linux/quotaops.h>
5981  #include <linux/slab.h>
5982 +#include <linux/vs_tag.h>
5983  
5984  #include "jfs_incore.h"
5985  #include "jfs_inode.h"
5986 @@ -3058,6 +3059,8 @@ static int copy_from_dinode(struct dinod
5987  {
5988         struct jfs_inode_info *jfs_ip = JFS_IP(ip);
5989         struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
5990 +       uid_t uid;
5991 +       gid_t gid;
5992  
5993         jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
5994         jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
5995 @@ -3078,14 +3081,18 @@ static int copy_from_dinode(struct dinod
5996         }
5997         ip->i_nlink = le32_to_cpu(dip->di_nlink);
5998  
5999 -       jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
6000 +       uid = le32_to_cpu(dip->di_uid);
6001 +       gid = le32_to_cpu(dip->di_gid);
6002 +       ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
6003 +
6004 +       jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
6005         if (sbi->uid == -1)
6006                 ip->i_uid = jfs_ip->saved_uid;
6007         else {
6008                 ip->i_uid = sbi->uid;
6009         }
6010  
6011 -       jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
6012 +       jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
6013         if (sbi->gid == -1)
6014                 ip->i_gid = jfs_ip->saved_gid;
6015         else {
6016 @@ -3150,14 +3157,12 @@ static void copy_to_dinode(struct dinode
6017         dip->di_size = cpu_to_le64(ip->i_size);
6018         dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
6019         dip->di_nlink = cpu_to_le32(ip->i_nlink);
6020 -       if (sbi->uid == -1)
6021 -               dip->di_uid = cpu_to_le32(ip->i_uid);
6022 -       else
6023 -               dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
6024 -       if (sbi->gid == -1)
6025 -               dip->di_gid = cpu_to_le32(ip->i_gid);
6026 -       else
6027 -               dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
6028 +
6029 +       dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
6030 +               (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
6031 +       dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
6032 +               (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
6033 +
6034         jfs_get_inode_flags(jfs_ip);
6035         /*
6036          * mode2 is only needed for storing the higher order bits.
6037 diff -NurpP --minimal linux-3.0.4/fs/jfs/jfs_inode.c linux-3.0.4-vs2.3.1/fs/jfs/jfs_inode.c
6038 --- linux-3.0.4/fs/jfs/jfs_inode.c      2010-08-02 16:52:49.000000000 +0200
6039 +++ linux-3.0.4-vs2.3.1/fs/jfs/jfs_inode.c      2011-06-10 22:11:24.000000000 +0200
6040 @@ -18,6 +18,7 @@
6041  
6042  #include <linux/fs.h>
6043  #include <linux/quotaops.h>
6044 +#include <linux/vs_tag.h>
6045  #include "jfs_incore.h"
6046  #include "jfs_inode.h"
6047  #include "jfs_filsys.h"
6048 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
6049  {
6050         unsigned int flags = JFS_IP(inode)->mode2;
6051  
6052 -       inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
6053 -               S_NOATIME | S_DIRSYNC | S_SYNC);
6054 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
6055 +               S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
6056  
6057         if (flags & JFS_IMMUTABLE_FL)
6058                 inode->i_flags |= S_IMMUTABLE;
6059 +       if (flags & JFS_IXUNLINK_FL)
6060 +               inode->i_flags |= S_IXUNLINK;
6061 +
6062 +       if (flags & JFS_SYNC_FL)
6063 +               inode->i_flags |= S_SYNC;
6064         if (flags & JFS_APPEND_FL)
6065                 inode->i_flags |= S_APPEND;
6066         if (flags & JFS_NOATIME_FL)
6067                 inode->i_flags |= S_NOATIME;
6068         if (flags & JFS_DIRSYNC_FL)
6069                 inode->i_flags |= S_DIRSYNC;
6070 -       if (flags & JFS_SYNC_FL)
6071 -               inode->i_flags |= S_SYNC;
6072 +
6073 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
6074 +
6075 +       if (flags & JFS_BARRIER_FL)
6076 +               inode->i_vflags |= V_BARRIER;
6077 +       if (flags & JFS_COW_FL)
6078 +               inode->i_vflags |= V_COW;
6079  }
6080  
6081  void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
6082  {
6083         unsigned int flags = jfs_ip->vfs_inode.i_flags;
6084 +       unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
6085 +
6086 +       jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
6087 +                          JFS_APPEND_FL | JFS_NOATIME_FL |
6088 +                          JFS_DIRSYNC_FL | JFS_SYNC_FL |
6089 +                          JFS_BARRIER_FL | JFS_COW_FL);
6090  
6091 -       jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
6092 -                          JFS_DIRSYNC_FL | JFS_SYNC_FL);
6093         if (flags & S_IMMUTABLE)
6094                 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
6095 +       if (flags & S_IXUNLINK)
6096 +               jfs_ip->mode2 |= JFS_IXUNLINK_FL;
6097 +
6098         if (flags & S_APPEND)
6099                 jfs_ip->mode2 |= JFS_APPEND_FL;
6100         if (flags & S_NOATIME)
6101 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
6102                 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
6103         if (flags & S_SYNC)
6104                 jfs_ip->mode2 |= JFS_SYNC_FL;
6105 +
6106 +       if (vflags & V_BARRIER)
6107 +               jfs_ip->mode2 |= JFS_BARRIER_FL;
6108 +       if (vflags & V_COW)
6109 +               jfs_ip->mode2 |= JFS_COW_FL;
6110  }
6111  
6112  /*
6113 diff -NurpP --minimal linux-3.0.4/fs/jfs/jfs_inode.h linux-3.0.4-vs2.3.1/fs/jfs/jfs_inode.h
6114 --- linux-3.0.4/fs/jfs/jfs_inode.h      2011-07-22 11:18:05.000000000 +0200
6115 +++ linux-3.0.4-vs2.3.1/fs/jfs/jfs_inode.h      2011-06-10 22:11:24.000000000 +0200
6116 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
6117  extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
6118         int fh_len, int fh_type);
6119  extern void jfs_set_inode_flags(struct inode *);
6120 +extern int jfs_sync_flags(struct inode *, int, int);
6121  extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
6122  extern int jfs_setattr(struct dentry *, struct iattr *);
6123  
6124 diff -NurpP --minimal linux-3.0.4/fs/jfs/namei.c linux-3.0.4-vs2.3.1/fs/jfs/namei.c
6125 --- linux-3.0.4/fs/jfs/namei.c  2011-05-22 16:17:53.000000000 +0200
6126 +++ linux-3.0.4-vs2.3.1/fs/jfs/namei.c  2011-06-10 22:11:24.000000000 +0200
6127 @@ -22,6 +22,7 @@
6128  #include <linux/ctype.h>
6129  #include <linux/quotaops.h>
6130  #include <linux/exportfs.h>
6131 +#include <linux/vs_tag.h>
6132  #include "jfs_incore.h"
6133  #include "jfs_superblock.h"
6134  #include "jfs_inode.h"
6135 @@ -1486,6 +1487,7 @@ static struct dentry *jfs_lookup(struct 
6136                 return ERR_CAST(ip);
6137         }
6138  
6139 +       dx_propagate_tag(nd, ip);
6140         return d_splice_alias(ip, dentry);
6141  }
6142  
6143 @@ -1550,6 +1552,7 @@ const struct inode_operations jfs_dir_in
6144  #ifdef CONFIG_JFS_POSIX_ACL
6145         .check_acl      = jfs_check_acl,
6146  #endif
6147 +       .sync_flags     = jfs_sync_flags,
6148  };
6149  
6150  const struct file_operations jfs_dir_operations = {
6151 diff -NurpP --minimal linux-3.0.4/fs/jfs/super.c linux-3.0.4-vs2.3.1/fs/jfs/super.c
6152 --- linux-3.0.4/fs/jfs/super.c  2011-05-22 16:17:53.000000000 +0200
6153 +++ linux-3.0.4-vs2.3.1/fs/jfs/super.c  2011-06-10 22:11:24.000000000 +0200
6154 @@ -198,7 +198,8 @@ static void jfs_put_super(struct super_b
6155  enum {
6156         Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
6157         Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
6158 -       Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
6159 +       Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
6160 +       Opt_tag, Opt_notag, Opt_tagid
6161  };
6162  
6163  static const match_table_t tokens = {
6164 @@ -208,6 +209,10 @@ static const match_table_t tokens = {
6165         {Opt_resize, "resize=%u"},
6166         {Opt_resize_nosize, "resize"},
6167         {Opt_errors, "errors=%s"},
6168 +       {Opt_tag, "tag"},
6169 +       {Opt_notag, "notag"},
6170 +       {Opt_tagid, "tagid=%u"},
6171 +       {Opt_tag, "tagxid"},
6172         {Opt_ignore, "noquota"},
6173         {Opt_ignore, "quota"},
6174         {Opt_usrquota, "usrquota"},
6175 @@ -342,6 +347,20 @@ static int parse_options(char *options, 
6176                         }
6177                         break;
6178                 }
6179 +#ifndef CONFIG_TAGGING_NONE
6180 +               case Opt_tag:
6181 +                       *flag |= JFS_TAGGED;
6182 +                       break;
6183 +               case Opt_notag:
6184 +                       *flag &= JFS_TAGGED;
6185 +                       break;
6186 +#endif
6187 +#ifdef CONFIG_PROPAGATE
6188 +               case Opt_tagid:
6189 +                       /* use args[0] */
6190 +                       *flag |= JFS_TAGGED;
6191 +                       break;
6192 +#endif
6193                 default:
6194                         printk("jfs: Unrecognized mount option \"%s\" "
6195                                         " or missing value\n", p);
6196 @@ -373,6 +392,12 @@ static int jfs_remount(struct super_bloc
6197                 return -EINVAL;
6198         }
6199  
6200 +       if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
6201 +               printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
6202 +                       sb->s_id);
6203 +               return -EINVAL;
6204 +       }
6205 +
6206         if (newLVSize) {
6207                 if (sb->s_flags & MS_RDONLY) {
6208                         printk(KERN_ERR
6209 @@ -455,6 +480,9 @@ static int jfs_fill_super(struct super_b
6210  #ifdef CONFIG_JFS_POSIX_ACL
6211         sb->s_flags |= MS_POSIXACL;
6212  #endif
6213 +       /* map mount option tagxid */
6214 +       if (sbi->flag & JFS_TAGGED)
6215 +               sb->s_flags |= MS_TAGGED;
6216  
6217         if (newLVSize) {
6218                 printk(KERN_ERR "resize option for remount only\n");
6219 diff -NurpP --minimal linux-3.0.4/fs/libfs.c linux-3.0.4-vs2.3.1/fs/libfs.c
6220 --- linux-3.0.4/fs/libfs.c      2011-07-22 11:18:05.000000000 +0200
6221 +++ linux-3.0.4-vs2.3.1/fs/libfs.c      2011-07-22 11:20:39.000000000 +0200
6222 @@ -133,7 +133,8 @@ static inline unsigned char dt_type(stru
6223   * both impossible due to the lock on directory.
6224   */
6225  
6226 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
6227 +static inline int do_dcache_readdir_filter(struct file *filp,
6228 +       void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
6229  {
6230         struct dentry *dentry = filp->f_path.dentry;
6231         struct dentry *cursor = filp->private_data;
6232 @@ -164,6 +165,8 @@ int dcache_readdir(struct file * filp, v
6233                         for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
6234                                 struct dentry *next;
6235                                 next = list_entry(p, struct dentry, d_u.d_child);
6236 +                               if (filter && !filter(next))
6237 +                                       continue;
6238                                 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
6239                                 if (!simple_positive(next)) {
6240                                         spin_unlock(&next->d_lock);
6241 @@ -190,6 +193,17 @@ int dcache_readdir(struct file * filp, v
6242         return 0;
6243  }
6244  
6245 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
6246 +{
6247 +       return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
6248 +}
6249 +
6250 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
6251 +       int (*filter)(struct dentry *))
6252 +{
6253 +       return do_dcache_readdir_filter(filp, dirent, filldir, filter);
6254 +}
6255 +
6256  ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
6257  {
6258         return -EISDIR;
6259 @@ -965,6 +979,7 @@ EXPORT_SYMBOL(dcache_dir_close);
6260  EXPORT_SYMBOL(dcache_dir_lseek);
6261  EXPORT_SYMBOL(dcache_dir_open);
6262  EXPORT_SYMBOL(dcache_readdir);
6263 +EXPORT_SYMBOL(dcache_readdir_filter);
6264  EXPORT_SYMBOL(generic_read_dir);
6265  EXPORT_SYMBOL(mount_pseudo);
6266  EXPORT_SYMBOL(simple_write_begin);
6267 diff -NurpP --minimal linux-3.0.4/fs/locks.c linux-3.0.4-vs2.3.1/fs/locks.c
6268 --- linux-3.0.4/fs/locks.c      2011-07-22 11:18:05.000000000 +0200
6269 +++ linux-3.0.4-vs2.3.1/fs/locks.c      2011-07-19 00:51:58.000000000 +0200
6270 @@ -126,6 +126,8 @@
6271  #include <linux/time.h>
6272  #include <linux/rcupdate.h>
6273  #include <linux/pid_namespace.h>
6274 +#include <linux/vs_base.h>
6275 +#include <linux/vs_limit.h>
6276  
6277  #include <asm/uaccess.h>
6278  
6279 @@ -171,13 +173,19 @@ static void locks_init_lock_always(struc
6280         fl->fl_flags = 0;
6281         fl->fl_type = 0;
6282         fl->fl_start = fl->fl_end = 0;
6283 +       fl->fl_xid = -1;
6284  }
6285  
6286 +
6287  /* Allocate an empty lock structure. */
6288  struct file_lock *locks_alloc_lock(void)
6289  {
6290 -       struct file_lock *fl = kmem_cache_alloc(filelock_cache, GFP_KERNEL);
6291 +       struct file_lock *fl;
6292 +
6293 +       if (!vx_locks_avail(1))
6294 +               return NULL;
6295  
6296 +       fl = kmem_cache_alloc(filelock_cache, GFP_KERNEL);
6297         if (fl)
6298                 locks_init_lock_always(fl);
6299  
6300 @@ -208,6 +216,7 @@ void locks_free_lock(struct file_lock *f
6301         BUG_ON(!list_empty(&fl->fl_block));
6302         BUG_ON(!list_empty(&fl->fl_link));
6303  
6304 +       vx_locks_dec(fl);
6305         locks_release_private(fl);
6306         kmem_cache_free(filelock_cache, fl);
6307  }
6308 @@ -272,6 +281,7 @@ void locks_copy_lock(struct file_lock *n
6309         new->fl_file = fl->fl_file;
6310         new->fl_ops = fl->fl_ops;
6311         new->fl_lmops = fl->fl_lmops;
6312 +       new->fl_xid = fl->fl_xid;
6313  
6314         locks_copy_private(new, fl);
6315  }
6316 @@ -310,6 +320,11 @@ static int flock_make_lock(struct file *
6317         fl->fl_flags = FL_FLOCK;
6318         fl->fl_type = type;
6319         fl->fl_end = OFFSET_MAX;
6320 +
6321 +       vxd_assert(filp->f_xid == vx_current_xid(),
6322 +               "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6323 +       fl->fl_xid = filp->f_xid;
6324 +       vx_locks_inc(fl);
6325         
6326         *lock = fl;
6327         return 0;
6328 @@ -459,6 +474,7 @@ static int lease_init(struct file *filp,
6329  
6330         fl->fl_owner = current->files;
6331         fl->fl_pid = current->tgid;
6332 +       fl->fl_xid = vx_current_xid();
6333  
6334         fl->fl_file = filp;
6335         fl->fl_flags = FL_LEASE;
6336 @@ -478,6 +494,11 @@ static struct file_lock *lease_alloc(str
6337         if (fl == NULL)
6338                 return ERR_PTR(error);
6339  
6340 +       fl->fl_xid = vx_current_xid();
6341 +       if (filp)
6342 +               vxd_assert(filp->f_xid == fl->fl_xid,
6343 +                       "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
6344 +       vx_locks_inc(fl);
6345         error = lease_init(filp, type, fl);
6346         if (error) {
6347                 locks_free_lock(fl);
6348 @@ -779,6 +800,7 @@ static int flock_lock_file(struct file *
6349                 lock_flocks();
6350         }
6351  
6352 +       new_fl->fl_xid = -1;
6353  find_conflict:
6354         for_each_lock(inode, before) {
6355                 struct file_lock *fl = *before;
6356 @@ -799,6 +821,7 @@ find_conflict:
6357                 goto out;
6358         locks_copy_lock(new_fl, request);
6359         locks_insert_lock(before, new_fl);
6360 +       vx_locks_inc(new_fl);
6361         new_fl = NULL;
6362         error = 0;
6363  
6364 @@ -809,7 +832,8 @@ out:
6365         return error;
6366  }
6367  
6368 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
6369 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
6370 +       struct file_lock *conflock, xid_t xid)
6371  {
6372         struct file_lock *fl;
6373         struct file_lock *new_fl = NULL;
6374 @@ -819,6 +843,8 @@ static int __posix_lock_file(struct inod
6375         struct file_lock **before;
6376         int error, added = 0;
6377  
6378 +       vxd_assert(xid == vx_current_xid(),
6379 +               "xid(%d) == current(%d)", xid, vx_current_xid());
6380         /*
6381          * We may need two file_lock structures for this operation,
6382          * so we get them in advance to avoid races.
6383 @@ -829,7 +855,11 @@ static int __posix_lock_file(struct inod
6384             (request->fl_type != F_UNLCK ||
6385              request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
6386                 new_fl = locks_alloc_lock();
6387 +               new_fl->fl_xid = xid;
6388 +               vx_locks_inc(new_fl);
6389                 new_fl2 = locks_alloc_lock();
6390 +               new_fl2->fl_xid = xid;
6391 +               vx_locks_inc(new_fl2);
6392         }
6393  
6394         lock_flocks();
6395 @@ -1028,7 +1058,8 @@ static int __posix_lock_file(struct inod
6396  int posix_lock_file(struct file *filp, struct file_lock *fl,
6397                         struct file_lock *conflock)
6398  {
6399 -       return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
6400 +       return __posix_lock_file(filp->f_path.dentry->d_inode,
6401 +               fl, conflock, filp->f_xid);
6402  }
6403  EXPORT_SYMBOL(posix_lock_file);
6404  
6405 @@ -1118,7 +1149,7 @@ int locks_mandatory_area(int read_write,
6406         fl.fl_end = offset + count - 1;
6407  
6408         for (;;) {
6409 -               error = __posix_lock_file(inode, &fl, NULL);
6410 +               error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
6411                 if (error != FILE_LOCK_DEFERRED)
6412                         break;
6413                 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
6414 @@ -1431,6 +1462,7 @@ int generic_setlease(struct file *filp, 
6415                 goto out;
6416  
6417         locks_insert_lock(before, lease);
6418 +       vx_locks_inc(lease);
6419         return 0;
6420  
6421  out:
6422 @@ -1815,6 +1847,11 @@ int fcntl_setlk(unsigned int fd, struct 
6423         if (file_lock == NULL)
6424                 return -ENOLCK;
6425  
6426 +       vxd_assert(filp->f_xid == vx_current_xid(),
6427 +               "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6428 +       file_lock->fl_xid = filp->f_xid;
6429 +       vx_locks_inc(file_lock);
6430 +
6431         /*
6432          * This might block, so we do it before checking the inode.
6433          */
6434 @@ -1933,6 +1970,11 @@ int fcntl_setlk64(unsigned int fd, struc
6435         if (file_lock == NULL)
6436                 return -ENOLCK;
6437  
6438 +       vxd_assert(filp->f_xid == vx_current_xid(),
6439 +               "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6440 +       file_lock->fl_xid = filp->f_xid;
6441 +       vx_locks_inc(file_lock);
6442 +
6443         /*
6444          * This might block, so we do it before checking the inode.
6445          */
6446 @@ -2198,8 +2240,11 @@ static int locks_show(struct seq_file *f
6447  
6448         lock_get_status(f, fl, *((loff_t *)f->private), "");
6449  
6450 -       list_for_each_entry(bfl, &fl->fl_block, fl_block)
6451 +       list_for_each_entry(bfl, &fl->fl_block, fl_block) {
6452 +               if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
6453 +                       continue;
6454                 lock_get_status(f, bfl, *((loff_t *)f->private), " ->");
6455 +       }
6456  
6457         return 0;
6458  }
6459 diff -NurpP --minimal linux-3.0.4/fs/namei.c linux-3.0.4-vs2.3.1/fs/namei.c
6460 --- linux-3.0.4/fs/namei.c      2011-07-22 11:18:05.000000000 +0200
6461 +++ linux-3.0.4-vs2.3.1/fs/namei.c      2011-10-11 21:13:01.000000000 +0200
6462 @@ -32,6 +32,14 @@
6463  #include <linux/fcntl.h>
6464  #include <linux/device_cgroup.h>
6465  #include <linux/fs_struct.h>
6466 +#include <linux/proc_fs.h>
6467 +#include <linux/vserver/inode.h>
6468 +#include <linux/vs_base.h>
6469 +#include <linux/vs_tag.h>
6470 +#include <linux/vs_cowbl.h>
6471 +#include <linux/vs_device.h>
6472 +#include <linux/vs_context.h>
6473 +#include <linux/pid_namespace.h>
6474  #include <asm/uaccess.h>
6475  
6476  #include "internal.h"
6477 @@ -173,6 +181,84 @@ void putname(const char *name)
6478  EXPORT_SYMBOL(putname);
6479  #endif
6480  
6481 +static inline int dx_barrier(const struct inode *inode)
6482 +{
6483 +       if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
6484 +               vxwprintk_task(1, "did hit the barrier.");
6485 +               return 1;
6486 +       }
6487 +       return 0;
6488 +}
6489 +
6490 +static int __dx_permission(const struct inode *inode, int mask)
6491 +{
6492 +       if (dx_barrier(inode))
6493 +               return -EACCES;
6494 +
6495 +       if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
6496 +               /* devpts is xid tagged */
6497 +               if (S_ISDIR(inode->i_mode) ||
6498 +                   vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
6499 +                       return 0;
6500 +
6501 +               /* just pretend we didn't find anything */
6502 +               return -ENOENT;
6503 +       }
6504 +       else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
6505 +               struct proc_dir_entry *de = PDE(inode);
6506 +
6507 +               if (de && !vx_hide_check(0, de->vx_flags))
6508 +                       goto out;
6509 +
6510 +               if ((mask & (MAY_WRITE | MAY_APPEND))) {
6511 +                       struct pid *pid;
6512 +                       struct task_struct *tsk;
6513 +
6514 +                       if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
6515 +                           vx_flags(VXF_STATE_SETUP, 0))
6516 +                               return 0;
6517 +
6518 +                       pid = PROC_I(inode)->pid;
6519 +                       if (!pid)
6520 +                               goto out;
6521 +
6522 +                       tsk = pid_task(pid, PIDTYPE_PID);
6523 +                       vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
6524 +                                 tsk, (tsk ? vx_task_xid(tsk) : 0));
6525 +                       if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
6526 +                               return 0;
6527 +               }
6528 +               else {
6529 +                       /* FIXME: Should we block some entries here? */
6530 +                       return 0;
6531 +               }
6532 +       }
6533 +       else {
6534 +               if (dx_notagcheck(inode->i_sb) ||
6535 +                   dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
6536 +                            DX_IDENT))
6537 +                       return 0;
6538 +       }
6539 +
6540 +out:
6541 +       return -EACCES;
6542 +}
6543 +
6544 +int dx_permission(const struct inode *inode, int mask)
6545 +{
6546 +       int ret = __dx_permission(inode, mask);
6547 +       if (unlikely(ret)) {
6548 +#ifndef        CONFIG_VSERVER_WARN_DEVPTS
6549 +               if (inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
6550 +#endif
6551 +                   vxwprintk_task(1,
6552 +                       "denied [0x%x] access to inode %s:%p[#%d,%lu]",
6553 +                       mask, inode->i_sb->s_id, inode, inode->i_tag,
6554 +                       inode->i_ino);
6555 +       }
6556 +       return ret;
6557 +}
6558 +
6559  /*
6560   * This does basic POSIX ACL permission checking
6561   */
6562 @@ -283,10 +369,14 @@ int inode_permission(struct inode *inode
6563                 /*
6564                  * Nobody gets write access to an immutable file.
6565                  */
6566 -               if (IS_IMMUTABLE(inode))
6567 +               if (IS_IMMUTABLE(inode) && !IS_COW(inode))
6568                         return -EACCES;
6569         }
6570  
6571 +       retval = dx_permission(inode, mask);
6572 +       if (retval)
6573 +               return retval;
6574 +
6575         if (inode->i_op->permission)
6576                 retval = inode->i_op->permission(inode, mask, 0);
6577         else
6578 @@ -582,6 +672,9 @@ static inline int exec_permission(struct
6579         int ret;
6580         struct user_namespace *ns = inode_userns(inode);
6581  
6582 +       if (dx_barrier(inode))
6583 +               return -EACCES;
6584 +
6585         if (inode->i_op->permission) {
6586                 ret = inode->i_op->permission(inode, MAY_EXEC, flags);
6587         } else {
6588 @@ -1089,7 +1182,8 @@ static void follow_dotdot(struct nameida
6589  
6590                 if (nd->path.dentry == nd->root.dentry &&
6591                     nd->path.mnt == nd->root.mnt) {
6592 -                       break;
6593 +                       /* for sane '/' avoid follow_mount() */
6594 +                       return;
6595                 }
6596                 if (nd->path.dentry != nd->path.mnt->mnt_root) {
6597                         /* rare case of legitimate dget_parent()... */
6598 @@ -1172,6 +1266,9 @@ static int do_lookup(struct nameidata *n
6599                                 goto unlazy;
6600                         }
6601                 }
6602 +
6603 +               /* FIXME: check dx permission */
6604 +
6605                 path->mnt = mnt;
6606                 path->dentry = dentry;
6607                 if (unlikely(!__follow_mount_rcu(nd, path, inode)))
6608 @@ -1220,6 +1317,8 @@ retry:
6609                 }
6610         }
6611  
6612 +       /* FIXME: check dx permission */
6613 +
6614         path->mnt = mnt;
6615         path->dentry = dentry;
6616         err = follow_managed(path, nd->flags);
6617 @@ -1839,7 +1938,7 @@ static int may_delete(struct inode *dir,
6618         if (IS_APPEND(dir))
6619                 return -EPERM;
6620         if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
6621 -           IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
6622 +               IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
6623                 return -EPERM;
6624         if (isdir) {
6625                 if (!S_ISDIR(victim->d_inode->i_mode))
6626 @@ -1966,6 +2065,15 @@ static int may_open(struct path *path, i
6627                 break;
6628         }
6629  
6630 +#ifdef CONFIG_VSERVER_COWBL
6631 +       if (IS_COW(inode) &&
6632 +               ((flag & O_ACCMODE) != O_RDONLY)) {
6633 +               if (IS_COW_LINK(inode))
6634 +                       return -EMLINK;
6635 +               inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
6636 +               mark_inode_dirty(inode);
6637 +       }
6638 +#endif
6639         error = inode_permission(inode, acc_mode);
6640         if (error)
6641                 return error;
6642 @@ -2199,6 +2307,16 @@ ok:
6643         }
6644  common:
6645         error = may_open(&nd->path, acc_mode, open_flag);
6646 +#ifdef CONFIG_VSERVER_COWBL
6647 +       if (error == -EMLINK) {
6648 +               struct dentry *dentry;
6649 +               dentry = cow_break_link(pathname);
6650 +               if (IS_ERR(dentry))
6651 +                       error = PTR_ERR(dentry);
6652 +               else
6653 +                       dput(dentry);
6654 +       }
6655 +#endif
6656         if (error)
6657                 goto exit;
6658         filp = nameidata_to_filp(nd);
6659 @@ -2241,6 +2359,7 @@ static struct file *path_openat(int dfd,
6660         struct path path;
6661         int error;
6662  
6663 +restart:
6664         filp = get_empty_filp();
6665         if (!filp)
6666                 return ERR_PTR(-ENFILE);
6667 @@ -2278,6 +2397,17 @@ static struct file *path_openat(int dfd,
6668                         filp = do_last(nd, &path, op, pathname);
6669                 put_link(nd, &link, cookie);
6670         }
6671 +
6672 +#ifdef CONFIG_VSERVER_COWBL
6673 +       if (filp == ERR_PTR(-EMLINK)) {
6674 +               if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
6675 +                       path_put(&nd->root);
6676 +               if (base)
6677 +                       fput(base);
6678 +               release_open_intent(nd);
6679 +               goto restart;
6680 +       }
6681 +#endif
6682  out:
6683         if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
6684                 path_put(&nd->root);
6685 @@ -2859,7 +2989,7 @@ int vfs_link(struct dentry *old_dentry, 
6686         /*
6687          * A link to an append-only or immutable file cannot be created.
6688          */
6689 -       if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
6690 +       if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
6691                 return -EPERM;
6692         if (!dir->i_op->link)
6693                 return -EPERM;
6694 @@ -3245,6 +3375,220 @@ int vfs_follow_link(struct nameidata *nd
6695         return __vfs_follow_link(nd, link);
6696  }
6697  
6698 +
6699 +#ifdef CONFIG_VSERVER_COWBL
6700 +
6701 +static inline
6702 +long do_cow_splice(struct file *in, struct file *out, size_t len)
6703 +{
6704 +       loff_t ppos = 0;
6705 +
6706 +       return do_splice_direct(in, &ppos, out, len, 0);
6707 +}
6708 +
6709 +struct dentry *cow_break_link(const char *pathname)
6710 +{
6711 +       int ret, mode, pathlen, redo = 0;
6712 +       struct nameidata old_nd, dir_nd;
6713 +       struct path old_path, new_path;
6714 +       struct dentry *dir, *res = NULL;
6715 +       struct file *old_file;
6716 +       struct file *new_file;
6717 +       char *to, *path, pad='\251';
6718 +       loff_t size;
6719 +
6720 +       vxdprintk(VXD_CBIT(misc, 1),
6721 +               "cow_break_link(" VS_Q("%s") ")", pathname);
6722 +       path = kmalloc(PATH_MAX, GFP_KERNEL);
6723 +       ret = -ENOMEM;
6724 +       if (!path)
6725 +               goto out;
6726 +
6727 +       /* old_nd will have refs to dentry and mnt */
6728 +       ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
6729 +       vxdprintk(VXD_CBIT(misc, 2), "do_path_lookup(old): %d", ret);
6730 +       if (ret < 0)
6731 +               goto out_free_path;
6732 +
6733 +       old_path = old_nd.path;
6734 +       mode = old_path.dentry->d_inode->i_mode;
6735 +
6736 +       to = d_path(&old_path, path, PATH_MAX-2);
6737 +       pathlen = strlen(to);
6738 +       vxdprintk(VXD_CBIT(misc, 2),
6739 +               "old path " VS_Q("%s") " [" VS_Q("%.*s") ":%d]", to,
6740 +               old_path.dentry->d_name.len, old_path.dentry->d_name.name,
6741 +               old_path.dentry->d_name.len);
6742 +
6743 +       to[pathlen + 1] = 0;
6744 +retry:
6745 +       to[pathlen] = pad--;
6746 +       ret = -EMLINK;
6747 +       if (pad <= '\240')
6748 +               goto out_rel_old;
6749 +
6750 +       vxdprintk(VXD_CBIT(misc, 1), "temp copy " VS_Q("%s"), to);
6751 +       /* dir_nd will have refs to dentry and mnt */
6752 +       ret = do_path_lookup(AT_FDCWD, to,
6753 +               LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
6754 +       vxdprintk(VXD_CBIT(misc, 2),
6755 +               "do_path_lookup(new): %d", ret);
6756 +       if (ret < 0)
6757 +               goto retry;
6758 +
6759 +       /* this puppy downs the inode mutex */
6760 +       new_path.dentry = lookup_create(&dir_nd, 0);
6761 +       if (!new_path.dentry || IS_ERR(new_path.dentry)) {
6762 +               vxdprintk(VXD_CBIT(misc, 2),
6763 +                       "lookup_create(new): %p", new_path.dentry);
6764 +               mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
6765 +               path_put(&dir_nd.path);
6766 +               goto retry;
6767 +       }
6768 +       vxdprintk(VXD_CBIT(misc, 2),
6769 +               "lookup_create(new): %p [" VS_Q("%.*s") ":%d]",
6770 +               new_path.dentry,
6771 +               new_path.dentry->d_name.len, new_path.dentry->d_name.name,
6772 +               new_path.dentry->d_name.len);
6773 +       dir = dir_nd.path.dentry;
6774 +
6775 +       ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
6776 +       vxdprintk(VXD_CBIT(misc, 2),
6777 +               "vfs_create(new): %d", ret);
6778 +       if (ret == -EEXIST) {
6779 +               mutex_unlock(&dir->d_inode->i_mutex);
6780 +               dput(new_path.dentry);
6781 +               path_put(&dir_nd.path);
6782 +               goto retry;
6783 +       }
6784 +       else if (ret < 0)
6785 +               goto out_unlock_new;
6786 +
6787 +       /* drop out early, ret passes ENOENT */
6788 +       ret = -ENOENT;
6789 +       if ((redo = d_unhashed(old_path.dentry)))
6790 +               goto out_unlock_new;
6791 +
6792 +       new_path.mnt = dir_nd.path.mnt;
6793 +       dget(old_path.dentry);
6794 +       mntget(old_path.mnt);
6795 +       /* this one cleans up the dentry/mnt in case of failure */
6796 +       old_file = dentry_open(old_path.dentry, old_path.mnt,
6797 +               O_RDONLY, current_cred());
6798 +       vxdprintk(VXD_CBIT(misc, 2),
6799 +               "dentry_open(old): %p", old_file);
6800 +       if (!old_file || IS_ERR(old_file)) {
6801 +               res = IS_ERR(old_file) ? (void *) old_file : res;
6802 +               goto out_unlock_new;
6803 +       }
6804 +
6805 +       dget(new_path.dentry);
6806 +       mntget(new_path.mnt);
6807 +       /* this one cleans up the dentry/mnt in case of failure */
6808 +       new_file = dentry_open(new_path.dentry, new_path.mnt,
6809 +               O_WRONLY, current_cred());
6810 +       vxdprintk(VXD_CBIT(misc, 2),
6811 +               "dentry_open(new): %p", new_file);
6812 +
6813 +       ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
6814 +       if (!new_file || IS_ERR(new_file))
6815 +               goto out_fput_old;
6816 +
6817 +       size = i_size_read(old_file->f_dentry->d_inode);
6818 +       ret = do_cow_splice(old_file, new_file, size);
6819 +       vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
6820 +       if (ret < 0) {
6821 +               goto out_fput_both;
6822 +       } else if (ret < size) {
6823 +               ret = -ENOSPC;
6824 +               goto out_fput_both;
6825 +       } else {
6826 +               struct inode *old_inode = old_path.dentry->d_inode;
6827 +               struct inode *new_inode = new_path.dentry->d_inode;
6828 +               struct iattr attr = {
6829 +                       .ia_uid = old_inode->i_uid,
6830 +                       .ia_gid = old_inode->i_gid,
6831 +                       .ia_valid = ATTR_UID | ATTR_GID
6832 +                       };
6833 +
6834 +               setattr_copy(new_inode, &attr);
6835 +               mark_inode_dirty(new_inode);
6836 +       }
6837 +
6838 +       mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
6839 +
6840 +       /* drop out late */
6841 +       ret = -ENOENT;
6842 +       if ((redo = d_unhashed(old_path.dentry)))
6843 +               goto out_unlock;
6844 +
6845 +       vxdprintk(VXD_CBIT(misc, 2),
6846 +               "vfs_rename: [" VS_Q("%*s") ":%d] -> [" VS_Q("%*s") ":%d]",
6847 +               new_path.dentry->d_name.len, new_path.dentry->d_name.name,
6848 +               new_path.dentry->d_name.len,
6849 +               old_path.dentry->d_name.len, old_path.dentry->d_name.name,
6850 +               old_path.dentry->d_name.len);
6851 +       ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
6852 +               old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
6853 +       vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
6854 +       res = new_path.dentry;
6855 +
6856 +out_unlock:
6857 +       mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
6858 +
6859 +out_fput_both:
6860 +       vxdprintk(VXD_CBIT(misc, 3),
6861 +               "fput(new_file=%p[#%ld])", new_file,
6862 +               atomic_long_read(&new_file->f_count));
6863 +       fput(new_file);
6864 +
6865 +out_fput_old:
6866 +       vxdprintk(VXD_CBIT(misc, 3),
6867 +               "fput(old_file=%p[#%ld])", old_file,
6868 +               atomic_long_read(&old_file->f_count));
6869 +       fput(old_file);
6870 +
6871 +out_unlock_new:
6872 +       mutex_unlock(&dir->d_inode->i_mutex);
6873 +       if (!ret)
6874 +               goto out_redo;
6875 +
6876 +       /* error path cleanup */
6877 +       vfs_unlink(dir->d_inode, new_path.dentry);
6878 +       dput(new_path.dentry);
6879 +
6880 +out_redo:
6881 +       if (!redo)
6882 +               goto out_rel_both;
6883 +       /* lookup dentry once again */
6884 +       path_put(&old_nd.path);
6885 +       ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
6886 +       if (ret)
6887 +               goto out_rel_both;
6888 +
6889 +       new_path.dentry = old_nd.path.dentry;
6890 +       vxdprintk(VXD_CBIT(misc, 2),
6891 +               "do_path_lookup(redo): %p [" VS_Q("%.*s") ":%d]",
6892 +               new_path.dentry,
6893 +               new_path.dentry->d_name.len, new_path.dentry->d_name.name,
6894 +               new_path.dentry->d_name.len);
6895 +       dget(new_path.dentry);
6896 +       res = new_path.dentry;
6897 +
6898 +out_rel_both:
6899 +       path_put(&dir_nd.path);
6900 +out_rel_old:
6901 +       path_put(&old_nd.path);
6902 +out_free_path:
6903 +       kfree(path);
6904 +out:
6905 +       if (ret)
6906 +               res = ERR_PTR(ret);
6907 +       return res;
6908 +}
6909 +
6910 +#endif
6911 +
6912  /* get the link contents into pagecache */
6913  static char *page_getlink(struct dentry * dentry, struct page **ppage)
6914  {
6915 diff -NurpP --minimal linux-3.0.4/fs/namespace.c linux-3.0.4-vs2.3.1/fs/namespace.c
6916 --- linux-3.0.4/fs/namespace.c  2011-07-22 11:18:05.000000000 +0200
6917 +++ linux-3.0.4-vs2.3.1/fs/namespace.c  2011-07-23 16:43:31.000000000 +0200
6918 @@ -31,6 +31,11 @@
6919  #include <linux/idr.h>
6920  #include <linux/fs_struct.h>
6921  #include <linux/fsnotify.h>
6922 +#include <linux/vs_base.h>
6923 +#include <linux/vs_context.h>
6924 +#include <linux/vs_tag.h>
6925 +#include <linux/vserver/space.h>
6926 +#include <linux/vserver/global.h>
6927  #include <asm/uaccess.h>
6928  #include <asm/unistd.h>
6929  #include "pnode.h"
6930 @@ -679,6 +684,10 @@ vfs_kern_mount(struct file_system_type *
6931         if (!type)
6932                 return ERR_PTR(-ENODEV);
6933  
6934 +       if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
6935 +               !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
6936 +               return ERR_PTR(-EPERM);
6937 +
6938         mnt = alloc_vfsmnt(name);
6939         if (!mnt)
6940                 return ERR_PTR(-ENOMEM);
6941 @@ -724,6 +733,7 @@ static struct vfsmount *clone_mnt(struct
6942                 mnt->mnt_root = dget(root);
6943                 mnt->mnt_mountpoint = mnt->mnt_root;
6944                 mnt->mnt_parent = mnt;
6945 +               mnt->mnt_tag = old->mnt_tag;
6946  
6947                 if (flag & CL_SLAVE) {
6948                         list_add(&mnt->mnt_slave, &old->mnt_slave_list);
6949 @@ -852,6 +862,31 @@ static inline void mangle(struct seq_fil
6950         seq_escape(m, s, " \t\n\\");
6951  }
6952  
6953 +static int mnt_is_reachable(struct vfsmount *mnt)
6954 +{
6955 +       struct path root;
6956 +       struct dentry *point;
6957 +       int ret;
6958 +
6959 +       if (mnt == mnt->mnt_ns->root)
6960 +               return 1;
6961 +
6962 +       br_read_lock(vfsmount_lock);
6963 +       root = current->fs->root;
6964 +       point = root.dentry;
6965 +
6966 +       while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
6967 +               point = mnt->mnt_mountpoint;
6968 +               mnt = mnt->mnt_parent;
6969 +       }
6970 +
6971 +       ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
6972 +
6973 +       br_read_unlock(vfsmount_lock);
6974 +
6975 +       return ret;
6976 +}
6977 +
6978  /*
6979   * Simple .show_options callback for filesystems which don't want to
6980   * implement more complex mount option showing.
6981 @@ -954,6 +989,8 @@ static int show_sb_opts(struct seq_file 
6982                 { MS_SYNCHRONOUS, ",sync" },
6983                 { MS_DIRSYNC, ",dirsync" },
6984                 { MS_MANDLOCK, ",mand" },
6985 +               { MS_TAGGED, ",tag" },
6986 +               { MS_NOTAGCHECK, ",notagcheck" },
6987                 { 0, NULL }
6988         };
6989         const struct proc_fs_info *fs_infop;
6990 @@ -1000,16 +1037,26 @@ static int show_vfsmnt(struct seq_file *
6991         int err = 0;
6992         struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
6993  
6994 -       if (mnt->mnt_sb->s_op->show_devname) {
6995 -               err = mnt->mnt_sb->s_op->show_devname(m, mnt);
6996 -               if (err)
6997 -                       goto out;
6998 +       if (vx_flags(VXF_HIDE_MOUNT, 0))
6999 +               return SEQ_SKIP;
7000 +       if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
7001 +               return SEQ_SKIP;
7002 +
7003 +       if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
7004 +               mnt == current->fs->root.mnt) {
7005 +               seq_puts(m, "/dev/root / ");
7006         } else {
7007 -               mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
7008 +               if (mnt->mnt_sb->s_op->show_devname) {
7009 +                       err = mnt->mnt_sb->s_op->show_devname(m, mnt);
7010 +                       if (err)
7011 +                               goto out;
7012 +               } else {
7013 +                       mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
7014 +               }
7015 +               seq_putc(m, ' ');
7016 +               seq_path(m, &mnt_path, " \t\n\\");
7017 +               seq_putc(m, ' ');
7018         }
7019 -       seq_putc(m, ' ');
7020 -       seq_path(m, &mnt_path, " \t\n\\");
7021 -       seq_putc(m, ' ');
7022         show_type(m, mnt->mnt_sb);
7023         seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
7024         err = show_sb_opts(m, mnt->mnt_sb);
7025 @@ -1039,6 +1086,11 @@ static int show_mountinfo(struct seq_fil
7026         struct path root = p->root;
7027         int err = 0;
7028  
7029 +       if (vx_flags(VXF_HIDE_MOUNT, 0))
7030 +               return SEQ_SKIP;
7031 +       if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
7032 +               return SEQ_SKIP;
7033 +
7034         seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
7035                    MAJOR(sb->s_dev), MINOR(sb->s_dev));
7036         if (sb->s_op->show_path)
7037 @@ -1107,21 +1159,31 @@ static int show_vfsstat(struct seq_file 
7038         struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
7039         int err = 0;
7040  
7041 -       /* device */
7042 -       if (mnt->mnt_sb->s_op->show_devname) {
7043 -               err = mnt->mnt_sb->s_op->show_devname(m, mnt);
7044 +       if (vx_flags(VXF_HIDE_MOUNT, 0))
7045 +               return SEQ_SKIP;
7046 +       if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
7047 +               return SEQ_SKIP;
7048 +
7049 +       if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
7050 +               mnt == current->fs->root.mnt) {
7051 +               seq_puts(m, "device /dev/root mounted on / ");
7052         } else {
7053 -               if (mnt->mnt_devname) {
7054 -                       seq_puts(m, "device ");
7055 -                       mangle(m, mnt->mnt_devname);
7056 -               } else
7057 -                       seq_puts(m, "no device");
7058 -       }
7059 +               /* device */
7060 +               if (mnt->mnt_sb->s_op->show_devname) {
7061 +                       err = mnt->mnt_sb->s_op->show_devname(m, mnt);
7062 +               } else {
7063 +                       if (mnt->mnt_devname) {
7064 +                               seq_puts(m, "device ");
7065 +                               mangle(m, mnt->mnt_devname);
7066 +                       } else
7067 +                               seq_puts(m, "no device");
7068 +               }
7069  
7070 -       /* mount point */
7071 -       seq_puts(m, " mounted on ");
7072 -       seq_path(m, &mnt_path, " \t\n\\");
7073 -       seq_putc(m, ' ');
7074 +               /* mount point */
7075 +               seq_puts(m, " mounted on ");
7076 +               seq_path(m, &mnt_path, " \t\n\\");
7077 +               seq_putc(m, ' ');
7078 +       }
7079  
7080         /* file system type */
7081         seq_puts(m, "with fstype ");
7082 @@ -1380,7 +1442,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
7083                 goto dput_and_out;
7084  
7085         retval = -EPERM;
7086 -       if (!capable(CAP_SYS_ADMIN))
7087 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7088                 goto dput_and_out;
7089  
7090         retval = do_umount(path.mnt, flags);
7091 @@ -1406,7 +1468,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
7092  
7093  static int mount_is_safe(struct path *path)
7094  {
7095 -       if (capable(CAP_SYS_ADMIN))
7096 +       if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7097                 return 0;
7098         return -EPERM;
7099  #ifdef notyet
7100 @@ -1716,7 +1778,7 @@ static int do_change_type(struct path *p
7101         int type;
7102         int err = 0;
7103  
7104 -       if (!capable(CAP_SYS_ADMIN))
7105 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
7106                 return -EPERM;
7107  
7108         if (path->dentry != path->mnt->mnt_root)
7109 @@ -1732,6 +1794,7 @@ static int do_change_type(struct path *p
7110                 if (err)
7111                         goto out_unlock;
7112         }
7113 +       // mnt->mnt_flags = mnt_flags;
7114  
7115         br_write_lock(vfsmount_lock);
7116         for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
7117 @@ -1747,12 +1810,14 @@ static int do_change_type(struct path *p
7118   * do loopback mount.
7119   */
7120  static int do_loopback(struct path *path, char *old_name,
7121 -                               int recurse)
7122 +       tag_t tag, unsigned long flags, int mnt_flags)
7123  {
7124         LIST_HEAD(umount_list);
7125         struct path old_path;
7126         struct vfsmount *mnt = NULL;
7127         int err = mount_is_safe(path);
7128 +       int recurse = flags & MS_REC;
7129 +
7130         if (err)
7131                 return err;
7132         if (!old_name || !*old_name)
7133 @@ -1818,12 +1883,12 @@ static int change_mount_flags(struct vfs
7134   * on it - tough luck.
7135   */
7136  static int do_remount(struct path *path, int flags, int mnt_flags,
7137 -                     void *data)
7138 +       void *data, xid_t xid)
7139  {
7140         int err;
7141         struct super_block *sb = path->mnt->mnt_sb;
7142  
7143 -       if (!capable(CAP_SYS_ADMIN))
7144 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
7145                 return -EPERM;
7146  
7147         if (!check_mnt(path->mnt))
7148 @@ -1871,7 +1936,7 @@ static int do_move_mount(struct path *pa
7149         struct path old_path, parent_path;
7150         struct vfsmount *p;
7151         int err = 0;
7152 -       if (!capable(CAP_SYS_ADMIN))
7153 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7154                 return -EPERM;
7155         if (!old_name || !*old_name)
7156                 return -EINVAL;
7157 @@ -2022,7 +2087,7 @@ static int do_new_mount(struct path *pat
7158                 return -EINVAL;
7159  
7160         /* we need capabilities... */
7161 -       if (!capable(CAP_SYS_ADMIN))
7162 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7163                 return -EPERM;
7164  
7165         mnt = do_kern_mount(type, flags, name, data);
7166 @@ -2291,6 +2356,7 @@ long do_mount(char *dev_name, char *dir_
7167         struct path path;
7168         int retval = 0;
7169         int mnt_flags = 0;
7170 +       tag_t tag = 0;
7171  
7172         /* Discard magic */
7173         if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
7174 @@ -2318,6 +2384,12 @@ long do_mount(char *dev_name, char *dir_
7175         if (!(flags & MS_NOATIME))
7176                 mnt_flags |= MNT_RELATIME;
7177  
7178 +       if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
7179 +               /* FIXME: bind and re-mounts get the tag flag? */
7180 +               if (flags & (MS_BIND|MS_REMOUNT))
7181 +                       flags |= MS_TAGID;
7182 +       }
7183 +
7184         /* Separate the per-mountpoint flags */
7185         if (flags & MS_NOSUID)
7186                 mnt_flags |= MNT_NOSUID;
7187 @@ -2334,15 +2406,17 @@ long do_mount(char *dev_name, char *dir_
7188         if (flags & MS_RDONLY)
7189                 mnt_flags |= MNT_READONLY;
7190  
7191 +       if (!capable(CAP_SYS_ADMIN))
7192 +               mnt_flags |= MNT_NODEV;
7193         flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
7194                    MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
7195                    MS_STRICTATIME);
7196  
7197         if (flags & MS_REMOUNT)
7198                 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
7199 -                                   data_page);
7200 +                                   data_page, tag);
7201         else if (flags & MS_BIND)
7202 -               retval = do_loopback(&path, dev_name, flags & MS_REC);
7203 +               retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
7204         else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
7205                 retval = do_change_type(&path, flags);
7206         else if (flags & MS_MOVE)
7207 @@ -2442,6 +2516,7 @@ static struct mnt_namespace *dup_mnt_ns(
7208                 q = next_mnt(q, new_ns->root);
7209         }
7210         up_write(&namespace_sem);
7211 +       atomic_inc(&vs_global_mnt_ns);
7212  
7213         if (rootmnt)
7214                 mntput(rootmnt);
7215 @@ -2581,9 +2656,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
7216                 goto out3;
7217  
7218         error = -EINVAL;
7219 -       if (IS_MNT_SHARED(old.mnt) ||
7220 -               IS_MNT_SHARED(new.mnt->mnt_parent) ||
7221 -               IS_MNT_SHARED(root.mnt->mnt_parent))
7222 +       if ((IS_MNT_SHARED(old.mnt) ||
7223 +               IS_MNT_SHARED(new.mnt->mnt_parent) ||
7224 +               IS_MNT_SHARED(root.mnt->mnt_parent)) &&
7225 +               !vx_flags(VXF_STATE_SETUP, 0))
7226                 goto out4;
7227         if (!check_mnt(root.mnt) || !check_mnt(new.mnt))
7228                 goto out4;
7229 @@ -2715,6 +2791,7 @@ void put_mnt_ns(struct mnt_namespace *ns
7230         br_write_unlock(vfsmount_lock);
7231         up_write(&namespace_sem);
7232         release_mounts(&umount_list);
7233 +       atomic_dec(&vs_global_mnt_ns);
7234         kfree(ns);
7235  }
7236  EXPORT_SYMBOL(put_mnt_ns);
7237 diff -NurpP --minimal linux-3.0.4/fs/nfs/client.c linux-3.0.4-vs2.3.1/fs/nfs/client.c
7238 --- linux-3.0.4/fs/nfs/client.c 2011-07-22 11:18:05.000000000 +0200
7239 +++ linux-3.0.4-vs2.3.1/fs/nfs/client.c 2011-06-10 22:11:24.000000000 +0200
7240 @@ -780,6 +780,9 @@ static int nfs_init_server_rpcclient(str
7241         if (server->flags & NFS_MOUNT_SOFT)
7242                 server->client->cl_softrtry = 1;
7243  
7244 +       server->client->cl_tag = 0;
7245 +       if (server->flags & NFS_MOUNT_TAGGED)
7246 +               server->client->cl_tag = 1;
7247         return 0;
7248  }
7249  
7250 @@ -951,6 +954,10 @@ static void nfs_server_set_fsinfo(struct
7251                 server->acdirmin = server->acdirmax = 0;
7252         }
7253  
7254 +       /* FIXME: needs fsinfo
7255 +       if (server->flags & NFS_MOUNT_TAGGED)
7256 +               sb->s_flags |= MS_TAGGED;       */
7257 +
7258         server->maxfilesize = fsinfo->maxfilesize;
7259  
7260         server->time_delta = fsinfo->time_delta;
7261 diff -NurpP --minimal linux-3.0.4/fs/nfs/dir.c linux-3.0.4-vs2.3.1/fs/nfs/dir.c
7262 --- linux-3.0.4/fs/nfs/dir.c    2011-08-31 18:56:42.000000000 +0200
7263 +++ linux-3.0.4-vs2.3.1/fs/nfs/dir.c    2011-08-08 23:04:47.000000000 +0200
7264 @@ -35,6 +35,7 @@
7265  #include <linux/sched.h>
7266  #include <linux/kmemleak.h>
7267  #include <linux/xattr.h>
7268 +#include <linux/vs_tag.h>
7269  
7270  #include "delegation.h"
7271  #include "iostat.h"
7272 @@ -1308,6 +1309,7 @@ static struct dentry *nfs_lookup(struct 
7273         if (IS_ERR(res))
7274                 goto out_unblock_sillyrename;
7275  
7276 +       dx_propagate_tag(nd, inode);
7277  no_entry:
7278         res = d_materialise_unique(dentry, inode);
7279         if (res != NULL) {
7280 diff -NurpP --minimal linux-3.0.4/fs/nfs/inode.c linux-3.0.4-vs2.3.1/fs/nfs/inode.c
7281 --- linux-3.0.4/fs/nfs/inode.c  2011-07-22 11:18:05.000000000 +0200
7282 +++ linux-3.0.4-vs2.3.1/fs/nfs/inode.c  2011-10-11 21:21:33.000000000 +0200
7283 @@ -38,6 +38,7 @@
7284  #include <linux/nfs_xdr.h>
7285  #include <linux/slab.h>
7286  #include <linux/compat.h>
7287 +#include <linux/vs_tag.h>
7288  
7289  #include <asm/system.h>
7290  #include <asm/uaccess.h>
7291 @@ -273,6 +274,8 @@ nfs_fhget(struct super_block *sb, struct
7292         if (inode->i_state & I_NEW) {
7293                 struct nfs_inode *nfsi = NFS_I(inode);
7294                 unsigned long now = jiffies;
7295 +               uid_t uid;
7296 +               gid_t gid;
7297  
7298                 /* We set i_ino for the few things that still rely on it,
7299                  * such as stat(2) */
7300 @@ -321,8 +324,8 @@ nfs_fhget(struct super_block *sb, struct
7301                 nfsi->change_attr = 0;
7302                 inode->i_size = 0;
7303                 inode->i_nlink = 0;
7304 -               inode->i_uid = -2;
7305 -               inode->i_gid = -2;
7306 +               uid = -2;
7307 +               gid = -2;
7308                 inode->i_blocks = 0;
7309                 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
7310  
7311 @@ -359,13 +362,13 @@ nfs_fhget(struct super_block *sb, struct
7312                 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
7313                         nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
7314                 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
7315 -                       inode->i_uid = fattr->uid;
7316 +                       uid = fattr->uid;
7317                 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
7318                         nfsi->cache_validity |= NFS_INO_INVALID_ATTR
7319                                 | NFS_INO_INVALID_ACCESS
7320                                 | NFS_INO_INVALID_ACL;
7321                 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
7322 -                       inode->i_gid = fattr->gid;
7323 +                       gid = fattr->gid;
7324                 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
7325                         nfsi->cache_validity |= NFS_INO_INVALID_ATTR
7326                                 | NFS_INO_INVALID_ACCESS
7327 @@ -378,6 +381,11 @@ nfs_fhget(struct super_block *sb, struct
7328                          */
7329                         inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
7330                 }
7331 +               inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7332 +               inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7333 +               inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7334 +                               /* maybe fattr->xid someday */
7335 +
7336                 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
7337                 nfsi->attrtimeo_timestamp = now;
7338                 nfsi->access_cache = RB_ROOT;
7339 @@ -494,6 +502,8 @@ void nfs_setattr_update_inode(struct ino
7340                         inode->i_uid = attr->ia_uid;
7341                 if ((attr->ia_valid & ATTR_GID) != 0)
7342                         inode->i_gid = attr->ia_gid;
7343 +               if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
7344 +                       inode->i_tag = attr->ia_tag;
7345                 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7346                 spin_unlock(&inode->i_lock);
7347         }
7348 @@ -941,6 +951,9 @@ static int nfs_check_inode_attributes(st
7349         struct nfs_inode *nfsi = NFS_I(inode);
7350         loff_t cur_size, new_isize;
7351         unsigned long invalid = 0;
7352 +       uid_t uid;
7353 +       gid_t gid;
7354 +       tag_t tag;
7355  
7356  
7357         /* Has the inode gone and changed behind our back? */
7358 @@ -964,13 +977,18 @@ static int nfs_check_inode_attributes(st
7359                         invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
7360         }
7361  
7362 +       uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7363 +       gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7364 +       tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7365 +
7366         /* Have any file permissions changed? */
7367         if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
7368                 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7369 -       if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
7370 +       if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
7371                 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7372 -       if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
7373 +       if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
7374                 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7375 +               /* maybe check for tag too? */
7376  
7377         /* Has the link count changed? */
7378         if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
7379 @@ -1205,6 +1223,9 @@ static int nfs_update_inode(struct inode
7380         unsigned long invalid = 0;
7381         unsigned long now = jiffies;
7382         unsigned long save_cache_validity;
7383 +       uid_t uid;
7384 +       gid_t gid;
7385 +       tag_t tag;
7386  
7387         dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
7388                         __func__, inode->i_sb->s_id, inode->i_ino,
7389 @@ -1312,6 +1333,9 @@ static int nfs_update_inode(struct inode
7390                                 | NFS_INO_REVAL_PAGECACHE
7391                                 | NFS_INO_REVAL_FORCED);
7392  
7393 +       uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
7394 +       gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
7395 +       tag = inode->i_tag;
7396  
7397         if (fattr->valid & NFS_ATTR_FATTR_ATIME)
7398                 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
7399 @@ -1333,9 +1357,9 @@ static int nfs_update_inode(struct inode
7400                                 | NFS_INO_REVAL_FORCED);
7401  
7402         if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
7403 -               if (inode->i_uid != fattr->uid) {
7404 +               if (uid != fattr->uid) {
7405                         invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7406 -                       inode->i_uid = fattr->uid;
7407 +                       uid = fattr->uid;
7408                 }
7409         } else if (server->caps & NFS_CAP_OWNER)
7410                 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
7411 @@ -1344,9 +1368,9 @@ static int nfs_update_inode(struct inode
7412                                 | NFS_INO_REVAL_FORCED);
7413  
7414         if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
7415 -               if (inode->i_gid != fattr->gid) {
7416 +               if (gid != fattr->gid) {
7417                         invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7418 -                       inode->i_gid = fattr->gid;
7419 +                       gid = fattr->gid;
7420                 }
7421         } else if (server->caps & NFS_CAP_OWNER_GROUP)
7422                 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
7423 @@ -1354,6 +1378,10 @@ static int nfs_update_inode(struct inode
7424                                 | NFS_INO_INVALID_ACL
7425                                 | NFS_INO_REVAL_FORCED);
7426  
7427 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7428 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7429 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, tag);
7430 +
7431         if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
7432                 if (inode->i_nlink != fattr->nlink) {
7433                         invalid |= NFS_INO_INVALID_ATTR;
7434 diff -NurpP --minimal linux-3.0.4/fs/nfs/nfs3xdr.c linux-3.0.4-vs2.3.1/fs/nfs/nfs3xdr.c
7435 --- linux-3.0.4/fs/nfs/nfs3xdr.c        2011-03-15 18:07:32.000000000 +0100
7436 +++ linux-3.0.4-vs2.3.1/fs/nfs/nfs3xdr.c        2011-06-10 22:11:24.000000000 +0200
7437 @@ -20,6 +20,7 @@
7438  #include <linux/nfs3.h>
7439  #include <linux/nfs_fs.h>
7440  #include <linux/nfsacl.h>
7441 +#include <linux/vs_tag.h>
7442  #include "internal.h"
7443  
7444  #define NFSDBG_FACILITY                NFSDBG_XDR
7445 @@ -562,7 +563,8 @@ static __be32 *xdr_decode_nfstime3(__be3
7446   *             set_mtime       mtime;
7447   *     };
7448   */
7449 -static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
7450 +static void encode_sattr3(struct xdr_stream *xdr,
7451 +       const struct iattr *attr, int tag)
7452  {
7453         u32 nbytes;
7454         __be32 *p;
7455 @@ -594,15 +596,19 @@ static void encode_sattr3(struct xdr_str
7456         } else
7457                 *p++ = xdr_zero;
7458  
7459 -       if (attr->ia_valid & ATTR_UID) {
7460 +       if (attr->ia_valid & ATTR_UID ||
7461 +               (tag && (attr->ia_valid & ATTR_TAG))) {
7462                 *p++ = xdr_one;
7463 -               *p++ = cpu_to_be32(attr->ia_uid);
7464 +               *p++ = cpu_to_be32(TAGINO_UID(tag,
7465 +                       attr->ia_uid, attr->ia_tag));
7466         } else
7467                 *p++ = xdr_zero;
7468  
7469 -       if (attr->ia_valid & ATTR_GID) {
7470 +       if (attr->ia_valid & ATTR_GID ||
7471 +               (tag && (attr->ia_valid & ATTR_TAG))) {
7472                 *p++ = xdr_one;
7473 -               *p++ = cpu_to_be32(attr->ia_gid);
7474 +               *p++ = cpu_to_be32(TAGINO_GID(tag,
7475 +                       attr->ia_gid, attr->ia_tag));
7476         } else
7477                 *p++ = xdr_zero;
7478  
7479 @@ -878,7 +884,7 @@ static void nfs3_xdr_enc_setattr3args(st
7480                                       const struct nfs3_sattrargs *args)
7481  {
7482         encode_nfs_fh3(xdr, args->fh);
7483 -       encode_sattr3(xdr, args->sattr);
7484 +       encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
7485         encode_sattrguard3(xdr, args);
7486  }
7487  
7488 @@ -1028,13 +1034,13 @@ static void nfs3_xdr_enc_write3args(stru
7489   *     };
7490   */
7491  static void encode_createhow3(struct xdr_stream *xdr,
7492 -                             const struct nfs3_createargs *args)
7493 +       const struct nfs3_createargs *args, int tag)
7494  {
7495         encode_uint32(xdr, args->createmode);
7496         switch (args->createmode) {
7497         case NFS3_CREATE_UNCHECKED:
7498         case NFS3_CREATE_GUARDED:
7499 -               encode_sattr3(xdr, args->sattr);
7500 +               encode_sattr3(xdr, args->sattr, tag);
7501                 break;
7502         case NFS3_CREATE_EXCLUSIVE:
7503                 encode_createverf3(xdr, args->verifier);
7504 @@ -1049,7 +1055,7 @@ static void nfs3_xdr_enc_create3args(str
7505                                      const struct nfs3_createargs *args)
7506  {
7507         encode_diropargs3(xdr, args->fh, args->name, args->len);
7508 -       encode_createhow3(xdr, args);
7509 +       encode_createhow3(xdr, args, req->rq_task->tk_client->cl_tag);
7510  }
7511  
7512  /*
7513 @@ -1065,7 +1071,7 @@ static void nfs3_xdr_enc_mkdir3args(stru
7514                                     const struct nfs3_mkdirargs *args)
7515  {
7516         encode_diropargs3(xdr, args->fh, args->name, args->len);
7517 -       encode_sattr3(xdr, args->sattr);
7518 +       encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
7519  }
7520  
7521  /*
7522 @@ -1082,9 +1088,9 @@ static void nfs3_xdr_enc_mkdir3args(stru
7523   *     };
7524   */
7525  static void encode_symlinkdata3(struct xdr_stream *xdr,
7526 -                               const struct nfs3_symlinkargs *args)
7527 +       const struct nfs3_symlinkargs *args, int tag)
7528  {
7529 -       encode_sattr3(xdr, args->sattr);
7530 +       encode_sattr3(xdr, args->sattr, tag);
7531         encode_nfspath3(xdr, args->pages, args->pathlen);
7532  }
7533  
7534 @@ -1093,7 +1099,7 @@ static void nfs3_xdr_enc_symlink3args(st
7535                                       const struct nfs3_symlinkargs *args)
7536  {
7537         encode_diropargs3(xdr, args->fromfh, args->fromname, args->fromlen);
7538 -       encode_symlinkdata3(xdr, args);
7539 +       encode_symlinkdata3(xdr, args, req->rq_task->tk_client->cl_tag);
7540  }
7541  
7542  /*
7543 @@ -1121,24 +1127,24 @@ static void nfs3_xdr_enc_symlink3args(st
7544   *     };
7545   */
7546  static void encode_devicedata3(struct xdr_stream *xdr,
7547 -                              const struct nfs3_mknodargs *args)
7548 +       const struct nfs3_mknodargs *args, int tag)
7549  {
7550 -       encode_sattr3(xdr, args->sattr);
7551 +       encode_sattr3(xdr, args->sattr, tag);
7552         encode_specdata3(xdr, args->rdev);
7553  }
7554  
7555  static void encode_mknoddata3(struct xdr_stream *xdr,
7556 -                             const struct nfs3_mknodargs *args)
7557 +       const struct nfs3_mknodargs *args, int tag)
7558  {
7559         encode_ftype3(xdr, args->type);
7560         switch (args->type) {
7561         case NF3CHR:
7562         case NF3BLK:
7563 -               encode_devicedata3(xdr, args);
7564 +               encode_devicedata3(xdr, args, tag);
7565                 break;
7566         case NF3SOCK:
7567         case NF3FIFO:
7568 -               encode_sattr3(xdr, args->sattr);
7569 +               encode_sattr3(xdr, args->sattr, tag);
7570                 break;
7571         case NF3REG:
7572         case NF3DIR:
7573 @@ -1153,7 +1159,7 @@ static void nfs3_xdr_enc_mknod3args(stru
7574                                     const struct nfs3_mknodargs *args)
7575  {
7576         encode_diropargs3(xdr, args->fh, args->name, args->len);
7577 -       encode_mknoddata3(xdr, args);
7578 +       encode_mknoddata3(xdr, args, req->rq_task->tk_client->cl_tag);
7579  }
7580  
7581  /*
7582 diff -NurpP --minimal linux-3.0.4/fs/nfs/super.c linux-3.0.4-vs2.3.1/fs/nfs/super.c
7583 --- linux-3.0.4/fs/nfs/super.c  2011-07-22 11:18:05.000000000 +0200
7584 +++ linux-3.0.4-vs2.3.1/fs/nfs/super.c  2011-06-10 22:11:24.000000000 +0200
7585 @@ -53,6 +53,7 @@
7586  #include <linux/nfs_xdr.h>
7587  #include <linux/magic.h>
7588  #include <linux/parser.h>
7589 +#include <linux/vs_tag.h>
7590  
7591  #include <asm/system.h>
7592  #include <asm/uaccess.h>
7593 @@ -87,6 +88,7 @@ enum {
7594         Opt_sharecache, Opt_nosharecache,
7595         Opt_resvport, Opt_noresvport,
7596         Opt_fscache, Opt_nofscache,
7597 +       Opt_tag, Opt_notag,
7598  
7599         /* Mount options that take integer arguments */
7600         Opt_port,
7601 @@ -100,6 +102,7 @@ enum {
7602         Opt_mountvers,
7603         Opt_nfsvers,
7604         Opt_minorversion,
7605 +       Opt_tagid,
7606  
7607         /* Mount options that take string arguments */
7608         Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost,
7609 @@ -180,6 +183,10 @@ static const match_table_t nfs_mount_opt
7610         { Opt_fscache_uniq, "fsc=%s" },
7611         { Opt_local_lock, "local_lock=%s" },
7612  
7613 +       { Opt_tag, "tag" },
7614 +       { Opt_notag, "notag" },
7615 +       { Opt_tagid, "tagid=%u" },
7616 +
7617         { Opt_err, NULL }
7618  };
7619  
7620 @@ -650,6 +657,7 @@ static void nfs_show_mount_options(struc
7621                 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
7622                 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
7623                 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
7624 +               { NFS_MOUNT_TAGGED, ",tag", "" },
7625                 { 0, NULL, NULL }
7626         };
7627         const struct proc_nfs_info *nfs_infop;
7628 @@ -1198,6 +1206,14 @@ static int nfs_parse_mount_options(char 
7629                         kfree(mnt->fscache_uniq);
7630                         mnt->fscache_uniq = NULL;
7631                         break;
7632 +#ifndef CONFIG_TAGGING_NONE
7633 +               case Opt_tag:
7634 +                       mnt->flags |= NFS_MOUNT_TAGGED;
7635 +                       break;
7636 +               case Opt_notag:
7637 +                       mnt->flags &= ~NFS_MOUNT_TAGGED;
7638 +                       break;
7639 +#endif
7640  
7641                 /*
7642                  * options that take numeric values
7643 @@ -1304,6 +1320,12 @@ static int nfs_parse_mount_options(char 
7644                                 goto out_invalid_value;
7645                         mnt->minorversion = option;
7646                         break;
7647 +#ifdef CONFIG_PROPAGATE
7648 +               case Opt_tagid:
7649 +                       /* use args[0] */
7650 +                       nfs_data.flags |= NFS_MOUNT_TAGGED;
7651 +                       break;
7652 +#endif
7653  
7654                 /*
7655                  * options that take text values
7656 diff -NurpP --minimal linux-3.0.4/fs/nfsd/auth.c linux-3.0.4-vs2.3.1/fs/nfsd/auth.c
7657 --- linux-3.0.4/fs/nfsd/auth.c  2010-02-25 11:52:05.000000000 +0100
7658 +++ linux-3.0.4-vs2.3.1/fs/nfsd/auth.c  2011-06-10 22:11:24.000000000 +0200
7659 @@ -1,6 +1,7 @@
7660  /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
7661  
7662  #include <linux/sched.h>
7663 +#include <linux/vs_tag.h>
7664  #include "nfsd.h"
7665  #include "auth.h"
7666  
7667 @@ -36,6 +37,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
7668  
7669         new->fsuid = rqstp->rq_cred.cr_uid;
7670         new->fsgid = rqstp->rq_cred.cr_gid;
7671 +       /* FIXME: this desperately needs a tag :)
7672 +       new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
7673 +                       */
7674  
7675         rqgi = rqstp->rq_cred.cr_group_info;
7676  
7677 diff -NurpP --minimal linux-3.0.4/fs/nfsd/nfs3xdr.c linux-3.0.4-vs2.3.1/fs/nfsd/nfs3xdr.c
7678 --- linux-3.0.4/fs/nfsd/nfs3xdr.c       2011-07-22 11:18:05.000000000 +0200
7679 +++ linux-3.0.4-vs2.3.1/fs/nfsd/nfs3xdr.c       2011-06-10 22:11:24.000000000 +0200
7680 @@ -7,6 +7,7 @@
7681   */
7682  
7683  #include <linux/namei.h>
7684 +#include <linux/vs_tag.h>
7685  #include "xdr3.h"
7686  #include "auth.h"
7687  
7688 @@ -95,6 +96,8 @@ static __be32 *
7689  decode_sattr3(__be32 *p, struct iattr *iap)
7690  {
7691         u32     tmp;
7692 +       uid_t   uid = 0;
7693 +       gid_t   gid = 0;
7694  
7695         iap->ia_valid = 0;
7696  
7697 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
7698         }
7699         if (*p++) {
7700                 iap->ia_valid |= ATTR_UID;
7701 -               iap->ia_uid = ntohl(*p++);
7702 +               uid = ntohl(*p++);
7703         }
7704         if (*p++) {
7705                 iap->ia_valid |= ATTR_GID;
7706 -               iap->ia_gid = ntohl(*p++);
7707 +               gid = ntohl(*p++);
7708         }
7709 +       iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7710 +       iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7711 +       iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7712         if (*p++) {
7713                 u64     newsize;
7714  
7715 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
7716         *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
7717         *p++ = htonl((u32) stat->mode);
7718         *p++ = htonl((u32) stat->nlink);
7719 -       *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7720 -       *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7721 +       *p++ = htonl((u32) nfsd_ruid(rqstp,
7722 +               TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
7723 +               stat->uid, stat->tag)));
7724 +       *p++ = htonl((u32) nfsd_rgid(rqstp,
7725 +               TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
7726 +               stat->gid, stat->tag)));
7727         if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
7728                 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
7729         } else {
7730 diff -NurpP --minimal linux-3.0.4/fs/nfsd/nfs4xdr.c linux-3.0.4-vs2.3.1/fs/nfsd/nfs4xdr.c
7731 --- linux-3.0.4/fs/nfsd/nfs4xdr.c       2011-07-22 11:18:05.000000000 +0200
7732 +++ linux-3.0.4-vs2.3.1/fs/nfsd/nfs4xdr.c       2011-06-10 22:11:24.000000000 +0200
7733 @@ -45,6 +45,7 @@
7734  #include <linux/statfs.h>
7735  #include <linux/utsname.h>
7736  #include <linux/sunrpc/svcauth_gss.h>
7737 +#include <linux/vs_tag.h>
7738  
7739  #include "idmap.h"
7740  #include "acl.h"
7741 @@ -2090,14 +2091,18 @@ out_acl:
7742                 WRITE32(stat.nlink);
7743         }
7744         if (bmval1 & FATTR4_WORD1_OWNER) {
7745 -               status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
7746 +               status = nfsd4_encode_user(rqstp,
7747 +                       TAGINO_UID(DX_TAG(dentry->d_inode),
7748 +                       stat.uid, stat.tag), &p, &buflen);
7749                 if (status == nfserr_resource)
7750                         goto out_resource;
7751                 if (status)
7752                         goto out;
7753         }
7754         if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
7755 -               status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
7756 +               status = nfsd4_encode_group(rqstp,
7757 +                       TAGINO_GID(DX_TAG(dentry->d_inode),
7758 +                       stat.gid, stat.tag), &p, &buflen);
7759                 if (status == nfserr_resource)
7760                         goto out_resource;
7761                 if (status)
7762 diff -NurpP --minimal linux-3.0.4/fs/nfsd/nfsxdr.c linux-3.0.4-vs2.3.1/fs/nfsd/nfsxdr.c
7763 --- linux-3.0.4/fs/nfsd/nfsxdr.c        2011-05-22 16:17:53.000000000 +0200
7764 +++ linux-3.0.4-vs2.3.1/fs/nfsd/nfsxdr.c        2011-06-10 22:11:24.000000000 +0200
7765 @@ -6,6 +6,7 @@
7766  
7767  #include "xdr.h"
7768  #include "auth.h"
7769 +#include <linux/vs_tag.h>
7770  
7771  #define NFSDDBG_FACILITY               NFSDDBG_XDR
7772  
7773 @@ -88,6 +89,8 @@ static __be32 *
7774  decode_sattr(__be32 *p, struct iattr *iap)
7775  {
7776         u32     tmp, tmp1;
7777 +       uid_t   uid = 0;
7778 +       gid_t   gid = 0;
7779  
7780         iap->ia_valid = 0;
7781  
7782 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
7783         }
7784         if ((tmp = ntohl(*p++)) != (u32)-1) {
7785                 iap->ia_valid |= ATTR_UID;
7786 -               iap->ia_uid = tmp;
7787 +               uid = tmp;
7788         }
7789         if ((tmp = ntohl(*p++)) != (u32)-1) {
7790                 iap->ia_valid |= ATTR_GID;
7791 -               iap->ia_gid = tmp;
7792 +               gid = tmp;
7793         }
7794 +       iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7795 +       iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7796 +       iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7797         if ((tmp = ntohl(*p++)) != (u32)-1) {
7798                 iap->ia_valid |= ATTR_SIZE;
7799                 iap->ia_size = tmp;
7800 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
7801         *p++ = htonl(nfs_ftypes[type >> 12]);
7802         *p++ = htonl((u32) stat->mode);
7803         *p++ = htonl((u32) stat->nlink);
7804 -       *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7805 -       *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7806 +       *p++ = htonl((u32) nfsd_ruid(rqstp,
7807 +               TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
7808 +       *p++ = htonl((u32) nfsd_rgid(rqstp,
7809 +               TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
7810  
7811         if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
7812                 *p++ = htonl(NFS_MAXPATHLEN);
7813 diff -NurpP --minimal linux-3.0.4/fs/ocfs2/dlmglue.c linux-3.0.4-vs2.3.1/fs/ocfs2/dlmglue.c
7814 --- linux-3.0.4/fs/ocfs2/dlmglue.c      2011-05-22 16:17:53.000000000 +0200
7815 +++ linux-3.0.4-vs2.3.1/fs/ocfs2/dlmglue.c      2011-06-10 22:11:24.000000000 +0200
7816 @@ -2041,6 +2041,7 @@ static void __ocfs2_stuff_meta_lvb(struc
7817         lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
7818         lvb->lvb_iuid      = cpu_to_be32(inode->i_uid);
7819         lvb->lvb_igid      = cpu_to_be32(inode->i_gid);
7820 +       lvb->lvb_itag      = cpu_to_be16(inode->i_tag);
7821         lvb->lvb_imode     = cpu_to_be16(inode->i_mode);
7822         lvb->lvb_inlink    = cpu_to_be16(inode->i_nlink);
7823         lvb->lvb_iatime_packed  =
7824 @@ -2091,6 +2092,7 @@ static void ocfs2_refresh_inode_from_lvb
7825  
7826         inode->i_uid     = be32_to_cpu(lvb->lvb_iuid);
7827         inode->i_gid     = be32_to_cpu(lvb->lvb_igid);
7828 +       inode->i_tag     = be16_to_cpu(lvb->lvb_itag);
7829         inode->i_mode    = be16_to_cpu(lvb->lvb_imode);
7830         inode->i_nlink   = be16_to_cpu(lvb->lvb_inlink);
7831         ocfs2_unpack_timespec(&inode->i_atime,
7832 diff -NurpP --minimal linux-3.0.4/fs/ocfs2/dlmglue.h linux-3.0.4-vs2.3.1/fs/ocfs2/dlmglue.h
7833 --- linux-3.0.4/fs/ocfs2/dlmglue.h      2010-10-21 13:07:50.000000000 +0200
7834 +++ linux-3.0.4-vs2.3.1/fs/ocfs2/dlmglue.h      2011-06-10 22:11:24.000000000 +0200
7835 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
7836         __be16       lvb_inlink;
7837         __be32       lvb_iattr;
7838         __be32       lvb_igeneration;
7839 -       __be32       lvb_reserved2;
7840 +       __be16       lvb_itag;
7841 +       __be16       lvb_reserved2;
7842  };
7843  
7844  #define OCFS2_QINFO_LVB_VERSION 1
7845 diff -NurpP --minimal linux-3.0.4/fs/ocfs2/file.c linux-3.0.4-vs2.3.1/fs/ocfs2/file.c
7846 --- linux-3.0.4/fs/ocfs2/file.c 2011-07-22 11:18:06.000000000 +0200
7847 +++ linux-3.0.4-vs2.3.1/fs/ocfs2/file.c 2011-06-10 22:43:33.000000000 +0200
7848 @@ -1111,7 +1111,7 @@ int ocfs2_setattr(struct dentry *dentry,
7849                 attr->ia_valid &= ~ATTR_SIZE;
7850  
7851  #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
7852 -                          | ATTR_GID | ATTR_UID | ATTR_MODE)
7853 +                          | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
7854         if (!(attr->ia_valid & OCFS2_VALID_ATTRS))
7855                 return 0;
7856  
7857 diff -NurpP --minimal linux-3.0.4/fs/ocfs2/inode.c linux-3.0.4-vs2.3.1/fs/ocfs2/inode.c
7858 --- linux-3.0.4/fs/ocfs2/inode.c        2011-05-22 16:17:53.000000000 +0200
7859 +++ linux-3.0.4-vs2.3.1/fs/ocfs2/inode.c        2011-06-10 22:11:24.000000000 +0200
7860 @@ -28,6 +28,7 @@
7861  #include <linux/highmem.h>
7862  #include <linux/pagemap.h>
7863  #include <linux/quotaops.h>
7864 +#include <linux/vs_tag.h>
7865  
7866  #include <asm/byteorder.h>
7867  
7868 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode 
7869  {
7870         unsigned int flags = OCFS2_I(inode)->ip_attr;
7871  
7872 -       inode->i_flags &= ~(S_IMMUTABLE |
7873 +       inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
7874                 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
7875  
7876         if (flags & OCFS2_IMMUTABLE_FL)
7877                 inode->i_flags |= S_IMMUTABLE;
7878 +       if (flags & OCFS2_IXUNLINK_FL)
7879 +               inode->i_flags |= S_IXUNLINK;
7880  
7881         if (flags & OCFS2_SYNC_FL)
7882                 inode->i_flags |= S_SYNC;
7883 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode 
7884                 inode->i_flags |= S_NOATIME;
7885         if (flags & OCFS2_DIRSYNC_FL)
7886                 inode->i_flags |= S_DIRSYNC;
7887 +
7888 +       inode->i_vflags &= ~(V_BARRIER | V_COW);
7889 +
7890 +       if (flags & OCFS2_BARRIER_FL)
7891 +               inode->i_vflags |= V_BARRIER;
7892 +       if (flags & OCFS2_COW_FL)
7893 +               inode->i_vflags |= V_COW;
7894  }
7895  
7896  /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
7897  void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
7898  {
7899         unsigned int flags = oi->vfs_inode.i_flags;
7900 +       unsigned int vflags = oi->vfs_inode.i_vflags;
7901 +
7902 +       oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
7903 +                       OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
7904 +                       OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
7905 +                       OCFS2_BARRIER_FL | OCFS2_COW_FL);
7906 +
7907 +       if (flags & S_IMMUTABLE)
7908 +               oi->ip_attr |= OCFS2_IMMUTABLE_FL;
7909 +       if (flags & S_IXUNLINK)
7910 +               oi->ip_attr |= OCFS2_IXUNLINK_FL;
7911  
7912 -       oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
7913 -                       OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
7914         if (flags & S_SYNC)
7915                 oi->ip_attr |= OCFS2_SYNC_FL;
7916         if (flags & S_APPEND)
7917                 oi->ip_attr |= OCFS2_APPEND_FL;
7918 -       if (flags & S_IMMUTABLE)
7919 -               oi->ip_attr |= OCFS2_IMMUTABLE_FL;
7920         if (flags & S_NOATIME)
7921                 oi->ip_attr |= OCFS2_NOATIME_FL;
7922         if (flags & S_DIRSYNC)
7923                 oi->ip_attr |= OCFS2_DIRSYNC_FL;
7924 +
7925 +       if (vflags & V_BARRIER)
7926 +               oi->ip_attr |= OCFS2_BARRIER_FL;
7927 +       if (vflags & V_COW)
7928 +               oi->ip_attr |= OCFS2_COW_FL;
7929  }
7930  
7931  struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
7932 @@ -241,6 +263,8 @@ void ocfs2_populate_inode(struct inode *
7933         struct super_block *sb;
7934         struct ocfs2_super *osb;
7935         int use_plocks = 1;
7936 +       uid_t uid;
7937 +       gid_t gid;
7938  
7939         sb = inode->i_sb;
7940         osb = OCFS2_SB(sb);
7941 @@ -269,8 +293,12 @@ void ocfs2_populate_inode(struct inode *
7942         inode->i_generation = le32_to_cpu(fe->i_generation);
7943         inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
7944         inode->i_mode = le16_to_cpu(fe->i_mode);
7945 -       inode->i_uid = le32_to_cpu(fe->i_uid);
7946 -       inode->i_gid = le32_to_cpu(fe->i_gid);
7947 +       uid = le32_to_cpu(fe->i_uid);
7948 +       gid = le32_to_cpu(fe->i_gid);
7949 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7950 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7951 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
7952 +               /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
7953  
7954         /* Fast symlinks will have i_size but no allocated clusters. */
7955         if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
7956 diff -NurpP --minimal linux-3.0.4/fs/ocfs2/inode.h linux-3.0.4-vs2.3.1/fs/ocfs2/inode.h
7957 --- linux-3.0.4/fs/ocfs2/inode.h        2011-01-05 21:50:26.000000000 +0100
7958 +++ linux-3.0.4-vs2.3.1/fs/ocfs2/inode.h        2011-06-10 22:11:24.000000000 +0200
7959 @@ -151,6 +151,7 @@ struct buffer_head *ocfs2_bread(struct i
7960  
7961  void ocfs2_set_inode_flags(struct inode *inode);
7962  void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
7963 +int ocfs2_sync_flags(struct inode *inode, int, int);
7964  
7965  static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
7966  {
7967 diff -NurpP --minimal linux-3.0.4/fs/ocfs2/ioctl.c linux-3.0.4-vs2.3.1/fs/ocfs2/ioctl.c
7968 --- linux-3.0.4/fs/ocfs2/ioctl.c        2011-07-22 11:18:06.000000000 +0200
7969 +++ linux-3.0.4-vs2.3.1/fs/ocfs2/ioctl.c        2011-06-10 22:11:24.000000000 +0200
7970 @@ -78,7 +78,41 @@ static int ocfs2_get_inode_attr(struct i
7971         return status;
7972  }
7973  
7974 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
7975 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
7976 +{
7977 +       struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
7978 +       struct buffer_head *bh = NULL;
7979 +       handle_t *handle = NULL;
7980 +       int status;
7981 +
7982 +       status = ocfs2_inode_lock(inode, &bh, 1);
7983 +       if (status < 0) {
7984 +               mlog_errno(status);
7985 +               return status;
7986 +       }
7987 +       handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
7988 +       if (IS_ERR(handle)) {
7989 +               status = PTR_ERR(handle);
7990 +               mlog_errno(status);
7991 +               goto bail_unlock;
7992 +       }
7993 +
7994 +       inode->i_flags = flags;
7995 +       inode->i_vflags = vflags;
7996 +       ocfs2_get_inode_flags(OCFS2_I(inode));
7997 +
7998 +       status = ocfs2_mark_inode_dirty(handle, inode, bh);
7999 +       if (status < 0)
8000 +               mlog_errno(status);
8001 +
8002 +       ocfs2_commit_trans(osb, handle);
8003 +bail_unlock:
8004 +       ocfs2_inode_unlock(inode, 1);
8005 +       brelse(bh);
8006 +       return status;
8007 +}
8008 +
8009 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
8010                                 unsigned mask)
8011  {
8012         struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
8013 @@ -103,6 +137,11 @@ static int ocfs2_set_inode_attr(struct i
8014         if (!S_ISDIR(inode->i_mode))
8015                 flags &= ~OCFS2_DIRSYNC_FL;
8016  
8017 +       if (IS_BARRIER(inode)) {
8018 +               vxwprintk_task(1, "messing with the barrier.");
8019 +               goto bail_unlock;
8020 +       }
8021 +
8022         handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
8023         if (IS_ERR(handle)) {
8024                 status = PTR_ERR(handle);
8025 @@ -880,6 +919,7 @@ bail:
8026         return status;
8027  }
8028  
8029 +
8030  long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
8031  {
8032         struct inode *inode = filp->f_path.dentry->d_inode;
8033 diff -NurpP --minimal linux-3.0.4/fs/ocfs2/namei.c linux-3.0.4-vs2.3.1/fs/ocfs2/namei.c
8034 --- linux-3.0.4/fs/ocfs2/namei.c        2011-05-22 16:17:53.000000000 +0200
8035 +++ linux-3.0.4-vs2.3.1/fs/ocfs2/namei.c        2011-06-10 22:11:24.000000000 +0200
8036 @@ -41,6 +41,7 @@
8037  #include <linux/slab.h>
8038  #include <linux/highmem.h>
8039  #include <linux/quotaops.h>
8040 +#include <linux/vs_tag.h>
8041  
8042  #include <cluster/masklog.h>
8043  
8044 @@ -477,6 +478,7 @@ static int __ocfs2_mknod_locked(struct i
8045         struct ocfs2_dinode *fe = NULL;
8046         struct ocfs2_extent_list *fel;
8047         u16 feat;
8048 +       tag_t tag;
8049  
8050         *new_fe_bh = NULL;
8051  
8052 @@ -514,8 +516,11 @@ static int __ocfs2_mknod_locked(struct i
8053         fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
8054         fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
8055         fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
8056 -       fe->i_uid = cpu_to_le32(inode->i_uid);
8057 -       fe->i_gid = cpu_to_le32(inode->i_gid);
8058 +
8059 +       tag = dx_current_fstag(osb->sb);
8060 +       fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
8061 +       fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
8062 +       inode->i_tag = tag;
8063         fe->i_mode = cpu_to_le16(inode->i_mode);
8064         if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
8065                 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
8066 diff -NurpP --minimal linux-3.0.4/fs/ocfs2/ocfs2.h linux-3.0.4-vs2.3.1/fs/ocfs2/ocfs2.h
8067 --- linux-3.0.4/fs/ocfs2/ocfs2.h        2011-05-22 16:17:53.000000000 +0200
8068 +++ linux-3.0.4-vs2.3.1/fs/ocfs2/ocfs2.h        2011-06-10 22:11:24.000000000 +0200
8069 @@ -272,6 +272,7 @@ enum ocfs2_mount_options
8070                                                      writes */
8071         OCFS2_MOUNT_HB_NONE = 1 << 13, /* No heartbeat */
8072         OCFS2_MOUNT_HB_GLOBAL = 1 << 14, /* Global heartbeat */
8073 +       OCFS2_MOUNT_TAGGED = 1 << 15, /* use tagging */
8074  };
8075  
8076  #define OCFS2_OSB_SOFT_RO                      0x0001
8077 diff -NurpP --minimal linux-3.0.4/fs/ocfs2/ocfs2_fs.h linux-3.0.4-vs2.3.1/fs/ocfs2/ocfs2_fs.h
8078 --- linux-3.0.4/fs/ocfs2/ocfs2_fs.h     2011-05-22 16:17:53.000000000 +0200
8079 +++ linux-3.0.4-vs2.3.1/fs/ocfs2/ocfs2_fs.h     2011-06-10 22:11:24.000000000 +0200
8080 @@ -266,6 +266,11 @@
8081  #define OCFS2_TOPDIR_FL                        FS_TOPDIR_FL    /* Top of directory hierarchies*/
8082  #define OCFS2_RESERVED_FL              FS_RESERVED_FL  /* reserved for ext2 lib */
8083  
8084 +#define OCFS2_IXUNLINK_FL              FS_IXUNLINK_FL  /* Immutable invert on unlink */
8085 +
8086 +#define OCFS2_BARRIER_FL               FS_BARRIER_FL   /* Barrier for chroot() */
8087 +#define OCFS2_COW_FL                   FS_COW_FL       /* Copy on Write marker */
8088 +
8089  #define OCFS2_FL_VISIBLE               FS_FL_USER_VISIBLE      /* User visible flags */
8090  #define OCFS2_FL_MODIFIABLE            FS_FL_USER_MODIFIABLE   /* User modifiable flags */
8091  
8092 diff -NurpP --minimal linux-3.0.4/fs/ocfs2/super.c linux-3.0.4-vs2.3.1/fs/ocfs2/super.c
8093 --- linux-3.0.4/fs/ocfs2/super.c        2011-07-22 11:18:06.000000000 +0200
8094 +++ linux-3.0.4-vs2.3.1/fs/ocfs2/super.c        2011-06-15 02:40:14.000000000 +0200
8095 @@ -184,6 +184,7 @@ enum {
8096         Opt_coherency_full,
8097         Opt_resv_level,
8098         Opt_dir_resv_level,
8099 +       Opt_tag, Opt_notag, Opt_tagid,
8100         Opt_err,
8101  };
8102  
8103 @@ -215,6 +216,9 @@ static const match_table_t tokens = {
8104         {Opt_coherency_full, "coherency=full"},
8105         {Opt_resv_level, "resv_level=%u"},
8106         {Opt_dir_resv_level, "dir_resv_level=%u"},
8107 +       {Opt_tag, "tag"},
8108 +       {Opt_notag, "notag"},
8109 +       {Opt_tagid, "tagid=%u"},
8110         {Opt_err, NULL}
8111  };
8112  
8113 @@ -662,6 +666,13 @@ static int ocfs2_remount(struct super_bl
8114                 goto out;
8115         }
8116  
8117 +       if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
8118 +           (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
8119 +               ret = -EINVAL;
8120 +               mlog(ML_ERROR, "Cannot change tagging on remount\n");
8121 +               goto out;
8122 +       }
8123 +
8124         /* We're going to/from readonly mode. */
8125         if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
8126                 /* Disable quota accounting before remounting RO */
8127 @@ -1177,6 +1188,9 @@ static int ocfs2_fill_super(struct super
8128  
8129         ocfs2_complete_mount_recovery(osb);
8130  
8131 +       if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
8132 +               sb->s_flags |= MS_TAGGED;
8133 +
8134         if (ocfs2_mount_local(osb))
8135                 snprintf(nodestr, sizeof(nodestr), "local");
8136         else
8137 @@ -1506,6 +1520,20 @@ static int ocfs2_parse_options(struct su
8138                             option < OCFS2_MAX_RESV_LEVEL)
8139                                 mopt->dir_resv_level = option;
8140                         break;
8141 +#ifndef CONFIG_TAGGING_NONE
8142 +               case Opt_tag:
8143 +                       mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
8144 +                       break;
8145 +               case Opt_notag:
8146 +                       mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
8147 +                       break;
8148 +#endif
8149 +#ifdef CONFIG_PROPAGATE
8150 +               case Opt_tagid:
8151 +                       /* use args[0] */
8152 +                       mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
8153 +                       break;
8154 +#endif
8155                 default:
8156                         mlog(ML_ERROR,
8157                              "Unrecognized mount option \"%s\" "
8158 diff -NurpP --minimal linux-3.0.4/fs/open.c linux-3.0.4-vs2.3.1/fs/open.c
8159 --- linux-3.0.4/fs/open.c       2011-05-22 16:17:53.000000000 +0200
8160 +++ linux-3.0.4-vs2.3.1/fs/open.c       2011-06-10 22:11:24.000000000 +0200
8161 @@ -30,6 +30,11 @@
8162  #include <linux/fs_struct.h>
8163  #include <linux/ima.h>
8164  #include <linux/dnotify.h>
8165 +#include <linux/vs_base.h>
8166 +#include <linux/vs_limit.h>
8167 +#include <linux/vs_tag.h>
8168 +#include <linux/vs_cowbl.h>
8169 +#include <linux/vserver/dlimit.h>
8170  
8171  #include "internal.h"
8172  
8173 @@ -494,6 +499,12 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
8174         error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
8175         if (error)
8176                 goto out;
8177 +
8178 +#ifdef CONFIG_VSERVER_COWBL
8179 +       error = cow_check_and_break(&path);
8180 +       if (error)
8181 +               goto dput_and_out;
8182 +#endif
8183         inode = path.dentry->d_inode;
8184  
8185         error = mnt_want_write(path.mnt);
8186 @@ -531,11 +542,11 @@ static int chown_common(struct path *pat
8187         newattrs.ia_valid =  ATTR_CTIME;
8188         if (user != (uid_t) -1) {
8189                 newattrs.ia_valid |= ATTR_UID;
8190 -               newattrs.ia_uid = user;
8191 +               newattrs.ia_uid = dx_map_uid(user);
8192         }
8193         if (group != (gid_t) -1) {
8194                 newattrs.ia_valid |= ATTR_GID;
8195 -               newattrs.ia_gid = group;
8196 +               newattrs.ia_gid = dx_map_gid(group);
8197         }
8198         if (!S_ISDIR(inode->i_mode))
8199                 newattrs.ia_valid |=
8200 @@ -560,6 +571,10 @@ SYSCALL_DEFINE3(chown, const char __user
8201         error = mnt_want_write(path.mnt);
8202         if (error)
8203                 goto out_release;
8204 +#ifdef CONFIG_VSERVER_COWBL
8205 +       error = cow_check_and_break(&path);
8206 +       if (!error)
8207 +#endif
8208         error = chown_common(&path, user, group);
8209         mnt_drop_write(path.mnt);
8210  out_release:
8211 @@ -587,6 +602,10 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
8212         error = mnt_want_write(path.mnt);
8213         if (error)
8214                 goto out_release;
8215 +#ifdef CONFIG_VSERVER_COWBL
8216 +       error = cow_check_and_break(&path);
8217 +       if (!error)
8218 +#endif
8219         error = chown_common(&path, user, group);
8220         mnt_drop_write(path.mnt);
8221  out_release:
8222 @@ -606,6 +625,10 @@ SYSCALL_DEFINE3(lchown, const char __use
8223         error = mnt_want_write(path.mnt);
8224         if (error)
8225                 goto out_release;
8226 +#ifdef CONFIG_VSERVER_COWBL
8227 +       error = cow_check_and_break(&path);
8228 +       if (!error)
8229 +#endif
8230         error = chown_common(&path, user, group);
8231         mnt_drop_write(path.mnt);
8232  out_release:
8233 @@ -857,6 +880,7 @@ static void __put_unused_fd(struct files
8234         __FD_CLR(fd, fdt->open_fds);
8235         if (fd < files->next_fd)
8236                 files->next_fd = fd;
8237 +       vx_openfd_dec(fd);
8238  }
8239  
8240  void put_unused_fd(unsigned int fd)
8241 diff -NurpP --minimal linux-3.0.4/fs/proc/array.c linux-3.0.4-vs2.3.1/fs/proc/array.c
8242 --- linux-3.0.4/fs/proc/array.c 2011-07-22 11:18:06.000000000 +0200
8243 +++ linux-3.0.4-vs2.3.1/fs/proc/array.c 2011-06-10 22:11:24.000000000 +0200
8244 @@ -81,6 +81,8 @@
8245  #include <linux/pid_namespace.h>
8246  #include <linux/ptrace.h>
8247  #include <linux/tracehook.h>
8248 +#include <linux/vs_context.h>
8249 +#include <linux/vs_network.h>
8250  
8251  #include <asm/pgtable.h>
8252  #include <asm/processor.h>
8253 @@ -170,6 +172,9 @@ static inline void task_state(struct seq
8254         rcu_read_lock();
8255         ppid = pid_alive(p) ?
8256                 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
8257 +       if (unlikely(vx_current_initpid(p->pid)))
8258 +               ppid = 0;
8259 +
8260         tpid = 0;
8261         if (pid_alive(p)) {
8262                 struct task_struct *tracer = tracehook_tracer_task(p);
8263 @@ -287,7 +292,7 @@ static inline void task_sig(struct seq_f
8264  }
8265  
8266  static void render_cap_t(struct seq_file *m, const char *header,
8267 -                       kernel_cap_t *a)
8268 +                       struct vx_info *vxi, kernel_cap_t *a)
8269  {
8270         unsigned __capi;
8271  
8272 @@ -312,10 +317,11 @@ static inline void task_cap(struct seq_f
8273         cap_bset        = cred->cap_bset;
8274         rcu_read_unlock();
8275  
8276 -       render_cap_t(m, "CapInh:\t", &cap_inheritable);
8277 -       render_cap_t(m, "CapPrm:\t", &cap_permitted);
8278 -       render_cap_t(m, "CapEff:\t", &cap_effective);
8279 -       render_cap_t(m, "CapBnd:\t", &cap_bset);
8280 +       /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
8281 +       render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
8282 +       render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
8283 +       render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
8284 +       render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
8285  }
8286  
8287  static inline void task_context_switch_counts(struct seq_file *m,
8288 @@ -337,6 +343,42 @@ static void task_cpus_allowed(struct seq
8289         seq_putc(m, '\n');
8290  }
8291  
8292 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
8293 +                       struct pid *pid, struct task_struct *task)
8294 +{
8295 +       seq_printf(m,   "Proxy:\t%p(%c)\n"
8296 +                       "Count:\t%u\n"
8297 +                       "uts:\t%p(%c)\n"
8298 +                       "ipc:\t%p(%c)\n"
8299 +                       "mnt:\t%p(%c)\n"
8300 +                       "pid:\t%p(%c)\n"
8301 +                       "net:\t%p(%c)\n",
8302 +                       task->nsproxy,
8303 +                       (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
8304 +                       atomic_read(&task->nsproxy->count),
8305 +                       task->nsproxy->uts_ns,
8306 +                       (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
8307 +                       task->nsproxy->ipc_ns,
8308 +                       (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
8309 +                       task->nsproxy->mnt_ns,
8310 +                       (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
8311 +                       task->nsproxy->pid_ns,
8312 +                       (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
8313 +                       task->nsproxy->net_ns,
8314 +                       (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
8315 +       return 0;
8316 +}
8317 +
8318 +void task_vs_id(struct seq_file *m, struct task_struct *task)
8319 +{
8320 +       if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
8321 +               return;
8322 +
8323 +       seq_printf(m, "VxID: %d\n", vx_task_xid(task));
8324 +       seq_printf(m, "NxID: %d\n", nx_task_nid(task));
8325 +}
8326 +
8327 +
8328  int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
8329                         struct pid *pid, struct task_struct *task)
8330  {
8331 @@ -353,6 +395,7 @@ int proc_pid_status(struct seq_file *m, 
8332         task_cap(m, task);
8333         task_cpus_allowed(m, task);
8334         cpuset_task_status_allowed(m, task);
8335 +       task_vs_id(m, task);
8336         task_context_switch_counts(m, task);
8337         return 0;
8338  }
8339 @@ -462,6 +505,17 @@ static int do_task_stat(struct seq_file 
8340         /* convert nsec -> ticks */
8341         start_time = nsec_to_clock_t(start_time);
8342  
8343 +       /* fixup start time for virt uptime */
8344 +       if (vx_flags(VXF_VIRT_UPTIME, 0)) {
8345 +               unsigned long long bias =
8346 +                       current->vx_info->cvirt.bias_clock;
8347 +
8348 +               if (start_time > bias)
8349 +                       start_time -= bias;
8350 +               else
8351 +                       start_time = 0;
8352 +       }
8353 +
8354         seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
8355  %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
8356  %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
8357 diff -NurpP --minimal linux-3.0.4/fs/proc/base.c linux-3.0.4-vs2.3.1/fs/proc/base.c
8358 --- linux-3.0.4/fs/proc/base.c  2011-08-31 18:56:42.000000000 +0200
8359 +++ linux-3.0.4-vs2.3.1/fs/proc/base.c  2011-08-08 23:04:47.000000000 +0200
8360 @@ -83,6 +83,8 @@
8361  #include <linux/pid_namespace.h>
8362  #include <linux/fs_struct.h>
8363  #include <linux/slab.h>
8364 +#include <linux/vs_context.h>
8365 +#include <linux/vs_network.h>
8366  #ifdef CONFIG_HARDWALL
8367  #include <asm/hardwall.h>
8368  #endif
8369 @@ -1102,11 +1104,16 @@ static ssize_t oom_adjust_write(struct f
8370                 goto err_task_lock;
8371         }
8372  
8373 -       if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
8374 +       if (oom_adjust < task->signal->oom_adj &&
8375 +               !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
8376                 err = -EACCES;
8377                 goto err_sighand;
8378         }
8379  
8380 +       /* prevent guest processes from circumventing the oom killer */
8381 +       if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
8382 +               oom_adjust = OOM_ADJUST_MIN;
8383 +
8384         if (oom_adjust != task->signal->oom_adj) {
8385                 if (oom_adjust == OOM_DISABLE)
8386                         atomic_inc(&task->mm->oom_disable_count);
8387 @@ -1275,7 +1282,7 @@ static ssize_t proc_loginuid_write(struc
8388         ssize_t length;
8389         uid_t loginuid;
8390  
8391 -       if (!capable(CAP_AUDIT_CONTROL))
8392 +       if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
8393                 return -EPERM;
8394  
8395         rcu_read_lock();
8396 @@ -1722,6 +1729,8 @@ struct inode *proc_pid_make_inode(struct
8397                 inode->i_gid = cred->egid;
8398                 rcu_read_unlock();
8399         }
8400 +       /* procfs is xid tagged */
8401 +       inode->i_tag = (tag_t)vx_task_xid(task);
8402         security_task_to_inode(task, inode);
8403  
8404  out:
8405 @@ -1758,6 +1767,8 @@ int pid_getattr(struct vfsmount *mnt, st
8406  
8407  /* dentry stuff */
8408  
8409 +static unsigned name_to_int(struct dentry *dentry);
8410 +
8411  /*
8412   *     Exceptional case: normally we are not allowed to unhash a busy
8413   * directory. In this case, however, we can do it - no aliasing problems
8414 @@ -1786,6 +1797,12 @@ int pid_revalidate(struct dentry *dentry
8415         task = get_proc_task(inode);
8416  
8417         if (task) {
8418 +               unsigned pid = name_to_int(dentry);
8419 +
8420 +               if (pid != ~0U && pid != vx_map_pid(task->pid)) {
8421 +                       put_task_struct(task);
8422 +                       goto drop;
8423 +               }
8424                 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
8425                     task_dumpable(task)) {
8426                         rcu_read_lock();
8427 @@ -1802,6 +1819,7 @@ int pid_revalidate(struct dentry *dentry
8428                 put_task_struct(task);
8429                 return 1;
8430         }
8431 +drop:
8432         d_drop(dentry);
8433         return 0;
8434  }
8435 @@ -2283,6 +2301,13 @@ static struct dentry *proc_pident_lookup
8436         if (!task)
8437                 goto out_no_task;
8438  
8439 +       /* TODO: maybe we can come up with a generic approach? */
8440 +       if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
8441 +               (dentry->d_name.len == 5) &&
8442 +               (!memcmp(dentry->d_name.name, "vinfo", 5) ||
8443 +               !memcmp(dentry->d_name.name, "ninfo", 5)))
8444 +               goto out;
8445 +
8446         /*
8447          * Yes, it does not scale. And it should not. Don't add
8448          * new entries into /proc/<tgid>/ without very good reasons.
8449 @@ -2668,7 +2693,7 @@ out_iput:
8450  static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
8451  {
8452         struct dentry *error;
8453 -       struct task_struct *task = get_proc_task(dir);
8454 +       struct task_struct *task = get_proc_task_real(dir);
8455         const struct pid_entry *p, *last;
8456  
8457         error = ERR_PTR(-ENOENT);
8458 @@ -2775,6 +2800,9 @@ static int proc_pid_personality(struct s
8459  static const struct file_operations proc_task_operations;
8460  static const struct inode_operations proc_task_inode_operations;
8461  
8462 +extern int proc_pid_vx_info(struct task_struct *, char *);
8463 +extern int proc_pid_nx_info(struct task_struct *, char *);
8464 +
8465  static const struct pid_entry tgid_base_stuff[] = {
8466         DIR("task",       S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
8467         DIR("fd",         S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
8468 @@ -2838,6 +2866,8 @@ static const struct pid_entry tgid_base_
8469  #ifdef CONFIG_CGROUPS
8470         REG("cgroup",  S_IRUGO, proc_cgroup_operations),
8471  #endif
8472 +       INF("vinfo",      S_IRUGO, proc_pid_vx_info),
8473 +       INF("ninfo",      S_IRUGO, proc_pid_nx_info),
8474         INF("oom_score",  S_IRUGO, proc_oom_score),
8475         REG("oom_adj",    S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
8476         REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
8477 @@ -2857,6 +2887,7 @@ static const struct pid_entry tgid_base_
8478  #ifdef CONFIG_HARDWALL
8479         INF("hardwall",   S_IRUGO, proc_pid_hardwall),
8480  #endif
8481 +       ONE("nsproxy",  S_IRUGO, proc_pid_nsproxy),
8482  };
8483  
8484  static int proc_tgid_base_readdir(struct file * filp,
8485 @@ -3049,7 +3080,7 @@ retry:
8486         iter.task = NULL;
8487         pid = find_ge_pid(iter.tgid, ns);
8488         if (pid) {
8489 -               iter.tgid = pid_nr_ns(pid, ns);
8490 +               iter.tgid = pid_unmapped_nr_ns(pid, ns);
8491                 iter.task = pid_task(pid, PIDTYPE_PID);
8492                 /* What we to know is if the pid we have find is the
8493                  * pid of a thread_group_leader.  Testing for task
8494 @@ -3079,7 +3110,7 @@ static int proc_pid_fill_cache(struct fi
8495         struct tgid_iter iter)
8496  {
8497         char name[PROC_NUMBUF];
8498 -       int len = snprintf(name, sizeof(name), "%d", iter.tgid);
8499 +       int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
8500         return proc_fill_cache(filp, dirent, filldir, name, len,
8501                                 proc_pid_instantiate, iter.task, NULL);
8502  }
8503 @@ -3096,7 +3127,7 @@ int proc_pid_readdir(struct file * filp,
8504                 goto out_no_task;
8505         nr = filp->f_pos - FIRST_PROCESS_ENTRY;
8506  
8507 -       reaper = get_proc_task(filp->f_path.dentry->d_inode);
8508 +       reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
8509         if (!reaper)
8510                 goto out_no_task;
8511  
8512 @@ -3113,6 +3144,8 @@ int proc_pid_readdir(struct file * filp,
8513              iter.task;
8514              iter.tgid += 1, iter = next_tgid(ns, iter)) {
8515                 filp->f_pos = iter.tgid + TGID_OFFSET;
8516 +               if (!vx_proc_task_visible(iter.task))
8517 +                       continue;
8518                 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
8519                         put_task_struct(iter.task);
8520                         goto out;
8521 @@ -3266,6 +3299,8 @@ static struct dentry *proc_task_lookup(s
8522         tid = name_to_int(dentry);
8523         if (tid == ~0U)
8524                 goto out;
8525 +       if (vx_current_initpid(tid))
8526 +               goto out;
8527  
8528         ns = dentry->d_sb->s_fs_info;
8529         rcu_read_lock();
8530 diff -NurpP --minimal linux-3.0.4/fs/proc/generic.c linux-3.0.4-vs2.3.1/fs/proc/generic.c
8531 --- linux-3.0.4/fs/proc/generic.c       2011-07-22 11:18:06.000000000 +0200
8532 +++ linux-3.0.4-vs2.3.1/fs/proc/generic.c       2011-06-10 22:11:24.000000000 +0200
8533 @@ -22,6 +22,7 @@
8534  #include <linux/bitops.h>
8535  #include <linux/spinlock.h>
8536  #include <linux/completion.h>
8537 +#include <linux/vserver/inode.h>
8538  #include <asm/uaccess.h>
8539  
8540  #include "internal.h"
8541 @@ -424,11 +425,15 @@ struct dentry *proc_lookup_de(struct pro
8542         for (de = de->subdir; de ; de = de->next) {
8543                 if (de->namelen != dentry->d_name.len)
8544                         continue;
8545 +               if (!vx_hide_check(0, de->vx_flags))
8546 +                       continue;
8547                 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
8548                         pde_get(de);
8549                         spin_unlock(&proc_subdir_lock);
8550                         error = -EINVAL;
8551                         inode = proc_get_inode(dir->i_sb, de);
8552 +                       /* generic proc entries belong to the host */
8553 +                       inode->i_tag = 0;
8554                         goto out_unlock;
8555                 }
8556         }
8557 @@ -506,6 +511,8 @@ int proc_readdir_de(struct proc_dir_entr
8558  
8559                                 /* filldir passes info to user space */
8560                                 pde_get(de);
8561 +                               if (!vx_hide_check(0, de->vx_flags))
8562 +                                       goto skip;
8563                                 spin_unlock(&proc_subdir_lock);
8564                                 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
8565                                             de->low_ino, de->mode >> 12) < 0) {
8566 @@ -513,6 +520,7 @@ int proc_readdir_de(struct proc_dir_entr
8567                                         goto out;
8568                                 }
8569                                 spin_lock(&proc_subdir_lock);
8570 +                       skip:
8571                                 filp->f_pos++;
8572                                 next = de->next;
8573                                 pde_put(de);
8574 @@ -627,6 +635,7 @@ static struct proc_dir_entry *__proc_cre
8575         ent->nlink = nlink;
8576         atomic_set(&ent->count, 1);
8577         ent->pde_users = 0;
8578 +       ent->vx_flags = IATTR_PROC_DEFAULT;
8579         spin_lock_init(&ent->pde_unload_lock);
8580         ent->pde_unload_completion = NULL;
8581         INIT_LIST_HEAD(&ent->pde_openers);
8582 @@ -650,7 +659,8 @@ struct proc_dir_entry *proc_symlink(cons
8583                                 kfree(ent->data);
8584                                 kfree(ent);
8585                                 ent = NULL;
8586 -                       }
8587 +                       } else
8588 +                               ent->vx_flags = IATTR_PROC_SYMLINK;
8589                 } else {
8590                         kfree(ent);
8591                         ent = NULL;
8592 diff -NurpP --minimal linux-3.0.4/fs/proc/inode.c linux-3.0.4-vs2.3.1/fs/proc/inode.c
8593 --- linux-3.0.4/fs/proc/inode.c 2011-07-22 11:18:06.000000000 +0200
8594 +++ linux-3.0.4-vs2.3.1/fs/proc/inode.c 2011-06-10 22:11:24.000000000 +0200
8595 @@ -442,6 +442,8 @@ struct inode *proc_get_inode(struct supe
8596                         inode->i_uid = de->uid;
8597                         inode->i_gid = de->gid;
8598                 }
8599 +               if (de->vx_flags)
8600 +                       PROC_I(inode)->vx_flags = de->vx_flags;
8601                 if (de->size)
8602                         inode->i_size = de->size;
8603                 if (de->nlink)
8604 diff -NurpP --minimal linux-3.0.4/fs/proc/internal.h linux-3.0.4-vs2.3.1/fs/proc/internal.h
8605 --- linux-3.0.4/fs/proc/internal.h      2011-07-22 11:18:06.000000000 +0200
8606 +++ linux-3.0.4-vs2.3.1/fs/proc/internal.h      2011-06-10 22:11:24.000000000 +0200
8607 @@ -10,6 +10,7 @@
8608   */
8609  
8610  #include <linux/proc_fs.h>
8611 +#include <linux/vs_pid.h>
8612  
8613  extern struct proc_dir_entry proc_root;
8614  #ifdef CONFIG_PROC_SYSCTL
8615 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
8616                                 struct pid *pid, struct task_struct *task);
8617  extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
8618                                 struct pid *pid, struct task_struct *task);
8619 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
8620 +                               struct pid *pid, struct task_struct *task);
8621 +
8622  extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
8623  
8624  extern const struct file_operations proc_maps_operations;
8625 @@ -76,11 +80,16 @@ static inline struct pid *proc_pid(struc
8626         return PROC_I(inode)->pid;
8627  }
8628  
8629 -static inline struct task_struct *get_proc_task(struct inode *inode)
8630 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
8631  {
8632         return get_pid_task(proc_pid(inode), PIDTYPE_PID);
8633  }
8634  
8635 +static inline struct task_struct *get_proc_task(struct inode *inode)
8636 +{
8637 +       return vx_get_proc_task(inode, proc_pid(inode));
8638 +}
8639 +
8640  static inline int proc_fd(struct inode *inode)
8641  {
8642         return PROC_I(inode)->fd;
8643 diff -NurpP --minimal linux-3.0.4/fs/proc/loadavg.c linux-3.0.4-vs2.3.1/fs/proc/loadavg.c
8644 --- linux-3.0.4/fs/proc/loadavg.c       2009-09-10 15:26:23.000000000 +0200
8645 +++ linux-3.0.4-vs2.3.1/fs/proc/loadavg.c       2011-06-10 22:11:24.000000000 +0200
8646 @@ -12,15 +12,27 @@
8647  
8648  static int loadavg_proc_show(struct seq_file *m, void *v)
8649  {
8650 +       unsigned long running;
8651 +       unsigned int threads;
8652         unsigned long avnrun[3];
8653  
8654         get_avenrun(avnrun, FIXED_1/200, 0);
8655  
8656 +       if (vx_flags(VXF_VIRT_LOAD, 0)) {
8657 +               struct vx_info *vxi = current_vx_info();
8658 +
8659 +               running = atomic_read(&vxi->cvirt.nr_running);
8660 +               threads = atomic_read(&vxi->cvirt.nr_threads);
8661 +       } else {
8662 +               running = nr_running();
8663 +               threads = nr_threads;
8664 +       }
8665 +
8666         seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
8667                 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
8668                 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
8669                 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
8670 -               nr_running(), nr_threads,
8671 +               running, threads,
8672                 task_active_pid_ns(current)->last_pid);
8673         return 0;
8674  }
8675 diff -NurpP --minimal linux-3.0.4/fs/proc/meminfo.c linux-3.0.4-vs2.3.1/fs/proc/meminfo.c
8676 --- linux-3.0.4/fs/proc/meminfo.c       2011-03-15 18:07:33.000000000 +0100
8677 +++ linux-3.0.4-vs2.3.1/fs/proc/meminfo.c       2011-06-10 22:11:24.000000000 +0200
8678 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
8679         allowed = ((totalram_pages - hugetlb_total_pages())
8680                 * sysctl_overcommit_ratio / 100) + total_swap_pages;
8681  
8682 -       cached = global_page_state(NR_FILE_PAGES) -
8683 +       cached = vx_flags(VXF_VIRT_MEM, 0) ?
8684 +               vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
8685                         total_swapcache_pages - i.bufferram;
8686         if (cached < 0)
8687                 cached = 0;
8688 diff -NurpP --minimal linux-3.0.4/fs/proc/root.c linux-3.0.4-vs2.3.1/fs/proc/root.c
8689 --- linux-3.0.4/fs/proc/root.c  2011-07-22 11:18:06.000000000 +0200
8690 +++ linux-3.0.4-vs2.3.1/fs/proc/root.c  2011-06-22 12:39:15.000000000 +0200
8691 @@ -18,9 +18,14 @@
8692  #include <linux/bitops.h>
8693  #include <linux/mount.h>
8694  #include <linux/pid_namespace.h>
8695 +#include <linux/vserver/inode.h>
8696  
8697  #include "internal.h"
8698  
8699 +struct proc_dir_entry *proc_virtual;
8700 +
8701 +extern void proc_vx_init(void);
8702 +
8703  static int proc_test_super(struct super_block *sb, void *data)
8704  {
8705         return sb->s_fs_info == data;
8706 @@ -125,6 +130,7 @@ void __init proc_root_init(void)
8707  #endif
8708         proc_mkdir("bus", NULL);
8709         proc_sys_init();
8710 +       proc_vx_init();
8711  }
8712  
8713  static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
8714 @@ -193,6 +199,7 @@ struct proc_dir_entry proc_root = {
8715         .proc_iops      = &proc_root_inode_operations, 
8716         .proc_fops      = &proc_root_operations,
8717         .parent         = &proc_root,
8718 +       .vx_flags       = IATTR_ADMIN | IATTR_WATCH,
8719  };
8720  
8721  int pid_ns_prepare_proc(struct pid_namespace *ns)
8722 diff -NurpP --minimal linux-3.0.4/fs/proc/uptime.c linux-3.0.4-vs2.3.1/fs/proc/uptime.c
8723 --- linux-3.0.4/fs/proc/uptime.c        2009-12-03 20:02:53.000000000 +0100
8724 +++ linux-3.0.4-vs2.3.1/fs/proc/uptime.c        2011-06-10 22:11:24.000000000 +0200
8725 @@ -4,22 +4,22 @@
8726  #include <linux/sched.h>
8727  #include <linux/seq_file.h>
8728  #include <linux/time.h>
8729 -#include <linux/kernel_stat.h>
8730 +#include <linux/vserver/cvirt.h>
8731  #include <asm/cputime.h>
8732  
8733  static int uptime_proc_show(struct seq_file *m, void *v)
8734  {
8735         struct timespec uptime;
8736         struct timespec idle;
8737 -       int i;
8738 -       cputime_t idletime = cputime_zero;
8739 -
8740 -       for_each_possible_cpu(i)
8741 -               idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
8742 +       cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
8743  
8744         do_posix_clock_monotonic_gettime(&uptime);
8745         monotonic_to_bootbased(&uptime);
8746         cputime_to_timespec(idletime, &idle);
8747 +
8748 +       if (vx_flags(VXF_VIRT_UPTIME, 0))
8749 +               vx_vsi_uptime(&uptime, &idle);
8750 +
8751         seq_printf(m, "%lu.%02lu %lu.%02lu\n",
8752                         (unsigned long) uptime.tv_sec,
8753                         (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
8754 diff -NurpP --minimal linux-3.0.4/fs/quota/dquot.c linux-3.0.4-vs2.3.1/fs/quota/dquot.c
8755 --- linux-3.0.4/fs/quota/dquot.c        2011-07-22 11:18:06.000000000 +0200
8756 +++ linux-3.0.4-vs2.3.1/fs/quota/dquot.c        2011-06-10 22:11:24.000000000 +0200
8757 @@ -1548,6 +1548,9 @@ int __dquot_alloc_space(struct inode *in
8758         int reserve = flags & DQUOT_SPACE_RESERVE;
8759         int nofail = flags & DQUOT_SPACE_NOFAIL;
8760  
8761 +       if ((ret = dl_alloc_space(inode, number)))
8762 +               return ret;
8763 +
8764         /*
8765          * First test before acquiring mutex - solves deadlocks when we
8766          * re-enter the quota code and are already holding the mutex
8767 @@ -1602,6 +1605,9 @@ int dquot_alloc_inode(const struct inode
8768         int cnt, ret = 0;
8769         char warntype[MAXQUOTAS];
8770  
8771 +       if ((ret = dl_alloc_inode(inode)))
8772 +               return ret;
8773 +
8774         /* First test before acquiring mutex - solves deadlocks when we
8775           * re-enter the quota code and are already holding the mutex */
8776         if (!dquot_active(inode))
8777 @@ -1672,6 +1678,8 @@ void __dquot_free_space(struct inode *in
8778         char warntype[MAXQUOTAS];
8779         int reserve = flags & DQUOT_SPACE_RESERVE;
8780  
8781 +       dl_free_space(inode, number);
8782 +
8783         /* First test before acquiring mutex - solves deadlocks when we
8784           * re-enter the quota code and are already holding the mutex */
8785         if (!dquot_active(inode)) {
8786 @@ -1710,6 +1718,8 @@ void dquot_free_inode(const struct inode
8787         unsigned int cnt;
8788         char warntype[MAXQUOTAS];
8789  
8790 +       dl_free_inode(inode);
8791 +
8792         /* First test before acquiring mutex - solves deadlocks when we
8793           * re-enter the quota code and are already holding the mutex */
8794         if (!dquot_active(inode))
8795 diff -NurpP --minimal linux-3.0.4/fs/quota/quota.c linux-3.0.4-vs2.3.1/fs/quota/quota.c
8796 --- linux-3.0.4/fs/quota/quota.c        2011-03-15 18:07:34.000000000 +0100
8797 +++ linux-3.0.4-vs2.3.1/fs/quota/quota.c        2011-06-13 18:19:47.000000000 +0200
8798 @@ -8,6 +8,7 @@
8799  #include <linux/fs.h>
8800  #include <linux/namei.h>
8801  #include <linux/slab.h>
8802 +#include <linux/vs_context.h>
8803  #include <asm/current.h>
8804  #include <asm/uaccess.h>
8805  #include <linux/kernel.h>
8806 @@ -38,7 +39,7 @@ static int check_quotactl_permission(str
8807                         break;
8808                 /*FALLTHROUGH*/
8809         default:
8810 -               if (!capable(CAP_SYS_ADMIN))
8811 +               if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8812                         return -EPERM;
8813         }
8814  
8815 @@ -293,6 +294,46 @@ static int do_quotactl(struct super_bloc
8816         }
8817  }
8818  
8819 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
8820 +
8821 +#include <linux/vroot.h>
8822 +#include <linux/major.h>
8823 +#include <linux/module.h>
8824 +#include <linux/kallsyms.h>
8825 +#include <linux/vserver/debug.h>
8826 +
8827 +static vroot_grb_func *vroot_get_real_bdev = NULL;
8828 +
8829 +static DEFINE_SPINLOCK(vroot_grb_lock);
8830 +
8831 +int register_vroot_grb(vroot_grb_func *func) {
8832 +       int ret = -EBUSY;
8833 +
8834 +       spin_lock(&vroot_grb_lock);
8835 +       if (!vroot_get_real_bdev) {
8836 +               vroot_get_real_bdev = func;
8837 +               ret = 0;
8838 +       }
8839 +       spin_unlock(&vroot_grb_lock);
8840 +       return ret;
8841 +}
8842 +EXPORT_SYMBOL(register_vroot_grb);
8843 +
8844 +int unregister_vroot_grb(vroot_grb_func *func) {
8845 +       int ret = -EINVAL;
8846 +
8847 +       spin_lock(&vroot_grb_lock);
8848 +       if (vroot_get_real_bdev) {
8849 +               vroot_get_real_bdev = NULL;
8850 +               ret = 0;
8851 +       }
8852 +       spin_unlock(&vroot_grb_lock);
8853 +       return ret;
8854 +}
8855 +EXPORT_SYMBOL(unregister_vroot_grb);
8856 +
8857 +#endif
8858 +
8859  /*
8860   * look up a superblock on which quota ops will be performed
8861   * - use the name of a block device to find the superblock thereon
8862 @@ -310,6 +351,22 @@ static struct super_block *quotactl_bloc
8863         putname(tmp);
8864         if (IS_ERR(bdev))
8865                 return ERR_CAST(bdev);
8866 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
8867 +       if (bdev && bdev->bd_inode &&
8868 +                       imajor(bdev->bd_inode) == VROOT_MAJOR) {
8869 +               struct block_device *bdnew = (void *)-EINVAL;
8870 +
8871 +               if (vroot_get_real_bdev)
8872 +                       bdnew = vroot_get_real_bdev(bdev);
8873 +               else
8874 +                       vxdprintk(VXD_CBIT(misc, 0),
8875 +                                       "vroot_get_real_bdev not set");
8876 +               bdput(bdev);
8877 +               if (IS_ERR(bdnew))
8878 +                       return ERR_PTR(PTR_ERR(bdnew));
8879 +               bdev = bdnew;
8880 +       }
8881 +#endif
8882         sb = get_super(bdev);
8883         bdput(bdev);
8884         if (!sb)
8885 diff -NurpP --minimal linux-3.0.4/fs/reiserfs/file.c linux-3.0.4-vs2.3.1/fs/reiserfs/file.c
8886 --- linux-3.0.4/fs/reiserfs/file.c      2011-01-05 21:50:26.000000000 +0100
8887 +++ linux-3.0.4-vs2.3.1/fs/reiserfs/file.c      2011-06-10 22:11:24.000000000 +0200
8888 @@ -312,4 +312,5 @@ const struct inode_operations reiserfs_f
8889         .listxattr = reiserfs_listxattr,
8890         .removexattr = reiserfs_removexattr,
8891         .permission = reiserfs_permission,
8892 +       .sync_flags = reiserfs_sync_flags,
8893  };
8894 diff -NurpP --minimal linux-3.0.4/fs/reiserfs/inode.c linux-3.0.4-vs2.3.1/fs/reiserfs/inode.c
8895 --- linux-3.0.4/fs/reiserfs/inode.c     2011-05-22 16:17:53.000000000 +0200
8896 +++ linux-3.0.4-vs2.3.1/fs/reiserfs/inode.c     2011-06-10 22:11:24.000000000 +0200
8897 @@ -18,6 +18,7 @@
8898  #include <linux/writeback.h>
8899  #include <linux/quotaops.h>
8900  #include <linux/swap.h>
8901 +#include <linux/vs_tag.h>
8902  
8903  int reiserfs_commit_write(struct file *f, struct page *page,
8904                           unsigned from, unsigned to);
8905 @@ -1131,6 +1132,8 @@ static void init_inode(struct inode *ino
8906         struct buffer_head *bh;
8907         struct item_head *ih;
8908         __u32 rdev;
8909 +       uid_t uid;
8910 +       gid_t gid;
8911         //int version = ITEM_VERSION_1;
8912  
8913         bh = PATH_PLAST_BUFFER(path);
8914 @@ -1151,12 +1154,13 @@ static void init_inode(struct inode *ino
8915                     (struct stat_data_v1 *)B_I_PITEM(bh, ih);
8916                 unsigned long blocks;
8917  
8918 +               uid = sd_v1_uid(sd);
8919 +               gid = sd_v1_gid(sd);
8920 +
8921                 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
8922                 set_inode_sd_version(inode, STAT_DATA_V1);
8923                 inode->i_mode = sd_v1_mode(sd);
8924                 inode->i_nlink = sd_v1_nlink(sd);
8925 -               inode->i_uid = sd_v1_uid(sd);
8926 -               inode->i_gid = sd_v1_gid(sd);
8927                 inode->i_size = sd_v1_size(sd);
8928                 inode->i_atime.tv_sec = sd_v1_atime(sd);
8929                 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
8930 @@ -1198,11 +1202,12 @@ static void init_inode(struct inode *ino
8931                 // (directories and symlinks)
8932                 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
8933  
8934 +               uid    = sd_v2_uid(sd);
8935 +               gid    = sd_v2_gid(sd);
8936 +
8937                 inode->i_mode = sd_v2_mode(sd);
8938                 inode->i_nlink = sd_v2_nlink(sd);
8939 -               inode->i_uid = sd_v2_uid(sd);
8940                 inode->i_size = sd_v2_size(sd);
8941 -               inode->i_gid = sd_v2_gid(sd);
8942                 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
8943                 inode->i_atime.tv_sec = sd_v2_atime(sd);
8944                 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
8945 @@ -1232,6 +1237,10 @@ static void init_inode(struct inode *ino
8946                 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
8947         }
8948  
8949 +       inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
8950 +       inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
8951 +       inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
8952 +
8953         pathrelse(path);
8954         if (S_ISREG(inode->i_mode)) {
8955                 inode->i_op = &reiserfs_file_inode_operations;
8956 @@ -1254,13 +1263,15 @@ static void init_inode(struct inode *ino
8957  static void inode2sd(void *sd, struct inode *inode, loff_t size)
8958  {
8959         struct stat_data *sd_v2 = (struct stat_data *)sd;
8960 +       uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
8961 +       gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
8962         __u16 flags;
8963  
8964 +       set_sd_v2_uid(sd_v2, uid);
8965 +       set_sd_v2_gid(sd_v2, gid);
8966         set_sd_v2_mode(sd_v2, inode->i_mode);
8967         set_sd_v2_nlink(sd_v2, inode->i_nlink);
8968 -       set_sd_v2_uid(sd_v2, inode->i_uid);
8969         set_sd_v2_size(sd_v2, size);
8970 -       set_sd_v2_gid(sd_v2, inode->i_gid);
8971         set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
8972         set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
8973         set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
8974 @@ -2863,14 +2874,19 @@ int reiserfs_commit_write(struct file *f
8975  void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
8976  {
8977         if (reiserfs_attrs(inode->i_sb)) {
8978 -               if (sd_attrs & REISERFS_SYNC_FL)
8979 -                       inode->i_flags |= S_SYNC;
8980 -               else
8981 -                       inode->i_flags &= ~S_SYNC;
8982                 if (sd_attrs & REISERFS_IMMUTABLE_FL)
8983                         inode->i_flags |= S_IMMUTABLE;
8984                 else
8985                         inode->i_flags &= ~S_IMMUTABLE;
8986 +               if (sd_attrs & REISERFS_IXUNLINK_FL)
8987 +                       inode->i_flags |= S_IXUNLINK;
8988 +               else
8989 +                       inode->i_flags &= ~S_IXUNLINK;
8990 +
8991 +               if (sd_attrs & REISERFS_SYNC_FL)
8992 +                       inode->i_flags |= S_SYNC;
8993 +               else
8994 +                       inode->i_flags &= ~S_SYNC;
8995                 if (sd_attrs & REISERFS_APPEND_FL)
8996                         inode->i_flags |= S_APPEND;
8997                 else
8998 @@ -2883,6 +2899,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
8999                         REISERFS_I(inode)->i_flags |= i_nopack_mask;
9000                 else
9001                         REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
9002 +
9003 +               if (sd_attrs & REISERFS_BARRIER_FL)
9004 +                       inode->i_vflags |= V_BARRIER;
9005 +               else
9006 +                       inode->i_vflags &= ~V_BARRIER;
9007 +               if (sd_attrs & REISERFS_COW_FL)
9008 +                       inode->i_vflags |= V_COW;
9009 +               else
9010 +                       inode->i_vflags &= ~V_COW;
9011         }
9012  }
9013  
9014 @@ -2893,6 +2918,11 @@ void i_attrs_to_sd_attrs(struct inode *i
9015                         *sd_attrs |= REISERFS_IMMUTABLE_FL;
9016                 else
9017                         *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
9018 +               if (inode->i_flags & S_IXUNLINK)
9019 +                       *sd_attrs |= REISERFS_IXUNLINK_FL;
9020 +               else
9021 +                       *sd_attrs &= ~REISERFS_IXUNLINK_FL;
9022 +
9023                 if (inode->i_flags & S_SYNC)
9024                         *sd_attrs |= REISERFS_SYNC_FL;
9025                 else
9026 @@ -2905,6 +2935,15 @@ void i_attrs_to_sd_attrs(struct inode *i
9027                         *sd_attrs |= REISERFS_NOTAIL_FL;
9028                 else
9029                         *sd_attrs &= ~REISERFS_NOTAIL_FL;
9030 +
9031 +               if (inode->i_vflags & V_BARRIER)
9032 +                       *sd_attrs |= REISERFS_BARRIER_FL;
9033 +               else
9034 +                       *sd_attrs &= ~REISERFS_BARRIER_FL;
9035 +               if (inode->i_vflags & V_COW)
9036 +                       *sd_attrs |= REISERFS_COW_FL;
9037 +               else
9038 +                       *sd_attrs &= ~REISERFS_COW_FL;
9039         }
9040  }
9041  
9042 @@ -3148,7 +3187,8 @@ int reiserfs_setattr(struct dentry *dent
9043         }
9044  
9045         if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
9046 -           (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
9047 +           (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
9048 +           (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
9049                 struct reiserfs_transaction_handle th;
9050                 int jbegin_count =
9051                     2 *
9052 @@ -3177,6 +3217,9 @@ int reiserfs_setattr(struct dentry *dent
9053                         inode->i_uid = attr->ia_uid;
9054                 if (attr->ia_valid & ATTR_GID)
9055                         inode->i_gid = attr->ia_gid;
9056 +                               if ((attr->ia_valid & ATTR_TAG) &&
9057 +                                       IS_TAGGED(inode))
9058 +                                       inode->i_tag = attr->ia_tag;
9059                 mark_inode_dirty(inode);
9060                 error = journal_end(&th, inode->i_sb, jbegin_count);
9061                 if (error)
9062 diff -NurpP --minimal linux-3.0.4/fs/reiserfs/ioctl.c linux-3.0.4-vs2.3.1/fs/reiserfs/ioctl.c
9063 --- linux-3.0.4/fs/reiserfs/ioctl.c     2011-05-22 16:17:53.000000000 +0200
9064 +++ linux-3.0.4-vs2.3.1/fs/reiserfs/ioctl.c     2011-06-10 22:11:24.000000000 +0200
9065 @@ -11,6 +11,21 @@
9066  #include <linux/pagemap.h>
9067  #include <linux/compat.h>
9068  
9069 +
9070 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
9071 +{
9072 +       __u16 sd_attrs = 0;
9073 +
9074 +       inode->i_flags = flags;
9075 +       inode->i_vflags = vflags;
9076 +
9077 +       i_attrs_to_sd_attrs(inode, &sd_attrs);
9078 +       REISERFS_I(inode)->i_attrs = sd_attrs;
9079 +       inode->i_ctime = CURRENT_TIME_SEC;
9080 +       mark_inode_dirty(inode);
9081 +       return 0;
9082 +}
9083 +
9084  /*
9085   * reiserfs_ioctl - handler for ioctl for inode
9086   * supported commands:
9087 @@ -22,7 +37,7 @@
9088  long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
9089  {
9090         struct inode *inode = filp->f_path.dentry->d_inode;
9091 -       unsigned int flags;
9092 +       unsigned int flags, oldflags;
9093         int err = 0;
9094  
9095         reiserfs_write_lock(inode->i_sb);
9096 @@ -47,6 +62,7 @@ long reiserfs_ioctl(struct file *filp, u
9097  
9098                 flags = REISERFS_I(inode)->i_attrs;
9099                 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
9100 +               flags &= REISERFS_FL_USER_VISIBLE;
9101                 err = put_user(flags, (int __user *)arg);
9102                 break;
9103         case REISERFS_IOC_SETFLAGS:{
9104 @@ -67,6 +83,10 @@ long reiserfs_ioctl(struct file *filp, u
9105                                 err = -EFAULT;
9106                                 goto setflags_out;
9107                         }
9108 +                       if (IS_BARRIER(inode)) {
9109 +                               vxwprintk_task(1, "messing with the barrier.");
9110 +                               return -EACCES;
9111 +                       }
9112                         /*
9113                          * Is it quota file? Do not allow user to mess with it
9114                          */
9115 @@ -91,6 +111,10 @@ long reiserfs_ioctl(struct file *filp, u
9116                                         goto setflags_out;
9117                                 }
9118                         }
9119 +
9120 +                       oldflags = REISERFS_I(inode)->i_attrs;
9121 +                       flags &= REISERFS_FL_USER_MODIFIABLE;
9122 +                       flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
9123                         sd_attrs_to_i_attrs(flags, inode);
9124                         REISERFS_I(inode)->i_attrs = flags;
9125                         inode->i_ctime = CURRENT_TIME_SEC;
9126 diff -NurpP --minimal linux-3.0.4/fs/reiserfs/namei.c linux-3.0.4-vs2.3.1/fs/reiserfs/namei.c
9127 --- linux-3.0.4/fs/reiserfs/namei.c     2011-05-22 16:17:53.000000000 +0200
9128 +++ linux-3.0.4-vs2.3.1/fs/reiserfs/namei.c     2011-06-10 22:11:24.000000000 +0200
9129 @@ -18,6 +18,7 @@
9130  #include <linux/reiserfs_acl.h>
9131  #include <linux/reiserfs_xattr.h>
9132  #include <linux/quotaops.h>
9133 +#include <linux/vs_tag.h>
9134  
9135  #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; }
9136  #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
9137 @@ -362,6 +363,7 @@ static struct dentry *reiserfs_lookup(st
9138         if (retval == IO_ERROR) {
9139                 return ERR_PTR(-EIO);
9140         }
9141 +               dx_propagate_tag(nd, inode);
9142  
9143         return d_splice_alias(inode, dentry);
9144  }
9145 @@ -1529,6 +1531,7 @@ const struct inode_operations reiserfs_d
9146         .listxattr = reiserfs_listxattr,
9147         .removexattr = reiserfs_removexattr,
9148         .permission = reiserfs_permission,
9149 +       .sync_flags = reiserfs_sync_flags,
9150  };
9151  
9152  /*
9153 diff -NurpP --minimal linux-3.0.4/fs/reiserfs/super.c linux-3.0.4-vs2.3.1/fs/reiserfs/super.c
9154 --- linux-3.0.4/fs/reiserfs/super.c     2011-07-22 11:18:06.000000000 +0200
9155 +++ linux-3.0.4-vs2.3.1/fs/reiserfs/super.c     2011-06-10 22:11:24.000000000 +0200
9156 @@ -899,6 +899,14 @@ static int reiserfs_parse_options(struct
9157                 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
9158                 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
9159  #endif
9160 +#ifndef CONFIG_TAGGING_NONE
9161 +               {"tagxid",.setmask = 1 << REISERFS_TAGGED},
9162 +               {"tag",.setmask = 1 << REISERFS_TAGGED},
9163 +               {"notag",.clrmask = 1 << REISERFS_TAGGED},
9164 +#endif
9165 +#ifdef CONFIG_PROPAGATE
9166 +               {"tag",.arg_required = 'T',.values = NULL},
9167 +#endif
9168  #ifdef CONFIG_REISERFS_FS_POSIX_ACL
9169                 {"acl",.setmask = 1 << REISERFS_POSIXACL},
9170                 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
9171 @@ -1208,6 +1216,14 @@ static int reiserfs_remount(struct super
9172         handle_quota_files(s, qf_names, &qfmt);
9173  #endif
9174  
9175 +       if ((mount_options & (1 << REISERFS_TAGGED)) &&
9176 +               !(s->s_flags & MS_TAGGED)) {
9177 +               reiserfs_warning(s, "super-vs01",
9178 +                       "reiserfs: tagging not permitted on remount.");
9179 +               err = -EINVAL;
9180 +               goto out_err;
9181 +       }
9182 +
9183         handle_attrs(s);
9184  
9185         /* Add options that are safe here */
9186 @@ -1690,6 +1706,10 @@ static int reiserfs_fill_super(struct su
9187                 goto error;
9188         }
9189  
9190 +       /* map mount option tagxid */
9191 +       if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
9192 +               s->s_flags |= MS_TAGGED;
9193 +
9194         rs = SB_DISK_SUPER_BLOCK(s);
9195         /* Let's do basic sanity check to verify that underlying device is not
9196            smaller than the filesystem. If the check fails then abort and scream,
9197 diff -NurpP --minimal linux-3.0.4/fs/reiserfs/xattr.c linux-3.0.4-vs2.3.1/fs/reiserfs/xattr.c
9198 --- linux-3.0.4/fs/reiserfs/xattr.c     2011-07-22 11:18:06.000000000 +0200
9199 +++ linux-3.0.4-vs2.3.1/fs/reiserfs/xattr.c     2011-06-22 12:39:15.000000000 +0200
9200 @@ -40,6 +40,7 @@
9201  #include <linux/errno.h>
9202  #include <linux/gfp.h>
9203  #include <linux/fs.h>
9204 +#include <linux/mount.h>
9205  #include <linux/file.h>
9206  #include <linux/pagemap.h>
9207  #include <linux/xattr.h>
9208 diff -NurpP --minimal linux-3.0.4/fs/stat.c linux-3.0.4-vs2.3.1/fs/stat.c
9209 --- linux-3.0.4/fs/stat.c       2011-05-22 16:17:54.000000000 +0200
9210 +++ linux-3.0.4-vs2.3.1/fs/stat.c       2011-06-10 22:11:24.000000000 +0200
9211 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
9212         stat->nlink = inode->i_nlink;
9213         stat->uid = inode->i_uid;
9214         stat->gid = inode->i_gid;
9215 +       stat->tag = inode->i_tag;
9216         stat->rdev = inode->i_rdev;
9217         stat->atime = inode->i_atime;
9218         stat->mtime = inode->i_mtime;
9219 diff -NurpP --minimal linux-3.0.4/fs/statfs.c linux-3.0.4-vs2.3.1/fs/statfs.c
9220 --- linux-3.0.4/fs/statfs.c     2011-05-22 16:17:54.000000000 +0200
9221 +++ linux-3.0.4-vs2.3.1/fs/statfs.c     2011-06-10 22:11:24.000000000 +0200
9222 @@ -7,6 +7,8 @@
9223  #include <linux/statfs.h>
9224  #include <linux/security.h>
9225  #include <linux/uaccess.h>
9226 +#include <linux/vs_base.h>
9227 +#include <linux/vs_dlimit.h>
9228  
9229  static int flags_by_mnt(int mnt_flags)
9230  {
9231 @@ -59,6 +61,8 @@ int statfs_by_dentry(struct dentry *dent
9232         retval = dentry->d_sb->s_op->statfs(dentry, buf);
9233         if (retval == 0 && buf->f_frsize == 0)
9234                 buf->f_frsize = buf->f_bsize;
9235 +       if (!vx_check(0, VS_ADMIN|VS_WATCH))
9236 +               vx_vsi_statfs(dentry->d_sb, buf);
9237         return retval;
9238  }
9239  
9240 diff -NurpP --minimal linux-3.0.4/fs/super.c linux-3.0.4-vs2.3.1/fs/super.c
9241 --- linux-3.0.4/fs/super.c      2011-07-22 11:18:06.000000000 +0200
9242 +++ linux-3.0.4-vs2.3.1/fs/super.c      2011-07-23 16:49:09.000000000 +0200
9243 @@ -32,6 +32,9 @@
9244  #include <linux/backing-dev.h>
9245  #include <linux/rculist_bl.h>
9246  #include <linux/cleancache.h>
9247 +#include <linux/devpts_fs.h>
9248 +#include <linux/proc_fs.h>
9249 +#include <linux/vs_context.h>
9250  #include "internal.h"
9251  
9252  
9253 @@ -943,6 +946,13 @@ mount_fs(struct file_system_type *type, 
9254         WARN_ON(sb->s_bdi == &default_backing_dev_info);
9255         sb->s_flags |= MS_BORN;
9256  
9257 +       error = -EPERM;
9258 +       if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) &&
9259 +               !sb->s_bdev &&
9260 +               (sb->s_magic != PROC_SUPER_MAGIC) &&
9261 +               (sb->s_magic != DEVPTS_SUPER_MAGIC))
9262 +               goto out_sb;
9263 +
9264         error = security_sb_kern_mount(sb, flags, secdata);
9265         if (error)
9266                 goto out_sb;
9267 diff -NurpP --minimal linux-3.0.4/fs/sysfs/mount.c linux-3.0.4-vs2.3.1/fs/sysfs/mount.c
9268 --- linux-3.0.4/fs/sysfs/mount.c        2011-07-22 11:18:06.000000000 +0200
9269 +++ linux-3.0.4-vs2.3.1/fs/sysfs/mount.c        2011-06-22 12:39:15.000000000 +0200
9270 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
9271  
9272         sb->s_blocksize = PAGE_CACHE_SIZE;
9273         sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
9274 -       sb->s_magic = SYSFS_MAGIC;
9275 +       sb->s_magic = SYSFS_SUPER_MAGIC;
9276         sb->s_op = &sysfs_ops;
9277         sb->s_time_gran = 1;
9278  
9279 diff -NurpP --minimal linux-3.0.4/fs/utimes.c linux-3.0.4-vs2.3.1/fs/utimes.c
9280 --- linux-3.0.4/fs/utimes.c     2011-05-22 16:17:54.000000000 +0200
9281 +++ linux-3.0.4-vs2.3.1/fs/utimes.c     2011-06-10 22:11:24.000000000 +0200
9282 @@ -8,6 +8,8 @@
9283  #include <linux/stat.h>
9284  #include <linux/utime.h>
9285  #include <linux/syscalls.h>
9286 +#include <linux/mount.h>
9287 +#include <linux/vs_cowbl.h>
9288  #include <asm/uaccess.h>
9289  #include <asm/unistd.h>
9290  
9291 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
9292  {
9293         int error;
9294         struct iattr newattrs;
9295 -       struct inode *inode = path->dentry->d_inode;
9296 +       struct inode *inode;
9297  
9298         error = mnt_want_write(path->mnt);
9299         if (error)
9300                 goto out;
9301  
9302 +       error = cow_check_and_break(path);
9303 +       if (error)
9304 +               goto mnt_drop_write_and_out;
9305 +
9306 +       inode = path->dentry->d_inode;
9307 +
9308         if (times && times[0].tv_nsec == UTIME_NOW &&
9309                      times[1].tv_nsec == UTIME_NOW)
9310                 times = NULL;
9311 diff -NurpP --minimal linux-3.0.4/fs/xattr.c linux-3.0.4-vs2.3.1/fs/xattr.c
9312 --- linux-3.0.4/fs/xattr.c      2011-07-22 11:18:09.000000000 +0200
9313 +++ linux-3.0.4-vs2.3.1/fs/xattr.c      2011-06-10 23:10:19.000000000 +0200
9314 @@ -18,6 +18,7 @@
9315  #include <linux/module.h>
9316  #include <linux/fsnotify.h>
9317  #include <linux/audit.h>
9318 +#include <linux/mount.h>
9319  #include <asm/uaccess.h>
9320  
9321  
9322 @@ -49,7 +50,7 @@ xattr_permission(struct inode *inode, co
9323          * The trusted.* namespace can only be accessed by privileged users.
9324          */
9325         if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) {
9326 -               if (!capable(CAP_SYS_ADMIN))
9327 +               if (!vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED))
9328                         return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
9329                 return 0;
9330         }
9331 diff -NurpP --minimal linux-3.0.4/fs/xfs/linux-2.6/xfs_ioctl.c linux-3.0.4-vs2.3.1/fs/xfs/linux-2.6/xfs_ioctl.c
9332 --- linux-3.0.4/fs/xfs/linux-2.6/xfs_ioctl.c    2011-05-22 16:17:54.000000000 +0200
9333 +++ linux-3.0.4-vs2.3.1/fs/xfs/linux-2.6/xfs_ioctl.c    2011-06-10 22:11:24.000000000 +0200
9334 @@ -28,7 +28,7 @@
9335  #include "xfs_bmap_btree.h"
9336  #include "xfs_dinode.h"
9337  #include "xfs_inode.h"
9338 -#include "xfs_ioctl.h"
9339 +// #include "xfs_ioctl.h"
9340  #include "xfs_rtalloc.h"
9341  #include "xfs_itable.h"
9342  #include "xfs_error.h"
9343 @@ -748,6 +748,10 @@ xfs_merge_ioc_xflags(
9344                 xflags |= XFS_XFLAG_IMMUTABLE;
9345         else
9346                 xflags &= ~XFS_XFLAG_IMMUTABLE;
9347 +       if (flags & FS_IXUNLINK_FL)
9348 +               xflags |= XFS_XFLAG_IXUNLINK;
9349 +       else
9350 +               xflags &= ~XFS_XFLAG_IXUNLINK;
9351         if (flags & FS_APPEND_FL)
9352                 xflags |= XFS_XFLAG_APPEND;
9353         else
9354 @@ -776,6 +780,8 @@ xfs_di2lxflags(
9355  
9356         if (di_flags & XFS_DIFLAG_IMMUTABLE)
9357                 flags |= FS_IMMUTABLE_FL;
9358 +       if (di_flags & XFS_DIFLAG_IXUNLINK)
9359 +               flags |= FS_IXUNLINK_FL;
9360         if (di_flags & XFS_DIFLAG_APPEND)
9361                 flags |= FS_APPEND_FL;
9362         if (di_flags & XFS_DIFLAG_SYNC)
9363 @@ -836,6 +842,8 @@ xfs_set_diflags(
9364         di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
9365         if (xflags & XFS_XFLAG_IMMUTABLE)
9366                 di_flags |= XFS_DIFLAG_IMMUTABLE;
9367 +       if (xflags & XFS_XFLAG_IXUNLINK)
9368 +               di_flags |= XFS_DIFLAG_IXUNLINK;
9369         if (xflags & XFS_XFLAG_APPEND)
9370                 di_flags |= XFS_DIFLAG_APPEND;
9371         if (xflags & XFS_XFLAG_SYNC)
9372 @@ -878,6 +886,10 @@ xfs_diflags_to_linux(
9373                 inode->i_flags |= S_IMMUTABLE;
9374         else
9375                 inode->i_flags &= ~S_IMMUTABLE;
9376 +       if (xflags & XFS_XFLAG_IXUNLINK)
9377 +               inode->i_flags |= S_IXUNLINK;
9378 +       else
9379 +               inode->i_flags &= ~S_IXUNLINK;
9380         if (xflags & XFS_XFLAG_APPEND)
9381                 inode->i_flags |= S_APPEND;
9382         else
9383 @@ -1370,10 +1382,18 @@ xfs_file_ioctl(
9384         case XFS_IOC_FSGETXATTRA:
9385                 return xfs_ioc_fsgetxattr(ip, 1, arg);
9386         case XFS_IOC_FSSETXATTR:
9387 +               if (IS_BARRIER(inode)) {
9388 +                       vxwprintk_task(1, "messing with the barrier.");
9389 +                       return -XFS_ERROR(EACCES);
9390 +               }
9391                 return xfs_ioc_fssetxattr(ip, filp, arg);
9392         case XFS_IOC_GETXFLAGS:
9393                 return xfs_ioc_getxflags(ip, arg);
9394         case XFS_IOC_SETXFLAGS:
9395 +               if (IS_BARRIER(inode)) {
9396 +                       vxwprintk_task(1, "messing with the barrier.");
9397 +                       return -XFS_ERROR(EACCES);
9398 +               }
9399                 return xfs_ioc_setxflags(ip, filp, arg);
9400  
9401         case XFS_IOC_FSSETDM: {
9402 diff -NurpP --minimal linux-3.0.4/fs/xfs/linux-2.6/xfs_ioctl.h linux-3.0.4-vs2.3.1/fs/xfs/linux-2.6/xfs_ioctl.h
9403 --- linux-3.0.4/fs/xfs/linux-2.6/xfs_ioctl.h    2010-07-07 18:31:54.000000000 +0200
9404 +++ linux-3.0.4-vs2.3.1/fs/xfs/linux-2.6/xfs_ioctl.h    2011-06-10 22:11:24.000000000 +0200
9405 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
9406         void __user             *uhandle,
9407         u32                     hlen);
9408  
9409 +extern int
9410 +xfs_sync_flags(
9411 +       struct inode            *inode,
9412 +       int                     flags,
9413 +       int                     vflags);
9414 +
9415  extern long
9416  xfs_file_ioctl(
9417         struct file             *filp,
9418 diff -NurpP --minimal linux-3.0.4/fs/xfs/linux-2.6/xfs_iops.c linux-3.0.4-vs2.3.1/fs/xfs/linux-2.6/xfs_iops.c
9419 --- linux-3.0.4/fs/xfs/linux-2.6/xfs_iops.c     2011-07-22 11:18:09.000000000 +0200
9420 +++ linux-3.0.4-vs2.3.1/fs/xfs/linux-2.6/xfs_iops.c     2011-06-22 12:39:15.000000000 +0200
9421 @@ -30,6 +30,7 @@
9422  #include "xfs_bmap_btree.h"
9423  #include "xfs_dinode.h"
9424  #include "xfs_inode.h"
9425 +#include "xfs_ioctl.h"
9426  #include "xfs_bmap.h"
9427  #include "xfs_rtalloc.h"
9428  #include "xfs_error.h"
9429 @@ -48,6 +49,7 @@
9430  #include <linux/security.h>
9431  #include <linux/fiemap.h>
9432  #include <linux/slab.h>
9433 +#include <linux/vs_tag.h>
9434  
9435  /*
9436   * Bring the timestamps in the XFS inode uptodate.
9437 @@ -464,6 +466,7 @@ xfs_vn_getattr(
9438         stat->nlink = ip->i_d.di_nlink;
9439         stat->uid = ip->i_d.di_uid;
9440         stat->gid = ip->i_d.di_gid;
9441 +       stat->tag = ip->i_d.di_tag;
9442         stat->ino = ip->i_ino;
9443         stat->atime = inode->i_atime;
9444         stat->mtime = inode->i_mtime;
9445 @@ -599,6 +602,7 @@ static const struct inode_operations xfs
9446         .removexattr            = generic_removexattr,
9447         .listxattr              = xfs_vn_listxattr,
9448         .fiemap                 = xfs_vn_fiemap,
9449 +       .sync_flags             = xfs_sync_flags,
9450  };
9451  
9452  static const struct inode_operations xfs_dir_inode_operations = {
9453 @@ -624,6 +628,7 @@ static const struct inode_operations xfs
9454         .getxattr               = generic_getxattr,
9455         .removexattr            = generic_removexattr,
9456         .listxattr              = xfs_vn_listxattr,
9457 +       .sync_flags             = xfs_sync_flags,
9458  };
9459  
9460  static const struct inode_operations xfs_dir_ci_inode_operations = {
9461 @@ -673,6 +678,10 @@ xfs_diflags_to_iflags(
9462                 inode->i_flags |= S_IMMUTABLE;
9463         else
9464                 inode->i_flags &= ~S_IMMUTABLE;
9465 +       if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
9466 +               inode->i_flags |= S_IXUNLINK;
9467 +       else
9468 +               inode->i_flags &= ~S_IXUNLINK;
9469         if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
9470                 inode->i_flags |= S_APPEND;
9471         else
9472 @@ -685,6 +694,15 @@ xfs_diflags_to_iflags(
9473                 inode->i_flags |= S_NOATIME;
9474         else
9475                 inode->i_flags &= ~S_NOATIME;
9476 +
9477 +       if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
9478 +               inode->i_vflags |= V_BARRIER;
9479 +       else
9480 +               inode->i_vflags &= ~V_BARRIER;
9481 +       if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
9482 +               inode->i_vflags |= V_COW;
9483 +       else
9484 +               inode->i_vflags &= ~V_COW;
9485  }
9486  
9487  /*
9488 @@ -716,6 +734,7 @@ xfs_setup_inode(
9489         inode->i_nlink  = ip->i_d.di_nlink;
9490         inode->i_uid    = ip->i_d.di_uid;
9491         inode->i_gid    = ip->i_d.di_gid;
9492 +       inode->i_tag    = ip->i_d.di_tag;
9493  
9494         switch (inode->i_mode & S_IFMT) {
9495         case S_IFBLK:
9496 diff -NurpP --minimal linux-3.0.4/fs/xfs/linux-2.6/xfs_linux.h linux-3.0.4-vs2.3.1/fs/xfs/linux-2.6/xfs_linux.h
9497 --- linux-3.0.4/fs/xfs/linux-2.6/xfs_linux.h    2011-07-22 11:18:09.000000000 +0200
9498 +++ linux-3.0.4-vs2.3.1/fs/xfs/linux-2.6/xfs_linux.h    2011-06-10 22:11:24.000000000 +0200
9499 @@ -115,6 +115,7 @@
9500  
9501  #define current_cpu()          (raw_smp_processor_id())
9502  #define current_pid()          (current->pid)
9503 +#define current_fstag(vp)      (dx_current_fstag((vp)->i_sb))
9504  #define current_test_flags(f)  (current->flags & (f))
9505  #define current_set_flags_nested(sp, f)                \
9506                 (*(sp) = current->flags, current->flags |= (f))
9507 diff -NurpP --minimal linux-3.0.4/fs/xfs/linux-2.6/xfs_super.c linux-3.0.4-vs2.3.1/fs/xfs/linux-2.6/xfs_super.c
9508 --- linux-3.0.4/fs/xfs/linux-2.6/xfs_super.c    2011-07-22 11:18:09.000000000 +0200
9509 +++ linux-3.0.4-vs2.3.1/fs/xfs/linux-2.6/xfs_super.c    2011-06-22 12:39:15.000000000 +0200
9510 @@ -114,6 +114,9 @@ mempool_t *xfs_ioend_pool;
9511  #define MNTOPT_NODELAYLOG  "nodelaylog"        /* Delayed logging disabled */
9512  #define MNTOPT_DISCARD    "discard"    /* Discard unused blocks */
9513  #define MNTOPT_NODISCARD   "nodiscard" /* Do not discard unused blocks */
9514 +#define MNTOPT_TAGXID  "tagxid"        /* context tagging for inodes */
9515 +#define MNTOPT_TAGGED  "tag"           /* context tagging for inodes */
9516 +#define MNTOPT_NOTAGTAG        "notag"         /* do not use context tagging */
9517  
9518  /*
9519   * Table driven mount option parser.
9520 @@ -122,10 +125,14 @@ mempool_t *xfs_ioend_pool;
9521   * in the future, too.
9522   */
9523  enum {
9524 +       Opt_tag, Opt_notag,
9525         Opt_barrier, Opt_nobarrier, Opt_err
9526  };
9527  
9528  static const match_table_t tokens = {
9529 +       {Opt_tag, "tagxid"},
9530 +       {Opt_tag, "tag"},
9531 +       {Opt_notag, "notag"},
9532         {Opt_barrier, "barrier"},
9533         {Opt_nobarrier, "nobarrier"},
9534         {Opt_err, NULL}
9535 @@ -373,6 +380,19 @@ xfs_parseargs(
9536                 } else if (!strcmp(this_char, "irixsgid")) {
9537                         xfs_warn(mp,
9538         "irixsgid is now a sysctl(2) variable, option is deprecated.");
9539 +#ifndef CONFIG_TAGGING_NONE
9540 +               } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
9541 +                       mp->m_flags |= XFS_MOUNT_TAGGED;
9542 +               } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
9543 +                       mp->m_flags &= ~XFS_MOUNT_TAGGED;
9544 +               } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
9545 +                       mp->m_flags |= XFS_MOUNT_TAGGED;
9546 +#endif
9547 +#ifdef CONFIG_PROPAGATE
9548 +               } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
9549 +                       /* use value */
9550 +                       mp->m_flags |= XFS_MOUNT_TAGGED;
9551 +#endif
9552                 } else {
9553                         xfs_warn(mp, "unknown mount option [%s].", this_char);
9554                         return EINVAL;
9555 @@ -1182,6 +1202,16 @@ xfs_fs_remount(
9556                 case Opt_nobarrier:
9557                         mp->m_flags &= ~XFS_MOUNT_BARRIER;
9558                         break;
9559 +               case Opt_tag:
9560 +                       if (!(sb->s_flags & MS_TAGGED)) {
9561 +                               printk(KERN_INFO
9562 +                                       "XFS: %s: tagging not permitted on remount.\n",
9563 +                                       sb->s_id);
9564 +                               return -EINVAL;
9565 +                       }
9566 +                       break;
9567 +               case Opt_notag:
9568 +                       break;
9569                 default:
9570                         /*
9571                          * Logically we would return an error here to prevent
9572 @@ -1397,6 +1427,9 @@ xfs_fs_fill_super(
9573         if (error)
9574                 goto out_free_sb;
9575  
9576 +       if (mp->m_flags & XFS_MOUNT_TAGGED)
9577 +               sb->s_flags |= MS_TAGGED;
9578 +
9579         /*
9580          * we must configure the block size in the superblock before we run the
9581          * full mount process as the mount process can lookup and cache inodes.
9582 diff -NurpP --minimal linux-3.0.4/fs/xfs/xfs_dinode.h linux-3.0.4-vs2.3.1/fs/xfs/xfs_dinode.h
9583 --- linux-3.0.4/fs/xfs/xfs_dinode.h     2011-01-05 21:50:28.000000000 +0100
9584 +++ linux-3.0.4-vs2.3.1/fs/xfs/xfs_dinode.h     2011-06-10 22:11:24.000000000 +0200
9585 @@ -51,7 +51,9 @@ typedef struct xfs_dinode {
9586         __be32          di_nlink;       /* number of links to file */
9587         __be16          di_projid_lo;   /* lower part of owner's project id */
9588         __be16          di_projid_hi;   /* higher part owner's project id */
9589 -       __u8            di_pad[6];      /* unused, zeroed space */
9590 +       __u8            di_pad[2];      /* unused, zeroed space */
9591 +       __be16          di_tag;         /* context tagging */
9592 +       __be16          di_vflags;      /* vserver specific flags */
9593         __be16          di_flushiter;   /* incremented on flush */
9594         xfs_timestamp_t di_atime;       /* time last accessed */
9595         xfs_timestamp_t di_mtime;       /* time last modified */
9596 @@ -184,6 +186,8 @@ static inline void xfs_dinode_put_rdev(s
9597  #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
9598  #define XFS_DIFLAG_NODEFRAG_BIT     13 /* do not reorganize/defragment */
9599  #define XFS_DIFLAG_FILESTREAM_BIT   14  /* use filestream allocator */
9600 +#define XFS_DIFLAG_IXUNLINK_BIT     15 /* Immutable inver on unlink */
9601 +
9602  #define XFS_DIFLAG_REALTIME      (1 << XFS_DIFLAG_REALTIME_BIT)
9603  #define XFS_DIFLAG_PREALLOC      (1 << XFS_DIFLAG_PREALLOC_BIT)
9604  #define XFS_DIFLAG_NEWRTBM       (1 << XFS_DIFLAG_NEWRTBM_BIT)
9605 @@ -199,6 +203,7 @@ static inline void xfs_dinode_put_rdev(s
9606  #define XFS_DIFLAG_EXTSZINHERIT  (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
9607  #define XFS_DIFLAG_NODEFRAG      (1 << XFS_DIFLAG_NODEFRAG_BIT)
9608  #define XFS_DIFLAG_FILESTREAM    (1 << XFS_DIFLAG_FILESTREAM_BIT)
9609 +#define XFS_DIFLAG_IXUNLINK      (1 << XFS_DIFLAG_IXUNLINK_BIT)
9610  
9611  #ifdef CONFIG_XFS_RT
9612  #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
9613 @@ -211,6 +216,10 @@ static inline void xfs_dinode_put_rdev(s
9614          XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
9615          XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
9616          XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
9617 -        XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
9618 +        XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
9619 +        XFS_DIFLAG_IXUNLINK)
9620 +
9621 +#define XFS_DIVFLAG_BARRIER    0x01
9622 +#define XFS_DIVFLAG_COW                0x02
9623  
9624  #endif /* __XFS_DINODE_H__ */
9625 diff -NurpP --minimal linux-3.0.4/fs/xfs/xfs_fs.h linux-3.0.4-vs2.3.1/fs/xfs/xfs_fs.h
9626 --- linux-3.0.4/fs/xfs/xfs_fs.h 2011-01-05 21:50:28.000000000 +0100
9627 +++ linux-3.0.4-vs2.3.1/fs/xfs/xfs_fs.h 2011-06-10 22:11:24.000000000 +0200
9628 @@ -67,6 +67,9 @@ struct fsxattr {
9629  #define XFS_XFLAG_EXTSZINHERIT 0x00001000      /* inherit inode extent size */
9630  #define XFS_XFLAG_NODEFRAG     0x00002000      /* do not defragment */
9631  #define XFS_XFLAG_FILESTREAM   0x00004000      /* use filestream allocator */
9632 +#define XFS_XFLAG_IXUNLINK     0x00008000      /* immutable invert on unlink */
9633 +#define XFS_XFLAG_BARRIER      0x10000000      /* chroot() barrier */
9634 +#define XFS_XFLAG_COW          0x20000000      /* copy on write mark */
9635  #define XFS_XFLAG_HASATTR      0x80000000      /* no DIFLAG for this   */
9636  
9637  /*
9638 @@ -297,7 +300,8 @@ typedef struct xfs_bstat {
9639  #define        bs_projid       bs_projid_lo    /* (previously just bs_projid)  */
9640         __u16           bs_forkoff;     /* inode fork offset in bytes   */
9641         __u16           bs_projid_hi;   /* higher part of project id    */
9642 -       unsigned char   bs_pad[10];     /* pad space, unused            */
9643 +       unsigned char   bs_pad[8];      /* pad space, unused            */
9644 +       __u16           bs_tag;         /* context tagging              */
9645         __u32           bs_dmevmask;    /* DMIG event mask              */
9646         __u16           bs_dmstate;     /* DMIG state info              */
9647         __u16           bs_aextents;    /* attribute number of extents  */
9648 diff -NurpP --minimal linux-3.0.4/fs/xfs/xfs_ialloc.c linux-3.0.4-vs2.3.1/fs/xfs/xfs_ialloc.c
9649 --- linux-3.0.4/fs/xfs/xfs_ialloc.c     2011-05-22 16:17:54.000000000 +0200
9650 +++ linux-3.0.4-vs2.3.1/fs/xfs/xfs_ialloc.c     2011-06-10 22:11:24.000000000 +0200
9651 @@ -37,7 +37,6 @@
9652  #include "xfs_error.h"
9653  #include "xfs_bmap.h"
9654  
9655 -
9656  /*
9657   * Allocation group level functions.
9658   */
9659 diff -NurpP --minimal linux-3.0.4/fs/xfs/xfs_inode.c linux-3.0.4-vs2.3.1/fs/xfs/xfs_inode.c
9660 --- linux-3.0.4/fs/xfs/xfs_inode.c      2011-07-22 11:18:10.000000000 +0200
9661 +++ linux-3.0.4-vs2.3.1/fs/xfs/xfs_inode.c      2011-06-10 22:11:24.000000000 +0200
9662 @@ -243,6 +243,7 @@ xfs_inotobp(
9663         return 0;
9664  }
9665  
9666 +#include <linux/vs_tag.h>
9667  
9668  /*
9669   * This routine is called to map an inode to the buffer containing
9670 @@ -641,15 +642,25 @@ xfs_iformat_btree(
9671  STATIC void
9672  xfs_dinode_from_disk(
9673         xfs_icdinode_t          *to,
9674 -       xfs_dinode_t            *from)
9675 +       xfs_dinode_t            *from,
9676 +       int tagged)
9677  {
9678 +       uint32_t uid, gid, tag;
9679 +
9680         to->di_magic = be16_to_cpu(from->di_magic);
9681         to->di_mode = be16_to_cpu(from->di_mode);
9682         to->di_version = from ->di_version;
9683         to->di_format = from->di_format;
9684         to->di_onlink = be16_to_cpu(from->di_onlink);
9685 -       to->di_uid = be32_to_cpu(from->di_uid);
9686 -       to->di_gid = be32_to_cpu(from->di_gid);
9687 +
9688 +       uid = be32_to_cpu(from->di_uid);
9689 +       gid = be32_to_cpu(from->di_gid);
9690 +       tag = be16_to_cpu(from->di_tag);
9691 +
9692 +       to->di_uid = INOTAG_UID(tagged, uid, gid);
9693 +       to->di_gid = INOTAG_GID(tagged, uid, gid);
9694 +       to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
9695 +
9696         to->di_nlink = be32_to_cpu(from->di_nlink);
9697         to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
9698         to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
9699 @@ -671,21 +682,26 @@ xfs_dinode_from_disk(
9700         to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
9701         to->di_dmstate  = be16_to_cpu(from->di_dmstate);
9702         to->di_flags    = be16_to_cpu(from->di_flags);
9703 +       to->di_vflags   = be16_to_cpu(from->di_vflags);
9704         to->di_gen      = be32_to_cpu(from->di_gen);
9705  }
9706  
9707  void
9708  xfs_dinode_to_disk(
9709         xfs_dinode_t            *to,
9710 -       xfs_icdinode_t          *from)
9711 +       xfs_icdinode_t          *from,
9712 +       int tagged)
9713  {
9714         to->di_magic = cpu_to_be16(from->di_magic);
9715         to->di_mode = cpu_to_be16(from->di_mode);
9716         to->di_version = from ->di_version;
9717         to->di_format = from->di_format;
9718         to->di_onlink = cpu_to_be16(from->di_onlink);
9719 -       to->di_uid = cpu_to_be32(from->di_uid);
9720 -       to->di_gid = cpu_to_be32(from->di_gid);
9721 +
9722 +       to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
9723 +       to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
9724 +       to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
9725 +
9726         to->di_nlink = cpu_to_be32(from->di_nlink);
9727         to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
9728         to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
9729 @@ -707,12 +723,14 @@ xfs_dinode_to_disk(
9730         to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
9731         to->di_dmstate = cpu_to_be16(from->di_dmstate);
9732         to->di_flags = cpu_to_be16(from->di_flags);
9733 +       to->di_vflags = cpu_to_be16(from->di_vflags);
9734         to->di_gen = cpu_to_be32(from->di_gen);
9735  }
9736  
9737  STATIC uint
9738  _xfs_dic2xflags(
9739 -       __uint16_t              di_flags)
9740 +       __uint16_t              di_flags,
9741 +       __uint16_t              di_vflags)
9742  {
9743         uint                    flags = 0;
9744  
9745 @@ -723,6 +741,8 @@ _xfs_dic2xflags(
9746                         flags |= XFS_XFLAG_PREALLOC;
9747                 if (di_flags & XFS_DIFLAG_IMMUTABLE)
9748                         flags |= XFS_XFLAG_IMMUTABLE;
9749 +               if (di_flags & XFS_DIFLAG_IXUNLINK)
9750 +                       flags |= XFS_XFLAG_IXUNLINK;
9751                 if (di_flags & XFS_DIFLAG_APPEND)
9752                         flags |= XFS_XFLAG_APPEND;
9753                 if (di_flags & XFS_DIFLAG_SYNC)
9754 @@ -747,6 +767,10 @@ _xfs_dic2xflags(
9755                         flags |= XFS_XFLAG_FILESTREAM;
9756         }
9757  
9758 +       if (di_vflags & XFS_DIVFLAG_BARRIER)
9759 +               flags |= FS_BARRIER_FL;
9760 +       if (di_vflags & XFS_DIVFLAG_COW)
9761 +               flags |= FS_COW_FL;
9762         return flags;
9763  }
9764  
9765 @@ -756,7 +780,7 @@ xfs_ip2xflags(
9766  {
9767         xfs_icdinode_t          *dic = &ip->i_d;
9768  
9769 -       return _xfs_dic2xflags(dic->di_flags) |
9770 +       return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
9771                                 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
9772  }
9773  
9774 @@ -764,7 +788,8 @@ uint
9775  xfs_dic2xflags(
9776         xfs_dinode_t            *dip)
9777  {
9778 -       return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
9779 +       return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
9780 +                               be16_to_cpu(dip->di_vflags)) |
9781                                 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
9782  }
9783  
9784 @@ -797,7 +822,6 @@ xfs_iread(
9785         if (error)
9786                 return error;
9787         dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
9788 -
9789         /*
9790          * If we got something that isn't an inode it means someone
9791          * (nfs or dmi) has a stale handle.
9792 @@ -820,7 +844,8 @@ xfs_iread(
9793          * Otherwise, just get the truly permanent information.
9794          */
9795         if (dip->di_mode) {
9796 -               xfs_dinode_from_disk(&ip->i_d, dip);
9797 +               xfs_dinode_from_disk(&ip->i_d, dip,
9798 +                       mp->m_flags & XFS_MOUNT_TAGGED);
9799                 error = xfs_iformat(ip, dip);
9800                 if (error)  {
9801  #ifdef DEBUG
9802 @@ -1015,6 +1040,7 @@ xfs_ialloc(
9803         ASSERT(ip->i_d.di_nlink == nlink);
9804         ip->i_d.di_uid = current_fsuid();
9805         ip->i_d.di_gid = current_fsgid();
9806 +       ip->i_d.di_tag = current_fstag(&ip->i_vnode);
9807         xfs_set_projid(ip, prid);
9808         memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
9809  
9810 @@ -1075,6 +1101,7 @@ xfs_ialloc(
9811         ip->i_d.di_dmevmask = 0;
9812         ip->i_d.di_dmstate = 0;
9813         ip->i_d.di_flags = 0;
9814 +       ip->i_d.di_vflags = 0;
9815         flags = XFS_ILOG_CORE;
9816         switch (mode & S_IFMT) {
9817         case S_IFIFO:
9818 @@ -2108,6 +2135,7 @@ xfs_ifree(
9819         }
9820         ip->i_d.di_mode = 0;            /* mark incore inode as free */
9821         ip->i_d.di_flags = 0;
9822 +       ip->i_d.di_vflags = 0;
9823         ip->i_d.di_dmevmask = 0;
9824         ip->i_d.di_forkoff = 0;         /* mark the attr fork not in use */
9825         ip->i_df.if_ext_max =
9826 @@ -2987,7 +3015,8 @@ xfs_iflush_int(
9827          * because if the inode is dirty at all the core must
9828          * be.
9829          */
9830 -       xfs_dinode_to_disk(dip, &ip->i_d);
9831 +       xfs_dinode_to_disk(dip, &ip->i_d,
9832 +               mp->m_flags & XFS_MOUNT_TAGGED);
9833  
9834         /* Wrap, we never let the log put out DI_MAX_FLUSH */
9835         if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
9836 diff -NurpP --minimal linux-3.0.4/fs/xfs/xfs_inode.h linux-3.0.4-vs2.3.1/fs/xfs/xfs_inode.h
9837 --- linux-3.0.4/fs/xfs/xfs_inode.h      2011-07-22 11:18:10.000000000 +0200
9838 +++ linux-3.0.4-vs2.3.1/fs/xfs/xfs_inode.h      2011-07-01 11:35:35.000000000 +0200
9839 @@ -135,7 +135,9 @@ typedef struct xfs_icdinode {
9840         __uint32_t      di_nlink;       /* number of links to file */
9841         __uint16_t      di_projid_lo;   /* lower part of owner's project id */
9842         __uint16_t      di_projid_hi;   /* higher part of owner's project id */
9843 -       __uint8_t       di_pad[6];      /* unused, zeroed space */
9844 +       __uint8_t       di_pad[2];      /* unused, zeroed space */
9845 +       __uint16_t      di_tag;         /* context tagging */
9846 +       __uint16_t      di_vflags;      /* vserver specific flags */
9847         __uint16_t      di_flushiter;   /* incremented on flush */
9848         xfs_ictimestamp_t di_atime;     /* time last accessed */
9849         xfs_ictimestamp_t di_mtime;     /* time last modified */
9850 @@ -546,7 +548,7 @@ int         xfs_itobp(struct xfs_mount *, struc
9851  int            xfs_iread(struct xfs_mount *, struct xfs_trans *,
9852                           struct xfs_inode *, uint);
9853  void           xfs_dinode_to_disk(struct xfs_dinode *,
9854 -                                  struct xfs_icdinode *);
9855 +                                  struct xfs_icdinode *, int);
9856  void           xfs_idestroy_fork(struct xfs_inode *, int);
9857  void           xfs_idata_realloc(struct xfs_inode *, int, int);
9858  void           xfs_iroot_realloc(struct xfs_inode *, int, int);
9859 diff -NurpP --minimal linux-3.0.4/fs/xfs/xfs_itable.c linux-3.0.4-vs2.3.1/fs/xfs/xfs_itable.c
9860 --- linux-3.0.4/fs/xfs/xfs_itable.c     2011-05-22 16:17:54.000000000 +0200
9861 +++ linux-3.0.4-vs2.3.1/fs/xfs/xfs_itable.c     2011-06-10 22:11:24.000000000 +0200
9862 @@ -98,6 +98,7 @@ xfs_bulkstat_one_int(
9863         buf->bs_mode = dic->di_mode;
9864         buf->bs_uid = dic->di_uid;
9865         buf->bs_gid = dic->di_gid;
9866 +       buf->bs_tag = dic->di_tag;
9867         buf->bs_size = dic->di_size;
9868  
9869         /*
9870 diff -NurpP --minimal linux-3.0.4/fs/xfs/xfs_log_recover.c linux-3.0.4-vs2.3.1/fs/xfs/xfs_log_recover.c
9871 --- linux-3.0.4/fs/xfs/xfs_log_recover.c        2011-07-22 11:18:10.000000000 +0200
9872 +++ linux-3.0.4-vs2.3.1/fs/xfs/xfs_log_recover.c        2011-06-10 22:11:24.000000000 +0200
9873 @@ -2343,7 +2343,8 @@ xlog_recover_inode_pass2(
9874         }
9875  
9876         /* The core is in in-core format */
9877 -       xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr);
9878 +       xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr,
9879 +               mp->m_flags & XFS_MOUNT_TAGGED);
9880  
9881         /* the rest is in on-disk format */
9882         if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
9883 diff -NurpP --minimal linux-3.0.4/fs/xfs/xfs_mount.h linux-3.0.4-vs2.3.1/fs/xfs/xfs_mount.h
9884 --- linux-3.0.4/fs/xfs/xfs_mount.h      2011-07-22 11:18:10.000000000 +0200
9885 +++ linux-3.0.4-vs2.3.1/fs/xfs/xfs_mount.h      2011-06-10 22:11:24.000000000 +0200
9886 @@ -249,6 +249,7 @@ typedef struct xfs_mount {
9887                                                    allocator */
9888  #define XFS_MOUNT_NOATTR2      (1ULL << 25)    /* disable use of attr2 format */
9889  
9890 +#define XFS_MOUNT_TAGGED       (1ULL << 31)    /* context tagging */
9891  
9892  /*
9893   * Default minimum read and write sizes.
9894 diff -NurpP --minimal linux-3.0.4/fs/xfs/xfs_vnodeops.c linux-3.0.4-vs2.3.1/fs/xfs/xfs_vnodeops.c
9895 --- linux-3.0.4/fs/xfs/xfs_vnodeops.c   2011-07-22 11:18:10.000000000 +0200
9896 +++ linux-3.0.4-vs2.3.1/fs/xfs/xfs_vnodeops.c   2011-07-01 11:35:35.000000000 +0200
9897 @@ -50,6 +50,78 @@
9898  #include "xfs_vnodeops.h"
9899  #include "xfs_trace.h"
9900  
9901 +
9902 +STATIC void
9903 +xfs_get_inode_flags(
9904 +       xfs_inode_t     *ip)
9905 +{
9906 +       struct inode    *inode = VFS_I(ip);
9907 +       unsigned int    flags = inode->i_flags;
9908 +       unsigned int    vflags = inode->i_vflags;
9909 +
9910 +       if (flags & S_IMMUTABLE)
9911 +               ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
9912 +       else
9913 +               ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
9914 +       if (flags & S_IXUNLINK)
9915 +               ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
9916 +       else
9917 +               ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
9918 +
9919 +       if (vflags & V_BARRIER)
9920 +               ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
9921 +       else
9922 +               ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
9923 +       if (vflags & V_COW)
9924 +               ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
9925 +       else
9926 +               ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
9927 +}
9928 +
9929 +int
9930 +xfs_sync_flags(
9931 +       struct inode            *inode,
9932 +       int                     flags,
9933 +       int                     vflags)
9934 +{
9935 +       struct xfs_inode        *ip = XFS_I(inode);
9936 +       struct xfs_mount        *mp = ip->i_mount;
9937 +       struct xfs_trans        *tp;
9938 +       unsigned int            lock_flags = 0;
9939 +       int                     code;
9940 +
9941 +       tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
9942 +       code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
9943 +       if (code)
9944 +               goto error_out;
9945 +
9946 +       xfs_ilock(ip, XFS_ILOCK_EXCL);
9947 +
9948 +       xfs_trans_ijoin(tp, ip);
9949 +
9950 +       inode->i_flags = flags;
9951 +       inode->i_vflags = vflags;
9952 +       xfs_get_inode_flags(ip);
9953 +
9954 +       xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
9955 +       xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
9956 +
9957 +       XFS_STATS_INC(xs_ig_attrchg);
9958 +
9959 +       if (mp->m_flags & XFS_MOUNT_WSYNC)
9960 +               xfs_trans_set_sync(tp);
9961 +       code = xfs_trans_commit(tp, 0);
9962 +       xfs_iunlock(ip, XFS_ILOCK_EXCL);
9963 +       return code;
9964 +
9965 +error_out:
9966 +       xfs_trans_cancel(tp, 0);
9967 +       if (lock_flags)
9968 +               xfs_iunlock(ip, XFS_ILOCK_EXCL);
9969 +       return code;
9970 +}
9971 +
9972 +
9973  int
9974  xfs_setattr(
9975         struct xfs_inode        *ip,
9976 @@ -65,6 +137,7 @@ xfs_setattr(
9977         uint                    commit_flags=0;
9978         uid_t                   uid=0, iuid=0;
9979         gid_t                   gid=0, igid=0;
9980 +       tag_t                   tag=0, itag=0;
9981         struct xfs_dquot        *udqp, *gdqp, *olddquot1, *olddquot2;
9982         int                     need_iolock = 1;
9983  
9984 @@ -147,7 +220,7 @@ xfs_setattr(
9985         /*
9986          * Change file ownership.  Must be the owner or privileged.
9987          */
9988 -       if (mask & (ATTR_UID|ATTR_GID)) {
9989 +       if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
9990                 /*
9991                  * These IDs could have changed since we last looked at them.
9992                  * But, we're assured that if the ownership did change
9993 @@ -156,8 +229,10 @@ xfs_setattr(
9994                  */
9995                 iuid = ip->i_d.di_uid;
9996                 igid = ip->i_d.di_gid;
9997 +               itag = ip->i_d.di_tag;
9998                 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
9999                 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
10000 +               tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
10001  
10002                 /*
10003                  * Do a quota reservation only if uid/gid is actually
10004 @@ -165,7 +240,8 @@ xfs_setattr(
10005                  */
10006                 if (XFS_IS_QUOTA_RUNNING(mp) &&
10007                     ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
10008 -                    (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {
10009 +                    (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
10010 +                    (XFS_IS_GQUOTA_ON(mp) && itag != tag))) {
10011                         ASSERT(tp);
10012                         code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp,
10013                                                 capable(CAP_FOWNER) ?
10014 @@ -329,7 +405,7 @@ xfs_setattr(
10015         /*
10016          * Change file ownership.  Must be the owner or privileged.
10017          */
10018 -       if (mask & (ATTR_UID|ATTR_GID)) {
10019 +       if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
10020                 /*
10021                  * CAP_FSETID overrides the following restrictions:
10022                  *
10023 @@ -345,6 +421,10 @@ xfs_setattr(
10024                  * Change the ownerships and register quota modifications
10025                  * in the transaction.
10026                  */
10027 +               if (itag != tag) {
10028 +                       ip->i_d.di_tag = tag;
10029 +                       inode->i_tag = tag;
10030 +               }
10031                 if (iuid != uid) {
10032                         if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {
10033                                 ASSERT(mask & ATTR_UID);
10034 diff -NurpP --minimal linux-3.0.4/fs/xfs/xfs_vnodeops.h linux-3.0.4-vs2.3.1/fs/xfs/xfs_vnodeops.h
10035 --- linux-3.0.4/fs/xfs/xfs_vnodeops.h   2011-05-22 16:17:54.000000000 +0200
10036 +++ linux-3.0.4-vs2.3.1/fs/xfs/xfs_vnodeops.h   2011-06-10 22:11:24.000000000 +0200
10037 @@ -13,6 +13,7 @@ struct xfs_inode;
10038  struct xfs_iomap;
10039  
10040  
10041 +int xfs_sync_xflags(struct xfs_inode *ip);
10042  int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags);
10043  #define        XFS_ATTR_DMI            0x01    /* invocation from a DMI function */
10044  #define        XFS_ATTR_NONBLOCK       0x02    /* return EAGAIN if operation would block */
10045 diff -NurpP --minimal linux-3.0.4/include/asm-generic/tlb.h linux-3.0.4-vs2.3.1/include/asm-generic/tlb.h
10046 --- linux-3.0.4/include/asm-generic/tlb.h       2011-07-22 11:18:10.000000000 +0200
10047 +++ linux-3.0.4-vs2.3.1/include/asm-generic/tlb.h       2011-06-10 22:11:24.000000000 +0200
10048 @@ -16,6 +16,7 @@
10049  #define _ASM_GENERIC__TLB_H
10050  
10051  #include <linux/swap.h>
10052 +#include <linux/vs_memory.h>
10053  #include <asm/pgalloc.h>
10054  #include <asm/tlbflush.h>
10055  
10056 diff -NurpP --minimal linux-3.0.4/include/linux/Kbuild linux-3.0.4-vs2.3.1/include/linux/Kbuild
10057 --- linux-3.0.4/include/linux/Kbuild    2011-07-22 11:18:10.000000000 +0200
10058 +++ linux-3.0.4-vs2.3.1/include/linux/Kbuild    2011-06-10 22:11:24.000000000 +0200
10059 @@ -17,6 +17,7 @@ header-y += netfilter_bridge/
10060  header-y += netfilter_ipv4/
10061  header-y += netfilter_ipv6/
10062  header-y += usb/
10063 +header-y += vserver/
10064  header-y += wimax/
10065  
10066  objhdr-y += version.h
10067 diff -NurpP --minimal linux-3.0.4/include/linux/capability.h linux-3.0.4-vs2.3.1/include/linux/capability.h
10068 --- linux-3.0.4/include/linux/capability.h      2011-07-22 11:18:10.000000000 +0200
10069 +++ linux-3.0.4-vs2.3.1/include/linux/capability.h      2011-06-10 22:11:24.000000000 +0200
10070 @@ -279,6 +279,7 @@ struct cpu_vfs_cap_data {
10071     arbitrary SCSI commands */
10072  /* Allow setting encryption key on loopback filesystem */
10073  /* Allow setting zone reclaim policy */
10074 +/* Allow the selection of a security context */
10075  
10076  #define CAP_SYS_ADMIN        21
10077  
10078 @@ -362,7 +363,12 @@ struct cpu_vfs_cap_data {
10079  
10080  #define CAP_LAST_CAP         CAP_WAKE_ALARM
10081  
10082 -#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
10083 +/* Allow context manipulations */
10084 +/* Allow changing context info on files */
10085 +
10086 +#define CAP_CONTEXT         63
10087 +
10088 +#define cap_valid(x) ((x) >= 0 && ((x) <= CAP_LAST_CAP || (x) == CAP_CONTEXT))
10089  
10090  /*
10091   * Bit location of each capability (used by user-space library and kernel)
10092 diff -NurpP --minimal linux-3.0.4/include/linux/cred.h linux-3.0.4-vs2.3.1/include/linux/cred.h
10093 --- linux-3.0.4/include/linux/cred.h    2011-07-22 11:18:10.000000000 +0200
10094 +++ linux-3.0.4-vs2.3.1/include/linux/cred.h    2011-06-10 22:11:24.000000000 +0200
10095 @@ -156,6 +156,7 @@ extern void exit_creds(struct task_struc
10096  extern int copy_creds(struct task_struct *, unsigned long);
10097  extern const struct cred *get_task_cred(struct task_struct *);
10098  extern struct cred *cred_alloc_blank(void);
10099 +extern struct cred *__prepare_creds(const struct cred *);
10100  extern struct cred *prepare_creds(void);
10101  extern struct cred *prepare_exec_creds(void);
10102  extern int commit_creds(struct cred *);
10103 @@ -209,6 +210,31 @@ static inline void validate_process_cred
10104  }
10105  #endif
10106  
10107 +static inline void set_cred_subscribers(struct cred *cred, int n)
10108 +{
10109 +#ifdef CONFIG_DEBUG_CREDENTIALS
10110 +       atomic_set(&cred->subscribers, n);
10111 +#endif
10112 +}
10113 +
10114 +static inline int read_cred_subscribers(const struct cred *cred)
10115 +{
10116 +#ifdef CONFIG_DEBUG_CREDENTIALS
10117 +       return atomic_read(&cred->subscribers);
10118 +#else
10119 +       return 0;
10120 +#endif
10121 +}
10122 +
10123 +static inline void alter_cred_subscribers(const struct cred *_cred, int n)
10124 +{
10125 +#ifdef CONFIG_DEBUG_CREDENTIALS
10126 +       struct cred *cred = (struct cred *) _cred;
10127 +
10128 +       atomic_add(n, &cred->subscribers);
10129 +#endif
10130 +}
10131 +
10132  /**
10133   * get_new_cred - Get a reference on a new set of credentials
10134   * @cred: The new credentials to reference
10135 diff -NurpP --minimal linux-3.0.4/include/linux/devpts_fs.h linux-3.0.4-vs2.3.1/include/linux/devpts_fs.h
10136 --- linux-3.0.4/include/linux/devpts_fs.h       2008-12-25 00:26:37.000000000 +0100
10137 +++ linux-3.0.4-vs2.3.1/include/linux/devpts_fs.h       2011-06-10 22:11:24.000000000 +0200
10138 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
10139  
10140  #endif
10141  
10142 -
10143  #endif /* _LINUX_DEVPTS_FS_H */
10144 diff -NurpP --minimal linux-3.0.4/include/linux/ext2_fs.h linux-3.0.4-vs2.3.1/include/linux/ext2_fs.h
10145 --- linux-3.0.4/include/linux/ext2_fs.h 2010-02-25 11:52:07.000000000 +0100
10146 +++ linux-3.0.4-vs2.3.1/include/linux/ext2_fs.h 2011-06-10 22:11:24.000000000 +0200
10147 @@ -189,8 +189,12 @@ struct ext2_group_desc
10148  #define EXT2_NOTAIL_FL                 FS_NOTAIL_FL    /* file tail should not be merged */
10149  #define EXT2_DIRSYNC_FL                        FS_DIRSYNC_FL   /* dirsync behaviour (directories only) */
10150  #define EXT2_TOPDIR_FL                 FS_TOPDIR_FL    /* Top of directory hierarchies*/
10151 +#define EXT2_IXUNLINK_FL               FS_IXUNLINK_FL  /* Immutable invert on unlink */
10152  #define EXT2_RESERVED_FL               FS_RESERVED_FL  /* reserved for ext2 lib */
10153  
10154 +#define EXT2_BARRIER_FL                        FS_BARRIER_FL   /* Barrier for chroot() */
10155 +#define EXT2_COW_FL                    FS_COW_FL       /* Copy on Write marker */
10156 +
10157  #define EXT2_FL_USER_VISIBLE           FS_FL_USER_VISIBLE      /* User visible flags */
10158  #define EXT2_FL_USER_MODIFIABLE                FS_FL_USER_MODIFIABLE   /* User modifiable flags */
10159  
10160 @@ -274,7 +278,8 @@ struct ext2_inode {
10161                         __u16   i_pad1;
10162                         __le16  l_i_uid_high;   /* these 2 fields    */
10163                         __le16  l_i_gid_high;   /* were reserved2[0] */
10164 -                       __u32   l_i_reserved2;
10165 +                       __le16  l_i_tag;        /* Context Tag */
10166 +                       __u16   l_i_reserved2;
10167                 } linux2;
10168                 struct {
10169                         __u8    h_i_frag;       /* Fragment number */
10170 @@ -303,6 +308,7 @@ struct ext2_inode {
10171  #define i_gid_low      i_gid
10172  #define i_uid_high     osd2.linux2.l_i_uid_high
10173  #define i_gid_high     osd2.linux2.l_i_gid_high
10174 +#define i_raw_tag      osd2.linux2.l_i_tag
10175  #define i_reserved2    osd2.linux2.l_i_reserved2
10176  #endif
10177  
10178 @@ -347,6 +353,7 @@ struct ext2_inode {
10179  #define EXT2_MOUNT_USRQUOTA            0x020000  /* user quota */
10180  #define EXT2_MOUNT_GRPQUOTA            0x040000  /* group quota */
10181  #define EXT2_MOUNT_RESERVATION         0x080000  /* Preallocation */
10182 +#define EXT2_MOUNT_TAGGED              (1<<24)   /* Enable Context Tags */
10183  
10184  
10185  #define clear_opt(o, opt)              o &= ~EXT2_MOUNT_##opt
10186 diff -NurpP --minimal linux-3.0.4/include/linux/ext3_fs.h linux-3.0.4-vs2.3.1/include/linux/ext3_fs.h
10187 --- linux-3.0.4/include/linux/ext3_fs.h 2011-07-22 11:18:10.000000000 +0200
10188 +++ linux-3.0.4-vs2.3.1/include/linux/ext3_fs.h 2011-06-10 22:11:24.000000000 +0200
10189 @@ -173,10 +173,14 @@ struct ext3_group_desc
10190  #define EXT3_NOTAIL_FL                 0x00008000 /* file tail should not be merged */
10191  #define EXT3_DIRSYNC_FL                        0x00010000 /* dirsync behaviour (directories only) */
10192  #define EXT3_TOPDIR_FL                 0x00020000 /* Top of directory hierarchies*/
10193 +#define EXT3_IXUNLINK_FL               0x08000000 /* Immutable invert on unlink */
10194  #define EXT3_RESERVED_FL               0x80000000 /* reserved for ext3 lib */
10195  
10196 -#define EXT3_FL_USER_VISIBLE           0x0003DFFF /* User visible flags */
10197 -#define EXT3_FL_USER_MODIFIABLE                0x000380FF /* User modifiable flags */
10198 +#define EXT3_BARRIER_FL                        0x04000000 /* Barrier for chroot() */
10199 +#define EXT3_COW_FL                    0x20000000 /* Copy on Write marker */
10200 +
10201 +#define EXT3_FL_USER_VISIBLE           0x0103DFFF /* User visible flags */
10202 +#define EXT3_FL_USER_MODIFIABLE                0x010380FF /* User modifiable flags */
10203  
10204  /* Flags that should be inherited by new inodes from their parent. */
10205  #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
10206 @@ -312,7 +316,8 @@ struct ext3_inode {
10207                         __u16   i_pad1;
10208                         __le16  l_i_uid_high;   /* these 2 fields    */
10209                         __le16  l_i_gid_high;   /* were reserved2[0] */
10210 -                       __u32   l_i_reserved2;
10211 +                       __le16  l_i_tag;        /* Context Tag */
10212 +                       __u16   l_i_reserved2;
10213                 } linux2;
10214                 struct {
10215                         __u8    h_i_frag;       /* Fragment number */
10216 @@ -343,6 +348,7 @@ struct ext3_inode {
10217  #define i_gid_low      i_gid
10218  #define i_uid_high     osd2.linux2.l_i_uid_high
10219  #define i_gid_high     osd2.linux2.l_i_gid_high
10220 +#define i_raw_tag      osd2.linux2.l_i_tag
10221  #define i_reserved2    osd2.linux2.l_i_reserved2
10222  
10223  #elif defined(__GNU__)
10224 @@ -405,6 +411,7 @@ struct ext3_inode {
10225  #define EXT3_MOUNT_GRPQUOTA            0x200000 /* "old" group quota */
10226  #define EXT3_MOUNT_DATA_ERR_ABORT      0x400000 /* Abort on file data write
10227                                                   * error in ordered mode */
10228 +#define EXT3_MOUNT_TAGGED              (1<<24) /* Enable Context Tags */
10229  
10230  /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
10231  #ifndef _LINUX_EXT2_FS_H
10232 @@ -919,6 +926,7 @@ extern void ext3_get_inode_flags(struct 
10233  extern void ext3_set_aops(struct inode *inode);
10234  extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
10235                        u64 start, u64 len);
10236 +extern int ext3_sync_flags(struct inode *, int, int);
10237  
10238  /* ioctl.c */
10239  extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
10240 diff -NurpP --minimal linux-3.0.4/include/linux/fs.h linux-3.0.4-vs2.3.1/include/linux/fs.h
10241 --- linux-3.0.4/include/linux/fs.h      2011-07-22 11:18:10.000000000 +0200
10242 +++ linux-3.0.4-vs2.3.1/include/linux/fs.h      2011-07-01 11:35:35.000000000 +0200
10243 @@ -208,6 +208,9 @@ struct inodes_stat_t {
10244  #define MS_KERNMOUNT   (1<<22) /* this is a kern_mount call */
10245  #define MS_I_VERSION   (1<<23) /* Update inode I_version field */
10246  #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
10247 +#define MS_TAGGED      (1<<25) /* use generic inode tagging */
10248 +#define MS_TAGID       (1<<26) /* use specific tag for this mount */
10249 +#define MS_NOTAGCHECK  (1<<27) /* don't check tags */
10250  #define MS_NOSEC       (1<<28)
10251  #define MS_BORN                (1<<29)
10252  #define MS_ACTIVE      (1<<30)
10253 @@ -239,6 +242,14 @@ struct inodes_stat_t {
10254  #define S_IMA          1024    /* Inode has an associated IMA struct */
10255  #define S_AUTOMOUNT    2048    /* Automount/referral quasi-directory */
10256  #define S_NOSEC                4096    /* no suid or xattr security attributes */
10257 +#define S_IXUNLINK     8192    /* Immutable Invert on unlink */
10258 +
10259 +/* Linux-VServer related Inode flags */
10260 +
10261 +#define V_VALID                1
10262 +#define V_XATTR                2
10263 +#define V_BARRIER      4       /* Barrier for chroot() */
10264 +#define V_COW          8       /* Copy on Write */
10265  
10266  /*
10267   * Note that nosuid etc flags are inode-specific: setting some file-system
10268 @@ -261,12 +272,15 @@ struct inodes_stat_t {
10269  #define IS_DIRSYNC(inode)      (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
10270                                         ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
10271  #define IS_MANDLOCK(inode)     __IS_FLG(inode, MS_MANDLOCK)
10272 -#define IS_NOATIME(inode)   __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
10273 -#define IS_I_VERSION(inode)   __IS_FLG(inode, MS_I_VERSION)
10274 +#define IS_NOATIME(inode)      __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
10275 +#define IS_I_VERSION(inode)    __IS_FLG(inode, MS_I_VERSION)
10276 +#define IS_TAGGED(inode)       __IS_FLG(inode, MS_TAGGED)
10277  
10278  #define IS_NOQUOTA(inode)      ((inode)->i_flags & S_NOQUOTA)
10279  #define IS_APPEND(inode)       ((inode)->i_flags & S_APPEND)
10280  #define IS_IMMUTABLE(inode)    ((inode)->i_flags & S_IMMUTABLE)
10281 +#define IS_IXUNLINK(inode)     ((inode)->i_flags & S_IXUNLINK)
10282 +#define IS_IXORUNLINK(inode)   ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
10283  #define IS_POSIXACL(inode)     __IS_FLG(inode, MS_POSIXACL)
10284  
10285  #define IS_DEADDIR(inode)      ((inode)->i_flags & S_DEAD)
10286 @@ -277,6 +291,16 @@ struct inodes_stat_t {
10287  #define IS_AUTOMOUNT(inode)    ((inode)->i_flags & S_AUTOMOUNT)
10288  #define IS_NOSEC(inode)                ((inode)->i_flags & S_NOSEC)
10289  
10290 +#define IS_BARRIER(inode)      (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
10291 +
10292 +#ifdef CONFIG_VSERVER_COWBL
10293 +#  define IS_COW(inode)                (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
10294 +#  define IS_COW_LINK(inode)   (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
10295 +#else
10296 +#  define IS_COW(inode)                (0)
10297 +#  define IS_COW_LINK(inode)   (0)
10298 +#endif
10299 +
10300  /* the read-only stuff doesn't really belong here, but any other place is
10301     probably as bad and I don't want to create yet another include file. */
10302  
10303 @@ -362,11 +386,14 @@ struct inodes_stat_t {
10304  #define FS_EXTENT_FL                   0x00080000 /* Extents */
10305  #define FS_DIRECTIO_FL                 0x00100000 /* Use direct i/o */
10306  #define FS_NOCOW_FL                    0x00800000 /* Do not cow file */
10307 +#define FS_IXUNLINK_FL                 0x08000000 /* Immutable invert on unlink */
10308  #define FS_RESERVED_FL                 0x80000000 /* reserved for ext2 lib */
10309  
10310 -#define FS_FL_USER_VISIBLE             0x0003DFFF /* User visible flags */
10311 -#define FS_FL_USER_MODIFIABLE          0x000380FF /* User modifiable flags */
10312 -
10313 +#define FS_BARRIER_FL                  0x04000000 /* Barrier for chroot() */
10314 +#define FS_COW_FL                      0x20000000 /* Copy on Write marker */
10315 +
10316 +#define FS_FL_USER_VISIBLE             0x0103DFFF /* User visible flags */
10317 +#define FS_FL_USER_MODIFIABLE          0x010380FF /* User modifiable flags */
10318  
10319  #define SYNC_FILE_RANGE_WAIT_BEFORE    1
10320  #define SYNC_FILE_RANGE_WRITE          2
10321 @@ -447,6 +474,7 @@ typedef void (dio_iodone_t)(struct kiocb
10322  #define ATTR_KILL_PRIV (1 << 14)
10323  #define ATTR_OPEN      (1 << 15) /* Truncating from open(O_TRUNC) */
10324  #define ATTR_TIMES_SET (1 << 16)
10325 +#define ATTR_TAG       (1 << 17)
10326  
10327  /*
10328   * This is the Inode Attributes structure, used for notify_change().  It
10329 @@ -462,6 +490,7 @@ struct iattr {
10330         umode_t         ia_mode;
10331         uid_t           ia_uid;
10332         gid_t           ia_gid;
10333 +       tag_t           ia_tag;
10334         loff_t          ia_size;
10335         struct timespec ia_atime;
10336         struct timespec ia_mtime;
10337 @@ -475,6 +504,9 @@ struct iattr {
10338         struct file     *ia_file;
10339  };
10340  
10341 +#define ATTR_FLAG_BARRIER      512     /* Barrier for chroot() */
10342 +#define ATTR_FLAG_IXUNLINK     1024    /* Immutable invert on unlink */
10343 +
10344  /*
10345   * Includes for diskquotas.
10346   */
10347 @@ -740,11 +772,13 @@ struct inode {
10348         umode_t                 i_mode;
10349         uid_t                   i_uid;
10350         gid_t                   i_gid;
10351 +       tag_t                   i_tag;
10352         const struct inode_operations   *i_op;
10353         struct super_block      *i_sb;
10354  
10355         spinlock_t              i_lock; /* i_blocks, i_bytes, maybe i_size */
10356 -       unsigned int            i_flags;
10357 +       unsigned short          i_flags;
10358 +       unsigned short          i_vflags;
10359         unsigned long           i_state;
10360  #ifdef CONFIG_SECURITY
10361         void                    *i_security;
10362 @@ -766,6 +800,7 @@ struct inode {
10363         atomic_t                i_count;
10364         unsigned int            i_nlink;
10365         dev_t                   i_rdev;
10366 +       dev_t                   i_mdev;
10367         unsigned int            i_blkbits;
10368         u64                     i_version;
10369         loff_t                  i_size;
10370 @@ -890,12 +925,12 @@ static inline void i_size_write(struct i
10371  
10372  static inline unsigned iminor(const struct inode *inode)
10373  {
10374 -       return MINOR(inode->i_rdev);
10375 +       return MINOR(inode->i_mdev);
10376  }
10377  
10378  static inline unsigned imajor(const struct inode *inode)
10379  {
10380 -       return MAJOR(inode->i_rdev);
10381 +       return MAJOR(inode->i_mdev);
10382  }
10383  
10384  extern struct block_device *I_BDEV(struct inode *inode);
10385 @@ -957,6 +992,7 @@ struct file {
10386         loff_t                  f_pos;
10387         struct fown_struct      f_owner;
10388         const struct cred       *f_cred;
10389 +       xid_t                   f_xid;
10390         struct file_ra_state    f_ra;
10391  
10392         u64                     f_version;
10393 @@ -1101,6 +1137,7 @@ struct file_lock {
10394         struct file *fl_file;
10395         loff_t fl_start;
10396         loff_t fl_end;
10397 +       xid_t fl_xid;
10398  
10399         struct fasync_struct *  fl_fasync; /* for lease break notifications */
10400         unsigned long fl_break_time;    /* for nonblocking lease breaks */
10401 @@ -1600,6 +1637,7 @@ struct inode_operations {
10402         ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
10403         ssize_t (*listxattr) (struct dentry *, char *, size_t);
10404         int (*removexattr) (struct dentry *, const char *);
10405 +       int (*sync_flags) (struct inode *, int, int);
10406         void (*truncate_range)(struct inode *, loff_t, loff_t);
10407         int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
10408                       u64 len);
10409 @@ -1618,6 +1656,7 @@ extern ssize_t vfs_readv(struct file *, 
10410                 unsigned long, loff_t *);
10411  extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
10412                 unsigned long, loff_t *);
10413 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
10414  
10415  struct super_operations {
10416         struct inode *(*alloc_inode)(struct super_block *sb);
10417 @@ -2437,6 +2476,7 @@ extern int dcache_dir_open(struct inode 
10418  extern int dcache_dir_close(struct inode *, struct file *);
10419  extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
10420  extern int dcache_readdir(struct file *, void *, filldir_t);
10421 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
10422  extern int simple_setattr(struct dentry *, struct iattr *);
10423  extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
10424  extern int simple_statfs(struct dentry *, struct kstatfs *);
10425 diff -NurpP --minimal linux-3.0.4/include/linux/gfs2_ondisk.h linux-3.0.4-vs2.3.1/include/linux/gfs2_ondisk.h
10426 --- linux-3.0.4/include/linux/gfs2_ondisk.h     2010-07-07 18:31:55.000000000 +0200
10427 +++ linux-3.0.4-vs2.3.1/include/linux/gfs2_ondisk.h     2011-06-10 22:11:24.000000000 +0200
10428 @@ -211,6 +211,9 @@ enum {
10429         gfs2fl_NoAtime          = 7,
10430         gfs2fl_Sync             = 8,
10431         gfs2fl_System           = 9,
10432 +       gfs2fl_IXUnlink         = 16,
10433 +       gfs2fl_Barrier          = 17,
10434 +       gfs2fl_Cow              = 18,
10435         gfs2fl_TruncInProg      = 29,
10436         gfs2fl_InheritDirectio  = 30,
10437         gfs2fl_InheritJdata     = 31,
10438 @@ -227,6 +230,9 @@ enum {
10439  #define GFS2_DIF_NOATIME               0x00000080
10440  #define GFS2_DIF_SYNC                  0x00000100
10441  #define GFS2_DIF_SYSTEM                        0x00000200 /* New in gfs2 */
10442 +#define GFS2_DIF_IXUNLINK              0x00010000
10443 +#define GFS2_DIF_BARRIER               0x00020000
10444 +#define GFS2_DIF_COW                   0x00040000
10445  #define GFS2_DIF_TRUNC_IN_PROG         0x20000000 /* New in gfs2 */
10446  #define GFS2_DIF_INHERIT_DIRECTIO      0x40000000
10447  #define GFS2_DIF_INHERIT_JDATA         0x80000000
10448 diff -NurpP --minimal linux-3.0.4/include/linux/if_tun.h linux-3.0.4-vs2.3.1/include/linux/if_tun.h
10449 --- linux-3.0.4/include/linux/if_tun.h  2010-08-02 16:52:54.000000000 +0200
10450 +++ linux-3.0.4-vs2.3.1/include/linux/if_tun.h  2011-06-10 22:11:24.000000000 +0200
10451 @@ -53,6 +53,7 @@
10452  #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
10453  #define TUNGETVNETHDRSZ _IOR('T', 215, int)
10454  #define TUNSETVNETHDRSZ _IOW('T', 216, int)
10455 +#define TUNSETNID     _IOW('T', 217, int)
10456  
10457  /* TUNSETIFF ifr flags */
10458  #define IFF_TUN                0x0001
10459 diff -NurpP --minimal linux-3.0.4/include/linux/init_task.h linux-3.0.4-vs2.3.1/include/linux/init_task.h
10460 --- linux-3.0.4/include/linux/init_task.h       2011-07-22 11:18:10.000000000 +0200
10461 +++ linux-3.0.4-vs2.3.1/include/linux/init_task.h       2011-06-10 22:11:24.000000000 +0200
10462 @@ -193,6 +193,10 @@ extern struct cred init_cred;
10463         INIT_FTRACE_GRAPH                                               \
10464         INIT_TRACE_RECURSION                                            \
10465         INIT_TASK_RCU_PREEMPT(tsk)                                      \
10466 +       .xid            = 0,                                            \
10467 +       .vx_info        = NULL,                                         \
10468 +       .nid            = 0,                                            \
10469 +       .nx_info        = NULL,                                         \
10470  }
10471  
10472  
10473 diff -NurpP --minimal linux-3.0.4/include/linux/ipc.h linux-3.0.4-vs2.3.1/include/linux/ipc.h
10474 --- linux-3.0.4/include/linux/ipc.h     2009-12-03 20:02:55.000000000 +0100
10475 +++ linux-3.0.4-vs2.3.1/include/linux/ipc.h     2011-06-10 22:11:24.000000000 +0200
10476 @@ -91,6 +91,7 @@ struct kern_ipc_perm
10477         key_t           key;
10478         uid_t           uid;
10479         gid_t           gid;
10480 +       xid_t           xid;
10481         uid_t           cuid;
10482         gid_t           cgid;
10483         mode_t          mode; 
10484 diff -NurpP --minimal linux-3.0.4/include/linux/ipc_namespace.h linux-3.0.4-vs2.3.1/include/linux/ipc_namespace.h
10485 --- linux-3.0.4/include/linux/ipc_namespace.h   2011-05-22 16:17:55.000000000 +0200
10486 +++ linux-3.0.4-vs2.3.1/include/linux/ipc_namespace.h   2011-06-13 14:09:44.000000000 +0200
10487 @@ -94,7 +94,8 @@ static inline int mq_init_ns(struct ipc_
10488  
10489  #if defined(CONFIG_IPC_NS)
10490  extern struct ipc_namespace *copy_ipcs(unsigned long flags,
10491 -                                      struct task_struct *tsk);
10492 +                                      struct ipc_namespace *old_ns,
10493 +                                      struct user_namespace *user_ns);
10494  static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
10495  {
10496         if (ns)
10497 @@ -105,12 +106,13 @@ static inline struct ipc_namespace *get_
10498  extern void put_ipc_ns(struct ipc_namespace *ns);
10499  #else
10500  static inline struct ipc_namespace *copy_ipcs(unsigned long flags,
10501 -                                             struct task_struct *tsk)
10502 +                                             struct ipc_namespace *old_ns,
10503 +                                             struct user_namespace *user_ns)
10504  {
10505         if (flags & CLONE_NEWIPC)
10506                 return ERR_PTR(-EINVAL);
10507  
10508 -       return tsk->nsproxy->ipc_ns;
10509 +       return old_ns;
10510  }
10511  
10512  static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
10513 diff -NurpP --minimal linux-3.0.4/include/linux/loop.h linux-3.0.4-vs2.3.1/include/linux/loop.h
10514 --- linux-3.0.4/include/linux/loop.h    2009-09-10 15:26:25.000000000 +0200
10515 +++ linux-3.0.4-vs2.3.1/include/linux/loop.h    2011-06-10 22:11:24.000000000 +0200
10516 @@ -45,6 +45,7 @@ struct loop_device {
10517         struct loop_func_table *lo_encryption;
10518         __u32           lo_init[2];
10519         uid_t           lo_key_owner;   /* Who set the key */
10520 +       xid_t           lo_xid;
10521         int             (*ioctl)(struct loop_device *, int cmd, 
10522                                  unsigned long arg); 
10523  
10524 diff -NurpP --minimal linux-3.0.4/include/linux/magic.h linux-3.0.4-vs2.3.1/include/linux/magic.h
10525 --- linux-3.0.4/include/linux/magic.h   2011-05-22 16:17:55.000000000 +0200
10526 +++ linux-3.0.4-vs2.3.1/include/linux/magic.h   2011-06-10 22:11:24.000000000 +0200
10527 @@ -3,7 +3,7 @@
10528  
10529  #define ADFS_SUPER_MAGIC       0xadf5
10530  #define AFFS_SUPER_MAGIC       0xadff
10531 -#define AFS_SUPER_MAGIC                0x5346414F
10532 +#define AFS_SUPER_MAGIC                0x5346414F
10533  #define AUTOFS_SUPER_MAGIC     0x0187
10534  #define CODA_SUPER_MAGIC       0x73757245
10535  #define CRAMFS_MAGIC           0x28cd3d45      /* some random number */
10536 @@ -41,6 +41,7 @@
10537  #define NFS_SUPER_MAGIC                0x6969
10538  #define OPENPROM_SUPER_MAGIC   0x9fa1
10539  #define PROC_SUPER_MAGIC       0x9fa0
10540 +#define DEVPTS_SUPER_MAGIC     0x1cd1
10541  #define QNX4_SUPER_MAGIC       0x002f          /* qnx4 fs detection */
10542  
10543  #define REISERFS_SUPER_MAGIC   0x52654973      /* used by gcc */
10544 diff -NurpP --minimal linux-3.0.4/include/linux/major.h linux-3.0.4-vs2.3.1/include/linux/major.h
10545 --- linux-3.0.4/include/linux/major.h   2009-09-10 15:26:25.000000000 +0200
10546 +++ linux-3.0.4-vs2.3.1/include/linux/major.h   2011-06-10 22:11:24.000000000 +0200
10547 @@ -15,6 +15,7 @@
10548  #define HD_MAJOR               IDE0_MAJOR
10549  #define PTY_SLAVE_MAJOR                3
10550  #define TTY_MAJOR              4
10551 +#define VROOT_MAJOR            4
10552  #define TTYAUX_MAJOR           5
10553  #define LP_MAJOR               6
10554  #define VCS_MAJOR              7
10555 diff -NurpP --minimal linux-3.0.4/include/linux/memcontrol.h linux-3.0.4-vs2.3.1/include/linux/memcontrol.h
10556 --- linux-3.0.4/include/linux/memcontrol.h      2011-07-22 11:18:10.000000000 +0200
10557 +++ linux-3.0.4-vs2.3.1/include/linux/memcontrol.h      2011-06-22 12:39:15.000000000 +0200
10558 @@ -86,6 +86,13 @@ extern struct mem_cgroup *try_get_mem_cg
10559  extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
10560  extern struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm);
10561  
10562 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
10563 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
10564 +
10565 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
10566 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
10567 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
10568 +
10569  static inline
10570  int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
10571  {
10572 diff -NurpP --minimal linux-3.0.4/include/linux/mm_types.h linux-3.0.4-vs2.3.1/include/linux/mm_types.h
10573 --- linux-3.0.4/include/linux/mm_types.h        2011-07-22 11:18:11.000000000 +0200
10574 +++ linux-3.0.4-vs2.3.1/include/linux/mm_types.h        2011-06-10 22:11:24.000000000 +0200
10575 @@ -268,6 +268,7 @@ struct mm_struct {
10576  
10577         /* Architecture-specific MM context */
10578         mm_context_t context;
10579 +       struct vx_info *mm_vx_info;
10580  
10581         /* Swap token stuff */
10582         /*
10583 diff -NurpP --minimal linux-3.0.4/include/linux/mmzone.h linux-3.0.4-vs2.3.1/include/linux/mmzone.h
10584 --- linux-3.0.4/include/linux/mmzone.h  2011-07-22 11:18:11.000000000 +0200
10585 +++ linux-3.0.4-vs2.3.1/include/linux/mmzone.h  2011-07-01 11:35:35.000000000 +0200
10586 @@ -654,6 +654,13 @@ typedef struct pglist_data {
10587         __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
10588  })
10589  
10590 +#define node_start_pfn(nid)    (NODE_DATA(nid)->node_start_pfn)
10591 +
10592 +#define node_end_pfn(nid) ({\
10593 +       pg_data_t *__pgdat = NODE_DATA(nid);\
10594 +       __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
10595 +})
10596 +
10597  #include <linux/memory_hotplug.h>
10598  
10599  extern struct mutex zonelists_mutex;
10600 diff -NurpP --minimal linux-3.0.4/include/linux/mount.h linux-3.0.4-vs2.3.1/include/linux/mount.h
10601 --- linux-3.0.4/include/linux/mount.h   2011-03-15 18:07:39.000000000 +0100
10602 +++ linux-3.0.4-vs2.3.1/include/linux/mount.h   2011-06-10 22:11:24.000000000 +0200
10603 @@ -52,6 +52,9 @@ struct mnt_pcp {
10604         int mnt_writers;
10605  };
10606  
10607 +#define MNT_TAGID      0x10000
10608 +#define MNT_NOTAG      0x20000
10609 +
10610  struct vfsmount {
10611         struct list_head mnt_hash;
10612         struct vfsmount *mnt_parent;    /* fs we are mounted on */
10613 @@ -86,6 +89,7 @@ struct vfsmount {
10614         int mnt_expiry_mark;            /* true if marked for expiry */
10615         int mnt_pinned;
10616         int mnt_ghosts;
10617 +       tag_t mnt_tag;                  /* tagging used for vfsmount */
10618  };
10619  
10620  struct file; /* forward dec */
10621 diff -NurpP --minimal linux-3.0.4/include/linux/net.h linux-3.0.4-vs2.3.1/include/linux/net.h
10622 --- linux-3.0.4/include/linux/net.h     2011-07-22 11:18:11.000000000 +0200
10623 +++ linux-3.0.4-vs2.3.1/include/linux/net.h     2011-06-10 22:11:24.000000000 +0200
10624 @@ -72,6 +72,7 @@ struct net;
10625  #define SOCK_NOSPACE           2
10626  #define SOCK_PASSCRED          3
10627  #define SOCK_PASSSEC           4
10628 +#define SOCK_USER_SOCKET       5
10629  
10630  #ifndef ARCH_HAS_SOCKET_TYPES
10631  /**
10632 diff -NurpP --minimal linux-3.0.4/include/linux/netdevice.h linux-3.0.4-vs2.3.1/include/linux/netdevice.h
10633 --- linux-3.0.4/include/linux/netdevice.h       2011-08-31 18:56:42.000000000 +0200
10634 +++ linux-3.0.4-vs2.3.1/include/linux/netdevice.h       2011-09-17 19:22:49.000000000 +0200
10635 @@ -1650,6 +1650,7 @@ extern void               netdev_resync_ops(struct ne
10636  extern int call_netdevice_notifiers(unsigned long val, struct net_device *dev);
10637  extern struct net_device       *dev_get_by_index(struct net *net, int ifindex);
10638  extern struct net_device       *__dev_get_by_index(struct net *net, int ifindex);
10639 +extern struct net_device       *dev_get_by_index_real_rcu(struct net *net, int ifindex);
10640  extern struct net_device       *dev_get_by_index_rcu(struct net *net, int ifindex);
10641  extern int             dev_restart(struct net_device *dev);
10642  #ifdef CONFIG_NETPOLL_TRAP
10643 diff -NurpP --minimal linux-3.0.4/include/linux/nfs_mount.h linux-3.0.4-vs2.3.1/include/linux/nfs_mount.h
10644 --- linux-3.0.4/include/linux/nfs_mount.h       2011-01-05 21:50:31.000000000 +0100
10645 +++ linux-3.0.4-vs2.3.1/include/linux/nfs_mount.h       2011-06-10 22:11:24.000000000 +0200
10646 @@ -63,7 +63,8 @@ struct nfs_mount_data {
10647  #define NFS_MOUNT_SECFLAVOUR   0x2000  /* 5 */
10648  #define NFS_MOUNT_NORDIRPLUS   0x4000  /* 5 */
10649  #define NFS_MOUNT_UNSHARED     0x8000  /* 5 */
10650 -#define NFS_MOUNT_FLAGMASK     0xFFFF
10651 +#define NFS_MOUNT_TAGGED       0x10000 /* context tagging */
10652 +#define NFS_MOUNT_FLAGMASK     0x1FFFF
10653  
10654  /* The following are for internal use only */
10655  #define NFS_MOUNT_LOOKUP_CACHE_NONEG   0x10000
10656 diff -NurpP --minimal linux-3.0.4/include/linux/nsproxy.h linux-3.0.4-vs2.3.1/include/linux/nsproxy.h
10657 --- linux-3.0.4/include/linux/nsproxy.h 2011-07-22 11:18:11.000000000 +0200
10658 +++ linux-3.0.4-vs2.3.1/include/linux/nsproxy.h 2011-06-10 22:11:24.000000000 +0200
10659 @@ -3,6 +3,7 @@
10660  
10661  #include <linux/spinlock.h>
10662  #include <linux/sched.h>
10663 +#include <linux/vserver/debug.h>
10664  
10665  struct mnt_namespace;
10666  struct uts_namespace;
10667 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
10668  }
10669  
10670  int copy_namespaces(unsigned long flags, struct task_struct *tsk);
10671 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
10672  void exit_task_namespaces(struct task_struct *tsk);
10673  void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
10674  void free_nsproxy(struct nsproxy *ns);
10675  int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
10676         struct fs_struct *);
10677  
10678 -static inline void put_nsproxy(struct nsproxy *ns)
10679 +#define        get_nsproxy(n)  __get_nsproxy(n, __FILE__, __LINE__)
10680 +
10681 +static inline void __get_nsproxy(struct nsproxy *ns,
10682 +       const char *_file, int _line)
10683  {
10684 -       if (atomic_dec_and_test(&ns->count)) {
10685 -               free_nsproxy(ns);
10686 -       }
10687 +       vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
10688 +               ns, atomic_read(&ns->count), _file, _line);
10689 +       atomic_inc(&ns->count);
10690  }
10691  
10692 -static inline void get_nsproxy(struct nsproxy *ns)
10693 +#define        put_nsproxy(n)  __put_nsproxy(n, __FILE__, __LINE__)
10694 +
10695 +static inline void __put_nsproxy(struct nsproxy *ns,
10696 +       const char *_file, int _line)
10697  {
10698 -       atomic_inc(&ns->count);
10699 +       vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
10700 +               ns, atomic_read(&ns->count), _file, _line);
10701 +       if (atomic_dec_and_test(&ns->count)) {
10702 +               free_nsproxy(ns);
10703 +       }
10704  }
10705  
10706  #endif
10707 diff -NurpP --minimal linux-3.0.4/include/linux/pid.h linux-3.0.4-vs2.3.1/include/linux/pid.h
10708 --- linux-3.0.4/include/linux/pid.h     2011-07-22 11:18:11.000000000 +0200
10709 +++ linux-3.0.4-vs2.3.1/include/linux/pid.h     2011-06-10 22:11:24.000000000 +0200
10710 @@ -8,7 +8,8 @@ enum pid_type
10711         PIDTYPE_PID,
10712         PIDTYPE_PGID,
10713         PIDTYPE_SID,
10714 -       PIDTYPE_MAX
10715 +       PIDTYPE_MAX,
10716 +       PIDTYPE_REALPID
10717  };
10718  
10719  /*
10720 @@ -171,6 +172,7 @@ static inline pid_t pid_nr(struct pid *p
10721  }
10722  
10723  pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
10724 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
10725  pid_t pid_vnr(struct pid *pid);
10726  
10727  #define do_each_pid_task(pid, type, task)                              \
10728 diff -NurpP --minimal linux-3.0.4/include/linux/proc_fs.h linux-3.0.4-vs2.3.1/include/linux/proc_fs.h
10729 --- linux-3.0.4/include/linux/proc_fs.h 2011-07-22 11:18:11.000000000 +0200
10730 +++ linux-3.0.4-vs2.3.1/include/linux/proc_fs.h 2011-06-10 22:11:24.000000000 +0200
10731 @@ -56,6 +56,7 @@ struct proc_dir_entry {
10732         nlink_t nlink;
10733         uid_t uid;
10734         gid_t gid;
10735 +       int vx_flags;
10736         loff_t size;
10737         const struct inode_operations *proc_iops;
10738         /*
10739 @@ -252,12 +253,18 @@ extern const struct proc_ns_operations n
10740  extern const struct proc_ns_operations utsns_operations;
10741  extern const struct proc_ns_operations ipcns_operations;
10742  
10743 +struct vx_info;
10744 +struct nx_info;
10745 +
10746  union proc_op {
10747         int (*proc_get_link)(struct inode *, struct path *);
10748         int (*proc_read)(struct task_struct *task, char *page);
10749         int (*proc_show)(struct seq_file *m,
10750                 struct pid_namespace *ns, struct pid *pid,
10751                 struct task_struct *task);
10752 +       int (*proc_vs_read)(char *page);
10753 +       int (*proc_vxi_read)(struct vx_info *vxi, char *page);
10754 +       int (*proc_nxi_read)(struct nx_info *nxi, char *page);
10755  };
10756  
10757  struct ctl_table_header;
10758 @@ -265,6 +272,7 @@ struct ctl_table;
10759  
10760  struct proc_inode {
10761         struct pid *pid;
10762 +       int vx_flags;
10763         int fd;
10764         union proc_op op;
10765         struct proc_dir_entry *pde;
10766 diff -NurpP --minimal linux-3.0.4/include/linux/quotaops.h linux-3.0.4-vs2.3.1/include/linux/quotaops.h
10767 --- linux-3.0.4/include/linux/quotaops.h        2011-05-22 16:17:57.000000000 +0200
10768 +++ linux-3.0.4-vs2.3.1/include/linux/quotaops.h        2011-06-10 22:11:24.000000000 +0200
10769 @@ -8,6 +8,7 @@
10770  #define _LINUX_QUOTAOPS_
10771  
10772  #include <linux/fs.h>
10773 +#include <linux/vs_dlimit.h>
10774  
10775  #define DQUOT_SPACE_WARN       0x1
10776  #define DQUOT_SPACE_RESERVE    0x2
10777 @@ -204,11 +205,12 @@ static inline void dquot_drop(struct ino
10778  
10779  static inline int dquot_alloc_inode(const struct inode *inode)
10780  {
10781 -       return 0;
10782 +       return dl_alloc_inode(inode);
10783  }
10784  
10785  static inline void dquot_free_inode(const struct inode *inode)
10786  {
10787 +       dl_free_inode(inode);
10788  }
10789  
10790  static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
10791 @@ -219,6 +221,10 @@ static inline int dquot_transfer(struct 
10792  static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
10793                 int flags)
10794  {
10795 +       int ret = 0;
10796 +
10797 +       if ((ret = dl_alloc_space(inode, number)))
10798 +               return ret;
10799         if (!(flags & DQUOT_SPACE_RESERVE))
10800                 inode_add_bytes(inode, number);
10801         return 0;
10802 @@ -229,6 +235,7 @@ static inline void __dquot_free_space(st
10803  {
10804         if (!(flags & DQUOT_SPACE_RESERVE))
10805                 inode_sub_bytes(inode, number);
10806 +       dl_free_space(inode, number);
10807  }
10808  
10809  static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
10810 diff -NurpP --minimal linux-3.0.4/include/linux/reboot.h linux-3.0.4-vs2.3.1/include/linux/reboot.h
10811 --- linux-3.0.4/include/linux/reboot.h  2010-07-07 18:31:56.000000000 +0200
10812 +++ linux-3.0.4-vs2.3.1/include/linux/reboot.h  2011-06-10 22:11:24.000000000 +0200
10813 @@ -33,6 +33,7 @@
10814  #define        LINUX_REBOOT_CMD_RESTART2       0xA1B2C3D4
10815  #define        LINUX_REBOOT_CMD_SW_SUSPEND     0xD000FCE2
10816  #define        LINUX_REBOOT_CMD_KEXEC          0x45584543
10817 +#define        LINUX_REBOOT_CMD_OOM            0xDEADBEEF
10818  
10819  
10820  #ifdef __KERNEL__
10821 diff -NurpP --minimal linux-3.0.4/include/linux/reiserfs_fs.h linux-3.0.4-vs2.3.1/include/linux/reiserfs_fs.h
10822 --- linux-3.0.4/include/linux/reiserfs_fs.h     2011-05-22 16:17:58.000000000 +0200
10823 +++ linux-3.0.4-vs2.3.1/include/linux/reiserfs_fs.h     2011-06-10 22:11:24.000000000 +0200
10824 @@ -976,6 +976,11 @@ struct stat_data_v1 {
10825  #define REISERFS_COMPR_FL     FS_COMPR_FL
10826  #define REISERFS_NOTAIL_FL    FS_NOTAIL_FL
10827  
10828 +/* unfortunately reiserfs sdattr is only 16 bit */
10829 +#define REISERFS_IXUNLINK_FL  (FS_IXUNLINK_FL >> 16)
10830 +#define REISERFS_BARRIER_FL   (FS_BARRIER_FL >> 16)
10831 +#define REISERFS_COW_FL       (FS_COW_FL >> 16)
10832 +
10833  /* persistent flags that file inherits from the parent directory */
10834  #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL |        \
10835                                 REISERFS_SYNC_FL |      \
10836 @@ -985,6 +990,9 @@ struct stat_data_v1 {
10837                                 REISERFS_COMPR_FL |     \
10838                                 REISERFS_NOTAIL_FL )
10839  
10840 +#define REISERFS_FL_USER_VISIBLE       0x80FF
10841 +#define REISERFS_FL_USER_MODIFIABLE    0x80FF
10842 +
10843  /* Stat Data on disk (reiserfs version of UFS disk inode minus the
10844     address blocks) */
10845  struct stat_data {
10846 @@ -2073,6 +2081,7 @@ static inline void reiserfs_update_sd(st
10847  void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
10848  void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
10849  int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
10850 +int reiserfs_sync_flags(struct inode *inode, int, int);
10851  
10852  int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len);
10853  
10854 diff -NurpP --minimal linux-3.0.4/include/linux/reiserfs_fs_sb.h linux-3.0.4-vs2.3.1/include/linux/reiserfs_fs_sb.h
10855 --- linux-3.0.4/include/linux/reiserfs_fs_sb.h  2010-02-25 11:52:07.000000000 +0100
10856 +++ linux-3.0.4-vs2.3.1/include/linux/reiserfs_fs_sb.h  2011-06-10 22:11:24.000000000 +0200
10857 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
10858         REISERFS_EXPOSE_PRIVROOT,
10859         REISERFS_BARRIER_NONE,
10860         REISERFS_BARRIER_FLUSH,
10861 +       REISERFS_TAGGED,
10862  
10863         /* Actions on error */
10864         REISERFS_ERROR_PANIC,
10865 diff -NurpP --minimal linux-3.0.4/include/linux/sched.h linux-3.0.4-vs2.3.1/include/linux/sched.h
10866 --- linux-3.0.4/include/linux/sched.h   2011-07-22 11:18:11.000000000 +0200
10867 +++ linux-3.0.4-vs2.3.1/include/linux/sched.h   2011-07-22 11:20:39.000000000 +0200
10868 @@ -1406,6 +1406,14 @@ struct task_struct {
10869  #endif
10870         seccomp_t seccomp;
10871  
10872 +/* vserver context data */
10873 +       struct vx_info *vx_info;
10874 +       struct nx_info *nx_info;
10875 +
10876 +       xid_t xid;
10877 +       nid_t nid;
10878 +       tag_t tag;
10879 +
10880  /* Thread group tracking */
10881         u32 parent_exec_id;
10882         u32 self_exec_id;
10883 @@ -1649,6 +1657,11 @@ struct pid_namespace;
10884  pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
10885                         struct pid_namespace *ns);
10886  
10887 +#include <linux/vserver/base.h>
10888 +#include <linux/vserver/context.h>
10889 +#include <linux/vserver/debug.h>
10890 +#include <linux/vserver/pid.h>
10891 +
10892  static inline pid_t task_pid_nr(struct task_struct *tsk)
10893  {
10894         return tsk->pid;
10895 @@ -1662,7 +1675,8 @@ static inline pid_t task_pid_nr_ns(struc
10896  
10897  static inline pid_t task_pid_vnr(struct task_struct *tsk)
10898  {
10899 -       return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
10900 +       // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
10901 +       return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
10902  }
10903  
10904  
10905 @@ -1675,7 +1689,7 @@ pid_t task_tgid_nr_ns(struct task_struct
10906  
10907  static inline pid_t task_tgid_vnr(struct task_struct *tsk)
10908  {
10909 -       return pid_vnr(task_tgid(tsk));
10910 +       return vx_map_tgid(pid_vnr(task_tgid(tsk)));
10911  }
10912  
10913  
10914 diff -NurpP --minimal linux-3.0.4/include/linux/shmem_fs.h linux-3.0.4-vs2.3.1/include/linux/shmem_fs.h
10915 --- linux-3.0.4/include/linux/shmem_fs.h        2011-07-22 11:18:11.000000000 +0200
10916 +++ linux-3.0.4-vs2.3.1/include/linux/shmem_fs.h        2011-07-01 11:35:35.000000000 +0200
10917 @@ -12,6 +12,9 @@
10918  
10919  #define SHMEM_SYMLINK_INLINE_LEN (SHMEM_NR_DIRECT * sizeof(swp_entry_t))
10920  
10921 +#define TMPFS_SUPER_MAGIC      0x01021994
10922 +
10923 +
10924  struct shmem_inode_info {
10925         spinlock_t              lock;
10926         unsigned long           flags;
10927 diff -NurpP --minimal linux-3.0.4/include/linux/stat.h linux-3.0.4-vs2.3.1/include/linux/stat.h
10928 --- linux-3.0.4/include/linux/stat.h    2008-12-25 00:26:37.000000000 +0100
10929 +++ linux-3.0.4-vs2.3.1/include/linux/stat.h    2011-06-10 22:11:24.000000000 +0200
10930 @@ -66,6 +66,7 @@ struct kstat {
10931         unsigned int    nlink;
10932         uid_t           uid;
10933         gid_t           gid;
10934 +       tag_t           tag;
10935         dev_t           rdev;
10936         loff_t          size;
10937         struct timespec  atime;
10938 diff -NurpP --minimal linux-3.0.4/include/linux/sunrpc/auth.h linux-3.0.4-vs2.3.1/include/linux/sunrpc/auth.h
10939 --- linux-3.0.4/include/linux/sunrpc/auth.h     2011-03-15 18:07:39.000000000 +0100
10940 +++ linux-3.0.4-vs2.3.1/include/linux/sunrpc/auth.h     2011-06-10 22:11:24.000000000 +0200
10941 @@ -25,6 +25,7 @@
10942  struct auth_cred {
10943         uid_t   uid;
10944         gid_t   gid;
10945 +       tag_t   tag;
10946         struct group_info *group_info;
10947         unsigned char machine_cred : 1;
10948  };
10949 diff -NurpP --minimal linux-3.0.4/include/linux/sunrpc/clnt.h linux-3.0.4-vs2.3.1/include/linux/sunrpc/clnt.h
10950 --- linux-3.0.4/include/linux/sunrpc/clnt.h     2011-05-22 16:17:58.000000000 +0200
10951 +++ linux-3.0.4-vs2.3.1/include/linux/sunrpc/clnt.h     2011-06-10 22:11:24.000000000 +0200
10952 @@ -49,7 +49,8 @@ struct rpc_clnt {
10953         unsigned int            cl_softrtry : 1,/* soft timeouts */
10954                                 cl_discrtry : 1,/* disconnect before retry */
10955                                 cl_autobind : 1,/* use getport() */
10956 -                               cl_chatty   : 1;/* be verbose */
10957 +                               cl_chatty   : 1,/* be verbose */
10958 +                               cl_tag      : 1;/* context tagging */
10959  
10960         struct rpc_rtt *        cl_rtt;         /* RTO estimator data */
10961         const struct rpc_timeout *cl_timeout;   /* Timeout strategy */
10962 diff -NurpP --minimal linux-3.0.4/include/linux/syscalls.h linux-3.0.4-vs2.3.1/include/linux/syscalls.h
10963 --- linux-3.0.4/include/linux/syscalls.h        2011-07-22 11:18:11.000000000 +0200
10964 +++ linux-3.0.4-vs2.3.1/include/linux/syscalls.h        2011-06-10 22:11:24.000000000 +0200
10965 @@ -483,6 +483,8 @@ asmlinkage long sys_symlink(const char _
10966  asmlinkage long sys_unlink(const char __user *pathname);
10967  asmlinkage long sys_rename(const char __user *oldname,
10968                                 const char __user *newname);
10969 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
10970 +                               umode_t mode);
10971  asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
10972  asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
10973  
10974 diff -NurpP --minimal linux-3.0.4/include/linux/sysctl.h linux-3.0.4-vs2.3.1/include/linux/sysctl.h
10975 --- linux-3.0.4/include/linux/sysctl.h  2011-03-15 18:07:40.000000000 +0100
10976 +++ linux-3.0.4-vs2.3.1/include/linux/sysctl.h  2011-06-10 22:11:24.000000000 +0200
10977 @@ -60,6 +60,7 @@ enum
10978         CTL_ABI=9,              /* Binary emulation */
10979         CTL_CPU=10,             /* CPU stuff (speed scaling, etc) */
10980         CTL_ARLAN=254,          /* arlan wireless driver */
10981 +       CTL_VSERVER=4242,       /* Linux-VServer debug */
10982         CTL_S390DBF=5677,       /* s390 debug */
10983         CTL_SUNRPC=7249,        /* sunrpc debug */
10984         CTL_PM=9899,            /* frv power management */
10985 @@ -94,6 +95,7 @@ enum
10986  
10987         KERN_PANIC=15,          /* int: panic timeout */
10988         KERN_REALROOTDEV=16,    /* real root device to mount after initrd */
10989 +       KERN_VSHELPER=17,       /* string: path to vshelper policy agent */
10990  
10991         KERN_SPARC_REBOOT=21,   /* reboot command on Sparc */
10992         KERN_CTLALTDEL=22,      /* int: allow ctl-alt-del to reboot */
10993 diff -NurpP --minimal linux-3.0.4/include/linux/sysfs.h linux-3.0.4-vs2.3.1/include/linux/sysfs.h
10994 --- linux-3.0.4/include/linux/sysfs.h   2011-07-22 11:18:11.000000000 +0200
10995 +++ linux-3.0.4-vs2.3.1/include/linux/sysfs.h   2011-06-22 12:39:15.000000000 +0200
10996 @@ -19,6 +19,8 @@
10997  #include <linux/kobject_ns.h>
10998  #include <asm/atomic.h>
10999  
11000 +#define SYSFS_SUPER_MAGIC      0x62656572
11001 +
11002  struct kobject;
11003  struct module;
11004  enum kobj_ns_type;
11005 diff -NurpP --minimal linux-3.0.4/include/linux/time.h linux-3.0.4-vs2.3.1/include/linux/time.h
11006 --- linux-3.0.4/include/linux/time.h    2011-07-22 11:18:11.000000000 +0200
11007 +++ linux-3.0.4-vs2.3.1/include/linux/time.h    2011-06-10 22:11:24.000000000 +0200
11008 @@ -256,6 +256,9 @@ static __always_inline void timespec_add
11009         a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
11010         a->tv_nsec = ns;
11011  }
11012 +
11013 +#include <linux/vs_time.h>
11014 +
11015  #endif /* __KERNEL__ */
11016  
11017  #define NFDBITS                        __NFDBITS
11018 diff -NurpP --minimal linux-3.0.4/include/linux/types.h linux-3.0.4-vs2.3.1/include/linux/types.h
11019 --- linux-3.0.4/include/linux/types.h   2011-05-22 16:17:58.000000000 +0200
11020 +++ linux-3.0.4-vs2.3.1/include/linux/types.h   2011-06-10 22:11:24.000000000 +0200
11021 @@ -40,6 +40,9 @@ typedef __kernel_uid32_t      uid_t;
11022  typedef __kernel_gid32_t       gid_t;
11023  typedef __kernel_uid16_t        uid16_t;
11024  typedef __kernel_gid16_t        gid16_t;
11025 +typedef unsigned int           xid_t;
11026 +typedef unsigned int           nid_t;
11027 +typedef unsigned int           tag_t;
11028  
11029  typedef unsigned long          uintptr_t;
11030  
11031 diff -NurpP --minimal linux-3.0.4/include/linux/utsname.h linux-3.0.4-vs2.3.1/include/linux/utsname.h
11032 --- linux-3.0.4/include/linux/utsname.h 2011-05-22 16:17:58.000000000 +0200
11033 +++ linux-3.0.4-vs2.3.1/include/linux/utsname.h 2011-06-13 14:36:48.000000000 +0200
11034 @@ -54,7 +54,8 @@ static inline void get_uts_ns(struct uts
11035  }
11036  
11037  extern struct uts_namespace *copy_utsname(unsigned long flags,
11038 -                                         struct task_struct *tsk);
11039 +                                         struct uts_namespace *old_ns,
11040 +                                         struct user_namespace *user_ns);
11041  extern void free_uts_ns(struct kref *kref);
11042  
11043  static inline void put_uts_ns(struct uts_namespace *ns)
11044 @@ -71,12 +72,13 @@ static inline void put_uts_ns(struct uts
11045  }
11046  
11047  static inline struct uts_namespace *copy_utsname(unsigned long flags,
11048 -                                                struct task_struct *tsk)
11049 +                                                struct uts_namespace *old_ns,
11050 +                                                struct user_namespace *user_ns)
11051  {
11052         if (flags & CLONE_NEWUTS)
11053                 return ERR_PTR(-EINVAL);
11054  
11055 -       return tsk->nsproxy->uts_ns;
11056 +       return old_ns;
11057  }
11058  #endif
11059  
11060 diff -NurpP --minimal linux-3.0.4/include/linux/vroot.h linux-3.0.4-vs2.3.1/include/linux/vroot.h
11061 --- linux-3.0.4/include/linux/vroot.h   1970-01-01 01:00:00.000000000 +0100
11062 +++ linux-3.0.4-vs2.3.1/include/linux/vroot.h   2011-06-10 22:11:24.000000000 +0200
11063 @@ -0,0 +1,51 @@
11064 +
11065 +/*
11066 + * include/linux/vroot.h
11067 + *
11068 + * written by Herbert Pötzl, 9/11/2002
11069 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
11070 + *
11071 + * Copyright (C) 2002-2007 by Herbert Pötzl.
11072 + * Redistribution of this file is permitted under the
11073 + * GNU General Public License.
11074 + */
11075 +
11076 +#ifndef _LINUX_VROOT_H
11077 +#define _LINUX_VROOT_H
11078 +
11079 +
11080 +#ifdef __KERNEL__
11081 +
11082 +/* Possible states of device */
11083 +enum {
11084 +       Vr_unbound,
11085 +       Vr_bound,
11086 +};
11087 +
11088 +struct vroot_device {
11089 +       int             vr_number;
11090 +       int             vr_refcnt;
11091 +
11092 +       struct semaphore        vr_ctl_mutex;
11093 +       struct block_device    *vr_device;
11094 +       int                     vr_state;
11095 +};
11096 +
11097 +
11098 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
11099 +
11100 +extern int register_vroot_grb(vroot_grb_func *);
11101 +extern int unregister_vroot_grb(vroot_grb_func *);
11102 +
11103 +#endif /* __KERNEL__ */
11104 +
11105 +#define MAX_VROOT_DEFAULT      8
11106 +
11107 +/*
11108 + * IOCTL commands --- we will commandeer 0x56 ('V')
11109 + */
11110 +
11111 +#define VROOT_SET_DEV          0x5600
11112 +#define VROOT_CLR_DEV          0x5601
11113 +
11114 +#endif /* _LINUX_VROOT_H */
11115 diff -NurpP --minimal linux-3.0.4/include/linux/vs_base.h linux-3.0.4-vs2.3.1/include/linux/vs_base.h
11116 --- linux-3.0.4/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
11117 +++ linux-3.0.4-vs2.3.1/include/linux/vs_base.h 2011-06-10 22:11:24.000000000 +0200
11118 @@ -0,0 +1,10 @@
11119 +#ifndef _VS_BASE_H
11120 +#define _VS_BASE_H
11121 +
11122 +#include "vserver/base.h"
11123 +#include "vserver/check.h"
11124 +#include "vserver/debug.h"
11125 +
11126 +#else
11127 +#warning duplicate inclusion
11128 +#endif
11129 diff -NurpP --minimal linux-3.0.4/include/linux/vs_context.h linux-3.0.4-vs2.3.1/include/linux/vs_context.h
11130 --- linux-3.0.4/include/linux/vs_context.h      1970-01-01 01:00:00.000000000 +0100
11131 +++ linux-3.0.4-vs2.3.1/include/linux/vs_context.h      2011-06-10 22:11:24.000000000 +0200
11132 @@ -0,0 +1,242 @@
11133 +#ifndef _VS_CONTEXT_H
11134 +#define _VS_CONTEXT_H
11135 +
11136 +#include "vserver/base.h"
11137 +#include "vserver/check.h"
11138 +#include "vserver/context.h"
11139 +#include "vserver/history.h"
11140 +#include "vserver/debug.h"
11141 +
11142 +#include <linux/sched.h>
11143 +
11144 +
11145 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
11146 +
11147 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
11148 +       const char *_file, int _line, void *_here)
11149 +{
11150 +       if (!vxi)
11151 +               return NULL;
11152 +
11153 +       vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
11154 +               vxi, vxi ? vxi->vx_id : 0,
11155 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11156 +               _file, _line);
11157 +       __vxh_get_vx_info(vxi, _here);
11158 +
11159 +       atomic_inc(&vxi->vx_usecnt);
11160 +       return vxi;
11161 +}
11162 +
11163 +
11164 +extern void free_vx_info(struct vx_info *);
11165 +
11166 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
11167 +
11168 +static inline void __put_vx_info(struct vx_info *vxi,
11169 +       const char *_file, int _line, void *_here)
11170 +{
11171 +       if (!vxi)
11172 +               return;
11173 +
11174 +       vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
11175 +               vxi, vxi ? vxi->vx_id : 0,
11176 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11177 +               _file, _line);
11178 +       __vxh_put_vx_info(vxi, _here);
11179 +
11180 +       if (atomic_dec_and_test(&vxi->vx_usecnt))
11181 +               free_vx_info(vxi);
11182 +}
11183 +
11184 +
11185 +#define init_vx_info(p, i) \
11186 +       __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
11187 +
11188 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
11189 +       const char *_file, int _line, void *_here)
11190 +{
11191 +       if (vxi) {
11192 +               vxlprintk(VXD_CBIT(xid, 3),
11193 +                       "init_vx_info(%p[#%d.%d])",
11194 +                       vxi, vxi ? vxi->vx_id : 0,
11195 +                       vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11196 +                       _file, _line);
11197 +               __vxh_init_vx_info(vxi, vxp, _here);
11198 +
11199 +               atomic_inc(&vxi->vx_usecnt);
11200 +       }
11201 +       *vxp = vxi;
11202 +}
11203 +
11204 +
11205 +#define set_vx_info(p, i) \
11206 +       __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
11207 +
11208 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
11209 +       const char *_file, int _line, void *_here)
11210 +{
11211 +       struct vx_info *vxo;
11212 +
11213 +       if (!vxi)
11214 +               return;
11215 +
11216 +       vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
11217 +               vxi, vxi ? vxi->vx_id : 0,
11218 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11219 +               _file, _line);
11220 +       __vxh_set_vx_info(vxi, vxp, _here);
11221 +
11222 +       atomic_inc(&vxi->vx_usecnt);
11223 +       vxo = xchg(vxp, vxi);
11224 +       BUG_ON(vxo);
11225 +}
11226 +
11227 +
11228 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
11229 +
11230 +static inline void __clr_vx_info(struct vx_info **vxp,
11231 +       const char *_file, int _line, void *_here)
11232 +{
11233 +       struct vx_info *vxo;
11234 +
11235 +       vxo = xchg(vxp, NULL);
11236 +       if (!vxo)
11237 +               return;
11238 +
11239 +       vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
11240 +               vxo, vxo ? vxo->vx_id : 0,
11241 +               vxo ? atomic_read(&vxo->vx_usecnt) : 0,
11242 +               _file, _line);
11243 +       __vxh_clr_vx_info(vxo, vxp, _here);
11244 +
11245 +       if (atomic_dec_and_test(&vxo->vx_usecnt))
11246 +               free_vx_info(vxo);
11247 +}
11248 +
11249 +
11250 +#define claim_vx_info(v, p) \
11251 +       __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
11252 +
11253 +static inline void __claim_vx_info(struct vx_info *vxi,
11254 +       struct task_struct *task,
11255 +       const char *_file, int _line, void *_here)
11256 +{
11257 +       vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
11258 +               vxi, vxi ? vxi->vx_id : 0,
11259 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11260 +               vxi ? atomic_read(&vxi->vx_tasks) : 0,
11261 +               task, _file, _line);
11262 +       __vxh_claim_vx_info(vxi, task, _here);
11263 +
11264 +       atomic_inc(&vxi->vx_tasks);
11265 +}
11266 +
11267 +
11268 +extern void unhash_vx_info(struct vx_info *);
11269 +
11270 +#define release_vx_info(v, p) \
11271 +       __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
11272 +
11273 +static inline void __release_vx_info(struct vx_info *vxi,
11274 +       struct task_struct *task,
11275 +       const char *_file, int _line, void *_here)
11276 +{
11277 +       vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
11278 +               vxi, vxi ? vxi->vx_id : 0,
11279 +               vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11280 +               vxi ? atomic_read(&vxi->vx_tasks) : 0,
11281 +               task, _file, _line);
11282 +       __vxh_release_vx_info(vxi, task, _here);
11283 +
11284 +       might_sleep();
11285 +
11286 +       if (atomic_dec_and_test(&vxi->vx_tasks))
11287 +               unhash_vx_info(vxi);
11288 +}
11289 +
11290 +
11291 +#define task_get_vx_info(p) \
11292 +       __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
11293 +
11294 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
11295 +       const char *_file, int _line, void *_here)
11296 +{
11297 +       struct vx_info *vxi;
11298 +
11299 +       task_lock(p);
11300 +       vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
11301 +               p, _file, _line);
11302 +       vxi = __get_vx_info(p->vx_info, _file, _line, _here);
11303 +       task_unlock(p);
11304 +       return vxi;
11305 +}
11306 +
11307 +
11308 +static inline void __wakeup_vx_info(struct vx_info *vxi)
11309 +{
11310 +       if (waitqueue_active(&vxi->vx_wait))
11311 +               wake_up_interruptible(&vxi->vx_wait);
11312 +}
11313 +
11314 +
11315 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
11316 +
11317 +static inline void __enter_vx_info(struct vx_info *vxi,
11318 +       struct vx_info_save *vxis, const char *_file, int _line)
11319 +{
11320 +       vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
11321 +               vxi, vxi ? vxi->vx_id : 0, vxis, current,
11322 +               current->xid, current->vx_info, _file, _line);
11323 +       vxis->vxi = xchg(&current->vx_info, vxi);
11324 +       vxis->xid = current->xid;
11325 +       current->xid = vxi ? vxi->vx_id : 0;
11326 +}
11327 +
11328 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
11329 +
11330 +static inline void __leave_vx_info(struct vx_info_save *vxis,
11331 +       const char *_file, int _line)
11332 +{
11333 +       vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
11334 +               vxis, vxis->xid, vxis->vxi, current,
11335 +               current->xid, current->vx_info, _file, _line);
11336 +       (void)xchg(&current->vx_info, vxis->vxi);
11337 +       current->xid = vxis->xid;
11338 +}
11339 +
11340 +
11341 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
11342 +{
11343 +       vxis->vxi = xchg(&current->vx_info, NULL);
11344 +       vxis->xid = xchg(&current->xid, (xid_t)0);
11345 +}
11346 +
11347 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
11348 +{
11349 +       (void)xchg(&current->xid, vxis->xid);
11350 +       (void)xchg(&current->vx_info, vxis->vxi);
11351 +}
11352 +
11353 +#define task_is_init(p) \
11354 +       __task_is_init(p, __FILE__, __LINE__, __HERE__)
11355 +
11356 +static inline int __task_is_init(struct task_struct *p,
11357 +       const char *_file, int _line, void *_here)
11358 +{
11359 +       int is_init = is_global_init(p);
11360 +
11361 +       task_lock(p);
11362 +       if (p->vx_info)
11363 +               is_init = p->vx_info->vx_initpid == p->pid;
11364 +       task_unlock(p);
11365 +       return is_init;
11366 +}
11367 +
11368 +extern void exit_vx_info(struct task_struct *, int);
11369 +extern void exit_vx_info_early(struct task_struct *, int);
11370 +
11371 +
11372 +#else
11373 +#warning duplicate inclusion
11374 +#endif
11375 diff -NurpP --minimal linux-3.0.4/include/linux/vs_cowbl.h linux-3.0.4-vs2.3.1/include/linux/vs_cowbl.h
11376 --- linux-3.0.4/include/linux/vs_cowbl.h        1970-01-01 01:00:00.000000000 +0100
11377 +++ linux-3.0.4-vs2.3.1/include/linux/vs_cowbl.h        2011-06-10 22:11:24.000000000 +0200
11378 @@ -0,0 +1,48 @@
11379 +#ifndef _VS_COWBL_H
11380 +#define _VS_COWBL_H
11381 +
11382 +#include <linux/fs.h>
11383 +#include <linux/dcache.h>
11384 +#include <linux/namei.h>
11385 +#include <linux/slab.h>
11386 +
11387 +extern struct dentry *cow_break_link(const char *pathname);
11388 +
11389 +static inline int cow_check_and_break(struct path *path)
11390 +{
11391 +       struct inode *inode = path->dentry->d_inode;
11392 +       int error = 0;
11393 +
11394 +       /* do we need this check? */
11395 +       if (IS_RDONLY(inode))
11396 +               return -EROFS;
11397 +
11398 +       if (IS_COW(inode)) {
11399 +               if (IS_COW_LINK(inode)) {
11400 +                       struct dentry *new_dentry, *old_dentry = path->dentry;
11401 +                       char *pp, *buf;
11402 +
11403 +                       buf = kmalloc(PATH_MAX, GFP_KERNEL);
11404 +                       if (!buf) {
11405 +                               return -ENOMEM;
11406 +                       }
11407 +                       pp = d_path(path, buf, PATH_MAX);
11408 +                       new_dentry = cow_break_link(pp);
11409 +                       kfree(buf);
11410 +                       if (!IS_ERR(new_dentry)) {
11411 +                               path->dentry = new_dentry;
11412 +                               dput(old_dentry);
11413 +                       } else
11414 +                               error = PTR_ERR(new_dentry);
11415 +               } else {
11416 +                       inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
11417 +                       inode->i_ctime = CURRENT_TIME;
11418 +                       mark_inode_dirty(inode);
11419 +               }
11420 +       }
11421 +       return error;
11422 +}
11423 +
11424 +#else
11425 +#warning duplicate inclusion
11426 +#endif
11427 diff -NurpP --minimal linux-3.0.4/include/linux/vs_cvirt.h linux-3.0.4-vs2.3.1/include/linux/vs_cvirt.h
11428 --- linux-3.0.4/include/linux/vs_cvirt.h        1970-01-01 01:00:00.000000000 +0100
11429 +++ linux-3.0.4-vs2.3.1/include/linux/vs_cvirt.h        2011-06-10 22:11:24.000000000 +0200
11430 @@ -0,0 +1,50 @@
11431 +#ifndef _VS_CVIRT_H
11432 +#define _VS_CVIRT_H
11433 +
11434 +#include "vserver/cvirt.h"
11435 +#include "vserver/context.h"
11436 +#include "vserver/base.h"
11437 +#include "vserver/check.h"
11438 +#include "vserver/debug.h"
11439 +
11440 +
11441 +static inline void vx_activate_task(struct task_struct *p)
11442 +{
11443 +       struct vx_info *vxi;
11444 +
11445 +       if ((vxi = p->vx_info)) {
11446 +               vx_update_load(vxi);
11447 +               atomic_inc(&vxi->cvirt.nr_running);
11448 +       }
11449 +}
11450 +
11451 +static inline void vx_deactivate_task(struct task_struct *p)
11452 +{
11453 +       struct vx_info *vxi;
11454 +
11455 +       if ((vxi = p->vx_info)) {
11456 +               vx_update_load(vxi);
11457 +               atomic_dec(&vxi->cvirt.nr_running);
11458 +       }
11459 +}
11460 +
11461 +static inline void vx_uninterruptible_inc(struct task_struct *p)
11462 +{
11463 +       struct vx_info *vxi;
11464 +
11465 +       if ((vxi = p->vx_info))
11466 +               atomic_inc(&vxi->cvirt.nr_uninterruptible);
11467 +}
11468 +
11469 +static inline void vx_uninterruptible_dec(struct task_struct *p)
11470 +{
11471 +       struct vx_info *vxi;
11472 +
11473 +       if ((vxi = p->vx_info))
11474 +               atomic_dec(&vxi->cvirt.nr_uninterruptible);
11475 +}
11476 +
11477 +
11478 +#else
11479 +#warning duplicate inclusion
11480 +#endif
11481 diff -NurpP --minimal linux-3.0.4/include/linux/vs_device.h linux-3.0.4-vs2.3.1/include/linux/vs_device.h
11482 --- linux-3.0.4/include/linux/vs_device.h       1970-01-01 01:00:00.000000000 +0100
11483 +++ linux-3.0.4-vs2.3.1/include/linux/vs_device.h       2011-06-10 22:11:24.000000000 +0200
11484 @@ -0,0 +1,45 @@
11485 +#ifndef _VS_DEVICE_H
11486 +#define _VS_DEVICE_H
11487 +
11488 +#include "vserver/base.h"
11489 +#include "vserver/device.h"
11490 +#include "vserver/debug.h"
11491 +
11492 +
11493 +#ifdef CONFIG_VSERVER_DEVICE
11494 +
11495 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
11496 +
11497 +#define vs_device_perm(v, d, m, p) \
11498 +       ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
11499 +
11500 +#else
11501 +
11502 +static inline
11503 +int vs_map_device(struct vx_info *vxi,
11504 +       dev_t device, dev_t *target, umode_t mode)
11505 +{
11506 +       if (target)
11507 +               *target = device;
11508 +       return ~0;
11509 +}
11510 +
11511 +#define vs_device_perm(v, d, m, p) ((p) == (p))
11512 +
11513 +#endif
11514 +
11515 +
11516 +#define vs_map_chrdev(d, t, p) \
11517 +       ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
11518 +#define vs_map_blkdev(d, t, p) \
11519 +       ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
11520 +
11521 +#define vs_chrdev_perm(d, p) \
11522 +       vs_device_perm(current_vx_info(), d, S_IFCHR, p)
11523 +#define vs_blkdev_perm(d, p) \
11524 +       vs_device_perm(current_vx_info(), d, S_IFBLK, p)
11525 +
11526 +
11527 +#else
11528 +#warning duplicate inclusion
11529 +#endif
11530 diff -NurpP --minimal linux-3.0.4/include/linux/vs_dlimit.h linux-3.0.4-vs2.3.1/include/linux/vs_dlimit.h
11531 --- linux-3.0.4/include/linux/vs_dlimit.h       1970-01-01 01:00:00.000000000 +0100
11532 +++ linux-3.0.4-vs2.3.1/include/linux/vs_dlimit.h       2011-06-10 22:11:24.000000000 +0200
11533 @@ -0,0 +1,215 @@
11534 +#ifndef _VS_DLIMIT_H
11535 +#define _VS_DLIMIT_H
11536 +
11537 +#include <linux/fs.h>
11538 +
11539 +#include "vserver/dlimit.h"
11540 +#include "vserver/base.h"
11541 +#include "vserver/debug.h"
11542 +
11543 +
11544 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
11545 +
11546 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
11547 +       const char *_file, int _line)
11548 +{
11549 +       if (!dli)
11550 +               return NULL;
11551 +       vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
11552 +               dli, dli ? dli->dl_tag : 0,
11553 +               dli ? atomic_read(&dli->dl_usecnt) : 0,
11554 +               _file, _line);
11555 +       atomic_inc(&dli->dl_usecnt);
11556 +       return dli;
11557 +}
11558 +
11559 +
11560 +#define free_dl_info(i) \
11561 +       call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
11562 +
11563 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
11564 +
11565 +static inline void __put_dl_info(struct dl_info *dli,
11566 +       const char *_file, int _line)
11567 +{
11568 +       if (!dli)
11569 +               return;
11570 +       vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
11571 +               dli, dli ? dli->dl_tag : 0,
11572 +               dli ? atomic_read(&dli->dl_usecnt) : 0,
11573 +               _file, _line);
11574 +       if (atomic_dec_and_test(&dli->dl_usecnt))
11575 +               free_dl_info(dli);
11576 +}
11577 +
11578 +
11579 +#define __dlimit_char(d)       ((d) ? '*' : ' ')
11580 +
11581 +static inline int __dl_alloc_space(struct super_block *sb,
11582 +       tag_t tag, dlsize_t nr, const char *file, int line)
11583 +{
11584 +       struct dl_info *dli = NULL;
11585 +       int ret = 0;
11586 +
11587 +       if (nr == 0)
11588 +               goto out;
11589 +       dli = locate_dl_info(sb, tag);
11590 +       if (!dli)
11591 +               goto out;
11592 +
11593 +       spin_lock(&dli->dl_lock);
11594 +       ret = (dli->dl_space_used + nr > dli->dl_space_total);
11595 +       if (!ret)
11596 +               dli->dl_space_used += nr;
11597 +       spin_unlock(&dli->dl_lock);
11598 +       put_dl_info(dli);
11599 +out:
11600 +       vxlprintk(VXD_CBIT(dlim, 1),
11601 +               "ALLOC (%p,#%d)%c %lld bytes (%d)",
11602 +               sb, tag, __dlimit_char(dli), (long long)nr,
11603 +               ret, file, line);
11604 +       return ret ? -ENOSPC : 0;
11605 +}
11606 +
11607 +static inline void __dl_free_space(struct super_block *sb,
11608 +       tag_t tag, dlsize_t nr, const char *_file, int _line)
11609 +{
11610 +       struct dl_info *dli = NULL;
11611 +
11612 +       if (nr == 0)
11613 +               goto out;
11614 +       dli = locate_dl_info(sb, tag);
11615 +       if (!dli)
11616 +               goto out;
11617 +
11618 +       spin_lock(&dli->dl_lock);
11619 +       if (dli->dl_space_used > nr)
11620 +               dli->dl_space_used -= nr;
11621 +       else
11622 +               dli->dl_space_used = 0;
11623 +       spin_unlock(&dli->dl_lock);
11624 +       put_dl_info(dli);
11625 +out:
11626 +       vxlprintk(VXD_CBIT(dlim, 1),
11627 +               "FREE  (%p,#%d)%c %lld bytes",
11628 +               sb, tag, __dlimit_char(dli), (long long)nr,
11629 +               _file, _line);
11630 +}
11631 +
11632 +static inline int __dl_alloc_inode(struct super_block *sb,
11633 +       tag_t tag, const char *_file, int _line)
11634 +{
11635 +       struct dl_info *dli;
11636 +       int ret = 0;
11637 +
11638 +       dli = locate_dl_info(sb, tag);
11639 +       if (!dli)
11640 +               goto out;
11641 +
11642 +       spin_lock(&dli->dl_lock);
11643 +       dli->dl_inodes_used++;
11644 +       ret = (dli->dl_inodes_used > dli->dl_inodes_total);
11645 +       spin_unlock(&dli->dl_lock);
11646 +       put_dl_info(dli);
11647 +out:
11648 +       vxlprintk(VXD_CBIT(dlim, 0),
11649 +               "ALLOC (%p,#%d)%c inode (%d)",
11650 +               sb, tag, __dlimit_char(dli), ret, _file, _line);
11651 +       return ret ? -ENOSPC : 0;
11652 +}
11653 +
11654 +static inline void __dl_free_inode(struct super_block *sb,
11655 +       tag_t tag, const char *_file, int _line)
11656 +{
11657 +       struct dl_info *dli;
11658 +
11659 +       dli = locate_dl_info(sb, tag);
11660 +       if (!dli)
11661 +               goto out;
11662 +
11663 +       spin_lock(&dli->dl_lock);
11664 +       if (dli->dl_inodes_used > 1)
11665 +               dli->dl_inodes_used--;
11666 +       else
11667 +               dli->dl_inodes_used = 0;
11668 +       spin_unlock(&dli->dl_lock);
11669 +       put_dl_info(dli);
11670 +out:
11671 +       vxlprintk(VXD_CBIT(dlim, 0),
11672 +               "FREE  (%p,#%d)%c inode",
11673 +               sb, tag, __dlimit_char(dli), _file, _line);
11674 +}
11675 +
11676 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
11677 +       unsigned long long *free_blocks, unsigned long long *root_blocks,
11678 +       const char *_file, int _line)
11679 +{
11680 +       struct dl_info *dli;
11681 +       uint64_t broot, bfree;
11682 +
11683 +       dli = locate_dl_info(sb, tag);
11684 +       if (!dli)
11685 +               return;
11686 +
11687 +       spin_lock(&dli->dl_lock);
11688 +       broot = (dli->dl_space_total -
11689 +               (dli->dl_space_total >> 10) * dli->dl_nrlmult)
11690 +               >> sb->s_blocksize_bits;
11691 +       bfree = (dli->dl_space_total - dli->dl_space_used)
11692 +                       >> sb->s_blocksize_bits;
11693 +       spin_unlock(&dli->dl_lock);
11694 +
11695 +       vxlprintk(VXD_CBIT(dlim, 2),
11696 +               "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
11697 +               (long long)bfree, (long long)broot,
11698 +               *free_blocks, *root_blocks, dli->dl_nrlmult,
11699 +               _file, _line);
11700 +       if (free_blocks) {
11701 +               if (*free_blocks > bfree)
11702 +                       *free_blocks = bfree;
11703 +       }
11704 +       if (root_blocks) {
11705 +               if (*root_blocks > broot)
11706 +                       *root_blocks = broot;
11707 +       }
11708 +       put_dl_info(dli);
11709 +}
11710 +
11711 +#define dl_prealloc_space(in, bytes) \
11712 +       __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11713 +               __FILE__, __LINE__ )
11714 +
11715 +#define dl_alloc_space(in, bytes) \
11716 +       __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11717 +               __FILE__, __LINE__ )
11718 +
11719 +#define dl_reserve_space(in, bytes) \
11720 +       __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11721 +               __FILE__, __LINE__ )
11722 +
11723 +#define dl_claim_space(in, bytes) (0)
11724 +
11725 +#define dl_release_space(in, bytes) \
11726 +       __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11727 +               __FILE__, __LINE__ )
11728 +
11729 +#define dl_free_space(in, bytes) \
11730 +       __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11731 +               __FILE__, __LINE__ )
11732 +
11733 +
11734 +
11735 +#define dl_alloc_inode(in) \
11736 +       __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
11737 +
11738 +#define dl_free_inode(in) \
11739 +       __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
11740 +
11741 +
11742 +#define dl_adjust_block(sb, tag, fb, rb) \
11743 +       __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
11744 +
11745 +
11746 +#else
11747 +#warning duplicate inclusion
11748 +#endif
11749 diff -NurpP --minimal linux-3.0.4/include/linux/vs_inet.h linux-3.0.4-vs2.3.1/include/linux/vs_inet.h
11750 --- linux-3.0.4/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
11751 +++ linux-3.0.4-vs2.3.1/include/linux/vs_inet.h 2011-08-18 17:01:00.000000000 +0200
11752 @@ -0,0 +1,353 @@
11753 +#ifndef _VS_INET_H
11754 +#define _VS_INET_H
11755 +
11756 +#include "vserver/base.h"
11757 +#include "vserver/network.h"
11758 +#include "vserver/debug.h"
11759 +
11760 +#define IPI_LOOPBACK   htonl(INADDR_LOOPBACK)
11761 +
11762 +#define NXAV4(a)       NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
11763 +                       NIPQUAD((a)->mask), (a)->type
11764 +#define NXAV4_FMT      "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
11765 +
11766 +#define NIPQUAD(addr) \
11767 +       ((unsigned char *)&addr)[0], \
11768 +       ((unsigned char *)&addr)[1], \
11769 +       ((unsigned char *)&addr)[2], \
11770 +       ((unsigned char *)&addr)[3]
11771 +
11772 +#define NIPQUAD_FMT "%u.%u.%u.%u"
11773 +
11774 +
11775 +static inline
11776 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
11777 +{
11778 +       __be32 ip = nxa->ip[0].s_addr;
11779 +       __be32 mask = nxa->mask.s_addr;
11780 +       __be32 bcast = ip | ~mask;
11781 +       int ret = 0;
11782 +
11783 +       switch (nxa->type & tmask) {
11784 +       case NXA_TYPE_MASK:
11785 +               ret = (ip == (addr & mask));
11786 +               break;
11787 +       case NXA_TYPE_ADDR:
11788 +               ret = 3;
11789 +               if (addr == ip)
11790 +                       break;
11791 +               /* fall through to broadcast */
11792 +       case NXA_MOD_BCAST:
11793 +               ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
11794 +               break;
11795 +       case NXA_TYPE_RANGE:
11796 +               ret = ((nxa->ip[0].s_addr <= addr) &&
11797 +                       (nxa->ip[1].s_addr > addr));
11798 +               break;
11799 +       case NXA_TYPE_ANY:
11800 +               ret = 2;
11801 +               break;
11802 +       }
11803 +
11804 +       vxdprintk(VXD_CBIT(net, 0),
11805 +               "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
11806 +               nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
11807 +       return ret;
11808 +}
11809 +
11810 +static inline
11811 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
11812 +{
11813 +       struct nx_addr_v4 *nxa;
11814 +       int ret = 1;
11815 +
11816 +       if (!nxi)
11817 +               goto out;
11818 +
11819 +       ret = 2;
11820 +       /* allow 127.0.0.1 when remapping lback */
11821 +       if ((tmask & NXA_LOOPBACK) &&
11822 +               (addr == IPI_LOOPBACK) &&
11823 +               nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
11824 +               goto out;
11825 +       ret = 3;
11826 +       /* check for lback address */
11827 +       if ((tmask & NXA_MOD_LBACK) &&
11828 +               (nxi->v4_lback.s_addr == addr))
11829 +               goto out;
11830 +       ret = 4;
11831 +       /* check for broadcast address */
11832 +       if ((tmask & NXA_MOD_BCAST) &&
11833 +               (nxi->v4_bcast.s_addr == addr))
11834 +               goto out;
11835 +       ret = 5;
11836 +       /* check for v4 addresses */
11837 +       for (nxa = &nxi->v4; nxa; nxa = nxa->next)
11838 +               if (v4_addr_match(nxa, addr, tmask))
11839 +                       goto out;
11840 +       ret = 0;
11841 +out:
11842 +       vxdprintk(VXD_CBIT(net, 0),
11843 +               "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
11844 +               nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
11845 +       return ret;
11846 +}
11847 +
11848 +static inline
11849 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
11850 +{
11851 +       /* FIXME: needs full range checks */
11852 +       return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
11853 +}
11854 +
11855 +static inline
11856 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
11857 +{
11858 +       struct nx_addr_v4 *ptr;
11859 +
11860 +       for (ptr = &nxi->v4; ptr; ptr = ptr->next)
11861 +               if (v4_nx_addr_match(ptr, nxa, mask))
11862 +                       return 1;
11863 +       return 0;
11864 +}
11865 +
11866 +#include <net/inet_sock.h>
11867 +
11868 +/*
11869 + *     Check if a given address matches for a socket
11870 + *
11871 + *     nxi:            the socket's nx_info if any
11872 + *     addr:           to be verified address
11873 + */
11874 +static inline
11875 +int v4_sock_addr_match (
11876 +       struct nx_info *nxi,
11877 +       struct inet_sock *inet,
11878 +       __be32 addr)
11879 +{
11880 +       __be32 saddr = inet->inet_rcv_saddr;
11881 +       __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
11882 +
11883 +       if (addr && (saddr == addr || bcast == addr))
11884 +               return 1;
11885 +       if (!saddr)
11886 +               return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
11887 +       return 0;
11888 +}
11889 +
11890 +
11891 +/* inet related checks and helpers */
11892 +
11893 +
11894 +struct in_ifaddr;
11895 +struct net_device;
11896 +struct sock;
11897 +
11898 +#ifdef CONFIG_INET
11899 +
11900 +#include <linux/netdevice.h>
11901 +#include <linux/inetdevice.h>
11902 +#include <net/inet_sock.h>
11903 +#include <net/inet_timewait_sock.h>
11904 +
11905 +
11906 +int dev_in_nx_info(struct net_device *, struct nx_info *);
11907 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
11908 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
11909 +
11910 +
11911 +/*
11912 + *     check if address is covered by socket
11913 + *
11914 + *     sk:     the socket to check against
11915 + *     addr:   the address in question (must be != 0)
11916 + */
11917 +
11918 +static inline
11919 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
11920 +{
11921 +       struct nx_info *nxi = sk->sk_nx_info;
11922 +       __be32 saddr = sk_rcv_saddr(sk);
11923 +
11924 +       vxdprintk(VXD_CBIT(net, 5),
11925 +               "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
11926 +               sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
11927 +               (sk->sk_socket?sk->sk_socket->flags:0));
11928 +
11929 +       if (saddr) {            /* direct address match */
11930 +               return v4_addr_match(nxa, saddr, -1);
11931 +       } else if (nxi) {       /* match against nx_info */
11932 +               return v4_nx_addr_in_nx_info(nxi, nxa, -1);
11933 +       } else {                /* unrestricted any socket */
11934 +               return 1;
11935 +       }
11936 +}
11937 +
11938 +
11939 +
11940 +static inline
11941 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
11942 +{
11943 +       vxdprintk(VXD_CBIT(net, 1),
11944 +               "nx_dev_visible(%p[#%u],%p " VS_Q("%s") ") %d",
11945 +               nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
11946 +               nxi ? dev_in_nx_info(dev, nxi) : 0);
11947 +
11948 +       if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
11949 +               return 1;
11950 +       if (dev_in_nx_info(dev, nxi))
11951 +               return 1;
11952 +       return 0;
11953 +}
11954 +
11955 +
11956 +static inline
11957 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
11958 +{
11959 +       if (!nxi)
11960 +               return 1;
11961 +       if (!ifa)
11962 +               return 0;
11963 +       return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
11964 +}
11965 +
11966 +static inline
11967 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
11968 +{
11969 +       vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
11970 +               nxi, nxi ? nxi->nx_id : 0, ifa,
11971 +               nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
11972 +
11973 +       if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
11974 +               return 1;
11975 +       if (v4_ifa_in_nx_info(ifa, nxi))
11976 +               return 1;
11977 +       return 0;
11978 +}
11979 +
11980 +
11981 +struct nx_v4_sock_addr {
11982 +       __be32 saddr;   /* Address used for validation */
11983 +       __be32 baddr;   /* Address used for socket bind */
11984 +};
11985 +
11986 +static inline
11987 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
11988 +       struct nx_v4_sock_addr *nsa)
11989 +{
11990 +       struct sock *sk = &inet->sk;
11991 +       struct nx_info *nxi = sk->sk_nx_info;
11992 +       __be32 saddr = addr->sin_addr.s_addr;
11993 +       __be32 baddr = saddr;
11994 +
11995 +       vxdprintk(VXD_CBIT(net, 3),
11996 +               "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
11997 +               sk, sk->sk_nx_info, sk->sk_socket,
11998 +               (sk->sk_socket ? sk->sk_socket->flags : 0),
11999 +               NIPQUAD(saddr));
12000 +
12001 +       if (nxi) {
12002 +               if (saddr == INADDR_ANY) {
12003 +                       if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
12004 +                               baddr = nxi->v4.ip[0].s_addr;
12005 +               } else if (saddr == IPI_LOOPBACK) {
12006 +                       if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
12007 +                               baddr = nxi->v4_lback.s_addr;
12008 +               } else if (!ipv4_is_multicast(saddr) ||
12009 +                       !nx_info_ncaps(nxi, NXC_MULTICAST)) {
12010 +                       /* normal address bind */
12011 +                       if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
12012 +                               return -EADDRNOTAVAIL;
12013 +               }
12014 +       }
12015 +
12016 +       vxdprintk(VXD_CBIT(net, 3),
12017 +               "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
12018 +               sk, NIPQUAD(saddr), NIPQUAD(baddr));
12019 +
12020 +       nsa->saddr = saddr;
12021 +       nsa->baddr = baddr;
12022 +       return 0;
12023 +}
12024 +
12025 +static inline
12026 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
12027 +{
12028 +       inet->inet_saddr = nsa->baddr;
12029 +       inet->inet_rcv_saddr = nsa->baddr;
12030 +}
12031 +
12032 +
12033 +/*
12034 + *      helper to simplify inet_lookup_listener
12035 + *
12036 + *      nxi:   the socket's nx_info if any
12037 + *      addr:  to be verified address
12038 + *      saddr: socket address
12039 + */
12040 +static inline int v4_inet_addr_match (
12041 +       struct nx_info *nxi,
12042 +       __be32 addr,
12043 +       __be32 saddr)
12044 +{
12045 +       if (addr && (saddr == addr))
12046 +               return 1;
12047 +       if (!saddr)
12048 +               return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
12049 +       return 0;
12050 +}
12051 +
12052 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
12053 +{
12054 +       if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
12055 +               (addr == nxi->v4_lback.s_addr))
12056 +               return IPI_LOOPBACK;
12057 +       return addr;
12058 +}
12059 +
12060 +static inline
12061 +int nx_info_has_v4(struct nx_info *nxi)
12062 +{
12063 +       if (!nxi)
12064 +               return 1;
12065 +       if (NX_IPV4(nxi))
12066 +               return 1;
12067 +       if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
12068 +               return 1;
12069 +       return 0;
12070 +}
12071 +
12072 +#else /* CONFIG_INET */
12073 +
12074 +static inline
12075 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
12076 +{
12077 +       return 1;
12078 +}
12079 +
12080 +static inline
12081 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
12082 +{
12083 +       return 1;
12084 +}
12085 +
12086 +static inline
12087 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
12088 +{
12089 +       return 1;
12090 +}
12091 +
12092 +static inline
12093 +int nx_info_has_v4(struct nx_info *nxi)
12094 +{
12095 +       return 0;
12096 +}
12097 +
12098 +#endif /* CONFIG_INET */
12099 +
12100 +#define current_nx_info_has_v4() \
12101 +       nx_info_has_v4(current_nx_info())
12102 +
12103 +#else
12104 +// #warning duplicate inclusion
12105 +#endif
12106 diff -NurpP --minimal linux-3.0.4/include/linux/vs_inet6.h linux-3.0.4-vs2.3.1/include/linux/vs_inet6.h
12107 --- linux-3.0.4/include/linux/vs_inet6.h        1970-01-01 01:00:00.000000000 +0100
12108 +++ linux-3.0.4-vs2.3.1/include/linux/vs_inet6.h        2011-06-10 22:11:24.000000000 +0200
12109 @@ -0,0 +1,246 @@
12110 +#ifndef _VS_INET6_H
12111 +#define _VS_INET6_H
12112 +
12113 +#include "vserver/base.h"
12114 +#include "vserver/network.h"
12115 +#include "vserver/debug.h"
12116 +
12117 +#include <net/ipv6.h>
12118 +
12119 +#define NXAV6(a)       &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
12120 +#define NXAV6_FMT      "[%pI6/%pI6/%d:%04x]"
12121 +
12122 +
12123 +#ifdef CONFIG_IPV6
12124 +
12125 +static inline
12126 +int v6_addr_match(struct nx_addr_v6 *nxa,
12127 +       const struct in6_addr *addr, uint16_t mask)
12128 +{
12129 +       int ret = 0;
12130 +
12131 +       switch (nxa->type & mask) {
12132 +       case NXA_TYPE_MASK:
12133 +               ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
12134 +               break;
12135 +       case NXA_TYPE_ADDR:
12136 +               ret = ipv6_addr_equal(&nxa->ip, addr);
12137 +               break;
12138 +       case NXA_TYPE_ANY:
12139 +               ret = 1;
12140 +               break;
12141 +       }
12142 +       vxdprintk(VXD_CBIT(net, 0),
12143 +               "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
12144 +               nxa, NXAV6(nxa), addr, mask, ret);
12145 +       return ret;
12146 +}
12147 +
12148 +static inline
12149 +int v6_addr_in_nx_info(struct nx_info *nxi,
12150 +       const struct in6_addr *addr, uint16_t mask)
12151 +{
12152 +       struct nx_addr_v6 *nxa;
12153 +       int ret = 1;
12154 +
12155 +       if (!nxi)
12156 +               goto out;
12157 +       for (nxa = &nxi->v6; nxa; nxa = nxa->next)
12158 +               if (v6_addr_match(nxa, addr, mask))
12159 +                       goto out;
12160 +       ret = 0;
12161 +out:
12162 +       vxdprintk(VXD_CBIT(net, 0),
12163 +               "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
12164 +               nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
12165 +       return ret;
12166 +}
12167 +
12168 +static inline
12169 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
12170 +{
12171 +       /* FIXME: needs full range checks */
12172 +       return v6_addr_match(nxa, &addr->ip, mask);
12173 +}
12174 +
12175 +static inline
12176 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
12177 +{
12178 +       struct nx_addr_v6 *ptr;
12179 +
12180 +       for (ptr = &nxi->v6; ptr; ptr = ptr->next)
12181 +               if (v6_nx_addr_match(ptr, nxa, mask))
12182 +                       return 1;
12183 +       return 0;
12184 +}
12185 +
12186 +
12187 +/*
12188 + *     Check if a given address matches for a socket
12189 + *
12190 + *     nxi:            the socket's nx_info if any
12191 + *     addr:           to be verified address
12192 + */
12193 +static inline
12194 +int v6_sock_addr_match (
12195 +       struct nx_info *nxi,
12196 +       struct inet_sock *inet,
12197 +       struct in6_addr *addr)
12198 +{
12199 +       struct sock *sk = &inet->sk;
12200 +       struct in6_addr *saddr = inet6_rcv_saddr(sk);
12201 +
12202 +       if (!ipv6_addr_any(addr) &&
12203 +               ipv6_addr_equal(saddr, addr))
12204 +               return 1;
12205 +       if (ipv6_addr_any(saddr))
12206 +               return v6_addr_in_nx_info(nxi, addr, -1);
12207 +       return 0;
12208 +}
12209 +
12210 +/*
12211 + *     check if address is covered by socket
12212 + *
12213 + *     sk:     the socket to check against
12214 + *     addr:   the address in question (must be != 0)
12215 + */
12216 +
12217 +static inline
12218 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
12219 +{
12220 +       struct nx_info *nxi = sk->sk_nx_info;
12221 +       struct in6_addr *saddr = inet6_rcv_saddr(sk);
12222 +
12223 +       vxdprintk(VXD_CBIT(net, 5),
12224 +               "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
12225 +               sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
12226 +               (sk->sk_socket?sk->sk_socket->flags:0));
12227 +
12228 +       if (!ipv6_addr_any(saddr)) {    /* direct address match */
12229 +               return v6_addr_match(nxa, saddr, -1);
12230 +       } else if (nxi) {               /* match against nx_info */
12231 +               return v6_nx_addr_in_nx_info(nxi, nxa, -1);
12232 +       } else {                        /* unrestricted any socket */
12233 +               return 1;
12234 +       }
12235 +}
12236 +
12237 +
12238 +/* inet related checks and helpers */
12239 +
12240 +
12241 +struct in_ifaddr;
12242 +struct net_device;
12243 +struct sock;
12244 +
12245 +
12246 +#include <linux/netdevice.h>
12247 +#include <linux/inetdevice.h>
12248 +#include <net/inet_timewait_sock.h>
12249 +
12250 +
12251 +int dev_in_nx_info(struct net_device *, struct nx_info *);
12252 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
12253 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
12254 +
12255 +
12256 +
12257 +static inline
12258 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
12259 +{
12260 +       if (!nxi)
12261 +               return 1;
12262 +       if (!ifa)
12263 +               return 0;
12264 +       return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
12265 +}
12266 +
12267 +static inline
12268 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
12269 +{
12270 +       vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
12271 +               nxi, nxi ? nxi->nx_id : 0, ifa,
12272 +               nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
12273 +
12274 +       if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
12275 +               return 1;
12276 +       if (v6_ifa_in_nx_info(ifa, nxi))
12277 +               return 1;
12278 +       return 0;
12279 +}
12280 +
12281 +
12282 +struct nx_v6_sock_addr {
12283 +       struct in6_addr saddr;  /* Address used for validation */
12284 +       struct in6_addr baddr;  /* Address used for socket bind */
12285 +};
12286 +
12287 +static inline
12288 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
12289 +       struct nx_v6_sock_addr *nsa)
12290 +{
12291 +       // struct sock *sk = &inet->sk;
12292 +       // struct nx_info *nxi = sk->sk_nx_info;
12293 +       struct in6_addr saddr = addr->sin6_addr;
12294 +       struct in6_addr baddr = saddr;
12295 +
12296 +       nsa->saddr = saddr;
12297 +       nsa->baddr = baddr;
12298 +       return 0;
12299 +}
12300 +
12301 +static inline
12302 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
12303 +{
12304 +       // struct sock *sk = &inet->sk;
12305 +       // struct in6_addr *saddr = inet6_rcv_saddr(sk);
12306 +
12307 +       // *saddr = nsa->baddr;
12308 +       // inet->inet_saddr = nsa->baddr;
12309 +}
12310 +
12311 +static inline
12312 +int nx_info_has_v6(struct nx_info *nxi)
12313 +{
12314 +       if (!nxi)
12315 +               return 1;
12316 +       if (NX_IPV6(nxi))
12317 +               return 1;
12318 +       return 0;
12319 +}
12320 +
12321 +#else /* CONFIG_IPV6 */
12322 +
12323 +static inline
12324 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
12325 +{
12326 +       return 1;
12327 +}
12328 +
12329 +
12330 +static inline
12331 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
12332 +{
12333 +       return 1;
12334 +}
12335 +
12336 +static inline
12337 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
12338 +{
12339 +       return 1;
12340 +}
12341 +
12342 +static inline
12343 +int nx_info_has_v6(struct nx_info *nxi)
12344 +{
12345 +       return 0;
12346 +}
12347 +
12348 +#endif /* CONFIG_IPV6 */
12349 +
12350 +#define current_nx_info_has_v6() \
12351 +       nx_info_has_v6(current_nx_info())
12352 +
12353 +#else
12354 +#warning duplicate inclusion
12355 +#endif
12356 diff -NurpP --minimal linux-3.0.4/include/linux/vs_limit.h linux-3.0.4-vs2.3.1/include/linux/vs_limit.h
12357 --- linux-3.0.4/include/linux/vs_limit.h        1970-01-01 01:00:00.000000000 +0100
12358 +++ linux-3.0.4-vs2.3.1/include/linux/vs_limit.h        2011-06-10 22:11:24.000000000 +0200
12359 @@ -0,0 +1,140 @@
12360 +#ifndef _VS_LIMIT_H
12361 +#define _VS_LIMIT_H
12362 +
12363 +#include "vserver/limit.h"
12364 +#include "vserver/base.h"
12365 +#include "vserver/context.h"
12366 +#include "vserver/debug.h"
12367 +#include "vserver/context.h"
12368 +#include "vserver/limit_int.h"
12369 +
12370 +
12371 +#define vx_acc_cres(v, d, p, r) \
12372 +       __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
12373 +
12374 +#define vx_acc_cres_cond(x, d, p, r) \
12375 +       __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
12376 +       r, d, p, __FILE__, __LINE__)
12377 +
12378 +
12379 +#define vx_add_cres(v, a, p, r) \
12380 +       __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
12381 +#define vx_sub_cres(v, a, p, r)                vx_add_cres(v, -(a), p, r)
12382 +
12383 +#define vx_add_cres_cond(x, a, p, r) \
12384 +       __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
12385 +       r, a, p, __FILE__, __LINE__)
12386 +#define vx_sub_cres_cond(x, a, p, r)   vx_add_cres_cond(x, -(a), p, r)
12387 +
12388 +
12389 +/* process and file limits */
12390 +
12391 +#define vx_nproc_inc(p) \
12392 +       vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
12393 +
12394 +#define vx_nproc_dec(p) \
12395 +       vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
12396 +
12397 +#define vx_files_inc(f) \
12398 +       vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
12399 +
12400 +#define vx_files_dec(f) \
12401 +       vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
12402 +
12403 +#define vx_locks_inc(l) \
12404 +       vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
12405 +
12406 +#define vx_locks_dec(l) \
12407 +       vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
12408 +
12409 +#define vx_openfd_inc(f) \
12410 +       vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
12411 +
12412 +#define vx_openfd_dec(f) \
12413 +       vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
12414 +
12415 +
12416 +#define vx_cres_avail(v, n, r) \
12417 +       __vx_cres_avail(v, r, n, __FILE__, __LINE__)
12418 +
12419 +
12420 +#define vx_nproc_avail(n) \
12421 +       vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
12422 +
12423 +#define vx_files_avail(n) \
12424 +       vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
12425 +
12426 +#define vx_locks_avail(n) \
12427 +       vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
12428 +
12429 +#define vx_openfd_avail(n) \
12430 +       vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
12431 +
12432 +
12433 +/* dentry limits */
12434 +
12435 +#define vx_dentry_inc(d) do {                                          \
12436 +       if ((d)->d_count == 1)                                          \
12437 +               vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY);    \
12438 +       } while (0)
12439 +
12440 +#define vx_dentry_dec(d) do {                                          \
12441 +       if ((d)->d_count == 0)                                          \
12442 +               vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY);    \
12443 +       } while (0)
12444 +
12445 +#define vx_dentry_avail(n) \
12446 +       vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
12447 +
12448 +
12449 +/* socket limits */
12450 +
12451 +#define vx_sock_inc(s) \
12452 +       vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
12453 +
12454 +#define vx_sock_dec(s) \
12455 +       vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
12456 +
12457 +#define vx_sock_avail(n) \
12458 +       vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
12459 +
12460 +
12461 +/* ipc resource limits */
12462 +
12463 +#define vx_ipcmsg_add(v, u, a) \
12464 +       vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
12465 +
12466 +#define vx_ipcmsg_sub(v, u, a) \
12467 +       vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
12468 +
12469 +#define vx_ipcmsg_avail(v, a) \
12470 +       vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
12471 +
12472 +
12473 +#define vx_ipcshm_add(v, k, a) \
12474 +       vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
12475 +
12476 +#define vx_ipcshm_sub(v, k, a) \
12477 +       vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
12478 +
12479 +#define vx_ipcshm_avail(v, a) \
12480 +       vx_cres_avail(v, a, VLIMIT_SHMEM)
12481 +
12482 +
12483 +#define vx_semary_inc(a) \
12484 +       vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
12485 +
12486 +#define vx_semary_dec(a) \
12487 +       vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
12488 +
12489 +
12490 +#define vx_nsems_add(a,n) \
12491 +       vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
12492 +
12493 +#define vx_nsems_sub(a,n) \
12494 +       vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
12495 +
12496 +
12497 +#else
12498 +#warning duplicate inclusion
12499 +#endif
12500 diff -NurpP --minimal linux-3.0.4/include/linux/vs_memory.h linux-3.0.4-vs2.3.1/include/linux/vs_memory.h
12501 --- linux-3.0.4/include/linux/vs_memory.h       1970-01-01 01:00:00.000000000 +0100
12502 +++ linux-3.0.4-vs2.3.1/include/linux/vs_memory.h       2011-06-10 22:11:24.000000000 +0200
12503 @@ -0,0 +1,58 @@
12504 +#ifndef _VS_MEMORY_H
12505 +#define _VS_MEMORY_H
12506 +
12507 +#include "vserver/limit.h"
12508 +#include "vserver/base.h"
12509 +#include "vserver/context.h"
12510 +#include "vserver/debug.h"
12511 +#include "vserver/context.h"
12512 +#include "vserver/limit_int.h"
12513 +
12514 +enum {
12515 +       VXPT_UNKNOWN = 0,
12516 +       VXPT_ANON,
12517 +       VXPT_NONE,
12518 +       VXPT_FILE,
12519 +       VXPT_SWAP,
12520 +       VXPT_WRITE
12521 +};
12522 +
12523 +#if 0
12524 +#define        vx_page_fault(mm, vma, type, ret)
12525 +#else
12526 +
12527 +static inline
12528 +void __vx_page_fault(struct mm_struct *mm,
12529 +       struct vm_area_struct *vma, int type, int ret)
12530 +{
12531 +       struct vx_info *vxi = mm->mm_vx_info;
12532 +       int what;
12533 +/*
12534 +       static char *page_type[6] =
12535 +               { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
12536 +       static char *page_what[4] =
12537 +               { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
12538 +*/
12539 +
12540 +       if (!vxi)
12541 +               return;
12542 +
12543 +       what = (ret & 0x3);
12544 +
12545 +/*     printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
12546 +               type, what, ret, page_type[type], page_what[what]);
12547 +*/
12548 +       if (ret & VM_FAULT_WRITE)
12549 +               what |= 0x4;
12550 +       atomic_inc(&vxi->cacct.page[type][what]);
12551 +}
12552 +
12553 +#define        vx_page_fault(mm, vma, type, ret)       __vx_page_fault(mm, vma, type, ret)
12554 +#endif
12555 +
12556 +
12557 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
12558 +
12559 +#else
12560 +#warning duplicate inclusion
12561 +#endif
12562 diff -NurpP --minimal linux-3.0.4/include/linux/vs_network.h linux-3.0.4-vs2.3.1/include/linux/vs_network.h
12563 --- linux-3.0.4/include/linux/vs_network.h      1970-01-01 01:00:00.000000000 +0100
12564 +++ linux-3.0.4-vs2.3.1/include/linux/vs_network.h      2011-06-10 22:11:24.000000000 +0200
12565 @@ -0,0 +1,169 @@
12566 +#ifndef _NX_VS_NETWORK_H
12567 +#define _NX_VS_NETWORK_H
12568 +
12569 +#include "vserver/context.h"
12570 +#include "vserver/network.h"
12571 +#include "vserver/base.h"
12572 +#include "vserver/check.h"
12573 +#include "vserver/debug.h"
12574 +
12575 +#include <linux/sched.h>
12576 +
12577 +
12578 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
12579 +
12580 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
12581 +       const char *_file, int _line)
12582 +{
12583 +       if (!nxi)
12584 +               return NULL;
12585 +
12586 +       vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
12587 +               nxi, nxi ? nxi->nx_id : 0,
12588 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
12589 +               _file, _line);
12590 +
12591 +       atomic_inc(&nxi->nx_usecnt);
12592 +       return nxi;
12593 +}
12594 +
12595 +
12596 +extern void free_nx_info(struct nx_info *);
12597 +
12598 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
12599 +
12600 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
12601 +{
12602 +       if (!nxi)
12603 +               return;
12604 +
12605 +       vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
12606 +               nxi, nxi ? nxi->nx_id : 0,
12607 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
12608 +               _file, _line);
12609 +
12610 +       if (atomic_dec_and_test(&nxi->nx_usecnt))
12611 +               free_nx_info(nxi);
12612 +}
12613 +
12614 +
12615 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
12616 +
12617 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
12618 +               const char *_file, int _line)
12619 +{
12620 +       if (nxi) {
12621 +               vxlprintk(VXD_CBIT(nid, 3),
12622 +                       "init_nx_info(%p[#%d.%d])",
12623 +                       nxi, nxi ? nxi->nx_id : 0,
12624 +                       nxi ? atomic_read(&nxi->nx_usecnt) : 0,
12625 +                       _file, _line);
12626 +
12627 +               atomic_inc(&nxi->nx_usecnt);
12628 +       }
12629 +       *nxp = nxi;
12630 +}
12631 +
12632 +
12633 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
12634 +
12635 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
12636 +       const char *_file, int _line)
12637 +{
12638 +       struct nx_info *nxo;
12639 +
12640 +       if (!nxi)
12641 +               return;
12642 +
12643 +       vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
12644 +               nxi, nxi ? nxi->nx_id : 0,
12645 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
12646 +               _file, _line);
12647 +
12648 +       atomic_inc(&nxi->nx_usecnt);
12649 +       nxo = xchg(nxp, nxi);
12650 +       BUG_ON(nxo);
12651 +}
12652 +
12653 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
12654 +
12655 +static inline void __clr_nx_info(struct nx_info **nxp,
12656 +       const char *_file, int _line)
12657 +{
12658 +       struct nx_info *nxo;
12659 +
12660 +       nxo = xchg(nxp, NULL);
12661 +       if (!nxo)
12662 +               return;
12663 +
12664 +       vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
12665 +               nxo, nxo ? nxo->nx_id : 0,
12666 +               nxo ? atomic_read(&nxo->nx_usecnt) : 0,
12667 +               _file, _line);
12668 +
12669 +       if (atomic_dec_and_test(&nxo->nx_usecnt))
12670 +               free_nx_info(nxo);
12671 +}
12672 +
12673 +
12674 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
12675 +
12676 +static inline void __claim_nx_info(struct nx_info *nxi,
12677 +       struct task_struct *task, const char *_file, int _line)
12678 +{
12679 +       vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
12680 +               nxi, nxi ? nxi->nx_id : 0,
12681 +               nxi?atomic_read(&nxi->nx_usecnt):0,
12682 +               nxi?atomic_read(&nxi->nx_tasks):0,
12683 +               task, _file, _line);
12684 +
12685 +       atomic_inc(&nxi->nx_tasks);
12686 +}
12687 +
12688 +
12689 +extern void unhash_nx_info(struct nx_info *);
12690 +
12691 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
12692 +
12693 +static inline void __release_nx_info(struct nx_info *nxi,
12694 +       struct task_struct *task, const char *_file, int _line)
12695 +{
12696 +       vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
12697 +               nxi, nxi ? nxi->nx_id : 0,
12698 +               nxi ? atomic_read(&nxi->nx_usecnt) : 0,
12699 +               nxi ? atomic_read(&nxi->nx_tasks) : 0,
12700 +               task, _file, _line);
12701 +
12702 +       might_sleep();
12703 +
12704 +       if (atomic_dec_and_test(&nxi->nx_tasks))
12705 +               unhash_nx_info(nxi);
12706 +}
12707 +
12708 +
12709 +#define task_get_nx_info(i)    __task_get_nx_info(i, __FILE__, __LINE__)
12710 +
12711 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
12712 +       const char *_file, int _line)
12713 +{
12714 +       struct nx_info *nxi;
12715 +
12716 +       task_lock(p);
12717 +       vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
12718 +               p, _file, _line);
12719 +       nxi = __get_nx_info(p->nx_info, _file, _line);
12720 +       task_unlock(p);
12721 +       return nxi;
12722 +}
12723 +
12724 +
12725 +static inline void exit_nx_info(struct task_struct *p)
12726 +{
12727 +       if (p->nx_info)
12728 +               release_nx_info(p->nx_info, p);
12729 +}
12730 +
12731 +
12732 +#else
12733 +#warning duplicate inclusion
12734 +#endif
12735 diff -NurpP --minimal linux-3.0.4/include/linux/vs_pid.h linux-3.0.4-vs2.3.1/include/linux/vs_pid.h
12736 --- linux-3.0.4/include/linux/vs_pid.h  1970-01-01 01:00:00.000000000 +0100
12737 +++ linux-3.0.4-vs2.3.1/include/linux/vs_pid.h  2011-06-10 22:11:24.000000000 +0200
12738 @@ -0,0 +1,50 @@
12739 +#ifndef _VS_PID_H
12740 +#define _VS_PID_H
12741 +
12742 +#include "vserver/base.h"
12743 +#include "vserver/check.h"
12744 +#include "vserver/context.h"
12745 +#include "vserver/debug.h"
12746 +#include "vserver/pid.h"
12747 +#include <linux/pid_namespace.h>
12748 +
12749 +
12750 +#define VXF_FAKE_INIT  (VXF_INFO_INIT | VXF_STATE_INIT)
12751 +
12752 +static inline
12753 +int vx_proc_task_visible(struct task_struct *task)
12754 +{
12755 +       if ((task->pid == 1) &&
12756 +               !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
12757 +               /* show a blend through init */
12758 +               goto visible;
12759 +       if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
12760 +               goto visible;
12761 +       return 0;
12762 +visible:
12763 +       return 1;
12764 +}
12765 +
12766 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
12767 +
12768 +
12769 +static inline
12770 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
12771 +{
12772 +       struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
12773 +
12774 +       if (task && !vx_proc_task_visible(task)) {
12775 +               vxdprintk(VXD_CBIT(misc, 6),
12776 +                       "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
12777 +                       task, task->xid, task->pid,
12778 +                       current, current->xid, current->pid);
12779 +               put_task_struct(task);
12780 +               task = NULL;
12781 +       }
12782 +       return task;
12783 +}
12784 +
12785 +
12786 +#else
12787 +#warning duplicate inclusion
12788 +#endif
12789 diff -NurpP --minimal linux-3.0.4/include/linux/vs_sched.h linux-3.0.4-vs2.3.1/include/linux/vs_sched.h
12790 --- linux-3.0.4/include/linux/vs_sched.h        1970-01-01 01:00:00.000000000 +0100
12791 +++ linux-3.0.4-vs2.3.1/include/linux/vs_sched.h        2011-06-10 22:11:24.000000000 +0200
12792 @@ -0,0 +1,40 @@
12793 +#ifndef _VS_SCHED_H
12794 +#define _VS_SCHED_H
12795 +
12796 +#include "vserver/base.h"
12797 +#include "vserver/context.h"
12798 +#include "vserver/sched.h"
12799 +
12800 +
12801 +#define MAX_PRIO_BIAS           20
12802 +#define MIN_PRIO_BIAS          -20
12803 +
12804 +static inline
12805 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
12806 +{
12807 +       struct vx_info *vxi = p->vx_info;
12808 +
12809 +       if (vxi)
12810 +               prio += vx_cpu(vxi, sched_pc).prio_bias;
12811 +       return prio;
12812 +}
12813 +
12814 +static inline void vx_account_user(struct vx_info *vxi,
12815 +       cputime_t cputime, int nice)
12816 +{
12817 +       if (!vxi)
12818 +               return;
12819 +       vx_cpu(vxi, sched_pc).user_ticks += cputime;
12820 +}
12821 +
12822 +static inline void vx_account_system(struct vx_info *vxi,
12823 +       cputime_t cputime, int idle)
12824 +{
12825 +       if (!vxi)
12826 +               return;
12827 +       vx_cpu(vxi, sched_pc).sys_ticks += cputime;
12828 +}
12829 +
12830 +#else
12831 +#warning duplicate inclusion
12832 +#endif
12833 diff -NurpP --minimal linux-3.0.4/include/linux/vs_socket.h linux-3.0.4-vs2.3.1/include/linux/vs_socket.h
12834 --- linux-3.0.4/include/linux/vs_socket.h       1970-01-01 01:00:00.000000000 +0100
12835 +++ linux-3.0.4-vs2.3.1/include/linux/vs_socket.h       2011-06-10 22:11:24.000000000 +0200
12836 @@ -0,0 +1,67 @@
12837 +#ifndef _VS_SOCKET_H
12838 +#define _VS_SOCKET_H
12839 +
12840 +#include "vserver/debug.h"
12841 +#include "vserver/base.h"
12842 +#include "vserver/cacct.h"
12843 +#include "vserver/context.h"
12844 +#include "vserver/tag.h"
12845 +
12846 +
12847 +/* socket accounting */
12848 +
12849 +#include <linux/socket.h>
12850 +
12851 +static inline int vx_sock_type(int family)
12852 +{
12853 +       switch (family) {
12854 +       case PF_UNSPEC:
12855 +               return VXA_SOCK_UNSPEC;
12856 +       case PF_UNIX:
12857 +               return VXA_SOCK_UNIX;
12858 +       case PF_INET:
12859 +               return VXA_SOCK_INET;
12860 +       case PF_INET6:
12861 +               return VXA_SOCK_INET6;
12862 +       case PF_PACKET:
12863 +               return VXA_SOCK_PACKET;
12864 +       default:
12865 +               return VXA_SOCK_OTHER;
12866 +       }
12867 +}
12868 +
12869 +#define vx_acc_sock(v, f, p, s) \
12870 +       __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
12871 +
12872 +static inline void __vx_acc_sock(struct vx_info *vxi,
12873 +       int family, int pos, int size, char *file, int line)
12874 +{
12875 +       if (vxi) {
12876 +               int type = vx_sock_type(family);
12877 +
12878 +               atomic_long_inc(&vxi->cacct.sock[type][pos].count);
12879 +               atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
12880 +       }
12881 +}
12882 +
12883 +#define vx_sock_recv(sk, s) \
12884 +       vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
12885 +#define vx_sock_send(sk, s) \
12886 +       vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
12887 +#define vx_sock_fail(sk, s) \
12888 +       vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
12889 +
12890 +
12891 +#define sock_vx_init(s) do {           \
12892 +       (s)->sk_xid = 0;                \
12893 +       (s)->sk_vx_info = NULL;         \
12894 +       } while (0)
12895 +
12896 +#define sock_nx_init(s) do {           \
12897 +       (s)->sk_nid = 0;                \
12898 +       (s)->sk_nx_info = NULL;         \
12899 +       } while (0)
12900 +
12901 +#else
12902 +#warning duplicate inclusion
12903 +#endif
12904 diff -NurpP --minimal linux-3.0.4/include/linux/vs_tag.h linux-3.0.4-vs2.3.1/include/linux/vs_tag.h
12905 --- linux-3.0.4/include/linux/vs_tag.h  1970-01-01 01:00:00.000000000 +0100
12906 +++ linux-3.0.4-vs2.3.1/include/linux/vs_tag.h  2011-06-10 22:11:24.000000000 +0200
12907 @@ -0,0 +1,47 @@
12908 +#ifndef _VS_TAG_H
12909 +#define _VS_TAG_H
12910 +
12911 +#include <linux/vserver/tag.h>
12912 +
12913 +/* check conditions */
12914 +
12915 +#define DX_ADMIN       0x0001
12916 +#define DX_WATCH       0x0002
12917 +#define DX_HOSTID      0x0008
12918 +
12919 +#define DX_IDENT       0x0010
12920 +
12921 +#define DX_ARG_MASK    0x0010
12922 +
12923 +
12924 +#define dx_task_tag(t) ((t)->tag)
12925 +
12926 +#define dx_current_tag() dx_task_tag(current)
12927 +
12928 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
12929 +
12930 +#define dx_weak_check(c, m)    ((m) ? dx_check(c, m) : 1)
12931 +
12932 +
12933 +/*
12934 + * check current context for ADMIN/WATCH and
12935 + * optionally against supplied argument
12936 + */
12937 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
12938 +{
12939 +       if (mode & DX_ARG_MASK) {
12940 +               if ((mode & DX_IDENT) && (id == cid))
12941 +                       return 1;
12942 +       }
12943 +       return (((mode & DX_ADMIN) && (cid == 0)) ||
12944 +               ((mode & DX_WATCH) && (cid == 1)) ||
12945 +               ((mode & DX_HOSTID) && (id == 0)));
12946 +}
12947 +
12948 +struct inode;
12949 +int dx_permission(const struct inode *inode, int mask);
12950 +
12951 +
12952 +#else
12953 +#warning duplicate inclusion
12954 +#endif
12955 diff -NurpP --minimal linux-3.0.4/include/linux/vs_time.h linux-3.0.4-vs2.3.1/include/linux/vs_time.h
12956 --- linux-3.0.4/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
12957 +++ linux-3.0.4-vs2.3.1/include/linux/vs_time.h 2011-06-13 14:57:45.000000000 +0200
12958 @@ -0,0 +1,19 @@
12959 +#ifndef _VS_TIME_H
12960 +#define _VS_TIME_H
12961 +
12962 +
12963 +/* time faking stuff */
12964 +
12965 +#ifdef CONFIG_VSERVER_VTIME
12966 +
12967 +extern void vx_adjust_timespec(struct timespec *ts);
12968 +extern int vx_settimeofday(const struct timespec *ts);
12969 +
12970 +#else
12971 +#define        vx_adjust_timespec(t)   do { } while (0)
12972 +#define        vx_settimeofday(t)      do_settimeofday(t)
12973 +#endif
12974 +
12975 +#else
12976 +#warning duplicate inclusion
12977 +#endif
12978 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/Kbuild linux-3.0.4-vs2.3.1/include/linux/vserver/Kbuild
12979 --- linux-3.0.4/include/linux/vserver/Kbuild    1970-01-01 01:00:00.000000000 +0100
12980 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/Kbuild    2011-08-08 18:02:46.000000000 +0200
12981 @@ -0,0 +1,8 @@
12982 +
12983 +header-y += context_cmd.h network_cmd.h space_cmd.h \
12984 +       cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
12985 +       inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
12986 +       debug_cmd.h device_cmd.h
12987 +
12988 +header-y += switch.h network.h monitor.h inode.h device.h
12989 +
12990 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/base.h linux-3.0.4-vs2.3.1/include/linux/vserver/base.h
12991 --- linux-3.0.4/include/linux/vserver/base.h    1970-01-01 01:00:00.000000000 +0100
12992 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/base.h    2011-08-01 18:26:07.000000000 +0200
12993 @@ -0,0 +1,178 @@
12994 +#ifndef _VX_BASE_H
12995 +#define _VX_BASE_H
12996 +
12997 +
12998 +/* context state changes */
12999 +
13000 +enum {
13001 +       VSC_STARTUP = 1,
13002 +       VSC_SHUTDOWN,
13003 +
13004 +       VSC_NETUP,
13005 +       VSC_NETDOWN,
13006 +};
13007 +
13008 +
13009 +
13010 +#define vx_task_xid(t) ((t)->xid)
13011 +
13012 +#define vx_current_xid() vx_task_xid(current)
13013 +
13014 +#define current_vx_info() (current->vx_info)
13015 +
13016 +
13017 +#define nx_task_nid(t) ((t)->nid)
13018 +
13019 +#define nx_current_nid() nx_task_nid(current)
13020 +
13021 +#define current_nx_info() (current->nx_info)
13022 +
13023 +
13024 +/* generic flag merging */
13025 +
13026 +#define vs_check_flags(v, m, f)        (((v) & (m)) ^ (f))
13027 +
13028 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
13029 +
13030 +#define vs_mask_mask(v, f, m)  (((v) & ~(m)) | ((v) & (f) & (m)))
13031 +
13032 +#define vs_check_bit(v, n)     ((v) & (1LL << (n)))
13033 +
13034 +
13035 +/* context flags */
13036 +
13037 +#define __vx_flags(v)  ((v) ? (v)->vx_flags : 0)
13038 +
13039 +#define vx_current_flags()     __vx_flags(current_vx_info())
13040 +
13041 +#define vx_info_flags(v, m, f) \
13042 +       vs_check_flags(__vx_flags(v), m, f)
13043 +
13044 +#define task_vx_flags(t, m, f) \
13045 +       ((t) && vx_info_flags((t)->vx_info, m, f))
13046 +
13047 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
13048 +
13049 +
13050 +/* context caps */
13051 +
13052 +#define __vx_ccaps(v)  ((v) ? (v)->vx_ccaps : 0)
13053 +
13054 +#define vx_current_ccaps()     __vx_ccaps(current_vx_info())
13055 +
13056 +#define vx_info_ccaps(v, c)    (__vx_ccaps(v) & (c))
13057 +
13058 +#define vx_ccaps(c)    vx_info_ccaps(current_vx_info(), (c))
13059 +
13060 +
13061 +
13062 +/* network flags */
13063 +
13064 +#define __nx_flags(n)  ((n) ? (n)->nx_flags : 0)
13065 +
13066 +#define nx_current_flags()     __nx_flags(current_nx_info())
13067 +
13068 +#define nx_info_flags(n, m, f) \
13069 +       vs_check_flags(__nx_flags(n), m, f)
13070 +
13071 +#define task_nx_flags(t, m, f) \
13072 +       ((t) && nx_info_flags((t)->nx_info, m, f))
13073 +
13074 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
13075 +
13076 +
13077 +/* network caps */
13078 +
13079 +#define __nx_ncaps(n)  ((n) ? (n)->nx_ncaps : 0)
13080 +
13081 +#define nx_current_ncaps()     __nx_ncaps(current_nx_info())
13082 +
13083 +#define nx_info_ncaps(n, c)    (__nx_ncaps(n) & (c))
13084 +
13085 +#define nx_ncaps(c)    nx_info_ncaps(current_nx_info(), c)
13086 +
13087 +
13088 +/* context mask capabilities */
13089 +
13090 +#define __vx_mcaps(v)  ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
13091 +
13092 +#define vx_info_mcaps(v, c)    (__vx_mcaps(v) & (c))
13093 +
13094 +#define vx_mcaps(c)    vx_info_mcaps(current_vx_info(), c)
13095 +
13096 +
13097 +/* context bcap mask */
13098 +
13099 +#define __vx_bcaps(v)          ((v)->vx_bcaps)
13100 +
13101 +#define vx_current_bcaps()     __vx_bcaps(current_vx_info())
13102 +
13103 +
13104 +/* mask given bcaps */
13105 +
13106 +#define vx_info_mbcaps(v, c)   ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
13107 +
13108 +#define vx_mbcaps(c)           vx_info_mbcaps(current_vx_info(), c)
13109 +
13110 +
13111 +/* masked cap_bset */
13112 +
13113 +#define vx_info_cap_bset(v)    vx_info_mbcaps(v, current->cap_bset)
13114 +
13115 +#define vx_current_cap_bset()  vx_info_cap_bset(current_vx_info())
13116 +
13117 +#if 0
13118 +#define vx_info_mbcap(v, b) \
13119 +       (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
13120 +       vx_info_bcaps(v, b) : (b))
13121 +
13122 +#define task_vx_mbcap(t, b) \
13123 +       vx_info_mbcap((t)->vx_info, (t)->b)
13124 +
13125 +#define vx_mbcap(b)    task_vx_mbcap(current, b)
13126 +#endif
13127 +
13128 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
13129 +
13130 +#define vx_capable(b, c) (capable(b) || \
13131 +       (cap_raised(current_cap(), b) && vx_ccaps(c)))
13132 +
13133 +#define vx_ns_capable(n, b, c) (ns_capable(n, b) || \
13134 +       (cap_raised(current_cap(), b) && vx_ccaps(c)))
13135 +
13136 +#define nx_capable(b, c) (capable(b) || \
13137 +       (cap_raised(current_cap(), b) && nx_ncaps(c)))
13138 +
13139 +#define vx_task_initpid(t, n) \
13140 +       ((t)->vx_info && \
13141 +       ((t)->vx_info->vx_initpid == (n)))
13142 +
13143 +#define vx_current_initpid(n)  vx_task_initpid(current, n)
13144 +
13145 +
13146 +/* context unshare mask */
13147 +
13148 +#define __vx_umask(v)          ((v)->vx_umask)
13149 +
13150 +#define vx_current_umask()     __vx_umask(current_vx_info())
13151 +
13152 +#define vx_can_unshare(b, f) (capable(b) || \
13153 +       (cap_raised(current_cap(), b) && \
13154 +       !((f) & ~vx_current_umask())))
13155 +
13156 +
13157 +#define __vx_wmask(v)          ((v)->vx_wmask)
13158 +
13159 +#define vx_current_wmask()     __vx_wmask(current_vx_info())
13160 +
13161 +
13162 +#define __vx_state(v)  ((v) ? ((v)->vx_state) : 0)
13163 +
13164 +#define vx_info_state(v, m)    (__vx_state(v) & (m))
13165 +
13166 +
13167 +#define __nx_state(n)  ((n) ? ((n)->nx_state) : 0)
13168 +
13169 +#define nx_info_state(n, m)    (__nx_state(n) & (m))
13170 +
13171 +#endif
13172 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/cacct.h linux-3.0.4-vs2.3.1/include/linux/vserver/cacct.h
13173 --- linux-3.0.4/include/linux/vserver/cacct.h   1970-01-01 01:00:00.000000000 +0100
13174 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/cacct.h   2011-06-10 22:11:24.000000000 +0200
13175 @@ -0,0 +1,15 @@
13176 +#ifndef _VX_CACCT_H
13177 +#define _VX_CACCT_H
13178 +
13179 +
13180 +enum sock_acc_field {
13181 +       VXA_SOCK_UNSPEC = 0,
13182 +       VXA_SOCK_UNIX,
13183 +       VXA_SOCK_INET,
13184 +       VXA_SOCK_INET6,
13185 +       VXA_SOCK_PACKET,
13186 +       VXA_SOCK_OTHER,
13187 +       VXA_SOCK_SIZE   /* array size */
13188 +};
13189 +
13190 +#endif /* _VX_CACCT_H */
13191 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/cacct_cmd.h linux-3.0.4-vs2.3.1/include/linux/vserver/cacct_cmd.h
13192 --- linux-3.0.4/include/linux/vserver/cacct_cmd.h       1970-01-01 01:00:00.000000000 +0100
13193 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/cacct_cmd.h       2011-06-10 22:11:24.000000000 +0200
13194 @@ -0,0 +1,23 @@
13195 +#ifndef _VX_CACCT_CMD_H
13196 +#define _VX_CACCT_CMD_H
13197 +
13198 +
13199 +/* virtual host info name commands */
13200 +
13201 +#define VCMD_sock_stat         VC_CMD(VSTAT, 5, 0)
13202 +
13203 +struct vcmd_sock_stat_v0 {
13204 +       uint32_t field;
13205 +       uint32_t count[3];
13206 +       uint64_t total[3];
13207 +};
13208 +
13209 +
13210 +#ifdef __KERNEL__
13211 +
13212 +#include <linux/compiler.h>
13213 +
13214 +extern int vc_sock_stat(struct vx_info *, void __user *);
13215 +
13216 +#endif /* __KERNEL__ */
13217 +#endif /* _VX_CACCT_CMD_H */
13218 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/cacct_def.h linux-3.0.4-vs2.3.1/include/linux/vserver/cacct_def.h
13219 --- linux-3.0.4/include/linux/vserver/cacct_def.h       1970-01-01 01:00:00.000000000 +0100
13220 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/cacct_def.h       2011-06-10 22:11:24.000000000 +0200
13221 @@ -0,0 +1,43 @@
13222 +#ifndef _VX_CACCT_DEF_H
13223 +#define _VX_CACCT_DEF_H
13224 +
13225 +#include <asm/atomic.h>
13226 +#include <linux/vserver/cacct.h>
13227 +
13228 +
13229 +struct _vx_sock_acc {
13230 +       atomic_long_t count;
13231 +       atomic_long_t total;
13232 +};
13233 +
13234 +/* context sub struct */
13235 +
13236 +struct _vx_cacct {
13237 +       struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
13238 +       atomic_t slab[8];
13239 +       atomic_t page[6][8];
13240 +};
13241 +
13242 +#ifdef CONFIG_VSERVER_DEBUG
13243 +
13244 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
13245 +{
13246 +       int i, j;
13247 +
13248 +       printk("\t_vx_cacct:");
13249 +       for (i = 0; i < 6; i++) {
13250 +               struct _vx_sock_acc *ptr = cacct->sock[i];
13251 +
13252 +               printk("\t [%d] =", i);
13253 +               for (j = 0; j < 3; j++) {
13254 +                       printk(" [%d] = %8lu, %8lu", j,
13255 +                               atomic_long_read(&ptr[j].count),
13256 +                               atomic_long_read(&ptr[j].total));
13257 +               }
13258 +               printk("\n");
13259 +       }
13260 +}
13261 +
13262 +#endif
13263 +
13264 +#endif /* _VX_CACCT_DEF_H */
13265 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/cacct_int.h linux-3.0.4-vs2.3.1/include/linux/vserver/cacct_int.h
13266 --- linux-3.0.4/include/linux/vserver/cacct_int.h       1970-01-01 01:00:00.000000000 +0100
13267 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/cacct_int.h       2011-06-10 22:11:24.000000000 +0200
13268 @@ -0,0 +1,21 @@
13269 +#ifndef _VX_CACCT_INT_H
13270 +#define _VX_CACCT_INT_H
13271 +
13272 +
13273 +#ifdef __KERNEL__
13274 +
13275 +static inline
13276 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
13277 +{
13278 +       return atomic_long_read(&cacct->sock[type][pos].count);
13279 +}
13280 +
13281 +
13282 +static inline
13283 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
13284 +{
13285 +       return atomic_long_read(&cacct->sock[type][pos].total);
13286 +}
13287 +
13288 +#endif /* __KERNEL__ */
13289 +#endif /* _VX_CACCT_INT_H */
13290 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/check.h linux-3.0.4-vs2.3.1/include/linux/vserver/check.h
13291 --- linux-3.0.4/include/linux/vserver/check.h   1970-01-01 01:00:00.000000000 +0100
13292 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/check.h   2011-06-10 22:11:24.000000000 +0200
13293 @@ -0,0 +1,89 @@
13294 +#ifndef _VS_CHECK_H
13295 +#define _VS_CHECK_H
13296 +
13297 +
13298 +#define MAX_S_CONTEXT  65535   /* Arbitrary limit */
13299 +
13300 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
13301 +#define MIN_D_CONTEXT  49152   /* dynamic contexts start here */
13302 +#else
13303 +#define MIN_D_CONTEXT  65536
13304 +#endif
13305 +
13306 +/* check conditions */
13307 +
13308 +#define VS_ADMIN       0x0001
13309 +#define VS_WATCH       0x0002
13310 +#define VS_HIDE                0x0004
13311 +#define VS_HOSTID      0x0008
13312 +
13313 +#define VS_IDENT       0x0010
13314 +#define VS_EQUIV       0x0020
13315 +#define VS_PARENT      0x0040
13316 +#define VS_CHILD       0x0080
13317 +
13318 +#define VS_ARG_MASK    0x00F0
13319 +
13320 +#define VS_DYNAMIC     0x0100
13321 +#define VS_STATIC      0x0200
13322 +
13323 +#define VS_ATR_MASK    0x0F00
13324 +
13325 +#ifdef CONFIG_VSERVER_PRIVACY
13326 +#define VS_ADMIN_P     (0)
13327 +#define VS_WATCH_P     (0)
13328 +#else
13329 +#define VS_ADMIN_P     VS_ADMIN
13330 +#define VS_WATCH_P     VS_WATCH
13331 +#endif
13332 +
13333 +#define VS_HARDIRQ     0x1000
13334 +#define VS_SOFTIRQ     0x2000
13335 +#define VS_IRQ         0x4000
13336 +
13337 +#define VS_IRQ_MASK    0xF000
13338 +
13339 +#include <linux/hardirq.h>
13340 +
13341 +/*
13342 + * check current context for ADMIN/WATCH and
13343 + * optionally against supplied argument
13344 + */
13345 +static inline int __vs_check(int cid, int id, unsigned int mode)
13346 +{
13347 +       if (mode & VS_ARG_MASK) {
13348 +               if ((mode & VS_IDENT) && (id == cid))
13349 +                       return 1;
13350 +       }
13351 +       if (mode & VS_ATR_MASK) {
13352 +               if ((mode & VS_DYNAMIC) &&
13353 +                       (id >= MIN_D_CONTEXT) &&
13354 +                       (id <= MAX_S_CONTEXT))
13355 +                       return 1;
13356 +               if ((mode & VS_STATIC) &&
13357 +                       (id > 1) && (id < MIN_D_CONTEXT))
13358 +                       return 1;
13359 +       }
13360 +       if (mode & VS_IRQ_MASK) {
13361 +               if ((mode & VS_IRQ) && unlikely(in_interrupt()))
13362 +                       return 1;
13363 +               if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
13364 +                       return 1;
13365 +               if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
13366 +                       return 1;
13367 +       }
13368 +       return (((mode & VS_ADMIN) && (cid == 0)) ||
13369 +               ((mode & VS_WATCH) && (cid == 1)) ||
13370 +               ((mode & VS_HOSTID) && (id == 0)));
13371 +}
13372 +
13373 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
13374 +
13375 +#define vx_weak_check(c, m)    ((m) ? vx_check(c, m) : 1)
13376 +
13377 +
13378 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
13379 +
13380 +#define nx_weak_check(c, m)    ((m) ? nx_check(c, m) : 1)
13381 +
13382 +#endif
13383 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/context.h linux-3.0.4-vs2.3.1/include/linux/vserver/context.h
13384 --- linux-3.0.4/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
13385 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/context.h 2011-08-01 18:23:13.000000000 +0200
13386 @@ -0,0 +1,190 @@
13387 +#ifndef _VX_CONTEXT_H
13388 +#define _VX_CONTEXT_H
13389 +
13390 +#include <linux/types.h>
13391 +#include <linux/capability.h>
13392 +
13393 +
13394 +/* context flags */
13395 +
13396 +#define VXF_INFO_SCHED         0x00000002
13397 +#define VXF_INFO_NPROC         0x00000004
13398 +#define VXF_INFO_PRIVATE       0x00000008
13399 +
13400 +#define VXF_INFO_INIT          0x00000010
13401 +#define VXF_INFO_HIDE          0x00000020
13402 +#define VXF_INFO_ULIMIT                0x00000040
13403 +#define VXF_INFO_NSPACE                0x00000080
13404 +
13405 +#define VXF_SCHED_HARD         0x00000100
13406 +#define VXF_SCHED_PRIO         0x00000200
13407 +#define VXF_SCHED_PAUSE                0x00000400
13408 +
13409 +#define VXF_VIRT_MEM           0x00010000
13410 +#define VXF_VIRT_UPTIME                0x00020000
13411 +#define VXF_VIRT_CPU           0x00040000
13412 +#define VXF_VIRT_LOAD          0x00080000
13413 +#define VXF_VIRT_TIME          0x00100000
13414 +
13415 +#define VXF_HIDE_MOUNT         0x01000000
13416 +/* was VXF_HIDE_NETIF          0x02000000 */
13417 +#define VXF_HIDE_VINFO         0x04000000
13418 +
13419 +#define VXF_STATE_SETUP                (1ULL << 32)
13420 +#define VXF_STATE_INIT         (1ULL << 33)
13421 +#define VXF_STATE_ADMIN                (1ULL << 34)
13422 +
13423 +#define VXF_SC_HELPER          (1ULL << 36)
13424 +#define VXF_REBOOT_KILL                (1ULL << 37)
13425 +#define VXF_PERSISTENT         (1ULL << 38)
13426 +
13427 +#define VXF_FORK_RSS           (1ULL << 48)
13428 +#define VXF_PROLIFIC           (1ULL << 49)
13429 +
13430 +#define VXF_IGNEG_NICE         (1ULL << 52)
13431 +
13432 +#define VXF_ONE_TIME           (0x0007ULL << 32)
13433 +
13434 +#define VXF_INIT_SET           (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
13435 +
13436 +
13437 +/* context migration */
13438 +
13439 +#define VXM_SET_INIT           0x00000001
13440 +#define VXM_SET_REAPER         0x00000002
13441 +
13442 +/* context caps */
13443 +
13444 +#define VXC_CAP_MASK           0x00000000
13445 +
13446 +#define VXC_SET_UTSNAME                0x00000001
13447 +#define VXC_SET_RLIMIT         0x00000002
13448 +#define VXC_FS_SECURITY                0x00000004
13449 +#define VXC_FS_TRUSTED         0x00000008
13450 +#define VXC_TIOCSTI            0x00000010
13451 +
13452 +/* was VXC_RAW_ICMP            0x00000100 */
13453 +#define VXC_SYSLOG             0x00001000
13454 +#define VXC_OOM_ADJUST         0x00002000
13455 +#define VXC_AUDIT_CONTROL      0x00004000
13456 +
13457 +#define VXC_SECURE_MOUNT       0x00010000
13458 +#define VXC_SECURE_REMOUNT     0x00020000
13459 +#define VXC_BINARY_MOUNT       0x00040000
13460 +
13461 +#define VXC_QUOTA_CTL          0x00100000
13462 +#define VXC_ADMIN_MAPPER       0x00200000
13463 +#define VXC_ADMIN_CLOOP                0x00400000
13464 +
13465 +#define VXC_KTHREAD            0x01000000
13466 +#define VXC_NAMESPACE          0x02000000
13467 +
13468 +
13469 +#ifdef __KERNEL__
13470 +
13471 +#include <linux/list.h>
13472 +#include <linux/spinlock.h>
13473 +#include <linux/rcupdate.h>
13474 +
13475 +#include "limit_def.h"
13476 +#include "sched_def.h"
13477 +#include "cvirt_def.h"
13478 +#include "cacct_def.h"
13479 +#include "device_def.h"
13480 +
13481 +#define VX_SPACES      2
13482 +
13483 +struct _vx_info_pc {
13484 +       struct _vx_sched_pc sched_pc;
13485 +       struct _vx_cvirt_pc cvirt_pc;
13486 +};
13487 +
13488 +struct _vx_space {
13489 +       unsigned long vx_nsmask;                /* assignment mask */
13490 +       struct nsproxy *vx_nsproxy;             /* private namespaces */
13491 +       struct fs_struct *vx_fs;                /* private namespace fs */
13492 +       const struct cred *vx_cred;             /* task credentials */
13493 +};
13494 +
13495 +struct vx_info {
13496 +       struct hlist_node vx_hlist;             /* linked list of contexts */
13497 +       xid_t vx_id;                            /* context id */
13498 +       atomic_t vx_usecnt;                     /* usage count */
13499 +       atomic_t vx_tasks;                      /* tasks count */
13500 +       struct vx_info *vx_parent;              /* parent context */
13501 +       int vx_state;                           /* context state */
13502 +
13503 +       struct _vx_space space[VX_SPACES];      /* namespace store */
13504 +
13505 +       uint64_t vx_flags;                      /* context flags */
13506 +       uint64_t vx_ccaps;                      /* context caps (vserver) */
13507 +       uint64_t vx_umask;                      /* unshare mask (guest) */
13508 +       uint64_t vx_wmask;                      /* warn mask (guest) */
13509 +       kernel_cap_t vx_bcaps;                  /* bounding caps (system) */
13510 +
13511 +       struct task_struct *vx_reaper;          /* guest reaper process */
13512 +       pid_t vx_initpid;                       /* PID of guest init */
13513 +       int64_t vx_badness_bias;                /* OOM points bias */
13514 +
13515 +       struct _vx_limit limit;                 /* vserver limits */
13516 +       struct _vx_sched sched;                 /* vserver scheduler */
13517 +       struct _vx_cvirt cvirt;                 /* virtual/bias stuff */
13518 +       struct _vx_cacct cacct;                 /* context accounting */
13519 +
13520 +       struct _vx_device dmap;                 /* default device map targets */
13521 +
13522 +#ifndef CONFIG_SMP
13523 +       struct _vx_info_pc info_pc;             /* per cpu data */
13524 +#else
13525 +       struct _vx_info_pc *ptr_pc;             /* per cpu array */
13526 +#endif
13527 +
13528 +       wait_queue_head_t vx_wait;              /* context exit waitqueue */
13529 +       int reboot_cmd;                         /* last sys_reboot() cmd */
13530 +       int exit_code;                          /* last process exit code */
13531 +
13532 +       char vx_name[65];                       /* vserver name */
13533 +};
13534 +
13535 +#ifndef CONFIG_SMP
13536 +#define        vx_ptr_pc(vxi)          (&(vxi)->info_pc)
13537 +#define        vx_per_cpu(vxi, v, id)  vx_ptr_pc(vxi)->v
13538 +#else
13539 +#define        vx_ptr_pc(vxi)          ((vxi)->ptr_pc)
13540 +#define        vx_per_cpu(vxi, v, id)  per_cpu_ptr(vx_ptr_pc(vxi), id)->v
13541 +#endif
13542 +
13543 +#define        vx_cpu(vxi, v)          vx_per_cpu(vxi, v, smp_processor_id())
13544 +
13545 +
13546 +struct vx_info_save {
13547 +       struct vx_info *vxi;
13548 +       xid_t xid;
13549 +};
13550 +
13551 +
13552 +/* status flags */
13553 +
13554 +#define VXS_HASHED     0x0001
13555 +#define VXS_PAUSED     0x0010
13556 +#define VXS_SHUTDOWN   0x0100
13557 +#define VXS_HELPER     0x1000
13558 +#define VXS_RELEASED   0x8000
13559 +
13560 +
13561 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
13562 +extern void release_vx_info(struct vx_info *, struct task_struct *);
13563 +
13564 +extern struct vx_info *lookup_vx_info(int);
13565 +extern struct vx_info *lookup_or_create_vx_info(int);
13566 +
13567 +extern int get_xid_list(int, unsigned int *, int);
13568 +extern int xid_is_hashed(xid_t);
13569 +
13570 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
13571 +
13572 +extern long vs_state_change(struct vx_info *, unsigned int);
13573 +
13574 +
13575 +#endif /* __KERNEL__ */
13576 +#endif /* _VX_CONTEXT_H */
13577 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/context_cmd.h linux-3.0.4-vs2.3.1/include/linux/vserver/context_cmd.h
13578 --- linux-3.0.4/include/linux/vserver/context_cmd.h     1970-01-01 01:00:00.000000000 +0100
13579 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/context_cmd.h     2011-08-01 18:25:07.000000000 +0200
13580 @@ -0,0 +1,162 @@
13581 +#ifndef _VX_CONTEXT_CMD_H
13582 +#define _VX_CONTEXT_CMD_H
13583 +
13584 +
13585 +/* vinfo commands */
13586 +
13587 +#define VCMD_task_xid          VC_CMD(VINFO, 1, 0)
13588 +
13589 +#ifdef __KERNEL__
13590 +extern int vc_task_xid(uint32_t);
13591 +
13592 +#endif /* __KERNEL__ */
13593 +
13594 +#define VCMD_vx_info           VC_CMD(VINFO, 5, 0)
13595 +
13596 +struct vcmd_vx_info_v0 {
13597 +       uint32_t xid;
13598 +       uint32_t initpid;
13599 +       /* more to come */
13600 +};
13601 +
13602 +#ifdef __KERNEL__
13603 +extern int vc_vx_info(struct vx_info *, void __user *);
13604 +
13605 +#endif /* __KERNEL__ */
13606 +
13607 +#define VCMD_ctx_stat          VC_CMD(VSTAT, 0, 0)
13608 +
13609 +struct vcmd_ctx_stat_v0 {
13610 +       uint32_t usecnt;
13611 +       uint32_t tasks;
13612 +       /* more to come */
13613 +};
13614 +
13615 +#ifdef __KERNEL__
13616 +extern int vc_ctx_stat(struct vx_info *, void __user *);
13617 +
13618 +#endif /* __KERNEL__ */
13619 +
13620 +/* context commands */
13621 +
13622 +#define VCMD_ctx_create_v0     VC_CMD(VPROC, 1, 0)
13623 +#define VCMD_ctx_create                VC_CMD(VPROC, 1, 1)
13624 +
13625 +struct vcmd_ctx_create {
13626 +       uint64_t flagword;
13627 +};
13628 +
13629 +#define VCMD_ctx_migrate_v0    VC_CMD(PROCMIG, 1, 0)
13630 +#define VCMD_ctx_migrate       VC_CMD(PROCMIG, 1, 1)
13631 +
13632 +struct vcmd_ctx_migrate {
13633 +       uint64_t flagword;
13634 +};
13635 +
13636 +#ifdef __KERNEL__
13637 +extern int vc_ctx_create(uint32_t, void __user *);
13638 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
13639 +
13640 +#endif /* __KERNEL__ */
13641 +
13642 +
13643 +/* flag commands */
13644 +
13645 +#define VCMD_get_cflags                VC_CMD(FLAGS, 1, 0)
13646 +#define VCMD_set_cflags                VC_CMD(FLAGS, 2, 0)
13647 +
13648 +struct vcmd_ctx_flags_v0 {
13649 +       uint64_t flagword;
13650 +       uint64_t mask;
13651 +};
13652 +
13653 +#ifdef __KERNEL__
13654 +extern int vc_get_cflags(struct vx_info *, void __user *);
13655 +extern int vc_set_cflags(struct vx_info *, void __user *);
13656 +
13657 +#endif /* __KERNEL__ */
13658 +
13659 +
13660 +/* context caps commands */
13661 +
13662 +#define VCMD_get_ccaps         VC_CMD(FLAGS, 3, 1)
13663 +#define VCMD_set_ccaps         VC_CMD(FLAGS, 4, 1)
13664 +
13665 +struct vcmd_ctx_caps_v1 {
13666 +       uint64_t ccaps;
13667 +       uint64_t cmask;
13668 +};
13669 +
13670 +#ifdef __KERNEL__
13671 +extern int vc_get_ccaps(struct vx_info *, void __user *);
13672 +extern int vc_set_ccaps(struct vx_info *, void __user *);
13673 +
13674 +#endif /* __KERNEL__ */
13675 +
13676 +
13677 +/* bcaps commands */
13678 +
13679 +#define VCMD_get_bcaps         VC_CMD(FLAGS, 9, 0)
13680 +#define VCMD_set_bcaps         VC_CMD(FLAGS, 10, 0)
13681 +
13682 +struct vcmd_bcaps {
13683 +       uint64_t bcaps;
13684 +       uint64_t bmask;
13685 +};
13686 +
13687 +#ifdef __KERNEL__
13688 +extern int vc_get_bcaps(struct vx_info *, void __user *);
13689 +extern int vc_set_bcaps(struct vx_info *, void __user *);
13690 +
13691 +#endif /* __KERNEL__ */
13692 +
13693 +
13694 +/* umask commands */
13695 +
13696 +#define VCMD_get_umask         VC_CMD(FLAGS, 13, 0)
13697 +#define VCMD_set_umask         VC_CMD(FLAGS, 14, 0)
13698 +
13699 +struct vcmd_umask {
13700 +       uint64_t umask;
13701 +       uint64_t mask;
13702 +};
13703 +
13704 +#ifdef __KERNEL__
13705 +extern int vc_get_umask(struct vx_info *, void __user *);
13706 +extern int vc_set_umask(struct vx_info *, void __user *);
13707 +
13708 +#endif /* __KERNEL__ */
13709 +
13710 +
13711 +/* wmask commands */
13712 +
13713 +#define VCMD_get_wmask         VC_CMD(FLAGS, 15, 0)
13714 +#define VCMD_set_wmask         VC_CMD(FLAGS, 16, 0)
13715 +
13716 +struct vcmd_wmask {
13717 +       uint64_t wmask;
13718 +       uint64_t mask;
13719 +};
13720 +
13721 +#ifdef __KERNEL__
13722 +extern int vc_get_wmask(struct vx_info *, void __user *);
13723 +extern int vc_set_wmask(struct vx_info *, void __user *);
13724 +
13725 +#endif /* __KERNEL__ */
13726 +
13727 +
13728 +/* OOM badness */
13729 +
13730 +#define VCMD_get_badness       VC_CMD(MEMCTRL, 5, 0)
13731 +#define VCMD_set_badness       VC_CMD(MEMCTRL, 6, 0)
13732 +
13733 +struct vcmd_badness_v0 {
13734 +       int64_t bias;
13735 +};
13736 +
13737 +#ifdef __KERNEL__
13738 +extern int vc_get_badness(struct vx_info *, void __user *);
13739 +extern int vc_set_badness(struct vx_info *, void __user *);
13740 +
13741 +#endif /* __KERNEL__ */
13742 +#endif /* _VX_CONTEXT_CMD_H */
13743 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/cvirt.h linux-3.0.4-vs2.3.1/include/linux/vserver/cvirt.h
13744 --- linux-3.0.4/include/linux/vserver/cvirt.h   1970-01-01 01:00:00.000000000 +0100
13745 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/cvirt.h   2011-06-10 22:11:24.000000000 +0200
13746 @@ -0,0 +1,20 @@
13747 +#ifndef _VX_CVIRT_H
13748 +#define _VX_CVIRT_H
13749 +
13750 +
13751 +#ifdef __KERNEL__
13752 +
13753 +struct timespec;
13754 +
13755 +void vx_vsi_uptime(struct timespec *, struct timespec *);
13756 +
13757 +
13758 +struct vx_info;
13759 +
13760 +void vx_update_load(struct vx_info *);
13761 +
13762 +
13763 +int vx_do_syslog(int, char __user *, int);
13764 +
13765 +#endif /* __KERNEL__ */
13766 +#endif /* _VX_CVIRT_H */
13767 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/cvirt_cmd.h linux-3.0.4-vs2.3.1/include/linux/vserver/cvirt_cmd.h
13768 --- linux-3.0.4/include/linux/vserver/cvirt_cmd.h       1970-01-01 01:00:00.000000000 +0100
13769 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/cvirt_cmd.h       2011-06-10 22:11:24.000000000 +0200
13770 @@ -0,0 +1,53 @@
13771 +#ifndef _VX_CVIRT_CMD_H
13772 +#define _VX_CVIRT_CMD_H
13773 +
13774 +
13775 +/* virtual host info name commands */
13776 +
13777 +#define VCMD_set_vhi_name      VC_CMD(VHOST, 1, 0)
13778 +#define VCMD_get_vhi_name      VC_CMD(VHOST, 2, 0)
13779 +
13780 +struct vcmd_vhi_name_v0 {
13781 +       uint32_t field;
13782 +       char name[65];
13783 +};
13784 +
13785 +
13786 +enum vhi_name_field {
13787 +       VHIN_CONTEXT = 0,
13788 +       VHIN_SYSNAME,
13789 +       VHIN_NODENAME,
13790 +       VHIN_RELEASE,
13791 +       VHIN_VERSION,
13792 +       VHIN_MACHINE,
13793 +       VHIN_DOMAINNAME,
13794 +};
13795 +
13796 +
13797 +#ifdef __KERNEL__
13798 +
13799 +#include <linux/compiler.h>
13800 +
13801 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
13802 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
13803 +
13804 +#endif /* __KERNEL__ */
13805 +
13806 +#define VCMD_virt_stat         VC_CMD(VSTAT, 3, 0)
13807 +
13808 +struct vcmd_virt_stat_v0 {
13809 +       uint64_t offset;
13810 +       uint64_t uptime;
13811 +       uint32_t nr_threads;
13812 +       uint32_t nr_running;
13813 +       uint32_t nr_uninterruptible;
13814 +       uint32_t nr_onhold;
13815 +       uint32_t nr_forks;
13816 +       uint32_t load[3];
13817 +};
13818 +
13819 +#ifdef __KERNEL__
13820 +extern int vc_virt_stat(struct vx_info *, void __user *);
13821 +
13822 +#endif /* __KERNEL__ */
13823 +#endif /* _VX_CVIRT_CMD_H */
13824 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/cvirt_def.h linux-3.0.4-vs2.3.1/include/linux/vserver/cvirt_def.h
13825 --- linux-3.0.4/include/linux/vserver/cvirt_def.h       1970-01-01 01:00:00.000000000 +0100
13826 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/cvirt_def.h       2011-06-10 22:11:24.000000000 +0200
13827 @@ -0,0 +1,80 @@
13828 +#ifndef _VX_CVIRT_DEF_H
13829 +#define _VX_CVIRT_DEF_H
13830 +
13831 +#include <linux/jiffies.h>
13832 +#include <linux/spinlock.h>
13833 +#include <linux/wait.h>
13834 +#include <linux/time.h>
13835 +#include <asm/atomic.h>
13836 +
13837 +
13838 +struct _vx_usage_stat {
13839 +       uint64_t user;
13840 +       uint64_t nice;
13841 +       uint64_t system;
13842 +       uint64_t softirq;
13843 +       uint64_t irq;
13844 +       uint64_t idle;
13845 +       uint64_t iowait;
13846 +};
13847 +
13848 +struct _vx_syslog {
13849 +       wait_queue_head_t log_wait;
13850 +       spinlock_t logbuf_lock;         /* lock for the log buffer */
13851 +
13852 +       unsigned long log_start;        /* next char to be read by syslog() */
13853 +       unsigned long con_start;        /* next char to be sent to consoles */
13854 +       unsigned long log_end;  /* most-recently-written-char + 1 */
13855 +       unsigned long logged_chars;     /* #chars since last read+clear operation */
13856 +
13857 +       char log_buf[1024];
13858 +};
13859 +
13860 +
13861 +/* context sub struct */
13862 +
13863 +struct _vx_cvirt {
13864 +       atomic_t nr_threads;            /* number of current threads */
13865 +       atomic_t nr_running;            /* number of running threads */
13866 +       atomic_t nr_uninterruptible;    /* number of uninterruptible threads */
13867 +
13868 +       atomic_t nr_onhold;             /* processes on hold */
13869 +       uint32_t onhold_last;           /* jiffies when put on hold */
13870 +
13871 +       struct timespec bias_ts;        /* time offset to the host */
13872 +       struct timespec bias_idle;
13873 +       struct timespec bias_uptime;    /* context creation point */
13874 +       uint64_t bias_clock;            /* offset in clock_t */
13875 +
13876 +       spinlock_t load_lock;           /* lock for the load averages */
13877 +       atomic_t load_updates;          /* nr of load updates done so far */
13878 +       uint32_t load_last;             /* last time load was calculated */
13879 +       uint32_t load[3];               /* load averages 1,5,15 */
13880 +
13881 +       atomic_t total_forks;           /* number of forks so far */
13882 +
13883 +       struct _vx_syslog syslog;
13884 +};
13885 +
13886 +struct _vx_cvirt_pc {
13887 +       struct _vx_usage_stat cpustat;
13888 +};
13889 +
13890 +
13891 +#ifdef CONFIG_VSERVER_DEBUG
13892 +
13893 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
13894 +{
13895 +       printk("\t_vx_cvirt:\n");
13896 +       printk("\t threads: %4d, %4d, %4d, %4d\n",
13897 +               atomic_read(&cvirt->nr_threads),
13898 +               atomic_read(&cvirt->nr_running),
13899 +               atomic_read(&cvirt->nr_uninterruptible),
13900 +               atomic_read(&cvirt->nr_onhold));
13901 +       /* add rest here */
13902 +       printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
13903 +}
13904 +
13905 +#endif
13906 +
13907 +#endif /* _VX_CVIRT_DEF_H */
13908 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/debug.h linux-3.0.4-vs2.3.1/include/linux/vserver/debug.h
13909 --- linux-3.0.4/include/linux/vserver/debug.h   1970-01-01 01:00:00.000000000 +0100
13910 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/debug.h   2011-06-10 22:11:24.000000000 +0200
13911 @@ -0,0 +1,140 @@
13912 +#ifndef _VX_DEBUG_H
13913 +#define _VX_DEBUG_H
13914 +
13915 +
13916 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
13917 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
13918 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
13919 +
13920 +#define VXD_DEV(d)     (d), (d)->bd_inode->i_ino,              \
13921 +                       imajor((d)->bd_inode), iminor((d)->bd_inode)
13922 +#define VXF_DEV                "%p[%lu,%d:%d]"
13923 +
13924 +#if    defined(CONFIG_QUOTES_UTF8)
13925 +#define        VS_Q_LQM        "\xc2\xbb"
13926 +#define        VS_Q_RQM        "\xc2\xab"
13927 +#elif  defined(CONFIG_QUOTES_ASCII)
13928 +#define        VS_Q_LQM        "\x27"
13929 +#define        VS_Q_RQM        "\x27"
13930 +#else
13931 +#define        VS_Q_LQM        "\xbb"
13932 +#define        VS_Q_RQM        "\xab"
13933 +#endif
13934 +
13935 +#define        VS_Q(f)         VS_Q_LQM f VS_Q_RQM
13936 +
13937 +
13938 +#define vxd_path(p)                                            \
13939 +       ({ static char _buffer[PATH_MAX];                       \
13940 +          d_path(p, _buffer, sizeof(_buffer)); })
13941 +
13942 +#define vxd_cond_path(n)                                       \
13943 +       ((n) ? vxd_path(&(n)->path) : "<null>" )
13944 +
13945 +
13946 +#ifdef CONFIG_VSERVER_DEBUG
13947 +
13948 +extern unsigned int vx_debug_switch;
13949 +extern unsigned int vx_debug_xid;
13950 +extern unsigned int vx_debug_nid;
13951 +extern unsigned int vx_debug_tag;
13952 +extern unsigned int vx_debug_net;
13953 +extern unsigned int vx_debug_limit;
13954 +extern unsigned int vx_debug_cres;
13955 +extern unsigned int vx_debug_dlim;
13956 +extern unsigned int vx_debug_quota;
13957 +extern unsigned int vx_debug_cvirt;
13958 +extern unsigned int vx_debug_space;
13959 +extern unsigned int vx_debug_misc;
13960 +
13961 +
13962 +#define VX_LOGLEVEL    "vxD: "
13963 +#define VX_PROC_FMT    "%p: "
13964 +#define VX_PROCESS     current
13965 +
13966 +#define vxdprintk(c, f, x...)                                  \
13967 +       do {                                                    \
13968 +               if (c)                                          \
13969 +                       printk(VX_LOGLEVEL VX_PROC_FMT f "\n",  \
13970 +                               VX_PROCESS , ##x);              \
13971 +       } while (0)
13972 +
13973 +#define vxlprintk(c, f, x...)                                  \
13974 +       do {                                                    \
13975 +               if (c)                                          \
13976 +                       printk(VX_LOGLEVEL f " @%s:%d\n", x);   \
13977 +       } while (0)
13978 +
13979 +#define vxfprintk(c, f, x...)                                  \
13980 +       do {                                                    \
13981 +               if (c)                                          \
13982 +                       printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
13983 +       } while (0)
13984 +
13985 +
13986 +struct vx_info;
13987 +
13988 +void dump_vx_info(struct vx_info *, int);
13989 +void dump_vx_info_inactive(int);
13990 +
13991 +#else  /* CONFIG_VSERVER_DEBUG */
13992 +
13993 +#define vx_debug_switch 0
13994 +#define vx_debug_xid   0
13995 +#define vx_debug_nid   0
13996 +#define vx_debug_tag   0
13997 +#define vx_debug_net   0
13998 +#define vx_debug_limit 0
13999 +#define vx_debug_cres  0
14000 +#define vx_debug_dlim  0
14001 +#define vx_debug_cvirt 0
14002 +
14003 +#define vxdprintk(x...) do { } while (0)
14004 +#define vxlprintk(x...) do { } while (0)
14005 +#define vxfprintk(x...) do { } while (0)
14006 +
14007 +#endif /* CONFIG_VSERVER_DEBUG */
14008 +
14009 +
14010 +#ifdef CONFIG_VSERVER_WARN
14011 +
14012 +#define VX_WARNLEVEL   KERN_WARNING "vxW: "
14013 +#define VX_WARN_TASK   "[" VS_Q("%s") ",%u:#%u|%u|%u] "
14014 +#define VX_WARN_XID    "[xid #%u] "
14015 +#define VX_WARN_NID    "[nid #%u] "
14016 +#define VX_WARN_TAG    "[tag #%u] "
14017 +
14018 +#define vxwprintk(c, f, x...)                                  \
14019 +       do {                                                    \
14020 +               if (c)                                          \
14021 +                       printk(VX_WARNLEVEL f "\n", ##x);       \
14022 +       } while (0)
14023 +
14024 +#else  /* CONFIG_VSERVER_WARN */
14025 +
14026 +#define vxwprintk(x...) do { } while (0)
14027 +
14028 +#endif /* CONFIG_VSERVER_WARN */
14029 +
14030 +#define vxwprintk_task(c, f, x...)                             \
14031 +       vxwprintk(c, VX_WARN_TASK f,                            \
14032 +               current->comm, current->pid,                    \
14033 +               current->xid, current->nid, current->tag, ##x)
14034 +#define vxwprintk_xid(c, f, x...)                              \
14035 +       vxwprintk(c, VX_WARN_XID f, current->xid, x)
14036 +#define vxwprintk_nid(c, f, x...)                              \
14037 +       vxwprintk(c, VX_WARN_NID f, current->nid, x)
14038 +#define vxwprintk_tag(c, f, x...)                              \
14039 +       vxwprintk(c, VX_WARN_TAG f, current->tag, x)
14040 +
14041 +#ifdef CONFIG_VSERVER_DEBUG
14042 +#define vxd_assert_lock(l)     assert_spin_locked(l)
14043 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
14044 +       "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
14045 +#else
14046 +#define vxd_assert_lock(l)     do { } while (0)
14047 +#define vxd_assert(c, f, x...) do { } while (0)
14048 +#endif
14049 +
14050 +
14051 +#endif /* _VX_DEBUG_H */
14052 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/debug_cmd.h linux-3.0.4-vs2.3.1/include/linux/vserver/debug_cmd.h
14053 --- linux-3.0.4/include/linux/vserver/debug_cmd.h       1970-01-01 01:00:00.000000000 +0100
14054 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/debug_cmd.h       2011-06-10 22:11:24.000000000 +0200
14055 @@ -0,0 +1,58 @@
14056 +#ifndef _VX_DEBUG_CMD_H
14057 +#define _VX_DEBUG_CMD_H
14058 +
14059 +
14060 +/* debug commands */
14061 +
14062 +#define VCMD_dump_history      VC_CMD(DEBUG, 1, 0)
14063 +
14064 +#define VCMD_read_history      VC_CMD(DEBUG, 5, 0)
14065 +#define VCMD_read_monitor      VC_CMD(DEBUG, 6, 0)
14066 +
14067 +struct  vcmd_read_history_v0 {
14068 +       uint32_t index;
14069 +       uint32_t count;
14070 +       char __user *data;
14071 +};
14072 +
14073 +struct  vcmd_read_monitor_v0 {
14074 +       uint32_t index;
14075 +       uint32_t count;
14076 +       char __user *data;
14077 +};
14078 +
14079 +
14080 +#ifdef __KERNEL__
14081 +
14082 +#ifdef CONFIG_COMPAT
14083 +
14084 +#include <asm/compat.h>
14085 +
14086 +struct vcmd_read_history_v0_x32 {
14087 +       uint32_t index;
14088 +       uint32_t count;
14089 +       compat_uptr_t data_ptr;
14090 +};
14091 +
14092 +struct vcmd_read_monitor_v0_x32 {
14093 +       uint32_t index;
14094 +       uint32_t count;
14095 +       compat_uptr_t data_ptr;
14096 +};
14097 +
14098 +#endif  /* CONFIG_COMPAT */
14099 +
14100 +extern int vc_dump_history(uint32_t);
14101 +
14102 +extern int vc_read_history(uint32_t, void __user *);
14103 +extern int vc_read_monitor(uint32_t, void __user *);
14104 +
14105 +#ifdef CONFIG_COMPAT
14106 +
14107 +extern int vc_read_history_x32(uint32_t, void __user *);
14108 +extern int vc_read_monitor_x32(uint32_t, void __user *);
14109 +
14110 +#endif  /* CONFIG_COMPAT */
14111 +
14112 +#endif /* __KERNEL__ */
14113 +#endif /* _VX_DEBUG_CMD_H */
14114 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/device.h linux-3.0.4-vs2.3.1/include/linux/vserver/device.h
14115 --- linux-3.0.4/include/linux/vserver/device.h  1970-01-01 01:00:00.000000000 +0100
14116 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/device.h  2011-06-10 22:11:24.000000000 +0200
14117 @@ -0,0 +1,15 @@
14118 +#ifndef _VX_DEVICE_H
14119 +#define _VX_DEVICE_H
14120 +
14121 +
14122 +#define DATTR_CREATE   0x00000001
14123 +#define DATTR_OPEN     0x00000002
14124 +
14125 +#define DATTR_REMAP    0x00000010
14126 +
14127 +#define DATTR_MASK     0x00000013
14128 +
14129 +
14130 +#else  /* _VX_DEVICE_H */
14131 +#warning duplicate inclusion
14132 +#endif /* _VX_DEVICE_H */
14133 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/device_cmd.h linux-3.0.4-vs2.3.1/include/linux/vserver/device_cmd.h
14134 --- linux-3.0.4/include/linux/vserver/device_cmd.h      1970-01-01 01:00:00.000000000 +0100
14135 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/device_cmd.h      2011-06-10 22:11:24.000000000 +0200
14136 @@ -0,0 +1,44 @@
14137 +#ifndef _VX_DEVICE_CMD_H
14138 +#define _VX_DEVICE_CMD_H
14139 +
14140 +
14141 +/*  device vserver commands */
14142 +
14143 +#define VCMD_set_mapping       VC_CMD(DEVICE, 1, 0)
14144 +#define VCMD_unset_mapping     VC_CMD(DEVICE, 2, 0)
14145 +
14146 +struct vcmd_set_mapping_v0 {
14147 +       const char __user *device;
14148 +       const char __user *target;
14149 +       uint32_t flags;
14150 +};
14151 +
14152 +
14153 +#ifdef __KERNEL__
14154 +
14155 +#ifdef CONFIG_COMPAT
14156 +
14157 +#include <asm/compat.h>
14158 +
14159 +struct vcmd_set_mapping_v0_x32 {
14160 +       compat_uptr_t device_ptr;
14161 +       compat_uptr_t target_ptr;
14162 +       uint32_t flags;
14163 +};
14164 +
14165 +#endif /* CONFIG_COMPAT */
14166 +
14167 +#include <linux/compiler.h>
14168 +
14169 +extern int vc_set_mapping(struct vx_info *, void __user *);
14170 +extern int vc_unset_mapping(struct vx_info *, void __user *);
14171 +
14172 +#ifdef CONFIG_COMPAT
14173 +
14174 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
14175 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
14176 +
14177 +#endif /* CONFIG_COMPAT */
14178 +
14179 +#endif /* __KERNEL__ */
14180 +#endif /* _VX_DEVICE_CMD_H */
14181 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/device_def.h linux-3.0.4-vs2.3.1/include/linux/vserver/device_def.h
14182 --- linux-3.0.4/include/linux/vserver/device_def.h      1970-01-01 01:00:00.000000000 +0100
14183 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/device_def.h      2011-06-10 22:11:24.000000000 +0200
14184 @@ -0,0 +1,17 @@
14185 +#ifndef _VX_DEVICE_DEF_H
14186 +#define _VX_DEVICE_DEF_H
14187 +
14188 +#include <linux/types.h>
14189 +
14190 +struct vx_dmap_target {
14191 +       dev_t target;
14192 +       uint32_t flags;
14193 +};
14194 +
14195 +struct _vx_device {
14196 +#ifdef CONFIG_VSERVER_DEVICE
14197 +       struct vx_dmap_target targets[2];
14198 +#endif
14199 +};
14200 +
14201 +#endif /* _VX_DEVICE_DEF_H */
14202 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/dlimit.h linux-3.0.4-vs2.3.1/include/linux/vserver/dlimit.h
14203 --- linux-3.0.4/include/linux/vserver/dlimit.h  1970-01-01 01:00:00.000000000 +0100
14204 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/dlimit.h  2011-06-10 22:11:24.000000000 +0200
14205 @@ -0,0 +1,54 @@
14206 +#ifndef _VX_DLIMIT_H
14207 +#define _VX_DLIMIT_H
14208 +
14209 +#include "switch.h"
14210 +
14211 +
14212 +#ifdef __KERNEL__
14213 +
14214 +/*      keep in sync with CDLIM_INFINITY       */
14215 +
14216 +#define DLIM_INFINITY          (~0ULL)
14217 +
14218 +#include <linux/spinlock.h>
14219 +#include <linux/rcupdate.h>
14220 +
14221 +struct super_block;
14222 +
14223 +struct dl_info {
14224 +       struct hlist_node dl_hlist;             /* linked list of contexts */
14225 +       struct rcu_head dl_rcu;                 /* the rcu head */
14226 +       tag_t dl_tag;                           /* context tag */
14227 +       atomic_t dl_usecnt;                     /* usage count */
14228 +       atomic_t dl_refcnt;                     /* reference count */
14229 +
14230 +       struct super_block *dl_sb;              /* associated superblock */
14231 +
14232 +       spinlock_t dl_lock;                     /* protect the values */
14233 +
14234 +       unsigned long long dl_space_used;       /* used space in bytes */
14235 +       unsigned long long dl_space_total;      /* maximum space in bytes */
14236 +       unsigned long dl_inodes_used;           /* used inodes */
14237 +       unsigned long dl_inodes_total;          /* maximum inodes */
14238 +
14239 +       unsigned int dl_nrlmult;                /* non root limit mult */
14240 +};
14241 +
14242 +struct rcu_head;
14243 +
14244 +extern void rcu_free_dl_info(struct rcu_head *);
14245 +extern void unhash_dl_info(struct dl_info *);
14246 +
14247 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
14248 +
14249 +
14250 +struct kstatfs;
14251 +
14252 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
14253 +
14254 +typedef uint64_t dlsize_t;
14255 +
14256 +#endif /* __KERNEL__ */
14257 +#else  /* _VX_DLIMIT_H */
14258 +#warning duplicate inclusion
14259 +#endif /* _VX_DLIMIT_H */
14260 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/dlimit_cmd.h linux-3.0.4-vs2.3.1/include/linux/vserver/dlimit_cmd.h
14261 --- linux-3.0.4/include/linux/vserver/dlimit_cmd.h      1970-01-01 01:00:00.000000000 +0100
14262 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/dlimit_cmd.h      2011-06-10 22:11:24.000000000 +0200
14263 @@ -0,0 +1,109 @@
14264 +#ifndef _VX_DLIMIT_CMD_H
14265 +#define _VX_DLIMIT_CMD_H
14266 +
14267 +
14268 +/*  dlimit vserver commands */
14269 +
14270 +#define VCMD_add_dlimit                VC_CMD(DLIMIT, 1, 0)
14271 +#define VCMD_rem_dlimit                VC_CMD(DLIMIT, 2, 0)
14272 +
14273 +#define VCMD_set_dlimit                VC_CMD(DLIMIT, 5, 0)
14274 +#define VCMD_get_dlimit                VC_CMD(DLIMIT, 6, 0)
14275 +
14276 +struct vcmd_ctx_dlimit_base_v0 {
14277 +       const char __user *name;
14278 +       uint32_t flags;
14279 +};
14280 +
14281 +struct vcmd_ctx_dlimit_v0 {
14282 +       const char __user *name;
14283 +       uint32_t space_used;                    /* used space in kbytes */
14284 +       uint32_t space_total;                   /* maximum space in kbytes */
14285 +       uint32_t inodes_used;                   /* used inodes */
14286 +       uint32_t inodes_total;                  /* maximum inodes */
14287 +       uint32_t reserved;                      /* reserved for root in % */
14288 +       uint32_t flags;
14289 +};
14290 +
14291 +#define CDLIM_UNSET            ((uint32_t)0UL)
14292 +#define CDLIM_INFINITY         ((uint32_t)~0UL)
14293 +#define CDLIM_KEEP             ((uint32_t)~1UL)
14294 +
14295 +#define DLIME_UNIT     0
14296 +#define DLIME_KILO     1
14297 +#define DLIME_MEGA     2
14298 +#define DLIME_GIGA     3
14299 +
14300 +#define DLIMF_SHIFT    0x10
14301 +
14302 +#define DLIMS_USED     0
14303 +#define DLIMS_TOTAL    2
14304 +
14305 +static inline
14306 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
14307 +{
14308 +       int exp = (flags & DLIMF_SHIFT) ?
14309 +               (flags >> shift) & DLIME_GIGA : DLIME_KILO;
14310 +       return ((uint64_t)val) << (10 * exp);
14311 +}
14312 +
14313 +static inline
14314 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
14315 +{
14316 +       int exp = 0;
14317 +
14318 +       if (*flags & DLIMF_SHIFT) {
14319 +               while (val > (1LL << 32) && (exp < 3)) {
14320 +                       val >>= 10;
14321 +                       exp++;
14322 +               }
14323 +               *flags &= ~(DLIME_GIGA << shift);
14324 +               *flags |= exp << shift;
14325 +       } else
14326 +               val >>= 10;
14327 +       return val;
14328 +}
14329 +
14330 +#ifdef __KERNEL__
14331 +
14332 +#ifdef CONFIG_COMPAT
14333 +
14334 +#include <asm/compat.h>
14335 +
14336 +struct vcmd_ctx_dlimit_base_v0_x32 {
14337 +       compat_uptr_t name_ptr;
14338 +       uint32_t flags;
14339 +};
14340 +
14341 +struct vcmd_ctx_dlimit_v0_x32 {
14342 +       compat_uptr_t name_ptr;
14343 +       uint32_t space_used;                    /* used space in kbytes */
14344 +       uint32_t space_total;                   /* maximum space in kbytes */
14345 +       uint32_t inodes_used;                   /* used inodes */
14346 +       uint32_t inodes_total;                  /* maximum inodes */
14347 +       uint32_t reserved;                      /* reserved for root in % */
14348 +       uint32_t flags;
14349 +};
14350 +
14351 +#endif /* CONFIG_COMPAT */
14352 +
14353 +#include <linux/compiler.h>
14354 +
14355 +extern int vc_add_dlimit(uint32_t, void __user *);
14356 +extern int vc_rem_dlimit(uint32_t, void __user *);
14357 +
14358 +extern int vc_set_dlimit(uint32_t, void __user *);
14359 +extern int vc_get_dlimit(uint32_t, void __user *);
14360 +
14361 +#ifdef CONFIG_COMPAT
14362 +
14363 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
14364 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
14365 +
14366 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
14367 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
14368 +
14369 +#endif /* CONFIG_COMPAT */
14370 +
14371 +#endif /* __KERNEL__ */
14372 +#endif /* _VX_DLIMIT_CMD_H */
14373 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/global.h linux-3.0.4-vs2.3.1/include/linux/vserver/global.h
14374 --- linux-3.0.4/include/linux/vserver/global.h  1970-01-01 01:00:00.000000000 +0100
14375 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/global.h  2011-06-10 22:11:24.000000000 +0200
14376 @@ -0,0 +1,19 @@
14377 +#ifndef _VX_GLOBAL_H
14378 +#define _VX_GLOBAL_H
14379 +
14380 +
14381 +extern atomic_t vx_global_ctotal;
14382 +extern atomic_t vx_global_cactive;
14383 +
14384 +extern atomic_t nx_global_ctotal;
14385 +extern atomic_t nx_global_cactive;
14386 +
14387 +extern atomic_t vs_global_nsproxy;
14388 +extern atomic_t vs_global_fs;
14389 +extern atomic_t vs_global_mnt_ns;
14390 +extern atomic_t vs_global_uts_ns;
14391 +extern atomic_t vs_global_user_ns;
14392 +extern atomic_t vs_global_pid_ns;
14393 +
14394 +
14395 +#endif /* _VX_GLOBAL_H */
14396 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/history.h linux-3.0.4-vs2.3.1/include/linux/vserver/history.h
14397 --- linux-3.0.4/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
14398 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/history.h 2011-06-10 22:11:24.000000000 +0200
14399 @@ -0,0 +1,197 @@
14400 +#ifndef _VX_HISTORY_H
14401 +#define _VX_HISTORY_H
14402 +
14403 +
14404 +enum {
14405 +       VXH_UNUSED = 0,
14406 +       VXH_THROW_OOPS = 1,
14407 +
14408 +       VXH_GET_VX_INFO,
14409 +       VXH_PUT_VX_INFO,
14410 +       VXH_INIT_VX_INFO,
14411 +       VXH_SET_VX_INFO,
14412 +       VXH_CLR_VX_INFO,
14413 +       VXH_CLAIM_VX_INFO,
14414 +       VXH_RELEASE_VX_INFO,
14415 +       VXH_ALLOC_VX_INFO,
14416 +       VXH_DEALLOC_VX_INFO,
14417 +       VXH_HASH_VX_INFO,
14418 +       VXH_UNHASH_VX_INFO,
14419 +       VXH_LOC_VX_INFO,
14420 +       VXH_LOOKUP_VX_INFO,
14421 +       VXH_CREATE_VX_INFO,
14422 +};
14423 +
14424 +struct _vxhe_vxi {
14425 +       struct vx_info *ptr;
14426 +       unsigned xid;
14427 +       unsigned usecnt;
14428 +       unsigned tasks;
14429 +};
14430 +
14431 +struct _vxhe_set_clr {
14432 +       void *data;
14433 +};
14434 +
14435 +struct _vxhe_loc_lookup {
14436 +       unsigned arg;
14437 +};
14438 +
14439 +struct _vx_hist_entry {
14440 +       void *loc;
14441 +       unsigned short seq;
14442 +       unsigned short type;
14443 +       struct _vxhe_vxi vxi;
14444 +       union {
14445 +               struct _vxhe_set_clr sc;
14446 +               struct _vxhe_loc_lookup ll;
14447 +       };
14448 +};
14449 +
14450 +#ifdef CONFIG_VSERVER_HISTORY
14451 +
14452 +extern unsigned volatile int vxh_active;
14453 +
14454 +struct _vx_hist_entry *vxh_advance(void *loc);
14455 +
14456 +
14457 +static inline
14458 +void   __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
14459 +{
14460 +       entry->vxi.ptr = vxi;
14461 +       if (vxi) {
14462 +               entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
14463 +               entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
14464 +               entry->vxi.xid = vxi->vx_id;
14465 +       }
14466 +}
14467 +
14468 +
14469 +#define        __HERE__ current_text_addr()
14470 +
14471 +#define __VXH_BODY(__type, __data, __here)     \
14472 +       struct _vx_hist_entry *entry;           \
14473 +                                               \
14474 +       preempt_disable();                      \
14475 +       entry = vxh_advance(__here);            \
14476 +       __data;                                 \
14477 +       entry->type = __type;                   \
14478 +       preempt_enable();
14479 +
14480 +
14481 +       /* pass vxi only */
14482 +
14483 +#define __VXH_SMPL                             \
14484 +       __vxh_copy_vxi(entry, vxi)
14485 +
14486 +static inline
14487 +void   __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
14488 +{
14489 +       __VXH_BODY(__type, __VXH_SMPL, __here)
14490 +}
14491 +
14492 +       /* pass vxi and data (void *) */
14493 +
14494 +#define __VXH_DATA                             \
14495 +       __vxh_copy_vxi(entry, vxi);             \
14496 +       entry->sc.data = data
14497 +
14498 +static inline
14499 +void   __vxh_data(struct vx_info *vxi, void *data,
14500 +                       int __type, void *__here)
14501 +{
14502 +       __VXH_BODY(__type, __VXH_DATA, __here)
14503 +}
14504 +
14505 +       /* pass vxi and arg (long) */
14506 +
14507 +#define __VXH_LONG                             \
14508 +       __vxh_copy_vxi(entry, vxi);             \
14509 +       entry->ll.arg = arg
14510 +
14511 +static inline
14512 +void   __vxh_long(struct vx_info *vxi, long arg,
14513 +                       int __type, void *__here)
14514 +{
14515 +       __VXH_BODY(__type, __VXH_LONG, __here)
14516 +}
14517 +
14518 +
14519 +static inline
14520 +void   __vxh_throw_oops(void *__here)
14521 +{
14522 +       __VXH_BODY(VXH_THROW_OOPS, {}, __here);
14523 +       /* prevent further acquisition */
14524 +       vxh_active = 0;
14525 +}
14526 +
14527 +
14528 +#define vxh_throw_oops()       __vxh_throw_oops(__HERE__);
14529 +
14530 +#define __vxh_get_vx_info(v, h)        __vxh_smpl(v, VXH_GET_VX_INFO, h);
14531 +#define __vxh_put_vx_info(v, h)        __vxh_smpl(v, VXH_PUT_VX_INFO, h);
14532 +
14533 +#define __vxh_init_vx_info(v, d, h) \
14534 +       __vxh_data(v, d, VXH_INIT_VX_INFO, h);
14535 +#define __vxh_set_vx_info(v, d, h) \
14536 +       __vxh_data(v, d, VXH_SET_VX_INFO, h);
14537 +#define __vxh_clr_vx_info(v, d, h) \
14538 +       __vxh_data(v, d, VXH_CLR_VX_INFO, h);
14539 +
14540 +#define __vxh_claim_vx_info(v, d, h) \
14541 +       __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
14542 +#define __vxh_release_vx_info(v, d, h) \
14543 +       __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
14544 +
14545 +#define vxh_alloc_vx_info(v) \
14546 +       __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
14547 +#define vxh_dealloc_vx_info(v) \
14548 +       __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
14549 +
14550 +#define vxh_hash_vx_info(v) \
14551 +       __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
14552 +#define vxh_unhash_vx_info(v) \
14553 +       __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
14554 +
14555 +#define vxh_loc_vx_info(v, l) \
14556 +       __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
14557 +#define vxh_lookup_vx_info(v, l) \
14558 +       __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
14559 +#define vxh_create_vx_info(v, l) \
14560 +       __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
14561 +
14562 +extern void vxh_dump_history(void);
14563 +
14564 +
14565 +#else  /* CONFIG_VSERVER_HISTORY */
14566 +
14567 +#define        __HERE__        0
14568 +
14569 +#define vxh_throw_oops()               do { } while (0)
14570 +
14571 +#define __vxh_get_vx_info(v, h)                do { } while (0)
14572 +#define __vxh_put_vx_info(v, h)                do { } while (0)
14573 +
14574 +#define __vxh_init_vx_info(v, d, h)    do { } while (0)
14575 +#define __vxh_set_vx_info(v, d, h)     do { } while (0)
14576 +#define __vxh_clr_vx_info(v, d, h)     do { } while (0)
14577 +
14578 +#define __vxh_claim_vx_info(v, d, h)   do { } while (0)
14579 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
14580 +
14581 +#define vxh_alloc_vx_info(v)           do { } while (0)
14582 +#define vxh_dealloc_vx_info(v)         do { } while (0)
14583 +
14584 +#define vxh_hash_vx_info(v)            do { } while (0)
14585 +#define vxh_unhash_vx_info(v)          do { } while (0)
14586 +
14587 +#define vxh_loc_vx_info(v, l)          do { } while (0)
14588 +#define vxh_lookup_vx_info(v, l)       do { } while (0)
14589 +#define vxh_create_vx_info(v, l)       do { } while (0)
14590 +
14591 +#define vxh_dump_history()             do { } while (0)
14592 +
14593 +
14594 +#endif /* CONFIG_VSERVER_HISTORY */
14595 +
14596 +#endif /* _VX_HISTORY_H */
14597 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/inode.h linux-3.0.4-vs2.3.1/include/linux/vserver/inode.h
14598 --- linux-3.0.4/include/linux/vserver/inode.h   1970-01-01 01:00:00.000000000 +0100
14599 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/inode.h   2011-06-10 22:11:24.000000000 +0200
14600 @@ -0,0 +1,39 @@
14601 +#ifndef _VX_INODE_H
14602 +#define _VX_INODE_H
14603 +
14604 +
14605 +#define IATTR_TAG      0x01000000
14606 +
14607 +#define IATTR_ADMIN    0x00000001
14608 +#define IATTR_WATCH    0x00000002
14609 +#define IATTR_HIDE     0x00000004
14610 +#define IATTR_FLAGS    0x00000007
14611 +
14612 +#define IATTR_BARRIER  0x00010000
14613 +#define IATTR_IXUNLINK 0x00020000
14614 +#define IATTR_IMMUTABLE 0x00040000
14615 +#define IATTR_COW      0x00080000
14616 +
14617 +#ifdef __KERNEL__
14618 +
14619 +
14620 +#ifdef CONFIG_VSERVER_PROC_SECURE
14621 +#define IATTR_PROC_DEFAULT     ( IATTR_ADMIN | IATTR_HIDE )
14622 +#define IATTR_PROC_SYMLINK     ( IATTR_ADMIN )
14623 +#else
14624 +#define IATTR_PROC_DEFAULT     ( IATTR_ADMIN )
14625 +#define IATTR_PROC_SYMLINK     ( IATTR_ADMIN )
14626 +#endif
14627 +
14628 +#define vx_hide_check(c, m)    (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
14629 +
14630 +#endif /* __KERNEL__ */
14631 +
14632 +/* inode ioctls */
14633 +
14634 +#define FIOC_GETXFLG   _IOR('x', 5, long)
14635 +#define FIOC_SETXFLG   _IOW('x', 6, long)
14636 +
14637 +#else  /* _VX_INODE_H */
14638 +#warning duplicate inclusion
14639 +#endif /* _VX_INODE_H */
14640 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/inode_cmd.h linux-3.0.4-vs2.3.1/include/linux/vserver/inode_cmd.h
14641 --- linux-3.0.4/include/linux/vserver/inode_cmd.h       1970-01-01 01:00:00.000000000 +0100
14642 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/inode_cmd.h       2011-06-10 22:11:24.000000000 +0200
14643 @@ -0,0 +1,59 @@
14644 +#ifndef _VX_INODE_CMD_H
14645 +#define _VX_INODE_CMD_H
14646 +
14647 +
14648 +/*  inode vserver commands */
14649 +
14650 +#define VCMD_get_iattr         VC_CMD(INODE, 1, 1)
14651 +#define VCMD_set_iattr         VC_CMD(INODE, 2, 1)
14652 +
14653 +#define VCMD_fget_iattr                VC_CMD(INODE, 3, 0)
14654 +#define VCMD_fset_iattr                VC_CMD(INODE, 4, 0)
14655 +
14656 +struct vcmd_ctx_iattr_v1 {
14657 +       const char __user *name;
14658 +       uint32_t tag;
14659 +       uint32_t flags;
14660 +       uint32_t mask;
14661 +};
14662 +
14663 +struct vcmd_ctx_fiattr_v0 {
14664 +       uint32_t tag;
14665 +       uint32_t flags;
14666 +       uint32_t mask;
14667 +};
14668 +
14669 +
14670 +#ifdef __KERNEL__
14671 +
14672 +
14673 +#ifdef CONFIG_COMPAT
14674 +
14675 +#include <asm/compat.h>
14676 +
14677 +struct vcmd_ctx_iattr_v1_x32 {
14678 +       compat_uptr_t name_ptr;
14679 +       uint32_t tag;
14680 +       uint32_t flags;
14681 +       uint32_t mask;
14682 +};
14683 +
14684 +#endif /* CONFIG_COMPAT */
14685 +
14686 +#include <linux/compiler.h>
14687 +
14688 +extern int vc_get_iattr(void __user *);
14689 +extern int vc_set_iattr(void __user *);
14690 +
14691 +extern int vc_fget_iattr(uint32_t, void __user *);
14692 +extern int vc_fset_iattr(uint32_t, void __user *);
14693 +
14694 +#ifdef CONFIG_COMPAT
14695 +
14696 +extern int vc_get_iattr_x32(void __user *);
14697 +extern int vc_set_iattr_x32(void __user *);
14698 +
14699 +#endif /* CONFIG_COMPAT */
14700 +
14701 +#endif /* __KERNEL__ */
14702 +#endif /* _VX_INODE_CMD_H */
14703 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/limit.h linux-3.0.4-vs2.3.1/include/linux/vserver/limit.h
14704 --- linux-3.0.4/include/linux/vserver/limit.h   1970-01-01 01:00:00.000000000 +0100
14705 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/limit.h   2011-06-10 22:11:24.000000000 +0200
14706 @@ -0,0 +1,71 @@
14707 +#ifndef _VX_LIMIT_H
14708 +#define _VX_LIMIT_H
14709 +
14710 +#define VLIMIT_NSOCK   16
14711 +#define VLIMIT_OPENFD  17
14712 +#define VLIMIT_ANON    18
14713 +#define VLIMIT_SHMEM   19
14714 +#define VLIMIT_SEMARY  20
14715 +#define VLIMIT_NSEMS   21
14716 +#define VLIMIT_DENTRY  22
14717 +#define VLIMIT_MAPPED  23
14718 +
14719 +
14720 +#ifdef __KERNEL__
14721 +
14722 +#define        VLIM_NOCHECK    ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
14723 +
14724 +/*     keep in sync with CRLIM_INFINITY */
14725 +
14726 +#define        VLIM_INFINITY   (~0ULL)
14727 +
14728 +#include <asm/atomic.h>
14729 +#include <asm/resource.h>
14730 +
14731 +#ifndef RLIM_INFINITY
14732 +#warning RLIM_INFINITY is undefined
14733 +#endif
14734 +
14735 +#define __rlim_val(l, r, v)    ((l)->res[r].v)
14736 +
14737 +#define __rlim_soft(l, r)      __rlim_val(l, r, soft)
14738 +#define __rlim_hard(l, r)      __rlim_val(l, r, hard)
14739 +
14740 +#define __rlim_rcur(l, r)      __rlim_val(l, r, rcur)
14741 +#define __rlim_rmin(l, r)      __rlim_val(l, r, rmin)
14742 +#define __rlim_rmax(l, r)      __rlim_val(l, r, rmax)
14743 +
14744 +#define __rlim_lhit(l, r)      __rlim_val(l, r, lhit)
14745 +#define __rlim_hit(l, r)       atomic_inc(&__rlim_lhit(l, r))
14746 +
14747 +typedef atomic_long_t rlim_atomic_t;
14748 +typedef unsigned long rlim_t;
14749 +
14750 +#define __rlim_get(l, r)       atomic_long_read(&__rlim_rcur(l, r))
14751 +#define __rlim_set(l, r, v)    atomic_long_set(&__rlim_rcur(l, r), v)
14752 +#define __rlim_inc(l, r)       atomic_long_inc(&__rlim_rcur(l, r))
14753 +#define __rlim_dec(l, r)       atomic_long_dec(&__rlim_rcur(l, r))
14754 +#define __rlim_add(l, r, v)    atomic_long_add(v, &__rlim_rcur(l, r))
14755 +#define __rlim_sub(l, r, v)    atomic_long_sub(v, &__rlim_rcur(l, r))
14756 +
14757 +
14758 +#if    (RLIM_INFINITY == VLIM_INFINITY)
14759 +#define        VX_VLIM(r) ((long long)(long)(r))
14760 +#define        VX_RLIM(v) ((rlim_t)(v))
14761 +#else
14762 +#define        VX_VLIM(r) (((r) == RLIM_INFINITY) \
14763 +               ? VLIM_INFINITY : (long long)(r))
14764 +#define        VX_RLIM(v) (((v) == VLIM_INFINITY) \
14765 +               ? RLIM_INFINITY : (rlim_t)(v))
14766 +#endif
14767 +
14768 +struct sysinfo;
14769 +
14770 +void vx_vsi_meminfo(struct sysinfo *);
14771 +void vx_vsi_swapinfo(struct sysinfo *);
14772 +long vx_vsi_cached(struct sysinfo *);
14773 +
14774 +#define NUM_LIMITS     24
14775 +
14776 +#endif /* __KERNEL__ */
14777 +#endif /* _VX_LIMIT_H */
14778 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/limit_cmd.h linux-3.0.4-vs2.3.1/include/linux/vserver/limit_cmd.h
14779 --- linux-3.0.4/include/linux/vserver/limit_cmd.h       1970-01-01 01:00:00.000000000 +0100
14780 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/limit_cmd.h       2011-06-10 22:11:24.000000000 +0200
14781 @@ -0,0 +1,71 @@
14782 +#ifndef _VX_LIMIT_CMD_H
14783 +#define _VX_LIMIT_CMD_H
14784 +
14785 +
14786 +/*  rlimit vserver commands */
14787 +
14788 +#define VCMD_get_rlimit                VC_CMD(RLIMIT, 1, 0)
14789 +#define VCMD_set_rlimit                VC_CMD(RLIMIT, 2, 0)
14790 +#define VCMD_get_rlimit_mask   VC_CMD(RLIMIT, 3, 0)
14791 +#define VCMD_reset_hits                VC_CMD(RLIMIT, 7, 0)
14792 +#define VCMD_reset_minmax      VC_CMD(RLIMIT, 9, 0)
14793 +
14794 +struct vcmd_ctx_rlimit_v0 {
14795 +       uint32_t id;
14796 +       uint64_t minimum;
14797 +       uint64_t softlimit;
14798 +       uint64_t maximum;
14799 +};
14800 +
14801 +struct vcmd_ctx_rlimit_mask_v0 {
14802 +       uint32_t minimum;
14803 +       uint32_t softlimit;
14804 +       uint32_t maximum;
14805 +};
14806 +
14807 +#define VCMD_rlimit_stat       VC_CMD(VSTAT, 1, 0)
14808 +
14809 +struct vcmd_rlimit_stat_v0 {
14810 +       uint32_t id;
14811 +       uint32_t hits;
14812 +       uint64_t value;
14813 +       uint64_t minimum;
14814 +       uint64_t maximum;
14815 +};
14816 +
14817 +#define CRLIM_UNSET            (0ULL)
14818 +#define CRLIM_INFINITY         (~0ULL)
14819 +#define CRLIM_KEEP             (~1ULL)
14820 +
14821 +#ifdef __KERNEL__
14822 +
14823 +#ifdef CONFIG_IA32_EMULATION
14824 +
14825 +struct vcmd_ctx_rlimit_v0_x32 {
14826 +       uint32_t id;
14827 +       uint64_t minimum;
14828 +       uint64_t softlimit;
14829 +       uint64_t maximum;
14830 +} __attribute__ ((packed));
14831 +
14832 +#endif /* CONFIG_IA32_EMULATION */
14833 +
14834 +#include <linux/compiler.h>
14835 +
14836 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
14837 +extern int vc_get_rlimit(struct vx_info *, void __user *);
14838 +extern int vc_set_rlimit(struct vx_info *, void __user *);
14839 +extern int vc_reset_hits(struct vx_info *, void __user *);
14840 +extern int vc_reset_minmax(struct vx_info *, void __user *);
14841 +
14842 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
14843 +
14844 +#ifdef CONFIG_IA32_EMULATION
14845 +
14846 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
14847 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
14848 +
14849 +#endif /* CONFIG_IA32_EMULATION */
14850 +
14851 +#endif /* __KERNEL__ */
14852 +#endif /* _VX_LIMIT_CMD_H */
14853 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/limit_def.h linux-3.0.4-vs2.3.1/include/linux/vserver/limit_def.h
14854 --- linux-3.0.4/include/linux/vserver/limit_def.h       1970-01-01 01:00:00.000000000 +0100
14855 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/limit_def.h       2011-06-10 22:11:24.000000000 +0200
14856 @@ -0,0 +1,47 @@
14857 +#ifndef _VX_LIMIT_DEF_H
14858 +#define _VX_LIMIT_DEF_H
14859 +
14860 +#include <asm/atomic.h>
14861 +#include <asm/resource.h>
14862 +
14863 +#include "limit.h"
14864 +
14865 +
14866 +struct _vx_res_limit {
14867 +       rlim_t soft;            /* Context soft limit */
14868 +       rlim_t hard;            /* Context hard limit */
14869 +
14870 +       rlim_atomic_t rcur;     /* Current value */
14871 +       rlim_t rmin;            /* Context minimum */
14872 +       rlim_t rmax;            /* Context maximum */
14873 +
14874 +       atomic_t lhit;          /* Limit hits */
14875 +};
14876 +
14877 +/* context sub struct */
14878 +
14879 +struct _vx_limit {
14880 +       struct _vx_res_limit res[NUM_LIMITS];
14881 +};
14882 +
14883 +#ifdef CONFIG_VSERVER_DEBUG
14884 +
14885 +static inline void __dump_vx_limit(struct _vx_limit *limit)
14886 +{
14887 +       int i;
14888 +
14889 +       printk("\t_vx_limit:");
14890 +       for (i = 0; i < NUM_LIMITS; i++) {
14891 +               printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
14892 +                       i, (unsigned long)__rlim_get(limit, i),
14893 +                       (unsigned long)__rlim_rmin(limit, i),
14894 +                       (unsigned long)__rlim_rmax(limit, i),
14895 +                       (long)__rlim_soft(limit, i),
14896 +                       (long)__rlim_hard(limit, i),
14897 +                       atomic_read(&__rlim_lhit(limit, i)));
14898 +       }
14899 +}
14900 +
14901 +#endif
14902 +
14903 +#endif /* _VX_LIMIT_DEF_H */
14904 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/limit_int.h linux-3.0.4-vs2.3.1/include/linux/vserver/limit_int.h
14905 --- linux-3.0.4/include/linux/vserver/limit_int.h       1970-01-01 01:00:00.000000000 +0100
14906 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/limit_int.h       2011-06-10 22:11:24.000000000 +0200
14907 @@ -0,0 +1,198 @@
14908 +#ifndef _VX_LIMIT_INT_H
14909 +#define _VX_LIMIT_INT_H
14910 +
14911 +#include "context.h"
14912 +
14913 +#ifdef __KERNEL__
14914 +
14915 +#define VXD_RCRES_COND(r)      VXD_CBIT(cres, r)
14916 +#define VXD_RLIMIT_COND(r)     VXD_CBIT(limit, r)
14917 +
14918 +extern const char *vlimit_name[NUM_LIMITS];
14919 +
14920 +static inline void __vx_acc_cres(struct vx_info *vxi,
14921 +       int res, int dir, void *_data, char *_file, int _line)
14922 +{
14923 +       if (VXD_RCRES_COND(res))
14924 +               vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
14925 +                       (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
14926 +                       (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
14927 +                       (dir > 0) ? "++" : "--", _data, _file, _line);
14928 +       if (!vxi)
14929 +               return;
14930 +
14931 +       if (dir > 0)
14932 +               __rlim_inc(&vxi->limit, res);
14933 +       else
14934 +               __rlim_dec(&vxi->limit, res);
14935 +}
14936 +
14937 +static inline void __vx_add_cres(struct vx_info *vxi,
14938 +       int res, int amount, void *_data, char *_file, int _line)
14939 +{
14940 +       if (VXD_RCRES_COND(res))
14941 +               vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
14942 +                       (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
14943 +                       (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
14944 +                       amount, _data, _file, _line);
14945 +       if (amount == 0)
14946 +               return;
14947 +       if (!vxi)
14948 +               return;
14949 +       __rlim_add(&vxi->limit, res, amount);
14950 +}
14951 +
14952 +static inline
14953 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
14954 +{
14955 +       int cond = (value > __rlim_rmax(limit, res));
14956 +
14957 +       if (cond)
14958 +               __rlim_rmax(limit, res) = value;
14959 +       return cond;
14960 +}
14961 +
14962 +static inline
14963 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
14964 +{
14965 +       int cond = (value < __rlim_rmin(limit, res));
14966 +
14967 +       if (cond)
14968 +               __rlim_rmin(limit, res) = value;
14969 +       return cond;
14970 +}
14971 +
14972 +static inline
14973 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
14974 +{
14975 +       if (!__vx_cres_adjust_max(limit, res, value))
14976 +               __vx_cres_adjust_min(limit, res, value);
14977 +}
14978 +
14979 +
14980 +/*     return values:
14981 +        +1 ... no limit hit
14982 +        -1 ... over soft limit
14983 +         0 ... over hard limit         */
14984 +
14985 +static inline int __vx_cres_avail(struct vx_info *vxi,
14986 +       int res, int num, char *_file, int _line)
14987 +{
14988 +       struct _vx_limit *limit;
14989 +       rlim_t value;
14990 +
14991 +       if (VXD_RLIMIT_COND(res))
14992 +               vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
14993 +                       (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
14994 +                       (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
14995 +                       (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
14996 +                       (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
14997 +                       num, _file, _line);
14998 +       if (!vxi)
14999 +               return 1;
15000 +
15001 +       limit = &vxi->limit;
15002 +       value = __rlim_get(limit, res);
15003 +
15004 +       if (!__vx_cres_adjust_max(limit, res, value))
15005 +               __vx_cres_adjust_min(limit, res, value);
15006 +
15007 +       if (num == 0)
15008 +               return 1;
15009 +
15010 +       if (__rlim_soft(limit, res) == RLIM_INFINITY)
15011 +               return -1;
15012 +       if (value + num <= __rlim_soft(limit, res))
15013 +               return -1;
15014 +
15015 +       if (__rlim_hard(limit, res) == RLIM_INFINITY)
15016 +               return 1;
15017 +       if (value + num <= __rlim_hard(limit, res))
15018 +               return 1;
15019 +
15020 +       __rlim_hit(limit, res);
15021 +       return 0;
15022 +}
15023 +
15024 +
15025 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
15026 +
15027 +static inline
15028 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
15029 +{
15030 +       rlim_t value, sum = 0;
15031 +       int res;
15032 +
15033 +       while ((res = *array++)) {
15034 +               value = __rlim_get(limit, res);
15035 +               __vx_cres_fixup(limit, res, value);
15036 +               sum += value;
15037 +       }
15038 +       return sum;
15039 +}
15040 +
15041 +static inline
15042 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
15043 +{
15044 +       rlim_t value = __vx_cres_array_sum(limit, array + 1);
15045 +       int res = *array;
15046 +
15047 +       if (value == __rlim_get(limit, res))
15048 +               return value;
15049 +
15050 +       __rlim_set(limit, res, value);
15051 +       /* now adjust min/max */
15052 +       if (!__vx_cres_adjust_max(limit, res, value))
15053 +               __vx_cres_adjust_min(limit, res, value);
15054 +
15055 +       return value;
15056 +}
15057 +
15058 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
15059 +       const int *array, int num, char *_file, int _line)
15060 +{
15061 +       struct _vx_limit *limit;
15062 +       rlim_t value = 0;
15063 +       int res;
15064 +
15065 +       if (num == 0)
15066 +               return 1;
15067 +       if (!vxi)
15068 +               return 1;
15069 +
15070 +       limit = &vxi->limit;
15071 +       res = *array;
15072 +       value = __vx_cres_array_sum(limit, array + 1);
15073 +
15074 +       __rlim_set(limit, res, value);
15075 +       __vx_cres_fixup(limit, res, value);
15076 +
15077 +       return __vx_cres_avail(vxi, res, num, _file, _line);
15078 +}
15079 +
15080 +
15081 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
15082 +{
15083 +       rlim_t value;
15084 +       int res;
15085 +
15086 +       /* complex resources first */
15087 +       if ((id < 0) || (id == RLIMIT_RSS))
15088 +               __vx_cres_array_fixup(limit, VLA_RSS);
15089 +
15090 +       for (res = 0; res < NUM_LIMITS; res++) {
15091 +               if ((id > 0) && (res != id))
15092 +                       continue;
15093 +
15094 +               value = __rlim_get(limit, res);
15095 +               __vx_cres_fixup(limit, res, value);
15096 +
15097 +               /* not supposed to happen, maybe warn? */
15098 +               if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
15099 +                       __rlim_rmax(limit, res) = __rlim_hard(limit, res);
15100 +       }
15101 +}
15102 +
15103 +
15104 +#endif /* __KERNEL__ */
15105 +#endif /* _VX_LIMIT_INT_H */
15106 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/monitor.h linux-3.0.4-vs2.3.1/include/linux/vserver/monitor.h
15107 --- linux-3.0.4/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
15108 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/monitor.h 2011-06-10 22:11:24.000000000 +0200
15109 @@ -0,0 +1,96 @@
15110 +#ifndef _VX_MONITOR_H
15111 +#define _VX_MONITOR_H
15112 +
15113 +#include <linux/types.h>
15114 +
15115 +enum {
15116 +       VXM_UNUSED = 0,
15117 +
15118 +       VXM_SYNC = 0x10,
15119 +
15120 +       VXM_UPDATE = 0x20,
15121 +       VXM_UPDATE_1,
15122 +       VXM_UPDATE_2,
15123 +
15124 +       VXM_RQINFO_1 = 0x24,
15125 +       VXM_RQINFO_2,
15126 +
15127 +       VXM_ACTIVATE = 0x40,
15128 +       VXM_DEACTIVATE,
15129 +       VXM_IDLE,
15130 +
15131 +       VXM_HOLD = 0x44,
15132 +       VXM_UNHOLD,
15133 +
15134 +       VXM_MIGRATE = 0x48,
15135 +       VXM_RESCHED,
15136 +
15137 +       /* all other bits are flags */
15138 +       VXM_SCHED = 0x80,
15139 +};
15140 +
15141 +struct _vxm_update_1 {
15142 +       uint32_t tokens_max;
15143 +       uint32_t fill_rate;
15144 +       uint32_t interval;
15145 +};
15146 +
15147 +struct _vxm_update_2 {
15148 +       uint32_t tokens_min;
15149 +       uint32_t fill_rate;
15150 +       uint32_t interval;
15151 +};
15152 +
15153 +struct _vxm_rqinfo_1 {
15154 +       uint16_t running;
15155 +       uint16_t onhold;
15156 +       uint16_t iowait;
15157 +       uint16_t uintr;
15158 +       uint32_t idle_tokens;
15159 +};
15160 +
15161 +struct _vxm_rqinfo_2 {
15162 +       uint32_t norm_time;
15163 +       uint32_t idle_time;
15164 +       uint32_t idle_skip;
15165 +};
15166 +
15167 +struct _vxm_sched {
15168 +       uint32_t tokens;
15169 +       uint32_t norm_time;
15170 +       uint32_t idle_time;
15171 +};
15172 +
15173 +struct _vxm_task {
15174 +       uint16_t pid;
15175 +       uint16_t state;
15176 +};
15177 +
15178 +struct _vxm_event {
15179 +       uint32_t jif;
15180 +       union {
15181 +               uint32_t seq;
15182 +               uint32_t sec;
15183 +       };
15184 +       union {
15185 +               uint32_t tokens;
15186 +               uint32_t nsec;
15187 +               struct _vxm_task tsk;
15188 +       };
15189 +};
15190 +
15191 +struct _vx_mon_entry {
15192 +       uint16_t type;
15193 +       uint16_t xid;
15194 +       union {
15195 +               struct _vxm_event ev;
15196 +               struct _vxm_sched sd;
15197 +               struct _vxm_update_1 u1;
15198 +               struct _vxm_update_2 u2;
15199 +               struct _vxm_rqinfo_1 q1;
15200 +               struct _vxm_rqinfo_2 q2;
15201 +       };
15202 +};
15203 +
15204 +
15205 +#endif /* _VX_MONITOR_H */
15206 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/network.h linux-3.0.4-vs2.3.1/include/linux/vserver/network.h
15207 --- linux-3.0.4/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
15208 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/network.h 2011-08-18 16:30:48.000000000 +0200
15209 @@ -0,0 +1,148 @@
15210 +#ifndef _VX_NETWORK_H
15211 +#define _VX_NETWORK_H
15212 +
15213 +#include <linux/types.h>
15214 +
15215 +
15216 +#define MAX_N_CONTEXT  65535   /* Arbitrary limit */
15217 +
15218 +
15219 +/* network flags */
15220 +
15221 +#define NXF_INFO_PRIVATE       0x00000008
15222 +
15223 +#define NXF_SINGLE_IP          0x00000100
15224 +#define NXF_LBACK_REMAP                0x00000200
15225 +#define NXF_LBACK_ALLOW                0x00000400
15226 +
15227 +#define NXF_HIDE_NETIF         0x02000000
15228 +#define NXF_HIDE_LBACK         0x04000000
15229 +
15230 +#define NXF_STATE_SETUP                (1ULL << 32)
15231 +#define NXF_STATE_ADMIN                (1ULL << 34)
15232 +
15233 +#define NXF_SC_HELPER          (1ULL << 36)
15234 +#define NXF_PERSISTENT         (1ULL << 38)
15235 +
15236 +#define NXF_ONE_TIME           (0x0005ULL << 32)
15237 +
15238 +
15239 +#define        NXF_INIT_SET            (__nxf_init_set())
15240 +
15241 +static inline uint64_t __nxf_init_set(void) {
15242 +       return    NXF_STATE_ADMIN
15243 +#ifdef CONFIG_VSERVER_AUTO_LBACK
15244 +               | NXF_LBACK_REMAP
15245 +               | NXF_HIDE_LBACK
15246 +#endif
15247 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
15248 +               | NXF_SINGLE_IP
15249 +#endif
15250 +               | NXF_HIDE_NETIF;
15251 +}
15252 +
15253 +
15254 +/* network caps */
15255 +
15256 +#define NXC_TUN_CREATE         0x00000001
15257 +
15258 +#define NXC_RAW_ICMP           0x00000100
15259 +
15260 +#define NXC_MULTICAST          0x00001000
15261 +
15262 +
15263 +/* address types */
15264 +
15265 +#define NXA_TYPE_IPV4          0x0001
15266 +#define NXA_TYPE_IPV6          0x0002
15267 +
15268 +#define NXA_TYPE_NONE          0x0000
15269 +#define NXA_TYPE_ANY           0x00FF
15270 +
15271 +#define NXA_TYPE_ADDR          0x0010
15272 +#define NXA_TYPE_MASK          0x0020
15273 +#define NXA_TYPE_RANGE         0x0040
15274 +
15275 +#define NXA_MASK_ALL           (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
15276 +
15277 +#define NXA_MOD_BCAST          0x0100
15278 +#define NXA_MOD_LBACK          0x0200
15279 +
15280 +#define NXA_LOOPBACK           0x1000
15281 +
15282 +#define NXA_MASK_BIND          (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
15283 +#define NXA_MASK_SHOW          (NXA_MASK_ALL | NXA_LOOPBACK)
15284 +
15285 +#ifdef __KERNEL__
15286 +
15287 +#include <linux/list.h>
15288 +#include <linux/spinlock.h>
15289 +#include <linux/rcupdate.h>
15290 +#include <linux/in.h>
15291 +#include <linux/in6.h>
15292 +#include <asm/atomic.h>
15293 +
15294 +struct nx_addr_v4 {
15295 +       struct nx_addr_v4 *next;
15296 +       struct in_addr ip[2];
15297 +       struct in_addr mask;
15298 +       uint16_t type;
15299 +       uint16_t flags;
15300 +};
15301 +
15302 +struct nx_addr_v6 {
15303 +       struct nx_addr_v6 *next;
15304 +       struct in6_addr ip;
15305 +       struct in6_addr mask;
15306 +       uint32_t prefix;
15307 +       uint16_t type;
15308 +       uint16_t flags;
15309 +};
15310 +
15311 +struct nx_info {
15312 +       struct hlist_node nx_hlist;     /* linked list of nxinfos */
15313 +       nid_t nx_id;                    /* vnet id */
15314 +       atomic_t nx_usecnt;             /* usage count */
15315 +       atomic_t nx_tasks;              /* tasks count */
15316 +       int nx_state;                   /* context state */
15317 +
15318 +       uint64_t nx_flags;              /* network flag word */
15319 +       uint64_t nx_ncaps;              /* network capabilities */
15320 +
15321 +       struct in_addr v4_lback;        /* Loopback address */
15322 +       struct in_addr v4_bcast;        /* Broadcast address */
15323 +       struct nx_addr_v4 v4;           /* First/Single ipv4 address */
15324 +#ifdef CONFIG_IPV6
15325 +       struct nx_addr_v6 v6;           /* First/Single ipv6 address */
15326 +#endif
15327 +       char nx_name[65];               /* network context name */
15328 +};
15329 +
15330 +
15331 +/* status flags */
15332 +
15333 +#define NXS_HASHED      0x0001
15334 +#define NXS_SHUTDOWN    0x0100
15335 +#define NXS_RELEASED    0x8000
15336 +
15337 +extern struct nx_info *lookup_nx_info(int);
15338 +
15339 +extern int get_nid_list(int, unsigned int *, int);
15340 +extern int nid_is_hashed(nid_t);
15341 +
15342 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
15343 +
15344 +extern long vs_net_change(struct nx_info *, unsigned int);
15345 +
15346 +struct sock;
15347 +
15348 +
15349 +#define NX_IPV4(n)     ((n)->v4.type != NXA_TYPE_NONE)
15350 +#ifdef  CONFIG_IPV6
15351 +#define NX_IPV6(n)     ((n)->v6.type != NXA_TYPE_NONE)
15352 +#else
15353 +#define NX_IPV6(n)     (0)
15354 +#endif
15355 +
15356 +#endif /* __KERNEL__ */
15357 +#endif /* _VX_NETWORK_H */
15358 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/network_cmd.h linux-3.0.4-vs2.3.1/include/linux/vserver/network_cmd.h
15359 --- linux-3.0.4/include/linux/vserver/network_cmd.h     1970-01-01 01:00:00.000000000 +0100
15360 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/network_cmd.h     2011-06-10 22:11:24.000000000 +0200
15361 @@ -0,0 +1,164 @@
15362 +#ifndef _VX_NETWORK_CMD_H
15363 +#define _VX_NETWORK_CMD_H
15364 +
15365 +
15366 +/* vinfo commands */
15367 +
15368 +#define VCMD_task_nid          VC_CMD(VINFO, 2, 0)
15369 +
15370 +#ifdef __KERNEL__
15371 +extern int vc_task_nid(uint32_t);
15372 +
15373 +#endif /* __KERNEL__ */
15374 +
15375 +#define VCMD_nx_info           VC_CMD(VINFO, 6, 0)
15376 +
15377 +struct vcmd_nx_info_v0 {
15378 +       uint32_t nid;
15379 +       /* more to come */
15380 +};
15381 +
15382 +#ifdef __KERNEL__
15383 +extern int vc_nx_info(struct nx_info *, void __user *);
15384 +
15385 +#endif /* __KERNEL__ */
15386 +
15387 +#include <linux/in.h>
15388 +#include <linux/in6.h>
15389 +
15390 +#define VCMD_net_create_v0     VC_CMD(VNET, 1, 0)
15391 +#define VCMD_net_create                VC_CMD(VNET, 1, 1)
15392 +
15393 +struct  vcmd_net_create {
15394 +       uint64_t flagword;
15395 +};
15396 +
15397 +#define VCMD_net_migrate       VC_CMD(NETMIG, 1, 0)
15398 +
15399 +#define VCMD_net_add           VC_CMD(NETALT, 1, 0)
15400 +#define VCMD_net_remove                VC_CMD(NETALT, 2, 0)
15401 +
15402 +struct vcmd_net_addr_v0 {
15403 +       uint16_t type;
15404 +       uint16_t count;
15405 +       struct in_addr ip[4];
15406 +       struct in_addr mask[4];
15407 +};
15408 +
15409 +#define VCMD_net_add_ipv4_v1   VC_CMD(NETALT, 1, 1)
15410 +#define VCMD_net_rem_ipv4_v1   VC_CMD(NETALT, 2, 1)
15411 +
15412 +struct vcmd_net_addr_ipv4_v1 {
15413 +       uint16_t type;
15414 +       uint16_t flags;
15415 +       struct in_addr ip;
15416 +       struct in_addr mask;
15417 +};
15418 +
15419 +#define VCMD_net_add_ipv4      VC_CMD(NETALT, 1, 2)
15420 +#define VCMD_net_rem_ipv4      VC_CMD(NETALT, 2, 2)
15421 +
15422 +struct vcmd_net_addr_ipv4_v2 {
15423 +       uint16_t type;
15424 +       uint16_t flags;
15425 +       struct in_addr ip;
15426 +       struct in_addr ip2;
15427 +       struct in_addr mask;
15428 +};
15429 +
15430 +#define VCMD_net_add_ipv6      VC_CMD(NETALT, 3, 1)
15431 +#define VCMD_net_remove_ipv6   VC_CMD(NETALT, 4, 1)
15432 +
15433 +struct vcmd_net_addr_ipv6_v1 {
15434 +       uint16_t type;
15435 +       uint16_t flags;
15436 +       uint32_t prefix;
15437 +       struct in6_addr ip;
15438 +       struct in6_addr mask;
15439 +};
15440 +
15441 +#define VCMD_add_match_ipv4    VC_CMD(NETALT, 5, 0)
15442 +#define VCMD_get_match_ipv4    VC_CMD(NETALT, 6, 0)
15443 +
15444 +struct vcmd_match_ipv4_v0 {
15445 +       uint16_t type;
15446 +       uint16_t flags;
15447 +       uint16_t parent;
15448 +       uint16_t prefix;
15449 +       struct in_addr ip;
15450 +       struct in_addr ip2;
15451 +       struct in_addr mask;
15452 +};
15453 +
15454 +#define VCMD_add_match_ipv6    VC_CMD(NETALT, 7, 0)
15455 +#define VCMD_get_match_ipv6    VC_CMD(NETALT, 8, 0)
15456 +
15457 +struct vcmd_match_ipv6_v0 {
15458 +       uint16_t type;
15459 +       uint16_t flags;
15460 +       uint16_t parent;
15461 +       uint16_t prefix;
15462 +       struct in6_addr ip;
15463 +       struct in6_addr ip2;
15464 +       struct in6_addr mask;
15465 +};
15466 +
15467 +
15468 +#ifdef __KERNEL__
15469 +extern int vc_net_create(uint32_t, void __user *);
15470 +extern int vc_net_migrate(struct nx_info *, void __user *);
15471 +
15472 +extern int vc_net_add(struct nx_info *, void __user *);
15473 +extern int vc_net_remove(struct nx_info *, void __user *);
15474 +
15475 +extern int vc_net_add_ipv4_v1(struct nx_info *, void __user *);
15476 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
15477 +
15478 +extern int vc_net_rem_ipv4_v1(struct nx_info *, void __user *);
15479 +extern int vc_net_rem_ipv4(struct nx_info *, void __user *);
15480 +
15481 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
15482 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
15483 +
15484 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
15485 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
15486 +
15487 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
15488 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
15489 +
15490 +#endif /* __KERNEL__ */
15491 +
15492 +
15493 +/* flag commands */
15494 +
15495 +#define VCMD_get_nflags                VC_CMD(FLAGS, 5, 0)
15496 +#define VCMD_set_nflags                VC_CMD(FLAGS, 6, 0)
15497 +
15498 +struct vcmd_net_flags_v0 {
15499 +       uint64_t flagword;
15500 +       uint64_t mask;
15501 +};
15502 +
15503 +#ifdef __KERNEL__
15504 +extern int vc_get_nflags(struct nx_info *, void __user *);
15505 +extern int vc_set_nflags(struct nx_info *, void __user *);
15506 +
15507 +#endif /* __KERNEL__ */
15508 +
15509 +
15510 +/* network caps commands */
15511 +
15512 +#define VCMD_get_ncaps         VC_CMD(FLAGS, 7, 0)
15513 +#define VCMD_set_ncaps         VC_CMD(FLAGS, 8, 0)
15514 +
15515 +struct vcmd_net_caps_v0 {
15516 +       uint64_t ncaps;
15517 +       uint64_t cmask;
15518 +};
15519 +
15520 +#ifdef __KERNEL__
15521 +extern int vc_get_ncaps(struct nx_info *, void __user *);
15522 +extern int vc_set_ncaps(struct nx_info *, void __user *);
15523 +
15524 +#endif /* __KERNEL__ */
15525 +#endif /* _VX_CONTEXT_CMD_H */
15526 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/percpu.h linux-3.0.4-vs2.3.1/include/linux/vserver/percpu.h
15527 --- linux-3.0.4/include/linux/vserver/percpu.h  1970-01-01 01:00:00.000000000 +0100
15528 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/percpu.h  2011-06-10 22:11:24.000000000 +0200
15529 @@ -0,0 +1,14 @@
15530 +#ifndef _VX_PERCPU_H
15531 +#define _VX_PERCPU_H
15532 +
15533 +#include "cvirt_def.h"
15534 +#include "sched_def.h"
15535 +
15536 +struct _vx_percpu {
15537 +       struct _vx_cvirt_pc cvirt;
15538 +       struct _vx_sched_pc sched;
15539 +};
15540 +
15541 +#define        PERCPU_PERCTX   (sizeof(struct _vx_percpu))
15542 +
15543 +#endif /* _VX_PERCPU_H */
15544 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/pid.h linux-3.0.4-vs2.3.1/include/linux/vserver/pid.h
15545 --- linux-3.0.4/include/linux/vserver/pid.h     1970-01-01 01:00:00.000000000 +0100
15546 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/pid.h     2011-06-10 22:11:24.000000000 +0200
15547 @@ -0,0 +1,51 @@
15548 +#ifndef _VSERVER_PID_H
15549 +#define _VSERVER_PID_H
15550 +
15551 +/* pid faking stuff */
15552 +
15553 +#define vx_info_map_pid(v, p) \
15554 +       __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
15555 +#define vx_info_map_tgid(v,p)  vx_info_map_pid(v,p)
15556 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
15557 +#define vx_map_tgid(p) vx_map_pid(p)
15558 +
15559 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
15560 +       const char *func, const char *file, int line)
15561 +{
15562 +       if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
15563 +               vxfprintk(VXD_CBIT(cvirt, 2),
15564 +                       "vx_map_tgid: %p/%llx: %d -> %d",
15565 +                       vxi, (long long)vxi->vx_flags, pid,
15566 +                       (pid && pid == vxi->vx_initpid) ? 1 : pid,
15567 +                       func, file, line);
15568 +               if (pid == 0)
15569 +                       return 0;
15570 +               if (pid == vxi->vx_initpid)
15571 +                       return 1;
15572 +       }
15573 +       return pid;
15574 +}
15575 +
15576 +#define vx_info_rmap_pid(v, p) \
15577 +       __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
15578 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
15579 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
15580 +
15581 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
15582 +       const char *func, const char *file, int line)
15583 +{
15584 +       if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
15585 +               vxfprintk(VXD_CBIT(cvirt, 2),
15586 +                       "vx_rmap_tgid: %p/%llx: %d -> %d",
15587 +                       vxi, (long long)vxi->vx_flags, pid,
15588 +                       (pid == 1) ? vxi->vx_initpid : pid,
15589 +                       func, file, line);
15590 +               if ((pid == 1) && vxi->vx_initpid)
15591 +                       return vxi->vx_initpid;
15592 +               if (pid == vxi->vx_initpid)
15593 +                       return ~0U;
15594 +       }
15595 +       return pid;
15596 +}
15597 +
15598 +#endif
15599 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/sched.h linux-3.0.4-vs2.3.1/include/linux/vserver/sched.h
15600 --- linux-3.0.4/include/linux/vserver/sched.h   1970-01-01 01:00:00.000000000 +0100
15601 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/sched.h   2011-06-10 22:11:24.000000000 +0200
15602 @@ -0,0 +1,23 @@
15603 +#ifndef _VX_SCHED_H
15604 +#define _VX_SCHED_H
15605 +
15606 +
15607 +#ifdef __KERNEL__
15608 +
15609 +struct timespec;
15610 +
15611 +void vx_vsi_uptime(struct timespec *, struct timespec *);
15612 +
15613 +
15614 +struct vx_info;
15615 +
15616 +void vx_update_load(struct vx_info *);
15617 +
15618 +
15619 +void vx_update_sched_param(struct _vx_sched *sched,
15620 +       struct _vx_sched_pc *sched_pc);
15621 +
15622 +#endif /* __KERNEL__ */
15623 +#else  /* _VX_SCHED_H */
15624 +#warning duplicate inclusion
15625 +#endif /* _VX_SCHED_H */
15626 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/sched_cmd.h linux-3.0.4-vs2.3.1/include/linux/vserver/sched_cmd.h
15627 --- linux-3.0.4/include/linux/vserver/sched_cmd.h       1970-01-01 01:00:00.000000000 +0100
15628 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/sched_cmd.h       2011-06-10 22:11:24.000000000 +0200
15629 @@ -0,0 +1,21 @@
15630 +#ifndef _VX_SCHED_CMD_H
15631 +#define _VX_SCHED_CMD_H
15632 +
15633 +
15634 +struct vcmd_prio_bias {
15635 +       int32_t cpu_id;
15636 +       int32_t prio_bias;
15637 +};
15638 +
15639 +#define VCMD_set_prio_bias     VC_CMD(SCHED, 4, 0)
15640 +#define VCMD_get_prio_bias     VC_CMD(SCHED, 5, 0)
15641 +
15642 +#ifdef __KERNEL__
15643 +
15644 +#include <linux/compiler.h>
15645 +
15646 +extern int vc_set_prio_bias(struct vx_info *, void __user *);
15647 +extern int vc_get_prio_bias(struct vx_info *, void __user *);
15648 +
15649 +#endif /* __KERNEL__ */
15650 +#endif /* _VX_SCHED_CMD_H */
15651 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/sched_def.h linux-3.0.4-vs2.3.1/include/linux/vserver/sched_def.h
15652 --- linux-3.0.4/include/linux/vserver/sched_def.h       1970-01-01 01:00:00.000000000 +0100
15653 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/sched_def.h       2011-06-10 22:11:24.000000000 +0200
15654 @@ -0,0 +1,38 @@
15655 +#ifndef _VX_SCHED_DEF_H
15656 +#define _VX_SCHED_DEF_H
15657 +
15658 +#include <linux/spinlock.h>
15659 +#include <linux/jiffies.h>
15660 +#include <linux/cpumask.h>
15661 +#include <asm/atomic.h>
15662 +#include <asm/param.h>
15663 +
15664 +
15665 +/* context sub struct */
15666 +
15667 +struct _vx_sched {
15668 +       int prio_bias;                  /* bias offset for priority */
15669 +
15670 +       cpumask_t update;               /* CPUs which should update */
15671 +};
15672 +
15673 +struct _vx_sched_pc {
15674 +       int prio_bias;                  /* bias offset for priority */
15675 +
15676 +       uint64_t user_ticks;            /* token tick events */
15677 +       uint64_t sys_ticks;             /* token tick events */
15678 +       uint64_t hold_ticks;            /* token ticks paused */
15679 +};
15680 +
15681 +
15682 +#ifdef CONFIG_VSERVER_DEBUG
15683 +
15684 +static inline void __dump_vx_sched(struct _vx_sched *sched)
15685 +{
15686 +       printk("\t_vx_sched:\n");
15687 +       printk("\t priority = %4d\n", sched->prio_bias);
15688 +}
15689 +
15690 +#endif
15691 +
15692 +#endif /* _VX_SCHED_DEF_H */
15693 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/signal.h linux-3.0.4-vs2.3.1/include/linux/vserver/signal.h
15694 --- linux-3.0.4/include/linux/vserver/signal.h  1970-01-01 01:00:00.000000000 +0100
15695 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/signal.h  2011-06-10 22:11:24.000000000 +0200
15696 @@ -0,0 +1,14 @@
15697 +#ifndef _VX_SIGNAL_H
15698 +#define _VX_SIGNAL_H
15699 +
15700 +
15701 +#ifdef __KERNEL__
15702 +
15703 +struct vx_info;
15704 +
15705 +int vx_info_kill(struct vx_info *, int, int);
15706 +
15707 +#endif /* __KERNEL__ */
15708 +#else  /* _VX_SIGNAL_H */
15709 +#warning duplicate inclusion
15710 +#endif /* _VX_SIGNAL_H */
15711 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/signal_cmd.h linux-3.0.4-vs2.3.1/include/linux/vserver/signal_cmd.h
15712 --- linux-3.0.4/include/linux/vserver/signal_cmd.h      1970-01-01 01:00:00.000000000 +0100
15713 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/signal_cmd.h      2011-06-10 22:11:24.000000000 +0200
15714 @@ -0,0 +1,43 @@
15715 +#ifndef _VX_SIGNAL_CMD_H
15716 +#define _VX_SIGNAL_CMD_H
15717 +
15718 +
15719 +/*  signalling vserver commands */
15720 +
15721 +#define VCMD_ctx_kill          VC_CMD(PROCTRL, 1, 0)
15722 +#define VCMD_wait_exit         VC_CMD(EVENT, 99, 0)
15723 +
15724 +struct vcmd_ctx_kill_v0 {
15725 +       int32_t pid;
15726 +       int32_t sig;
15727 +};
15728 +
15729 +struct vcmd_wait_exit_v0 {
15730 +       int32_t reboot_cmd;
15731 +       int32_t exit_code;
15732 +};
15733 +
15734 +#ifdef __KERNEL__
15735 +
15736 +extern int vc_ctx_kill(struct vx_info *, void __user *);
15737 +extern int vc_wait_exit(struct vx_info *, void __user *);
15738 +
15739 +#endif /* __KERNEL__ */
15740 +
15741 +/*  process alteration commands */
15742 +
15743 +#define VCMD_get_pflags                VC_CMD(PROCALT, 5, 0)
15744 +#define VCMD_set_pflags                VC_CMD(PROCALT, 6, 0)
15745 +
15746 +struct vcmd_pflags_v0 {
15747 +       uint32_t flagword;
15748 +       uint32_t mask;
15749 +};
15750 +
15751 +#ifdef __KERNEL__
15752 +
15753 +extern int vc_get_pflags(uint32_t pid, void __user *);
15754 +extern int vc_set_pflags(uint32_t pid, void __user *);
15755 +
15756 +#endif /* __KERNEL__ */
15757 +#endif /* _VX_SIGNAL_CMD_H */
15758 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/space.h linux-3.0.4-vs2.3.1/include/linux/vserver/space.h
15759 --- linux-3.0.4/include/linux/vserver/space.h   1970-01-01 01:00:00.000000000 +0100
15760 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/space.h   2011-06-10 22:11:24.000000000 +0200
15761 @@ -0,0 +1,12 @@
15762 +#ifndef _VX_SPACE_H
15763 +#define _VX_SPACE_H
15764 +
15765 +#include <linux/types.h>
15766 +
15767 +struct vx_info;
15768 +
15769 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
15770 +
15771 +#else  /* _VX_SPACE_H */
15772 +#warning duplicate inclusion
15773 +#endif /* _VX_SPACE_H */
15774 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/space_cmd.h linux-3.0.4-vs2.3.1/include/linux/vserver/space_cmd.h
15775 --- linux-3.0.4/include/linux/vserver/space_cmd.h       1970-01-01 01:00:00.000000000 +0100
15776 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/space_cmd.h       2011-06-10 22:11:24.000000000 +0200
15777 @@ -0,0 +1,38 @@
15778 +#ifndef _VX_SPACE_CMD_H
15779 +#define _VX_SPACE_CMD_H
15780 +
15781 +
15782 +#define VCMD_enter_space_v0    VC_CMD(PROCALT, 1, 0)
15783 +#define VCMD_enter_space_v1    VC_CMD(PROCALT, 1, 1)
15784 +#define VCMD_enter_space       VC_CMD(PROCALT, 1, 2)
15785 +
15786 +#define VCMD_set_space_v0      VC_CMD(PROCALT, 3, 0)
15787 +#define VCMD_set_space_v1      VC_CMD(PROCALT, 3, 1)
15788 +#define VCMD_set_space         VC_CMD(PROCALT, 3, 2)
15789 +
15790 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
15791 +
15792 +#define VCMD_get_space_mask    VC_CMD(VSPACE, 0, 1)
15793 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
15794 +
15795 +
15796 +struct vcmd_space_mask_v1 {
15797 +       uint64_t mask;
15798 +};
15799 +
15800 +struct vcmd_space_mask_v2 {
15801 +       uint64_t mask;
15802 +       uint32_t index;
15803 +};
15804 +
15805 +
15806 +#ifdef __KERNEL__
15807 +
15808 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
15809 +extern int vc_set_space_v1(struct vx_info *, void __user *);
15810 +extern int vc_enter_space(struct vx_info *, void __user *);
15811 +extern int vc_set_space(struct vx_info *, void __user *);
15812 +extern int vc_get_space_mask(void __user *, int);
15813 +
15814 +#endif /* __KERNEL__ */
15815 +#endif /* _VX_SPACE_CMD_H */
15816 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/switch.h linux-3.0.4-vs2.3.1/include/linux/vserver/switch.h
15817 --- linux-3.0.4/include/linux/vserver/switch.h  1970-01-01 01:00:00.000000000 +0100
15818 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/switch.h  2011-06-10 22:11:24.000000000 +0200
15819 @@ -0,0 +1,98 @@
15820 +#ifndef _VX_SWITCH_H
15821 +#define _VX_SWITCH_H
15822 +
15823 +#include <linux/types.h>
15824 +
15825 +
15826 +#define VC_CATEGORY(c)         (((c) >> 24) & 0x3F)
15827 +#define VC_COMMAND(c)          (((c) >> 16) & 0xFF)
15828 +#define VC_VERSION(c)          ((c) & 0xFFF)
15829 +
15830 +#define VC_CMD(c, i, v)                ((((VC_CAT_ ## c) & 0x3F) << 24) \
15831 +                               | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
15832 +
15833 +/*
15834 +
15835 +  Syscall Matrix V2.8
15836 +
15837 +        |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
15838 +        |STATS  |DESTROY|ALTER  |CHANGE |LIMIT  |TEST   | |       |       |
15839 +        |INFO   |SETUP  |       |MOVE   |       |       | |       |       |
15840 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15841 +  SYSTEM |VERSION|VSETUP |VHOST  |       |       |       | |DEVICE |       |
15842 +  HOST   |     00|     01|     02|     03|     04|     05| |     06|     07|
15843 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15844 +  CPU    |       |VPROC  |PROCALT|PROCMIG|PROCTRL|       | |SCHED. |       |
15845 +  PROCESS|     08|     09|     10|     11|     12|     13| |     14|     15|
15846 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15847 +  MEMORY |       |       |       |       |MEMCTRL|       | |SWAP   |       |
15848 +        |     16|     17|     18|     19|     20|     21| |     22|     23|
15849 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15850 +  NETWORK|       |VNET   |NETALT |NETMIG |NETCTL |       | |SERIAL |       |
15851 +        |     24|     25|     26|     27|     28|     29| |     30|     31|
15852 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15853 +  DISK   |       |       |       |TAGMIG |DLIMIT |       | |INODE  |       |
15854 +  VFS    |     32|     33|     34|     35|     36|     37| |     38|     39|
15855 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15856 +  OTHER  |VSTAT  |       |       |       |       |       | |VINFO  |       |
15857 +        |     40|     41|     42|     43|     44|     45| |     46|     47|
15858 +  =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
15859 +  SPECIAL|EVENT  |       |       |       |FLAGS  |       | |VSPACE |       |
15860 +        |     48|     49|     50|     51|     52|     53| |     54|     55|
15861 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15862 +  SPECIAL|DEBUG  |       |       |       |RLIMIT |SYSCALL| |       |COMPAT |
15863 +        |     56|     57|     58|     59|     60|TEST 61| |     62|     63|
15864 +  -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15865 +
15866 +*/
15867 +
15868 +#define VC_CAT_VERSION         0
15869 +
15870 +#define VC_CAT_VSETUP          1
15871 +#define VC_CAT_VHOST           2
15872 +
15873 +#define VC_CAT_DEVICE          6
15874 +
15875 +#define VC_CAT_VPROC           9
15876 +#define VC_CAT_PROCALT         10
15877 +#define VC_CAT_PROCMIG         11
15878 +#define VC_CAT_PROCTRL         12
15879 +
15880 +#define VC_CAT_SCHED           14
15881 +#define VC_CAT_MEMCTRL         20
15882 +
15883 +#define VC_CAT_VNET            25
15884 +#define VC_CAT_NETALT          26
15885 +#define VC_CAT_NETMIG          27
15886 +#define VC_CAT_NETCTRL         28
15887 +
15888 +#define VC_CAT_TAGMIG          35
15889 +#define VC_CAT_DLIMIT          36
15890 +#define VC_CAT_INODE           38
15891 +
15892 +#define VC_CAT_VSTAT           40
15893 +#define VC_CAT_VINFO           46
15894 +#define VC_CAT_EVENT           48
15895 +
15896 +#define VC_CAT_FLAGS           52
15897 +#define VC_CAT_VSPACE          54
15898 +#define VC_CAT_DEBUG           56
15899 +#define VC_CAT_RLIMIT          60
15900 +
15901 +#define VC_CAT_SYSTEST         61
15902 +#define VC_CAT_COMPAT          63
15903 +
15904 +/*  query version */
15905 +
15906 +#define VCMD_get_version       VC_CMD(VERSION, 0, 0)
15907 +#define VCMD_get_vci           VC_CMD(VERSION, 1, 0)
15908 +
15909 +
15910 +#ifdef __KERNEL__
15911 +
15912 +#include <linux/errno.h>
15913 +
15914 +#endif /* __KERNEL__ */
15915 +
15916 +#endif /* _VX_SWITCH_H */
15917 +
15918 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/tag.h linux-3.0.4-vs2.3.1/include/linux/vserver/tag.h
15919 --- linux-3.0.4/include/linux/vserver/tag.h     1970-01-01 01:00:00.000000000 +0100
15920 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/tag.h     2011-06-10 22:11:24.000000000 +0200
15921 @@ -0,0 +1,143 @@
15922 +#ifndef _DX_TAG_H
15923 +#define _DX_TAG_H
15924 +
15925 +#include <linux/types.h>
15926 +
15927 +
15928 +#define DX_TAG(in)     (IS_TAGGED(in))
15929 +
15930 +
15931 +#ifdef CONFIG_TAG_NFSD
15932 +#define DX_TAG_NFSD    1
15933 +#else
15934 +#define DX_TAG_NFSD    0
15935 +#endif
15936 +
15937 +
15938 +#ifdef CONFIG_TAGGING_NONE
15939 +
15940 +#define MAX_UID                0xFFFFFFFF
15941 +#define MAX_GID                0xFFFFFFFF
15942 +
15943 +#define INOTAG_TAG(cond, uid, gid, tag)        (0)
15944 +
15945 +#define TAGINO_UID(cond, uid, tag)     (uid)
15946 +#define TAGINO_GID(cond, gid, tag)     (gid)
15947 +
15948 +#endif
15949 +
15950 +
15951 +#ifdef CONFIG_TAGGING_GID16
15952 +
15953 +#define MAX_UID                0xFFFFFFFF
15954 +#define MAX_GID                0x0000FFFF
15955 +
15956 +#define INOTAG_TAG(cond, uid, gid, tag)        \
15957 +       ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
15958 +
15959 +#define TAGINO_UID(cond, uid, tag)     (uid)
15960 +#define TAGINO_GID(cond, gid, tag)     \
15961 +       ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
15962 +
15963 +#endif
15964 +
15965 +
15966 +#ifdef CONFIG_TAGGING_ID24
15967 +
15968 +#define MAX_UID                0x00FFFFFF
15969 +#define MAX_GID                0x00FFFFFF
15970 +
15971 +#define INOTAG_TAG(cond, uid, gid, tag)        \
15972 +       ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
15973 +
15974 +#define TAGINO_UID(cond, uid, tag)     \
15975 +       ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
15976 +#define TAGINO_GID(cond, gid, tag)     \
15977 +       ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
15978 +
15979 +#endif
15980 +
15981 +
15982 +#ifdef CONFIG_TAGGING_UID16
15983 +
15984 +#define MAX_UID                0x0000FFFF
15985 +#define MAX_GID                0xFFFFFFFF
15986 +
15987 +#define INOTAG_TAG(cond, uid, gid, tag)        \
15988 +       ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
15989 +
15990 +#define TAGINO_UID(cond, uid, tag)     \
15991 +       ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
15992 +#define TAGINO_GID(cond, gid, tag)     (gid)
15993 +
15994 +#endif
15995 +
15996 +
15997 +#ifdef CONFIG_TAGGING_INTERN
15998 +
15999 +#define MAX_UID                0xFFFFFFFF
16000 +#define MAX_GID                0xFFFFFFFF
16001 +
16002 +#define INOTAG_TAG(cond, uid, gid, tag)        \
16003 +       ((cond) ? (tag) : 0)
16004 +
16005 +#define TAGINO_UID(cond, uid, tag)     (uid)
16006 +#define TAGINO_GID(cond, gid, tag)     (gid)
16007 +
16008 +#endif
16009 +
16010 +
16011 +#ifndef CONFIG_TAGGING_NONE
16012 +#define dx_current_fstag(sb)   \
16013 +       ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
16014 +#else
16015 +#define dx_current_fstag(sb)   (0)
16016 +#endif
16017 +
16018 +#ifndef CONFIG_TAGGING_INTERN
16019 +#define TAGINO_TAG(cond, tag)  (0)
16020 +#else
16021 +#define TAGINO_TAG(cond, tag)  ((cond) ? (tag) : 0)
16022 +#endif
16023 +
16024 +#define INOTAG_UID(cond, uid, gid)     \
16025 +       ((cond) ? ((uid) & MAX_UID) : (uid))
16026 +#define INOTAG_GID(cond, uid, gid)     \
16027 +       ((cond) ? ((gid) & MAX_GID) : (gid))
16028 +
16029 +
16030 +static inline uid_t dx_map_uid(uid_t uid)
16031 +{
16032 +       if ((uid > MAX_UID) && (uid != -1))
16033 +               uid = -2;
16034 +       return (uid & MAX_UID);
16035 +}
16036 +
16037 +static inline gid_t dx_map_gid(gid_t gid)
16038 +{
16039 +       if ((gid > MAX_GID) && (gid != -1))
16040 +               gid = -2;
16041 +       return (gid & MAX_GID);
16042 +}
16043 +
16044 +struct peer_tag {
16045 +       int32_t xid;
16046 +       int32_t nid;
16047 +};
16048 +
16049 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
16050 +
16051 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
16052 +                unsigned long *flags);
16053 +
16054 +#ifdef CONFIG_PROPAGATE
16055 +
16056 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
16057 +
16058 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
16059 +
16060 +#else
16061 +#define dx_propagate_tag(n, i) do { } while (0)
16062 +#endif
16063 +
16064 +#endif /* _DX_TAG_H */
16065 diff -NurpP --minimal linux-3.0.4/include/linux/vserver/tag_cmd.h linux-3.0.4-vs2.3.1/include/linux/vserver/tag_cmd.h
16066 --- linux-3.0.4/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
16067 +++ linux-3.0.4-vs2.3.1/include/linux/vserver/tag_cmd.h 2011-06-10 22:11:24.000000000 +0200
16068 @@ -0,0 +1,22 @@
16069 +#ifndef _VX_TAG_CMD_H
16070 +#define _VX_TAG_CMD_H
16071 +
16072 +
16073 +/* vinfo commands */
16074 +
16075 +#define VCMD_task_tag          VC_CMD(VINFO, 3, 0)
16076 +
16077 +#ifdef __KERNEL__
16078 +extern int vc_task_tag(uint32_t);
16079 +
16080 +#endif /* __KERNEL__ */
16081 +
16082 +/* context commands */
16083 +
16084 +#define VCMD_tag_migrate       VC_CMD(TAGMIG, 1, 0)
16085 +
16086 +#ifdef __KERNEL__
16087 +extern int vc_tag_migrate(uint32_t);
16088 +
16089 +#endif /* __KERNEL__ */
16090 +#endif /* _VX_TAG_CMD_H */
16091 diff -NurpP --minimal linux-3.0.4/include/net/addrconf.h linux-3.0.4-vs2.3.1/include/net/addrconf.h
16092 --- linux-3.0.4/include/net/addrconf.h  2011-07-22 11:18:11.000000000 +0200
16093 +++ linux-3.0.4-vs2.3.1/include/net/addrconf.h  2011-06-10 22:11:24.000000000 +0200
16094 @@ -80,7 +80,8 @@ extern int                    ipv6_dev_get_saddr(struct n
16095                                                struct net_device *dev,
16096                                                const struct in6_addr *daddr,
16097                                                unsigned int srcprefs,
16098 -                                              struct in6_addr *saddr);
16099 +                                              struct in6_addr *saddr,
16100 +                                              struct nx_info *nxi);
16101  extern int                     ipv6_get_lladdr(struct net_device *dev,
16102                                                 struct in6_addr *addr,
16103                                                 unsigned char banned_flags);
16104 diff -NurpP --minimal linux-3.0.4/include/net/af_unix.h linux-3.0.4-vs2.3.1/include/net/af_unix.h
16105 --- linux-3.0.4/include/net/af_unix.h   2011-07-22 11:18:11.000000000 +0200
16106 +++ linux-3.0.4-vs2.3.1/include/net/af_unix.h   2011-06-10 22:11:24.000000000 +0200
16107 @@ -4,6 +4,7 @@
16108  #include <linux/socket.h>
16109  #include <linux/un.h>
16110  #include <linux/mutex.h>
16111 +#include <linux/vs_base.h>
16112  #include <net/sock.h>
16113  
16114  extern void unix_inflight(struct file *fp);
16115 diff -NurpP --minimal linux-3.0.4/include/net/inet_timewait_sock.h linux-3.0.4-vs2.3.1/include/net/inet_timewait_sock.h
16116 --- linux-3.0.4/include/net/inet_timewait_sock.h        2011-03-15 18:07:40.000000000 +0100
16117 +++ linux-3.0.4-vs2.3.1/include/net/inet_timewait_sock.h        2011-06-10 22:11:24.000000000 +0200
16118 @@ -113,6 +113,10 @@ struct inet_timewait_sock {
16119  #define tw_net                 __tw_common.skc_net
16120  #define tw_daddr               __tw_common.skc_daddr
16121  #define tw_rcv_saddr           __tw_common.skc_rcv_saddr
16122 +#define tw_xid                 __tw_common.skc_xid
16123 +#define tw_vx_info             __tw_common.skc_vx_info
16124 +#define tw_nid                 __tw_common.skc_nid
16125 +#define tw_nx_info             __tw_common.skc_nx_info
16126         int                     tw_timeout;
16127         volatile unsigned char  tw_substate;
16128         unsigned char           tw_rcv_wscale;
16129 diff -NurpP --minimal linux-3.0.4/include/net/ip6_route.h linux-3.0.4-vs2.3.1/include/net/ip6_route.h
16130 --- linux-3.0.4/include/net/ip6_route.h 2011-07-22 11:18:11.000000000 +0200
16131 +++ linux-3.0.4-vs2.3.1/include/net/ip6_route.h 2011-06-16 14:16:51.000000000 +0200
16132 @@ -86,7 +86,8 @@ extern int                    ip6_route_get_saddr(struct 
16133                                                     struct rt6_info *rt,
16134                                                     const struct in6_addr *daddr,
16135                                                     unsigned int prefs,
16136 -                                                   struct in6_addr *saddr);
16137 +                                                   struct in6_addr *saddr,
16138 +                                                   struct nx_info *nxi);
16139  
16140  extern struct rt6_info         *rt6_lookup(struct net *net,
16141                                             const struct in6_addr *daddr,
16142 diff -NurpP --minimal linux-3.0.4/include/net/route.h linux-3.0.4-vs2.3.1/include/net/route.h
16143 --- linux-3.0.4/include/net/route.h     2011-07-22 11:18:11.000000000 +0200
16144 +++ linux-3.0.4-vs2.3.1/include/net/route.h     2011-07-27 19:42:59.000000000 +0200
16145 @@ -202,6 +202,9 @@ static inline void ip_rt_put(struct rtab
16146                 dst_release(&rt->dst);
16147  }
16148  
16149 +#include <linux/vs_base.h>
16150 +#include <linux/vs_inet.h>
16151 +
16152  #define IPTOS_RT_MASK  (IPTOS_TOS_MASK & ~3)
16153  
16154  extern const __u8 ip_tos2prio[16];
16155 @@ -253,6 +256,9 @@ static inline void ip_route_connect_init
16156                            protocol, flow_flags, dst, src, dport, sport);
16157  }
16158  
16159 +extern struct rtable *ip_v4_find_src(struct net *net, struct nx_info *,
16160 +       struct flowi4 *);
16161 +
16162  static inline struct rtable *ip_route_connect(struct flowi4 *fl4,
16163                                               __be32 dst, __be32 src, u32 tos,
16164                                               int oif, u8 protocol,
16165 @@ -261,11 +267,25 @@ static inline struct rtable *ip_route_co
16166  {
16167         struct net *net = sock_net(sk);
16168         struct rtable *rt;
16169 +       struct nx_info *nx_info = current_nx_info();
16170  
16171         ip_route_connect_init(fl4, dst, src, tos, oif, protocol,
16172                               sport, dport, sk, can_sleep);
16173  
16174 -       if (!dst || !src) {
16175 +       if (sk)
16176 +               nx_info = sk->sk_nx_info;
16177 +
16178 +       vxdprintk(VXD_CBIT(net, 4),
16179 +               "ip_route_connect(%p) %p,%p;%lx",
16180 +               sk, nx_info, sk->sk_socket,
16181 +               (sk->sk_socket?sk->sk_socket->flags:0));
16182 +
16183 +       rt = ip_v4_find_src(net, nx_info, fl4);
16184 +       if (IS_ERR(rt))
16185 +               return rt;
16186 +       ip_rt_put(rt);
16187 +
16188 +       if (!fl4->daddr || !fl4->saddr) {
16189                 rt = __ip_route_output_key(net, fl4);
16190                 if (IS_ERR(rt))
16191                         return rt;
16192 diff -NurpP --minimal linux-3.0.4/include/net/sock.h linux-3.0.4-vs2.3.1/include/net/sock.h
16193 --- linux-3.0.4/include/net/sock.h      2011-07-22 11:18:12.000000000 +0200
16194 +++ linux-3.0.4-vs2.3.1/include/net/sock.h      2011-07-01 11:35:35.000000000 +0200
16195 @@ -149,6 +149,10 @@ struct sock_common {
16196  #ifdef CONFIG_NET_NS
16197         struct net              *skc_net;
16198  #endif
16199 +       xid_t                   skc_xid;
16200 +       struct vx_info          *skc_vx_info;
16201 +       nid_t                   skc_nid;
16202 +       struct nx_info          *skc_nx_info;
16203         /*
16204          * fields between dontcopy_begin/dontcopy_end
16205          * are not copied in sock_copy()
16206 @@ -256,6 +260,10 @@ struct sock {
16207  #define sk_bind_node           __sk_common.skc_bind_node
16208  #define sk_prot                        __sk_common.skc_prot
16209  #define sk_net                 __sk_common.skc_net
16210 +#define sk_xid                 __sk_common.skc_xid
16211 +#define sk_vx_info             __sk_common.skc_vx_info
16212 +#define sk_nid                 __sk_common.skc_nid
16213 +#define sk_nx_info             __sk_common.skc_nx_info
16214         socket_lock_t           sk_lock;
16215         struct sk_buff_head     sk_receive_queue;
16216         /*
16217 diff -NurpP --minimal linux-3.0.4/init/Kconfig linux-3.0.4-vs2.3.1/init/Kconfig
16218 --- linux-3.0.4/init/Kconfig    2011-07-22 11:18:12.000000000 +0200
16219 +++ linux-3.0.4-vs2.3.1/init/Kconfig    2011-08-08 18:08:57.000000000 +0200
16220 @@ -574,6 +574,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
16221  menuconfig CGROUPS
16222         boolean "Control Group support"
16223         depends on EVENTFD
16224 +       default y
16225         help
16226           This option adds support for grouping sets of processes together, for
16227           use with process control subsystems such as Cpusets, CFS, memory
16228 @@ -790,6 +791,7 @@ config IPC_NS
16229  config USER_NS
16230         bool "User namespace (EXPERIMENTAL)"
16231         depends on EXPERIMENTAL
16232 +       depends on VSERVER_DISABLED
16233         default y
16234         help
16235           This allows containers, i.e. vservers, to use user namespaces
16236 diff -NurpP --minimal linux-3.0.4/init/main.c linux-3.0.4-vs2.3.1/init/main.c
16237 --- linux-3.0.4/init/main.c     2011-07-22 11:18:12.000000000 +0200
16238 +++ linux-3.0.4-vs2.3.1/init/main.c     2011-06-22 12:39:15.000000000 +0200
16239 @@ -68,6 +68,7 @@
16240  #include <linux/shmem_fs.h>
16241  #include <linux/slab.h>
16242  #include <linux/perf_event.h>
16243 +#include <linux/vserver/percpu.h>
16244  
16245  #include <asm/io.h>
16246  #include <asm/bugs.h>
16247 diff -NurpP --minimal linux-3.0.4/ipc/mqueue.c linux-3.0.4-vs2.3.1/ipc/mqueue.c
16248 --- linux-3.0.4/ipc/mqueue.c    2011-03-15 18:07:41.000000000 +0100
16249 +++ linux-3.0.4-vs2.3.1/ipc/mqueue.c    2011-06-10 22:11:24.000000000 +0200
16250 @@ -33,6 +33,8 @@
16251  #include <linux/pid.h>
16252  #include <linux/ipc_namespace.h>
16253  #include <linux/slab.h>
16254 +#include <linux/vs_context.h>
16255 +#include <linux/vs_limit.h>
16256  
16257  #include <net/sock.h>
16258  #include "util.h"
16259 @@ -66,6 +68,7 @@ struct mqueue_inode_info {
16260         struct sigevent notify;
16261         struct pid* notify_owner;
16262         struct user_struct *user;       /* user who created, for accounting */
16263 +       struct vx_info *vxi;
16264         struct sock *notify_sock;
16265         struct sk_buff *notify_cookie;
16266  
16267 @@ -126,6 +129,7 @@ static struct inode *mqueue_get_inode(st
16268         if (S_ISREG(mode)) {
16269                 struct mqueue_inode_info *info;
16270                 struct task_struct *p = current;
16271 +               struct vx_info *vxi = p->vx_info;
16272                 unsigned long mq_bytes, mq_msg_tblsz;
16273  
16274                 inode->i_fop = &mqueue_file_operations;
16275 @@ -139,6 +143,7 @@ static struct inode *mqueue_get_inode(st
16276                 info->notify_owner = NULL;
16277                 info->qsize = 0;
16278                 info->user = NULL;      /* set when all is ok */
16279 +               info->vxi = NULL;
16280                 memset(&info->attr, 0, sizeof(info->attr));
16281                 info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
16282                 info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
16283 @@ -163,17 +163,20 @@ static struct inode *mqueue_get_inode(st
16284  
16285                 spin_lock(&mq_lock);
16286                 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
16287 -                   u->mq_bytes + mq_bytes > task_rlimit(p, RLIMIT_MSGQUEUE)) {
16288 +                   u->mq_bytes + mq_bytes > task_rlimit(p, RLIMIT_MSGQUEUE) ||
16289 +                   !vx_ipcmsg_avail(vxi, mq_bytes)) {
16290                         spin_unlock(&mq_lock);
16291                         /* mqueue_evict_inode() releases info->messages */
16292                         ret = -EMFILE;
16293                         goto out_inode;
16294                 }
16295                 u->mq_bytes += mq_bytes;
16296 +               vx_ipcmsg_add(vxi, u, mq_bytes);
16297                 spin_unlock(&mq_lock);
16298  
16299                 /* all is ok */
16300                 info->user = get_uid(u);
16301 +               info->vxi = get_vx_info(vxi);
16302         } else if (S_ISDIR(mode)) {
16303                 inc_nlink(inode);
16304                 /* Some things misbehave if size == 0 on a directory */
16305 @@ -275,8 +283,11 @@ static void mqueue_evict_inode(struct in
16306             + info->attr.mq_msgsize);
16307         user = info->user;
16308         if (user) {
16309 +               struct vx_info *vxi = info->vxi;
16310 +
16311                 spin_lock(&mq_lock);
16312                 user->mq_bytes -= mq_bytes;
16313 +               vx_ipcmsg_sub(vxi, user, mq_bytes);
16314                 /*
16315                  * get_ns_from_inode() ensures that the
16316                  * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
16317 @@ -286,6 +297,7 @@ static void mqueue_evict_inode(struct in
16318                 if (ipc_ns)
16319                         ipc_ns->mq_queues_count--;
16320                 spin_unlock(&mq_lock);
16321 +               put_vx_info(vxi);
16322                 free_uid(user);
16323         }
16324         if (ipc_ns)
16325 diff -NurpP --minimal linux-3.0.4/ipc/msg.c linux-3.0.4-vs2.3.1/ipc/msg.c
16326 --- linux-3.0.4/ipc/msg.c       2011-05-22 16:17:59.000000000 +0200
16327 +++ linux-3.0.4-vs2.3.1/ipc/msg.c       2011-06-10 22:11:24.000000000 +0200
16328 @@ -37,6 +37,7 @@
16329  #include <linux/rwsem.h>
16330  #include <linux/nsproxy.h>
16331  #include <linux/ipc_namespace.h>
16332 +#include <linux/vs_base.h>
16333  
16334  #include <asm/current.h>
16335  #include <asm/uaccess.h>
16336 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
16337  
16338         msq->q_perm.mode = msgflg & S_IRWXUGO;
16339         msq->q_perm.key = key;
16340 +       msq->q_perm.xid = vx_current_xid();
16341  
16342         msq->q_perm.security = NULL;
16343         retval = security_msg_queue_alloc(msq);
16344 diff -NurpP --minimal linux-3.0.4/ipc/namespace.c linux-3.0.4-vs2.3.1/ipc/namespace.c
16345 --- linux-3.0.4/ipc/namespace.c 2011-07-22 11:18:12.000000000 +0200
16346 +++ linux-3.0.4-vs2.3.1/ipc/namespace.c 2011-06-13 14:09:44.000000000 +0200
16347 @@ -13,11 +13,12 @@
16348  #include <linux/mount.h>
16349  #include <linux/user_namespace.h>
16350  #include <linux/proc_fs.h>
16351 +#include <linux/vs_base.h>
16352 +#include <linux/vserver/global.h>
16353  
16354  #include "util.h"
16355  
16356 -static struct ipc_namespace *create_ipc_ns(struct task_struct *tsk,
16357 -                                          struct ipc_namespace *old_ns)
16358 +static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns)
16359  {
16360         struct ipc_namespace *ns;
16361         int err;
16362 @@ -46,19 +47,18 @@ static struct ipc_namespace *create_ipc_
16363         ipcns_notify(IPCNS_CREATED);
16364         register_ipcns_notifier(ns);
16365  
16366 -       ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
16367 +       ns->user_ns = get_user_ns(user_ns);
16368  
16369         return ns;
16370  }
16371  
16372  struct ipc_namespace *copy_ipcs(unsigned long flags,
16373 -                               struct task_struct *tsk)
16374 +                               struct ipc_namespace *old_ns,
16375 +                               struct user_namespace *user_ns)
16376  {
16377 -       struct ipc_namespace *ns = tsk->nsproxy->ipc_ns;
16378 -
16379         if (!(flags & CLONE_NEWIPC))
16380 -               return get_ipc_ns(ns);
16381 -       return create_ipc_ns(tsk, ns);
16382 +               return get_ipc_ns(old_ns);
16383 +       return create_ipc_ns(user_ns);
16384  }
16385  
16386  /*
16387 diff -NurpP --minimal linux-3.0.4/ipc/sem.c linux-3.0.4-vs2.3.1/ipc/sem.c
16388 --- linux-3.0.4/ipc/sem.c       2011-08-31 18:56:42.000000000 +0200
16389 +++ linux-3.0.4-vs2.3.1/ipc/sem.c       2011-08-08 23:04:47.000000000 +0200
16390 @@ -86,6 +86,8 @@
16391  #include <linux/rwsem.h>
16392  #include <linux/nsproxy.h>
16393  #include <linux/ipc_namespace.h>
16394 +#include <linux/vs_base.h>
16395 +#include <linux/vs_limit.h>
16396  
16397  #include <asm/uaccess.h>
16398  #include "util.h"
16399 @@ -260,6 +262,7 @@ static int newary(struct ipc_namespace *
16400  
16401         sma->sem_perm.mode = (semflg & S_IRWXUGO);
16402         sma->sem_perm.key = key;
16403 +       sma->sem_perm.xid = vx_current_xid();
16404  
16405         sma->sem_perm.security = NULL;
16406         retval = security_sem_alloc(sma);
16407 @@ -275,6 +278,9 @@ static int newary(struct ipc_namespace *
16408                 return id;
16409         }
16410         ns->used_sems += nsems;
16411 +       /* FIXME: obsoleted? */
16412 +       vx_semary_inc(sma);
16413 +       vx_nsems_add(sma, nsems);
16414  
16415         sma->sem_base = (struct sem *) &sma[1];
16416  
16417 @@ -730,6 +736,9 @@ static void freeary(struct ipc_namespace
16418  
16419         wake_up_sem_queue_do(&tasks);
16420         ns->used_sems -= sma->sem_nsems;
16421 +       /* FIXME: obsoleted? */
16422 +       vx_nsems_sub(sma, sma->sem_nsems);
16423 +       vx_semary_dec(sma);
16424         security_sem_free(sma);
16425         ipc_rcu_putref(sma);
16426  }
16427 diff -NurpP --minimal linux-3.0.4/ipc/shm.c linux-3.0.4-vs2.3.1/ipc/shm.c
16428 --- linux-3.0.4/ipc/shm.c       2011-07-22 11:18:12.000000000 +0200
16429 +++ linux-3.0.4-vs2.3.1/ipc/shm.c       2011-06-10 22:11:24.000000000 +0200
16430 @@ -39,6 +39,8 @@
16431  #include <linux/nsproxy.h>
16432  #include <linux/mount.h>
16433  #include <linux/ipc_namespace.h>
16434 +#include <linux/vs_context.h>
16435 +#include <linux/vs_limit.h>
16436  
16437  #include <asm/uaccess.h>
16438  
16439 @@ -173,7 +175,12 @@ static void shm_open(struct vm_area_stru
16440   */
16441  static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
16442  {
16443 -       ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
16444 +       struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
16445 +       int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
16446 +
16447 +       vx_ipcshm_sub(vxi, shp, numpages);
16448 +       ns->shm_tot -= numpages;
16449 +
16450         shm_rmid(ns, shp);
16451         shm_unlock(shp);
16452         if (!is_file_hugepages(shp->shm_file))
16453 @@ -183,6 +190,7 @@ static void shm_destroy(struct ipc_names
16454                                                 shp->mlock_user);
16455         fput (shp->shm_file);
16456         security_shm_free(shp);
16457 +       put_vx_info(vxi);
16458         ipc_rcu_putref(shp);
16459  }
16460  
16461 @@ -355,11 +363,15 @@ static int newseg(struct ipc_namespace *
16462         if (ns->shm_tot + numpages > ns->shm_ctlall)
16463                 return -ENOSPC;
16464  
16465 +       if (!vx_ipcshm_avail(current_vx_info(), numpages))
16466 +               return -ENOSPC;
16467 +
16468         shp = ipc_rcu_alloc(sizeof(*shp));
16469         if (!shp)
16470                 return -ENOMEM;
16471  
16472         shp->shm_perm.key = key;
16473 +       shp->shm_perm.xid = vx_current_xid();
16474         shp->shm_perm.mode = (shmflg & S_IRWXUGO);
16475         shp->mlock_user = NULL;
16476  
16477 @@ -413,6 +425,7 @@ static int newseg(struct ipc_namespace *
16478         ns->shm_tot += numpages;
16479         error = shp->shm_perm.id;
16480         shm_unlock(shp);
16481 +       vx_ipcshm_add(current_vx_info(), key, numpages);
16482         return error;
16483  
16484  no_id:
16485 diff -NurpP --minimal linux-3.0.4/kernel/Makefile linux-3.0.4-vs2.3.1/kernel/Makefile
16486 --- linux-3.0.4/kernel/Makefile 2011-07-22 11:18:12.000000000 +0200
16487 +++ linux-3.0.4-vs2.3.1/kernel/Makefile 2011-06-10 22:11:24.000000000 +0200
16488 @@ -24,6 +24,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
16489  CFLAGS_REMOVE_irq_work.o = -pg
16490  endif
16491  
16492 +obj-y += vserver/
16493  obj-$(CONFIG_FREEZER) += freezer.o
16494  obj-$(CONFIG_PROFILING) += profile.o
16495  obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
16496 diff -NurpP --minimal linux-3.0.4/kernel/capability.c linux-3.0.4-vs2.3.1/kernel/capability.c
16497 --- linux-3.0.4/kernel/capability.c     2011-07-22 11:18:12.000000000 +0200
16498 +++ linux-3.0.4-vs2.3.1/kernel/capability.c     2011-07-19 19:27:53.000000000 +0200
16499 @@ -15,6 +15,7 @@
16500  #include <linux/syscalls.h>
16501  #include <linux/pid_namespace.h>
16502  #include <linux/user_namespace.h>
16503 +#include <linux/vs_context.h>
16504  #include <asm/uaccess.h>
16505  
16506  /*
16507 @@ -116,6 +117,7 @@ static int cap_validate_magic(cap_user_h
16508         return 0;
16509  }
16510  
16511 +
16512  /*
16513   * The only thing that can change the capabilities of the current
16514   * process is the current process. As such, we can't be in this code
16515 @@ -340,6 +342,8 @@ bool has_capability_noaudit(struct task_
16516         return (ret == 0);
16517  }
16518  
16519 +#include <linux/vserver/base.h>
16520 +
16521  /**
16522   * capable - Determine if the current task has a superior capability in effect
16523   * @cap: The capability to be tested for
16524 @@ -374,6 +378,9 @@ bool ns_capable(struct user_namespace *n
16525                 BUG();
16526         }
16527  
16528 +       if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
16529 +               return true;
16530 +
16531         if (security_capable(ns, current_cred(), cap) == 0) {
16532                 current->flags |= PF_SUPERPRIV;
16533                 return true;
16534 diff -NurpP --minimal linux-3.0.4/kernel/compat.c linux-3.0.4-vs2.3.1/kernel/compat.c
16535 --- linux-3.0.4/kernel/compat.c 2011-07-22 11:18:12.000000000 +0200
16536 +++ linux-3.0.4-vs2.3.1/kernel/compat.c 2011-06-10 22:11:24.000000000 +0200
16537 @@ -970,7 +970,7 @@ asmlinkage long compat_sys_stime(compat_
16538         if (err)
16539                 return err;
16540  
16541 -       do_settimeofday(&tv);
16542 +       vx_settimeofday(&tv);
16543         return 0;
16544  }
16545  
16546 diff -NurpP --minimal linux-3.0.4/kernel/cred.c linux-3.0.4-vs2.3.1/kernel/cred.c
16547 --- linux-3.0.4/kernel/cred.c   2011-07-22 11:18:12.000000000 +0200
16548 +++ linux-3.0.4-vs2.3.1/kernel/cred.c   2011-06-10 22:11:24.000000000 +0200
16549 @@ -61,31 +61,6 @@ struct cred init_cred = {
16550  #endif
16551  };
16552  
16553 -static inline void set_cred_subscribers(struct cred *cred, int n)
16554 -{
16555 -#ifdef CONFIG_DEBUG_CREDENTIALS
16556 -       atomic_set(&cred->subscribers, n);
16557 -#endif
16558 -}
16559 -
16560 -static inline int read_cred_subscribers(const struct cred *cred)
16561 -{
16562 -#ifdef CONFIG_DEBUG_CREDENTIALS
16563 -       return atomic_read(&cred->subscribers);
16564 -#else
16565 -       return 0;
16566 -#endif
16567 -}
16568 -
16569 -static inline void alter_cred_subscribers(const struct cred *_cred, int n)
16570 -{
16571 -#ifdef CONFIG_DEBUG_CREDENTIALS
16572 -       struct cred *cred = (struct cred *) _cred;
16573 -
16574 -       atomic_add(n, &cred->subscribers);
16575 -#endif
16576 -}
16577 -
16578  /*
16579   * Dispose of the shared task group credentials
16580   */
16581 @@ -281,21 +256,16 @@ error:
16582   *
16583   * Call commit_creds() or abort_creds() to clean up.
16584   */
16585 -struct cred *prepare_creds(void)
16586 +struct cred *__prepare_creds(const struct cred *old)
16587  {
16588 -       struct task_struct *task = current;
16589 -       const struct cred *old;
16590         struct cred *new;
16591  
16592 -       validate_process_creds();
16593 -
16594         new = kmem_cache_alloc(cred_jar, GFP_KERNEL);
16595         if (!new)
16596                 return NULL;
16597  
16598         kdebug("prepare_creds() alloc %p", new);
16599  
16600 -       old = task->cred;
16601         memcpy(new, old, sizeof(struct cred));
16602  
16603         atomic_set(&new->usage, 1);
16604 @@ -322,6 +292,13 @@ error:
16605         abort_creds(new);
16606         return NULL;
16607  }
16608 +
16609 +struct cred *prepare_creds(void)
16610 +{
16611 +       validate_process_creds();
16612 +
16613 +       return __prepare_creds(current->cred);
16614 +}
16615  EXPORT_SYMBOL(prepare_creds);
16616  
16617  /*
16618 diff -NurpP --minimal linux-3.0.4/kernel/exit.c linux-3.0.4-vs2.3.1/kernel/exit.c
16619 --- linux-3.0.4/kernel/exit.c   2011-07-22 11:18:12.000000000 +0200
16620 +++ linux-3.0.4-vs2.3.1/kernel/exit.c   2011-06-22 12:39:15.000000000 +0200
16621 @@ -48,6 +48,10 @@
16622  #include <linux/fs_struct.h>
16623  #include <linux/init_task.h>
16624  #include <linux/perf_event.h>
16625 +#include <linux/vs_limit.h>
16626 +#include <linux/vs_context.h>
16627 +#include <linux/vs_network.h>
16628 +#include <linux/vs_pid.h>
16629  #include <trace/events/sched.h>
16630  #include <linux/hw_breakpoint.h>
16631  #include <linux/oom.h>
16632 @@ -494,9 +498,11 @@ static void close_files(struct files_str
16633                                         filp_close(file, files);
16634                                         cond_resched();
16635                                 }
16636 +                               vx_openfd_dec(i);
16637                         }
16638                         i++;
16639                         set >>= 1;
16640 +                       cond_resched();
16641                 }
16642         }
16643  }
16644 @@ -1047,11 +1053,16 @@ NORET_TYPE void do_exit(long code)
16645  
16646         validate_creds_for_do_exit(tsk);
16647  
16648 +       /* needs to stay after exit_notify() */
16649 +       exit_vx_info(tsk, code);
16650 +       exit_nx_info(tsk);
16651 +
16652         preempt_disable();
16653         exit_rcu();
16654         /* causes final put_task_struct in finish_task_switch(). */
16655         tsk->state = TASK_DEAD;
16656         schedule();
16657 +       printk("bad task: %p [%lx]\n", current, current->state);
16658         BUG();
16659         /* Avoid "noreturn function does return".  */
16660         for (;;)
16661 diff -NurpP --minimal linux-3.0.4/kernel/fork.c linux-3.0.4-vs2.3.1/kernel/fork.c
16662 --- linux-3.0.4/kernel/fork.c   2011-07-22 11:18:12.000000000 +0200
16663 +++ linux-3.0.4-vs2.3.1/kernel/fork.c   2011-06-10 22:21:02.000000000 +0200
16664 @@ -67,6 +67,10 @@
16665  #include <linux/user-return-notifier.h>
16666  #include <linux/oom.h>
16667  #include <linux/khugepaged.h>
16668 +#include <linux/vs_context.h>
16669 +#include <linux/vs_network.h>
16670 +#include <linux/vs_limit.h>
16671 +#include <linux/vs_memory.h>
16672  
16673  #include <asm/pgtable.h>
16674  #include <asm/pgalloc.h>
16675 @@ -167,6 +171,8 @@ void free_task(struct task_struct *tsk)
16676         account_kernel_stack(tsk->stack, -1);
16677         free_thread_info(tsk->stack);
16678         rt_mutex_debug_task_free(tsk);
16679 +       clr_vx_info(&tsk->vx_info);
16680 +       clr_nx_info(&tsk->nx_info);
16681         ftrace_graph_exit_task(tsk);
16682         free_task_struct(tsk);
16683  }
16684 @@ -505,6 +511,7 @@ static struct mm_struct * mm_init(struct
16685         if (likely(!mm_alloc_pgd(mm))) {
16686                 mm->def_flags = 0;
16687                 mmu_notifier_mm_init(mm);
16688 +               set_vx_info(&mm->mm_vx_info, p->vx_info);
16689                 return mm;
16690         }
16691  
16692 @@ -542,6 +549,7 @@ void __mmdrop(struct mm_struct *mm)
16693  #ifdef CONFIG_TRANSPARENT_HUGEPAGE
16694         VM_BUG_ON(mm->pmd_huge_pte);
16695  #endif
16696 +       clr_vx_info(&mm->mm_vx_info);
16697         free_mm(mm);
16698  }
16699  EXPORT_SYMBOL_GPL(__mmdrop);
16700 @@ -729,6 +737,7 @@ struct mm_struct *dup_mm(struct task_str
16701                 goto fail_nomem;
16702  
16703         memcpy(mm, oldmm, sizeof(*mm));
16704 +       mm->mm_vx_info = NULL;
16705         mm_init_cpumask(mm);
16706  
16707         /* Initializing for Swap token stuff */
16708 @@ -772,6 +781,7 @@ fail_nocontext:
16709          * If init_new_context() failed, we cannot use mmput() to free the mm
16710          * because it calls destroy_context()
16711          */
16712 +       clr_vx_info(&mm->mm_vx_info);
16713         mm_free_pgd(mm);
16714         free_mm(mm);
16715         return NULL;
16716 @@ -1057,6 +1067,8 @@ static struct task_struct *copy_process(
16717         int retval;
16718         struct task_struct *p;
16719         int cgroup_callbacks_done = 0;
16720 +       struct vx_info *vxi;
16721 +       struct nx_info *nxi;
16722  
16723         if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
16724                 return ERR_PTR(-EINVAL);
16725 @@ -1103,7 +1115,12 @@ static struct task_struct *copy_process(
16726         DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
16727         DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
16728  #endif
16729 +       init_vx_info(&p->vx_info, current_vx_info());
16730 +       init_nx_info(&p->nx_info, current_nx_info());
16731 +
16732         retval = -EAGAIN;
16733 +       if (!vx_nproc_avail(1))
16734 +               goto bad_fork_free;
16735         if (atomic_read(&p->real_cred->user->processes) >=
16736                         task_rlimit(p, RLIMIT_NPROC)) {
16737                 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
16738 @@ -1360,6 +1377,18 @@ static struct task_struct *copy_process(
16739  
16740         total_forks++;
16741         spin_unlock(&current->sighand->siglock);
16742 +
16743 +       /* p is copy of current */
16744 +       vxi = p->vx_info;
16745 +       if (vxi) {
16746 +               claim_vx_info(vxi, p);
16747 +               atomic_inc(&vxi->cvirt.nr_threads);
16748 +               atomic_inc(&vxi->cvirt.total_forks);
16749 +               vx_nproc_inc(p);
16750 +       }
16751 +       nxi = p->nx_info;
16752 +       if (nxi)
16753 +               claim_nx_info(nxi, p);
16754         write_unlock_irq(&tasklist_lock);
16755         proc_fork_connector(p);
16756         cgroup_post_fork(p);
16757 diff -NurpP --minimal linux-3.0.4/kernel/kthread.c linux-3.0.4-vs2.3.1/kernel/kthread.c
16758 --- linux-3.0.4/kernel/kthread.c        2011-07-22 11:18:12.000000000 +0200
16759 +++ linux-3.0.4-vs2.3.1/kernel/kthread.c        2011-06-10 22:11:24.000000000 +0200
16760 @@ -16,6 +16,7 @@
16761  #include <linux/mutex.h>
16762  #include <linux/slab.h>
16763  #include <linux/freezer.h>
16764 +#include <linux/vs_pid.h>
16765  #include <trace/events/sched.h>
16766  
16767  static DEFINE_SPINLOCK(kthread_create_lock);
16768 diff -NurpP --minimal linux-3.0.4/kernel/nsproxy.c linux-3.0.4-vs2.3.1/kernel/nsproxy.c
16769 --- linux-3.0.4/kernel/nsproxy.c        2011-07-22 11:18:12.000000000 +0200
16770 +++ linux-3.0.4-vs2.3.1/kernel/nsproxy.c        2011-06-13 14:09:44.000000000 +0200
16771 @@ -20,6 +20,8 @@
16772  #include <linux/mnt_namespace.h>
16773  #include <linux/utsname.h>
16774  #include <linux/pid_namespace.h>
16775 +#include <linux/vserver/global.h>
16776 +#include <linux/vserver/debug.h>
16777  #include <net/net_namespace.h>
16778  #include <linux/ipc_namespace.h>
16779  #include <linux/proc_fs.h>
16780 @@ -46,8 +48,11 @@ static inline struct nsproxy *create_nsp
16781         struct nsproxy *nsproxy;
16782  
16783         nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
16784 -       if (nsproxy)
16785 +       if (nsproxy) {
16786                 atomic_set(&nsproxy->count, 1);
16787 +               atomic_inc(&vs_global_nsproxy);
16788 +       }
16789 +       vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
16790         return nsproxy;
16791  }
16792  
16793 @@ -56,8 +61,11 @@ static inline struct nsproxy *create_nsp
16794   * Return the newly created nsproxy.  Do not attach this to the task,
16795   * leave it to the caller to do proper locking and attach it to task.
16796   */
16797 -static struct nsproxy *create_new_namespaces(unsigned long flags,
16798 -                       struct task_struct *tsk, struct fs_struct *new_fs)
16799 +static struct nsproxy *unshare_namespaces(unsigned long flags,
16800 +                       struct nsproxy *orig,
16801 +                       struct fs_struct *new_fs,
16802 +                       struct user_namespace *new_user,
16803 +                       struct pid_namespace *new_pid)
16804  {
16805         struct nsproxy *new_nsp;
16806         int err;
16807 @@ -66,31 +74,31 @@ static struct nsproxy *create_new_namesp
16808         if (!new_nsp)
16809                 return ERR_PTR(-ENOMEM);
16810  
16811 -       new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
16812 +       new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
16813         if (IS_ERR(new_nsp->mnt_ns)) {
16814                 err = PTR_ERR(new_nsp->mnt_ns);
16815                 goto out_ns;
16816         }
16817  
16818 -       new_nsp->uts_ns = copy_utsname(flags, tsk);
16819 +       new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns, new_user);
16820         if (IS_ERR(new_nsp->uts_ns)) {
16821                 err = PTR_ERR(new_nsp->uts_ns);
16822                 goto out_uts;
16823         }
16824  
16825 -       new_nsp->ipc_ns = copy_ipcs(flags, tsk);
16826 +       new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns, new_user);
16827         if (IS_ERR(new_nsp->ipc_ns)) {
16828                 err = PTR_ERR(new_nsp->ipc_ns);
16829                 goto out_ipc;
16830         }
16831  
16832 -       new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
16833 +       new_nsp->pid_ns = copy_pid_ns(flags, new_pid);
16834         if (IS_ERR(new_nsp->pid_ns)) {
16835                 err = PTR_ERR(new_nsp->pid_ns);
16836                 goto out_pid;
16837         }
16838  
16839 -       new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
16840 +       new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
16841         if (IS_ERR(new_nsp->net_ns)) {
16842                 err = PTR_ERR(new_nsp->net_ns);
16843                 goto out_net;
16844 @@ -115,6 +123,40 @@ out_ns:
16845         return ERR_PTR(err);
16846  }
16847  
16848 +static struct nsproxy *create_new_namespaces(unsigned long flags,
16849 +                       struct task_struct *tsk, struct fs_struct *new_fs)
16850 +{
16851 +       return unshare_namespaces(flags, tsk->nsproxy,
16852 +               new_fs, task_cred_xxx(tsk, user)->user_ns,
16853 +               task_active_pid_ns(tsk));
16854 +}
16855 +
16856 +/*
16857 + * copies the nsproxy, setting refcount to 1, and grabbing a
16858 + * reference to all contained namespaces.
16859 + */
16860 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
16861 +{
16862 +       struct nsproxy *ns = create_nsproxy();
16863 +
16864 +       if (ns) {
16865 +               memcpy(ns, orig, sizeof(struct nsproxy));
16866 +               atomic_set(&ns->count, 1);
16867 +
16868 +               if (ns->mnt_ns)
16869 +                       get_mnt_ns(ns->mnt_ns);
16870 +               if (ns->uts_ns)
16871 +                       get_uts_ns(ns->uts_ns);
16872 +               if (ns->ipc_ns)
16873 +                       get_ipc_ns(ns->ipc_ns);
16874 +               if (ns->pid_ns)
16875 +                       get_pid_ns(ns->pid_ns);
16876 +               if (ns->net_ns)
16877 +                       get_net(ns->net_ns);
16878 +       }
16879 +       return ns;
16880 +}
16881 +
16882  /*
16883   * called from clone.  This now handles copy for nsproxy and all
16884   * namespaces therein.
16885 @@ -122,9 +164,12 @@ out_ns:
16886  int copy_namespaces(unsigned long flags, struct task_struct *tsk)
16887  {
16888         struct nsproxy *old_ns = tsk->nsproxy;
16889 -       struct nsproxy *new_ns;
16890 +       struct nsproxy *new_ns = NULL;
16891         int err = 0;
16892  
16893 +       vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
16894 +               flags, tsk, old_ns);
16895 +
16896         if (!old_ns)
16897                 return 0;
16898  
16899 @@ -134,7 +179,7 @@ int copy_namespaces(unsigned long flags,
16900                                 CLONE_NEWPID | CLONE_NEWNET)))
16901                 return 0;
16902  
16903 -       if (!capable(CAP_SYS_ADMIN)) {
16904 +       if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
16905                 err = -EPERM;
16906                 goto out;
16907         }
16908 @@ -161,6 +206,9 @@ int copy_namespaces(unsigned long flags,
16909  
16910  out:
16911         put_nsproxy(old_ns);
16912 +       vxdprintk(VXD_CBIT(space, 3),
16913 +               "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
16914 +               flags, tsk, old_ns, err, new_ns);
16915         return err;
16916  }
16917  
16918 @@ -174,7 +222,9 @@ void free_nsproxy(struct nsproxy *ns)
16919                 put_ipc_ns(ns->ipc_ns);
16920         if (ns->pid_ns)
16921                 put_pid_ns(ns->pid_ns);
16922 -       put_net(ns->net_ns);
16923 +       if (ns->net_ns)
16924 +               put_net(ns->net_ns);
16925 +       atomic_dec(&vs_global_nsproxy);
16926         kmem_cache_free(nsproxy_cachep, ns);
16927  }
16928  
16929 @@ -187,11 +237,15 @@ int unshare_nsproxy_namespaces(unsigned 
16930  {
16931         int err = 0;
16932  
16933 +       vxdprintk(VXD_CBIT(space, 4),
16934 +               "unshare_nsproxy_namespaces(0x%08lx,[%p])",
16935 +               unshare_flags, current->nsproxy);
16936 +
16937         if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
16938                                CLONE_NEWNET)))
16939                 return 0;
16940  
16941 -       if (!capable(CAP_SYS_ADMIN))
16942 +       if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
16943                 return -EPERM;
16944  
16945         *new_nsp = create_new_namespaces(unshare_flags, current,
16946 diff -NurpP --minimal linux-3.0.4/kernel/pid.c linux-3.0.4-vs2.3.1/kernel/pid.c
16947 --- linux-3.0.4/kernel/pid.c    2011-05-22 16:17:59.000000000 +0200
16948 +++ linux-3.0.4-vs2.3.1/kernel/pid.c    2011-06-10 22:11:24.000000000 +0200
16949 @@ -36,6 +36,7 @@
16950  #include <linux/pid_namespace.h>
16951  #include <linux/init_task.h>
16952  #include <linux/syscalls.h>
16953 +#include <linux/vs_pid.h>
16954  
16955  #define pid_hashfn(nr, ns)     \
16956         hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
16957 @@ -342,7 +343,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
16958  
16959  struct pid *find_vpid(int nr)
16960  {
16961 -       return find_pid_ns(nr, current->nsproxy->pid_ns);
16962 +       return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
16963  }
16964  EXPORT_SYMBOL_GPL(find_vpid);
16965  
16966 @@ -402,6 +403,9 @@ void transfer_pid(struct task_struct *ol
16967  struct task_struct *pid_task(struct pid *pid, enum pid_type type)
16968  {
16969         struct task_struct *result = NULL;
16970 +
16971 +       if (type == PIDTYPE_REALPID)
16972 +               type = PIDTYPE_PID;
16973         if (pid) {
16974                 struct hlist_node *first;
16975                 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]),
16976 @@ -420,7 +424,7 @@ EXPORT_SYMBOL(pid_task);
16977  struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
16978  {
16979         rcu_lockdep_assert(rcu_read_lock_held());
16980 -       return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
16981 +       return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
16982  }
16983  
16984  struct task_struct *find_task_by_vpid(pid_t vnr)
16985 @@ -464,7 +468,7 @@ struct pid *find_get_pid(pid_t nr)
16986  }
16987  EXPORT_SYMBOL_GPL(find_get_pid);
16988  
16989 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
16990 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
16991  {
16992         struct upid *upid;
16993         pid_t nr = 0;
16994 @@ -477,6 +481,11 @@ pid_t pid_nr_ns(struct pid *pid, struct 
16995         return nr;
16996  }
16997  
16998 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
16999 +{
17000 +       return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
17001 +}
17002 +
17003  pid_t pid_vnr(struct pid *pid)
17004  {
17005         return pid_nr_ns(pid, current->nsproxy->pid_ns);
17006 diff -NurpP --minimal linux-3.0.4/kernel/pid_namespace.c linux-3.0.4-vs2.3.1/kernel/pid_namespace.c
17007 --- linux-3.0.4/kernel/pid_namespace.c  2011-05-22 16:17:59.000000000 +0200
17008 +++ linux-3.0.4-vs2.3.1/kernel/pid_namespace.c  2011-06-10 22:17:45.000000000 +0200
17009 @@ -15,6 +15,7 @@
17010  #include <linux/acct.h>
17011  #include <linux/slab.h>
17012  #include <linux/proc_fs.h>
17013 +#include <linux/vserver/global.h>
17014  
17015  #define BITS_PER_PAGE          (PAGE_SIZE*8)
17016  
17017 @@ -88,6 +89,7 @@ static struct pid_namespace *create_pid_
17018                 goto out_free_map;
17019  
17020         kref_init(&ns->kref);
17021 +       atomic_inc(&vs_global_pid_ns);
17022         ns->level = level;
17023         ns->parent = get_pid_ns(parent_pid_ns);
17024  
17025 @@ -119,6 +121,7 @@ static void destroy_pid_namespace(struct
17026  
17027         for (i = 0; i < PIDMAP_ENTRIES; i++)
17028                 kfree(ns->pidmap[i].page);
17029 +       atomic_dec(&vs_global_pid_ns);
17030         kmem_cache_free(pid_ns_cachep, ns);
17031  }
17032  
17033 diff -NurpP --minimal linux-3.0.4/kernel/posix-timers.c linux-3.0.4-vs2.3.1/kernel/posix-timers.c
17034 --- linux-3.0.4/kernel/posix-timers.c   2011-07-22 11:18:12.000000000 +0200
17035 +++ linux-3.0.4-vs2.3.1/kernel/posix-timers.c   2011-06-10 22:11:24.000000000 +0200
17036 @@ -47,6 +47,7 @@
17037  #include <linux/wait.h>
17038  #include <linux/workqueue.h>
17039  #include <linux/module.h>
17040 +#include <linux/vs_context.h>
17041  
17042  /*
17043   * Management arrays for POSIX timers.  Timers are kept in slab memory
17044 @@ -340,6 +341,7 @@ int posix_timer_event(struct k_itimer *t
17045  {
17046         struct task_struct *task;
17047         int shared, ret = -1;
17048 +
17049         /*
17050          * FIXME: if ->sigq is queued we can race with
17051          * dequeue_signal()->do_schedule_next_timer().
17052 @@ -356,10 +358,18 @@ int posix_timer_event(struct k_itimer *t
17053         rcu_read_lock();
17054         task = pid_task(timr->it_pid, PIDTYPE_PID);
17055         if (task) {
17056 +               struct vx_info_save vxis;
17057 +               struct vx_info *vxi;
17058 +
17059 +               vxi = get_vx_info(task->vx_info);
17060 +               enter_vx_info(vxi, &vxis);
17061                 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
17062                 ret = send_sigqueue(timr->sigq, task, shared);
17063 +               leave_vx_info(&vxis);
17064 +               put_vx_info(vxi);
17065         }
17066         rcu_read_unlock();
17067 +
17068         /* If we failed to send the signal the timer stops. */
17069         return ret > 0;
17070  }
17071 diff -NurpP --minimal linux-3.0.4/kernel/printk.c linux-3.0.4-vs2.3.1/kernel/printk.c
17072 --- linux-3.0.4/kernel/printk.c 2011-07-22 11:18:12.000000000 +0200
17073 +++ linux-3.0.4-vs2.3.1/kernel/printk.c 2011-06-10 22:11:24.000000000 +0200
17074 @@ -41,6 +41,7 @@
17075  #include <linux/cpu.h>
17076  #include <linux/notifier.h>
17077  #include <linux/rculist.h>
17078 +#include <linux/vs_cvirt.h>
17079  
17080  #include <asm/uaccess.h>
17081  
17082 @@ -314,7 +315,7 @@ static int check_syslog_permissions(int 
17083                 return 0;
17084  
17085         if (syslog_action_restricted(type)) {
17086 -               if (capable(CAP_SYSLOG))
17087 +               if (vx_capable(CAP_SYSLOG, VXC_SYSLOG))
17088                         return 0;
17089                 /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */
17090                 if (capable(CAP_SYS_ADMIN)) {
17091 @@ -342,12 +343,9 @@ int do_syslog(int type, char __user *buf
17092         if (error)
17093                 return error;
17094  
17095 -       switch (type) {
17096 -       case SYSLOG_ACTION_CLOSE:       /* Close log */
17097 -               break;
17098 -       case SYSLOG_ACTION_OPEN:        /* Open log */
17099 -               break;
17100 -       case SYSLOG_ACTION_READ:        /* Read from log */
17101 +       if ((type == SYSLOG_ACTION_READ) ||
17102 +           (type == SYSLOG_ACTION_READ_ALL) ||
17103 +           (type == SYSLOG_ACTION_READ_CLEAR)) {
17104                 error = -EINVAL;
17105                 if (!buf || len < 0)
17106                         goto out;
17107 @@ -358,6 +356,16 @@ int do_syslog(int type, char __user *buf
17108                         error = -EFAULT;
17109                         goto out;
17110                 }
17111 +       }
17112 +       if (!vx_check(0, VS_ADMIN|VS_WATCH))
17113 +               return vx_do_syslog(type, buf, len);
17114 +
17115 +       switch (type) {
17116 +       case SYSLOG_ACTION_CLOSE:       /* Close log */
17117 +               break;
17118 +       case SYSLOG_ACTION_OPEN:        /* Open log */
17119 +               break;
17120 +       case SYSLOG_ACTION_READ:        /* Read from log */
17121                 error = wait_event_interruptible(log_wait,
17122                                                         (log_start - log_end));
17123                 if (error)
17124 @@ -384,16 +392,6 @@ int do_syslog(int type, char __user *buf
17125                 /* FALL THRU */
17126         /* Read last kernel messages */
17127         case SYSLOG_ACTION_READ_ALL:
17128 -               error = -EINVAL;
17129 -               if (!buf || len < 0)
17130 -                       goto out;
17131 -               error = 0;
17132 -               if (!len)
17133 -                       goto out;
17134 -               if (!access_ok(VERIFY_WRITE, buf, len)) {
17135 -                       error = -EFAULT;
17136 -                       goto out;
17137 -               }
17138                 count = len;
17139                 if (count > log_buf_len)
17140                         count = log_buf_len;
17141 diff -NurpP --minimal linux-3.0.4/kernel/ptrace.c linux-3.0.4-vs2.3.1/kernel/ptrace.c
17142 --- linux-3.0.4/kernel/ptrace.c 2011-07-22 11:18:12.000000000 +0200
17143 +++ linux-3.0.4-vs2.3.1/kernel/ptrace.c 2011-06-10 22:11:24.000000000 +0200
17144 @@ -22,6 +22,7 @@
17145  #include <linux/syscalls.h>
17146  #include <linux/uaccess.h>
17147  #include <linux/regset.h>
17148 +#include <linux/vs_context.h>
17149  #include <linux/hw_breakpoint.h>
17150  
17151  
17152 @@ -169,6 +170,11 @@ ok:
17153                 dumpable = get_dumpable(task->mm);
17154         if (!dumpable && !task_ns_capable(task, CAP_SYS_PTRACE))
17155                 return -EPERM;
17156 +       if (!vx_check(task->xid, VS_ADMIN_P|VS_WATCH_P|VS_IDENT))
17157 +               return -EPERM;
17158 +       if (!vx_check(task->xid, VS_IDENT) &&
17159 +               !task_vx_flags(task, VXF_STATE_ADMIN, 0))
17160 +               return -EACCES;
17161  
17162         return security_ptrace_access_check(task, mode);
17163  }
17164 diff -NurpP --minimal linux-3.0.4/kernel/sched.c linux-3.0.4-vs2.3.1/kernel/sched.c
17165 --- linux-3.0.4/kernel/sched.c  2011-07-22 11:18:12.000000000 +0200
17166 +++ linux-3.0.4-vs2.3.1/kernel/sched.c  2011-07-22 11:20:39.000000000 +0200
17167 @@ -71,6 +71,8 @@
17168  #include <linux/ctype.h>
17169  #include <linux/ftrace.h>
17170  #include <linux/slab.h>
17171 +#include <linux/vs_sched.h>
17172 +#include <linux/vs_cvirt.h>
17173  
17174  #include <asm/tlb.h>
17175  #include <asm/irq_regs.h>
17176 @@ -3461,9 +3463,17 @@ static void calc_global_nohz(unsigned lo
17177   */
17178  void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
17179  {
17180 -       loads[0] = (avenrun[0] + offset) << shift;
17181 -       loads[1] = (avenrun[1] + offset) << shift;
17182 -       loads[2] = (avenrun[2] + offset) << shift;
17183 +       if (vx_flags(VXF_VIRT_LOAD, 0)) {
17184 +               struct vx_info *vxi = current_vx_info();
17185 +
17186 +               loads[0] = (vxi->cvirt.load[0] + offset) << shift;
17187 +               loads[1] = (vxi->cvirt.load[1] + offset) << shift;
17188 +               loads[2] = (vxi->cvirt.load[2] + offset) << shift;
17189 +       } else {
17190 +               loads[0] = (avenrun[0] + offset) << shift;
17191 +               loads[1] = (avenrun[1] + offset) << shift;
17192 +               loads[2] = (avenrun[2] + offset) << shift;
17193 +       }
17194  }
17195  
17196  /*
17197 @@ -3746,16 +3756,19 @@ void account_user_time(struct task_struc
17198                        cputime_t cputime_scaled)
17199  {
17200         struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
17201 +       struct vx_info *vxi = p->vx_info;  /* p is _always_ current */
17202         cputime64_t tmp;
17203 +       int nice = (TASK_NICE(p) > 0);
17204  
17205         /* Add user time to process. */
17206         p->utime = cputime_add(p->utime, cputime);
17207         p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
17208 +       vx_account_user(vxi, cputime, nice);
17209         account_group_user_time(p, cputime);
17210  
17211         /* Add user time to cpustat. */
17212         tmp = cputime_to_cputime64(cputime);
17213 -       if (TASK_NICE(p) > 0)
17214 +       if (nice)
17215                 cpustat->nice = cputime64_add(cpustat->nice, tmp);
17216         else
17217                 cpustat->user = cputime64_add(cpustat->user, tmp);
17218 @@ -3807,10 +3820,12 @@ void __account_system_time(struct task_s
17219                         cputime_t cputime_scaled, cputime64_t *target_cputime64)
17220  {
17221         cputime64_t tmp = cputime_to_cputime64(cputime);
17222 +       struct vx_info *vxi = p->vx_info;  /* p is _always_ current */
17223  
17224         /* Add system time to process. */
17225         p->stime = cputime_add(p->stime, cputime);
17226         p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
17227 +       vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
17228         account_group_system_time(p, cputime);
17229  
17230         /* Add system time to cpustat. */
17231 @@ -4968,7 +4983,7 @@ SYSCALL_DEFINE1(nice, int, increment)
17232                 nice = 19;
17233  
17234         if (increment < 0 && !can_nice(current, nice))
17235 -               return -EPERM;
17236 +               return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
17237  
17238         retval = security_task_setnice(current, nice);
17239         if (retval)
17240 diff -NurpP --minimal linux-3.0.4/kernel/sched_fair.c linux-3.0.4-vs2.3.1/kernel/sched_fair.c
17241 --- linux-3.0.4/kernel/sched_fair.c     2011-07-22 11:18:12.000000000 +0200
17242 +++ linux-3.0.4-vs2.3.1/kernel/sched_fair.c     2011-07-22 11:20:39.000000000 +0200
17243 @@ -998,6 +998,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
17244                 __enqueue_entity(cfs_rq, se);
17245         se->on_rq = 1;
17246  
17247 +       if (entity_is_task(se))
17248 +               vx_activate_task(task_of(se));
17249         if (cfs_rq->nr_running == 1)
17250                 list_add_leaf_cfs_rq(cfs_rq);
17251  }
17252 @@ -1074,6 +1076,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
17253         if (se != cfs_rq->curr)
17254                 __dequeue_entity(cfs_rq, se);
17255         se->on_rq = 0;
17256 +       if (entity_is_task(se))
17257 +               vx_deactivate_task(task_of(se));
17258         update_cfs_load(cfs_rq, 0);
17259         account_entity_dequeue(cfs_rq, se);
17260  
17261 diff -NurpP --minimal linux-3.0.4/kernel/signal.c linux-3.0.4-vs2.3.1/kernel/signal.c
17262 --- linux-3.0.4/kernel/signal.c 2011-07-22 11:18:12.000000000 +0200
17263 +++ linux-3.0.4-vs2.3.1/kernel/signal.c 2011-07-22 11:20:39.000000000 +0200
17264 @@ -28,6 +28,8 @@
17265  #include <linux/freezer.h>
17266  #include <linux/pid_namespace.h>
17267  #include <linux/nsproxy.h>
17268 +#include <linux/vs_context.h>
17269 +#include <linux/vs_pid.h>
17270  #define CREATE_TRACE_POINTS
17271  #include <trace/events/signal.h>
17272  
17273 @@ -744,9 +746,18 @@ static int check_kill_permission(int sig
17274         struct pid *sid;
17275         int error;
17276  
17277 +       vxdprintk(VXD_CBIT(misc, 7),
17278 +               "check_kill_permission(%d,%p,%p[#%u,%u])",
17279 +               sig, info, t, vx_task_xid(t), t->pid);
17280 +
17281         if (!valid_signal(sig))
17282                 return -EINVAL;
17283  
17284 +/*     FIXME: needed? if so, why?
17285 +       if ((info != SEND_SIG_NOINFO) &&
17286 +               (is_si_special(info) || !si_fromuser(info)))
17287 +               goto skip;      */
17288 +
17289         if (!si_fromuser(info))
17290                 return 0;
17291  
17292 @@ -770,6 +781,20 @@ static int check_kill_permission(int sig
17293                 }
17294         }
17295  
17296 +       error = -EPERM;
17297 +       if (t->pid == 1 && current->xid)
17298 +               return error;
17299 +
17300 +       error = -ESRCH;
17301 +       /* FIXME: we shouldn't return ESRCH ever, to avoid
17302 +                 loops, maybe ENOENT or EACCES? */
17303 +       if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
17304 +               vxdprintk(current->xid || VXD_CBIT(misc, 7),
17305 +                       "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
17306 +                       sig, info, t, vx_task_xid(t), t->pid, current->xid);
17307 +               return error;
17308 +       }
17309 +/* skip: */
17310         return security_task_kill(t, info, sig, 0);
17311  }
17312  
17313 @@ -1246,7 +1271,7 @@ int kill_pid_info(int sig, struct siginf
17314         rcu_read_lock();
17315  retry:
17316         p = pid_task(pid, PIDTYPE_PID);
17317 -       if (p) {
17318 +       if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
17319                 error = group_send_sig_info(sig, info, p);
17320                 if (unlikely(error == -ESRCH))
17321                         /*
17322 @@ -1285,7 +1310,7 @@ int kill_pid_info_as_uid(int sig, struct
17323  
17324         rcu_read_lock();
17325         p = pid_task(pid, PIDTYPE_PID);
17326 -       if (!p) {
17327 +       if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
17328                 ret = -ESRCH;
17329                 goto out_unlock;
17330         }
17331 @@ -1340,8 +1365,10 @@ static int kill_something_info(int sig, 
17332                 struct task_struct * p;
17333  
17334                 for_each_process(p) {
17335 -                       if (task_pid_vnr(p) > 1 &&
17336 -                                       !same_thread_group(p, current)) {
17337 +                       if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
17338 +                               task_pid_vnr(p) > 1 &&
17339 +                               !same_thread_group(p, current) &&
17340 +                               !vx_current_initpid(p->pid)) {
17341                                 int err = group_send_sig_info(sig, info, p);
17342                                 ++count;
17343                                 if (err != -EPERM)
17344 @@ -2140,6 +2167,11 @@ relock:
17345                                 !sig_kernel_only(signr))
17346                         continue;
17347  
17348 +               /* virtual init is protected against user signals */
17349 +               if ((info->si_code == SI_USER) &&
17350 +                       vx_current_initpid(current->pid))
17351 +                       continue;
17352 +
17353                 if (sig_kernel_stop(signr)) {
17354                         /*
17355                          * The default action is to stop all threads in
17356 diff -NurpP --minimal linux-3.0.4/kernel/softirq.c linux-3.0.4-vs2.3.1/kernel/softirq.c
17357 --- linux-3.0.4/kernel/softirq.c        2011-07-22 11:18:12.000000000 +0200
17358 +++ linux-3.0.4-vs2.3.1/kernel/softirq.c        2011-07-22 11:20:39.000000000 +0200
17359 @@ -24,6 +24,7 @@
17360  #include <linux/ftrace.h>
17361  #include <linux/smp.h>
17362  #include <linux/tick.h>
17363 +#include <linux/vs_context.h>
17364  
17365  #define CREATE_TRACE_POINTS
17366  #include <trace/events/irq.h>
17367 diff -NurpP --minimal linux-3.0.4/kernel/sys.c linux-3.0.4-vs2.3.1/kernel/sys.c
17368 --- linux-3.0.4/kernel/sys.c    2011-08-31 18:56:42.000000000 +0200
17369 +++ linux-3.0.4-vs2.3.1/kernel/sys.c    2011-08-31 19:37:44.000000000 +0200
17370 @@ -45,6 +45,7 @@
17371  #include <linux/syscalls.h>
17372  #include <linux/kprobes.h>
17373  #include <linux/user_namespace.h>
17374 +#include <linux/vs_pid.h>
17375  
17376  #include <linux/kmsg_dump.h>
17377  /* Move somewhere else to avoid recompiling? */
17378 @@ -155,7 +156,10 @@ static int set_one_prio(struct task_stru
17379                 goto out;
17380         }
17381         if (niceval < task_nice(p) && !can_nice(p, niceval)) {
17382 -               error = -EACCES;
17383 +               if (vx_flags(VXF_IGNEG_NICE, 0))
17384 +                       error = 0;
17385 +               else
17386 +                       error = -EACCES;
17387                 goto out;
17388         }
17389         no_nice = security_task_setnice(p, niceval);
17390 @@ -205,6 +209,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
17391                         else
17392                                 pgrp = task_pgrp(current);
17393                         do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17394 +                               if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17395 +                                       continue;
17396                                 error = set_one_prio(p, niceval, error);
17397                         } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
17398                         break;
17399 @@ -268,6 +274,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
17400                         else
17401                                 pgrp = task_pgrp(current);
17402                         do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17403 +                               if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17404 +                                       continue;
17405                                 niceval = 20 - task_nice(p);
17406                                 if (niceval > retval)
17407                                         retval = niceval;
17408 @@ -387,6 +395,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
17409  
17410  static DEFINE_MUTEX(reboot_mutex);
17411  
17412 +long vs_reboot(unsigned int, void __user *);
17413 +
17414  /*
17415   * Reboot system call: for obvious reasons only root may call it,
17416   * and even root needs to set up some magic numbers in the registers
17417 @@ -419,6 +429,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
17418         if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
17419                 cmd = LINUX_REBOOT_CMD_HALT;
17420  
17421 +       if (!vx_check(0, VS_ADMIN|VS_WATCH))
17422 +               return vs_reboot(cmd, arg);
17423 +
17424         mutex_lock(&reboot_mutex);
17425         switch (cmd) {
17426         case LINUX_REBOOT_CMD_RESTART:
17427 @@ -1235,7 +1248,8 @@ SYSCALL_DEFINE2(sethostname, char __user
17428         int errno;
17429         char tmp[__NEW_UTS_LEN];
17430  
17431 -       if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
17432 +       if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
17433 +               CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17434                 return -EPERM;
17435  
17436         if (len < 0 || len > __NEW_UTS_LEN)
17437 @@ -1285,7 +1299,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
17438         int errno;
17439         char tmp[__NEW_UTS_LEN];
17440  
17441 -       if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
17442 +       if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
17443 +               CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17444                 return -EPERM;
17445         if (len < 0 || len > __NEW_UTS_LEN)
17446                 return -EINVAL;
17447 @@ -1403,7 +1418,7 @@ int do_prlimit(struct task_struct *tsk, 
17448                 /* Keep the capable check against init_user_ns until
17449                    cgroups can contain all limits */
17450                 if (new_rlim->rlim_max > rlim->rlim_max &&
17451 -                               !capable(CAP_SYS_RESOURCE))
17452 +                       !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
17453                         retval = -EPERM;
17454                 if (!retval)
17455                         retval = security_task_setrlimit(tsk->group_leader,
17456 @@ -1457,7 +1472,8 @@ static int check_prlimit_permission(stru
17457              cred->gid == tcred->sgid &&
17458              cred->gid == tcred->gid))
17459                 return 0;
17460 -       if (ns_capable(tcred->user->user_ns, CAP_SYS_RESOURCE))
17461 +       if (vx_ns_capable(tcred->user->user_ns,
17462 +               CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
17463                 return 0;
17464  
17465         return -EPERM;
17466 diff -NurpP --minimal linux-3.0.4/kernel/sysctl.c linux-3.0.4-vs2.3.1/kernel/sysctl.c
17467 --- linux-3.0.4/kernel/sysctl.c 2011-07-22 11:18:12.000000000 +0200
17468 +++ linux-3.0.4-vs2.3.1/kernel/sysctl.c 2011-06-15 02:40:14.000000000 +0200
17469 @@ -75,6 +75,7 @@
17470  #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
17471  #include <linux/lockdep.h>
17472  #endif
17473 +extern char vshelper_path[];
17474  #ifdef CONFIG_CHR_DEV_SG
17475  #include <scsi/sg.h>
17476  #endif
17477 @@ -568,6 +569,13 @@ static struct ctl_table kern_table[] = {
17478                 .proc_handler   = proc_dostring,
17479         },
17480  #endif
17481 +       {
17482 +               .procname       = "vshelper",
17483 +               .data           = &vshelper_path,
17484 +               .maxlen         = 256,
17485 +               .mode           = 0644,
17486 +               .proc_handler   = &proc_dostring,
17487 +       },
17488  #ifdef CONFIG_CHR_DEV_SG
17489         {
17490                 .procname       = "sg-big-buff",
17491 diff -NurpP --minimal linux-3.0.4/kernel/sysctl_binary.c linux-3.0.4-vs2.3.1/kernel/sysctl_binary.c
17492 --- linux-3.0.4/kernel/sysctl_binary.c  2011-05-22 16:17:59.000000000 +0200
17493 +++ linux-3.0.4-vs2.3.1/kernel/sysctl_binary.c  2011-06-10 22:11:24.000000000 +0200
17494 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
17495  
17496         { CTL_INT,      KERN_PANIC,                     "panic" },
17497         { CTL_INT,      KERN_REALROOTDEV,               "real-root-dev" },
17498 +       { CTL_STR,      KERN_VSHELPER,                  "vshelper" },
17499  
17500         { CTL_STR,      KERN_SPARC_REBOOT,              "reboot-cmd" },
17501         { CTL_INT,      KERN_CTLALTDEL,                 "ctrl-alt-del" },
17502 diff -NurpP --minimal linux-3.0.4/kernel/time/timekeeping.c linux-3.0.4-vs2.3.1/kernel/time/timekeeping.c
17503 --- linux-3.0.4/kernel/time/timekeeping.c       2011-07-22 11:18:12.000000000 +0200
17504 +++ linux-3.0.4-vs2.3.1/kernel/time/timekeeping.c       2011-06-10 22:11:24.000000000 +0200
17505 @@ -233,6 +233,7 @@ void getnstimeofday(struct timespec *ts)
17506         } while (read_seqretry(&xtime_lock, seq));
17507  
17508         timespec_add_ns(ts, nsecs);
17509 +       vx_adjust_timespec(ts);
17510  }
17511  
17512  EXPORT_SYMBOL(getnstimeofday);
17513 diff -NurpP --minimal linux-3.0.4/kernel/time.c linux-3.0.4-vs2.3.1/kernel/time.c
17514 --- linux-3.0.4/kernel/time.c   2011-05-22 16:17:59.000000000 +0200
17515 +++ linux-3.0.4-vs2.3.1/kernel/time.c   2011-06-10 22:11:24.000000000 +0200
17516 @@ -92,7 +92,7 @@ SYSCALL_DEFINE1(stime, time_t __user *, 
17517         if (err)
17518                 return err;
17519  
17520 -       do_settimeofday(&tv);
17521 +       vx_settimeofday(&tv);
17522         return 0;
17523  }
17524  
17525 @@ -177,7 +177,7 @@ int do_sys_settimeofday(const struct tim
17526                 /* SMP safe, again the code in arch/foo/time.c should
17527                  * globally block out interrupts when it runs.
17528                  */
17529 -               return do_settimeofday(tv);
17530 +               return vx_settimeofday(tv);
17531         }
17532         return 0;
17533  }
17534 diff -NurpP --minimal linux-3.0.4/kernel/timer.c linux-3.0.4-vs2.3.1/kernel/timer.c
17535 --- linux-3.0.4/kernel/timer.c  2011-07-22 11:18:12.000000000 +0200
17536 +++ linux-3.0.4-vs2.3.1/kernel/timer.c  2011-06-15 02:40:14.000000000 +0200
17537 @@ -40,6 +40,10 @@
17538  #include <linux/irq_work.h>
17539  #include <linux/sched.h>
17540  #include <linux/slab.h>
17541 +#include <linux/vs_base.h>
17542 +#include <linux/vs_cvirt.h>
17543 +#include <linux/vs_pid.h>
17544 +#include <linux/vserver/sched.h>
17545  
17546  #include <asm/uaccess.h>
17547  #include <asm/unistd.h>
17548 @@ -1336,12 +1340,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
17549  
17550  #endif
17551  
17552 -#ifndef __alpha__
17553 -
17554 -/*
17555 - * The Alpha uses getxpid, getxuid, and getxgid instead.  Maybe this
17556 - * should be moved into arch/i386 instead?
17557 - */
17558  
17559  /**
17560   * sys_getpid - return the thread group id of the current process
17561 @@ -1370,10 +1368,23 @@ SYSCALL_DEFINE0(getppid)
17562         rcu_read_lock();
17563         pid = task_tgid_vnr(current->real_parent);
17564         rcu_read_unlock();
17565 +       return vx_map_pid(pid);
17566 +}
17567  
17568 -       return pid;
17569 +#ifdef __alpha__
17570 +
17571 +/*
17572 + * The Alpha uses getxpid, getxuid, and getxgid instead.
17573 + */
17574 +
17575 +asmlinkage long do_getxpid(long *ppid)
17576 +{
17577 +       *ppid = sys_getppid();
17578 +       return sys_getpid();
17579  }
17580  
17581 +#else /* _alpha_ */
17582 +
17583  SYSCALL_DEFINE0(getuid)
17584  {
17585         /* Only we change this so SMP safe */
17586 diff -NurpP --minimal linux-3.0.4/kernel/user_namespace.c linux-3.0.4-vs2.3.1/kernel/user_namespace.c
17587 --- linux-3.0.4/kernel/user_namespace.c 2011-03-15 18:07:42.000000000 +0100
17588 +++ linux-3.0.4-vs2.3.1/kernel/user_namespace.c 2011-06-10 22:11:24.000000000 +0200
17589 @@ -11,6 +11,7 @@
17590  #include <linux/user_namespace.h>
17591  #include <linux/highuid.h>
17592  #include <linux/cred.h>
17593 +#include <linux/vserver/global.h>
17594  
17595  static struct kmem_cache *user_ns_cachep __read_mostly;
17596  
17597 @@ -33,6 +34,7 @@ int create_user_ns(struct cred *new)
17598                 return -ENOMEM;
17599  
17600         kref_init(&ns->kref);
17601 +       atomic_inc(&vs_global_user_ns);
17602  
17603         for (n = 0; n < UIDHASH_SZ; ++n)
17604                 INIT_HLIST_HEAD(ns->uidhash_table + n);
17605 @@ -81,6 +83,8 @@ void free_user_ns(struct kref *kref)
17606         struct user_namespace *ns =
17607                 container_of(kref, struct user_namespace, kref);
17608  
17609 +       /* FIXME: maybe move into destroyer? */
17610 +       atomic_dec(&vs_global_user_ns);
17611         INIT_WORK(&ns->destroyer, free_user_ns_work);
17612         schedule_work(&ns->destroyer);
17613  }
17614 diff -NurpP --minimal linux-3.0.4/kernel/utsname.c linux-3.0.4-vs2.3.1/kernel/utsname.c
17615 --- linux-3.0.4/kernel/utsname.c        2011-07-22 11:18:12.000000000 +0200
17616 +++ linux-3.0.4-vs2.3.1/kernel/utsname.c        2011-06-13 14:09:44.000000000 +0200
17617 @@ -16,14 +16,17 @@
17618  #include <linux/slab.h>
17619  #include <linux/user_namespace.h>
17620  #include <linux/proc_fs.h>
17621 +#include <linux/vserver/global.h>
17622  
17623  static struct uts_namespace *create_uts_ns(void)
17624  {
17625         struct uts_namespace *uts_ns;
17626  
17627         uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
17628 -       if (uts_ns)
17629 +       if (uts_ns) {
17630                 kref_init(&uts_ns->kref);
17631 +               atomic_inc(&vs_global_uts_ns);
17632 +       }
17633         return uts_ns;
17634  }
17635  
17636 @@ -32,8 +35,8 @@ static struct uts_namespace *create_uts_
17637   * @old_ns: namespace to clone
17638   * Return NULL on error (failure to kmalloc), new ns otherwise
17639   */
17640 -static struct uts_namespace *clone_uts_ns(struct task_struct *tsk,
17641 -                                         struct uts_namespace *old_ns)
17642 +static struct uts_namespace *clone_uts_ns(struct uts_namespace *old_ns,
17643 +                                         struct user_namespace *old_user)
17644  {
17645         struct uts_namespace *ns;
17646  
17647 @@ -43,7 +46,7 @@ static struct uts_namespace *clone_uts_n
17648  
17649         down_read(&uts_sem);
17650         memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
17651 -       ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
17652 +       ns->user_ns = get_user_ns(old_user);
17653         up_read(&uts_sem);
17654         return ns;
17655  }
17656 @@ -55,9 +58,9 @@ static struct uts_namespace *clone_uts_n
17657   * versa.
17658   */
17659  struct uts_namespace *copy_utsname(unsigned long flags,
17660 -                                  struct task_struct *tsk)
17661 +                                  struct uts_namespace *old_ns,
17662 +                                  struct user_namespace *user_ns)
17663  {
17664 -       struct uts_namespace *old_ns = tsk->nsproxy->uts_ns;
17665         struct uts_namespace *new_ns;
17666  
17667         BUG_ON(!old_ns);
17668 @@ -66,7 +69,7 @@ struct uts_namespace *copy_utsname(unsig
17669         if (!(flags & CLONE_NEWUTS))
17670                 return old_ns;
17671  
17672 -       new_ns = clone_uts_ns(tsk, old_ns);
17673 +       new_ns = clone_uts_ns(old_ns, user_ns);
17674  
17675         put_uts_ns(old_ns);
17676         return new_ns;
17677 @@ -78,6 +81,7 @@ void free_uts_ns(struct kref *kref)
17678  
17679         ns = container_of(kref, struct uts_namespace, kref);
17680         put_user_ns(ns->user_ns);
17681 +       atomic_dec(&vs_global_uts_ns);
17682         kfree(ns);
17683  }
17684  
17685 diff -NurpP --minimal linux-3.0.4/kernel/vserver/Kconfig linux-3.0.4-vs2.3.1/kernel/vserver/Kconfig
17686 --- linux-3.0.4/kernel/vserver/Kconfig  1970-01-01 01:00:00.000000000 +0100
17687 +++ linux-3.0.4-vs2.3.1/kernel/vserver/Kconfig  2011-08-08 18:06:22.000000000 +0200
17688 @@ -0,0 +1,232 @@
17689 +#
17690 +# Linux VServer configuration
17691 +#
17692 +
17693 +menu "Linux VServer"
17694 +
17695 +config VSERVER_AUTO_LBACK
17696 +       bool    "Automatically Assign Loopback IP"
17697 +       default y
17698 +       help
17699 +         Automatically assign a guest specific loopback
17700 +         IP and add it to the kernel network stack on
17701 +         startup.
17702 +
17703 +config VSERVER_AUTO_SINGLE
17704 +       bool    "Automatic Single IP Special Casing"
17705 +       depends on EXPERIMENTAL
17706 +       default y
17707 +       help
17708 +         This allows network contexts with a single IP to
17709 +         automatically remap 0.0.0.0 bindings to that IP,
17710 +         avoiding further network checks and improving
17711 +         performance.
17712 +
17713 +         (note: such guests do not allow to change the ip
17714 +          on the fly and do not show loopback addresses)
17715 +
17716 +config VSERVER_COWBL
17717 +       bool    "Enable COW Immutable Link Breaking"
17718 +       default y
17719 +       help
17720 +         This enables the COW (Copy-On-Write) link break code.
17721 +         It allows you to treat unified files like normal files
17722 +         when writing to them (which will implicitely break the
17723 +         link and create a copy of the unified file)
17724 +
17725 +config VSERVER_VTIME
17726 +       bool    "Enable Virtualized Guest Time"
17727 +       depends on EXPERIMENTAL
17728 +       default n
17729 +       help
17730 +         This enables per guest time offsets to allow for
17731 +         adjusting the system clock individually per guest.
17732 +         this adds some overhead to the time functions and
17733 +         therefore should not be enabled without good reason.
17734 +
17735 +config VSERVER_DEVICE
17736 +       bool    "Enable Guest Device Mapping"
17737 +       depends on EXPERIMENTAL
17738 +       default n
17739 +       help
17740 +         This enables generic device remapping.
17741 +
17742 +config VSERVER_PROC_SECURE
17743 +       bool    "Enable Proc Security"
17744 +       depends on PROC_FS
17745 +       default y
17746 +       help
17747 +         This configures ProcFS security to initially hide
17748 +         non-process entries for all contexts except the main and
17749 +         spectator context (i.e. for all guests), which is a secure
17750 +         default.
17751 +
17752 +         (note: on 1.2x the entries were visible by default)
17753 +
17754 +choice
17755 +       prompt  "Persistent Inode Tagging"
17756 +       default TAGGING_ID24
17757 +       help
17758 +         This adds persistent context information to filesystems
17759 +         mounted with the tagxid option. Tagging is a requirement
17760 +         for per-context disk limits and per-context quota.
17761 +
17762 +
17763 +config TAGGING_NONE
17764 +       bool    "Disabled"
17765 +       help
17766 +         do not store per-context information in inodes.
17767 +
17768 +config TAGGING_UID16
17769 +       bool    "UID16/GID32"
17770 +       help
17771 +         reduces UID to 16 bit, but leaves GID at 32 bit.
17772 +
17773 +config TAGGING_GID16
17774 +       bool    "UID32/GID16"
17775 +       help
17776 +         reduces GID to 16 bit, but leaves UID at 32 bit.
17777 +
17778 +config TAGGING_ID24
17779 +       bool    "UID24/GID24"
17780 +       help
17781 +         uses the upper 8bit from UID and GID for XID tagging
17782 +         which leaves 24bit for UID/GID each, which should be
17783 +         more than sufficient for normal use.
17784 +
17785 +config TAGGING_INTERN
17786 +       bool    "UID32/GID32"
17787 +       help
17788 +         this uses otherwise reserved inode fields in the on
17789 +         disk representation, which limits the use to a few
17790 +         filesystems (currently ext2 and ext3)
17791 +
17792 +endchoice
17793 +
17794 +config TAG_NFSD
17795 +       bool    "Tag NFSD User Auth and Files"
17796 +       default n
17797 +       help
17798 +         Enable this if you do want the in-kernel NFS
17799 +         Server to use the tagging specified above.
17800 +         (will require patched clients too)
17801 +
17802 +config VSERVER_PRIVACY
17803 +       bool    "Honor Privacy Aspects of Guests"
17804 +       default n
17805 +       help
17806 +         When enabled, most context checks will disallow
17807 +         access to structures assigned to a specific context,
17808 +         like ptys or loop devices.
17809 +
17810 +config VSERVER_CONTEXTS
17811 +       int     "Maximum number of Contexts (1-65533)"  if EMBEDDED
17812 +       range 1 65533
17813 +       default "768"   if 64BIT
17814 +       default "256"
17815 +       help
17816 +         This setting will optimize certain data structures
17817 +         and memory allocations according to the expected
17818 +         maximum.
17819 +
17820 +         note: this is not a strict upper limit.
17821 +
17822 +config VSERVER_WARN
17823 +       bool    "VServer Warnings"
17824 +       default y
17825 +       help
17826 +         This enables various runtime warnings, which will
17827 +         notify about potential manipulation attempts or
17828 +         resource shortage. It is generally considered to
17829 +         be a good idea to have that enabled.
17830 +
17831 +config VSERVER_WARN_DEVPTS
17832 +       bool    "VServer DevPTS Warnings"
17833 +       depends on VSERVER_WARN
17834 +       default y
17835 +       help
17836 +         This enables DevPTS related warnings, issued when a
17837 +         process inside a context tries to lookup or access
17838 +         a dynamic pts from the host or a different context.
17839 +
17840 +config VSERVER_DEBUG
17841 +       bool    "VServer Debugging Code"
17842 +       default n
17843 +       help
17844 +         Set this to yes if you want to be able to activate
17845 +         debugging output at runtime. It adds a very small
17846 +         overhead to all vserver related functions and
17847 +         increases the kernel size by about 20k.
17848 +
17849 +config VSERVER_HISTORY
17850 +       bool    "VServer History Tracing"
17851 +       depends on VSERVER_DEBUG
17852 +       default n
17853 +       help
17854 +         Set this to yes if you want to record the history of
17855 +         linux-vserver activities, so they can be replayed in
17856 +         the event of a kernel panic or oops.
17857 +
17858 +config VSERVER_HISTORY_SIZE
17859 +       int     "Per-CPU History Size (32-65536)"
17860 +       depends on VSERVER_HISTORY
17861 +       range 32 65536
17862 +       default 64
17863 +       help
17864 +         This allows you to specify the number of entries in
17865 +         the per-CPU history buffer.
17866 +
17867 +config VSERVER_LEGACY_MEM
17868 +       bool    "Legacy Memory Limits"
17869 +       default n
17870 +       help
17871 +         This provides fake memory limits to keep
17872 +         older tools happy in the face of memory
17873 +         cgroups
17874 +
17875 +choice
17876 +       prompt  "Quotes used in debug and warn messages"
17877 +       default QUOTES_ISO8859
17878 +
17879 +config QUOTES_ISO8859
17880 +       bool    "Extended ASCII (ISO 8859) angle quotes"
17881 +       help
17882 +         This uses the extended ASCII characters \xbb
17883 +         and \xab for quoting file and process names.
17884 +
17885 +config QUOTES_UTF8
17886 +       bool    "UTF-8 angle quotes"
17887 +       help
17888 +         This uses the the UTF-8 sequences for angle
17889 +         quotes to quote file and process names.
17890 +
17891 +config QUOTES_ASCII
17892 +       bool    "ASCII single quotes"
17893 +       help
17894 +         This uses the ASCII single quote character
17895 +         (\x27) to quote file and process names.
17896 +
17897 +endchoice
17898 +
17899 +endmenu
17900 +
17901 +
17902 +config VSERVER
17903 +       bool
17904 +       default y
17905 +       select NAMESPACES
17906 +       select UTS_NS
17907 +       select IPC_NS
17908 +#      select USER_NS
17909 +       select SYSVIPC
17910 +
17911 +config VSERVER_SECURITY
17912 +       bool
17913 +       depends on SECURITY
17914 +       default y
17915 +       select SECURITY_CAPABILITIES
17916 +
17917 +config VSERVER_DISABLED
17918 +       bool
17919 +       default n
17920 +
17921 diff -NurpP --minimal linux-3.0.4/kernel/vserver/Makefile linux-3.0.4-vs2.3.1/kernel/vserver/Makefile
17922 --- linux-3.0.4/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
17923 +++ linux-3.0.4-vs2.3.1/kernel/vserver/Makefile 2011-06-10 22:11:24.000000000 +0200
17924 @@ -0,0 +1,18 @@
17925 +#
17926 +# Makefile for the Linux vserver routines.
17927 +#
17928 +
17929 +
17930 +obj-y          += vserver.o
17931 +
17932 +vserver-y      := switch.o context.o space.o sched.o network.o inode.o \
17933 +                  limit.o cvirt.o cacct.o signal.o helper.o init.o \
17934 +                  dlimit.o tag.o
17935 +
17936 +vserver-$(CONFIG_INET) += inet.o
17937 +vserver-$(CONFIG_PROC_FS) += proc.o
17938 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
17939 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
17940 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
17941 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
17942 +
17943 diff -NurpP --minimal linux-3.0.4/kernel/vserver/cacct.c linux-3.0.4-vs2.3.1/kernel/vserver/cacct.c
17944 --- linux-3.0.4/kernel/vserver/cacct.c  1970-01-01 01:00:00.000000000 +0100
17945 +++ linux-3.0.4-vs2.3.1/kernel/vserver/cacct.c  2011-06-10 22:11:24.000000000 +0200
17946 @@ -0,0 +1,42 @@
17947 +/*
17948 + *  linux/kernel/vserver/cacct.c
17949 + *
17950 + *  Virtual Server: Context Accounting
17951 + *
17952 + *  Copyright (C) 2006-2007 Herbert Pötzl
17953 + *
17954 + *  V0.01  added accounting stats
17955 + *
17956 + */
17957 +
17958 +#include <linux/types.h>
17959 +#include <linux/vs_context.h>
17960 +#include <linux/vserver/cacct_cmd.h>
17961 +#include <linux/vserver/cacct_int.h>
17962 +
17963 +#include <asm/errno.h>
17964 +#include <asm/uaccess.h>
17965 +
17966 +
17967 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
17968 +{
17969 +       struct vcmd_sock_stat_v0 vc_data;
17970 +       int j, field;
17971 +
17972 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17973 +               return -EFAULT;
17974 +
17975 +       field = vc_data.field;
17976 +       if ((field < 0) || (field >= VXA_SOCK_SIZE))
17977 +               return -EINVAL;
17978 +
17979 +       for (j = 0; j < 3; j++) {
17980 +               vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
17981 +               vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
17982 +       }
17983 +
17984 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17985 +               return -EFAULT;
17986 +       return 0;
17987 +}
17988 +
17989 diff -NurpP --minimal linux-3.0.4/kernel/vserver/cacct_init.h linux-3.0.4-vs2.3.1/kernel/vserver/cacct_init.h
17990 --- linux-3.0.4/kernel/vserver/cacct_init.h     1970-01-01 01:00:00.000000000 +0100
17991 +++ linux-3.0.4-vs2.3.1/kernel/vserver/cacct_init.h     2011-06-10 22:11:24.000000000 +0200
17992 @@ -0,0 +1,25 @@
17993 +
17994 +
17995 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
17996 +{
17997 +       int i, j;
17998 +
17999 +
18000 +       for (i = 0; i < VXA_SOCK_SIZE; i++) {
18001 +               for (j = 0; j < 3; j++) {
18002 +                       atomic_long_set(&cacct->sock[i][j].count, 0);
18003 +                       atomic_long_set(&cacct->sock[i][j].total, 0);
18004 +               }
18005 +       }
18006 +       for (i = 0; i < 8; i++)
18007 +               atomic_set(&cacct->slab[i], 0);
18008 +       for (i = 0; i < 5; i++)
18009 +               for (j = 0; j < 4; j++)
18010 +                       atomic_set(&cacct->page[i][j], 0);
18011 +}
18012 +
18013 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
18014 +{
18015 +       return;
18016 +}
18017 +
18018 diff -NurpP --minimal linux-3.0.4/kernel/vserver/cacct_proc.h linux-3.0.4-vs2.3.1/kernel/vserver/cacct_proc.h
18019 --- linux-3.0.4/kernel/vserver/cacct_proc.h     1970-01-01 01:00:00.000000000 +0100
18020 +++ linux-3.0.4-vs2.3.1/kernel/vserver/cacct_proc.h     2011-06-10 22:11:24.000000000 +0200
18021 @@ -0,0 +1,53 @@
18022 +#ifndef _VX_CACCT_PROC_H
18023 +#define _VX_CACCT_PROC_H
18024 +
18025 +#include <linux/vserver/cacct_int.h>
18026 +
18027 +
18028 +#define VX_SOCKA_TOP   \
18029 +       "Type\t    recv #/bytes\t\t   send #/bytes\t\t    fail #/bytes\n"
18030 +
18031 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
18032 +{
18033 +       int i, j, length = 0;
18034 +       static char *type[VXA_SOCK_SIZE] = {
18035 +               "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
18036 +       };
18037 +
18038 +       length += sprintf(buffer + length, VX_SOCKA_TOP);
18039 +       for (i = 0; i < VXA_SOCK_SIZE; i++) {
18040 +               length += sprintf(buffer + length, "%s:", type[i]);
18041 +               for (j = 0; j < 3; j++) {
18042 +                       length += sprintf(buffer + length,
18043 +                               "\t%10lu/%-10lu",
18044 +                               vx_sock_count(cacct, i, j),
18045 +                               vx_sock_total(cacct, i, j));
18046 +               }
18047 +               buffer[length++] = '\n';
18048 +       }
18049 +
18050 +       length += sprintf(buffer + length, "\n");
18051 +       length += sprintf(buffer + length,
18052 +               "slab:\t %8u %8u %8u %8u\n",
18053 +               atomic_read(&cacct->slab[1]),
18054 +               atomic_read(&cacct->slab[4]),
18055 +               atomic_read(&cacct->slab[0]),
18056 +               atomic_read(&cacct->slab[2]));
18057 +
18058 +       length += sprintf(buffer + length, "\n");
18059 +       for (i = 0; i < 5; i++) {
18060 +               length += sprintf(buffer + length,
18061 +                       "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
18062 +                       atomic_read(&cacct->page[i][0]),
18063 +                       atomic_read(&cacct->page[i][1]),
18064 +                       atomic_read(&cacct->page[i][2]),
18065 +                       atomic_read(&cacct->page[i][3]),
18066 +                       atomic_read(&cacct->page[i][4]),
18067 +                       atomic_read(&cacct->page[i][5]),
18068 +                       atomic_read(&cacct->page[i][6]),
18069 +                       atomic_read(&cacct->page[i][7]));
18070 +       }
18071 +       return length;
18072 +}
18073 +
18074 +#endif /* _VX_CACCT_PROC_H */
18075 diff -NurpP --minimal linux-3.0.4/kernel/vserver/context.c linux-3.0.4-vs2.3.1/kernel/vserver/context.c
18076 --- linux-3.0.4/kernel/vserver/context.c        1970-01-01 01:00:00.000000000 +0100
18077 +++ linux-3.0.4-vs2.3.1/kernel/vserver/context.c        2011-08-01 18:28:12.000000000 +0200
18078 @@ -0,0 +1,1107 @@
18079 +/*
18080 + *  linux/kernel/vserver/context.c
18081 + *
18082 + *  Virtual Server: Context Support
18083 + *
18084 + *  Copyright (C) 2003-2011  Herbert Pötzl
18085 + *
18086 + *  V0.01  context helper
18087 + *  V0.02  vx_ctx_kill syscall command
18088 + *  V0.03  replaced context_info calls
18089 + *  V0.04  redesign of struct (de)alloc
18090 + *  V0.05  rlimit basic implementation
18091 + *  V0.06  task_xid and info commands
18092 + *  V0.07  context flags and caps
18093 + *  V0.08  switch to RCU based hash
18094 + *  V0.09  revert to non RCU for now
18095 + *  V0.10  and back to working RCU hash
18096 + *  V0.11  and back to locking again
18097 + *  V0.12  referenced context store
18098 + *  V0.13  separate per cpu data
18099 + *  V0.14  changed vcmds to vxi arg
18100 + *  V0.15  added context stat
18101 + *  V0.16  have __create claim() the vxi
18102 + *  V0.17  removed older and legacy stuff
18103 + *  V0.18  added user credentials
18104 + *  V0.19  added warn mask
18105 + *
18106 + */
18107 +
18108 +#include <linux/slab.h>
18109 +#include <linux/types.h>
18110 +#include <linux/security.h>
18111 +#include <linux/pid_namespace.h>
18112 +#include <linux/capability.h>
18113 +
18114 +#include <linux/vserver/context.h>
18115 +#include <linux/vserver/network.h>
18116 +#include <linux/vserver/debug.h>
18117 +#include <linux/vserver/limit.h>
18118 +#include <linux/vserver/limit_int.h>
18119 +#include <linux/vserver/space.h>
18120 +#include <linux/init_task.h>
18121 +#include <linux/fs_struct.h>
18122 +#include <linux/cred.h>
18123 +
18124 +#include <linux/vs_context.h>
18125 +#include <linux/vs_limit.h>
18126 +#include <linux/vs_pid.h>
18127 +#include <linux/vserver/context_cmd.h>
18128 +
18129 +#include "cvirt_init.h"
18130 +#include "cacct_init.h"
18131 +#include "limit_init.h"
18132 +#include "sched_init.h"
18133 +
18134 +
18135 +atomic_t vx_global_ctotal      = ATOMIC_INIT(0);
18136 +atomic_t vx_global_cactive     = ATOMIC_INIT(0);
18137 +
18138 +
18139 +/*     now inactive context structures */
18140 +
18141 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
18142 +
18143 +static DEFINE_SPINLOCK(vx_info_inactive_lock);
18144 +
18145 +
18146 +/*     __alloc_vx_info()
18147 +
18148 +       * allocate an initialized vx_info struct
18149 +       * doesn't make it visible (hash)                        */
18150 +
18151 +static struct vx_info *__alloc_vx_info(xid_t xid)
18152 +{
18153 +       struct vx_info *new = NULL;
18154 +       int cpu, index;
18155 +
18156 +       vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
18157 +
18158 +       /* would this benefit from a slab cache? */
18159 +       new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
18160 +       if (!new)
18161 +               return 0;
18162 +
18163 +       memset(new, 0, sizeof(struct vx_info));
18164 +#ifdef CONFIG_SMP
18165 +       new->ptr_pc = alloc_percpu(struct _vx_info_pc);
18166 +       if (!new->ptr_pc)
18167 +               goto error;
18168 +#endif
18169 +       new->vx_id = xid;
18170 +       INIT_HLIST_NODE(&new->vx_hlist);
18171 +       atomic_set(&new->vx_usecnt, 0);
18172 +       atomic_set(&new->vx_tasks, 0);
18173 +       new->vx_parent = NULL;
18174 +       new->vx_state = 0;
18175 +       init_waitqueue_head(&new->vx_wait);
18176 +
18177 +       /* prepare reaper */
18178 +       get_task_struct(init_pid_ns.child_reaper);
18179 +       new->vx_reaper = init_pid_ns.child_reaper;
18180 +       new->vx_badness_bias = 0;
18181 +
18182 +       /* rest of init goes here */
18183 +       vx_info_init_limit(&new->limit);
18184 +       vx_info_init_sched(&new->sched);
18185 +       vx_info_init_cvirt(&new->cvirt);
18186 +       vx_info_init_cacct(&new->cacct);
18187 +
18188 +       /* per cpu data structures */
18189 +       for_each_possible_cpu(cpu) {
18190 +               vx_info_init_sched_pc(
18191 +                       &vx_per_cpu(new, sched_pc, cpu), cpu);
18192 +               vx_info_init_cvirt_pc(
18193 +                       &vx_per_cpu(new, cvirt_pc, cpu), cpu);
18194 +       }
18195 +
18196 +       new->vx_flags = VXF_INIT_SET;
18197 +       new->vx_bcaps = CAP_FULL_SET;   // maybe ~CAP_SETPCAP
18198 +       new->vx_ccaps = 0;
18199 +       new->vx_umask = 0;
18200 +       new->vx_wmask = 0;
18201 +
18202 +       new->reboot_cmd = 0;
18203 +       new->exit_code = 0;
18204 +
18205 +       // preconfig spaces
18206 +       for (index = 0; index < VX_SPACES; index++) {
18207 +               struct _vx_space *space = &new->space[index];
18208 +
18209 +               // filesystem
18210 +               spin_lock(&init_fs.lock);
18211 +               init_fs.users++;
18212 +               spin_unlock(&init_fs.lock);
18213 +               space->vx_fs = &init_fs;
18214 +
18215 +               /* FIXME: do we want defaults? */
18216 +               // space->vx_real_cred = 0;
18217 +               // space->vx_cred = 0;
18218 +       }
18219 +
18220 +
18221 +       vxdprintk(VXD_CBIT(xid, 0),
18222 +               "alloc_vx_info(%d) = %p", xid, new);
18223 +       vxh_alloc_vx_info(new);
18224 +       atomic_inc(&vx_global_ctotal);
18225 +       return new;
18226 +#ifdef CONFIG_SMP
18227 +error:
18228 +       kfree(new);
18229 +       return 0;
18230 +#endif
18231 +}
18232 +
18233 +/*     __dealloc_vx_info()
18234 +
18235 +       * final disposal of vx_info                             */
18236 +
18237 +static void __dealloc_vx_info(struct vx_info *vxi)
18238 +{
18239 +#ifdef CONFIG_VSERVER_WARN
18240 +       struct vx_info_save vxis;
18241 +       int cpu;
18242 +#endif
18243 +       vxdprintk(VXD_CBIT(xid, 0),
18244 +               "dealloc_vx_info(%p)", vxi);
18245 +       vxh_dealloc_vx_info(vxi);
18246 +
18247 +#ifdef CONFIG_VSERVER_WARN
18248 +       enter_vx_info(vxi, &vxis);
18249 +       vx_info_exit_limit(&vxi->limit);
18250 +       vx_info_exit_sched(&vxi->sched);
18251 +       vx_info_exit_cvirt(&vxi->cvirt);
18252 +       vx_info_exit_cacct(&vxi->cacct);
18253 +
18254 +       for_each_possible_cpu(cpu) {
18255 +               vx_info_exit_sched_pc(
18256 +                       &vx_per_cpu(vxi, sched_pc, cpu), cpu);
18257 +               vx_info_exit_cvirt_pc(
18258 +                       &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
18259 +       }
18260 +       leave_vx_info(&vxis);
18261 +#endif
18262 +
18263 +       vxi->vx_id = -1;
18264 +       vxi->vx_state |= VXS_RELEASED;
18265 +
18266 +#ifdef CONFIG_SMP
18267 +       free_percpu(vxi->ptr_pc);
18268 +#endif
18269 +       kfree(vxi);
18270 +       atomic_dec(&vx_global_ctotal);
18271 +}
18272 +
18273 +static void __shutdown_vx_info(struct vx_info *vxi)
18274 +{
18275 +       struct nsproxy *nsproxy;
18276 +       struct fs_struct *fs;
18277 +       struct cred *cred;
18278 +       int index, kill;
18279 +
18280 +       might_sleep();
18281 +
18282 +       vxi->vx_state |= VXS_SHUTDOWN;
18283 +       vs_state_change(vxi, VSC_SHUTDOWN);
18284 +
18285 +       for (index = 0; index < VX_SPACES; index++) {
18286 +               struct _vx_space *space = &vxi->space[index];
18287 +
18288 +               nsproxy = xchg(&space->vx_nsproxy, NULL);
18289 +               if (nsproxy)
18290 +                       put_nsproxy(nsproxy);
18291 +
18292 +               fs = xchg(&space->vx_fs, NULL);
18293 +               spin_lock(&fs->lock);
18294 +               kill = !--fs->users;
18295 +               spin_unlock(&fs->lock);
18296 +               if (kill)
18297 +                       free_fs_struct(fs);
18298 +
18299 +               cred = (struct cred *)xchg(&space->vx_cred, NULL);
18300 +               if (cred)
18301 +                       abort_creds(cred);
18302 +       }
18303 +}
18304 +
18305 +/* exported stuff */
18306 +
18307 +void free_vx_info(struct vx_info *vxi)
18308 +{
18309 +       unsigned long flags;
18310 +       unsigned index;
18311 +
18312 +       /* check for reference counts first */
18313 +       BUG_ON(atomic_read(&vxi->vx_usecnt));
18314 +       BUG_ON(atomic_read(&vxi->vx_tasks));
18315 +
18316 +       /* context must not be hashed */
18317 +       BUG_ON(vx_info_state(vxi, VXS_HASHED));
18318 +
18319 +       /* context shutdown is mandatory */
18320 +       BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
18321 +
18322 +       /* spaces check */
18323 +       for (index = 0; index < VX_SPACES; index++) {
18324 +               struct _vx_space *space = &vxi->space[index];
18325 +
18326 +               BUG_ON(space->vx_nsproxy);
18327 +               BUG_ON(space->vx_fs);
18328 +               // BUG_ON(space->vx_real_cred);
18329 +               // BUG_ON(space->vx_cred);
18330 +       }
18331 +
18332 +       spin_lock_irqsave(&vx_info_inactive_lock, flags);
18333 +       hlist_del(&vxi->vx_hlist);
18334 +       spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
18335 +
18336 +       __dealloc_vx_info(vxi);
18337 +}
18338 +
18339 +
18340 +/*     hash table for vx_info hash */
18341 +
18342 +#define VX_HASH_SIZE   13
18343 +
18344 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
18345 +       { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
18346 +
18347 +static DEFINE_SPINLOCK(vx_info_hash_lock);
18348 +
18349 +
18350 +static inline unsigned int __hashval(xid_t xid)
18351 +{
18352 +       return (xid % VX_HASH_SIZE);
18353 +}
18354 +
18355 +
18356 +
18357 +/*     __hash_vx_info()
18358 +
18359 +       * add the vxi to the global hash table
18360 +       * requires the hash_lock to be held                     */
18361 +
18362 +static inline void __hash_vx_info(struct vx_info *vxi)
18363 +{
18364 +       struct hlist_head *head;
18365 +
18366 +       vxd_assert_lock(&vx_info_hash_lock);
18367 +       vxdprintk(VXD_CBIT(xid, 4),
18368 +               "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
18369 +       vxh_hash_vx_info(vxi);
18370 +
18371 +       /* context must not be hashed */
18372 +       BUG_ON(vx_info_state(vxi, VXS_HASHED));
18373 +
18374 +       vxi->vx_state |= VXS_HASHED;
18375 +       head = &vx_info_hash[__hashval(vxi->vx_id)];
18376 +       hlist_add_head(&vxi->vx_hlist, head);
18377 +       atomic_inc(&vx_global_cactive);
18378 +}
18379 +
18380 +/*     __unhash_vx_info()
18381 +
18382 +       * remove the vxi from the global hash table
18383 +       * requires the hash_lock to be held                     */
18384 +
18385 +static inline void __unhash_vx_info(struct vx_info *vxi)
18386 +{
18387 +       unsigned long flags;
18388 +
18389 +       vxd_assert_lock(&vx_info_hash_lock);
18390 +       vxdprintk(VXD_CBIT(xid, 4),
18391 +               "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
18392 +               atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
18393 +       vxh_unhash_vx_info(vxi);
18394 +
18395 +       /* context must be hashed */
18396 +       BUG_ON(!vx_info_state(vxi, VXS_HASHED));
18397 +       /* but without tasks */
18398 +       BUG_ON(atomic_read(&vxi->vx_tasks));
18399 +
18400 +       vxi->vx_state &= ~VXS_HASHED;
18401 +       hlist_del_init(&vxi->vx_hlist);
18402 +       spin_lock_irqsave(&vx_info_inactive_lock, flags);
18403 +       hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
18404 +       spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
18405 +       atomic_dec(&vx_global_cactive);
18406 +}
18407 +
18408 +
18409 +/*     __lookup_vx_info()
18410 +
18411 +       * requires the hash_lock to be held
18412 +       * doesn't increment the vx_refcnt                       */
18413 +
18414 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
18415 +{
18416 +       struct hlist_head *head = &vx_info_hash[__hashval(xid)];
18417 +       struct hlist_node *pos;
18418 +       struct vx_info *vxi;
18419 +
18420 +       vxd_assert_lock(&vx_info_hash_lock);
18421 +       hlist_for_each(pos, head) {
18422 +               vxi = hlist_entry(pos, struct vx_info, vx_hlist);
18423 +
18424 +               if (vxi->vx_id == xid)
18425 +                       goto found;
18426 +       }
18427 +       vxi = NULL;
18428 +found:
18429 +       vxdprintk(VXD_CBIT(xid, 0),
18430 +               "__lookup_vx_info(#%u): %p[#%u]",
18431 +               xid, vxi, vxi ? vxi->vx_id : 0);
18432 +       vxh_lookup_vx_info(vxi, xid);
18433 +       return vxi;
18434 +}
18435 +
18436 +
18437 +/*     __create_vx_info()
18438 +
18439 +       * create the requested context
18440 +       * get(), claim() and hash it                            */
18441 +
18442 +static struct vx_info *__create_vx_info(int id)
18443 +{
18444 +       struct vx_info *new, *vxi = NULL;
18445 +
18446 +       vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
18447 +
18448 +       if (!(new = __alloc_vx_info(id)))
18449 +               return ERR_PTR(-ENOMEM);
18450 +
18451 +       /* required to make dynamic xids unique */
18452 +       spin_lock(&vx_info_hash_lock);
18453 +
18454 +       /* static context requested */
18455 +       if ((vxi = __lookup_vx_info(id))) {
18456 +               vxdprintk(VXD_CBIT(xid, 0),
18457 +                       "create_vx_info(%d) = %p (already there)", id, vxi);
18458 +               if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18459 +                       vxi = ERR_PTR(-EBUSY);
18460 +               else
18461 +                       vxi = ERR_PTR(-EEXIST);
18462 +               goto out_unlock;
18463 +       }
18464 +       /* new context */
18465 +       vxdprintk(VXD_CBIT(xid, 0),
18466 +               "create_vx_info(%d) = %p (new)", id, new);
18467 +       claim_vx_info(new, NULL);
18468 +       __hash_vx_info(get_vx_info(new));
18469 +       vxi = new, new = NULL;
18470 +
18471 +out_unlock:
18472 +       spin_unlock(&vx_info_hash_lock);
18473 +       vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
18474 +       if (new)
18475 +               __dealloc_vx_info(new);
18476 +       return vxi;
18477 +}
18478 +
18479 +
18480 +/*     exported stuff                                          */
18481 +
18482 +
18483 +void unhash_vx_info(struct vx_info *vxi)
18484 +{
18485 +       spin_lock(&vx_info_hash_lock);
18486 +       __unhash_vx_info(vxi);
18487 +       spin_unlock(&vx_info_hash_lock);
18488 +       __shutdown_vx_info(vxi);
18489 +       __wakeup_vx_info(vxi);
18490 +}
18491 +
18492 +
18493 +/*     lookup_vx_info()
18494 +
18495 +       * search for a vx_info and get() it
18496 +       * negative id means current                             */
18497 +
18498 +struct vx_info *lookup_vx_info(int id)
18499 +{
18500 +       struct vx_info *vxi = NULL;
18501 +
18502 +       if (id < 0) {
18503 +               vxi = get_vx_info(current_vx_info());
18504 +       } else if (id > 1) {
18505 +               spin_lock(&vx_info_hash_lock);
18506 +               vxi = get_vx_info(__lookup_vx_info(id));
18507 +               spin_unlock(&vx_info_hash_lock);
18508 +       }
18509 +       return vxi;
18510 +}
18511 +
18512 +/*     xid_is_hashed()
18513 +
18514 +       * verify that xid is still hashed                       */
18515 +
18516 +int xid_is_hashed(xid_t xid)
18517 +{
18518 +       int hashed;
18519 +
18520 +       spin_lock(&vx_info_hash_lock);
18521 +       hashed = (__lookup_vx_info(xid) != NULL);
18522 +       spin_unlock(&vx_info_hash_lock);
18523 +       return hashed;
18524 +}
18525 +
18526 +#ifdef CONFIG_PROC_FS
18527 +
18528 +/*     get_xid_list()
18529 +
18530 +       * get a subset of hashed xids for proc
18531 +       * assumes size is at least one                          */
18532 +
18533 +int get_xid_list(int index, unsigned int *xids, int size)
18534 +{
18535 +       int hindex, nr_xids = 0;
18536 +
18537 +       /* only show current and children */
18538 +       if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
18539 +               if (index > 0)
18540 +                       return 0;
18541 +               xids[nr_xids] = vx_current_xid();
18542 +               return 1;
18543 +       }
18544 +
18545 +       for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
18546 +               struct hlist_head *head = &vx_info_hash[hindex];
18547 +               struct hlist_node *pos;
18548 +
18549 +               spin_lock(&vx_info_hash_lock);
18550 +               hlist_for_each(pos, head) {
18551 +                       struct vx_info *vxi;
18552 +
18553 +                       if (--index > 0)
18554 +                               continue;
18555 +
18556 +                       vxi = hlist_entry(pos, struct vx_info, vx_hlist);
18557 +                       xids[nr_xids] = vxi->vx_id;
18558 +                       if (++nr_xids >= size) {
18559 +                               spin_unlock(&vx_info_hash_lock);
18560 +                               goto out;
18561 +                       }
18562 +               }
18563 +               /* keep the lock time short */
18564 +               spin_unlock(&vx_info_hash_lock);
18565 +       }
18566 +out:
18567 +       return nr_xids;
18568 +}
18569 +#endif
18570 +
18571 +#ifdef CONFIG_VSERVER_DEBUG
18572 +
18573 +void   dump_vx_info_inactive(int level)
18574 +{
18575 +       struct hlist_node *entry, *next;
18576 +
18577 +       hlist_for_each_safe(entry, next, &vx_info_inactive) {
18578 +               struct vx_info *vxi =
18579 +                       list_entry(entry, struct vx_info, vx_hlist);
18580 +
18581 +               dump_vx_info(vxi, level);
18582 +       }
18583 +}
18584 +
18585 +#endif
18586 +
18587 +#if 0
18588 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
18589 +{
18590 +       struct user_struct *new_user, *old_user;
18591 +
18592 +       if (!p || !vxi)
18593 +               BUG();
18594 +
18595 +       if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
18596 +               return -EACCES;
18597 +
18598 +       new_user = alloc_uid(vxi->vx_id, p->uid);
18599 +       if (!new_user)
18600 +               return -ENOMEM;
18601 +
18602 +       old_user = p->user;
18603 +       if (new_user != old_user) {
18604 +               atomic_inc(&new_user->processes);
18605 +               atomic_dec(&old_user->processes);
18606 +               p->user = new_user;
18607 +       }
18608 +       free_uid(old_user);
18609 +       return 0;
18610 +}
18611 +#endif
18612 +
18613 +#if 0
18614 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
18615 +{
18616 +       // p->cap_effective &= vxi->vx_cap_bset;
18617 +       p->cap_effective =
18618 +               cap_intersect(p->cap_effective, vxi->cap_bset);
18619 +       // p->cap_inheritable &= vxi->vx_cap_bset;
18620 +       p->cap_inheritable =
18621 +               cap_intersect(p->cap_inheritable, vxi->cap_bset);
18622 +       // p->cap_permitted &= vxi->vx_cap_bset;
18623 +       p->cap_permitted =
18624 +               cap_intersect(p->cap_permitted, vxi->cap_bset);
18625 +}
18626 +#endif
18627 +
18628 +
18629 +#include <linux/file.h>
18630 +#include <linux/fdtable.h>
18631 +
18632 +static int vx_openfd_task(struct task_struct *tsk)
18633 +{
18634 +       struct files_struct *files = tsk->files;
18635 +       struct fdtable *fdt;
18636 +       const unsigned long *bptr;
18637 +       int count, total;
18638 +
18639 +       /* no rcu_read_lock() because of spin_lock() */
18640 +       spin_lock(&files->file_lock);
18641 +       fdt = files_fdtable(files);
18642 +       bptr = fdt->open_fds->fds_bits;
18643 +       count = fdt->max_fds / (sizeof(unsigned long) * 8);
18644 +       for (total = 0; count > 0; count--) {
18645 +               if (*bptr)
18646 +                       total += hweight_long(*bptr);
18647 +               bptr++;
18648 +       }
18649 +       spin_unlock(&files->file_lock);
18650 +       return total;
18651 +}
18652 +
18653 +
18654 +/*     for *space compatibility */
18655 +
18656 +asmlinkage long sys_unshare(unsigned long);
18657 +
18658 +/*
18659 + *     migrate task to new context
18660 + *     gets vxi, puts old_vxi on change
18661 + *     optionally unshares namespaces (hack)
18662 + */
18663 +
18664 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
18665 +{
18666 +       struct vx_info *old_vxi;
18667 +       int ret = 0;
18668 +
18669 +       if (!p || !vxi)
18670 +               BUG();
18671 +
18672 +       vxdprintk(VXD_CBIT(xid, 5),
18673 +               "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
18674 +               vxi->vx_id, atomic_read(&vxi->vx_usecnt));
18675 +
18676 +       if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
18677 +               !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18678 +               return -EACCES;
18679 +
18680 +       if (vx_info_state(vxi, VXS_SHUTDOWN))
18681 +               return -EFAULT;
18682 +
18683 +       old_vxi = task_get_vx_info(p);
18684 +       if (old_vxi == vxi)
18685 +               goto out;
18686 +
18687 +//     if (!(ret = vx_migrate_user(p, vxi))) {
18688 +       {
18689 +               int openfd;
18690 +
18691 +               task_lock(p);
18692 +               openfd = vx_openfd_task(p);
18693 +
18694 +               if (old_vxi) {
18695 +                       atomic_dec(&old_vxi->cvirt.nr_threads);
18696 +                       atomic_dec(&old_vxi->cvirt.nr_running);
18697 +                       __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
18698 +                       /* FIXME: what about the struct files here? */
18699 +                       __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
18700 +                       /* account for the executable */
18701 +                       __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
18702 +               }
18703 +               atomic_inc(&vxi->cvirt.nr_threads);
18704 +               atomic_inc(&vxi->cvirt.nr_running);
18705 +               __rlim_inc(&vxi->limit, RLIMIT_NPROC);
18706 +               /* FIXME: what about the struct files here? */
18707 +               __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
18708 +               /* account for the executable */
18709 +               __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
18710 +
18711 +               if (old_vxi) {
18712 +                       release_vx_info(old_vxi, p);
18713 +                       clr_vx_info(&p->vx_info);
18714 +               }
18715 +               claim_vx_info(vxi, p);
18716 +               set_vx_info(&p->vx_info, vxi);
18717 +               p->xid = vxi->vx_id;
18718 +
18719 +               vxdprintk(VXD_CBIT(xid, 5),
18720 +                       "moved task %p into vxi:%p[#%d]",
18721 +                       p, vxi, vxi->vx_id);
18722 +
18723 +               // vx_mask_cap_bset(vxi, p);
18724 +               task_unlock(p);
18725 +
18726 +               /* hack for *spaces to provide compatibility */
18727 +               if (unshare) {
18728 +                       struct nsproxy *old_nsp, *new_nsp;
18729 +
18730 +                       ret = unshare_nsproxy_namespaces(
18731 +                               CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
18732 +                               &new_nsp, NULL);
18733 +                       if (ret)
18734 +                               goto out;
18735 +
18736 +                       old_nsp = xchg(&p->nsproxy, new_nsp);
18737 +                       vx_set_space(vxi,
18738 +                               CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
18739 +                       put_nsproxy(old_nsp);
18740 +               }
18741 +       }
18742 +out:
18743 +       put_vx_info(old_vxi);
18744 +       return ret;
18745 +}
18746 +
18747 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
18748 +{
18749 +       struct task_struct *old_reaper;
18750 +
18751 +       if (!vxi)
18752 +               return -EINVAL;
18753 +
18754 +       vxdprintk(VXD_CBIT(xid, 6),
18755 +               "vx_set_reaper(%p[#%d],%p[#%d,%d])",
18756 +               vxi, vxi->vx_id, p, p->xid, p->pid);
18757 +
18758 +       old_reaper = vxi->vx_reaper;
18759 +       if (old_reaper == p)
18760 +               return 0;
18761 +
18762 +       /* set new child reaper */
18763 +       get_task_struct(p);
18764 +       vxi->vx_reaper = p;
18765 +       put_task_struct(old_reaper);
18766 +       return 0;
18767 +}
18768 +
18769 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
18770 +{
18771 +       if (!vxi)
18772 +               return -EINVAL;
18773 +
18774 +       vxdprintk(VXD_CBIT(xid, 6),
18775 +               "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
18776 +               vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18777 +
18778 +       vxi->vx_flags &= ~VXF_STATE_INIT;
18779 +       // vxi->vx_initpid = p->tgid;
18780 +       vxi->vx_initpid = p->pid;
18781 +       return 0;
18782 +}
18783 +
18784 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
18785 +{
18786 +       vxdprintk(VXD_CBIT(xid, 6),
18787 +               "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
18788 +               vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18789 +
18790 +       vxi->exit_code = code;
18791 +       vxi->vx_initpid = 0;
18792 +}
18793 +
18794 +
18795 +void vx_set_persistent(struct vx_info *vxi)
18796 +{
18797 +       vxdprintk(VXD_CBIT(xid, 6),
18798 +               "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
18799 +
18800 +       get_vx_info(vxi);
18801 +       claim_vx_info(vxi, NULL);
18802 +}
18803 +
18804 +void vx_clear_persistent(struct vx_info *vxi)
18805 +{
18806 +       vxdprintk(VXD_CBIT(xid, 6),
18807 +               "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
18808 +
18809 +       release_vx_info(vxi, NULL);
18810 +       put_vx_info(vxi);
18811 +}
18812 +
18813 +void vx_update_persistent(struct vx_info *vxi)
18814 +{
18815 +       if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
18816 +               vx_set_persistent(vxi);
18817 +       else
18818 +               vx_clear_persistent(vxi);
18819 +}
18820 +
18821 +
18822 +/*     task must be current or locked          */
18823 +
18824 +void   exit_vx_info(struct task_struct *p, int code)
18825 +{
18826 +       struct vx_info *vxi = p->vx_info;
18827 +
18828 +       if (vxi) {
18829 +               atomic_dec(&vxi->cvirt.nr_threads);
18830 +               vx_nproc_dec(p);
18831 +
18832 +               vxi->exit_code = code;
18833 +               release_vx_info(vxi, p);
18834 +       }
18835 +}
18836 +
18837 +void   exit_vx_info_early(struct task_struct *p, int code)
18838 +{
18839 +       struct vx_info *vxi = p->vx_info;
18840 +
18841 +       if (vxi) {
18842 +               if (vxi->vx_initpid == p->pid)
18843 +                       vx_exit_init(vxi, p, code);
18844 +               if (vxi->vx_reaper == p)
18845 +                       vx_set_reaper(vxi, init_pid_ns.child_reaper);
18846 +       }
18847 +}
18848 +
18849 +
18850 +/* vserver syscall commands below here */
18851 +
18852 +/* taks xid and vx_info functions */
18853 +
18854 +#include <asm/uaccess.h>
18855 +
18856 +
18857 +int vc_task_xid(uint32_t id)
18858 +{
18859 +       xid_t xid;
18860 +
18861 +       if (id) {
18862 +               struct task_struct *tsk;
18863 +
18864 +               rcu_read_lock();
18865 +               tsk = find_task_by_real_pid(id);
18866 +               xid = (tsk) ? tsk->xid : -ESRCH;
18867 +               rcu_read_unlock();
18868 +       } else
18869 +               xid = vx_current_xid();
18870 +       return xid;
18871 +}
18872 +
18873 +
18874 +int vc_vx_info(struct vx_info *vxi, void __user *data)
18875 +{
18876 +       struct vcmd_vx_info_v0 vc_data;
18877 +
18878 +       vc_data.xid = vxi->vx_id;
18879 +       vc_data.initpid = vxi->vx_initpid;
18880 +
18881 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18882 +               return -EFAULT;
18883 +       return 0;
18884 +}
18885 +
18886 +
18887 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
18888 +{
18889 +       struct vcmd_ctx_stat_v0 vc_data;
18890 +
18891 +       vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
18892 +       vc_data.tasks = atomic_read(&vxi->vx_tasks);
18893 +
18894 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18895 +               return -EFAULT;
18896 +       return 0;
18897 +}
18898 +
18899 +
18900 +/* context functions */
18901 +
18902 +int vc_ctx_create(uint32_t xid, void __user *data)
18903 +{
18904 +       struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
18905 +       struct vx_info *new_vxi;
18906 +       int ret;
18907 +
18908 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18909 +               return -EFAULT;
18910 +
18911 +       if ((xid > MAX_S_CONTEXT) || (xid < 2))
18912 +               return -EINVAL;
18913 +
18914 +       new_vxi = __create_vx_info(xid);
18915 +       if (IS_ERR(new_vxi))
18916 +               return PTR_ERR(new_vxi);
18917 +
18918 +       /* initial flags */
18919 +       new_vxi->vx_flags = vc_data.flagword;
18920 +
18921 +       ret = -ENOEXEC;
18922 +       if (vs_state_change(new_vxi, VSC_STARTUP))
18923 +               goto out;
18924 +
18925 +       ret = vx_migrate_task(current, new_vxi, (!data));
18926 +       if (ret)
18927 +               goto out;
18928 +
18929 +       /* return context id on success */
18930 +       ret = new_vxi->vx_id;
18931 +
18932 +       /* get a reference for persistent contexts */
18933 +       if ((vc_data.flagword & VXF_PERSISTENT))
18934 +               vx_set_persistent(new_vxi);
18935 +out:
18936 +       release_vx_info(new_vxi, NULL);
18937 +       put_vx_info(new_vxi);
18938 +       return ret;
18939 +}
18940 +
18941 +
18942 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
18943 +{
18944 +       struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
18945 +       int ret;
18946 +
18947 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18948 +               return -EFAULT;
18949 +
18950 +       ret = vx_migrate_task(current, vxi, 0);
18951 +       if (ret)
18952 +               return ret;
18953 +       if (vc_data.flagword & VXM_SET_INIT)
18954 +               ret = vx_set_init(vxi, current);
18955 +       if (ret)
18956 +               return ret;
18957 +       if (vc_data.flagword & VXM_SET_REAPER)
18958 +               ret = vx_set_reaper(vxi, current);
18959 +       return ret;
18960 +}
18961 +
18962 +
18963 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
18964 +{
18965 +       struct vcmd_ctx_flags_v0 vc_data;
18966 +
18967 +       vc_data.flagword = vxi->vx_flags;
18968 +
18969 +       /* special STATE flag handling */
18970 +       vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
18971 +
18972 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18973 +               return -EFAULT;
18974 +       return 0;
18975 +}
18976 +
18977 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
18978 +{
18979 +       struct vcmd_ctx_flags_v0 vc_data;
18980 +       uint64_t mask, trigger;
18981 +
18982 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18983 +               return -EFAULT;
18984 +
18985 +       /* special STATE flag handling */
18986 +       mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
18987 +       trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
18988 +
18989 +       if (vxi == current_vx_info()) {
18990 +               /* if (trigger & VXF_STATE_SETUP)
18991 +                       vx_mask_cap_bset(vxi, current); */
18992 +               if (trigger & VXF_STATE_INIT) {
18993 +                       int ret;
18994 +
18995 +                       ret = vx_set_init(vxi, current);
18996 +                       if (ret)
18997 +                               return ret;
18998 +                       ret = vx_set_reaper(vxi, current);
18999 +                       if (ret)
19000 +                               return ret;
19001 +               }
19002 +       }
19003 +
19004 +       vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
19005 +               vc_data.flagword, mask);
19006 +       if (trigger & VXF_PERSISTENT)
19007 +               vx_update_persistent(vxi);
19008 +
19009 +       return 0;
19010 +}
19011 +
19012 +
19013 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
19014 +{
19015 +       uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
19016 +
19017 +       // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
19018 +       return v;
19019 +}
19020 +
19021 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
19022 +{
19023 +       kernel_cap_t c = __cap_empty_set;
19024 +
19025 +       c.cap[0] = v & 0xFFFFFFFF;
19026 +       c.cap[1] = (v >> 32) & 0xFFFFFFFF;
19027 +
19028 +       // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
19029 +       return c;
19030 +}
19031 +
19032 +
19033 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
19034 +{
19035 +       if (bcaps)
19036 +               *bcaps = caps_from_cap_t(vxi->vx_bcaps);
19037 +       if (ccaps)
19038 +               *ccaps = vxi->vx_ccaps;
19039 +
19040 +       return 0;
19041 +}
19042 +
19043 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
19044 +{
19045 +       struct vcmd_ctx_caps_v1 vc_data;
19046 +       int ret;
19047 +
19048 +       ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
19049 +       if (ret)
19050 +               return ret;
19051 +       vc_data.cmask = ~0ULL;
19052 +
19053 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19054 +               return -EFAULT;
19055 +       return 0;
19056 +}
19057 +
19058 +static int do_set_caps(struct vx_info *vxi,
19059 +       uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
19060 +{
19061 +       uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
19062 +
19063 +#if 0
19064 +       printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
19065 +               bcaps, bmask, ccaps, cmask);
19066 +#endif
19067 +       vxi->vx_bcaps = cap_t_from_caps(
19068 +               vs_mask_flags(bcold, bcaps, bmask));
19069 +       vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
19070 +
19071 +       return 0;
19072 +}
19073 +
19074 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
19075 +{
19076 +       struct vcmd_ctx_caps_v1 vc_data;
19077 +
19078 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19079 +               return -EFAULT;
19080 +
19081 +       return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
19082 +}
19083 +
19084 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
19085 +{
19086 +       struct vcmd_bcaps vc_data;
19087 +       int ret;
19088 +
19089 +       ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
19090 +       if (ret)
19091 +               return ret;
19092 +       vc_data.bmask = ~0ULL;
19093 +
19094 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19095 +               return -EFAULT;
19096 +       return 0;
19097 +}
19098 +
19099 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
19100 +{
19101 +       struct vcmd_bcaps vc_data;
19102 +
19103 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19104 +               return -EFAULT;
19105 +
19106 +       return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
19107 +}
19108 +
19109 +
19110 +int vc_get_umask(struct vx_info *vxi, void __user *data)
19111 +{
19112 +       struct vcmd_umask vc_data;
19113 +
19114 +       vc_data.umask = vxi->vx_umask;
19115 +       vc_data.mask = ~0ULL;
19116 +
19117 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19118 +               return -EFAULT;
19119 +       return 0;
19120 +}
19121 +
19122 +int vc_set_umask(struct vx_info *vxi, void __user *data)
19123 +{
19124 +       struct vcmd_umask vc_data;
19125 +
19126 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19127 +               return -EFAULT;
19128 +
19129 +       vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
19130 +               vc_data.umask, vc_data.mask);
19131 +       return 0;
19132 +}
19133 +
19134 +
19135 +int vc_get_wmask(struct vx_info *vxi, void __user *data)
19136 +{
19137 +       struct vcmd_wmask vc_data;
19138 +
19139 +       vc_data.wmask = vxi->vx_wmask;
19140 +       vc_data.mask = ~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_wmask(struct vx_info *vxi, void __user *data)
19148 +{
19149 +       struct vcmd_wmask vc_data;
19150 +
19151 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19152 +               return -EFAULT;
19153 +
19154 +       vxi->vx_wmask = vs_mask_flags(vxi->vx_wmask,
19155 +               vc_data.wmask, vc_data.mask);
19156 +       return 0;
19157 +}
19158 +
19159 +
19160 +int vc_get_badness(struct vx_info *vxi, void __user *data)
19161 +{
19162 +       struct vcmd_badness_v0 vc_data;
19163 +
19164 +       vc_data.bias = vxi->vx_badness_bias;
19165 +
19166 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19167 +               return -EFAULT;
19168 +       return 0;
19169 +}
19170 +
19171 +int vc_set_badness(struct vx_info *vxi, void __user *data)
19172 +{
19173 +       struct vcmd_badness_v0 vc_data;
19174 +
19175 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19176 +               return -EFAULT;
19177 +
19178 +       vxi->vx_badness_bias = vc_data.bias;
19179 +       return 0;
19180 +}
19181 +
19182 +#include <linux/module.h>
19183 +
19184 +EXPORT_SYMBOL_GPL(free_vx_info);
19185 +
19186 diff -NurpP --minimal linux-3.0.4/kernel/vserver/cvirt.c linux-3.0.4-vs2.3.1/kernel/vserver/cvirt.c
19187 --- linux-3.0.4/kernel/vserver/cvirt.c  1970-01-01 01:00:00.000000000 +0100
19188 +++ linux-3.0.4-vs2.3.1/kernel/vserver/cvirt.c  2011-06-13 14:57:26.000000000 +0200
19189 @@ -0,0 +1,303 @@
19190 +/*
19191 + *  linux/kernel/vserver/cvirt.c
19192 + *
19193 + *  Virtual Server: Context Virtualization
19194 + *
19195 + *  Copyright (C) 2004-2007  Herbert Pötzl
19196 + *
19197 + *  V0.01  broken out from limit.c
19198 + *  V0.02  added utsname stuff
19199 + *  V0.03  changed vcmds to vxi arg
19200 + *
19201 + */
19202 +
19203 +#include <linux/types.h>
19204 +#include <linux/utsname.h>
19205 +#include <linux/vs_cvirt.h>
19206 +#include <linux/vserver/switch.h>
19207 +#include <linux/vserver/cvirt_cmd.h>
19208 +
19209 +#include <asm/uaccess.h>
19210 +
19211 +
19212 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
19213 +{
19214 +       struct vx_info *vxi = current_vx_info();
19215 +
19216 +       set_normalized_timespec(uptime,
19217 +               uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
19218 +               uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
19219 +       if (!idle)
19220 +               return;
19221 +       set_normalized_timespec(idle,
19222 +               idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
19223 +               idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
19224 +       return;
19225 +}
19226 +
19227 +uint64_t vx_idle_jiffies(void)
19228 +{
19229 +       return init_task.utime + init_task.stime;
19230 +}
19231 +
19232 +
19233 +
19234 +static inline uint32_t __update_loadavg(uint32_t load,
19235 +       int wsize, int delta, int n)
19236 +{
19237 +       unsigned long long calc, prev;
19238 +
19239 +       /* just set it to n */
19240 +       if (unlikely(delta >= wsize))
19241 +               return (n << FSHIFT);
19242 +
19243 +       calc = delta * n;
19244 +       calc <<= FSHIFT;
19245 +       prev = (wsize - delta);
19246 +       prev *= load;
19247 +       calc += prev;
19248 +       do_div(calc, wsize);
19249 +       return calc;
19250 +}
19251 +
19252 +
19253 +void vx_update_load(struct vx_info *vxi)
19254 +{
19255 +       uint32_t now, last, delta;
19256 +       unsigned int nr_running, nr_uninterruptible;
19257 +       unsigned int total;
19258 +       unsigned long flags;
19259 +
19260 +       spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
19261 +
19262 +       now = jiffies;
19263 +       last = vxi->cvirt.load_last;
19264 +       delta = now - last;
19265 +
19266 +       if (delta < 5*HZ)
19267 +               goto out;
19268 +
19269 +       nr_running = atomic_read(&vxi->cvirt.nr_running);
19270 +       nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
19271 +       total = nr_running + nr_uninterruptible;
19272 +
19273 +       vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
19274 +               60*HZ, delta, total);
19275 +       vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
19276 +               5*60*HZ, delta, total);
19277 +       vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
19278 +               15*60*HZ, delta, total);
19279 +
19280 +       vxi->cvirt.load_last = now;
19281 +out:
19282 +       atomic_inc(&vxi->cvirt.load_updates);
19283 +       spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
19284 +}
19285 +
19286 +
19287 +/*
19288 + * Commands to do_syslog:
19289 + *
19290 + *      0 -- Close the log.  Currently a NOP.
19291 + *      1 -- Open the log. Currently a NOP.
19292 + *      2 -- Read from the log.
19293 + *      3 -- Read all messages remaining in the ring buffer.
19294 + *      4 -- Read and clear all messages remaining in the ring buffer
19295 + *      5 -- Clear ring buffer.
19296 + *      6 -- Disable printk's to console
19297 + *      7 -- Enable printk's to console
19298 + *      8 -- Set level of messages printed to console
19299 + *      9 -- Return number of unread characters in the log buffer
19300 + *     10 -- Return size of the log buffer
19301 + */
19302 +int vx_do_syslog(int type, char __user *buf, int len)
19303 +{
19304 +       int error = 0;
19305 +       int do_clear = 0;
19306 +       struct vx_info *vxi = current_vx_info();
19307 +       struct _vx_syslog *log;
19308 +
19309 +       if (!vxi)
19310 +               return -EINVAL;
19311 +       log = &vxi->cvirt.syslog;
19312 +
19313 +       switch (type) {
19314 +       case 0:         /* Close log */
19315 +       case 1:         /* Open log */
19316 +               break;
19317 +       case 2:         /* Read from log */
19318 +               error = wait_event_interruptible(log->log_wait,
19319 +                       (log->log_start - log->log_end));
19320 +               if (error)
19321 +                       break;
19322 +               spin_lock_irq(&log->logbuf_lock);
19323 +               spin_unlock_irq(&log->logbuf_lock);
19324 +               break;
19325 +       case 4:         /* Read/clear last kernel messages */
19326 +               do_clear = 1;
19327 +               /* fall through */
19328 +       case 3:         /* Read last kernel messages */
19329 +               return 0;
19330 +
19331 +       case 5:         /* Clear ring buffer */
19332 +               return 0;
19333 +
19334 +       case 6:         /* Disable logging to console */
19335 +       case 7:         /* Enable logging to console */
19336 +       case 8:         /* Set level of messages printed to console */
19337 +               break;
19338 +
19339 +       case 9:         /* Number of chars in the log buffer */
19340 +               return 0;
19341 +       case 10:        /* Size of the log buffer */
19342 +               return 0;
19343 +       default:
19344 +               error = -EINVAL;
19345 +               break;
19346 +       }
19347 +       return error;
19348 +}
19349 +
19350 +
19351 +/* virtual host info names */
19352 +
19353 +static char *vx_vhi_name(struct vx_info *vxi, int id)
19354 +{
19355 +       struct nsproxy *nsproxy;
19356 +       struct uts_namespace *uts;
19357 +
19358 +       if (id == VHIN_CONTEXT)
19359 +               return vxi->vx_name;
19360 +
19361 +       nsproxy = vxi->space[0].vx_nsproxy;
19362 +       if (!nsproxy)
19363 +               return NULL;
19364 +
19365 +       uts = nsproxy->uts_ns;
19366 +       if (!uts)
19367 +               return NULL;
19368 +
19369 +       switch (id) {
19370 +       case VHIN_SYSNAME:
19371 +               return uts->name.sysname;
19372 +       case VHIN_NODENAME:
19373 +               return uts->name.nodename;
19374 +       case VHIN_RELEASE:
19375 +               return uts->name.release;
19376 +       case VHIN_VERSION:
19377 +               return uts->name.version;
19378 +       case VHIN_MACHINE:
19379 +               return uts->name.machine;
19380 +       case VHIN_DOMAINNAME:
19381 +               return uts->name.domainname;
19382 +       default:
19383 +               return NULL;
19384 +       }
19385 +       return NULL;
19386 +}
19387 +
19388 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
19389 +{
19390 +       struct vcmd_vhi_name_v0 vc_data;
19391 +       char *name;
19392 +
19393 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19394 +               return -EFAULT;
19395 +
19396 +       name = vx_vhi_name(vxi, vc_data.field);
19397 +       if (!name)
19398 +               return -EINVAL;
19399 +
19400 +       memcpy(name, vc_data.name, 65);
19401 +       return 0;
19402 +}
19403 +
19404 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
19405 +{
19406 +       struct vcmd_vhi_name_v0 vc_data;
19407 +       char *name;
19408 +
19409 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19410 +               return -EFAULT;
19411 +
19412 +       name = vx_vhi_name(vxi, vc_data.field);
19413 +       if (!name)
19414 +               return -EINVAL;
19415 +
19416 +       memcpy(vc_data.name, name, 65);
19417 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19418 +               return -EFAULT;
19419 +       return 0;
19420 +}
19421 +
19422 +
19423 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
19424 +{
19425 +       struct vcmd_virt_stat_v0 vc_data;
19426 +       struct _vx_cvirt *cvirt = &vxi->cvirt;
19427 +       struct timespec uptime;
19428 +
19429 +       do_posix_clock_monotonic_gettime(&uptime);
19430 +       set_normalized_timespec(&uptime,
19431 +               uptime.tv_sec - cvirt->bias_uptime.tv_sec,
19432 +               uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
19433 +
19434 +       vc_data.offset = timespec_to_ns(&cvirt->bias_ts);
19435 +       vc_data.uptime = timespec_to_ns(&uptime);
19436 +       vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
19437 +       vc_data.nr_running = atomic_read(&cvirt->nr_running);
19438 +       vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
19439 +       vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
19440 +       vc_data.nr_forks = atomic_read(&cvirt->total_forks);
19441 +       vc_data.load[0] = cvirt->load[0];
19442 +       vc_data.load[1] = cvirt->load[1];
19443 +       vc_data.load[2] = cvirt->load[2];
19444 +
19445 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19446 +               return -EFAULT;
19447 +       return 0;
19448 +}
19449 +
19450 +
19451 +#ifdef CONFIG_VSERVER_VTIME
19452 +
19453 +/* virtualized time base */
19454 +
19455 +void vx_adjust_timespec(struct timespec *ts)
19456 +{
19457 +       struct vx_info *vxi;
19458 +
19459 +       if (!vx_flags(VXF_VIRT_TIME, 0))
19460 +               return;
19461 +
19462 +       vxi = current_vx_info();
19463 +       ts->tv_sec += vxi->cvirt.bias_ts.tv_sec;
19464 +       ts->tv_nsec += vxi->cvirt.bias_ts.tv_nsec;
19465 +
19466 +       if (ts->tv_nsec >= NSEC_PER_SEC) {
19467 +               ts->tv_sec++;
19468 +               ts->tv_nsec -= NSEC_PER_SEC;
19469 +       } else if (ts->tv_nsec < 0) {
19470 +               ts->tv_sec--;
19471 +               ts->tv_nsec += NSEC_PER_SEC;
19472 +       }
19473 +}
19474 +
19475 +int vx_settimeofday(const struct timespec *ts)
19476 +{
19477 +       struct timespec ats, delta;
19478 +       struct vx_info *vxi;
19479 +
19480 +       if (!vx_flags(VXF_VIRT_TIME, 0))
19481 +               return do_settimeofday(ts);
19482 +
19483 +       getnstimeofday(&ats);
19484 +       delta = timespec_sub(*ts, ats);
19485 +
19486 +       vxi = current_vx_info();
19487 +       vxi->cvirt.bias_ts = timespec_add(vxi->cvirt.bias_ts, delta);
19488 +       return 0;
19489 +}
19490 +
19491 +#endif
19492 +
19493 diff -NurpP --minimal linux-3.0.4/kernel/vserver/cvirt_init.h linux-3.0.4-vs2.3.1/kernel/vserver/cvirt_init.h
19494 --- linux-3.0.4/kernel/vserver/cvirt_init.h     1970-01-01 01:00:00.000000000 +0100
19495 +++ linux-3.0.4-vs2.3.1/kernel/vserver/cvirt_init.h     2011-06-10 22:11:24.000000000 +0200
19496 @@ -0,0 +1,70 @@
19497 +
19498 +
19499 +extern uint64_t vx_idle_jiffies(void);
19500 +
19501 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
19502 +{
19503 +       uint64_t idle_jiffies = vx_idle_jiffies();
19504 +       uint64_t nsuptime;
19505 +
19506 +       do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
19507 +       nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
19508 +               * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
19509 +       cvirt->bias_clock = nsec_to_clock_t(nsuptime);
19510 +       cvirt->bias_ts.tv_sec = 0;
19511 +       cvirt->bias_ts.tv_nsec = 0;
19512 +
19513 +       jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
19514 +       atomic_set(&cvirt->nr_threads, 0);
19515 +       atomic_set(&cvirt->nr_running, 0);
19516 +       atomic_set(&cvirt->nr_uninterruptible, 0);
19517 +       atomic_set(&cvirt->nr_onhold, 0);
19518 +
19519 +       spin_lock_init(&cvirt->load_lock);
19520 +       cvirt->load_last = jiffies;
19521 +       atomic_set(&cvirt->load_updates, 0);
19522 +       cvirt->load[0] = 0;
19523 +       cvirt->load[1] = 0;
19524 +       cvirt->load[2] = 0;
19525 +       atomic_set(&cvirt->total_forks, 0);
19526 +
19527 +       spin_lock_init(&cvirt->syslog.logbuf_lock);
19528 +       init_waitqueue_head(&cvirt->syslog.log_wait);
19529 +       cvirt->syslog.log_start = 0;
19530 +       cvirt->syslog.log_end = 0;
19531 +       cvirt->syslog.con_start = 0;
19532 +       cvirt->syslog.logged_chars = 0;
19533 +}
19534 +
19535 +static inline
19536 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19537 +{
19538 +       // cvirt_pc->cpustat = { 0 };
19539 +}
19540 +
19541 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
19542 +{
19543 +#ifdef CONFIG_VSERVER_WARN
19544 +       int value;
19545 +#endif
19546 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
19547 +               "!!! cvirt: %p[nr_threads] = %d on exit.",
19548 +               cvirt, value);
19549 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
19550 +               "!!! cvirt: %p[nr_running] = %d on exit.",
19551 +               cvirt, value);
19552 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
19553 +               "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
19554 +               cvirt, value);
19555 +       vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
19556 +               "!!! cvirt: %p[nr_onhold] = %d on exit.",
19557 +               cvirt, value);
19558 +       return;
19559 +}
19560 +
19561 +static inline
19562 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19563 +{
19564 +       return;
19565 +}
19566 +
19567 diff -NurpP --minimal linux-3.0.4/kernel/vserver/cvirt_proc.h linux-3.0.4-vs2.3.1/kernel/vserver/cvirt_proc.h
19568 --- linux-3.0.4/kernel/vserver/cvirt_proc.h     1970-01-01 01:00:00.000000000 +0100
19569 +++ linux-3.0.4-vs2.3.1/kernel/vserver/cvirt_proc.h     2011-06-10 22:11:24.000000000 +0200
19570 @@ -0,0 +1,135 @@
19571 +#ifndef _VX_CVIRT_PROC_H
19572 +#define _VX_CVIRT_PROC_H
19573 +
19574 +#include <linux/nsproxy.h>
19575 +#include <linux/mnt_namespace.h>
19576 +#include <linux/ipc_namespace.h>
19577 +#include <linux/utsname.h>
19578 +#include <linux/ipc.h>
19579 +
19580 +
19581 +static inline
19582 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
19583 +{
19584 +       struct mnt_namespace *ns;
19585 +       struct uts_namespace *uts;
19586 +       struct ipc_namespace *ipc;
19587 +       struct path path;
19588 +       char *pstr, *root;
19589 +       int length = 0;
19590 +
19591 +       if (!nsproxy)
19592 +               goto out;
19593 +
19594 +       length += sprintf(buffer + length,
19595 +               "NSProxy:\t%p [%p,%p,%p]\n",
19596 +               nsproxy, nsproxy->mnt_ns,
19597 +               nsproxy->uts_ns, nsproxy->ipc_ns);
19598 +
19599 +       ns = nsproxy->mnt_ns;
19600 +       if (!ns)
19601 +               goto skip_ns;
19602 +
19603 +       pstr = kmalloc(PATH_MAX, GFP_KERNEL);
19604 +       if (!pstr)
19605 +               goto skip_ns;
19606 +
19607 +       path.mnt = ns->root;
19608 +       path.dentry = ns->root->mnt_root;
19609 +       root = d_path(&path, pstr, PATH_MAX - 2);
19610 +       length += sprintf(buffer + length,
19611 +               "Namespace:\t%p [#%u]\n"
19612 +               "RootPath:\t%s\n",
19613 +               ns, atomic_read(&ns->count),
19614 +               root);
19615 +       kfree(pstr);
19616 +skip_ns:
19617 +
19618 +       uts = nsproxy->uts_ns;
19619 +       if (!uts)
19620 +               goto skip_uts;
19621 +
19622 +       length += sprintf(buffer + length,
19623 +               "SysName:\t%.*s\n"
19624 +               "NodeName:\t%.*s\n"
19625 +               "Release:\t%.*s\n"
19626 +               "Version:\t%.*s\n"
19627 +               "Machine:\t%.*s\n"
19628 +               "DomainName:\t%.*s\n",
19629 +               __NEW_UTS_LEN, uts->name.sysname,
19630 +               __NEW_UTS_LEN, uts->name.nodename,
19631 +               __NEW_UTS_LEN, uts->name.release,
19632 +               __NEW_UTS_LEN, uts->name.version,
19633 +               __NEW_UTS_LEN, uts->name.machine,
19634 +               __NEW_UTS_LEN, uts->name.domainname);
19635 +skip_uts:
19636 +
19637 +       ipc = nsproxy->ipc_ns;
19638 +       if (!ipc)
19639 +               goto skip_ipc;
19640 +
19641 +       length += sprintf(buffer + length,
19642 +               "SEMS:\t\t%d %d %d %d  %d\n"
19643 +               "MSG:\t\t%d %d %d\n"
19644 +               "SHM:\t\t%lu %lu  %d %d\n",
19645 +               ipc->sem_ctls[0], ipc->sem_ctls[1],
19646 +               ipc->sem_ctls[2], ipc->sem_ctls[3],
19647 +               ipc->used_sems,
19648 +               ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
19649 +               (unsigned long)ipc->shm_ctlmax,
19650 +               (unsigned long)ipc->shm_ctlall,
19651 +               ipc->shm_ctlmni, ipc->shm_tot);
19652 +skip_ipc:
19653 +out:
19654 +       return length;
19655 +}
19656 +
19657 +
19658 +#include <linux/sched.h>
19659 +
19660 +#define LOAD_INT(x) ((x) >> FSHIFT)
19661 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
19662 +
19663 +static inline
19664 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
19665 +{
19666 +       int length = 0;
19667 +       int a, b, c;
19668 +
19669 +       length += sprintf(buffer + length,
19670 +               "BiasUptime:\t%lu.%02lu\n",
19671 +               (unsigned long)cvirt->bias_uptime.tv_sec,
19672 +               (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
19673 +
19674 +       a = cvirt->load[0] + (FIXED_1 / 200);
19675 +       b = cvirt->load[1] + (FIXED_1 / 200);
19676 +       c = cvirt->load[2] + (FIXED_1 / 200);
19677 +       length += sprintf(buffer + length,
19678 +               "nr_threads:\t%d\n"
19679 +               "nr_running:\t%d\n"
19680 +               "nr_unintr:\t%d\n"
19681 +               "nr_onhold:\t%d\n"
19682 +               "load_updates:\t%d\n"
19683 +               "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
19684 +               "total_forks:\t%d\n",
19685 +               atomic_read(&cvirt->nr_threads),
19686 +               atomic_read(&cvirt->nr_running),
19687 +               atomic_read(&cvirt->nr_uninterruptible),
19688 +               atomic_read(&cvirt->nr_onhold),
19689 +               atomic_read(&cvirt->load_updates),
19690 +               LOAD_INT(a), LOAD_FRAC(a),
19691 +               LOAD_INT(b), LOAD_FRAC(b),
19692 +               LOAD_INT(c), LOAD_FRAC(c),
19693 +               atomic_read(&cvirt->total_forks));
19694 +       return length;
19695 +}
19696 +
19697 +static inline
19698 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
19699 +       char *buffer, int cpu)
19700 +{
19701 +       int length = 0;
19702 +       return length;
19703 +}
19704 +
19705 +#endif /* _VX_CVIRT_PROC_H */
19706 diff -NurpP --minimal linux-3.0.4/kernel/vserver/debug.c linux-3.0.4-vs2.3.1/kernel/vserver/debug.c
19707 --- linux-3.0.4/kernel/vserver/debug.c  1970-01-01 01:00:00.000000000 +0100
19708 +++ linux-3.0.4-vs2.3.1/kernel/vserver/debug.c  2011-06-10 22:11:24.000000000 +0200
19709 @@ -0,0 +1,32 @@
19710 +/*
19711 + *  kernel/vserver/debug.c
19712 + *
19713 + *  Copyright (C) 2005-2007 Herbert Pötzl
19714 + *
19715 + *  V0.01  vx_info dump support
19716 + *
19717 + */
19718 +
19719 +#include <linux/module.h>
19720 +
19721 +#include <linux/vserver/context.h>
19722 +
19723 +
19724 +void   dump_vx_info(struct vx_info *vxi, int level)
19725 +{
19726 +       printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
19727 +               atomic_read(&vxi->vx_usecnt),
19728 +               atomic_read(&vxi->vx_tasks),
19729 +               vxi->vx_state);
19730 +       if (level > 0) {
19731 +               __dump_vx_limit(&vxi->limit);
19732 +               __dump_vx_sched(&vxi->sched);
19733 +               __dump_vx_cvirt(&vxi->cvirt);
19734 +               __dump_vx_cacct(&vxi->cacct);
19735 +       }
19736 +       printk("---\n");
19737 +}
19738 +
19739 +
19740 +EXPORT_SYMBOL_GPL(dump_vx_info);
19741 +
19742 diff -NurpP --minimal linux-3.0.4/kernel/vserver/device.c linux-3.0.4-vs2.3.1/kernel/vserver/device.c
19743 --- linux-3.0.4/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
19744 +++ linux-3.0.4-vs2.3.1/kernel/vserver/device.c 2011-06-10 23:20:56.000000000 +0200
19745 @@ -0,0 +1,443 @@
19746 +/*
19747 + *  linux/kernel/vserver/device.c
19748 + *
19749 + *  Linux-VServer: Device Support
19750 + *
19751 + *  Copyright (C) 2006  Herbert Pötzl
19752 + *  Copyright (C) 2007  Daniel Hokka Zakrisson
19753 + *
19754 + *  V0.01  device mapping basics
19755 + *  V0.02  added defaults
19756 + *
19757 + */
19758 +
19759 +#include <linux/slab.h>
19760 +#include <linux/rcupdate.h>
19761 +#include <linux/fs.h>
19762 +#include <linux/namei.h>
19763 +#include <linux/hash.h>
19764 +
19765 +#include <asm/errno.h>
19766 +#include <asm/uaccess.h>
19767 +#include <linux/vserver/base.h>
19768 +#include <linux/vserver/debug.h>
19769 +#include <linux/vserver/context.h>
19770 +#include <linux/vserver/device.h>
19771 +#include <linux/vserver/device_cmd.h>
19772 +
19773 +
19774 +#define DMAP_HASH_BITS 4
19775 +
19776 +
19777 +struct vs_mapping {
19778 +       union {
19779 +               struct hlist_node hlist;
19780 +               struct list_head list;
19781 +       } u;
19782 +#define dm_hlist       u.hlist
19783 +#define dm_list                u.list
19784 +       xid_t xid;
19785 +       dev_t device;
19786 +       struct vx_dmap_target target;
19787 +};
19788 +
19789 +
19790 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
19791 +
19792 +static DEFINE_SPINLOCK(dmap_main_hash_lock);
19793 +
19794 +static struct vx_dmap_target dmap_defaults[2] = {
19795 +       { .flags = DATTR_OPEN },
19796 +       { .flags = DATTR_OPEN },
19797 +};
19798 +
19799 +
19800 +struct kmem_cache *dmap_cachep __read_mostly;
19801 +
19802 +int __init dmap_cache_init(void)
19803 +{
19804 +       dmap_cachep = kmem_cache_create("dmap_cache",
19805 +               sizeof(struct vs_mapping), 0,
19806 +               SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
19807 +       return 0;
19808 +}
19809 +
19810 +__initcall(dmap_cache_init);
19811 +
19812 +
19813 +static inline unsigned int __hashval(dev_t dev, int bits)
19814 +{
19815 +       return hash_long((unsigned long)dev, bits);
19816 +}
19817 +
19818 +
19819 +/*     __hash_mapping()
19820 + *     add the mapping to the hash table
19821 + */
19822 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
19823 +{
19824 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19825 +       struct hlist_head *head, *hash = dmap_main_hash;
19826 +       int device = vdm->device;
19827 +
19828 +       spin_lock(hash_lock);
19829 +       vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
19830 +               vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
19831 +
19832 +       head = &hash[__hashval(device, DMAP_HASH_BITS)];
19833 +       hlist_add_head(&vdm->dm_hlist, head);
19834 +       spin_unlock(hash_lock);
19835 +}
19836 +
19837 +
19838 +static inline int __mode_to_default(umode_t mode)
19839 +{
19840 +       switch (mode) {
19841 +       case S_IFBLK:
19842 +               return 0;
19843 +       case S_IFCHR:
19844 +               return 1;
19845 +       default:
19846 +               BUG();
19847 +       }
19848 +}
19849 +
19850 +
19851 +/*     __set_default()
19852 + *     set a default
19853 + */
19854 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
19855 +       struct vx_dmap_target *vdmt)
19856 +{
19857 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19858 +       spin_lock(hash_lock);
19859 +
19860 +       if (vxi)
19861 +               vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
19862 +       else
19863 +               dmap_defaults[__mode_to_default(mode)] = *vdmt;
19864 +
19865 +
19866 +       spin_unlock(hash_lock);
19867 +
19868 +       vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
19869 +                 vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
19870 +}
19871 +
19872 +
19873 +/*     __remove_default()
19874 + *     remove a default
19875 + */
19876 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
19877 +{
19878 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19879 +       spin_lock(hash_lock);
19880 +
19881 +       if (vxi)
19882 +               vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
19883 +       else    /* remove == reset */
19884 +               dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
19885 +
19886 +       spin_unlock(hash_lock);
19887 +       return 0;
19888 +}
19889 +
19890 +
19891 +/*     __find_mapping()
19892 + *     find a mapping in the hash table
19893 + *
19894 + *     caller must hold hash_lock
19895 + */
19896 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
19897 +       struct vs_mapping **local, struct vs_mapping **global)
19898 +{
19899 +       struct hlist_head *hash = dmap_main_hash;
19900 +       struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
19901 +       struct hlist_node *pos;
19902 +       struct vs_mapping *vdm;
19903 +
19904 +       *local = NULL;
19905 +       if (global)
19906 +               *global = NULL;
19907 +
19908 +       hlist_for_each(pos, head) {
19909 +               vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
19910 +
19911 +               if ((vdm->device == device) &&
19912 +                       !((vdm->target.flags ^ mode) & S_IFMT)) {
19913 +                       if (vdm->xid == xid) {
19914 +                               *local = vdm;
19915 +                               return 1;
19916 +                       } else if (global && vdm->xid == 0)
19917 +                               *global = vdm;
19918 +               }
19919 +       }
19920 +
19921 +       if (global && *global)
19922 +               return 0;
19923 +       else
19924 +               return -ENOENT;
19925 +}
19926 +
19927 +
19928 +/*     __lookup_mapping()
19929 + *     find a mapping and store the result in target and flags
19930 + */
19931 +static inline int __lookup_mapping(struct vx_info *vxi,
19932 +       dev_t device, dev_t *target, int *flags, umode_t mode)
19933 +{
19934 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19935 +       struct vs_mapping *vdm, *global;
19936 +       struct vx_dmap_target *vdmt;
19937 +       int ret = 0;
19938 +       xid_t xid = vxi->vx_id;
19939 +       int index;
19940 +
19941 +       spin_lock(hash_lock);
19942 +       if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
19943 +               ret = 1;
19944 +               vdmt = &vdm->target;
19945 +               goto found;
19946 +       }
19947 +
19948 +       index = __mode_to_default(mode);
19949 +       if (vxi && vxi->dmap.targets[index].flags) {
19950 +               ret = 2;
19951 +               vdmt = &vxi->dmap.targets[index];
19952 +       } else if (global) {
19953 +               ret = 3;
19954 +               vdmt = &global->target;
19955 +               goto found;
19956 +       } else {
19957 +               ret = 4;
19958 +               vdmt = &dmap_defaults[index];
19959 +       }
19960 +
19961 +found:
19962 +       if (target && (vdmt->flags & DATTR_REMAP))
19963 +               *target = vdmt->target;
19964 +       else if (target)
19965 +               *target = device;
19966 +       if (flags)
19967 +               *flags = vdmt->flags;
19968 +
19969 +       spin_unlock(hash_lock);
19970 +
19971 +       return ret;
19972 +}
19973 +
19974 +
19975 +/*     __remove_mapping()
19976 + *     remove a mapping from the hash table
19977 + */
19978 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
19979 +       umode_t mode)
19980 +{
19981 +       spinlock_t *hash_lock = &dmap_main_hash_lock;
19982 +       struct vs_mapping *vdm = NULL;
19983 +       int ret = 0;
19984 +
19985 +       spin_lock(hash_lock);
19986 +
19987 +       ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
19988 +               NULL);
19989 +       vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
19990 +               vxi, vxi ? vxi->vx_id : 0, device, mode);
19991 +       if (ret < 0)
19992 +               goto out;
19993 +       hlist_del(&vdm->dm_hlist);
19994 +
19995 +out:
19996 +       spin_unlock(hash_lock);
19997 +       if (vdm)
19998 +               kmem_cache_free(dmap_cachep, vdm);
19999 +       return ret;
20000 +}
20001 +
20002 +
20003 +
20004 +int vs_map_device(struct vx_info *vxi,
20005 +       dev_t device, dev_t *target, umode_t mode)
20006 +{
20007 +       int ret, flags = DATTR_MASK;
20008 +
20009 +       if (!vxi) {
20010 +               if (target)
20011 +                       *target = device;
20012 +               goto out;
20013 +       }
20014 +       ret = __lookup_mapping(vxi, device, target, &flags, mode);
20015 +       vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
20016 +               device, target ? *target : 0, flags, mode, ret);
20017 +out:
20018 +       return (flags & DATTR_MASK);
20019 +}
20020 +
20021 +
20022 +
20023 +static int do_set_mapping(struct vx_info *vxi,
20024 +       dev_t device, dev_t target, int flags, umode_t mode)
20025 +{
20026 +       if (device) {
20027 +               struct vs_mapping *new;
20028 +
20029 +               new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
20030 +               if (!new)
20031 +                       return -ENOMEM;
20032 +
20033 +               INIT_HLIST_NODE(&new->dm_hlist);
20034 +               new->device = device;
20035 +               new->target.target = target;
20036 +               new->target.flags = flags | mode;
20037 +               new->xid = (vxi ? vxi->vx_id : 0);
20038 +
20039 +               vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
20040 +               __hash_mapping(vxi, new);
20041 +       } else {
20042 +               struct vx_dmap_target new = {
20043 +                       .target = target,
20044 +                       .flags = flags | mode,
20045 +               };
20046 +               __set_default(vxi, mode, &new);
20047 +       }
20048 +       return 0;
20049 +}
20050 +
20051 +
20052 +static int do_unset_mapping(struct vx_info *vxi,
20053 +       dev_t device, dev_t target, int flags, umode_t mode)
20054 +{
20055 +       int ret = -EINVAL;
20056 +
20057 +       if (device) {
20058 +               ret = __remove_mapping(vxi, device, mode);
20059 +               if (ret < 0)
20060 +                       goto out;
20061 +       } else {
20062 +               ret = __remove_default(vxi, mode);
20063 +               if (ret < 0)
20064 +                       goto out;
20065 +       }
20066 +
20067 +out:
20068 +       return ret;
20069 +}
20070 +
20071 +
20072 +static inline int __user_device(const char __user *name, dev_t *dev,
20073 +       umode_t *mode)
20074 +{
20075 +       struct nameidata nd;
20076 +       int ret;
20077 +
20078 +       if (!name) {
20079 +               *dev = 0;
20080 +               return 0;
20081 +       }
20082 +       ret = user_lpath(name, &nd.path);
20083 +       if (ret)
20084 +               return ret;
20085 +       if (nd.path.dentry->d_inode) {
20086 +               *dev = nd.path.dentry->d_inode->i_rdev;
20087 +               *mode = nd.path.dentry->d_inode->i_mode;
20088 +       }
20089 +       path_put(&nd.path);
20090 +       return 0;
20091 +}
20092 +
20093 +static inline int __mapping_mode(dev_t device, dev_t target,
20094 +       umode_t device_mode, umode_t target_mode, umode_t *mode)
20095 +{
20096 +       if (device)
20097 +               *mode = device_mode & S_IFMT;
20098 +       else if (target)
20099 +               *mode = target_mode & S_IFMT;
20100 +       else
20101 +               return -EINVAL;
20102 +
20103 +       /* if both given, device and target mode have to match */
20104 +       if (device && target &&
20105 +               ((device_mode ^ target_mode) & S_IFMT))
20106 +               return -EINVAL;
20107 +       return 0;
20108 +}
20109 +
20110 +
20111 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
20112 +       const char __user *target_path, int flags, int set)
20113 +{
20114 +       dev_t device = ~0, target = ~0;
20115 +       umode_t device_mode = 0, target_mode = 0, mode;
20116 +       int ret;
20117 +
20118 +       ret = __user_device(device_path, &device, &device_mode);
20119 +       if (ret)
20120 +               return ret;
20121 +       ret = __user_device(target_path, &target, &target_mode);
20122 +       if (ret)
20123 +               return ret;
20124 +
20125 +       ret = __mapping_mode(device, target,
20126 +               device_mode, target_mode, &mode);
20127 +       if (ret)
20128 +               return ret;
20129 +
20130 +       if (set)
20131 +               return do_set_mapping(vxi, device, target,
20132 +                       flags, mode);
20133 +       else
20134 +               return do_unset_mapping(vxi, device, target,
20135 +                       flags, mode);
20136 +}
20137 +
20138 +
20139 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
20140 +{
20141 +       struct vcmd_set_mapping_v0 vc_data;
20142 +
20143 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20144 +               return -EFAULT;
20145 +
20146 +       return do_mapping(vxi, vc_data.device, vc_data.target,
20147 +               vc_data.flags, 1);
20148 +}
20149 +
20150 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
20151 +{
20152 +       struct vcmd_set_mapping_v0 vc_data;
20153 +
20154 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20155 +               return -EFAULT;
20156 +
20157 +       return do_mapping(vxi, vc_data.device, vc_data.target,
20158 +               vc_data.flags, 0);
20159 +}
20160 +
20161 +
20162 +#ifdef CONFIG_COMPAT
20163 +
20164 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
20165 +{
20166 +       struct vcmd_set_mapping_v0_x32 vc_data;
20167 +
20168 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20169 +               return -EFAULT;
20170 +
20171 +       return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
20172 +               compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
20173 +}
20174 +
20175 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
20176 +{
20177 +       struct vcmd_set_mapping_v0_x32 vc_data;
20178 +
20179 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20180 +               return -EFAULT;
20181 +
20182 +       return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
20183 +               compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
20184 +}
20185 +
20186 +#endif /* CONFIG_COMPAT */
20187 +
20188 +
20189 diff -NurpP --minimal linux-3.0.4/kernel/vserver/dlimit.c linux-3.0.4-vs2.3.1/kernel/vserver/dlimit.c
20190 --- linux-3.0.4/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
20191 +++ linux-3.0.4-vs2.3.1/kernel/vserver/dlimit.c 2011-06-10 23:20:56.000000000 +0200
20192 @@ -0,0 +1,531 @@
20193 +/*
20194 + *  linux/kernel/vserver/dlimit.c
20195 + *
20196 + *  Virtual Server: Context Disk Limits
20197 + *
20198 + *  Copyright (C) 2004-2009  Herbert Pötzl
20199 + *
20200 + *  V0.01  initial version
20201 + *  V0.02  compat32 splitup
20202 + *  V0.03  extended interface
20203 + *
20204 + */
20205 +
20206 +#include <linux/statfs.h>
20207 +#include <linux/sched.h>
20208 +#include <linux/namei.h>
20209 +#include <linux/vs_tag.h>
20210 +#include <linux/vs_dlimit.h>
20211 +#include <linux/vserver/dlimit_cmd.h>
20212 +#include <linux/slab.h>
20213 +// #include <linux/gfp.h>
20214 +
20215 +#include <asm/uaccess.h>
20216 +
20217 +/*     __alloc_dl_info()
20218 +
20219 +       * allocate an initialized dl_info struct
20220 +       * doesn't make it visible (hash)                        */
20221 +
20222 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
20223 +{
20224 +       struct dl_info *new = NULL;
20225 +
20226 +       vxdprintk(VXD_CBIT(dlim, 5),
20227 +               "alloc_dl_info(%p,%d)*", sb, tag);
20228 +
20229 +       /* would this benefit from a slab cache? */
20230 +       new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
20231 +       if (!new)
20232 +               return 0;
20233 +
20234 +       memset(new, 0, sizeof(struct dl_info));
20235 +       new->dl_tag = tag;
20236 +       new->dl_sb = sb;
20237 +       // INIT_RCU_HEAD(&new->dl_rcu);
20238 +       INIT_HLIST_NODE(&new->dl_hlist);
20239 +       spin_lock_init(&new->dl_lock);
20240 +       atomic_set(&new->dl_refcnt, 0);
20241 +       atomic_set(&new->dl_usecnt, 0);
20242 +
20243 +       /* rest of init goes here */
20244 +
20245 +       vxdprintk(VXD_CBIT(dlim, 4),
20246 +               "alloc_dl_info(%p,%d) = %p", sb, tag, new);
20247 +       return new;
20248 +}
20249 +
20250 +/*     __dealloc_dl_info()
20251 +
20252 +       * final disposal of dl_info                             */
20253 +
20254 +static void __dealloc_dl_info(struct dl_info *dli)
20255 +{
20256 +       vxdprintk(VXD_CBIT(dlim, 4),
20257 +               "dealloc_dl_info(%p)", dli);
20258 +
20259 +       dli->dl_hlist.next = LIST_POISON1;
20260 +       dli->dl_tag = -1;
20261 +       dli->dl_sb = 0;
20262 +
20263 +       BUG_ON(atomic_read(&dli->dl_usecnt));
20264 +       BUG_ON(atomic_read(&dli->dl_refcnt));
20265 +
20266 +       kfree(dli);
20267 +}
20268 +
20269 +
20270 +/*     hash table for dl_info hash */
20271 +
20272 +#define DL_HASH_SIZE   13
20273 +
20274 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
20275 +
20276 +static DEFINE_SPINLOCK(dl_info_hash_lock);
20277 +
20278 +
20279 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
20280 +{
20281 +       return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
20282 +}
20283 +
20284 +
20285 +
20286 +/*     __hash_dl_info()
20287 +
20288 +       * add the dli to the global hash table
20289 +       * requires the hash_lock to be held                     */
20290 +
20291 +static inline void __hash_dl_info(struct dl_info *dli)
20292 +{
20293 +       struct hlist_head *head;
20294 +
20295 +       vxdprintk(VXD_CBIT(dlim, 6),
20296 +               "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
20297 +       get_dl_info(dli);
20298 +       head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
20299 +       hlist_add_head_rcu(&dli->dl_hlist, head);
20300 +}
20301 +
20302 +/*     __unhash_dl_info()
20303 +
20304 +       * remove the dli from the global hash table
20305 +       * requires the hash_lock to be held                     */
20306 +
20307 +static inline void __unhash_dl_info(struct dl_info *dli)
20308 +{
20309 +       vxdprintk(VXD_CBIT(dlim, 6),
20310 +               "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
20311 +       hlist_del_rcu(&dli->dl_hlist);
20312 +       put_dl_info(dli);
20313 +}
20314 +
20315 +
20316 +/*     __lookup_dl_info()
20317 +
20318 +       * requires the rcu_read_lock()
20319 +       * doesn't increment the dl_refcnt                       */
20320 +
20321 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
20322 +{
20323 +       struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
20324 +       struct hlist_node *pos;
20325 +       struct dl_info *dli;
20326 +
20327 +       hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
20328 +
20329 +               if (dli->dl_tag == tag && dli->dl_sb == sb) {
20330 +                       return dli;
20331 +               }
20332 +       }
20333 +       return NULL;
20334 +}
20335 +
20336 +
20337 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
20338 +{
20339 +       struct dl_info *dli;
20340 +
20341 +       rcu_read_lock();
20342 +       dli = get_dl_info(__lookup_dl_info(sb, tag));
20343 +       vxdprintk(VXD_CBIT(dlim, 7),
20344 +               "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
20345 +       rcu_read_unlock();
20346 +       return dli;
20347 +}
20348 +
20349 +void rcu_free_dl_info(struct rcu_head *head)
20350 +{
20351 +       struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
20352 +       int usecnt, refcnt;
20353 +
20354 +       BUG_ON(!dli || !head);
20355 +
20356 +       usecnt = atomic_read(&dli->dl_usecnt);
20357 +       BUG_ON(usecnt < 0);
20358 +
20359 +       refcnt = atomic_read(&dli->dl_refcnt);
20360 +       BUG_ON(refcnt < 0);
20361 +
20362 +       vxdprintk(VXD_CBIT(dlim, 3),
20363 +               "rcu_free_dl_info(%p)", dli);
20364 +       if (!usecnt)
20365 +               __dealloc_dl_info(dli);
20366 +       else
20367 +               printk("!!! rcu didn't free\n");
20368 +}
20369 +
20370 +
20371 +
20372 +
20373 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
20374 +       uint32_t flags, int add)
20375 +{
20376 +       struct path path;
20377 +       int ret;
20378 +
20379 +       ret = user_lpath(name, &path);
20380 +       if (!ret) {
20381 +               struct super_block *sb;
20382 +               struct dl_info *dli;
20383 +
20384 +               ret = -EINVAL;
20385 +               if (!path.dentry->d_inode)
20386 +                       goto out_release;
20387 +               if (!(sb = path.dentry->d_inode->i_sb))
20388 +                       goto out_release;
20389 +
20390 +               if (add) {
20391 +                       dli = __alloc_dl_info(sb, id);
20392 +                       spin_lock(&dl_info_hash_lock);
20393 +
20394 +                       ret = -EEXIST;
20395 +                       if (__lookup_dl_info(sb, id))
20396 +                               goto out_unlock;
20397 +                       __hash_dl_info(dli);
20398 +                       dli = NULL;
20399 +               } else {
20400 +                       spin_lock(&dl_info_hash_lock);
20401 +                       dli = __lookup_dl_info(sb, id);
20402 +
20403 +                       ret = -ESRCH;
20404 +                       if (!dli)
20405 +                               goto out_unlock;
20406 +                       __unhash_dl_info(dli);
20407 +               }
20408 +               ret = 0;
20409 +       out_unlock:
20410 +               spin_unlock(&dl_info_hash_lock);
20411 +               if (add && dli)
20412 +                       __dealloc_dl_info(dli);
20413 +       out_release:
20414 +               path_put(&path);
20415 +       }
20416 +       return ret;
20417 +}
20418 +
20419 +int vc_add_dlimit(uint32_t id, void __user *data)
20420 +{
20421 +       struct vcmd_ctx_dlimit_base_v0 vc_data;
20422 +
20423 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20424 +               return -EFAULT;
20425 +
20426 +       return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
20427 +}
20428 +
20429 +int vc_rem_dlimit(uint32_t id, void __user *data)
20430 +{
20431 +       struct vcmd_ctx_dlimit_base_v0 vc_data;
20432 +
20433 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20434 +               return -EFAULT;
20435 +
20436 +       return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
20437 +}
20438 +
20439 +#ifdef CONFIG_COMPAT
20440 +
20441 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
20442 +{
20443 +       struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
20444 +
20445 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20446 +               return -EFAULT;
20447 +
20448 +       return do_addrem_dlimit(id,
20449 +               compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
20450 +}
20451 +
20452 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
20453 +{
20454 +       struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
20455 +
20456 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20457 +               return -EFAULT;
20458 +
20459 +       return do_addrem_dlimit(id,
20460 +               compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
20461 +}
20462 +
20463 +#endif /* CONFIG_COMPAT */
20464 +
20465 +
20466 +static inline
20467 +int do_set_dlimit(uint32_t id, const char __user *name,
20468 +       uint32_t space_used, uint32_t space_total,
20469 +       uint32_t inodes_used, uint32_t inodes_total,
20470 +       uint32_t reserved, uint32_t flags)
20471 +{
20472 +       struct path path;
20473 +       int ret;
20474 +
20475 +       ret = user_lpath(name, &path);
20476 +       if (!ret) {
20477 +               struct super_block *sb;
20478 +               struct dl_info *dli;
20479 +
20480 +               ret = -EINVAL;
20481 +               if (!path.dentry->d_inode)
20482 +                       goto out_release;
20483 +               if (!(sb = path.dentry->d_inode->i_sb))
20484 +                       goto out_release;
20485 +
20486 +               /* sanity checks */
20487 +               if ((reserved != CDLIM_KEEP &&
20488 +                       reserved > 100) ||
20489 +                       (inodes_used != CDLIM_KEEP &&
20490 +                       inodes_used > inodes_total) ||
20491 +                       (space_used != CDLIM_KEEP &&
20492 +                       space_used > space_total))
20493 +                       goto out_release;
20494 +
20495 +               ret = -ESRCH;
20496 +               dli = locate_dl_info(sb, id);
20497 +               if (!dli)
20498 +                       goto out_release;
20499 +
20500 +               spin_lock(&dli->dl_lock);
20501 +
20502 +               if (inodes_used != CDLIM_KEEP)
20503 +                       dli->dl_inodes_used = inodes_used;
20504 +               if (inodes_total != CDLIM_KEEP)
20505 +                       dli->dl_inodes_total = inodes_total;
20506 +               if (space_used != CDLIM_KEEP)
20507 +                       dli->dl_space_used = dlimit_space_32to64(
20508 +                               space_used, flags, DLIMS_USED);
20509 +
20510 +               if (space_total == CDLIM_INFINITY)
20511 +                       dli->dl_space_total = DLIM_INFINITY;
20512 +               else if (space_total != CDLIM_KEEP)
20513 +                       dli->dl_space_total = dlimit_space_32to64(
20514 +                               space_total, flags, DLIMS_TOTAL);
20515 +
20516 +               if (reserved != CDLIM_KEEP)
20517 +                       dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
20518 +
20519 +               spin_unlock(&dli->dl_lock);
20520 +
20521 +               put_dl_info(dli);
20522 +               ret = 0;
20523 +
20524 +       out_release:
20525 +               path_put(&path);
20526 +       }
20527 +       return ret;
20528 +}
20529 +
20530 +int vc_set_dlimit(uint32_t id, void __user *data)
20531 +{
20532 +       struct vcmd_ctx_dlimit_v0 vc_data;
20533 +
20534 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20535 +               return -EFAULT;
20536 +
20537 +       return do_set_dlimit(id, vc_data.name,
20538 +               vc_data.space_used, vc_data.space_total,
20539 +               vc_data.inodes_used, vc_data.inodes_total,
20540 +               vc_data.reserved, vc_data.flags);
20541 +}
20542 +
20543 +#ifdef CONFIG_COMPAT
20544 +
20545 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
20546 +{
20547 +       struct vcmd_ctx_dlimit_v0_x32 vc_data;
20548 +
20549 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20550 +               return -EFAULT;
20551 +
20552 +       return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
20553 +               vc_data.space_used, vc_data.space_total,
20554 +               vc_data.inodes_used, vc_data.inodes_total,
20555 +               vc_data.reserved, vc_data.flags);
20556 +}
20557 +
20558 +#endif /* CONFIG_COMPAT */
20559 +
20560 +
20561 +static inline
20562 +int do_get_dlimit(uint32_t id, const char __user *name,
20563 +       uint32_t *space_used, uint32_t *space_total,
20564 +       uint32_t *inodes_used, uint32_t *inodes_total,
20565 +       uint32_t *reserved, uint32_t *flags)
20566 +{
20567 +       struct path path;
20568 +       int ret;
20569 +
20570 +       ret = user_lpath(name, &path);
20571 +       if (!ret) {
20572 +               struct super_block *sb;
20573 +               struct dl_info *dli;
20574 +
20575 +               ret = -EINVAL;
20576 +               if (!path.dentry->d_inode)
20577 +                       goto out_release;
20578 +               if (!(sb = path.dentry->d_inode->i_sb))
20579 +                       goto out_release;
20580 +
20581 +               ret = -ESRCH;
20582 +               dli = locate_dl_info(sb, id);
20583 +               if (!dli)
20584 +                       goto out_release;
20585 +
20586 +               spin_lock(&dli->dl_lock);
20587 +               *inodes_used = dli->dl_inodes_used;
20588 +               *inodes_total = dli->dl_inodes_total;
20589 +
20590 +               *space_used = dlimit_space_64to32(
20591 +                       dli->dl_space_used, flags, DLIMS_USED);
20592 +
20593 +               if (dli->dl_space_total == DLIM_INFINITY)
20594 +                       *space_total = CDLIM_INFINITY;
20595 +               else
20596 +                       *space_total = dlimit_space_64to32(
20597 +                               dli->dl_space_total, flags, DLIMS_TOTAL);
20598 +
20599 +               *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
20600 +               spin_unlock(&dli->dl_lock);
20601 +
20602 +               put_dl_info(dli);
20603 +               ret = -EFAULT;
20604 +
20605 +               ret = 0;
20606 +       out_release:
20607 +               path_put(&path);
20608 +       }
20609 +       return ret;
20610 +}
20611 +
20612 +
20613 +int vc_get_dlimit(uint32_t id, void __user *data)
20614 +{
20615 +       struct vcmd_ctx_dlimit_v0 vc_data;
20616 +       int ret;
20617 +
20618 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20619 +               return -EFAULT;
20620 +
20621 +       ret = do_get_dlimit(id, vc_data.name,
20622 +               &vc_data.space_used, &vc_data.space_total,
20623 +               &vc_data.inodes_used, &vc_data.inodes_total,
20624 +               &vc_data.reserved, &vc_data.flags);
20625 +       if (ret)
20626 +               return ret;
20627 +
20628 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20629 +               return -EFAULT;
20630 +       return 0;
20631 +}
20632 +
20633 +#ifdef CONFIG_COMPAT
20634 +
20635 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
20636 +{
20637 +       struct vcmd_ctx_dlimit_v0_x32 vc_data;
20638 +       int ret;
20639 +
20640 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20641 +               return -EFAULT;
20642 +
20643 +       ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
20644 +               &vc_data.space_used, &vc_data.space_total,
20645 +               &vc_data.inodes_used, &vc_data.inodes_total,
20646 +               &vc_data.reserved, &vc_data.flags);
20647 +       if (ret)
20648 +               return ret;
20649 +
20650 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20651 +               return -EFAULT;
20652 +       return 0;
20653 +}
20654 +
20655 +#endif /* CONFIG_COMPAT */
20656 +
20657 +
20658 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
20659 +{
20660 +       struct dl_info *dli;
20661 +       __u64 blimit, bfree, bavail;
20662 +       __u32 ifree;
20663 +
20664 +       dli = locate_dl_info(sb, dx_current_tag());
20665 +       if (!dli)
20666 +               return;
20667 +
20668 +       spin_lock(&dli->dl_lock);
20669 +       if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
20670 +               goto no_ilim;
20671 +
20672 +       /* reduce max inodes available to limit */
20673 +       if (buf->f_files > dli->dl_inodes_total)
20674 +               buf->f_files = dli->dl_inodes_total;
20675 +
20676 +       ifree = dli->dl_inodes_total - dli->dl_inodes_used;
20677 +       /* reduce free inodes to min */
20678 +       if (ifree < buf->f_ffree)
20679 +               buf->f_ffree = ifree;
20680 +
20681 +no_ilim:
20682 +       if (dli->dl_space_total == DLIM_INFINITY)
20683 +               goto no_blim;
20684 +
20685 +       blimit = dli->dl_space_total >> sb->s_blocksize_bits;
20686 +
20687 +       if (dli->dl_space_total < dli->dl_space_used)
20688 +               bfree = 0;
20689 +       else
20690 +               bfree = (dli->dl_space_total - dli->dl_space_used)
20691 +                       >> sb->s_blocksize_bits;
20692 +
20693 +       bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
20694 +       if (bavail < dli->dl_space_used)
20695 +               bavail = 0;
20696 +       else
20697 +               bavail = (bavail - dli->dl_space_used)
20698 +                       >> sb->s_blocksize_bits;
20699 +
20700 +       /* reduce max space available to limit */
20701 +       if (buf->f_blocks > blimit)
20702 +               buf->f_blocks = blimit;
20703 +
20704 +       /* reduce free space to min */
20705 +       if (bfree < buf->f_bfree)
20706 +               buf->f_bfree = bfree;
20707 +
20708 +       /* reduce avail space to min */
20709 +       if (bavail < buf->f_bavail)
20710 +               buf->f_bavail = bavail;
20711 +
20712 +no_blim:
20713 +       spin_unlock(&dli->dl_lock);
20714 +       put_dl_info(dli);
20715 +
20716 +       return;
20717 +}
20718 +
20719 +#include <linux/module.h>
20720 +
20721 +EXPORT_SYMBOL_GPL(locate_dl_info);
20722 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
20723 +
20724 diff -NurpP --minimal linux-3.0.4/kernel/vserver/helper.c linux-3.0.4-vs2.3.1/kernel/vserver/helper.c
20725 --- linux-3.0.4/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
20726 +++ linux-3.0.4-vs2.3.1/kernel/vserver/helper.c 2011-06-10 22:11:24.000000000 +0200
20727 @@ -0,0 +1,223 @@
20728 +/*
20729 + *  linux/kernel/vserver/helper.c
20730 + *
20731 + *  Virtual Context Support
20732 + *
20733 + *  Copyright (C) 2004-2007  Herbert Pötzl
20734 + *
20735 + *  V0.01  basic helper
20736 + *
20737 + */
20738 +
20739 +#include <linux/kmod.h>
20740 +#include <linux/reboot.h>
20741 +#include <linux/vs_context.h>
20742 +#include <linux/vs_network.h>
20743 +#include <linux/vserver/signal.h>
20744 +
20745 +
20746 +char vshelper_path[255] = "/sbin/vshelper";
20747 +
20748 +
20749 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
20750 +{
20751 +       int ret;
20752 +
20753 +       if ((ret = call_usermodehelper(name, argv, envp, sync))) {
20754 +               printk( KERN_WARNING
20755 +                       "%s: (%s %s) returned %s with %d\n",
20756 +                       name, argv[1], argv[2],
20757 +                       sync ? "sync" : "async", ret);
20758 +       }
20759 +       vxdprintk(VXD_CBIT(switch, 4),
20760 +               "%s: (%s %s) returned %s with %d",
20761 +               name, argv[1], argv[2], sync ? "sync" : "async", ret);
20762 +       return ret;
20763 +}
20764 +
20765 +/*
20766 + *      vshelper path is set via /proc/sys
20767 + *      invoked by vserver sys_reboot(), with
20768 + *      the following arguments
20769 + *
20770 + *      argv [0] = vshelper_path;
20771 + *      argv [1] = action: "restart", "halt", "poweroff", ...
20772 + *      argv [2] = context identifier
20773 + *
20774 + *      envp [*] = type-specific parameters
20775 + */
20776 +
20777 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
20778 +{
20779 +       char id_buf[8], cmd_buf[16];
20780 +       char uid_buf[16], pid_buf[16];
20781 +       int ret;
20782 +
20783 +       char *argv[] = {vshelper_path, NULL, id_buf, 0};
20784 +       char *envp[] = {"HOME=/", "TERM=linux",
20785 +                       "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
20786 +                       uid_buf, pid_buf, cmd_buf, 0};
20787 +
20788 +       if (vx_info_state(vxi, VXS_HELPER))
20789 +               return -EAGAIN;
20790 +       vxi->vx_state |= VXS_HELPER;
20791 +
20792 +       snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20793 +
20794 +       snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20795 +       snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
20796 +       snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
20797 +
20798 +       switch (cmd) {
20799 +       case LINUX_REBOOT_CMD_RESTART:
20800 +               argv[1] = "restart";
20801 +               break;
20802 +
20803 +       case LINUX_REBOOT_CMD_HALT:
20804 +               argv[1] = "halt";
20805 +               break;
20806 +
20807 +       case LINUX_REBOOT_CMD_POWER_OFF:
20808 +               argv[1] = "poweroff";
20809 +               break;
20810 +
20811 +       case LINUX_REBOOT_CMD_SW_SUSPEND:
20812 +               argv[1] = "swsusp";
20813 +               break;
20814 +
20815 +       case LINUX_REBOOT_CMD_OOM:
20816 +               argv[1] = "oom";
20817 +               break;
20818 +
20819 +       default:
20820 +               vxi->vx_state &= ~VXS_HELPER;
20821 +               return 0;
20822 +       }
20823 +
20824 +       ret = do_vshelper(vshelper_path, argv, envp, 0);
20825 +       vxi->vx_state &= ~VXS_HELPER;
20826 +       __wakeup_vx_info(vxi);
20827 +       return (ret) ? -EPERM : 0;
20828 +}
20829 +
20830 +
20831 +long vs_reboot(unsigned int cmd, void __user *arg)
20832 +{
20833 +       struct vx_info *vxi = current_vx_info();
20834 +       long ret = 0;
20835 +
20836 +       vxdprintk(VXD_CBIT(misc, 5),
20837 +               "vs_reboot(%p[#%d],%u)",
20838 +               vxi, vxi ? vxi->vx_id : 0, cmd);
20839 +
20840 +       ret = vs_reboot_helper(vxi, cmd, arg);
20841 +       if (ret)
20842 +               return ret;
20843 +
20844 +       vxi->reboot_cmd = cmd;
20845 +       if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20846 +               switch (cmd) {
20847 +               case LINUX_REBOOT_CMD_RESTART:
20848 +               case LINUX_REBOOT_CMD_HALT:
20849 +               case LINUX_REBOOT_CMD_POWER_OFF:
20850 +                       vx_info_kill(vxi, 0, SIGKILL);
20851 +                       vx_info_kill(vxi, 1, SIGKILL);
20852 +               default:
20853 +                       break;
20854 +               }
20855 +       }
20856 +       return 0;
20857 +}
20858 +
20859 +long vs_oom_action(unsigned int cmd)
20860 +{
20861 +       struct vx_info *vxi = current_vx_info();
20862 +       long ret = 0;
20863 +
20864 +       vxdprintk(VXD_CBIT(misc, 5),
20865 +               "vs_oom_action(%p[#%d],%u)",
20866 +               vxi, vxi ? vxi->vx_id : 0, cmd);
20867 +
20868 +       ret = vs_reboot_helper(vxi, cmd, NULL);
20869 +       if (ret)
20870 +               return ret;
20871 +
20872 +       vxi->reboot_cmd = cmd;
20873 +       if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20874 +               vx_info_kill(vxi, 0, SIGKILL);
20875 +               vx_info_kill(vxi, 1, SIGKILL);
20876 +       }
20877 +       return 0;
20878 +}
20879 +
20880 +/*
20881 + *      argv [0] = vshelper_path;
20882 + *      argv [1] = action: "startup", "shutdown"
20883 + *      argv [2] = context identifier
20884 + *
20885 + *      envp [*] = type-specific parameters
20886 + */
20887 +
20888 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
20889 +{
20890 +       char id_buf[8], cmd_buf[16];
20891 +       char *argv[] = {vshelper_path, NULL, id_buf, 0};
20892 +       char *envp[] = {"HOME=/", "TERM=linux",
20893 +                       "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20894 +
20895 +       if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
20896 +               return 0;
20897 +
20898 +       snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20899 +       snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20900 +
20901 +       switch (cmd) {
20902 +       case VSC_STARTUP:
20903 +               argv[1] = "startup";
20904 +               break;
20905 +       case VSC_SHUTDOWN:
20906 +               argv[1] = "shutdown";
20907 +               break;
20908 +       default:
20909 +               return 0;
20910 +       }
20911 +
20912 +       return do_vshelper(vshelper_path, argv, envp, 1);
20913 +}
20914 +
20915 +
20916 +/*
20917 + *      argv [0] = vshelper_path;
20918 + *      argv [1] = action: "netup", "netdown"
20919 + *      argv [2] = context identifier
20920 + *
20921 + *      envp [*] = type-specific parameters
20922 + */
20923 +
20924 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
20925 +{
20926 +       char id_buf[8], cmd_buf[16];
20927 +       char *argv[] = {vshelper_path, NULL, id_buf, 0};
20928 +       char *envp[] = {"HOME=/", "TERM=linux",
20929 +                       "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20930 +
20931 +       if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
20932 +               return 0;
20933 +
20934 +       snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
20935 +       snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20936 +
20937 +       switch (cmd) {
20938 +       case VSC_NETUP:
20939 +               argv[1] = "netup";
20940 +               break;
20941 +       case VSC_NETDOWN:
20942 +               argv[1] = "netdown";
20943 +               break;
20944 +       default:
20945 +               return 0;
20946 +       }
20947 +
20948 +       return do_vshelper(vshelper_path, argv, envp, 1);
20949 +}
20950 +
20951 diff -NurpP --minimal linux-3.0.4/kernel/vserver/history.c linux-3.0.4-vs2.3.1/kernel/vserver/history.c
20952 --- linux-3.0.4/kernel/vserver/history.c        1970-01-01 01:00:00.000000000 +0100
20953 +++ linux-3.0.4-vs2.3.1/kernel/vserver/history.c        2011-06-10 22:11:24.000000000 +0200
20954 @@ -0,0 +1,258 @@
20955 +/*
20956 + *  kernel/vserver/history.c
20957 + *
20958 + *  Virtual Context History Backtrace
20959 + *
20960 + *  Copyright (C) 2004-2007  Herbert Pötzl
20961 + *
20962 + *  V0.01  basic structure
20963 + *  V0.02  hash/unhash and trace
20964 + *  V0.03  preemption fixes
20965 + *
20966 + */
20967 +
20968 +#include <linux/module.h>
20969 +#include <asm/uaccess.h>
20970 +
20971 +#include <linux/vserver/context.h>
20972 +#include <linux/vserver/debug.h>
20973 +#include <linux/vserver/debug_cmd.h>
20974 +#include <linux/vserver/history.h>
20975 +
20976 +
20977 +#ifdef CONFIG_VSERVER_HISTORY
20978 +#define VXH_SIZE       CONFIG_VSERVER_HISTORY_SIZE
20979 +#else
20980 +#define VXH_SIZE       64
20981 +#endif
20982 +
20983 +struct _vx_history {
20984 +       unsigned int counter;
20985 +
20986 +       struct _vx_hist_entry entry[VXH_SIZE + 1];
20987 +};
20988 +
20989 +
20990 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
20991 +
20992 +unsigned volatile int vxh_active = 1;
20993 +
20994 +static atomic_t sequence = ATOMIC_INIT(0);
20995 +
20996 +
20997 +/*     vxh_advance()
20998 +
20999 +       * requires disabled preemption                          */
21000 +
21001 +struct _vx_hist_entry *vxh_advance(void *loc)
21002 +{
21003 +       unsigned int cpu = smp_processor_id();
21004 +       struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
21005 +       struct _vx_hist_entry *entry;
21006 +       unsigned int index;
21007 +
21008 +       index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
21009 +       entry = &hist->entry[index];
21010 +
21011 +       entry->seq = atomic_inc_return(&sequence);
21012 +       entry->loc = loc;
21013 +       return entry;
21014 +}
21015 +
21016 +EXPORT_SYMBOL_GPL(vxh_advance);
21017 +
21018 +
21019 +#define VXH_LOC_FMTS   "(#%04x,*%d):%p"
21020 +
21021 +#define VXH_LOC_ARGS(e)        (e)->seq, cpu, (e)->loc
21022 +
21023 +
21024 +#define VXH_VXI_FMTS   "%p[#%d,%d.%d]"
21025 +
21026 +#define VXH_VXI_ARGS(e)        (e)->vxi.ptr,                           \
21027 +                       (e)->vxi.ptr ? (e)->vxi.xid : 0,        \
21028 +                       (e)->vxi.ptr ? (e)->vxi.usecnt : 0,     \
21029 +                       (e)->vxi.ptr ? (e)->vxi.tasks : 0
21030 +
21031 +void   vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
21032 +{
21033 +       switch (e->type) {
21034 +       case VXH_THROW_OOPS:
21035 +               printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
21036 +               break;
21037 +
21038 +       case VXH_GET_VX_INFO:
21039 +       case VXH_PUT_VX_INFO:
21040 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
21041 +                       VXH_LOC_ARGS(e),
21042 +                       (e->type == VXH_GET_VX_INFO) ? "get" : "put",
21043 +                       VXH_VXI_ARGS(e));
21044 +               break;
21045 +
21046 +       case VXH_INIT_VX_INFO:
21047 +       case VXH_SET_VX_INFO:
21048 +       case VXH_CLR_VX_INFO:
21049 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
21050 +                       VXH_LOC_ARGS(e),
21051 +                       (e->type == VXH_INIT_VX_INFO) ? "init" :
21052 +                       ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
21053 +                       VXH_VXI_ARGS(e), e->sc.data);
21054 +               break;
21055 +
21056 +       case VXH_CLAIM_VX_INFO:
21057 +       case VXH_RELEASE_VX_INFO:
21058 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
21059 +                       VXH_LOC_ARGS(e),
21060 +                       (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
21061 +                       VXH_VXI_ARGS(e), e->sc.data);
21062 +               break;
21063 +
21064 +       case VXH_ALLOC_VX_INFO:
21065 +       case VXH_DEALLOC_VX_INFO:
21066 +               printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
21067 +                       VXH_LOC_ARGS(e),
21068 +                       (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
21069 +                       VXH_VXI_ARGS(e));
21070 +               break;
21071 +
21072 +       case VXH_HASH_VX_INFO:
21073 +       case VXH_UNHASH_VX_INFO:
21074 +               printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
21075 +                       VXH_LOC_ARGS(e),
21076 +                       (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
21077 +                       VXH_VXI_ARGS(e));
21078 +               break;
21079 +
21080 +       case VXH_LOC_VX_INFO:
21081 +       case VXH_LOOKUP_VX_INFO:
21082 +       case VXH_CREATE_VX_INFO:
21083 +               printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
21084 +                       VXH_LOC_ARGS(e),
21085 +                       (e->type == VXH_CREATE_VX_INFO) ? "create" :
21086 +                       ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
21087 +                       e->ll.arg, VXH_VXI_ARGS(e));
21088 +               break;
21089 +       }
21090 +}
21091 +
21092 +static void __vxh_dump_history(void)
21093 +{
21094 +       unsigned int i, cpu;
21095 +
21096 +       printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
21097 +               atomic_read(&sequence), NR_CPUS);
21098 +
21099 +       for (i = 0; i < VXH_SIZE; i++) {
21100 +               for_each_online_cpu(cpu) {
21101 +                       struct _vx_history *hist =
21102 +                               &per_cpu(vx_history_buffer, cpu);
21103 +                       unsigned int index = (hist->counter - i) % VXH_SIZE;
21104 +                       struct _vx_hist_entry *entry = &hist->entry[index];
21105 +
21106 +                       vxh_dump_entry(entry, cpu);
21107 +               }
21108 +       }
21109 +}
21110 +
21111 +void   vxh_dump_history(void)
21112 +{
21113 +       vxh_active = 0;
21114 +#ifdef CONFIG_SMP
21115 +       local_irq_enable();
21116 +       smp_send_stop();
21117 +       local_irq_disable();
21118 +#endif
21119 +       __vxh_dump_history();
21120 +}
21121 +
21122 +
21123 +/* vserver syscall commands below here */
21124 +
21125 +
21126 +int vc_dump_history(uint32_t id)
21127 +{
21128 +       vxh_active = 0;
21129 +       __vxh_dump_history();
21130 +       vxh_active = 1;
21131 +
21132 +       return 0;
21133 +}
21134 +
21135 +
21136 +int do_read_history(struct __user _vx_hist_entry *data,
21137 +       int cpu, uint32_t *index, uint32_t *count)
21138 +{
21139 +       int pos, ret = 0;
21140 +       struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
21141 +       int end = hist->counter;
21142 +       int start = end - VXH_SIZE + 2;
21143 +       int idx = *index;
21144 +
21145 +       /* special case: get current pos */
21146 +       if (!*count) {
21147 +               *index = end;
21148 +               return 0;
21149 +       }
21150 +
21151 +       /* have we lost some data? */
21152 +       if (idx < start)
21153 +               idx = start;
21154 +
21155 +       for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
21156 +               struct _vx_hist_entry *entry =
21157 +                       &hist->entry[idx % VXH_SIZE];
21158 +
21159 +               /* send entry to userspace */
21160 +               ret = copy_to_user(&data[pos], entry, sizeof(*entry));
21161 +               if (ret)
21162 +                       break;
21163 +       }
21164 +       /* save new index and count */
21165 +       *index = idx;
21166 +       *count = pos;
21167 +       return ret ? ret : (*index < end);
21168 +}
21169 +
21170 +int vc_read_history(uint32_t id, void __user *data)
21171 +{
21172 +       struct vcmd_read_history_v0 vc_data;
21173 +       int ret;
21174 +
21175 +       if (id >= NR_CPUS)
21176 +               return -EINVAL;
21177 +
21178 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21179 +               return -EFAULT;
21180 +
21181 +       ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
21182 +               id, &vc_data.index, &vc_data.count);
21183 +
21184 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21185 +               return -EFAULT;
21186 +       return ret;
21187 +}
21188 +
21189 +#ifdef CONFIG_COMPAT
21190 +
21191 +int vc_read_history_x32(uint32_t id, void __user *data)
21192 +{
21193 +       struct vcmd_read_history_v0_x32 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 *)
21203 +               compat_ptr(vc_data.data_ptr),
21204 +               id, &vc_data.index, &vc_data.count);
21205 +
21206 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21207 +               return -EFAULT;
21208 +       return ret;
21209 +}
21210 +
21211 +#endif /* CONFIG_COMPAT */
21212 +
21213 diff -NurpP --minimal linux-3.0.4/kernel/vserver/inet.c linux-3.0.4-vs2.3.1/kernel/vserver/inet.c
21214 --- linux-3.0.4/kernel/vserver/inet.c   1970-01-01 01:00:00.000000000 +0100
21215 +++ linux-3.0.4-vs2.3.1/kernel/vserver/inet.c   2011-08-30 20:14:33.000000000 +0200
21216 @@ -0,0 +1,225 @@
21217 +
21218 +#include <linux/in.h>
21219 +#include <linux/inetdevice.h>
21220 +#include <linux/vs_inet.h>
21221 +#include <linux/vs_inet6.h>
21222 +#include <linux/vserver/debug.h>
21223 +#include <net/route.h>
21224 +#include <net/addrconf.h>
21225 +
21226 +
21227 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
21228 +{
21229 +       int ret = 0;
21230 +
21231 +       if (!nxi1 || !nxi2 || nxi1 == nxi2)
21232 +               ret = 1;
21233 +       else {
21234 +               struct nx_addr_v4 *ptr;
21235 +
21236 +               for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
21237 +                       if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
21238 +                               ret = 1;
21239 +                               break;
21240 +                       }
21241 +               }
21242 +       }
21243 +
21244 +       vxdprintk(VXD_CBIT(net, 2),
21245 +               "nx_v4_addr_conflict(%p,%p): %d",
21246 +               nxi1, nxi2, ret);
21247 +
21248 +       return ret;
21249 +}
21250 +
21251 +
21252 +#ifdef CONFIG_IPV6
21253 +
21254 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
21255 +{
21256 +       int ret = 0;
21257 +
21258 +       if (!nxi1 || !nxi2 || nxi1 == nxi2)
21259 +               ret = 1;
21260 +       else {
21261 +               struct nx_addr_v6 *ptr;
21262 +
21263 +               for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
21264 +                       if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
21265 +                               ret = 1;
21266 +                               break;
21267 +                       }
21268 +               }
21269 +       }
21270 +
21271 +       vxdprintk(VXD_CBIT(net, 2),
21272 +               "nx_v6_addr_conflict(%p,%p): %d",
21273 +               nxi1, nxi2, ret);
21274 +
21275 +       return ret;
21276 +}
21277 +
21278 +#endif
21279 +
21280 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
21281 +{
21282 +       struct in_device *in_dev;
21283 +       struct in_ifaddr **ifap;
21284 +       struct in_ifaddr *ifa;
21285 +       int ret = 0;
21286 +
21287 +       if (!dev)
21288 +               goto out;
21289 +       in_dev = in_dev_get(dev);
21290 +       if (!in_dev)
21291 +               goto out;
21292 +
21293 +       for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
21294 +               ifap = &ifa->ifa_next) {
21295 +               if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
21296 +                       ret = 1;
21297 +                       break;
21298 +               }
21299 +       }
21300 +       in_dev_put(in_dev);
21301 +out:
21302 +       return ret;
21303 +}
21304 +
21305 +
21306 +#ifdef CONFIG_IPV6
21307 +
21308 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
21309 +{
21310 +       struct inet6_dev *in_dev;
21311 +       struct inet6_ifaddr *ifa;
21312 +       int ret = 0;
21313 +
21314 +       if (!dev)
21315 +               goto out;
21316 +       in_dev = in6_dev_get(dev);
21317 +       if (!in_dev)
21318 +               goto out;
21319 +
21320 +       // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
21321 +       list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
21322 +               if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
21323 +                       ret = 1;
21324 +                       break;
21325 +               }
21326 +       }
21327 +       in6_dev_put(in_dev);
21328 +out:
21329 +       return ret;
21330 +}
21331 +
21332 +#endif
21333 +
21334 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
21335 +{
21336 +       int ret = 1;
21337 +
21338 +       if (!nxi)
21339 +               goto out;
21340 +       if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
21341 +               goto out;
21342 +#ifdef CONFIG_IPV6
21343 +       ret = 2;
21344 +       if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
21345 +               goto out;
21346 +#endif
21347 +       ret = 0;
21348 +out:
21349 +       vxdprintk(VXD_CBIT(net, 3),
21350 +               "dev_in_nx_info(%p,%p[#%d]) = %d",
21351 +               dev, nxi, nxi ? nxi->nx_id : 0, ret);
21352 +       return ret;
21353 +}
21354 +
21355 +struct rtable *ip_v4_find_src(struct net *net, struct nx_info *nxi,
21356 +       struct flowi4 *fl4)
21357 +{
21358 +       struct rtable *rt;
21359 +
21360 +       if (!nxi)
21361 +               return NULL;
21362 +
21363 +       /* FIXME: handle lback only case */
21364 +       if (!NX_IPV4(nxi))
21365 +               return ERR_PTR(-EPERM);
21366 +
21367 +       vxdprintk(VXD_CBIT(net, 4),
21368 +               "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
21369 +               nxi, nxi ? nxi->nx_id : 0,
21370 +               NIPQUAD(fl4->saddr), NIPQUAD(fl4->daddr));
21371 +
21372 +       /* single IP is unconditional */
21373 +       if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
21374 +               (fl4->saddr == INADDR_ANY))
21375 +               fl4->saddr = nxi->v4.ip[0].s_addr;
21376 +
21377 +       if (fl4->saddr == INADDR_ANY) {
21378 +               struct nx_addr_v4 *ptr;
21379 +               __be32 found = 0;
21380 +
21381 +               rt = __ip_route_output_key(net, fl4);
21382 +               if (!IS_ERR(rt)) {
21383 +                       found = fl4->saddr;
21384 +                       ip_rt_put(rt);
21385 +                       vxdprintk(VXD_CBIT(net, 4),
21386 +                               "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
21387 +                               nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(found));
21388 +                       if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
21389 +                               goto found;
21390 +               }
21391 +
21392 +               for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
21393 +                       __be32 primary = ptr->ip[0].s_addr;
21394 +                       __be32 mask = ptr->mask.s_addr;
21395 +                       __be32 neta = primary & mask;
21396 +
21397 +                       vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
21398 +                               NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
21399 +                               nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
21400 +                               NIPQUAD(mask), NIPQUAD(neta));
21401 +                       if ((found & mask) != neta)
21402 +                               continue;
21403 +
21404 +                       fl4->saddr = primary;
21405 +                       rt = __ip_route_output_key(net, fl4);
21406 +                       vxdprintk(VXD_CBIT(net, 4),
21407 +                               "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
21408 +                               nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(primary));
21409 +                       if (!IS_ERR(rt)) {
21410 +                               found = fl4->saddr;
21411 +                               ip_rt_put(rt);
21412 +                               if (found == primary)
21413 +                                       goto found;
21414 +                       }
21415 +               }
21416 +               /* still no source ip? */
21417 +               found = ipv4_is_loopback(fl4->daddr)
21418 +                       ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
21419 +       found:
21420 +               /* assign src ip to flow */
21421 +               fl4->saddr = found;
21422 +
21423 +       } else {
21424 +               if (!v4_addr_in_nx_info(nxi, fl4->saddr, NXA_MASK_BIND))
21425 +                       return ERR_PTR(-EPERM);
21426 +       }
21427 +
21428 +       if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
21429 +               if (ipv4_is_loopback(fl4->daddr))
21430 +                       fl4->daddr = nxi->v4_lback.s_addr;
21431 +               if (ipv4_is_loopback(fl4->saddr))
21432 +                       fl4->saddr = nxi->v4_lback.s_addr;
21433 +       } else if (ipv4_is_loopback(fl4->daddr) &&
21434 +               !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
21435 +               return ERR_PTR(-EPERM);
21436 +
21437 +       return NULL;
21438 +}
21439 +
21440 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
21441 +
21442 diff -NurpP --minimal linux-3.0.4/kernel/vserver/init.c linux-3.0.4-vs2.3.1/kernel/vserver/init.c
21443 --- linux-3.0.4/kernel/vserver/init.c   1970-01-01 01:00:00.000000000 +0100
21444 +++ linux-3.0.4-vs2.3.1/kernel/vserver/init.c   2011-06-10 22:11:24.000000000 +0200
21445 @@ -0,0 +1,45 @@
21446 +/*
21447 + *  linux/kernel/init.c
21448 + *
21449 + *  Virtual Server Init
21450 + *
21451 + *  Copyright (C) 2004-2007  Herbert Pötzl
21452 + *
21453 + *  V0.01  basic structure
21454 + *
21455 + */
21456 +
21457 +#include <linux/init.h>
21458 +
21459 +int    vserver_register_sysctl(void);
21460 +void   vserver_unregister_sysctl(void);
21461 +
21462 +
21463 +static int __init init_vserver(void)
21464 +{
21465 +       int ret = 0;
21466 +
21467 +#ifdef CONFIG_VSERVER_DEBUG
21468 +       vserver_register_sysctl();
21469 +#endif
21470 +       return ret;
21471 +}
21472 +
21473 +
21474 +static void __exit exit_vserver(void)
21475 +{
21476 +
21477 +#ifdef CONFIG_VSERVER_DEBUG
21478 +       vserver_unregister_sysctl();
21479 +#endif
21480 +       return;
21481 +}
21482 +
21483 +/* FIXME: GFP_ZONETYPES gone
21484 +long vx_slab[GFP_ZONETYPES]; */
21485 +long vx_area;
21486 +
21487 +
21488 +module_init(init_vserver);
21489 +module_exit(exit_vserver);
21490 +
21491 diff -NurpP --minimal linux-3.0.4/kernel/vserver/inode.c linux-3.0.4-vs2.3.1/kernel/vserver/inode.c
21492 --- linux-3.0.4/kernel/vserver/inode.c  1970-01-01 01:00:00.000000000 +0100
21493 +++ linux-3.0.4-vs2.3.1/kernel/vserver/inode.c  2011-06-10 22:11:24.000000000 +0200
21494 @@ -0,0 +1,437 @@
21495 +/*
21496 + *  linux/kernel/vserver/inode.c
21497 + *
21498 + *  Virtual Server: File System Support
21499 + *
21500 + *  Copyright (C) 2004-2007  Herbert Pötzl
21501 + *
21502 + *  V0.01  separated from vcontext V0.05
21503 + *  V0.02  moved to tag (instead of xid)
21504 + *
21505 + */
21506 +
21507 +#include <linux/tty.h>
21508 +#include <linux/proc_fs.h>
21509 +#include <linux/devpts_fs.h>
21510 +#include <linux/fs.h>
21511 +#include <linux/file.h>
21512 +#include <linux/mount.h>
21513 +#include <linux/parser.h>
21514 +#include <linux/namei.h>
21515 +#include <linux/vserver/inode.h>
21516 +#include <linux/vserver/inode_cmd.h>
21517 +#include <linux/vs_base.h>
21518 +#include <linux/vs_tag.h>
21519 +
21520 +#include <asm/uaccess.h>
21521 +
21522 +
21523 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21524 +{
21525 +       struct proc_dir_entry *entry;
21526 +
21527 +       if (!in || !in->i_sb)
21528 +               return -ESRCH;
21529 +
21530 +       *flags = IATTR_TAG
21531 +               | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
21532 +               | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
21533 +               | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
21534 +               | (IS_COW(in) ? IATTR_COW : 0);
21535 +       *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
21536 +
21537 +       if (S_ISDIR(in->i_mode))
21538 +               *mask |= IATTR_BARRIER;
21539 +
21540 +       if (IS_TAGGED(in)) {
21541 +               *tag = in->i_tag;
21542 +               *mask |= IATTR_TAG;
21543 +       }
21544 +
21545 +       switch (in->i_sb->s_magic) {
21546 +       case PROC_SUPER_MAGIC:
21547 +               entry = PROC_I(in)->pde;
21548 +
21549 +               /* check for specific inodes? */
21550 +               if (entry)
21551 +                       *mask |= IATTR_FLAGS;
21552 +               if (entry)
21553 +                       *flags |= (entry->vx_flags & IATTR_FLAGS);
21554 +               else
21555 +                       *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
21556 +               break;
21557 +
21558 +       case DEVPTS_SUPER_MAGIC:
21559 +               *tag = in->i_tag;
21560 +               *mask |= IATTR_TAG;
21561 +               break;
21562 +
21563 +       default:
21564 +               break;
21565 +       }
21566 +       return 0;
21567 +}
21568 +
21569 +int vc_get_iattr(void __user *data)
21570 +{
21571 +       struct path path;
21572 +       struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
21573 +       int ret;
21574 +
21575 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21576 +               return -EFAULT;
21577 +
21578 +       ret = user_lpath(vc_data.name, &path);
21579 +       if (!ret) {
21580 +               ret = __vc_get_iattr(path.dentry->d_inode,
21581 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21582 +               path_put(&path);
21583 +       }
21584 +       if (ret)
21585 +               return ret;
21586 +
21587 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21588 +               ret = -EFAULT;
21589 +       return ret;
21590 +}
21591 +
21592 +#ifdef CONFIG_COMPAT
21593 +
21594 +int vc_get_iattr_x32(void __user *data)
21595 +{
21596 +       struct path path;
21597 +       struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
21598 +       int ret;
21599 +
21600 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21601 +               return -EFAULT;
21602 +
21603 +       ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21604 +       if (!ret) {
21605 +               ret = __vc_get_iattr(path.dentry->d_inode,
21606 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21607 +               path_put(&path);
21608 +       }
21609 +       if (ret)
21610 +               return ret;
21611 +
21612 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21613 +               ret = -EFAULT;
21614 +       return ret;
21615 +}
21616 +
21617 +#endif /* CONFIG_COMPAT */
21618 +
21619 +
21620 +int vc_fget_iattr(uint32_t fd, void __user *data)
21621 +{
21622 +       struct file *filp;
21623 +       struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
21624 +       int ret;
21625 +
21626 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21627 +               return -EFAULT;
21628 +
21629 +       filp = fget(fd);
21630 +       if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21631 +               return -EBADF;
21632 +
21633 +       ret = __vc_get_iattr(filp->f_dentry->d_inode,
21634 +               &vc_data.tag, &vc_data.flags, &vc_data.mask);
21635 +
21636 +       fput(filp);
21637 +
21638 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21639 +               ret = -EFAULT;
21640 +       return ret;
21641 +}
21642 +
21643 +
21644 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21645 +{
21646 +       struct inode *in = de->d_inode;
21647 +       int error = 0, is_proc = 0, has_tag = 0;
21648 +       struct iattr attr = { 0 };
21649 +
21650 +       if (!in || !in->i_sb)
21651 +               return -ESRCH;
21652 +
21653 +       is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
21654 +       if ((*mask & IATTR_FLAGS) && !is_proc)
21655 +               return -EINVAL;
21656 +
21657 +       has_tag = IS_TAGGED(in) ||
21658 +               (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
21659 +       if ((*mask & IATTR_TAG) && !has_tag)
21660 +               return -EINVAL;
21661 +
21662 +       mutex_lock(&in->i_mutex);
21663 +       if (*mask & IATTR_TAG) {
21664 +               attr.ia_tag = *tag;
21665 +               attr.ia_valid |= ATTR_TAG;
21666 +       }
21667 +
21668 +       if (*mask & IATTR_FLAGS) {
21669 +               struct proc_dir_entry *entry = PROC_I(in)->pde;
21670 +               unsigned int iflags = PROC_I(in)->vx_flags;
21671 +
21672 +               iflags = (iflags & ~(*mask & IATTR_FLAGS))
21673 +                       | (*flags & IATTR_FLAGS);
21674 +               PROC_I(in)->vx_flags = iflags;
21675 +               if (entry)
21676 +                       entry->vx_flags = iflags;
21677 +       }
21678 +
21679 +       if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
21680 +               IATTR_BARRIER | IATTR_COW)) {
21681 +               int iflags = in->i_flags;
21682 +               int vflags = in->i_vflags;
21683 +
21684 +               if (*mask & IATTR_IMMUTABLE) {
21685 +                       if (*flags & IATTR_IMMUTABLE)
21686 +                               iflags |= S_IMMUTABLE;
21687 +                       else
21688 +                               iflags &= ~S_IMMUTABLE;
21689 +               }
21690 +               if (*mask & IATTR_IXUNLINK) {
21691 +                       if (*flags & IATTR_IXUNLINK)
21692 +                               iflags |= S_IXUNLINK;
21693 +                       else
21694 +                               iflags &= ~S_IXUNLINK;
21695 +               }
21696 +               if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
21697 +                       if (*flags & IATTR_BARRIER)
21698 +                               vflags |= V_BARRIER;
21699 +                       else
21700 +                               vflags &= ~V_BARRIER;
21701 +               }
21702 +               if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
21703 +                       if (*flags & IATTR_COW)
21704 +                               vflags |= V_COW;
21705 +                       else
21706 +                               vflags &= ~V_COW;
21707 +               }
21708 +               if (in->i_op && in->i_op->sync_flags) {
21709 +                       error = in->i_op->sync_flags(in, iflags, vflags);
21710 +                       if (error)
21711 +                               goto out;
21712 +               }
21713 +       }
21714 +
21715 +       if (attr.ia_valid) {
21716 +               if (in->i_op && in->i_op->setattr)
21717 +                       error = in->i_op->setattr(de, &attr);
21718 +               else {
21719 +                       error = inode_change_ok(in, &attr);
21720 +                       if (!error) {
21721 +                               setattr_copy(in, &attr);
21722 +                               mark_inode_dirty(in);
21723 +                       }
21724 +               }
21725 +       }
21726 +
21727 +out:
21728 +       mutex_unlock(&in->i_mutex);
21729 +       return error;
21730 +}
21731 +
21732 +int vc_set_iattr(void __user *data)
21733 +{
21734 +       struct path path;
21735 +       struct vcmd_ctx_iattr_v1 vc_data;
21736 +       int ret;
21737 +
21738 +       if (!capable(CAP_LINUX_IMMUTABLE))
21739 +               return -EPERM;
21740 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21741 +               return -EFAULT;
21742 +
21743 +       ret = user_lpath(vc_data.name, &path);
21744 +       if (!ret) {
21745 +               ret = __vc_set_iattr(path.dentry,
21746 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21747 +               path_put(&path);
21748 +       }
21749 +
21750 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21751 +               ret = -EFAULT;
21752 +       return ret;
21753 +}
21754 +
21755 +#ifdef CONFIG_COMPAT
21756 +
21757 +int vc_set_iattr_x32(void __user *data)
21758 +{
21759 +       struct path path;
21760 +       struct vcmd_ctx_iattr_v1_x32 vc_data;
21761 +       int ret;
21762 +
21763 +       if (!capable(CAP_LINUX_IMMUTABLE))
21764 +               return -EPERM;
21765 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21766 +               return -EFAULT;
21767 +
21768 +       ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21769 +       if (!ret) {
21770 +               ret = __vc_set_iattr(path.dentry,
21771 +                       &vc_data.tag, &vc_data.flags, &vc_data.mask);
21772 +               path_put(&path);
21773 +       }
21774 +
21775 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21776 +               ret = -EFAULT;
21777 +       return ret;
21778 +}
21779 +
21780 +#endif /* CONFIG_COMPAT */
21781 +
21782 +int vc_fset_iattr(uint32_t fd, void __user *data)
21783 +{
21784 +       struct file *filp;
21785 +       struct vcmd_ctx_fiattr_v0 vc_data;
21786 +       int ret;
21787 +
21788 +       if (!capable(CAP_LINUX_IMMUTABLE))
21789 +               return -EPERM;
21790 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21791 +               return -EFAULT;
21792 +
21793 +       filp = fget(fd);
21794 +       if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21795 +               return -EBADF;
21796 +
21797 +       ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
21798 +               &vc_data.flags, &vc_data.mask);
21799 +
21800 +       fput(filp);
21801 +
21802 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21803 +               return -EFAULT;
21804 +       return ret;
21805 +}
21806 +
21807 +
21808 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
21809 +
21810 +static match_table_t tokens = {
21811 +       {Opt_notagcheck, "notagcheck"},
21812 +#ifdef CONFIG_PROPAGATE
21813 +       {Opt_notag, "notag"},
21814 +       {Opt_tag, "tag"},
21815 +       {Opt_tagid, "tagid=%u"},
21816 +#endif
21817 +       {Opt_err, NULL}
21818 +};
21819 +
21820 +
21821 +static void __dx_parse_remove(char *string, char *opt)
21822 +{
21823 +       char *p = strstr(string, opt);
21824 +       char *q = p;
21825 +
21826 +       if (p) {
21827 +               while (*q != '\0' && *q != ',')
21828 +                       q++;
21829 +               while (*q)
21830 +                       *p++ = *q++;
21831 +               while (*p)
21832 +                       *p++ = '\0';
21833 +       }
21834 +}
21835 +
21836 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
21837 +                unsigned long *flags)
21838 +{
21839 +       int set = 0;
21840 +       substring_t args[MAX_OPT_ARGS];
21841 +       int token;
21842 +       char *s, *p, *opts;
21843 +#if defined(CONFIG_PROPAGATE) || defined(CONFIG_VSERVER_WARN)
21844 +       int option = 0;
21845 +#endif
21846 +
21847 +       if (!string)
21848 +               return 0;
21849 +       s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
21850 +       if (!s)
21851 +               return 0;
21852 +
21853 +       opts = s;
21854 +       while ((p = strsep(&opts, ",")) != NULL) {
21855 +               token = match_token(p, tokens, args);
21856 +
21857 +               switch (token) {
21858 +#ifdef CONFIG_PROPAGATE
21859 +               case Opt_tag:
21860 +                       if (tag)
21861 +                               *tag = 0;
21862 +                       if (remove)
21863 +                               __dx_parse_remove(s, "tag");
21864 +                       *mnt_flags |= MNT_TAGID;
21865 +                       set |= MNT_TAGID;
21866 +                       break;
21867 +               case Opt_notag:
21868 +                       if (remove)
21869 +                               __dx_parse_remove(s, "notag");
21870 +                       *mnt_flags |= MNT_NOTAG;
21871 +                       set |= MNT_NOTAG;
21872 +                       break;
21873 +               case Opt_tagid:
21874 +                       if (tag && !match_int(args, &option))
21875 +                               *tag = option;
21876 +                       if (remove)
21877 +                               __dx_parse_remove(s, "tagid");
21878 +                       *mnt_flags |= MNT_TAGID;
21879 +                       set |= MNT_TAGID;
21880 +                       break;
21881 +#endif
21882 +               case Opt_notagcheck:
21883 +                       if (remove)
21884 +                               __dx_parse_remove(s, "notagcheck");
21885 +                       *flags |= MS_NOTAGCHECK;
21886 +                       set |= MS_NOTAGCHECK;
21887 +                       break;
21888 +               }
21889 +               vxdprintk(VXD_CBIT(tag, 7),
21890 +                       "dx_parse_tag(" VS_Q("%s") "): %d:#%d",
21891 +                       p, token, option);
21892 +       }
21893 +       if (set)
21894 +               strcpy(string, s);
21895 +       kfree(s);
21896 +       return set;
21897 +}
21898 +
21899 +#ifdef CONFIG_PROPAGATE
21900 +
21901 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
21902 +{
21903 +       tag_t new_tag = 0;
21904 +       struct vfsmount *mnt;
21905 +       int propagate;
21906 +
21907 +       if (!nd)
21908 +               return;
21909 +       mnt = nd->path.mnt;
21910 +       if (!mnt)
21911 +               return;
21912 +
21913 +       propagate = (mnt->mnt_flags & MNT_TAGID);
21914 +       if (propagate)
21915 +               new_tag = mnt->mnt_tag;
21916 +
21917 +       vxdprintk(VXD_CBIT(tag, 7),
21918 +               "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
21919 +               inode, inode->i_ino, inode->i_tag,
21920 +               new_tag, (propagate) ? 1 : 0);
21921 +
21922 +       if (propagate)
21923 +               inode->i_tag = new_tag;
21924 +}
21925 +
21926 +#include <linux/module.h>
21927 +
21928 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
21929 +
21930 +#endif /* CONFIG_PROPAGATE */
21931 +
21932 diff -NurpP --minimal linux-3.0.4/kernel/vserver/limit.c linux-3.0.4-vs2.3.1/kernel/vserver/limit.c
21933 --- linux-3.0.4/kernel/vserver/limit.c  1970-01-01 01:00:00.000000000 +0100
21934 +++ linux-3.0.4-vs2.3.1/kernel/vserver/limit.c  2011-10-11 20:48:08.000000000 +0200
21935 @@ -0,0 +1,360 @@
21936 +/*
21937 + *  linux/kernel/vserver/limit.c
21938 + *
21939 + *  Virtual Server: Context Limits
21940 + *
21941 + *  Copyright (C) 2004-2010  Herbert Pötzl
21942 + *
21943 + *  V0.01  broken out from vcontext V0.05
21944 + *  V0.02  changed vcmds to vxi arg
21945 + *  V0.03  added memory cgroup support
21946 + *
21947 + */
21948 +
21949 +#include <linux/sched.h>
21950 +#include <linux/module.h>
21951 +#include <linux/memcontrol.h>
21952 +#include <linux/res_counter.h>
21953 +#include <linux/vs_limit.h>
21954 +#include <linux/vserver/limit.h>
21955 +#include <linux/vserver/limit_cmd.h>
21956 +
21957 +#include <asm/uaccess.h>
21958 +
21959 +
21960 +const char *vlimit_name[NUM_LIMITS] = {
21961 +#ifdef CONFIG_VSERVER_LEGACY_MEM
21962 +       [RLIMIT_RSS]            = "RSS",
21963 +       [RLIMIT_AS]             = "VM",
21964 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
21965 +       [RLIMIT_CPU]            = "CPU",
21966 +       [RLIMIT_NPROC]          = "NPROC",
21967 +       [RLIMIT_NOFILE]         = "NOFILE",
21968 +       [RLIMIT_LOCKS]          = "LOCKS",
21969 +       [RLIMIT_SIGPENDING]     = "SIGP",
21970 +       [RLIMIT_MSGQUEUE]       = "MSGQ",
21971 +
21972 +       [VLIMIT_NSOCK]          = "NSOCK",
21973 +       [VLIMIT_OPENFD]         = "OPENFD",
21974 +       [VLIMIT_SHMEM]          = "SHMEM",
21975 +       [VLIMIT_DENTRY]         = "DENTRY",
21976 +};
21977 +
21978 +EXPORT_SYMBOL_GPL(vlimit_name);
21979 +
21980 +#define MASK_ENTRY(x)  (1 << (x))
21981 +
21982 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
21983 +               /* minimum */
21984 +       0
21985 +       ,       /* softlimit */
21986 +#ifdef CONFIG_VSERVER_LEGACY_MEM
21987 +       MASK_ENTRY( RLIMIT_RSS          ) |
21988 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
21989 +       0
21990 +       ,       /* maximum */
21991 +#ifdef CONFIG_VSERVER_LEGACY_MEM
21992 +       MASK_ENTRY( RLIMIT_RSS          ) |
21993 +       MASK_ENTRY( RLIMIT_AS           ) |
21994 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
21995 +       MASK_ENTRY( RLIMIT_NPROC        ) |
21996 +       MASK_ENTRY( RLIMIT_NOFILE       ) |
21997 +       MASK_ENTRY( RLIMIT_LOCKS        ) |
21998 +       MASK_ENTRY( RLIMIT_MSGQUEUE     ) |
21999 +
22000 +       MASK_ENTRY( VLIMIT_NSOCK        ) |
22001 +       MASK_ENTRY( VLIMIT_OPENFD       ) |
22002 +       MASK_ENTRY( VLIMIT_SHMEM        ) |
22003 +       MASK_ENTRY( VLIMIT_DENTRY       ) |
22004 +       0
22005 +};
22006 +               /* accounting only */
22007 +uint32_t account_mask =
22008 +       MASK_ENTRY( VLIMIT_SEMARY       ) |
22009 +       MASK_ENTRY( VLIMIT_NSEMS        ) |
22010 +       MASK_ENTRY( VLIMIT_MAPPED       ) |
22011 +       0;
22012 +
22013 +
22014 +static int is_valid_vlimit(int id)
22015 +{
22016 +       uint32_t mask = vlimit_mask.minimum |
22017 +               vlimit_mask.softlimit | vlimit_mask.maximum;
22018 +       return mask & (1 << id);
22019 +}
22020 +
22021 +static int is_accounted_vlimit(int id)
22022 +{
22023 +       if (is_valid_vlimit(id))
22024 +               return 1;
22025 +       return account_mask & (1 << id);
22026 +}
22027 +
22028 +
22029 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
22030 +{
22031 +       rlim_t limit = __rlim_soft(&vxi->limit, id);
22032 +       return VX_VLIM(limit);
22033 +}
22034 +
22035 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
22036 +{
22037 +       rlim_t limit = __rlim_hard(&vxi->limit, id);
22038 +       return VX_VLIM(limit);
22039 +}
22040 +
22041 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
22042 +       uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
22043 +{
22044 +       if (!is_valid_vlimit(id))
22045 +               return -EINVAL;
22046 +
22047 +       if (minimum)
22048 +               *minimum = CRLIM_UNSET;
22049 +       if (softlimit)
22050 +               *softlimit = vc_get_soft(vxi, id);
22051 +       if (maximum)
22052 +               *maximum = vc_get_hard(vxi, id);
22053 +       return 0;
22054 +}
22055 +
22056 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
22057 +{
22058 +       struct vcmd_ctx_rlimit_v0 vc_data;
22059 +       int ret;
22060 +
22061 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22062 +               return -EFAULT;
22063 +
22064 +       ret = do_get_rlimit(vxi, vc_data.id,
22065 +               &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
22066 +       if (ret)
22067 +               return ret;
22068 +
22069 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22070 +               return -EFAULT;
22071 +       return 0;
22072 +}
22073 +
22074 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
22075 +       uint64_t minimum, uint64_t softlimit, uint64_t maximum)
22076 +{
22077 +       if (!is_valid_vlimit(id))
22078 +               return -EINVAL;
22079 +
22080 +       if (maximum != CRLIM_KEEP)
22081 +               __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
22082 +       if (softlimit != CRLIM_KEEP)
22083 +               __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
22084 +
22085 +       /* clamp soft limit */
22086 +       if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
22087 +               __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
22088 +
22089 +       return 0;
22090 +}
22091 +
22092 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
22093 +{
22094 +       struct vcmd_ctx_rlimit_v0 vc_data;
22095 +
22096 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22097 +               return -EFAULT;
22098 +
22099 +       return do_set_rlimit(vxi, vc_data.id,
22100 +               vc_data.minimum, vc_data.softlimit, vc_data.maximum);
22101 +}
22102 +
22103 +#ifdef CONFIG_IA32_EMULATION
22104 +
22105 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
22106 +{
22107 +       struct vcmd_ctx_rlimit_v0_x32 vc_data;
22108 +
22109 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22110 +               return -EFAULT;
22111 +
22112 +       return do_set_rlimit(vxi, vc_data.id,
22113 +               vc_data.minimum, vc_data.softlimit, vc_data.maximum);
22114 +}
22115 +
22116 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
22117 +{
22118 +       struct vcmd_ctx_rlimit_v0_x32 vc_data;
22119 +       int ret;
22120 +
22121 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22122 +               return -EFAULT;
22123 +
22124 +       ret = do_get_rlimit(vxi, vc_data.id,
22125 +               &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
22126 +       if (ret)
22127 +               return ret;
22128 +
22129 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22130 +               return -EFAULT;
22131 +       return 0;
22132 +}
22133 +
22134 +#endif /* CONFIG_IA32_EMULATION */
22135 +
22136 +
22137 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
22138 +{
22139 +       if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
22140 +               return -EFAULT;
22141 +       return 0;
22142 +}
22143 +
22144 +
22145 +static inline void vx_reset_hits(struct _vx_limit *limit)
22146 +{
22147 +       int lim;
22148 +
22149 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
22150 +               atomic_set(&__rlim_lhit(limit, lim), 0);
22151 +       }
22152 +}
22153 +
22154 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
22155 +{
22156 +       vx_reset_hits(&vxi->limit);
22157 +       return 0;
22158 +}
22159 +
22160 +static inline void vx_reset_minmax(struct _vx_limit *limit)
22161 +{
22162 +       rlim_t value;
22163 +       int lim;
22164 +
22165 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
22166 +               value = __rlim_get(limit, lim);
22167 +               __rlim_rmax(limit, lim) = value;
22168 +               __rlim_rmin(limit, lim) = value;
22169 +       }
22170 +}
22171 +
22172 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
22173 +{
22174 +       vx_reset_minmax(&vxi->limit);
22175 +       return 0;
22176 +}
22177 +
22178 +
22179 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
22180 +{
22181 +       struct vcmd_rlimit_stat_v0 vc_data;
22182 +       struct _vx_limit *limit = &vxi->limit;
22183 +       int id;
22184 +
22185 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22186 +               return -EFAULT;
22187 +
22188 +       id = vc_data.id;
22189 +       if (!is_accounted_vlimit(id))
22190 +               return -EINVAL;
22191 +
22192 +       vx_limit_fixup(limit, id);
22193 +       vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
22194 +       vc_data.value = __rlim_get(limit, id);
22195 +       vc_data.minimum = __rlim_rmin(limit, id);
22196 +       vc_data.maximum = __rlim_rmax(limit, id);
22197 +
22198 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22199 +               return -EFAULT;
22200 +       return 0;
22201 +}
22202 +
22203 +
22204 +void vx_vsi_meminfo(struct sysinfo *val)
22205 +{
22206 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
22207 +       struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22208 +       u64 res_limit, res_usage;
22209 +
22210 +       if (!mcg)
22211 +               return;
22212 +
22213 +       res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
22214 +       res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
22215 +
22216 +       if (res_limit != RESOURCE_MAX)
22217 +               val->totalram = (res_limit >> PAGE_SHIFT);
22218 +       val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
22219 +       val->bufferram = 0;
22220 +       val->totalhigh = 0;
22221 +       val->freehigh = 0;
22222 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
22223 +       return;
22224 +}
22225 +
22226 +void vx_vsi_swapinfo(struct sysinfo *val)
22227 +{
22228 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
22229 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
22230 +       struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22231 +       u64 res_limit, res_usage, memsw_limit, memsw_usage;
22232 +       s64 swap_limit, swap_usage;
22233 +
22234 +       if (!mcg)
22235 +               return;
22236 +
22237 +       res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
22238 +       res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
22239 +       memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
22240 +       memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
22241 +
22242 +       /* memory unlimited */
22243 +       if (res_limit == RESOURCE_MAX)
22244 +               return;
22245 +
22246 +       swap_limit = memsw_limit - res_limit;
22247 +       /* we have a swap limit? */
22248 +       if (memsw_limit != RESOURCE_MAX)
22249 +               val->totalswap = swap_limit >> PAGE_SHIFT;
22250 +
22251 +       /* calculate swap part */
22252 +       swap_usage = (memsw_usage > res_usage) ?
22253 +               memsw_usage - res_usage : 0;
22254 +
22255 +       /* total shown minus usage gives free swap */
22256 +       val->freeswap = (swap_usage < swap_limit) ?
22257 +               val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
22258 +#else  /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
22259 +       val->totalswap = 0;
22260 +       val->freeswap = 0;
22261 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
22262 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
22263 +       return;
22264 +}
22265 +
22266 +long vx_vsi_cached(struct sysinfo *val)
22267 +{
22268 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
22269 +       struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22270 +
22271 +       return mem_cgroup_stat_read_cache(mcg);
22272 +#else
22273 +       return 0;
22274 +#endif
22275 +}
22276 +
22277 +
22278 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
22279 +{
22280 +       struct vx_info *vxi = mm->mm_vx_info;
22281 +       unsigned long points;
22282 +       rlim_t v, w;
22283 +
22284 +       if (!vxi)
22285 +               return 0;
22286 +
22287 +       points = vxi->vx_badness_bias;
22288 +
22289 +       v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22290 +       w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22291 +       points += (v > w) ? (v - w) : 0;
22292 +
22293 +       return points;
22294 +}
22295 +
22296 diff -NurpP --minimal linux-3.0.4/kernel/vserver/limit_init.h linux-3.0.4-vs2.3.1/kernel/vserver/limit_init.h
22297 --- linux-3.0.4/kernel/vserver/limit_init.h     1970-01-01 01:00:00.000000000 +0100
22298 +++ linux-3.0.4-vs2.3.1/kernel/vserver/limit_init.h     2011-06-10 22:11:24.000000000 +0200
22299 @@ -0,0 +1,31 @@
22300 +
22301 +
22302 +static inline void vx_info_init_limit(struct _vx_limit *limit)
22303 +{
22304 +       int lim;
22305 +
22306 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
22307 +               __rlim_soft(limit, lim) = RLIM_INFINITY;
22308 +               __rlim_hard(limit, lim) = RLIM_INFINITY;
22309 +               __rlim_set(limit, lim, 0);
22310 +               atomic_set(&__rlim_lhit(limit, lim), 0);
22311 +               __rlim_rmin(limit, lim) = 0;
22312 +               __rlim_rmax(limit, lim) = 0;
22313 +       }
22314 +}
22315 +
22316 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
22317 +{
22318 +       rlim_t value;
22319 +       int lim;
22320 +
22321 +       for (lim = 0; lim < NUM_LIMITS; lim++) {
22322 +               if ((1 << lim) & VLIM_NOCHECK)
22323 +                       continue;
22324 +               value = __rlim_get(limit, lim);
22325 +               vxwprintk_xid(value,
22326 +                       "!!! limit: %p[%s,%d] = %ld on exit.",
22327 +                       limit, vlimit_name[lim], lim, (long)value);
22328 +       }
22329 +}
22330 +
22331 diff -NurpP --minimal linux-3.0.4/kernel/vserver/limit_proc.h linux-3.0.4-vs2.3.1/kernel/vserver/limit_proc.h
22332 --- linux-3.0.4/kernel/vserver/limit_proc.h     1970-01-01 01:00:00.000000000 +0100
22333 +++ linux-3.0.4-vs2.3.1/kernel/vserver/limit_proc.h     2011-06-10 22:11:24.000000000 +0200
22334 @@ -0,0 +1,57 @@
22335 +#ifndef _VX_LIMIT_PROC_H
22336 +#define _VX_LIMIT_PROC_H
22337 +
22338 +#include <linux/vserver/limit_int.h>
22339 +
22340 +
22341 +#define VX_LIMIT_FMT   ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
22342 +#define VX_LIMIT_TOP   \
22343 +       "Limit\t current\t     min/max\t\t    soft/hard\t\thits\n"
22344 +
22345 +#define VX_LIMIT_ARG(r)                                \
22346 +       (unsigned long)__rlim_get(limit, r),    \
22347 +       (unsigned long)__rlim_rmin(limit, r),   \
22348 +       (unsigned long)__rlim_rmax(limit, r),   \
22349 +       VX_VLIM(__rlim_soft(limit, r)),         \
22350 +       VX_VLIM(__rlim_hard(limit, r)),         \
22351 +       atomic_read(&__rlim_lhit(limit, r))
22352 +
22353 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
22354 +{
22355 +       vx_limit_fixup(limit, -1);
22356 +       return sprintf(buffer, VX_LIMIT_TOP
22357 +               "PROC"  VX_LIMIT_FMT
22358 +               "VM"    VX_LIMIT_FMT
22359 +               "VML"   VX_LIMIT_FMT
22360 +               "RSS"   VX_LIMIT_FMT
22361 +               "ANON"  VX_LIMIT_FMT
22362 +               "RMAP"  VX_LIMIT_FMT
22363 +               "FILES" VX_LIMIT_FMT
22364 +               "OFD"   VX_LIMIT_FMT
22365 +               "LOCKS" VX_LIMIT_FMT
22366 +               "SOCK"  VX_LIMIT_FMT
22367 +               "MSGQ"  VX_LIMIT_FMT
22368 +               "SHM"   VX_LIMIT_FMT
22369 +               "SEMA"  VX_LIMIT_FMT
22370 +               "SEMS"  VX_LIMIT_FMT
22371 +               "DENT"  VX_LIMIT_FMT,
22372 +               VX_LIMIT_ARG(RLIMIT_NPROC),
22373 +               VX_LIMIT_ARG(RLIMIT_AS),
22374 +               VX_LIMIT_ARG(RLIMIT_MEMLOCK),
22375 +               VX_LIMIT_ARG(RLIMIT_RSS),
22376 +               VX_LIMIT_ARG(VLIMIT_ANON),
22377 +               VX_LIMIT_ARG(VLIMIT_MAPPED),
22378 +               VX_LIMIT_ARG(RLIMIT_NOFILE),
22379 +               VX_LIMIT_ARG(VLIMIT_OPENFD),
22380 +               VX_LIMIT_ARG(RLIMIT_LOCKS),
22381 +               VX_LIMIT_ARG(VLIMIT_NSOCK),
22382 +               VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
22383 +               VX_LIMIT_ARG(VLIMIT_SHMEM),
22384 +               VX_LIMIT_ARG(VLIMIT_SEMARY),
22385 +               VX_LIMIT_ARG(VLIMIT_NSEMS),
22386 +               VX_LIMIT_ARG(VLIMIT_DENTRY));
22387 +}
22388 +
22389 +#endif /* _VX_LIMIT_PROC_H */
22390 +
22391 +
22392 diff -NurpP --minimal linux-3.0.4/kernel/vserver/network.c linux-3.0.4-vs2.3.1/kernel/vserver/network.c
22393 --- linux-3.0.4/kernel/vserver/network.c        1970-01-01 01:00:00.000000000 +0100
22394 +++ linux-3.0.4-vs2.3.1/kernel/vserver/network.c        2011-06-10 23:20:56.000000000 +0200
22395 @@ -0,0 +1,912 @@
22396 +/*
22397 + *  linux/kernel/vserver/network.c
22398 + *
22399 + *  Virtual Server: Network Support
22400 + *
22401 + *  Copyright (C) 2003-2007  Herbert Pötzl
22402 + *
22403 + *  V0.01  broken out from vcontext V0.05
22404 + *  V0.02  cleaned up implementation
22405 + *  V0.03  added equiv nx commands
22406 + *  V0.04  switch to RCU based hash
22407 + *  V0.05  and back to locking again
22408 + *  V0.06  changed vcmds to nxi arg
22409 + *  V0.07  have __create claim() the nxi
22410 + *
22411 + */
22412 +
22413 +#include <linux/err.h>
22414 +#include <linux/slab.h>
22415 +#include <linux/rcupdate.h>
22416 +
22417 +#include <linux/vs_network.h>
22418 +#include <linux/vs_pid.h>
22419 +#include <linux/vserver/network_cmd.h>
22420 +
22421 +
22422 +atomic_t nx_global_ctotal      = ATOMIC_INIT(0);
22423 +atomic_t nx_global_cactive     = ATOMIC_INIT(0);
22424 +
22425 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
22426 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
22427 +
22428 +
22429 +static int __init init_network(void)
22430 +{
22431 +       nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
22432 +               sizeof(struct nx_addr_v4), 0,
22433 +               SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22434 +       nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
22435 +               sizeof(struct nx_addr_v6), 0,
22436 +               SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22437 +       return 0;
22438 +}
22439 +
22440 +
22441 +/*     __alloc_nx_addr_v4()                                    */
22442 +
22443 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
22444 +{
22445 +       struct nx_addr_v4 *nxa = kmem_cache_alloc(
22446 +               nx_addr_v4_cachep, GFP_KERNEL);
22447 +
22448 +       if (!IS_ERR(nxa))
22449 +               memset(nxa, 0, sizeof(*nxa));
22450 +       return nxa;
22451 +}
22452 +
22453 +/*     __dealloc_nx_addr_v4()                                  */
22454 +
22455 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
22456 +{
22457 +       kmem_cache_free(nx_addr_v4_cachep, nxa);
22458 +}
22459 +
22460 +/*     __dealloc_nx_addr_v4_all()                              */
22461 +
22462 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
22463 +{
22464 +       while (nxa) {
22465 +               struct nx_addr_v4 *next = nxa->next;
22466 +
22467 +               __dealloc_nx_addr_v4(nxa);
22468 +               nxa = next;
22469 +       }
22470 +}
22471 +
22472 +
22473 +#ifdef CONFIG_IPV6
22474 +
22475 +/*     __alloc_nx_addr_v6()                                    */
22476 +
22477 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
22478 +{
22479 +       struct nx_addr_v6 *nxa = kmem_cache_alloc(
22480 +               nx_addr_v6_cachep, GFP_KERNEL);
22481 +
22482 +       if (!IS_ERR(nxa))
22483 +               memset(nxa, 0, sizeof(*nxa));
22484 +       return nxa;
22485 +}
22486 +
22487 +/*     __dealloc_nx_addr_v6()                                  */
22488 +
22489 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
22490 +{
22491 +       kmem_cache_free(nx_addr_v6_cachep, nxa);
22492 +}
22493 +
22494 +/*     __dealloc_nx_addr_v6_all()                              */
22495 +
22496 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
22497 +{
22498 +       while (nxa) {
22499 +               struct nx_addr_v6 *next = nxa->next;
22500 +
22501 +               __dealloc_nx_addr_v6(nxa);
22502 +               nxa = next;
22503 +       }
22504 +}
22505 +
22506 +#endif /* CONFIG_IPV6 */
22507 +
22508 +/*     __alloc_nx_info()
22509 +
22510 +       * allocate an initialized nx_info struct
22511 +       * doesn't make it visible (hash)                        */
22512 +
22513 +static struct nx_info *__alloc_nx_info(nid_t nid)
22514 +{
22515 +       struct nx_info *new = NULL;
22516 +
22517 +       vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
22518 +
22519 +       /* would this benefit from a slab cache? */
22520 +       new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
22521 +       if (!new)
22522 +               return 0;
22523 +
22524 +       memset(new, 0, sizeof(struct nx_info));
22525 +       new->nx_id = nid;
22526 +       INIT_HLIST_NODE(&new->nx_hlist);
22527 +       atomic_set(&new->nx_usecnt, 0);
22528 +       atomic_set(&new->nx_tasks, 0);
22529 +       new->nx_state = 0;
22530 +
22531 +       new->nx_flags = NXF_INIT_SET;
22532 +
22533 +       /* rest of init goes here */
22534 +
22535 +       new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
22536 +       new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
22537 +
22538 +       vxdprintk(VXD_CBIT(nid, 0),
22539 +               "alloc_nx_info(%d) = %p", nid, new);
22540 +       atomic_inc(&nx_global_ctotal);
22541 +       return new;
22542 +}
22543 +
22544 +/*     __dealloc_nx_info()
22545 +
22546 +       * final disposal of nx_info                             */
22547 +
22548 +static void __dealloc_nx_info(struct nx_info *nxi)
22549 +{
22550 +       vxdprintk(VXD_CBIT(nid, 0),
22551 +               "dealloc_nx_info(%p)", nxi);
22552 +
22553 +       nxi->nx_hlist.next = LIST_POISON1;
22554 +       nxi->nx_id = -1;
22555 +
22556 +       BUG_ON(atomic_read(&nxi->nx_usecnt));
22557 +       BUG_ON(atomic_read(&nxi->nx_tasks));
22558 +
22559 +       __dealloc_nx_addr_v4_all(nxi->v4.next);
22560 +
22561 +       nxi->nx_state |= NXS_RELEASED;
22562 +       kfree(nxi);
22563 +       atomic_dec(&nx_global_ctotal);
22564 +}
22565 +
22566 +static void __shutdown_nx_info(struct nx_info *nxi)
22567 +{
22568 +       nxi->nx_state |= NXS_SHUTDOWN;
22569 +       vs_net_change(nxi, VSC_NETDOWN);
22570 +}
22571 +
22572 +/*     exported stuff                                          */
22573 +
22574 +void free_nx_info(struct nx_info *nxi)
22575 +{
22576 +       /* context shutdown is mandatory */
22577 +       BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
22578 +
22579 +       /* context must not be hashed */
22580 +       BUG_ON(nxi->nx_state & NXS_HASHED);
22581 +
22582 +       BUG_ON(atomic_read(&nxi->nx_usecnt));
22583 +       BUG_ON(atomic_read(&nxi->nx_tasks));
22584 +
22585 +       __dealloc_nx_info(nxi);
22586 +}
22587 +
22588 +
22589 +void __nx_set_lback(struct nx_info *nxi)
22590 +{
22591 +       int nid = nxi->nx_id;
22592 +       __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
22593 +
22594 +       nxi->v4_lback.s_addr = lback;
22595 +}
22596 +
22597 +extern int __nx_inet_add_lback(__be32 addr);
22598 +extern int __nx_inet_del_lback(__be32 addr);
22599 +
22600 +
22601 +/*     hash table for nx_info hash */
22602 +
22603 +#define NX_HASH_SIZE   13
22604 +
22605 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
22606 +
22607 +static DEFINE_SPINLOCK(nx_info_hash_lock);
22608 +
22609 +
22610 +static inline unsigned int __hashval(nid_t nid)
22611 +{
22612 +       return (nid % NX_HASH_SIZE);
22613 +}
22614 +
22615 +
22616 +
22617 +/*     __hash_nx_info()
22618 +
22619 +       * add the nxi to the global hash table
22620 +       * requires the hash_lock to be held                     */
22621 +
22622 +static inline void __hash_nx_info(struct nx_info *nxi)
22623 +{
22624 +       struct hlist_head *head;
22625 +
22626 +       vxd_assert_lock(&nx_info_hash_lock);
22627 +       vxdprintk(VXD_CBIT(nid, 4),
22628 +               "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
22629 +
22630 +       /* context must not be hashed */
22631 +       BUG_ON(nx_info_state(nxi, NXS_HASHED));
22632 +
22633 +       nxi->nx_state |= NXS_HASHED;
22634 +       head = &nx_info_hash[__hashval(nxi->nx_id)];
22635 +       hlist_add_head(&nxi->nx_hlist, head);
22636 +       atomic_inc(&nx_global_cactive);
22637 +}
22638 +
22639 +/*     __unhash_nx_info()
22640 +
22641 +       * remove the nxi from the global hash table
22642 +       * requires the hash_lock to be held                     */
22643 +
22644 +static inline void __unhash_nx_info(struct nx_info *nxi)
22645 +{
22646 +       vxd_assert_lock(&nx_info_hash_lock);
22647 +       vxdprintk(VXD_CBIT(nid, 4),
22648 +               "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
22649 +               atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
22650 +
22651 +       /* context must be hashed */
22652 +       BUG_ON(!nx_info_state(nxi, NXS_HASHED));
22653 +       /* but without tasks */
22654 +       BUG_ON(atomic_read(&nxi->nx_tasks));
22655 +
22656 +       nxi->nx_state &= ~NXS_HASHED;
22657 +       hlist_del(&nxi->nx_hlist);
22658 +       atomic_dec(&nx_global_cactive);
22659 +}
22660 +
22661 +
22662 +/*     __lookup_nx_info()
22663 +
22664 +       * requires the hash_lock to be held
22665 +       * doesn't increment the nx_refcnt                       */
22666 +
22667 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
22668 +{
22669 +       struct hlist_head *head = &nx_info_hash[__hashval(nid)];
22670 +       struct hlist_node *pos;
22671 +       struct nx_info *nxi;
22672 +
22673 +       vxd_assert_lock(&nx_info_hash_lock);
22674 +       hlist_for_each(pos, head) {
22675 +               nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22676 +
22677 +               if (nxi->nx_id == nid)
22678 +                       goto found;
22679 +       }
22680 +       nxi = NULL;
22681 +found:
22682 +       vxdprintk(VXD_CBIT(nid, 0),
22683 +               "__lookup_nx_info(#%u): %p[#%u]",
22684 +               nid, nxi, nxi ? nxi->nx_id : 0);
22685 +       return nxi;
22686 +}
22687 +
22688 +
22689 +/*     __create_nx_info()
22690 +
22691 +       * create the requested context
22692 +       * get(), claim() and hash it                            */
22693 +
22694 +static struct nx_info *__create_nx_info(int id)
22695 +{
22696 +       struct nx_info *new, *nxi = NULL;
22697 +
22698 +       vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
22699 +
22700 +       if (!(new = __alloc_nx_info(id)))
22701 +               return ERR_PTR(-ENOMEM);
22702 +
22703 +       /* required to make dynamic xids unique */
22704 +       spin_lock(&nx_info_hash_lock);
22705 +
22706 +       /* static context requested */
22707 +       if ((nxi = __lookup_nx_info(id))) {
22708 +               vxdprintk(VXD_CBIT(nid, 0),
22709 +                       "create_nx_info(%d) = %p (already there)", id, nxi);
22710 +               if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22711 +                       nxi = ERR_PTR(-EBUSY);
22712 +               else
22713 +                       nxi = ERR_PTR(-EEXIST);
22714 +               goto out_unlock;
22715 +       }
22716 +       /* new context */
22717 +       vxdprintk(VXD_CBIT(nid, 0),
22718 +               "create_nx_info(%d) = %p (new)", id, new);
22719 +       claim_nx_info(new, NULL);
22720 +       __nx_set_lback(new);
22721 +       __hash_nx_info(get_nx_info(new));
22722 +       nxi = new, new = NULL;
22723 +
22724 +out_unlock:
22725 +       spin_unlock(&nx_info_hash_lock);
22726 +       if (new)
22727 +               __dealloc_nx_info(new);
22728 +       return nxi;
22729 +}
22730 +
22731 +
22732 +
22733 +/*     exported stuff                                          */
22734 +
22735 +
22736 +void unhash_nx_info(struct nx_info *nxi)
22737 +{
22738 +       __shutdown_nx_info(nxi);
22739 +       spin_lock(&nx_info_hash_lock);
22740 +       __unhash_nx_info(nxi);
22741 +       spin_unlock(&nx_info_hash_lock);
22742 +}
22743 +
22744 +/*     lookup_nx_info()
22745 +
22746 +       * search for a nx_info and get() it
22747 +       * negative id means current                             */
22748 +
22749 +struct nx_info *lookup_nx_info(int id)
22750 +{
22751 +       struct nx_info *nxi = NULL;
22752 +
22753 +       if (id < 0) {
22754 +               nxi = get_nx_info(current_nx_info());
22755 +       } else if (id > 1) {
22756 +               spin_lock(&nx_info_hash_lock);
22757 +               nxi = get_nx_info(__lookup_nx_info(id));
22758 +               spin_unlock(&nx_info_hash_lock);
22759 +       }
22760 +       return nxi;
22761 +}
22762 +
22763 +/*     nid_is_hashed()
22764 +
22765 +       * verify that nid is still hashed                       */
22766 +
22767 +int nid_is_hashed(nid_t nid)
22768 +{
22769 +       int hashed;
22770 +
22771 +       spin_lock(&nx_info_hash_lock);
22772 +       hashed = (__lookup_nx_info(nid) != NULL);
22773 +       spin_unlock(&nx_info_hash_lock);
22774 +       return hashed;
22775 +}
22776 +
22777 +
22778 +#ifdef CONFIG_PROC_FS
22779 +
22780 +/*     get_nid_list()
22781 +
22782 +       * get a subset of hashed nids for proc
22783 +       * assumes size is at least one                          */
22784 +
22785 +int get_nid_list(int index, unsigned int *nids, int size)
22786 +{
22787 +       int hindex, nr_nids = 0;
22788 +
22789 +       /* only show current and children */
22790 +       if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
22791 +               if (index > 0)
22792 +                       return 0;
22793 +               nids[nr_nids] = nx_current_nid();
22794 +               return 1;
22795 +       }
22796 +
22797 +       for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
22798 +               struct hlist_head *head = &nx_info_hash[hindex];
22799 +               struct hlist_node *pos;
22800 +
22801 +               spin_lock(&nx_info_hash_lock);
22802 +               hlist_for_each(pos, head) {
22803 +                       struct nx_info *nxi;
22804 +
22805 +                       if (--index > 0)
22806 +                               continue;
22807 +
22808 +                       nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22809 +                       nids[nr_nids] = nxi->nx_id;
22810 +                       if (++nr_nids >= size) {
22811 +                               spin_unlock(&nx_info_hash_lock);
22812 +                               goto out;
22813 +                       }
22814 +               }
22815 +               /* keep the lock time short */
22816 +               spin_unlock(&nx_info_hash_lock);
22817 +       }
22818 +out:
22819 +       return nr_nids;
22820 +}
22821 +#endif
22822 +
22823 +
22824 +/*
22825 + *     migrate task to new network
22826 + *     gets nxi, puts old_nxi on change
22827 + */
22828 +
22829 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
22830 +{
22831 +       struct nx_info *old_nxi;
22832 +       int ret = 0;
22833 +
22834 +       if (!p || !nxi)
22835 +               BUG();
22836 +
22837 +       vxdprintk(VXD_CBIT(nid, 5),
22838 +               "nx_migrate_task(%p,%p[#%d.%d.%d])",
22839 +               p, nxi, nxi->nx_id,
22840 +               atomic_read(&nxi->nx_usecnt),
22841 +               atomic_read(&nxi->nx_tasks));
22842 +
22843 +       if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
22844 +               !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22845 +               return -EACCES;
22846 +
22847 +       if (nx_info_state(nxi, NXS_SHUTDOWN))
22848 +               return -EFAULT;
22849 +
22850 +       /* maybe disallow this completely? */
22851 +       old_nxi = task_get_nx_info(p);
22852 +       if (old_nxi == nxi)
22853 +               goto out;
22854 +
22855 +       task_lock(p);
22856 +       if (old_nxi)
22857 +               clr_nx_info(&p->nx_info);
22858 +       claim_nx_info(nxi, p);
22859 +       set_nx_info(&p->nx_info, nxi);
22860 +       p->nid = nxi->nx_id;
22861 +       task_unlock(p);
22862 +
22863 +       vxdprintk(VXD_CBIT(nid, 5),
22864 +               "moved task %p into nxi:%p[#%d]",
22865 +               p, nxi, nxi->nx_id);
22866 +
22867 +       if (old_nxi)
22868 +               release_nx_info(old_nxi, p);
22869 +       ret = 0;
22870 +out:
22871 +       put_nx_info(old_nxi);
22872 +       return ret;
22873 +}
22874 +
22875 +
22876 +void nx_set_persistent(struct nx_info *nxi)
22877 +{
22878 +       vxdprintk(VXD_CBIT(nid, 6),
22879 +               "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
22880 +
22881 +       get_nx_info(nxi);
22882 +       claim_nx_info(nxi, NULL);
22883 +}
22884 +
22885 +void nx_clear_persistent(struct nx_info *nxi)
22886 +{
22887 +       vxdprintk(VXD_CBIT(nid, 6),
22888 +               "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
22889 +
22890 +       release_nx_info(nxi, NULL);
22891 +       put_nx_info(nxi);
22892 +}
22893 +
22894 +void nx_update_persistent(struct nx_info *nxi)
22895 +{
22896 +       if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
22897 +               nx_set_persistent(nxi);
22898 +       else
22899 +               nx_clear_persistent(nxi);
22900 +}
22901 +
22902 +/* vserver syscall commands below here */
22903 +
22904 +/* taks nid and nx_info functions */
22905 +
22906 +#include <asm/uaccess.h>
22907 +
22908 +
22909 +int vc_task_nid(uint32_t id)
22910 +{
22911 +       nid_t nid;
22912 +
22913 +       if (id) {
22914 +               struct task_struct *tsk;
22915 +
22916 +               rcu_read_lock();
22917 +               tsk = find_task_by_real_pid(id);
22918 +               nid = (tsk) ? tsk->nid : -ESRCH;
22919 +               rcu_read_unlock();
22920 +       } else
22921 +               nid = nx_current_nid();
22922 +       return nid;
22923 +}
22924 +
22925 +
22926 +int vc_nx_info(struct nx_info *nxi, void __user *data)
22927 +{
22928 +       struct vcmd_nx_info_v0 vc_data;
22929 +
22930 +       vc_data.nid = nxi->nx_id;
22931 +
22932 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22933 +               return -EFAULT;
22934 +       return 0;
22935 +}
22936 +
22937 +
22938 +/* network functions */
22939 +
22940 +int vc_net_create(uint32_t nid, void __user *data)
22941 +{
22942 +       struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
22943 +       struct nx_info *new_nxi;
22944 +       int ret;
22945 +
22946 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22947 +               return -EFAULT;
22948 +
22949 +       if ((nid > MAX_S_CONTEXT) || (nid < 2))
22950 +               return -EINVAL;
22951 +
22952 +       new_nxi = __create_nx_info(nid);
22953 +       if (IS_ERR(new_nxi))
22954 +               return PTR_ERR(new_nxi);
22955 +
22956 +       /* initial flags */
22957 +       new_nxi->nx_flags = vc_data.flagword;
22958 +
22959 +       ret = -ENOEXEC;
22960 +       if (vs_net_change(new_nxi, VSC_NETUP))
22961 +               goto out;
22962 +
22963 +       ret = nx_migrate_task(current, new_nxi);
22964 +       if (ret)
22965 +               goto out;
22966 +
22967 +       /* return context id on success */
22968 +       ret = new_nxi->nx_id;
22969 +
22970 +       /* get a reference for persistent contexts */
22971 +       if ((vc_data.flagword & NXF_PERSISTENT))
22972 +               nx_set_persistent(new_nxi);
22973 +out:
22974 +       release_nx_info(new_nxi, NULL);
22975 +       put_nx_info(new_nxi);
22976 +       return ret;
22977 +}
22978 +
22979 +
22980 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
22981 +{
22982 +       return nx_migrate_task(current, nxi);
22983 +}
22984 +
22985 +
22986 +
22987 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
22988 +       uint16_t type, uint16_t flags)
22989 +{
22990 +       struct nx_addr_v4 *nxa = &nxi->v4;
22991 +
22992 +       if (NX_IPV4(nxi)) {
22993 +               /* locate last entry */
22994 +               for (; nxa->next; nxa = nxa->next);
22995 +               nxa->next = __alloc_nx_addr_v4();
22996 +               nxa = nxa->next;
22997 +
22998 +               if (IS_ERR(nxa))
22999 +                       return PTR_ERR(nxa);
23000 +       }
23001 +
23002 +       if (nxi->v4.next)
23003 +               /* remove single ip for ip list */
23004 +               nxi->nx_flags &= ~NXF_SINGLE_IP;
23005 +
23006 +       nxa->ip[0].s_addr = ip;
23007 +       nxa->ip[1].s_addr = ip2;
23008 +       nxa->mask.s_addr = mask;
23009 +       nxa->type = type;
23010 +       nxa->flags = flags;
23011 +       return 0;
23012 +}
23013 +
23014 +int do_remove_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
23015 +       uint16_t type, uint16_t flags)
23016 +{
23017 +       struct nx_addr_v4 *nxa = &nxi->v4;
23018 +
23019 +       switch (type) {
23020 +/*     case NXA_TYPE_ADDR:
23021 +               break;          */
23022 +
23023 +       case NXA_TYPE_ANY:
23024 +               __dealloc_nx_addr_v4_all(xchg(&nxa->next, NULL));
23025 +               memset(nxa, 0, sizeof(*nxa));
23026 +               break;
23027 +
23028 +       default:
23029 +               return -EINVAL;
23030 +       }
23031 +       return 0;
23032 +}
23033 +
23034 +
23035 +int vc_net_add(struct nx_info *nxi, void __user *data)
23036 +{
23037 +       struct vcmd_net_addr_v0 vc_data;
23038 +       int index, ret = 0;
23039 +
23040 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23041 +               return -EFAULT;
23042 +
23043 +       switch (vc_data.type) {
23044 +       case NXA_TYPE_IPV4:
23045 +               if ((vc_data.count < 1) || (vc_data.count > 4))
23046 +                       return -EINVAL;
23047 +
23048 +               index = 0;
23049 +               while (index < vc_data.count) {
23050 +                       ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
23051 +                               vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
23052 +                       if (ret)
23053 +                               return ret;
23054 +                       index++;
23055 +               }
23056 +               ret = index;
23057 +               break;
23058 +
23059 +       case NXA_TYPE_IPV4|NXA_MOD_BCAST:
23060 +               nxi->v4_bcast = vc_data.ip[0];
23061 +               ret = 1;
23062 +               break;
23063 +
23064 +       case NXA_TYPE_IPV4|NXA_MOD_LBACK:
23065 +               nxi->v4_lback = vc_data.ip[0];
23066 +               ret = 1;
23067 +               break;
23068 +
23069 +       default:
23070 +               ret = -EINVAL;
23071 +               break;
23072 +       }
23073 +       return ret;
23074 +}
23075 +
23076 +int vc_net_remove(struct nx_info *nxi, void __user *data)
23077 +{
23078 +       struct vcmd_net_addr_v0 vc_data;
23079 +
23080 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23081 +               return -EFAULT;
23082 +
23083 +       switch (vc_data.type) {
23084 +       case NXA_TYPE_ANY:
23085 +               __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
23086 +               memset(&nxi->v4, 0, sizeof(nxi->v4));
23087 +               break;
23088 +
23089 +       default:
23090 +               return -EINVAL;
23091 +       }
23092 +       return 0;
23093 +}
23094 +
23095 +
23096 +int vc_net_add_ipv4_v1(struct nx_info *nxi, void __user *data)
23097 +{
23098 +       struct vcmd_net_addr_ipv4_v1 vc_data;
23099 +
23100 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23101 +               return -EFAULT;
23102 +
23103 +       switch (vc_data.type) {
23104 +       case NXA_TYPE_ADDR:
23105 +       case NXA_TYPE_MASK:
23106 +               return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
23107 +                       vc_data.mask.s_addr, vc_data.type, vc_data.flags);
23108 +
23109 +       case NXA_TYPE_ADDR | NXA_MOD_BCAST:
23110 +               nxi->v4_bcast = vc_data.ip;
23111 +               break;
23112 +
23113 +       case NXA_TYPE_ADDR | NXA_MOD_LBACK:
23114 +               nxi->v4_lback = vc_data.ip;
23115 +               break;
23116 +
23117 +       default:
23118 +               return -EINVAL;
23119 +       }
23120 +       return 0;
23121 +}
23122 +
23123 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
23124 +{
23125 +       struct vcmd_net_addr_ipv4_v2 vc_data;
23126 +
23127 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23128 +               return -EFAULT;
23129 +
23130 +       switch (vc_data.type) {
23131 +       case NXA_TYPE_ADDR:
23132 +       case NXA_TYPE_MASK:
23133 +       case NXA_TYPE_RANGE:
23134 +               return do_add_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
23135 +                       vc_data.mask.s_addr, vc_data.type, vc_data.flags);
23136 +
23137 +       case NXA_TYPE_ADDR | NXA_MOD_BCAST:
23138 +               nxi->v4_bcast = vc_data.ip;
23139 +               break;
23140 +
23141 +       case NXA_TYPE_ADDR | NXA_MOD_LBACK:
23142 +               nxi->v4_lback = vc_data.ip;
23143 +               break;
23144 +
23145 +       default:
23146 +               return -EINVAL;
23147 +       }
23148 +       return 0;
23149 +}
23150 +
23151 +int vc_net_rem_ipv4_v1(struct nx_info *nxi, void __user *data)
23152 +{
23153 +       struct vcmd_net_addr_ipv4_v1 vc_data;
23154 +
23155 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23156 +               return -EFAULT;
23157 +
23158 +       return do_remove_v4_addr(nxi, vc_data.ip.s_addr, 0,
23159 +               vc_data.mask.s_addr, vc_data.type, vc_data.flags);
23160 +}
23161 +
23162 +int vc_net_rem_ipv4(struct nx_info *nxi, void __user *data)
23163 +{
23164 +       struct vcmd_net_addr_ipv4_v2 vc_data;
23165 +
23166 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23167 +               return -EFAULT;
23168 +
23169 +       return do_remove_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
23170 +               vc_data.mask.s_addr, vc_data.type, vc_data.flags);
23171 +}
23172 +
23173 +#ifdef CONFIG_IPV6
23174 +
23175 +int do_add_v6_addr(struct nx_info *nxi,
23176 +       struct in6_addr *ip, struct in6_addr *mask,
23177 +       uint32_t prefix, uint16_t type, uint16_t flags)
23178 +{
23179 +       struct nx_addr_v6 *nxa = &nxi->v6;
23180 +
23181 +       if (NX_IPV6(nxi)) {
23182 +               /* locate last entry */
23183 +               for (; nxa->next; nxa = nxa->next);
23184 +               nxa->next = __alloc_nx_addr_v6();
23185 +               nxa = nxa->next;
23186 +
23187 +               if (IS_ERR(nxa))
23188 +                       return PTR_ERR(nxa);
23189 +       }
23190 +
23191 +       nxa->ip = *ip;
23192 +       nxa->mask = *mask;
23193 +       nxa->prefix = prefix;
23194 +       nxa->type = type;
23195 +       nxa->flags = flags;
23196 +       return 0;
23197 +}
23198 +
23199 +
23200 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
23201 +{
23202 +       struct vcmd_net_addr_ipv6_v1 vc_data;
23203 +
23204 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23205 +               return -EFAULT;
23206 +
23207 +       switch (vc_data.type) {
23208 +       case NXA_TYPE_ADDR:
23209 +               memset(&vc_data.mask, ~0, sizeof(vc_data.mask));
23210 +               /* fallthrough */
23211 +       case NXA_TYPE_MASK:
23212 +               return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
23213 +                       vc_data.prefix, vc_data.type, vc_data.flags);
23214 +       default:
23215 +               return -EINVAL;
23216 +       }
23217 +       return 0;
23218 +}
23219 +
23220 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
23221 +{
23222 +       struct vcmd_net_addr_ipv6_v1 vc_data;
23223 +
23224 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23225 +               return -EFAULT;
23226 +
23227 +       switch (vc_data.type) {
23228 +       case NXA_TYPE_ANY:
23229 +               __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
23230 +               memset(&nxi->v6, 0, sizeof(nxi->v6));
23231 +               break;
23232 +
23233 +       default:
23234 +               return -EINVAL;
23235 +       }
23236 +       return 0;
23237 +}
23238 +
23239 +#endif /* CONFIG_IPV6 */
23240 +
23241 +
23242 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
23243 +{
23244 +       struct vcmd_net_flags_v0 vc_data;
23245 +
23246 +       vc_data.flagword = nxi->nx_flags;
23247 +
23248 +       /* special STATE flag handling */
23249 +       vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
23250 +
23251 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23252 +               return -EFAULT;
23253 +       return 0;
23254 +}
23255 +
23256 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
23257 +{
23258 +       struct vcmd_net_flags_v0 vc_data;
23259 +       uint64_t mask, trigger;
23260 +
23261 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23262 +               return -EFAULT;
23263 +
23264 +       /* special STATE flag handling */
23265 +       mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
23266 +       trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
23267 +
23268 +       nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
23269 +               vc_data.flagword, mask);
23270 +       if (trigger & NXF_PERSISTENT)
23271 +               nx_update_persistent(nxi);
23272 +
23273 +       return 0;
23274 +}
23275 +
23276 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
23277 +{
23278 +       struct vcmd_net_caps_v0 vc_data;
23279 +
23280 +       vc_data.ncaps = nxi->nx_ncaps;
23281 +       vc_data.cmask = ~0ULL;
23282 +
23283 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23284 +               return -EFAULT;
23285 +       return 0;
23286 +}
23287 +
23288 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
23289 +{
23290 +       struct vcmd_net_caps_v0 vc_data;
23291 +
23292 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23293 +               return -EFAULT;
23294 +
23295 +       nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
23296 +               vc_data.ncaps, vc_data.cmask);
23297 +       return 0;
23298 +}
23299 +
23300 +
23301 +#include <linux/module.h>
23302 +
23303 +module_init(init_network);
23304 +
23305 +EXPORT_SYMBOL_GPL(free_nx_info);
23306 +EXPORT_SYMBOL_GPL(unhash_nx_info);
23307 +
23308 diff -NurpP --minimal linux-3.0.4/kernel/vserver/proc.c linux-3.0.4-vs2.3.1/kernel/vserver/proc.c
23309 --- linux-3.0.4/kernel/vserver/proc.c   1970-01-01 01:00:00.000000000 +0100
23310 +++ linux-3.0.4-vs2.3.1/kernel/vserver/proc.c   2011-08-01 19:57:21.000000000 +0200
23311 @@ -0,0 +1,1103 @@
23312 +/*
23313 + *  linux/kernel/vserver/proc.c
23314 + *
23315 + *  Virtual Context Support
23316 + *
23317 + *  Copyright (C) 2003-2011  Herbert Pötzl
23318 + *
23319 + *  V0.01  basic structure
23320 + *  V0.02  adaptation vs1.3.0
23321 + *  V0.03  proc permissions
23322 + *  V0.04  locking/generic
23323 + *  V0.05  next generation procfs
23324 + *  V0.06  inode validation
23325 + *  V0.07  generic rewrite vid
23326 + *  V0.08  remove inode type
23327 + *  V0.09  added u/wmask info
23328 + *
23329 + */
23330 +
23331 +#include <linux/proc_fs.h>
23332 +#include <linux/fs_struct.h>
23333 +#include <linux/mount.h>
23334 +#include <asm/unistd.h>
23335 +
23336 +#include <linux/vs_context.h>
23337 +#include <linux/vs_network.h>
23338 +#include <linux/vs_cvirt.h>
23339 +
23340 +#include <linux/in.h>
23341 +#include <linux/inetdevice.h>
23342 +#include <linux/vs_inet.h>
23343 +#include <linux/vs_inet6.h>
23344 +
23345 +#include <linux/vserver/global.h>
23346 +
23347 +#include "cvirt_proc.h"
23348 +#include "cacct_proc.h"
23349 +#include "limit_proc.h"
23350 +#include "sched_proc.h"
23351 +#include "vci_config.h"
23352 +
23353 +
23354 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
23355 +{
23356 +       unsigned __capi;
23357 +
23358 +       CAP_FOR_EACH_U32(__capi) {
23359 +               buffer += sprintf(buffer, "%08x",
23360 +                       c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
23361 +       }
23362 +       return buffer;
23363 +}
23364 +
23365 +
23366 +static struct proc_dir_entry *proc_virtual;
23367 +
23368 +static struct proc_dir_entry *proc_virtnet;
23369 +
23370 +
23371 +/* first the actual feeds */
23372 +
23373 +
23374 +static int proc_vci(char *buffer)
23375 +{
23376 +       return sprintf(buffer,
23377 +               "VCIVersion:\t%04x:%04x\n"
23378 +               "VCISyscall:\t%d\n"
23379 +               "VCIKernel:\t%08x\n",
23380 +               VCI_VERSION >> 16,
23381 +               VCI_VERSION & 0xFFFF,
23382 +               __NR_vserver,
23383 +               vci_kernel_config());
23384 +}
23385 +
23386 +static int proc_virtual_info(char *buffer)
23387 +{
23388 +       return proc_vci(buffer);
23389 +}
23390 +
23391 +static int proc_virtual_status(char *buffer)
23392 +{
23393 +       return sprintf(buffer,
23394 +               "#CTotal:\t%d\n"
23395 +               "#CActive:\t%d\n"
23396 +               "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
23397 +               "#InitTask:\t%d\t%d %d\n",
23398 +               atomic_read(&vx_global_ctotal),
23399 +               atomic_read(&vx_global_cactive),
23400 +               atomic_read(&vs_global_nsproxy),
23401 +               atomic_read(&vs_global_fs),
23402 +               atomic_read(&vs_global_mnt_ns),
23403 +               atomic_read(&vs_global_uts_ns),
23404 +               atomic_read(&nr_ipc_ns),
23405 +               atomic_read(&vs_global_user_ns),
23406 +               atomic_read(&vs_global_pid_ns),
23407 +               atomic_read(&init_task.usage),
23408 +               atomic_read(&init_task.nsproxy->count),
23409 +               init_task.fs->users);
23410 +}
23411 +
23412 +
23413 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
23414 +{
23415 +       int length;
23416 +
23417 +       length = sprintf(buffer,
23418 +               "ID:\t%d\n"
23419 +               "Info:\t%p\n"
23420 +               "Init:\t%d\n"
23421 +               "OOM:\t%lld\n",
23422 +               vxi->vx_id,
23423 +               vxi,
23424 +               vxi->vx_initpid,
23425 +               vxi->vx_badness_bias);
23426 +       return length;
23427 +}
23428 +
23429 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
23430 +{
23431 +       char *orig = buffer;
23432 +
23433 +       buffer += sprintf(buffer,
23434 +               "UseCnt:\t%d\n"
23435 +               "Tasks:\t%d\n"
23436 +               "Flags:\t%016llx\n",
23437 +               atomic_read(&vxi->vx_usecnt),
23438 +               atomic_read(&vxi->vx_tasks),
23439 +               (unsigned long long)vxi->vx_flags);
23440 +
23441 +       buffer += sprintf(buffer, "BCaps:\t");
23442 +       buffer = print_cap_t(buffer, &vxi->vx_bcaps);
23443 +       buffer += sprintf(buffer, "\n");
23444 +
23445 +       buffer += sprintf(buffer,
23446 +               "CCaps:\t%016llx\n"
23447 +               "Umask:\t%16llx\n"
23448 +               "Wmask:\t%16llx\n"
23449 +               "Spaces:\t%08lx %08lx\n",
23450 +               (unsigned long long)vxi->vx_ccaps,
23451 +               (unsigned long long)vxi->vx_umask,
23452 +               (unsigned long long)vxi->vx_wmask,
23453 +               vxi->space[0].vx_nsmask, vxi->space[1].vx_nsmask);
23454 +       return buffer - orig;
23455 +}
23456 +
23457 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
23458 +{
23459 +       return vx_info_proc_limit(&vxi->limit, buffer);
23460 +}
23461 +
23462 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
23463 +{
23464 +       int cpu, length;
23465 +
23466 +       length = vx_info_proc_sched(&vxi->sched, buffer);
23467 +       for_each_online_cpu(cpu) {
23468 +               length += vx_info_proc_sched_pc(
23469 +                       &vx_per_cpu(vxi, sched_pc, cpu),
23470 +                       buffer + length, cpu);
23471 +       }
23472 +       return length;
23473 +}
23474 +
23475 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
23476 +{
23477 +       return vx_info_proc_nsproxy(vxi->space[0].vx_nsproxy, buffer);
23478 +}
23479 +
23480 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
23481 +{
23482 +       return vx_info_proc_nsproxy(vxi->space[1].vx_nsproxy, buffer);
23483 +}
23484 +
23485 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
23486 +{
23487 +       int cpu, length;
23488 +
23489 +       vx_update_load(vxi);
23490 +       length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
23491 +       for_each_online_cpu(cpu) {
23492 +               length += vx_info_proc_cvirt_pc(
23493 +                       &vx_per_cpu(vxi, cvirt_pc, cpu),
23494 +                       buffer + length, cpu);
23495 +       }
23496 +       return length;
23497 +}
23498 +
23499 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
23500 +{
23501 +       return vx_info_proc_cacct(&vxi->cacct, buffer);
23502 +}
23503 +
23504 +
23505 +static int proc_virtnet_info(char *buffer)
23506 +{
23507 +       return proc_vci(buffer);
23508 +}
23509 +
23510 +static int proc_virtnet_status(char *buffer)
23511 +{
23512 +       return sprintf(buffer,
23513 +               "#CTotal:\t%d\n"
23514 +               "#CActive:\t%d\n",
23515 +               atomic_read(&nx_global_ctotal),
23516 +               atomic_read(&nx_global_cactive));
23517 +}
23518 +
23519 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
23520 +{
23521 +       struct nx_addr_v4 *v4a;
23522 +#ifdef CONFIG_IPV6
23523 +       struct nx_addr_v6 *v6a;
23524 +#endif
23525 +       int length, i;
23526 +
23527 +       length = sprintf(buffer,
23528 +               "ID:\t%d\n"
23529 +               "Info:\t%p\n"
23530 +               "Bcast:\t" NIPQUAD_FMT "\n"
23531 +               "Lback:\t" NIPQUAD_FMT "\n",
23532 +               nxi->nx_id,
23533 +               nxi,
23534 +               NIPQUAD(nxi->v4_bcast.s_addr),
23535 +               NIPQUAD(nxi->v4_lback.s_addr));
23536 +
23537 +       if (!NX_IPV4(nxi))
23538 +               goto skip_v4;
23539 +       for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
23540 +               length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
23541 +                       i, NXAV4(v4a));
23542 +skip_v4:
23543 +#ifdef CONFIG_IPV6
23544 +       if (!NX_IPV6(nxi))
23545 +               goto skip_v6;
23546 +       for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
23547 +               length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
23548 +                       i, NXAV6(v6a));
23549 +skip_v6:
23550 +#endif
23551 +       return length;
23552 +}
23553 +
23554 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
23555 +{
23556 +       int length;
23557 +
23558 +       length = sprintf(buffer,
23559 +               "UseCnt:\t%d\n"
23560 +               "Tasks:\t%d\n"
23561 +               "Flags:\t%016llx\n"
23562 +               "NCaps:\t%016llx\n",
23563 +               atomic_read(&nxi->nx_usecnt),
23564 +               atomic_read(&nxi->nx_tasks),
23565 +               (unsigned long long)nxi->nx_flags,
23566 +               (unsigned long long)nxi->nx_ncaps);
23567 +       return length;
23568 +}
23569 +
23570 +
23571 +
23572 +/* here the inode helpers */
23573 +
23574 +struct vs_entry {
23575 +       int len;
23576 +       char *name;
23577 +       mode_t mode;
23578 +       struct inode_operations *iop;
23579 +       struct file_operations *fop;
23580 +       union proc_op op;
23581 +};
23582 +
23583 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
23584 +{
23585 +       struct inode *inode = new_inode(sb);
23586 +
23587 +       if (!inode)
23588 +               goto out;
23589 +
23590 +       inode->i_mode = p->mode;
23591 +       if (p->iop)
23592 +               inode->i_op = p->iop;
23593 +       if (p->fop)
23594 +               inode->i_fop = p->fop;
23595 +
23596 +       inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
23597 +       inode->i_flags |= S_IMMUTABLE;
23598 +
23599 +       inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
23600 +
23601 +       inode->i_uid = 0;
23602 +       inode->i_gid = 0;
23603 +       inode->i_tag = 0;
23604 +out:
23605 +       return inode;
23606 +}
23607 +
23608 +static struct dentry *vs_proc_instantiate(struct inode *dir,
23609 +       struct dentry *dentry, int id, void *ptr)
23610 +{
23611 +       struct vs_entry *p = ptr;
23612 +       struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
23613 +       struct dentry *error = ERR_PTR(-EINVAL);
23614 +
23615 +       if (!inode)
23616 +               goto out;
23617 +
23618 +       PROC_I(inode)->op = p->op;
23619 +       PROC_I(inode)->fd = id;
23620 +       d_add(dentry, inode);
23621 +       error = NULL;
23622 +out:
23623 +       return error;
23624 +}
23625 +
23626 +/* Lookups */
23627 +
23628 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
23629 +
23630 +/*
23631 + * Fill a directory entry.
23632 + *
23633 + * If possible create the dcache entry and derive our inode number and
23634 + * file type from dcache entry.
23635 + *
23636 + * Since all of the proc inode numbers are dynamically generated, the inode
23637 + * numbers do not exist until the inode is cache.  This means creating the
23638 + * the dcache entry in readdir is necessary to keep the inode numbers
23639 + * reported by readdir in sync with the inode numbers reported
23640 + * by stat.
23641 + */
23642 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
23643 +       char *name, int len, instantiate_t instantiate, int id, void *ptr)
23644 +{
23645 +       struct dentry *child, *dir = filp->f_dentry;
23646 +       struct inode *inode;
23647 +       struct qstr qname;
23648 +       ino_t ino = 0;
23649 +       unsigned type = DT_UNKNOWN;
23650 +
23651 +       qname.name = name;
23652 +       qname.len  = len;
23653 +       qname.hash = full_name_hash(name, len);
23654 +
23655 +       child = d_lookup(dir, &qname);
23656 +       if (!child) {
23657 +               struct dentry *new;
23658 +               new = d_alloc(dir, &qname);
23659 +               if (new) {
23660 +                       child = instantiate(dir->d_inode, new, id, ptr);
23661 +                       if (child)
23662 +                               dput(new);
23663 +                       else
23664 +                               child = new;
23665 +               }
23666 +       }
23667 +       if (!child || IS_ERR(child) || !child->d_inode)
23668 +               goto end_instantiate;
23669 +       inode = child->d_inode;
23670 +       if (inode) {
23671 +               ino = inode->i_ino;
23672 +               type = inode->i_mode >> 12;
23673 +       }
23674 +       dput(child);
23675 +end_instantiate:
23676 +       if (!ino)
23677 +               ino = find_inode_number(dir, &qname);
23678 +       if (!ino)
23679 +               ino = 1;
23680 +       return filldir(dirent, name, len, filp->f_pos, ino, type);
23681 +}
23682 +
23683 +
23684 +
23685 +/* get and revalidate vx_info/xid */
23686 +
23687 +static inline
23688 +struct vx_info *get_proc_vx_info(struct inode *inode)
23689 +{
23690 +       return lookup_vx_info(PROC_I(inode)->fd);
23691 +}
23692 +
23693 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
23694 +{
23695 +       struct inode *inode = dentry->d_inode;
23696 +       xid_t xid = PROC_I(inode)->fd;
23697 +
23698 +       if (!xid || xid_is_hashed(xid))
23699 +               return 1;
23700 +       d_drop(dentry);
23701 +       return 0;
23702 +}
23703 +
23704 +
23705 +/* get and revalidate nx_info/nid */
23706 +
23707 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
23708 +{
23709 +       struct inode *inode = dentry->d_inode;
23710 +       nid_t nid = PROC_I(inode)->fd;
23711 +
23712 +       if (!nid || nid_is_hashed(nid))
23713 +               return 1;
23714 +       d_drop(dentry);
23715 +       return 0;
23716 +}
23717 +
23718 +
23719 +
23720 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
23721 +
23722 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
23723 +                         size_t count, loff_t *ppos)
23724 +{
23725 +       struct inode *inode = file->f_dentry->d_inode;
23726 +       unsigned long page;
23727 +       ssize_t length = 0;
23728 +
23729 +       if (count > PROC_BLOCK_SIZE)
23730 +               count = PROC_BLOCK_SIZE;
23731 +
23732 +       /* fade that out as soon as stable */
23733 +       WARN_ON(PROC_I(inode)->fd);
23734 +
23735 +       if (!(page = __get_free_page(GFP_KERNEL)))
23736 +               return -ENOMEM;
23737 +
23738 +       BUG_ON(!PROC_I(inode)->op.proc_vs_read);
23739 +       length = PROC_I(inode)->op.proc_vs_read((char *)page);
23740 +
23741 +       if (length >= 0)
23742 +               length = simple_read_from_buffer(buf, count, ppos,
23743 +                       (char *)page, length);
23744 +
23745 +       free_page(page);
23746 +       return length;
23747 +}
23748 +
23749 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
23750 +                         size_t count, loff_t *ppos)
23751 +{
23752 +       struct inode *inode = file->f_dentry->d_inode;
23753 +       struct vx_info *vxi = NULL;
23754 +       xid_t xid = PROC_I(inode)->fd;
23755 +       unsigned long page;
23756 +       ssize_t length = 0;
23757 +
23758 +       if (count > PROC_BLOCK_SIZE)
23759 +               count = PROC_BLOCK_SIZE;
23760 +
23761 +       /* fade that out as soon as stable */
23762 +       WARN_ON(!xid);
23763 +       vxi = lookup_vx_info(xid);
23764 +       if (!vxi)
23765 +               goto out;
23766 +
23767 +       length = -ENOMEM;
23768 +       if (!(page = __get_free_page(GFP_KERNEL)))
23769 +               goto out_put;
23770 +
23771 +       BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
23772 +       length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
23773 +
23774 +       if (length >= 0)
23775 +               length = simple_read_from_buffer(buf, count, ppos,
23776 +                       (char *)page, length);
23777 +
23778 +       free_page(page);
23779 +out_put:
23780 +       put_vx_info(vxi);
23781 +out:
23782 +       return length;
23783 +}
23784 +
23785 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
23786 +                         size_t count, loff_t *ppos)
23787 +{
23788 +       struct inode *inode = file->f_dentry->d_inode;
23789 +       struct nx_info *nxi = NULL;
23790 +       nid_t nid = PROC_I(inode)->fd;
23791 +       unsigned long page;
23792 +       ssize_t length = 0;
23793 +
23794 +       if (count > PROC_BLOCK_SIZE)
23795 +               count = PROC_BLOCK_SIZE;
23796 +
23797 +       /* fade that out as soon as stable */
23798 +       WARN_ON(!nid);
23799 +       nxi = lookup_nx_info(nid);
23800 +       if (!nxi)
23801 +               goto out;
23802 +
23803 +       length = -ENOMEM;
23804 +       if (!(page = __get_free_page(GFP_KERNEL)))
23805 +               goto out_put;
23806 +
23807 +       BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
23808 +       length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
23809 +
23810 +       if (length >= 0)
23811 +               length = simple_read_from_buffer(buf, count, ppos,
23812 +                       (char *)page, length);
23813 +
23814 +       free_page(page);
23815 +out_put:
23816 +       put_nx_info(nxi);
23817 +out:
23818 +       return length;
23819 +}
23820 +
23821 +
23822 +
23823 +/* here comes the lower level */
23824 +
23825 +
23826 +#define NOD(NAME, MODE, IOP, FOP, OP) {        \
23827 +       .len  = sizeof(NAME) - 1,       \
23828 +       .name = (NAME),                 \
23829 +       .mode = MODE,                   \
23830 +       .iop  = IOP,                    \
23831 +       .fop  = FOP,                    \
23832 +       .op   = OP,                     \
23833 +}
23834 +
23835 +
23836 +#define DIR(NAME, MODE, OTYPE)                         \
23837 +       NOD(NAME, (S_IFDIR | (MODE)),                   \
23838 +               &proc_ ## OTYPE ## _inode_operations,   \
23839 +               &proc_ ## OTYPE ## _file_operations, { } )
23840 +
23841 +#define INF(NAME, MODE, OTYPE)                         \
23842 +       NOD(NAME, (S_IFREG | (MODE)), NULL,             \
23843 +               &proc_vs_info_file_operations,          \
23844 +               { .proc_vs_read = &proc_##OTYPE } )
23845 +
23846 +#define VINF(NAME, MODE, OTYPE)                                \
23847 +       NOD(NAME, (S_IFREG | (MODE)), NULL,             \
23848 +               &proc_vx_info_file_operations,          \
23849 +               { .proc_vxi_read = &proc_##OTYPE } )
23850 +
23851 +#define NINF(NAME, MODE, OTYPE)                                \
23852 +       NOD(NAME, (S_IFREG | (MODE)), NULL,             \
23853 +               &proc_nx_info_file_operations,          \
23854 +               { .proc_nxi_read = &proc_##OTYPE } )
23855 +
23856 +
23857 +static struct file_operations proc_vs_info_file_operations = {
23858 +       .read =         proc_vs_info_read,
23859 +};
23860 +
23861 +static struct file_operations proc_vx_info_file_operations = {
23862 +       .read =         proc_vx_info_read,
23863 +};
23864 +
23865 +static struct dentry_operations proc_xid_dentry_operations = {
23866 +       .d_revalidate = proc_xid_revalidate,
23867 +};
23868 +
23869 +static struct vs_entry vx_base_stuff[] = {
23870 +       VINF("info",    S_IRUGO, vxi_info),
23871 +       VINF("status",  S_IRUGO, vxi_status),
23872 +       VINF("limit",   S_IRUGO, vxi_limit),
23873 +       VINF("sched",   S_IRUGO, vxi_sched),
23874 +       VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
23875 +       VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
23876 +       VINF("cvirt",   S_IRUGO, vxi_cvirt),
23877 +       VINF("cacct",   S_IRUGO, vxi_cacct),
23878 +       {}
23879 +};
23880 +
23881 +
23882 +
23883 +
23884 +static struct dentry *proc_xid_instantiate(struct inode *dir,
23885 +       struct dentry *dentry, int id, void *ptr)
23886 +{
23887 +       dentry->d_op = &proc_xid_dentry_operations;
23888 +       return vs_proc_instantiate(dir, dentry, id, ptr);
23889 +}
23890 +
23891 +static struct dentry *proc_xid_lookup(struct inode *dir,
23892 +       struct dentry *dentry, struct nameidata *nd)
23893 +{
23894 +       struct vs_entry *p = vx_base_stuff;
23895 +       struct dentry *error = ERR_PTR(-ENOENT);
23896 +
23897 +       for (; p->name; p++) {
23898 +               if (p->len != dentry->d_name.len)
23899 +                       continue;
23900 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
23901 +                       break;
23902 +       }
23903 +       if (!p->name)
23904 +               goto out;
23905 +
23906 +       error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23907 +out:
23908 +       return error;
23909 +}
23910 +
23911 +static int proc_xid_readdir(struct file *filp,
23912 +       void *dirent, filldir_t filldir)
23913 +{
23914 +       struct dentry *dentry = filp->f_dentry;
23915 +       struct inode *inode = dentry->d_inode;
23916 +       struct vs_entry *p = vx_base_stuff;
23917 +       int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
23918 +       int pos, index;
23919 +       u64 ino;
23920 +
23921 +       pos = filp->f_pos;
23922 +       switch (pos) {
23923 +       case 0:
23924 +               ino = inode->i_ino;
23925 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23926 +                       goto out;
23927 +               pos++;
23928 +               /* fall through */
23929 +       case 1:
23930 +               ino = parent_ino(dentry);
23931 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23932 +                       goto out;
23933 +               pos++;
23934 +               /* fall through */
23935 +       default:
23936 +               index = pos - 2;
23937 +               if (index >= size)
23938 +                       goto out;
23939 +               for (p += index; p->name; p++) {
23940 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23941 +                               vs_proc_instantiate, PROC_I(inode)->fd, p))
23942 +                               goto out;
23943 +                       pos++;
23944 +               }
23945 +       }
23946 +out:
23947 +       filp->f_pos = pos;
23948 +       return 1;
23949 +}
23950 +
23951 +
23952 +
23953 +static struct file_operations proc_nx_info_file_operations = {
23954 +       .read =         proc_nx_info_read,
23955 +};
23956 +
23957 +static struct dentry_operations proc_nid_dentry_operations = {
23958 +       .d_revalidate = proc_nid_revalidate,
23959 +};
23960 +
23961 +static struct vs_entry nx_base_stuff[] = {
23962 +       NINF("info",    S_IRUGO, nxi_info),
23963 +       NINF("status",  S_IRUGO, nxi_status),
23964 +       {}
23965 +};
23966 +
23967 +
23968 +static struct dentry *proc_nid_instantiate(struct inode *dir,
23969 +       struct dentry *dentry, int id, void *ptr)
23970 +{
23971 +       dentry->d_op = &proc_nid_dentry_operations;
23972 +       return vs_proc_instantiate(dir, dentry, id, ptr);
23973 +}
23974 +
23975 +static struct dentry *proc_nid_lookup(struct inode *dir,
23976 +       struct dentry *dentry, struct nameidata *nd)
23977 +{
23978 +       struct vs_entry *p = nx_base_stuff;
23979 +       struct dentry *error = ERR_PTR(-ENOENT);
23980 +
23981 +       for (; p->name; p++) {
23982 +               if (p->len != dentry->d_name.len)
23983 +                       continue;
23984 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
23985 +                       break;
23986 +       }
23987 +       if (!p->name)
23988 +               goto out;
23989 +
23990 +       error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23991 +out:
23992 +       return error;
23993 +}
23994 +
23995 +static int proc_nid_readdir(struct file *filp,
23996 +       void *dirent, filldir_t filldir)
23997 +{
23998 +       struct dentry *dentry = filp->f_dentry;
23999 +       struct inode *inode = dentry->d_inode;
24000 +       struct vs_entry *p = nx_base_stuff;
24001 +       int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
24002 +       int pos, index;
24003 +       u64 ino;
24004 +
24005 +       pos = filp->f_pos;
24006 +       switch (pos) {
24007 +       case 0:
24008 +               ino = inode->i_ino;
24009 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24010 +                       goto out;
24011 +               pos++;
24012 +               /* fall through */
24013 +       case 1:
24014 +               ino = parent_ino(dentry);
24015 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24016 +                       goto out;
24017 +               pos++;
24018 +               /* fall through */
24019 +       default:
24020 +               index = pos - 2;
24021 +               if (index >= size)
24022 +                       goto out;
24023 +               for (p += index; p->name; p++) {
24024 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24025 +                               vs_proc_instantiate, PROC_I(inode)->fd, p))
24026 +                               goto out;
24027 +                       pos++;
24028 +               }
24029 +       }
24030 +out:
24031 +       filp->f_pos = pos;
24032 +       return 1;
24033 +}
24034 +
24035 +
24036 +#define MAX_MULBY10    ((~0U - 9) / 10)
24037 +
24038 +static inline int atovid(const char *str, int len)
24039 +{
24040 +       int vid, c;
24041 +
24042 +       vid = 0;
24043 +       while (len-- > 0) {
24044 +               c = *str - '0';
24045 +               str++;
24046 +               if (c > 9)
24047 +                       return -1;
24048 +               if (vid >= MAX_MULBY10)
24049 +                       return -1;
24050 +               vid *= 10;
24051 +               vid += c;
24052 +               if (!vid)
24053 +                       return -1;
24054 +       }
24055 +       return vid;
24056 +}
24057 +
24058 +/* now the upper level (virtual) */
24059 +
24060 +
24061 +static struct file_operations proc_xid_file_operations = {
24062 +       .read =         generic_read_dir,
24063 +       .readdir =      proc_xid_readdir,
24064 +};
24065 +
24066 +static struct inode_operations proc_xid_inode_operations = {
24067 +       .lookup =       proc_xid_lookup,
24068 +};
24069 +
24070 +static struct vs_entry vx_virtual_stuff[] = {
24071 +       INF("info",     S_IRUGO, virtual_info),
24072 +       INF("status",   S_IRUGO, virtual_status),
24073 +       DIR(NULL,       S_IRUGO | S_IXUGO, xid),
24074 +};
24075 +
24076 +
24077 +static struct dentry *proc_virtual_lookup(struct inode *dir,
24078 +       struct dentry *dentry, struct nameidata *nd)
24079 +{
24080 +       struct vs_entry *p = vx_virtual_stuff;
24081 +       struct dentry *error = ERR_PTR(-ENOENT);
24082 +       int id = 0;
24083 +
24084 +       for (; p->name; p++) {
24085 +               if (p->len != dentry->d_name.len)
24086 +                       continue;
24087 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
24088 +                       break;
24089 +       }
24090 +       if (p->name)
24091 +               goto instantiate;
24092 +
24093 +       id = atovid(dentry->d_name.name, dentry->d_name.len);
24094 +       if ((id < 0) || !xid_is_hashed(id))
24095 +               goto out;
24096 +
24097 +instantiate:
24098 +       error = proc_xid_instantiate(dir, dentry, id, p);
24099 +out:
24100 +       return error;
24101 +}
24102 +
24103 +static struct file_operations proc_nid_file_operations = {
24104 +       .read =         generic_read_dir,
24105 +       .readdir =      proc_nid_readdir,
24106 +};
24107 +
24108 +static struct inode_operations proc_nid_inode_operations = {
24109 +       .lookup =       proc_nid_lookup,
24110 +};
24111 +
24112 +static struct vs_entry nx_virtnet_stuff[] = {
24113 +       INF("info",     S_IRUGO, virtnet_info),
24114 +       INF("status",   S_IRUGO, virtnet_status),
24115 +       DIR(NULL,       S_IRUGO | S_IXUGO, nid),
24116 +};
24117 +
24118 +
24119 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
24120 +       struct dentry *dentry, struct nameidata *nd)
24121 +{
24122 +       struct vs_entry *p = nx_virtnet_stuff;
24123 +       struct dentry *error = ERR_PTR(-ENOENT);
24124 +       int id = 0;
24125 +
24126 +       for (; p->name; p++) {
24127 +               if (p->len != dentry->d_name.len)
24128 +                       continue;
24129 +               if (!memcmp(dentry->d_name.name, p->name, p->len))
24130 +                       break;
24131 +       }
24132 +       if (p->name)
24133 +               goto instantiate;
24134 +
24135 +       id = atovid(dentry->d_name.name, dentry->d_name.len);
24136 +       if ((id < 0) || !nid_is_hashed(id))
24137 +               goto out;
24138 +
24139 +instantiate:
24140 +       error = proc_nid_instantiate(dir, dentry, id, p);
24141 +out:
24142 +       return error;
24143 +}
24144 +
24145 +
24146 +#define PROC_MAXVIDS 32
24147 +
24148 +int proc_virtual_readdir(struct file *filp,
24149 +       void *dirent, filldir_t filldir)
24150 +{
24151 +       struct dentry *dentry = filp->f_dentry;
24152 +       struct inode *inode = dentry->d_inode;
24153 +       struct vs_entry *p = vx_virtual_stuff;
24154 +       int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
24155 +       int pos, index;
24156 +       unsigned int xid_array[PROC_MAXVIDS];
24157 +       char buf[PROC_NUMBUF];
24158 +       unsigned int nr_xids, i;
24159 +       u64 ino;
24160 +
24161 +       pos = filp->f_pos;
24162 +       switch (pos) {
24163 +       case 0:
24164 +               ino = inode->i_ino;
24165 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24166 +                       goto out;
24167 +               pos++;
24168 +               /* fall through */
24169 +       case 1:
24170 +               ino = parent_ino(dentry);
24171 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24172 +                       goto out;
24173 +               pos++;
24174 +               /* fall through */
24175 +       default:
24176 +               index = pos - 2;
24177 +               if (index >= size)
24178 +                       goto entries;
24179 +               for (p += index; p->name; p++) {
24180 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24181 +                               vs_proc_instantiate, 0, p))
24182 +                               goto out;
24183 +                       pos++;
24184 +               }
24185 +       entries:
24186 +               index = pos - size;
24187 +               p = &vx_virtual_stuff[size - 1];
24188 +               nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
24189 +               for (i = 0; i < nr_xids; i++) {
24190 +                       int n, xid = xid_array[i];
24191 +                       unsigned int j = PROC_NUMBUF;
24192 +
24193 +                       n = xid;
24194 +                       do
24195 +                               buf[--j] = '0' + (n % 10);
24196 +                       while (n /= 10);
24197 +
24198 +                       if (proc_fill_cache(filp, dirent, filldir,
24199 +                               buf + j, PROC_NUMBUF - j,
24200 +                               vs_proc_instantiate, xid, p))
24201 +                               goto out;
24202 +                       pos++;
24203 +               }
24204 +       }
24205 +out:
24206 +       filp->f_pos = pos;
24207 +       return 0;
24208 +}
24209 +
24210 +static int proc_virtual_getattr(struct vfsmount *mnt,
24211 +       struct dentry *dentry, struct kstat *stat)
24212 +{
24213 +       struct inode *inode = dentry->d_inode;
24214 +
24215 +       generic_fillattr(inode, stat);
24216 +       stat->nlink = 2 + atomic_read(&vx_global_cactive);
24217 +       return 0;
24218 +}
24219 +
24220 +static struct file_operations proc_virtual_dir_operations = {
24221 +       .read =         generic_read_dir,
24222 +       .readdir =      proc_virtual_readdir,
24223 +};
24224 +
24225 +static struct inode_operations proc_virtual_dir_inode_operations = {
24226 +       .getattr =      proc_virtual_getattr,
24227 +       .lookup =       proc_virtual_lookup,
24228 +};
24229 +
24230 +
24231 +
24232 +
24233 +
24234 +int proc_virtnet_readdir(struct file *filp,
24235 +       void *dirent, filldir_t filldir)
24236 +{
24237 +       struct dentry *dentry = filp->f_dentry;
24238 +       struct inode *inode = dentry->d_inode;
24239 +       struct vs_entry *p = nx_virtnet_stuff;
24240 +       int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
24241 +       int pos, index;
24242 +       unsigned int nid_array[PROC_MAXVIDS];
24243 +       char buf[PROC_NUMBUF];
24244 +       unsigned int nr_nids, i;
24245 +       u64 ino;
24246 +
24247 +       pos = filp->f_pos;
24248 +       switch (pos) {
24249 +       case 0:
24250 +               ino = inode->i_ino;
24251 +               if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24252 +                       goto out;
24253 +               pos++;
24254 +               /* fall through */
24255 +       case 1:
24256 +               ino = parent_ino(dentry);
24257 +               if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24258 +                       goto out;
24259 +               pos++;
24260 +               /* fall through */
24261 +       default:
24262 +               index = pos - 2;
24263 +               if (index >= size)
24264 +                       goto entries;
24265 +               for (p += index; p->name; p++) {
24266 +                       if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24267 +                               vs_proc_instantiate, 0, p))
24268 +                               goto out;
24269 +                       pos++;
24270 +               }
24271 +       entries:
24272 +               index = pos - size;
24273 +               p = &nx_virtnet_stuff[size - 1];
24274 +               nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
24275 +               for (i = 0; i < nr_nids; i++) {
24276 +                       int n, nid = nid_array[i];
24277 +                       unsigned int j = PROC_NUMBUF;
24278 +
24279 +                       n = nid;
24280 +                       do
24281 +                               buf[--j] = '0' + (n % 10);
24282 +                       while (n /= 10);
24283 +
24284 +                       if (proc_fill_cache(filp, dirent, filldir,
24285 +                               buf + j, PROC_NUMBUF - j,
24286 +                               vs_proc_instantiate, nid, p))
24287 +                               goto out;
24288 +                       pos++;
24289 +               }
24290 +       }
24291 +out:
24292 +       filp->f_pos = pos;
24293 +       return 0;
24294 +}
24295 +
24296 +static int proc_virtnet_getattr(struct vfsmount *mnt,
24297 +       struct dentry *dentry, struct kstat *stat)
24298 +{
24299 +       struct inode *inode = dentry->d_inode;
24300 +
24301 +       generic_fillattr(inode, stat);
24302 +       stat->nlink = 2 + atomic_read(&nx_global_cactive);
24303 +       return 0;
24304 +}
24305 +
24306 +static struct file_operations proc_virtnet_dir_operations = {
24307 +       .read =         generic_read_dir,
24308 +       .readdir =      proc_virtnet_readdir,
24309 +};
24310 +
24311 +static struct inode_operations proc_virtnet_dir_inode_operations = {
24312 +       .getattr =      proc_virtnet_getattr,
24313 +       .lookup =       proc_virtnet_lookup,
24314 +};
24315 +
24316 +
24317 +
24318 +void proc_vx_init(void)
24319 +{
24320 +       struct proc_dir_entry *ent;
24321 +
24322 +       ent = proc_mkdir("virtual", 0);
24323 +       if (ent) {
24324 +               ent->proc_fops = &proc_virtual_dir_operations;
24325 +               ent->proc_iops = &proc_virtual_dir_inode_operations;
24326 +       }
24327 +       proc_virtual = ent;
24328 +
24329 +       ent = proc_mkdir("virtnet", 0);
24330 +       if (ent) {
24331 +               ent->proc_fops = &proc_virtnet_dir_operations;
24332 +               ent->proc_iops = &proc_virtnet_dir_inode_operations;
24333 +       }
24334 +       proc_virtnet = ent;
24335 +}
24336 +
24337 +
24338 +
24339 +
24340 +/* per pid info */
24341 +
24342 +
24343 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
24344 +{
24345 +       struct vx_info *vxi;
24346 +       char *orig = buffer;
24347 +
24348 +       buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
24349 +
24350 +       vxi = task_get_vx_info(p);
24351 +       if (!vxi)
24352 +               goto out;
24353 +
24354 +       buffer += sprintf(buffer, "BCaps:\t");
24355 +       buffer = print_cap_t(buffer, &vxi->vx_bcaps);
24356 +       buffer += sprintf(buffer, "\n");
24357 +       buffer += sprintf(buffer, "CCaps:\t%016llx\n",
24358 +               (unsigned long long)vxi->vx_ccaps);
24359 +       buffer += sprintf(buffer, "CFlags:\t%016llx\n",
24360 +               (unsigned long long)vxi->vx_flags);
24361 +       buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
24362 +
24363 +       put_vx_info(vxi);
24364 +out:
24365 +       return buffer - orig;
24366 +}
24367 +
24368 +
24369 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
24370 +{
24371 +       struct nx_info *nxi;
24372 +       struct nx_addr_v4 *v4a;
24373 +#ifdef CONFIG_IPV6
24374 +       struct nx_addr_v6 *v6a;
24375 +#endif
24376 +       char *orig = buffer;
24377 +       int i;
24378 +
24379 +       buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
24380 +
24381 +       nxi = task_get_nx_info(p);
24382 +       if (!nxi)
24383 +               goto out;
24384 +
24385 +       buffer += sprintf(buffer, "NCaps:\t%016llx\n",
24386 +               (unsigned long long)nxi->nx_ncaps);
24387 +       buffer += sprintf(buffer, "NFlags:\t%016llx\n",
24388 +               (unsigned long long)nxi->nx_flags);
24389 +
24390 +       buffer += sprintf(buffer,
24391 +               "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
24392 +               NIPQUAD(nxi->v4_bcast.s_addr));
24393 +       buffer += sprintf (buffer,
24394 +               "V4Root[lback]:\t" NIPQUAD_FMT "\n",
24395 +               NIPQUAD(nxi->v4_lback.s_addr));
24396 +       if (!NX_IPV4(nxi))
24397 +               goto skip_v4;
24398 +       for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
24399 +               buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
24400 +                       i, NXAV4(v4a));
24401 +skip_v4:
24402 +#ifdef CONFIG_IPV6
24403 +       if (!NX_IPV6(nxi))
24404 +               goto skip_v6;
24405 +       for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
24406 +               buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
24407 +                       i, NXAV6(v6a));
24408 +skip_v6:
24409 +#endif
24410 +       put_nx_info(nxi);
24411 +out:
24412 +       return buffer - orig;
24413 +}
24414 +
24415 diff -NurpP --minimal linux-3.0.4/kernel/vserver/sched.c linux-3.0.4-vs2.3.1/kernel/vserver/sched.c
24416 --- linux-3.0.4/kernel/vserver/sched.c  1970-01-01 01:00:00.000000000 +0100
24417 +++ linux-3.0.4-vs2.3.1/kernel/vserver/sched.c  2011-06-10 22:11:24.000000000 +0200
24418 @@ -0,0 +1,82 @@
24419 +/*
24420 + *  linux/kernel/vserver/sched.c
24421 + *
24422 + *  Virtual Server: Scheduler Support
24423 + *
24424 + *  Copyright (C) 2004-2010  Herbert Pötzl
24425 + *
24426 + *  V0.01  adapted Sam Vilains version to 2.6.3
24427 + *  V0.02  removed legacy interface
24428 + *  V0.03  changed vcmds to vxi arg
24429 + *  V0.04  removed older and legacy interfaces
24430 + *  V0.05  removed scheduler code/commands
24431 + *
24432 + */
24433 +
24434 +#include <linux/vs_context.h>
24435 +#include <linux/vs_sched.h>
24436 +#include <linux/vserver/sched_cmd.h>
24437 +
24438 +#include <asm/uaccess.h>
24439 +
24440 +
24441 +void vx_update_sched_param(struct _vx_sched *sched,
24442 +       struct _vx_sched_pc *sched_pc)
24443 +{
24444 +       sched_pc->prio_bias = sched->prio_bias;
24445 +}
24446 +
24447 +static int do_set_prio_bias(struct vx_info *vxi, struct vcmd_prio_bias *data)
24448 +{
24449 +       int cpu;
24450 +
24451 +       if (data->prio_bias > MAX_PRIO_BIAS)
24452 +               data->prio_bias = MAX_PRIO_BIAS;
24453 +       if (data->prio_bias < MIN_PRIO_BIAS)
24454 +               data->prio_bias = MIN_PRIO_BIAS;
24455 +
24456 +       if (data->cpu_id != ~0) {
24457 +               vxi->sched.update = cpumask_of_cpu(data->cpu_id);
24458 +               cpus_and(vxi->sched.update, cpu_online_map,
24459 +                       vxi->sched.update);
24460 +       } else
24461 +               vxi->sched.update = cpu_online_map;
24462 +
24463 +       for_each_cpu_mask(cpu, vxi->sched.update)
24464 +               vx_update_sched_param(&vxi->sched,
24465 +                       &vx_per_cpu(vxi, sched_pc, cpu));
24466 +       return 0;
24467 +}
24468 +
24469 +int vc_set_prio_bias(struct vx_info *vxi, void __user *data)
24470 +{
24471 +       struct vcmd_prio_bias vc_data;
24472 +
24473 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24474 +               return -EFAULT;
24475 +
24476 +       return do_set_prio_bias(vxi, &vc_data);
24477 +}
24478 +
24479 +int vc_get_prio_bias(struct vx_info *vxi, void __user *data)
24480 +{
24481 +       struct vcmd_prio_bias vc_data;
24482 +       struct _vx_sched_pc *pcd;
24483 +       int cpu;
24484 +
24485 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24486 +               return -EFAULT;
24487 +
24488 +       cpu = vc_data.cpu_id;
24489 +
24490 +       if (!cpu_possible(cpu))
24491 +               return -EINVAL;
24492 +
24493 +       pcd = &vx_per_cpu(vxi, sched_pc, cpu);
24494 +       vc_data.prio_bias = pcd->prio_bias;
24495 +
24496 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24497 +               return -EFAULT;
24498 +       return 0;
24499 +}
24500 +
24501 diff -NurpP --minimal linux-3.0.4/kernel/vserver/sched_init.h linux-3.0.4-vs2.3.1/kernel/vserver/sched_init.h
24502 --- linux-3.0.4/kernel/vserver/sched_init.h     1970-01-01 01:00:00.000000000 +0100
24503 +++ linux-3.0.4-vs2.3.1/kernel/vserver/sched_init.h     2011-06-10 22:11:24.000000000 +0200
24504 @@ -0,0 +1,27 @@
24505 +
24506 +static inline void vx_info_init_sched(struct _vx_sched *sched)
24507 +{
24508 +       /* scheduling; hard code starting values as constants */
24509 +       sched->prio_bias = 0;
24510 +}
24511 +
24512 +static inline
24513 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24514 +{
24515 +       sched_pc->prio_bias = 0;
24516 +
24517 +       sched_pc->user_ticks = 0;
24518 +       sched_pc->sys_ticks = 0;
24519 +       sched_pc->hold_ticks = 0;
24520 +}
24521 +
24522 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
24523 +{
24524 +       return;
24525 +}
24526 +
24527 +static inline
24528 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24529 +{
24530 +       return;
24531 +}
24532 diff -NurpP --minimal linux-3.0.4/kernel/vserver/sched_proc.h linux-3.0.4-vs2.3.1/kernel/vserver/sched_proc.h
24533 --- linux-3.0.4/kernel/vserver/sched_proc.h     1970-01-01 01:00:00.000000000 +0100
24534 +++ linux-3.0.4-vs2.3.1/kernel/vserver/sched_proc.h     2011-06-10 22:11:24.000000000 +0200
24535 @@ -0,0 +1,32 @@
24536 +#ifndef _VX_SCHED_PROC_H
24537 +#define _VX_SCHED_PROC_H
24538 +
24539 +
24540 +static inline
24541 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
24542 +{
24543 +       int length = 0;
24544 +
24545 +       length += sprintf(buffer,
24546 +               "PrioBias:\t%8d\n",
24547 +               sched->prio_bias);
24548 +       return length;
24549 +}
24550 +
24551 +static inline
24552 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
24553 +       char *buffer, int cpu)
24554 +{
24555 +       int length = 0;
24556 +
24557 +       length += sprintf(buffer + length,
24558 +               "cpu %d: %lld %lld %lld", cpu,
24559 +               (unsigned long long)sched_pc->user_ticks,
24560 +               (unsigned long long)sched_pc->sys_ticks,
24561 +               (unsigned long long)sched_pc->hold_ticks);
24562 +       length += sprintf(buffer + length,
24563 +               " %d\n", sched_pc->prio_bias);
24564 +       return length;
24565 +}
24566 +
24567 +#endif /* _VX_SCHED_PROC_H */
24568 diff -NurpP --minimal linux-3.0.4/kernel/vserver/signal.c linux-3.0.4-vs2.3.1/kernel/vserver/signal.c
24569 --- linux-3.0.4/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
24570 +++ linux-3.0.4-vs2.3.1/kernel/vserver/signal.c 2011-06-10 22:11:24.000000000 +0200
24571 @@ -0,0 +1,134 @@
24572 +/*
24573 + *  linux/kernel/vserver/signal.c
24574 + *
24575 + *  Virtual Server: Signal Support
24576 + *
24577 + *  Copyright (C) 2003-2007  Herbert Pötzl
24578 + *
24579 + *  V0.01  broken out from vcontext V0.05
24580 + *  V0.02  changed vcmds to vxi arg
24581 + *  V0.03  adjusted siginfo for kill
24582 + *
24583 + */
24584 +
24585 +#include <asm/uaccess.h>
24586 +
24587 +#include <linux/vs_context.h>
24588 +#include <linux/vs_pid.h>
24589 +#include <linux/vserver/signal_cmd.h>
24590 +
24591 +
24592 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
24593 +{
24594 +       int retval, count = 0;
24595 +       struct task_struct *p;
24596 +       struct siginfo *sip = SEND_SIG_PRIV;
24597 +
24598 +       retval = -ESRCH;
24599 +       vxdprintk(VXD_CBIT(misc, 4),
24600 +               "vx_info_kill(%p[#%d],%d,%d)*",
24601 +               vxi, vxi->vx_id, pid, sig);
24602 +       read_lock(&tasklist_lock);
24603 +       switch (pid) {
24604 +       case  0:
24605 +       case -1:
24606 +               for_each_process(p) {
24607 +                       int err = 0;
24608 +
24609 +                       if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
24610 +                               (pid && vxi->vx_initpid == p->pid))
24611 +                               continue;
24612 +
24613 +                       err = group_send_sig_info(sig, sip, p);
24614 +                       ++count;
24615 +                       if (err != -EPERM)
24616 +                               retval = err;
24617 +               }
24618 +               break;
24619 +
24620 +       case 1:
24621 +               if (vxi->vx_initpid) {
24622 +                       pid = vxi->vx_initpid;
24623 +                       /* for now, only SIGINT to private init ... */
24624 +                       if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24625 +                               /* ... as long as there are tasks left */
24626 +                               (atomic_read(&vxi->vx_tasks) > 1))
24627 +                               sig = SIGINT;
24628 +               }
24629 +               /* fallthrough */
24630 +       default:
24631 +               rcu_read_lock();
24632 +               p = find_task_by_real_pid(pid);
24633 +               rcu_read_unlock();
24634 +               if (p) {
24635 +                       if (vx_task_xid(p) == vxi->vx_id)
24636 +                               retval = group_send_sig_info(sig, sip, p);
24637 +               }
24638 +               break;
24639 +       }
24640 +       read_unlock(&tasklist_lock);
24641 +       vxdprintk(VXD_CBIT(misc, 4),
24642 +               "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
24643 +               vxi, vxi->vx_id, pid, sig, (long)sip, retval);
24644 +       return retval;
24645 +}
24646 +
24647 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
24648 +{
24649 +       struct vcmd_ctx_kill_v0 vc_data;
24650 +
24651 +       if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24652 +               return -EFAULT;
24653 +
24654 +       /* special check to allow guest shutdown */
24655 +       if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24656 +               /* forbid killall pid=0 when init is present */
24657 +               (((vc_data.pid < 1) && vxi->vx_initpid) ||
24658 +               (vc_data.pid > 1)))
24659 +               return -EACCES;
24660 +
24661 +       return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
24662 +}
24663 +
24664 +
24665 +static int __wait_exit(struct vx_info *vxi)
24666 +{
24667 +       DECLARE_WAITQUEUE(wait, current);
24668 +       int ret = 0;
24669 +
24670 +       add_wait_queue(&vxi->vx_wait, &wait);
24671 +       set_current_state(TASK_INTERRUPTIBLE);
24672 +
24673 +wait:
24674 +       if (vx_info_state(vxi,
24675 +               VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
24676 +               goto out;
24677 +       if (signal_pending(current)) {
24678 +               ret = -ERESTARTSYS;
24679 +               goto out;
24680 +       }
24681 +       schedule();
24682 +       goto wait;
24683 +
24684 +out:
24685 +       set_current_state(TASK_RUNNING);
24686 +       remove_wait_queue(&vxi->vx_wait, &wait);
24687 +       return ret;
24688 +}
24689 +
24690 +
24691 +
24692 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
24693 +{
24694 +       struct vcmd_wait_exit_v0 vc_data;
24695 +       int ret;
24696 +
24697 +       ret = __wait_exit(vxi);
24698 +       vc_data.reboot_cmd = vxi->reboot_cmd;
24699 +       vc_data.exit_code = vxi->exit_code;
24700 +
24701 +       if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24702 +               ret = -EFAULT;
24703 +       return ret;
24704 +}
24705 +
24706 diff -NurpP --minimal linux-3.0.4/kernel/vserver/space.c linux-3.0.4-vs2.3.1/kernel/vserver/space.c
24707 --- linux-3.0.4/kernel/vserver/space.c  1970-01-01 01:00:00.000000000 +0100
24708 +++ linux-3.0.4-vs2.3.1/kernel/vserver/space.c  2011-07-20 02:11:49.000000000 +0200
24709 @@ -0,0 +1,435 @@
24710 +/*
24711 + *  linux/kernel/vserver/space.c
24712 + *
24713 + *  Virtual Server: Context Space Support
24714 + *
24715 + *  Copyright (C) 2003-2010  Herbert Pötzl
24716 + *
24717 + *  V0.01  broken out from context.c 0.07
24718 + *  V0.02  added task locking for namespace
24719 + *  V0.03  broken out vx_enter_namespace
24720 + *  V0.04  added *space support and commands
24721 + *  V0.05  added credential support
24722 + *
24723 + */
24724 +
24725 +#include <linux/utsname.h>
24726 +#include <linux/nsproxy.h>
24727 +#include <linux/err.h>
24728 +#include <linux/fs_struct.h>
24729 +#include <linux/cred.h>
24730 +#include <asm/uaccess.h>
24731 +
24732 +#include <linux/vs_context.h>
24733 +#include <linux/vserver/space.h>
24734 +#include <linux/vserver/space_cmd.h>
24735 +
24736 +atomic_t vs_global_nsproxy     = ATOMIC_INIT(0);
24737 +atomic_t vs_global_fs          = ATOMIC_INIT(0);
24738 +atomic_t vs_global_mnt_ns      = ATOMIC_INIT(0);
24739 +atomic_t vs_global_uts_ns      = ATOMIC_INIT(0);
24740 +atomic_t vs_global_user_ns     = ATOMIC_INIT(0);
24741 +atomic_t vs_global_pid_ns      = ATOMIC_INIT(0);
24742 +
24743 +
24744 +/* namespace functions */
24745 +
24746 +#include <linux/mnt_namespace.h>
24747 +#include <linux/user_namespace.h>
24748 +#include <linux/pid_namespace.h>
24749 +#include <linux/ipc_namespace.h>
24750 +#include <net/net_namespace.h>
24751 +
24752 +
24753 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
24754 +       .mask = CLONE_FS |
24755 +               CLONE_NEWNS |
24756 +#ifdef CONFIG_UTS_NS
24757 +               CLONE_NEWUTS |
24758 +#endif
24759 +#ifdef CONFIG_IPC_NS
24760 +               CLONE_NEWIPC |
24761 +#endif
24762 +#ifdef CONFIG_USER_NS
24763 +               CLONE_NEWUSER |
24764 +#endif
24765 +               0
24766 +};
24767 +
24768 +static const struct vcmd_space_mask_v1 space_mask = {
24769 +       .mask = CLONE_FS |
24770 +               CLONE_NEWNS |
24771 +#ifdef CONFIG_UTS_NS
24772 +               CLONE_NEWUTS |
24773 +#endif
24774 +#ifdef CONFIG_IPC_NS
24775 +               CLONE_NEWIPC |
24776 +#endif
24777 +#ifdef CONFIG_USER_NS
24778 +               CLONE_NEWUSER |
24779 +#endif
24780 +#ifdef CONFIG_PID_NS
24781 +               CLONE_NEWPID |
24782 +#endif
24783 +#ifdef CONFIG_NET_NS
24784 +               CLONE_NEWNET |
24785 +#endif
24786 +               0
24787 +};
24788 +
24789 +static const struct vcmd_space_mask_v1 default_space_mask = {
24790 +       .mask = CLONE_FS |
24791 +               CLONE_NEWNS |
24792 +#ifdef CONFIG_UTS_NS
24793 +               CLONE_NEWUTS |
24794 +#endif
24795 +#ifdef CONFIG_IPC_NS
24796 +               CLONE_NEWIPC |
24797 +#endif
24798 +#ifdef CONFIG_USER_NS
24799 +               CLONE_NEWUSER |
24800 +#endif
24801 +#ifdef CONFIG_PID_NS
24802 +//             CLONE_NEWPID |
24803 +#endif
24804 +               0
24805 +};
24806 +
24807 +/*
24808 + *     build a new nsproxy mix
24809 + *      assumes that both proxies are 'const'
24810 + *     does not touch nsproxy refcounts
24811 + *     will hold a reference on the result.
24812 + */
24813 +
24814 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
24815 +       struct nsproxy *new_nsproxy, unsigned long mask)
24816 +{
24817 +       struct mnt_namespace *old_ns;
24818 +       struct uts_namespace *old_uts;
24819 +       struct ipc_namespace *old_ipc;
24820 +#ifdef CONFIG_PID_NS
24821 +       struct pid_namespace *old_pid;
24822 +#endif
24823 +#ifdef CONFIG_NET_NS
24824 +       struct net *old_net;
24825 +#endif
24826 +       struct nsproxy *nsproxy;
24827 +
24828 +       nsproxy = copy_nsproxy(old_nsproxy);
24829 +       if (!nsproxy)
24830 +               goto out;
24831 +
24832 +       if (mask & CLONE_NEWNS) {
24833 +               old_ns = nsproxy->mnt_ns;
24834 +               nsproxy->mnt_ns = new_nsproxy->mnt_ns;
24835 +               if (nsproxy->mnt_ns)
24836 +                       get_mnt_ns(nsproxy->mnt_ns);
24837 +       } else
24838 +               old_ns = NULL;
24839 +
24840 +       if (mask & CLONE_NEWUTS) {
24841 +               old_uts = nsproxy->uts_ns;
24842 +               nsproxy->uts_ns = new_nsproxy->uts_ns;
24843 +               if (nsproxy->uts_ns)
24844 +                       get_uts_ns(nsproxy->uts_ns);
24845 +       } else
24846 +               old_uts = NULL;
24847 +
24848 +       if (mask & CLONE_NEWIPC) {
24849 +               old_ipc = nsproxy->ipc_ns;
24850 +               nsproxy->ipc_ns = new_nsproxy->ipc_ns;
24851 +               if (nsproxy->ipc_ns)
24852 +                       get_ipc_ns(nsproxy->ipc_ns);
24853 +       } else
24854 +               old_ipc = NULL;
24855 +
24856 +#ifdef CONFIG_PID_NS
24857 +       if (mask & CLONE_NEWPID) {
24858 +               old_pid = nsproxy->pid_ns;
24859 +               nsproxy->pid_ns = new_nsproxy->pid_ns;
24860 +               if (nsproxy->pid_ns)
24861 +                       get_pid_ns(nsproxy->pid_ns);
24862 +       } else
24863 +               old_pid = NULL;
24864 +#endif
24865 +#ifdef CONFIG_NET_NS
24866 +       if (mask & CLONE_NEWNET) {
24867 +               old_net = nsproxy->net_ns;
24868 +               nsproxy->net_ns = new_nsproxy->net_ns;
24869 +               if (nsproxy->net_ns)
24870 +                       get_net(nsproxy->net_ns);
24871 +       } else
24872 +               old_net = NULL;
24873 +#endif
24874 +       if (old_ns)
24875 +               put_mnt_ns(old_ns);
24876 +       if (old_uts)
24877 +               put_uts_ns(old_uts);
24878 +       if (old_ipc)
24879 +               put_ipc_ns(old_ipc);
24880 +#ifdef CONFIG_PID_NS
24881 +       if (old_pid)
24882 +               put_pid_ns(old_pid);
24883 +#endif
24884 +#ifdef CONFIG_NET_NS
24885 +       if (old_net)
24886 +               put_net(old_net);
24887 +#endif
24888 +out:
24889 +       return nsproxy;
24890 +}
24891 +
24892 +
24893 +/*
24894 + *     merge two nsproxy structs into a new one.
24895 + *     will hold a reference on the result.
24896 + */
24897 +
24898 +static inline
24899 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
24900 +       struct nsproxy *proxy, unsigned long mask)
24901 +{
24902 +       struct nsproxy null_proxy = { .mnt_ns = NULL };
24903 +
24904 +       if (!proxy)
24905 +               return NULL;
24906 +
24907 +       if (mask) {
24908 +               /* vs_mix_nsproxy returns with reference */
24909 +               return vs_mix_nsproxy(old ? old : &null_proxy,
24910 +                       proxy, mask);
24911 +       }
24912 +       get_nsproxy(proxy);
24913 +       return proxy;
24914 +}
24915 +
24916 +
24917 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
24918 +{
24919 +       struct nsproxy *proxy, *proxy_cur, *proxy_new;
24920 +       struct fs_struct *fs_cur, *fs = NULL;
24921 +       struct _vx_space *space;
24922 +       int ret, kill = 0;
24923 +
24924 +       vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
24925 +               vxi, vxi->vx_id, mask, index);
24926 +
24927 +       if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
24928 +               return -EACCES;
24929 +
24930 +       if (index >= VX_SPACES)
24931 +               return -EINVAL;
24932 +
24933 +       space = &vxi->space[index];
24934 +
24935 +       if (!mask)
24936 +               mask = space->vx_nsmask;
24937 +
24938 +       if ((mask & space->vx_nsmask) != mask)
24939 +               return -EINVAL;
24940 +
24941 +       if (mask & CLONE_FS) {
24942 +               fs = copy_fs_struct(space->vx_fs);
24943 +               if (!fs)
24944 +                       return -ENOMEM;
24945 +       }
24946 +       proxy = space->vx_nsproxy;
24947 +
24948 +       vxdprintk(VXD_CBIT(space, 9),
24949 +               "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
24950 +               vxi, vxi->vx_id, mask, index, proxy, fs);
24951 +
24952 +       task_lock(current);
24953 +       fs_cur = current->fs;
24954 +
24955 +       if (mask & CLONE_FS) {
24956 +               spin_lock(&fs_cur->lock);
24957 +               current->fs = fs;
24958 +               kill = !--fs_cur->users;
24959 +               spin_unlock(&fs_cur->lock);
24960 +       }
24961 +
24962 +       proxy_cur = current->nsproxy;
24963 +       get_nsproxy(proxy_cur);
24964 +       task_unlock(current);
24965 +
24966 +       if (kill)
24967 +               free_fs_struct(fs_cur);
24968 +
24969 +       proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
24970 +       if (IS_ERR(proxy_new)) {
24971 +               ret = PTR_ERR(proxy_new);
24972 +               goto out_put;
24973 +       }
24974 +
24975 +       proxy_new = xchg(&current->nsproxy, proxy_new);
24976 +
24977 +       if (mask & CLONE_NEWUSER) {
24978 +               struct cred *cred;
24979 +
24980 +               vxdprintk(VXD_CBIT(space, 10),
24981 +                       "vx_enter_space(%p[#%u],%p) cred (%p,%p)",
24982 +                       vxi, vxi->vx_id, space->vx_cred,
24983 +                       current->real_cred, current->cred);
24984 +
24985 +               if (space->vx_cred) {
24986 +                       cred = __prepare_creds(space->vx_cred);
24987 +                       if (cred)
24988 +                               commit_creds(cred);
24989 +               }
24990 +       }
24991 +
24992 +       ret = 0;
24993 +
24994 +       if (proxy_new)
24995 +               put_nsproxy(proxy_new);
24996 +out_put:
24997 +       if (proxy_cur)
24998 +               put_nsproxy(proxy_cur);
24999 +       return ret;
25000 +}
25001 +
25002 +
25003 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
25004 +{
25005 +       struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
25006 +       struct fs_struct *fs_vxi, *fs;
25007 +       struct _vx_space *space;
25008 +       int ret, kill = 0;
25009 +
25010 +       vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
25011 +               vxi, vxi->vx_id, mask, index);
25012 +
25013 +       if ((mask & space_mask.mask) != mask)
25014 +               return -EINVAL;
25015 +
25016 +       if (index >= VX_SPACES)
25017 +               return -EINVAL;
25018 +
25019 +       space = &vxi->space[index];
25020 +
25021 +       proxy_vxi = space->vx_nsproxy;
25022 +       fs_vxi = space->vx_fs;
25023 +
25024 +       if (mask & CLONE_FS) {
25025 +               fs = copy_fs_struct(current->fs);
25026 +               if (!fs)
25027 +                       return -ENOMEM;
25028 +       }
25029 +
25030 +       task_lock(current);
25031 +
25032 +       if (mask & CLONE_FS) {
25033 +               spin_lock(&fs_vxi->lock);
25034 +               space->vx_fs = fs;
25035 +               kill = !--fs_vxi->users;
25036 +               spin_unlock(&fs_vxi->lock);
25037 +       }
25038 +
25039 +       proxy_cur = current->nsproxy;
25040 +       get_nsproxy(proxy_cur);
25041 +       task_unlock(current);
25042 +
25043 +       if (kill)
25044 +               free_fs_struct(fs_vxi);
25045 +
25046 +       proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
25047 +       if (IS_ERR(proxy_new)) {
25048 +               ret = PTR_ERR(proxy_new);
25049 +               goto out_put;
25050 +       }
25051 +
25052 +       proxy_new = xchg(&space->vx_nsproxy, proxy_new);
25053 +       space->vx_nsmask |= mask;
25054 +
25055 +       if (mask & CLONE_NEWUSER) {
25056 +               struct cred *cred;
25057 +
25058 +               vxdprintk(VXD_CBIT(space, 10),
25059 +                       "vx_set_space(%p[#%u],%p) cred (%p,%p)",
25060 +                       vxi, vxi->vx_id, space->vx_cred,
25061 +                       current->real_cred, current->cred);
25062 +
25063 +               cred = prepare_creds();
25064 +               cred = (struct cred *)xchg(&space->vx_cred, cred);
25065 +               if (cred)
25066 +                       abort_creds(cred);
25067 +       }
25068 +
25069 +       ret = 0;
25070 +
25071 +       if (proxy_new)
25072 +               put_nsproxy(proxy_new);
25073 +out_put:
25074 +       if (proxy_cur)
25075 +               put_nsproxy(proxy_cur);
25076 +       return ret;
25077 +}
25078 +
25079 +
25080 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
25081 +{
25082 +       struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
25083 +
25084 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25085 +               return -EFAULT;
25086 +
25087 +       return vx_enter_space(vxi, vc_data.mask, 0);
25088 +}
25089 +
25090 +int vc_enter_space(struct vx_info *vxi, void __user *data)
25091 +{
25092 +       struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
25093 +
25094 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25095 +               return -EFAULT;
25096 +
25097 +       if (vc_data.index >= VX_SPACES)
25098 +               return -EINVAL;
25099 +
25100 +       return vx_enter_space(vxi, vc_data.mask, vc_data.index);
25101 +}
25102 +
25103 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
25104 +{
25105 +       struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
25106 +
25107 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25108 +               return -EFAULT;
25109 +
25110 +       return vx_set_space(vxi, vc_data.mask, 0);
25111 +}
25112 +
25113 +int vc_set_space(struct vx_info *vxi, void __user *data)
25114 +{
25115 +       struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
25116 +
25117 +       if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25118 +               return -EFAULT;
25119 +
25120 +       if (vc_data.index >= VX_SPACES)
25121 +               return -EINVAL;
25122 +
25123 +       return vx_set_space(vxi, vc_data.mask, vc_data.index);
25124 +}
25125 +
25126 +int vc_get_space_mask(void __user *data, int type)
25127 +{
25128 +       const struct vcmd_space_mask_v1 *mask;
25129 +
25130 +       if (type == 0)
25131 +               mask = &space_mask_v0;
25132 +       else if (type == 1)
25133 +               mask = &space_mask;
25134 +       else
25135 +               mask = &default_space_mask;
25136 +
25137 +       vxdprintk(VXD_CBIT(space, 10),
25138 +               "vc_get_space_mask(%d) = %08llx", type, mask->mask);
25139 +
25140 +       if (copy_to_user(data, mask, sizeof(*mask)))
25141 +               return -EFAULT;
25142 +       return 0;
25143 +}
25144 +
25145 diff -NurpP --minimal linux-3.0.4/kernel/vserver/switch.c linux-3.0.4-vs2.3.1/kernel/vserver/switch.c
25146 --- linux-3.0.4/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
25147 +++ linux-3.0.4-vs2.3.1/kernel/vserver/switch.c 2011-08-01 18:28:26.000000000 +0200
25148 @@ -0,0 +1,556 @@
25149 +/*
25150 + *  linux/kernel/vserver/switch.c
25151 + *
25152 + *  Virtual Server: Syscall Switch
25153 + *
25154 + *  Copyright (C) 2003-2011  Herbert Pötzl
25155 + *
25156 + *  V0.01  syscall switch
25157 + *  V0.02  added signal to context
25158 + *  V0.03  added rlimit functions
25159 + *  V0.04  added iattr, task/xid functions
25160 + *  V0.05  added debug/history stuff
25161 + *  V0.06  added compat32 layer
25162 + *  V0.07  vcmd args and perms
25163 + *  V0.08  added status commands
25164 + *  V0.09  added tag commands
25165 + *  V0.10  added oom bias
25166 + *  V0.11  added device commands
25167 + *  V0.12  added warn mask
25168 + *
25169 + */
25170 +
25171 +#include <linux/vs_context.h>
25172 +#include <linux/vs_network.h>
25173 +#include <linux/vserver/switch.h>
25174 +
25175 +#include "vci_config.h"
25176 +
25177 +
25178 +static inline
25179 +int vc_get_version(uint32_t id)
25180 +{
25181 +       return VCI_VERSION;
25182 +}
25183 +
25184 +static inline
25185 +int vc_get_vci(uint32_t id)
25186 +{
25187 +       return vci_kernel_config();
25188 +}
25189 +
25190 +#include <linux/vserver/context_cmd.h>
25191 +#include <linux/vserver/cvirt_cmd.h>
25192 +#include <linux/vserver/cacct_cmd.h>
25193 +#include <linux/vserver/limit_cmd.h>
25194 +#include <linux/vserver/network_cmd.h>
25195 +#include <linux/vserver/sched_cmd.h>
25196 +#include <linux/vserver/debug_cmd.h>
25197 +#include <linux/vserver/inode_cmd.h>
25198 +#include <linux/vserver/dlimit_cmd.h>
25199 +#include <linux/vserver/signal_cmd.h>
25200 +#include <linux/vserver/space_cmd.h>
25201 +#include <linux/vserver/tag_cmd.h>
25202 +#include <linux/vserver/device_cmd.h>
25203 +
25204 +#include <linux/vserver/inode.h>
25205 +#include <linux/vserver/dlimit.h>
25206 +
25207 +
25208 +#ifdef CONFIG_COMPAT
25209 +#define __COMPAT(name, id, data, compat)       \
25210 +       (compat) ? name ## _x32(id, data) : name(id, data)
25211 +#define __COMPAT_NO_ID(name, data, compat)     \
25212 +       (compat) ? name ## _x32(data) : name(data)
25213 +#else
25214 +#define __COMPAT(name, id, data, compat)       \
25215 +       name(id, data)
25216 +#define __COMPAT_NO_ID(name, data, compat)     \
25217 +       name(data)
25218 +#endif
25219 +
25220 +
25221 +static inline
25222 +long do_vcmd(uint32_t cmd, uint32_t id,
25223 +       struct vx_info *vxi, struct nx_info *nxi,
25224 +       void __user *data, int compat)
25225 +{
25226 +       switch (cmd) {
25227 +
25228 +       case VCMD_get_version:
25229 +               return vc_get_version(id);
25230 +       case VCMD_get_vci:
25231 +               return vc_get_vci(id);
25232 +
25233 +       case VCMD_task_xid:
25234 +               return vc_task_xid(id);
25235 +       case VCMD_vx_info:
25236 +               return vc_vx_info(vxi, data);
25237 +
25238 +       case VCMD_task_nid:
25239 +               return vc_task_nid(id);
25240 +       case VCMD_nx_info:
25241 +               return vc_nx_info(nxi, data);
25242 +
25243 +       case VCMD_task_tag:
25244 +               return vc_task_tag(id);
25245 +
25246 +       case VCMD_set_space_v1:
25247 +               return vc_set_space_v1(vxi, data);
25248 +       /* this is version 2 */
25249 +       case VCMD_set_space:
25250 +               return vc_set_space(vxi, data);
25251 +
25252 +       case VCMD_get_space_mask_v0:
25253 +               return vc_get_space_mask(data, 0);
25254 +       /* this is version 1 */
25255 +       case VCMD_get_space_mask:
25256 +               return vc_get_space_mask(data, 1);
25257 +
25258 +       case VCMD_get_space_default:
25259 +               return vc_get_space_mask(data, -1);
25260 +
25261 +       case VCMD_set_umask:
25262 +               return vc_set_umask(vxi, data);
25263 +
25264 +       case VCMD_get_umask:
25265 +               return vc_get_umask(vxi, data);
25266 +
25267 +       case VCMD_set_wmask:
25268 +               return vc_set_wmask(vxi, data);
25269 +
25270 +       case VCMD_get_wmask:
25271 +               return vc_get_wmask(vxi, data);
25272 +#ifdef CONFIG_IA32_EMULATION
25273 +       case VCMD_get_rlimit:
25274 +               return __COMPAT(vc_get_rlimit, vxi, data, compat);
25275 +       case VCMD_set_rlimit:
25276 +               return __COMPAT(vc_set_rlimit, vxi, data, compat);
25277 +#else
25278 +       case VCMD_get_rlimit:
25279 +               return vc_get_rlimit(vxi, data);
25280 +       case VCMD_set_rlimit:
25281 +               return vc_set_rlimit(vxi, data);
25282 +#endif
25283 +       case VCMD_get_rlimit_mask:
25284 +               return vc_get_rlimit_mask(id, data);
25285 +       case VCMD_reset_hits:
25286 +               return vc_reset_hits(vxi, data);
25287 +       case VCMD_reset_minmax:
25288 +               return vc_reset_minmax(vxi, data);
25289 +
25290 +       case VCMD_get_vhi_name:
25291 +               return vc_get_vhi_name(vxi, data);
25292 +       case VCMD_set_vhi_name:
25293 +               return vc_set_vhi_name(vxi, data);
25294 +
25295 +       case VCMD_ctx_stat:
25296 +               return vc_ctx_stat(vxi, data);
25297 +       case VCMD_virt_stat:
25298 +               return vc_virt_stat(vxi, data);
25299 +       case VCMD_sock_stat:
25300 +               return vc_sock_stat(vxi, data);
25301 +       case VCMD_rlimit_stat:
25302 +               return vc_rlimit_stat(vxi, data);
25303 +
25304 +       case VCMD_set_cflags:
25305 +               return vc_set_cflags(vxi, data);
25306 +       case VCMD_get_cflags:
25307 +               return vc_get_cflags(vxi, data);
25308 +
25309 +       /* this is version 1 */
25310 +       case VCMD_set_ccaps:
25311 +               return vc_set_ccaps(vxi, data);
25312 +       /* this is version 1 */
25313 +       case VCMD_get_ccaps:
25314 +               return vc_get_ccaps(vxi, data);
25315 +       case VCMD_set_bcaps:
25316 +               return vc_set_bcaps(vxi, data);
25317 +       case VCMD_get_bcaps:
25318 +               return vc_get_bcaps(vxi, data);
25319 +
25320 +       case VCMD_set_badness:
25321 +               return vc_set_badness(vxi, data);
25322 +       case VCMD_get_badness:
25323 +               return vc_get_badness(vxi, data);
25324 +
25325 +       case VCMD_set_nflags:
25326 +               return vc_set_nflags(nxi, data);
25327 +       case VCMD_get_nflags:
25328 +               return vc_get_nflags(nxi, data);
25329 +
25330 +       case VCMD_set_ncaps:
25331 +               return vc_set_ncaps(nxi, data);
25332 +       case VCMD_get_ncaps:
25333 +               return vc_get_ncaps(nxi, data);
25334 +
25335 +       case VCMD_set_prio_bias:
25336 +               return vc_set_prio_bias(vxi, data);
25337 +       case VCMD_get_prio_bias:
25338 +               return vc_get_prio_bias(vxi, data);
25339 +       case VCMD_add_dlimit:
25340 +               return __COMPAT(vc_add_dlimit, id, data, compat);
25341 +       case VCMD_rem_dlimit:
25342 +               return __COMPAT(vc_rem_dlimit, id, data, compat);
25343 +       case VCMD_set_dlimit:
25344 +               return __COMPAT(vc_set_dlimit, id, data, compat);
25345 +       case VCMD_get_dlimit:
25346 +               return __COMPAT(vc_get_dlimit, id, data, compat);
25347 +
25348 +       case VCMD_ctx_kill:
25349 +               return vc_ctx_kill(vxi, data);
25350 +
25351 +       case VCMD_wait_exit:
25352 +               return vc_wait_exit(vxi, data);
25353 +
25354 +       case VCMD_get_iattr:
25355 +               return __COMPAT_NO_ID(vc_get_iattr, data, compat);
25356 +       case VCMD_set_iattr:
25357 +               return __COMPAT_NO_ID(vc_set_iattr, data, compat);
25358 +
25359 +       case VCMD_fget_iattr:
25360 +               return vc_fget_iattr(id, data);
25361 +       case VCMD_fset_iattr:
25362 +               return vc_fset_iattr(id, data);
25363 +
25364 +       case VCMD_enter_space_v0:
25365 +               return vc_enter_space_v1(vxi, NULL);
25366 +       case VCMD_enter_space_v1:
25367 +               return vc_enter_space_v1(vxi, data);
25368 +       /* this is version 2 */
25369 +       case VCMD_enter_space:
25370 +               return vc_enter_space(vxi, data);
25371 +
25372 +       case VCMD_ctx_create_v0:
25373 +               return vc_ctx_create(id, NULL);
25374 +       case VCMD_ctx_create:
25375 +               return vc_ctx_create(id, data);
25376 +       case VCMD_ctx_migrate_v0:
25377 +               return vc_ctx_migrate(vxi, NULL);
25378 +       case VCMD_ctx_migrate:
25379 +               return vc_ctx_migrate(vxi, data);
25380 +
25381 +       case VCMD_net_create_v0:
25382 +               return vc_net_create(id, NULL);
25383 +       case VCMD_net_create:
25384 +               return vc_net_create(id, data);
25385 +       case VCMD_net_migrate:
25386 +               return vc_net_migrate(nxi, data);
25387 +
25388 +       case VCMD_tag_migrate:
25389 +               return vc_tag_migrate(id);
25390 +
25391 +       case VCMD_net_add:
25392 +               return vc_net_add(nxi, data);
25393 +       case VCMD_net_remove:
25394 +               return vc_net_remove(nxi, data);
25395 +
25396 +       case VCMD_net_add_ipv4_v1:
25397 +               return vc_net_add_ipv4_v1(nxi, data);
25398 +       /* this is version 2 */
25399 +       case VCMD_net_add_ipv4:
25400 +               return vc_net_add_ipv4(nxi, data);
25401 +
25402 +       case VCMD_net_rem_ipv4_v1:
25403 +               return vc_net_rem_ipv4_v1(nxi, data);
25404 +       /* this is version 2 */
25405 +       case VCMD_net_rem_ipv4:
25406 +               return vc_net_rem_ipv4(nxi, data);
25407 +#ifdef CONFIG_IPV6
25408 +       case VCMD_net_add_ipv6:
25409 +               return vc_net_add_ipv6(nxi, data);
25410 +       case VCMD_net_remove_ipv6:
25411 +               return vc_net_remove_ipv6(nxi, data);
25412 +#endif
25413 +/*     case VCMD_add_match_ipv4:
25414 +               return vc_add_match_ipv4(nxi, data);
25415 +       case VCMD_get_match_ipv4:
25416 +               return vc_get_match_ipv4(nxi, data);
25417 +#ifdef CONFIG_IPV6
25418 +       case VCMD_add_match_ipv6:
25419 +               return vc_add_match_ipv6(nxi, data);
25420 +       case VCMD_get_match_ipv6:
25421 +               return vc_get_match_ipv6(nxi, data);
25422 +#endif */
25423 +
25424 +#ifdef CONFIG_VSERVER_DEVICE
25425 +       case VCMD_set_mapping:
25426 +               return __COMPAT(vc_set_mapping, vxi, data, compat);
25427 +       case VCMD_unset_mapping:
25428 +               return __COMPAT(vc_unset_mapping, vxi, data, compat);
25429 +#endif
25430 +#ifdef CONFIG_VSERVER_HISTORY
25431 +       case VCMD_dump_history:
25432 +               return vc_dump_history(id);
25433 +       case VCMD_read_history:
25434 +               return __COMPAT(vc_read_history, id, data, compat);
25435 +#endif
25436 +       default:
25437 +               vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
25438 +                       VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
25439 +       }
25440 +       return -ENOSYS;
25441 +}
25442 +
25443 +
25444 +#define        __VCMD(vcmd, _perm, _args, _flags)              \
25445 +       case VCMD_ ## vcmd: perm = _perm;               \
25446 +               args = _args; flags = _flags; break
25447 +
25448 +
25449 +#define VCA_NONE       0x00
25450 +#define VCA_VXI                0x01
25451 +#define VCA_NXI                0x02
25452 +
25453 +#define VCF_NONE       0x00
25454 +#define VCF_INFO       0x01
25455 +#define VCF_ADMIN      0x02
25456 +#define VCF_ARES       0x06    /* includes admin */
25457 +#define VCF_SETUP      0x08
25458 +
25459 +#define VCF_ZIDOK      0x10    /* zero id okay */
25460 +
25461 +
25462 +static inline
25463 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
25464 +{
25465 +       long ret;
25466 +       int permit = -1, state = 0;
25467 +       int perm = -1, args = 0, flags = 0;
25468 +       struct vx_info *vxi = NULL;
25469 +       struct nx_info *nxi = NULL;
25470 +
25471 +       switch (cmd) {
25472 +       /* unpriviledged commands */
25473 +       __VCMD(get_version,      0, VCA_NONE,   0);
25474 +       __VCMD(get_vci,          0, VCA_NONE,   0);
25475 +       __VCMD(get_rlimit_mask,  0, VCA_NONE,   0);
25476 +       __VCMD(get_space_mask_v0,0, VCA_NONE,   0);
25477 +       __VCMD(get_space_mask,   0, VCA_NONE,   0);
25478 +       __VCMD(get_space_default,0, VCA_NONE,   0);
25479 +
25480 +       /* info commands */
25481 +       __VCMD(task_xid,         2, VCA_NONE,   0);
25482 +       __VCMD(reset_hits,       2, VCA_VXI,    0);
25483 +       __VCMD(reset_minmax,     2, VCA_VXI,    0);
25484 +       __VCMD(vx_info,          3, VCA_VXI,    VCF_INFO);
25485 +       __VCMD(get_bcaps,        3, VCA_VXI,    VCF_INFO);
25486 +       __VCMD(get_ccaps,        3, VCA_VXI,    VCF_INFO);
25487 +       __VCMD(get_cflags,       3, VCA_VXI,    VCF_INFO);
25488 +       __VCMD(get_umask,        3, VCA_VXI,    VCF_INFO);
25489 +       __VCMD(get_wmask,        3, VCA_VXI,    VCF_INFO);
25490 +       __VCMD(get_badness,      3, VCA_VXI,    VCF_INFO);
25491 +       __VCMD(get_vhi_name,     3, VCA_VXI,    VCF_INFO);
25492 +       __VCMD(get_rlimit,       3, VCA_VXI,    VCF_INFO);
25493 +
25494 +       __VCMD(ctx_stat,         3, VCA_VXI,    VCF_INFO);
25495 +       __VCMD(virt_stat,        3, VCA_VXI,    VCF_INFO);
25496 +       __VCMD(sock_stat,        3, VCA_VXI,    VCF_INFO);
25497 +       __VCMD(rlimit_stat,      3, VCA_VXI,    VCF_INFO);
25498 +
25499 +       __VCMD(task_nid,         2, VCA_NONE,   0);
25500 +       __VCMD(nx_info,          3, VCA_NXI,    VCF_INFO);
25501 +       __VCMD(get_ncaps,        3, VCA_NXI,    VCF_INFO);
25502 +       __VCMD(get_nflags,       3, VCA_NXI,    VCF_INFO);
25503 +
25504 +       __VCMD(task_tag,         2, VCA_NONE,   0);
25505 +
25506 +       __VCMD(get_iattr,        2, VCA_NONE,   0);
25507 +       __VCMD(fget_iattr,       2, VCA_NONE,   0);
25508 +       __VCMD(get_dlimit,       3, VCA_NONE,   VCF_INFO);
25509 +       __VCMD(get_prio_bias,    3, VCA_VXI,    VCF_INFO);
25510 +
25511 +       /* lower admin commands */
25512 +       __VCMD(wait_exit,        4, VCA_VXI,    VCF_INFO);
25513 +       __VCMD(ctx_create_v0,    5, VCA_NONE,   0);
25514 +       __VCMD(ctx_create,       5, VCA_NONE,   0);
25515 +       __VCMD(ctx_migrate_v0,   5, VCA_VXI,    VCF_ADMIN);
25516 +       __VCMD(ctx_migrate,      5, VCA_VXI,    VCF_ADMIN);
25517 +       __VCMD(enter_space_v0,   5, VCA_VXI,    VCF_ADMIN);
25518 +       __VCMD(enter_space_v1,   5, VCA_VXI,    VCF_ADMIN);
25519 +       __VCMD(enter_space,      5, VCA_VXI,    VCF_ADMIN);
25520 +
25521 +       __VCMD(net_create_v0,    5, VCA_NONE,   0);
25522 +       __VCMD(net_create,       5, VCA_NONE,   0);
25523 +       __VCMD(net_migrate,      5, VCA_NXI,    VCF_ADMIN);
25524 +
25525 +       __VCMD(tag_migrate,      5, VCA_NONE,   VCF_ADMIN);
25526 +
25527 +       /* higher admin commands */
25528 +       __VCMD(ctx_kill,         6, VCA_VXI,    VCF_ARES);
25529 +       __VCMD(set_space_v1,     7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25530 +       __VCMD(set_space,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25531 +
25532 +       __VCMD(set_ccaps,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25533 +       __VCMD(set_bcaps,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25534 +       __VCMD(set_cflags,       7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25535 +       __VCMD(set_umask,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25536 +       __VCMD(set_wmask,        7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25537 +       __VCMD(set_badness,      7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25538 +
25539 +       __VCMD(set_vhi_name,     7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25540 +       __VCMD(set_rlimit,       7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25541 +       __VCMD(set_prio_bias,    7, VCA_VXI,    VCF_ARES | VCF_SETUP);
25542 +
25543 +       __VCMD(set_ncaps,        7, VCA_NXI,    VCF_ARES | VCF_SETUP);
25544 +       __VCMD(set_nflags,       7, VCA_NXI,    VCF_ARES | VCF_SETUP);
25545 +       __VCMD(net_add,          8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25546 +       __VCMD(net_remove,       8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25547 +       __VCMD(net_add_ipv4_v1,  8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25548 +       __VCMD(net_rem_ipv4_v1,  8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25549 +       __VCMD(net_add_ipv4,     8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25550 +       __VCMD(net_rem_ipv4,     8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25551 +#ifdef CONFIG_IPV6
25552 +       __VCMD(net_add_ipv6,     8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25553 +       __VCMD(net_remove_ipv6,  8, VCA_NXI,    VCF_ARES | VCF_SETUP);
25554 +#endif
25555 +       __VCMD(set_iattr,        7, VCA_NONE,   0);
25556 +       __VCMD(fset_iattr,       7, VCA_NONE,   0);
25557 +       __VCMD(set_dlimit,       7, VCA_NONE,   VCF_ARES);
25558 +       __VCMD(add_dlimit,       8, VCA_NONE,   VCF_ARES);
25559 +       __VCMD(rem_dlimit,       8, VCA_NONE,   VCF_ARES);
25560 +
25561 +#ifdef CONFIG_VSERVER_DEVICE
25562 +       __VCMD(set_mapping,      8, VCA_VXI,    VCF_ARES|VCF_ZIDOK);
25563 +       __VCMD(unset_mapping,    8, VCA_VXI,    VCF_ARES|VCF_ZIDOK);
25564 +#endif
25565 +       /* debug level admin commands */
25566 +#ifdef CONFIG_VSERVER_HISTORY
25567 +       __VCMD(dump_history,     9, VCA_NONE,   0);
25568 +       __VCMD(read_history,     9, VCA_NONE,   0);
25569 +#endif
25570 +
25571 +       default:
25572 +               perm = -1;
25573 +       }
25574 +
25575 +       vxdprintk(VXD_CBIT(switch, 0),
25576 +               "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
25577 +               VC_CATEGORY(cmd), VC_COMMAND(cmd),
25578 +               VC_VERSION(cmd), id, data, compat,
25579 +               perm, args, flags);
25580 +
25581 +       ret = -ENOSYS;
25582 +       if (perm < 0)
25583 +               goto out;
25584 +
25585 +       state = 1;
25586 +       if (!capable(CAP_CONTEXT))
25587 +               goto out;
25588 +
25589 +       state = 2;
25590 +       /* moved here from the individual commands */
25591 +       ret = -EPERM;
25592 +       if ((perm > 1) && !capable(CAP_SYS_ADMIN))
25593 +               goto out;
25594 +
25595 +       state = 3;
25596 +       /* vcmd involves resource management  */
25597 +       ret = -EPERM;
25598 +       if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
25599 +               goto out;
25600 +
25601 +       state = 4;
25602 +       /* various legacy exceptions */
25603 +       switch (cmd) {
25604 +       /* will go away when spectator is a cap */
25605 +       case VCMD_ctx_migrate_v0:
25606 +       case VCMD_ctx_migrate:
25607 +               if (id == 1) {
25608 +                       current->xid = 1;
25609 +                       ret = 1;
25610 +                       goto out;
25611 +               }
25612 +               break;
25613 +
25614 +       /* will go away when spectator is a cap */
25615 +       case VCMD_net_migrate:
25616 +               if (id == 1) {
25617 +                       current->nid = 1;
25618 +                       ret = 1;
25619 +                       goto out;
25620 +               }
25621 +               break;
25622 +       }
25623 +
25624 +       /* vcmds are fine by default */
25625 +       permit = 1;
25626 +
25627 +       /* admin type vcmds require admin ... */
25628 +       if (flags & VCF_ADMIN)
25629 +               permit = vx_check(0, VS_ADMIN) ? 1 : 0;
25630 +
25631 +       /* ... but setup type vcmds override that */
25632 +       if (!permit && (flags & VCF_SETUP))
25633 +               permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
25634 +
25635 +       state = 5;
25636 +       ret = -EPERM;
25637 +       if (!permit)
25638 +               goto out;
25639 +
25640 +       state = 6;
25641 +       if (!id && (flags & VCF_ZIDOK))
25642 +               goto skip_id;
25643 +
25644 +       ret = -ESRCH;
25645 +       if (args & VCA_VXI) {
25646 +               vxi = lookup_vx_info(id);
25647 +               if (!vxi)
25648 +                       goto out;
25649 +
25650 +               if ((flags & VCF_ADMIN) &&
25651 +                       /* special case kill for shutdown */
25652 +                       (cmd != VCMD_ctx_kill) &&
25653 +                       /* can context be administrated? */
25654 +                       !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
25655 +                       ret = -EACCES;
25656 +                       goto out_vxi;
25657 +               }
25658 +       }
25659 +       state = 7;
25660 +       if (args & VCA_NXI) {
25661 +               nxi = lookup_nx_info(id);
25662 +               if (!nxi)
25663 +                       goto out_vxi;
25664 +
25665 +               if ((flags & VCF_ADMIN) &&
25666 +                       /* can context be administrated? */
25667 +                       !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
25668 +                       ret = -EACCES;
25669 +                       goto out_nxi;
25670 +               }
25671 +       }
25672 +skip_id:
25673 +       state = 8;
25674 +       ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
25675 +
25676 +out_nxi:
25677 +       if ((args & VCA_NXI) && nxi)
25678 +               put_nx_info(nxi);
25679 +out_vxi:
25680 +       if ((args & VCA_VXI) && vxi)
25681 +               put_vx_info(vxi);
25682 +out:
25683 +       vxdprintk(VXD_CBIT(switch, 1),
25684 +               "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
25685 +               VC_CATEGORY(cmd), VC_COMMAND(cmd),
25686 +               VC_VERSION(cmd), ret, ret, state, permit);
25687 +       return ret;
25688 +}
25689 +
25690 +asmlinkage long
25691 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
25692 +{
25693 +       return do_vserver(cmd, id, data, 0);
25694 +}
25695 +
25696 +#ifdef CONFIG_COMPAT
25697 +
25698 +asmlinkage long
25699 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
25700 +{
25701 +       return do_vserver(cmd, id, data, 1);
25702 +}
25703 +
25704 +#endif /* CONFIG_COMPAT */
25705 diff -NurpP --minimal linux-3.0.4/kernel/vserver/sysctl.c linux-3.0.4-vs2.3.1/kernel/vserver/sysctl.c
25706 --- linux-3.0.4/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
25707 +++ linux-3.0.4-vs2.3.1/kernel/vserver/sysctl.c 2011-06-10 22:11:24.000000000 +0200
25708 @@ -0,0 +1,241 @@
25709 +/*
25710 + *  kernel/vserver/sysctl.c
25711 + *
25712 + *  Virtual Context Support
25713 + *
25714 + *  Copyright (C) 2004-2007  Herbert Pötzl
25715 + *
25716 + *  V0.01  basic structure
25717 + *
25718 + */
25719 +
25720 +#include <linux/module.h>
25721 +#include <linux/ctype.h>
25722 +#include <linux/sysctl.h>
25723 +#include <linux/parser.h>
25724 +#include <asm/uaccess.h>
25725 +
25726 +enum {
25727 +       CTL_DEBUG_ERROR         = 0,
25728 +       CTL_DEBUG_SWITCH        = 1,
25729 +       CTL_DEBUG_XID,
25730 +       CTL_DEBUG_NID,
25731 +       CTL_DEBUG_TAG,
25732 +       CTL_DEBUG_NET,
25733 +       CTL_DEBUG_LIMIT,
25734 +       CTL_DEBUG_CRES,
25735 +       CTL_DEBUG_DLIM,
25736 +       CTL_DEBUG_QUOTA,
25737 +       CTL_DEBUG_CVIRT,
25738 +       CTL_DEBUG_SPACE,
25739 +       CTL_DEBUG_MISC,
25740 +};
25741 +
25742 +
25743 +unsigned int vx_debug_switch   = 0;
25744 +unsigned int vx_debug_xid      = 0;
25745 +unsigned int vx_debug_nid      = 0;
25746 +unsigned int vx_debug_tag      = 0;
25747 +unsigned int vx_debug_net      = 0;
25748 +unsigned int vx_debug_limit    = 0;
25749 +unsigned int vx_debug_cres     = 0;
25750 +unsigned int vx_debug_dlim     = 0;
25751 +unsigned int vx_debug_quota    = 0;
25752 +unsigned int vx_debug_cvirt    = 0;
25753 +unsigned int vx_debug_space    = 0;
25754 +unsigned int vx_debug_misc     = 0;
25755 +
25756 +
25757 +static struct ctl_table_header *vserver_table_header;
25758 +static ctl_table vserver_root_table[];
25759 +
25760 +
25761 +void vserver_register_sysctl(void)
25762 +{
25763 +       if (!vserver_table_header) {
25764 +               vserver_table_header = register_sysctl_table(vserver_root_table);
25765 +       }
25766 +
25767 +}
25768 +
25769 +void vserver_unregister_sysctl(void)
25770 +{
25771 +       if (vserver_table_header) {
25772 +               unregister_sysctl_table(vserver_table_header);
25773 +               vserver_table_header = NULL;
25774 +       }
25775 +}
25776 +
25777 +
25778 +static int proc_dodebug(ctl_table *table, int write,
25779 +       void __user *buffer, size_t *lenp, loff_t *ppos)
25780 +{
25781 +       char            tmpbuf[20], *p, c;
25782 +       unsigned int    value;
25783 +       size_t          left, len;
25784 +
25785 +       if ((*ppos && !write) || !*lenp) {
25786 +               *lenp = 0;
25787 +               return 0;
25788 +       }
25789 +
25790 +       left = *lenp;
25791 +
25792 +       if (write) {
25793 +               if (!access_ok(VERIFY_READ, buffer, left))
25794 +                       return -EFAULT;
25795 +               p = (char *)buffer;
25796 +               while (left && __get_user(c, p) >= 0 && isspace(c))
25797 +                       left--, p++;
25798 +               if (!left)
25799 +                       goto done;
25800 +
25801 +               if (left > sizeof(tmpbuf) - 1)
25802 +                       return -EINVAL;
25803 +               if (copy_from_user(tmpbuf, p, left))
25804 +                       return -EFAULT;
25805 +               tmpbuf[left] = '\0';
25806 +
25807 +               for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
25808 +                       value = 10 * value + (*p - '0');
25809 +               if (*p && !isspace(*p))
25810 +                       return -EINVAL;
25811 +               while (left && isspace(*p))
25812 +                       left--, p++;
25813 +               *(unsigned int *)table->data = value;
25814 +       } else {
25815 +               if (!access_ok(VERIFY_WRITE, buffer, left))
25816 +                       return -EFAULT;
25817 +               len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
25818 +               if (len > left)
25819 +                       len = left;
25820 +               if (__copy_to_user(buffer, tmpbuf, len))
25821 +                       return -EFAULT;
25822 +               if ((left -= len) > 0) {
25823 +                       if (put_user('\n', (char *)buffer + len))
25824 +                               return -EFAULT;
25825 +                       left--;
25826 +               }
25827 +       }
25828 +
25829 +done:
25830 +       *lenp -= left;
25831 +       *ppos += *lenp;
25832 +       return 0;
25833 +}
25834 +
25835 +static int zero;
25836 +
25837 +#define        CTL_ENTRY(ctl, name)                            \
25838 +       {                                               \
25839 +               .procname       = #name,                \
25840 +               .data           = &vx_ ## name,         \
25841 +               .maxlen         = sizeof(int),          \
25842 +               .mode           = 0644,                 \
25843 +               .proc_handler   = &proc_dodebug,        \
25844 +               .extra1         = &zero,                \
25845 +               .extra2         = &zero,                \
25846 +       }
25847 +
25848 +static ctl_table vserver_debug_table[] = {
25849 +       CTL_ENTRY(CTL_DEBUG_SWITCH,     debug_switch),
25850 +       CTL_ENTRY(CTL_DEBUG_XID,        debug_xid),
25851 +       CTL_ENTRY(CTL_DEBUG_NID,        debug_nid),
25852 +       CTL_ENTRY(CTL_DEBUG_TAG,        debug_tag),
25853 +       CTL_ENTRY(CTL_DEBUG_NET,        debug_net),
25854 +       CTL_ENTRY(CTL_DEBUG_LIMIT,      debug_limit),
25855 +       CTL_ENTRY(CTL_DEBUG_CRES,       debug_cres),
25856 +       CTL_ENTRY(CTL_DEBUG_DLIM,       debug_dlim),
25857 +       CTL_ENTRY(CTL_DEBUG_QUOTA,      debug_quota),
25858 +       CTL_ENTRY(CTL_DEBUG_CVIRT,      debug_cvirt),
25859 +       CTL_ENTRY(CTL_DEBUG_SPACE,      debug_space),
25860 +       CTL_ENTRY(CTL_DEBUG_MISC,       debug_misc),
25861 +       { 0 }
25862 +};
25863 +
25864 +static ctl_table vserver_root_table[] = {
25865 +       {
25866 +               .procname       = "vserver",
25867 +               .mode           = 0555,
25868 +               .child          = vserver_debug_table
25869 +       },
25870 +       { 0 }
25871 +};
25872 +
25873 +
25874 +static match_table_t tokens = {
25875 +       { CTL_DEBUG_SWITCH,     "switch=%x"     },
25876 +       { CTL_DEBUG_XID,        "xid=%x"        },
25877 +       { CTL_DEBUG_NID,        "nid=%x"        },
25878 +       { CTL_DEBUG_TAG,        "tag=%x"        },
25879 +       { CTL_DEBUG_NET,        "net=%x"        },
25880 +       { CTL_DEBUG_LIMIT,      "limit=%x"      },
25881 +       { CTL_DEBUG_CRES,       "cres=%x"       },
25882 +       { CTL_DEBUG_DLIM,       "dlim=%x"       },
25883 +       { CTL_DEBUG_QUOTA,      "quota=%x"      },
25884 +       { CTL_DEBUG_CVIRT,      "cvirt=%x"      },
25885 +       { CTL_DEBUG_SPACE,      "space=%x"      },
25886 +       { CTL_DEBUG_MISC,       "misc=%x"       },
25887 +       { CTL_DEBUG_ERROR,      NULL            }
25888 +};
25889 +
25890 +#define        HANDLE_CASE(id, name, val)                              \
25891 +       case CTL_DEBUG_ ## id:                                  \
25892 +               vx_debug_ ## name = val;                        \
25893 +               printk("vs_debug_" #name "=0x%x\n", val);       \
25894 +               break
25895 +
25896 +
25897 +static int __init vs_debug_setup(char *str)
25898 +{
25899 +       char *p;
25900 +       int token;
25901 +
25902 +       printk("vs_debug_setup(%s)\n", str);
25903 +       while ((p = strsep(&str, ",")) != NULL) {
25904 +               substring_t args[MAX_OPT_ARGS];
25905 +               unsigned int value;
25906 +
25907 +               if (!*p)
25908 +                       continue;
25909 +
25910 +               token = match_token(p, tokens, args);
25911 +               value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
25912 +
25913 +               switch (token) {
25914 +               HANDLE_CASE(SWITCH, switch, value);
25915 +               HANDLE_CASE(XID,    xid,    value);
25916 +               HANDLE_CASE(NID,    nid,    value);
25917 +               HANDLE_CASE(TAG,    tag,    value);
25918 +               HANDLE_CASE(NET,    net,    value);
25919 +               HANDLE_CASE(LIMIT,  limit,  value);
25920 +               HANDLE_CASE(CRES,   cres,   value);
25921 +               HANDLE_CASE(DLIM,   dlim,   value);
25922 +               HANDLE_CASE(QUOTA,  quota,  value);
25923 +               HANDLE_CASE(CVIRT,  cvirt,  value);
25924 +               HANDLE_CASE(SPACE,  space,  value);
25925 +               HANDLE_CASE(MISC,   misc,   value);
25926 +               default:
25927 +                       return -EINVAL;
25928 +                       break;
25929 +               }
25930 +       }
25931 +       return 1;
25932 +}
25933 +
25934 +__setup("vsdebug=", vs_debug_setup);
25935 +
25936 +
25937 +
25938 +EXPORT_SYMBOL_GPL(vx_debug_switch);
25939 +EXPORT_SYMBOL_GPL(vx_debug_xid);
25940 +EXPORT_SYMBOL_GPL(vx_debug_nid);
25941 +EXPORT_SYMBOL_GPL(vx_debug_net);
25942 +EXPORT_SYMBOL_GPL(vx_debug_limit);
25943 +EXPORT_SYMBOL_GPL(vx_debug_cres);
25944 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
25945 +EXPORT_SYMBOL_GPL(vx_debug_quota);
25946 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
25947 +EXPORT_SYMBOL_GPL(vx_debug_space);
25948 +EXPORT_SYMBOL_GPL(vx_debug_misc);
25949 +
25950 diff -NurpP --minimal linux-3.0.4/kernel/vserver/tag.c linux-3.0.4-vs2.3.1/kernel/vserver/tag.c
25951 --- linux-3.0.4/kernel/vserver/tag.c    1970-01-01 01:00:00.000000000 +0100
25952 +++ linux-3.0.4-vs2.3.1/kernel/vserver/tag.c    2011-06-10 22:11:24.000000000 +0200
25953 @@ -0,0 +1,63 @@
25954 +/*
25955 + *  linux/kernel/vserver/tag.c
25956 + *
25957 + *  Virtual Server: Shallow Tag Space
25958 + *
25959 + *  Copyright (C) 2007  Herbert Pötzl
25960 + *
25961 + *  V0.01  basic implementation
25962 + *
25963 + */
25964 +
25965 +#include <linux/sched.h>
25966 +#include <linux/vserver/debug.h>
25967 +#include <linux/vs_pid.h>
25968 +#include <linux/vs_tag.h>
25969 +
25970 +#include <linux/vserver/tag_cmd.h>
25971 +
25972 +
25973 +int dx_migrate_task(struct task_struct *p, tag_t tag)
25974 +{
25975 +       if (!p)
25976 +               BUG();
25977 +
25978 +       vxdprintk(VXD_CBIT(tag, 5),
25979 +               "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
25980 +
25981 +       task_lock(p);
25982 +       p->tag = tag;
25983 +       task_unlock(p);
25984 +
25985 +       vxdprintk(VXD_CBIT(tag, 5),
25986 +               "moved task %p into [#%d]", p, tag);
25987 +       return 0;
25988 +}
25989 +
25990 +/* vserver syscall commands below here */
25991 +
25992 +/* taks xid and vx_info functions */
25993 +
25994 +
25995 +int vc_task_tag(uint32_t id)
25996 +{
25997 +       tag_t tag;
25998 +
25999 +       if (id) {
26000 +               struct task_struct *tsk;
26001 +               rcu_read_lock();
26002 +               tsk = find_task_by_real_pid(id);
26003 +               tag = (tsk) ? tsk->tag : -ESRCH;
26004 +               rcu_read_unlock();
26005 +       } else
26006 +               tag = dx_current_tag();
26007 +       return tag;
26008 +}
26009 +
26010 +
26011 +int vc_tag_migrate(uint32_t tag)
26012 +{
26013 +       return dx_migrate_task(current, tag & 0xFFFF);
26014 +}
26015 +
26016 +
26017 diff -NurpP --minimal linux-3.0.4/kernel/vserver/vci_config.h linux-3.0.4-vs2.3.1/kernel/vserver/vci_config.h
26018 --- linux-3.0.4/kernel/vserver/vci_config.h     1970-01-01 01:00:00.000000000 +0100
26019 +++ linux-3.0.4-vs2.3.1/kernel/vserver/vci_config.h     2011-06-10 22:11:24.000000000 +0200
26020 @@ -0,0 +1,76 @@
26021 +
26022 +/*  interface version */
26023 +
26024 +#define VCI_VERSION            0x00020308
26025 +
26026 +
26027 +enum {
26028 +       VCI_KCBIT_NO_DYNAMIC = 0,
26029 +
26030 +       VCI_KCBIT_PROC_SECURE = 4,
26031 +       /* VCI_KCBIT_HARDCPU = 5, */
26032 +       /* VCI_KCBIT_IDLELIMIT = 6, */
26033 +       /* VCI_KCBIT_IDLETIME = 7, */
26034 +
26035 +       VCI_KCBIT_COWBL = 8,
26036 +       VCI_KCBIT_FULLCOWBL = 9,
26037 +       VCI_KCBIT_SPACES = 10,
26038 +       VCI_KCBIT_NETV2 = 11,
26039 +       VCI_KCBIT_MEMCG = 12,
26040 +
26041 +       VCI_KCBIT_DEBUG = 16,
26042 +       VCI_KCBIT_HISTORY = 20,
26043 +       VCI_KCBIT_TAGGED = 24,
26044 +       VCI_KCBIT_PPTAG = 28,
26045 +
26046 +       VCI_KCBIT_MORE = 31,
26047 +};
26048 +
26049 +
26050 +static inline uint32_t vci_kernel_config(void)
26051 +{
26052 +       return
26053 +       (1 << VCI_KCBIT_NO_DYNAMIC) |
26054 +
26055 +       /* configured features */
26056 +#ifdef CONFIG_VSERVER_PROC_SECURE
26057 +       (1 << VCI_KCBIT_PROC_SECURE) |
26058 +#endif
26059 +#ifdef CONFIG_VSERVER_COWBL
26060 +       (1 << VCI_KCBIT_COWBL) |
26061 +       (1 << VCI_KCBIT_FULLCOWBL) |
26062 +#endif
26063 +       (1 << VCI_KCBIT_SPACES) |
26064 +       (1 << VCI_KCBIT_NETV2) |
26065 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
26066 +       (1 << VCI_KCBIT_MEMCG) |
26067 +#endif
26068 +
26069 +       /* debug options */
26070 +#ifdef CONFIG_VSERVER_DEBUG
26071 +       (1 << VCI_KCBIT_DEBUG) |
26072 +#endif
26073 +#ifdef CONFIG_VSERVER_HISTORY
26074 +       (1 << VCI_KCBIT_HISTORY) |
26075 +#endif
26076 +
26077 +       /* inode context tagging */
26078 +#if    defined(CONFIG_TAGGING_NONE)
26079 +       (0 << VCI_KCBIT_TAGGED) |
26080 +#elif  defined(CONFIG_TAGGING_UID16)
26081 +       (1 << VCI_KCBIT_TAGGED) |
26082 +#elif  defined(CONFIG_TAGGING_GID16)
26083 +       (2 << VCI_KCBIT_TAGGED) |
26084 +#elif  defined(CONFIG_TAGGING_ID24)
26085 +       (3 << VCI_KCBIT_TAGGED) |
26086 +#elif  defined(CONFIG_TAGGING_INTERN)
26087 +       (4 << VCI_KCBIT_TAGGED) |
26088 +#elif  defined(CONFIG_TAGGING_RUNTIME)
26089 +       (5 << VCI_KCBIT_TAGGED) |
26090 +#else
26091 +       (7 << VCI_KCBIT_TAGGED) |
26092 +#endif
26093 +       (1 << VCI_KCBIT_PPTAG) |
26094 +       0;
26095 +}
26096 +
26097 diff -NurpP --minimal linux-3.0.4/mm/filemap_xip.c linux-3.0.4-vs2.3.1/mm/filemap_xip.c
26098 --- linux-3.0.4/mm/filemap_xip.c        2011-07-22 11:18:12.000000000 +0200
26099 +++ linux-3.0.4-vs2.3.1/mm/filemap_xip.c        2011-06-10 22:11:24.000000000 +0200
26100 @@ -18,6 +18,7 @@
26101  #include <linux/seqlock.h>
26102  #include <linux/mutex.h>
26103  #include <linux/gfp.h>
26104 +#include <linux/vs_memory.h>
26105  #include <asm/tlbflush.h>
26106  #include <asm/io.h>
26107  
26108 diff -NurpP --minimal linux-3.0.4/mm/fremap.c linux-3.0.4-vs2.3.1/mm/fremap.c
26109 --- linux-3.0.4/mm/fremap.c     2011-07-22 11:18:12.000000000 +0200
26110 +++ linux-3.0.4-vs2.3.1/mm/fremap.c     2011-06-10 22:11:24.000000000 +0200
26111 @@ -16,6 +16,7 @@
26112  #include <linux/module.h>
26113  #include <linux/syscalls.h>
26114  #include <linux/mmu_notifier.h>
26115 +#include <linux/vs_memory.h>
26116  
26117  #include <asm/mmu_context.h>
26118  #include <asm/cacheflush.h>
26119 diff -NurpP --minimal linux-3.0.4/mm/hugetlb.c linux-3.0.4-vs2.3.1/mm/hugetlb.c
26120 --- linux-3.0.4/mm/hugetlb.c    2011-07-22 11:18:12.000000000 +0200
26121 +++ linux-3.0.4-vs2.3.1/mm/hugetlb.c    2011-06-22 12:39:16.000000000 +0200
26122 @@ -28,6 +28,7 @@
26123  
26124  #include <linux/hugetlb.h>
26125  #include <linux/node.h>
26126 +#include <linux/vs_memory.h>
26127  #include "internal.h"
26128  
26129  const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
26130 diff -NurpP --minimal linux-3.0.4/mm/memcontrol.c linux-3.0.4-vs2.3.1/mm/memcontrol.c
26131 --- linux-3.0.4/mm/memcontrol.c 2011-08-31 18:56:42.000000000 +0200
26132 +++ linux-3.0.4-vs2.3.1/mm/memcontrol.c 2011-08-08 23:04:47.000000000 +0200
26133 @@ -741,6 +741,31 @@ struct mem_cgroup *mem_cgroup_from_task(
26134                                 struct mem_cgroup, css);
26135  }
26136  
26137 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
26138 +{
26139 +       return res_counter_read_u64(&mem->res, member);
26140 +}
26141 +
26142 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
26143 +{
26144 +       return res_counter_read_u64(&mem->memsw, member);
26145 +}
26146 +
26147 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
26148 +{
26149 +       return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
26150 +}
26151 +
26152 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
26153 +{
26154 +       return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
26155 +}
26156 +
26157 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
26158 +{
26159 +       return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
26160 +}
26161 +
26162  struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
26163  {
26164         struct mem_cgroup *mem = NULL;
26165 diff -NurpP --minimal linux-3.0.4/mm/memory.c linux-3.0.4-vs2.3.1/mm/memory.c
26166 --- linux-3.0.4/mm/memory.c     2011-08-31 18:56:42.000000000 +0200
26167 +++ linux-3.0.4-vs2.3.1/mm/memory.c     2011-08-08 23:04:47.000000000 +0200
26168 @@ -3388,6 +3388,7 @@ int handle_pte_fault(struct mm_struct *m
26169  {
26170         pte_t entry;
26171         spinlock_t *ptl;
26172 +       int ret = 0, type = VXPT_UNKNOWN;
26173  
26174         entry = *pte;
26175         if (!pte_present(entry)) {
26176 @@ -3412,9 +3413,12 @@ int handle_pte_fault(struct mm_struct *m
26177         if (unlikely(!pte_same(*pte, entry)))
26178                 goto unlock;
26179         if (flags & FAULT_FLAG_WRITE) {
26180 -               if (!pte_write(entry))
26181 -                       return do_wp_page(mm, vma, address,
26182 +               if (!pte_write(entry)) {
26183 +                       ret = do_wp_page(mm, vma, address,
26184                                         pte, pmd, ptl, entry);
26185 +                       type = VXPT_WRITE;
26186 +                       goto out;
26187 +               }
26188                 entry = pte_mkdirty(entry);
26189         }
26190         entry = pte_mkyoung(entry);
26191 @@ -3432,7 +3436,10 @@ int handle_pte_fault(struct mm_struct *m
26192         }
26193  unlock:
26194         pte_unmap_unlock(pte, ptl);
26195 -       return 0;
26196 +       ret = 0;
26197 +out:
26198 +       vx_page_fault(mm, vma, type, ret);
26199 +       return ret;
26200  }
26201  
26202  /*
26203 diff -NurpP --minimal linux-3.0.4/mm/mremap.c linux-3.0.4-vs2.3.1/mm/mremap.c
26204 --- linux-3.0.4/mm/mremap.c     2011-07-22 11:18:12.000000000 +0200
26205 +++ linux-3.0.4-vs2.3.1/mm/mremap.c     2011-06-10 22:11:24.000000000 +0200
26206 @@ -19,6 +19,7 @@
26207  #include <linux/security.h>
26208  #include <linux/syscalls.h>
26209  #include <linux/mmu_notifier.h>
26210 +#include <linux/vs_memory.h>
26211  
26212  #include <asm/uaccess.h>
26213  #include <asm/cacheflush.h>
26214 diff -NurpP --minimal linux-3.0.4/mm/oom_kill.c linux-3.0.4-vs2.3.1/mm/oom_kill.c
26215 --- linux-3.0.4/mm/oom_kill.c   2011-08-31 18:56:42.000000000 +0200
26216 +++ linux-3.0.4-vs2.3.1/mm/oom_kill.c   2011-08-08 23:04:47.000000000 +0200
26217 @@ -32,6 +32,9 @@
26218  #include <linux/mempolicy.h>
26219  #include <linux/security.h>
26220  #include <linux/ptrace.h>
26221 +#include <linux/reboot.h>
26222 +#include <linux/vs_memory.h>
26223 +#include <linux/vs_context.h>
26224  
26225  int sysctl_panic_on_oom;
26226  int sysctl_oom_kill_allocating_task;
26227 @@ -134,11 +137,18 @@ struct task_struct *find_lock_task_mm(st
26228  static bool oom_unkillable_task(struct task_struct *p,
26229                 const struct mem_cgroup *mem, const nodemask_t *nodemask)
26230  {
26231 -       if (is_global_init(p))
26232 +       unsigned xid = vx_current_xid();
26233 +
26234 +       /* skip the init task, global and per guest */
26235 +       if (task_is_init(p))
26236                 return true;
26237         if (p->flags & PF_KTHREAD)
26238                 return true;
26239  
26240 +       /* skip other guest and host processes if oom in guest */
26241 +       if (xid && vx_task_xid(p) != xid)
26242 +               return true;
26243 +
26244         /* When mem_cgroup_out_of_memory() and p is not member of the group */
26245         if (mem && !task_in_mem_cgroup(p, mem))
26246                 return true;
26247 @@ -214,6 +224,18 @@ unsigned int oom_badness(struct task_str
26248         points += p->signal->oom_score_adj;
26249  
26250         /*
26251 +        * add points for context badness and
26252 +        * reduce badness for processes belonging to
26253 +        * a different context
26254 +        */
26255 +
26256 +       points += vx_badness(p, p->mm);
26257 +
26258 +       if ((vx_current_xid() > 1) &&
26259 +               vx_current_xid() != vx_task_xid(p))
26260 +               points /= 16;
26261 +
26262 +       /*
26263          * Never return 0 for an eligible task that may be killed since it's
26264          * possible that no single user task uses more than 0.1% of memory and
26265          * no single admin tasks uses more than 3.0%.
26266 @@ -429,8 +451,8 @@ static int oom_kill_task(struct task_str
26267         /* mm cannot be safely dereferenced after task_unlock(p) */
26268         mm = p->mm;
26269  
26270 -       pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
26271 -               task_pid_nr(p), p->comm, K(p->mm->total_vm),
26272 +       pr_err("Killed process %d:#%u (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
26273 +               task_pid_nr(p), p->xid, p->comm, K(p->mm->total_vm),
26274                 K(get_mm_counter(p->mm, MM_ANONPAGES)),
26275                 K(get_mm_counter(p->mm, MM_FILEPAGES)));
26276         task_unlock(p);
26277 @@ -484,8 +506,8 @@ static int oom_kill_process(struct task_
26278         }
26279  
26280         task_lock(p);
26281 -       pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
26282 -               message, task_pid_nr(p), p->comm, points);
26283 +       pr_err("%s: Kill process %d:#%u (%s) score %d or sacrifice child\n",
26284 +               message, task_pid_nr(p), p->xid, p->comm, points);
26285         task_unlock(p);
26286  
26287         /*
26288 @@ -586,6 +608,8 @@ int unregister_oom_notifier(struct notif
26289  }
26290  EXPORT_SYMBOL_GPL(unregister_oom_notifier);
26291  
26292 +long vs_oom_action(unsigned int);
26293 +
26294  /*
26295   * Try to acquire the OOM killer lock for the zones in zonelist.  Returns zero
26296   * if a parallel OOM killing is already taking place that includes a zone in
26297 @@ -744,7 +768,12 @@ retry:
26298         if (!p) {
26299                 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
26300                 read_unlock(&tasklist_lock);
26301 -               panic("Out of memory and no killable processes...\n");
26302 +
26303 +               /* avoid panic for guest OOM */
26304 +               if (current->xid)
26305 +                       vs_oom_action(LINUX_REBOOT_CMD_OOM);
26306 +               else
26307 +                       panic("Out of memory and no killable processes...\n");
26308         }
26309  
26310         if (oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
26311 diff -NurpP --minimal linux-3.0.4/mm/page_alloc.c linux-3.0.4-vs2.3.1/mm/page_alloc.c
26312 --- linux-3.0.4/mm/page_alloc.c 2011-07-22 11:18:12.000000000 +0200
26313 +++ linux-3.0.4-vs2.3.1/mm/page_alloc.c 2011-06-10 22:24:12.000000000 +0200
26314 @@ -57,6 +57,8 @@
26315  #include <linux/ftrace_event.h>
26316  #include <linux/memcontrol.h>
26317  #include <linux/prefetch.h>
26318 +#include <linux/vs_base.h>
26319 +#include <linux/vs_limit.h>
26320  
26321  #include <asm/tlbflush.h>
26322  #include <asm/div64.h>
26323 @@ -2470,6 +2472,9 @@ void si_meminfo(struct sysinfo *val)
26324         val->totalhigh = totalhigh_pages;
26325         val->freehigh = nr_free_highpages();
26326         val->mem_unit = PAGE_SIZE;
26327 +
26328 +       if (vx_flags(VXF_VIRT_MEM, 0))
26329 +               vx_vsi_meminfo(val);
26330  }
26331  
26332  EXPORT_SYMBOL(si_meminfo);
26333 @@ -2490,6 +2495,9 @@ void si_meminfo_node(struct sysinfo *val
26334         val->freehigh = 0;
26335  #endif
26336         val->mem_unit = PAGE_SIZE;
26337 +
26338 +       if (vx_flags(VXF_VIRT_MEM, 0))
26339 +               vx_vsi_meminfo(val);
26340  }
26341  #endif
26342  
26343 diff -NurpP --minimal linux-3.0.4/mm/pgtable-generic.c linux-3.0.4-vs2.3.1/mm/pgtable-generic.c
26344 --- linux-3.0.4/mm/pgtable-generic.c    2011-03-15 18:07:42.000000000 +0100
26345 +++ linux-3.0.4-vs2.3.1/mm/pgtable-generic.c    2011-06-10 22:11:24.000000000 +0200
26346 @@ -6,6 +6,8 @@
26347   *  Copyright (C) 2010  Linus Torvalds
26348   */
26349  
26350 +#include <linux/mm.h>
26351 +
26352  #include <linux/pagemap.h>
26353  #include <asm/tlb.h>
26354  #include <asm-generic/pgtable.h>
26355 diff -NurpP --minimal linux-3.0.4/mm/rmap.c linux-3.0.4-vs2.3.1/mm/rmap.c
26356 --- linux-3.0.4/mm/rmap.c       2011-07-22 11:18:12.000000000 +0200
26357 +++ linux-3.0.4-vs2.3.1/mm/rmap.c       2011-07-01 11:35:35.000000000 +0200
26358 @@ -57,6 +57,7 @@
26359  #include <linux/mmu_notifier.h>
26360  #include <linux/migrate.h>
26361  #include <linux/hugetlb.h>
26362 +#include <linux/vs_memory.h>
26363  
26364  #include <asm/tlbflush.h>
26365  
26366 diff -NurpP --minimal linux-3.0.4/mm/shmem.c linux-3.0.4-vs2.3.1/mm/shmem.c
26367 --- linux-3.0.4/mm/shmem.c      2011-07-22 11:18:12.000000000 +0200
26368 +++ linux-3.0.4-vs2.3.1/mm/shmem.c      2011-07-01 11:35:35.000000000 +0200
26369 @@ -1850,7 +1850,7 @@ static int shmem_statfs(struct dentry *d
26370  {
26371         struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
26372  
26373 -       buf->f_type = TMPFS_MAGIC;
26374 +       buf->f_type = TMPFS_SUPER_MAGIC;
26375         buf->f_bsize = PAGE_CACHE_SIZE;
26376         buf->f_namelen = NAME_MAX;
26377         if (sbinfo->max_blocks) {
26378 @@ -2605,7 +2605,7 @@ int shmem_fill_super(struct super_block 
26379         sb->s_maxbytes = SHMEM_MAX_BYTES;
26380         sb->s_blocksize = PAGE_CACHE_SIZE;
26381         sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
26382 -       sb->s_magic = TMPFS_MAGIC;
26383 +       sb->s_magic = TMPFS_SUPER_MAGIC;
26384         sb->s_op = &shmem_ops;
26385         sb->s_time_gran = 1;
26386  #ifdef CONFIG_TMPFS_XATTR
26387 diff -NurpP --minimal linux-3.0.4/mm/slab.c linux-3.0.4-vs2.3.1/mm/slab.c
26388 --- linux-3.0.4/mm/slab.c       2011-07-22 11:18:12.000000000 +0200
26389 +++ linux-3.0.4-vs2.3.1/mm/slab.c       2011-06-15 02:41:23.000000000 +0200
26390 @@ -411,6 +411,8 @@ static void kmem_list3_init(struct kmem_
26391  #define STATS_INC_FREEMISS(x)  do { } while (0)
26392  #endif
26393  
26394 +#include "slab_vs.h"
26395 +
26396  #if DEBUG
26397  
26398  /*
26399 @@ -3348,6 +3350,7 @@ retry:
26400  
26401         obj = slab_get_obj(cachep, slabp, nodeid);
26402         check_slabp(cachep, slabp);
26403 +       vx_slab_alloc(cachep, flags);
26404         l3->free_objects--;
26405         /* move slabp to correct slabp list: */
26406         list_del(&slabp->list);
26407 @@ -3425,6 +3428,7 @@ __cache_alloc_node(struct kmem_cache *ca
26408         /* ___cache_alloc_node can fall back to other nodes */
26409         ptr = ____cache_alloc_node(cachep, flags, nodeid);
26410    out:
26411 +       vx_slab_alloc(cachep, flags);
26412         local_irq_restore(save_flags);
26413         ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
26414         kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
26415 @@ -3612,6 +3616,7 @@ static inline void __cache_free(struct k
26416         check_irq_off();
26417         kmemleak_free_recursive(objp, cachep->flags);
26418         objp = cache_free_debugcheck(cachep, objp, caller);
26419 +       vx_slab_free(cachep);
26420  
26421         kmemcheck_slab_free(cachep, objp, obj_size(cachep));
26422  
26423 diff -NurpP --minimal linux-3.0.4/mm/slab_vs.h linux-3.0.4-vs2.3.1/mm/slab_vs.h
26424 --- linux-3.0.4/mm/slab_vs.h    1970-01-01 01:00:00.000000000 +0100
26425 +++ linux-3.0.4-vs2.3.1/mm/slab_vs.h    2011-06-10 22:11:24.000000000 +0200
26426 @@ -0,0 +1,29 @@
26427 +
26428 +#include <linux/vserver/context.h>
26429 +
26430 +#include <linux/vs_context.h>
26431 +
26432 +static inline
26433 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
26434 +{
26435 +       int what = gfp_zone(cachep->gfpflags);
26436 +       struct vx_info *vxi = current_vx_info();
26437 +
26438 +       if (!vxi)
26439 +               return;
26440 +
26441 +       atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
26442 +}
26443 +
26444 +static inline
26445 +void vx_slab_free(struct kmem_cache *cachep)
26446 +{
26447 +       int what = gfp_zone(cachep->gfpflags);
26448 +       struct vx_info *vxi = current_vx_info();
26449 +
26450 +       if (!vxi)
26451 +               return;
26452 +
26453 +       atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
26454 +}
26455 +
26456 diff -NurpP --minimal linux-3.0.4/mm/swapfile.c linux-3.0.4-vs2.3.1/mm/swapfile.c
26457 --- linux-3.0.4/mm/swapfile.c   2011-07-22 11:18:12.000000000 +0200
26458 +++ linux-3.0.4-vs2.3.1/mm/swapfile.c   2011-07-01 11:35:35.000000000 +0200
26459 @@ -37,6 +37,8 @@
26460  #include <asm/tlbflush.h>
26461  #include <linux/swapops.h>
26462  #include <linux/page_cgroup.h>
26463 +#include <linux/vs_base.h>
26464 +#include <linux/vs_memory.h>
26465  
26466  static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
26467                                  unsigned char);
26468 @@ -1759,6 +1761,16 @@ static int swap_show(struct seq_file *sw
26469  
26470         if (si == SEQ_START_TOKEN) {
26471                 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
26472 +               if (vx_flags(VXF_VIRT_MEM, 0)) {
26473 +                       struct sysinfo si;
26474 +
26475 +                       vx_vsi_swapinfo(&si);
26476 +                       if (si.totalswap < (1 << 10))
26477 +                               return 0;
26478 +                       seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
26479 +                               "hdv0", "partition", si.totalswap >> 10,
26480 +                               (si.totalswap - si.freeswap) >> 10, -1);
26481 +               }
26482                 return 0;
26483         }
26484  
26485 @@ -2186,6 +2198,8 @@ void si_swapinfo(struct sysinfo *val)
26486         val->freeswap = nr_swap_pages + nr_to_be_unused;
26487         val->totalswap = total_swap_pages + nr_to_be_unused;
26488         spin_unlock(&swap_lock);
26489 +       if (vx_flags(VXF_VIRT_MEM, 0))
26490 +               vx_vsi_swapinfo(val);
26491  }
26492  
26493  /*
26494 diff -NurpP --minimal linux-3.0.4/net/bridge/br_multicast.c linux-3.0.4-vs2.3.1/net/bridge/br_multicast.c
26495 --- linux-3.0.4/net/bridge/br_multicast.c       2011-07-22 11:18:12.000000000 +0200
26496 +++ linux-3.0.4-vs2.3.1/net/bridge/br_multicast.c       2011-07-19 00:44:39.000000000 +0200
26497 @@ -447,7 +447,7 @@ static struct sk_buff *br_ip6_multicast_
26498         ip6h->hop_limit = 1;
26499         ipv6_addr_set(&ip6h->daddr, htonl(0xff020000), 0, 0, htonl(1));
26500         ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0,
26501 -                          &ip6h->saddr);
26502 +                          &ip6h->saddr, NULL);
26503         ipv6_eth_mc_map(&ip6h->daddr, eth->h_dest);
26504  
26505         hopopt = (u8 *)(ip6h + 1);
26506 diff -NurpP --minimal linux-3.0.4/net/core/dev.c linux-3.0.4-vs2.3.1/net/core/dev.c
26507 --- linux-3.0.4/net/core/dev.c  2011-07-22 11:18:13.000000000 +0200
26508 +++ linux-3.0.4-vs2.3.1/net/core/dev.c  2011-09-17 19:20:44.000000000 +0200
26509 @@ -127,6 +127,7 @@
26510  #include <linux/in.h>
26511  #include <linux/jhash.h>
26512  #include <linux/random.h>
26513 +#include <linux/vs_inet.h>
26514  #include <trace/events/napi.h>
26515  #include <trace/events/net.h>
26516  #include <trace/events/skb.h>
26517 @@ -609,7 +610,8 @@ struct net_device *__dev_get_by_name(str
26518         struct hlist_head *head = dev_name_hash(net, name);
26519  
26520         hlist_for_each_entry(dev, p, head, name_hlist)
26521 -               if (!strncmp(dev->name, name, IFNAMSIZ))
26522 +               if (!strncmp(dev->name, name, IFNAMSIZ) &&
26523 +                   nx_dev_visible(current_nx_info(), dev))
26524                         return dev;
26525  
26526         return NULL;
26527 @@ -635,7 +637,8 @@ struct net_device *dev_get_by_name_rcu(s
26528         struct hlist_head *head = dev_name_hash(net, name);
26529  
26530         hlist_for_each_entry_rcu(dev, p, head, name_hlist)
26531 -               if (!strncmp(dev->name, name, IFNAMSIZ))
26532 +               if (!strncmp(dev->name, name, IFNAMSIZ) &&
26533 +                   nx_dev_visible(current_nx_info(), dev))
26534                         return dev;
26535  
26536         return NULL;
26537 @@ -686,7 +689,8 @@ struct net_device *__dev_get_by_index(st
26538         struct hlist_head *head = dev_index_hash(net, ifindex);
26539  
26540         hlist_for_each_entry(dev, p, head, index_hlist)
26541 -               if (dev->ifindex == ifindex)
26542 +               if ((dev->ifindex == ifindex) &&
26543 +                   nx_dev_visible(current_nx_info(), dev))
26544                         return dev;
26545  
26546         return NULL;
26547 @@ -704,7 +708,7 @@ EXPORT_SYMBOL(__dev_get_by_index);
26548   *     about locking. The caller must hold RCU lock.
26549   */
26550  
26551 -struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
26552 +struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex)
26553  {
26554         struct hlist_node *p;
26555         struct net_device *dev;
26556 @@ -716,6 +720,16 @@ struct net_device *dev_get_by_index_rcu(
26557  
26558         return NULL;
26559  }
26560 +EXPORT_SYMBOL(dev_get_by_index_real_rcu);
26561 +
26562 +struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
26563 +{
26564 +       struct net_device *dev = dev_get_by_index_real_rcu(net, ifindex);
26565 +
26566 +       if (nx_dev_visible(current_nx_info(), dev))
26567 +               return dev;
26568 +       return NULL;
26569 +}
26570  EXPORT_SYMBOL(dev_get_by_index_rcu);
26571  
26572  
26573 @@ -764,7 +778,8 @@ struct net_device *dev_getbyhwaddr_rcu(s
26574  
26575         for_each_netdev_rcu(net, dev)
26576                 if (dev->type == type &&
26577 -                   !memcmp(dev->dev_addr, ha, dev->addr_len))
26578 +                   !memcmp(dev->dev_addr, ha, dev->addr_len) &&
26579 +                   nx_dev_visible(current_nx_info(), dev))
26580                         return dev;
26581  
26582         return NULL;
26583 @@ -776,9 +791,11 @@ struct net_device *__dev_getfirstbyhwtyp
26584         struct net_device *dev;
26585  
26586         ASSERT_RTNL();
26587 -       for_each_netdev(net, dev)
26588 -               if (dev->type == type)
26589 +       for_each_netdev(net, dev) {
26590 +               if ((dev->type == type) &&
26591 +                   nx_dev_visible(current_nx_info(), dev))
26592                         return dev;
26593 +       }
26594  
26595         return NULL;
26596  }
26597 @@ -896,6 +913,8 @@ static int __dev_alloc_name(struct net *
26598                                 continue;
26599                         if (i < 0 || i >= max_netdevices)
26600                                 continue;
26601 +                       if (!nx_dev_visible(current_nx_info(), d))
26602 +                               continue;
26603  
26604                         /*  avoid cases where sscanf is not exact inverse of printf */
26605                         snprintf(buf, IFNAMSIZ, name, i);
26606 @@ -3937,6 +3956,8 @@ static int dev_ifconf(struct net *net, c
26607  
26608         total = 0;
26609         for_each_netdev(net, dev) {
26610 +               if (!nx_dev_visible(current_nx_info(), dev))
26611 +                       continue;
26612                 for (i = 0; i < NPROTO; i++) {
26613                         if (gifconf_list[i]) {
26614                                 int done;
26615 @@ -4011,6 +4032,10 @@ static void dev_seq_printf_stats(struct 
26616         struct rtnl_link_stats64 temp;
26617         const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
26618  
26619 +       /* device visible inside network context? */
26620 +       if (!nx_dev_visible(current_nx_info(), dev))
26621 +               return;
26622 +
26623         seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
26624                    "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
26625                    dev->name, stats->rx_bytes, stats->rx_packets,
26626 diff -NurpP --minimal linux-3.0.4/net/core/rtnetlink.c linux-3.0.4-vs2.3.1/net/core/rtnetlink.c
26627 --- linux-3.0.4/net/core/rtnetlink.c    2011-07-22 11:18:13.000000000 +0200
26628 +++ linux-3.0.4-vs2.3.1/net/core/rtnetlink.c    2011-06-10 22:11:24.000000000 +0200
26629 @@ -1015,6 +1015,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
26630                 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
26631                         if (idx < s_idx)
26632                                 goto cont;
26633 +                       if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
26634 +                               continue;
26635                         if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
26636                                              NETLINK_CB(cb->skb).pid,
26637                                              cb->nlh->nlmsg_seq, 0,
26638 @@ -1848,6 +1850,9 @@ void rtmsg_ifinfo(int type, struct net_d
26639         struct sk_buff *skb;
26640         int err = -ENOBUFS;
26641  
26642 +       if (!nx_dev_visible(current_nx_info(), dev))
26643 +               return;
26644 +
26645         skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
26646         if (skb == NULL)
26647                 goto errout;
26648 diff -NurpP --minimal linux-3.0.4/net/core/sock.c linux-3.0.4-vs2.3.1/net/core/sock.c
26649 --- linux-3.0.4/net/core/sock.c 2011-05-22 16:18:00.000000000 +0200
26650 +++ linux-3.0.4-vs2.3.1/net/core/sock.c 2011-06-10 22:11:24.000000000 +0200
26651 @@ -127,6 +127,10 @@
26652  #include <net/cls_cgroup.h>
26653  
26654  #include <linux/filter.h>
26655 +#include <linux/vs_socket.h>
26656 +#include <linux/vs_limit.h>
26657 +#include <linux/vs_context.h>
26658 +#include <linux/vs_network.h>
26659  
26660  #ifdef CONFIG_INET
26661  #include <net/tcp.h>
26662 @@ -1070,6 +1074,8 @@ static struct sock *sk_prot_alloc(struct
26663                         goto out_free_sec;
26664                 sk_tx_queue_clear(sk);
26665         }
26666 +               sock_vx_init(sk);
26667 +               sock_nx_init(sk);
26668  
26669         return sk;
26670  
26671 @@ -1169,6 +1175,11 @@ static void __sk_free(struct sock *sk)
26672                 put_cred(sk->sk_peer_cred);
26673         put_pid(sk->sk_peer_pid);
26674         put_net(sock_net(sk));
26675 +       vx_sock_dec(sk);
26676 +       clr_vx_info(&sk->sk_vx_info);
26677 +       sk->sk_xid = -1;
26678 +       clr_nx_info(&sk->sk_nx_info);
26679 +       sk->sk_nid = -1;
26680         sk_prot_free(sk->sk_prot_creator, sk);
26681  }
26682  
26683 @@ -1216,6 +1227,8 @@ struct sock *sk_clone(const struct sock 
26684  
26685                 /* SANITY */
26686                 get_net(sock_net(newsk));
26687 +               sock_vx_init(newsk);
26688 +               sock_nx_init(newsk);
26689                 sk_node_init(&newsk->sk_node);
26690                 sock_lock_init(newsk);
26691                 bh_lock_sock(newsk);
26692 @@ -1271,6 +1284,12 @@ struct sock *sk_clone(const struct sock 
26693                 smp_wmb();
26694                 atomic_set(&newsk->sk_refcnt, 2);
26695  
26696 +               set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
26697 +               newsk->sk_xid = sk->sk_xid;
26698 +               vx_sock_inc(newsk);
26699 +               set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
26700 +               newsk->sk_nid = sk->sk_nid;
26701 +
26702                 /*
26703                  * Increment the counter in the same struct proto as the master
26704                  * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
26705 @@ -2017,6 +2036,12 @@ void sock_init_data(struct socket *sock,
26706  
26707         sk->sk_stamp = ktime_set(-1L, 0);
26708  
26709 +       set_vx_info(&sk->sk_vx_info, current_vx_info());
26710 +       sk->sk_xid = vx_current_xid();
26711 +       vx_sock_inc(sk);
26712 +       set_nx_info(&sk->sk_nx_info, current_nx_info());
26713 +       sk->sk_nid = nx_current_nid();
26714 +
26715         /*
26716          * Before updating sk_refcnt, we must commit prior changes to memory
26717          * (Documentation/RCU/rculist_nulls.txt for details)
26718 diff -NurpP --minimal linux-3.0.4/net/ipv4/af_inet.c linux-3.0.4-vs2.3.1/net/ipv4/af_inet.c
26719 --- linux-3.0.4/net/ipv4/af_inet.c      2011-07-22 11:18:13.000000000 +0200
26720 +++ linux-3.0.4-vs2.3.1/net/ipv4/af_inet.c      2011-07-19 00:44:39.000000000 +0200
26721 @@ -117,6 +117,7 @@
26722  #ifdef CONFIG_IP_MROUTE
26723  #include <linux/mroute.h>
26724  #endif
26725 +#include <linux/vs_limit.h>
26726  
26727  
26728  /* The inetsw table contains everything that inet_create needs to
26729 @@ -326,9 +327,13 @@ lookup_protocol:
26730         }
26731  
26732         err = -EPERM;
26733 +       if ((protocol == IPPROTO_ICMP) &&
26734 +               nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
26735 +               goto override;
26736 +
26737         if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
26738                 goto out_rcu_unlock;
26739 -
26740 +override:
26741         err = -EAFNOSUPPORT;
26742         if (!inet_netns_ok(net, protocol))
26743                 goto out_rcu_unlock;
26744 @@ -452,6 +457,7 @@ int inet_bind(struct socket *sock, struc
26745         struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
26746         struct sock *sk = sock->sk;
26747         struct inet_sock *inet = inet_sk(sk);
26748 +       struct nx_v4_sock_addr nsa;
26749         unsigned short snum;
26750         int chk_addr_ret;
26751         int err;
26752 @@ -470,7 +476,11 @@ int inet_bind(struct socket *sock, struc
26753                 goto out;
26754         }
26755  
26756 -       chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
26757 +       err = v4_map_sock_addr(inet, addr, &nsa);
26758 +       if (err)
26759 +               goto out;
26760 +
26761 +       chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
26762  
26763         /* Not specified by any standard per-se, however it breaks too
26764          * many applications when removed.  It is unfortunate since
26765 @@ -482,7 +492,7 @@ int inet_bind(struct socket *sock, struc
26766         err = -EADDRNOTAVAIL;
26767         if (!sysctl_ip_nonlocal_bind &&
26768             !(inet->freebind || inet->transparent) &&
26769 -           addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
26770 +           nsa.saddr != htonl(INADDR_ANY) &&
26771             chk_addr_ret != RTN_LOCAL &&
26772             chk_addr_ret != RTN_MULTICAST &&
26773             chk_addr_ret != RTN_BROADCAST)
26774 @@ -507,7 +517,7 @@ int inet_bind(struct socket *sock, struc
26775         if (sk->sk_state != TCP_CLOSE || inet->inet_num)
26776                 goto out_release_sock;
26777  
26778 -       inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
26779 +       v4_set_sock_addr(inet, &nsa);
26780         if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
26781                 inet->inet_saddr = 0;  /* Use device */
26782  
26783 @@ -710,11 +720,13 @@ int inet_getname(struct socket *sock, st
26784                      peer == 1))
26785                         return -ENOTCONN;
26786                 sin->sin_port = inet->inet_dport;
26787 -               sin->sin_addr.s_addr = inet->inet_daddr;
26788 +               sin->sin_addr.s_addr =
26789 +                       nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
26790         } else {
26791                 __be32 addr = inet->inet_rcv_saddr;
26792                 if (!addr)
26793                         addr = inet->inet_saddr;
26794 +               addr = nx_map_sock_lback(sk->sk_nx_info, addr);
26795                 sin->sin_port = inet->inet_sport;
26796                 sin->sin_addr.s_addr = addr;
26797         }
26798 diff -NurpP --minimal linux-3.0.4/net/ipv4/arp.c linux-3.0.4-vs2.3.1/net/ipv4/arp.c
26799 --- linux-3.0.4/net/ipv4/arp.c  2011-05-22 16:18:00.000000000 +0200
26800 +++ linux-3.0.4-vs2.3.1/net/ipv4/arp.c  2011-08-29 05:14:51.000000000 +0200
26801 @@ -1365,6 +1365,7 @@ static void arp_format_neigh_entry(struc
26802         struct net_device *dev = n->dev;
26803         int hatype = dev->type;
26804  
26805 +       /* FIXME: check for network context */
26806         read_lock(&n->lock);
26807         /* Convert hardware address to XX:XX:XX:XX ... form. */
26808  #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
26809 @@ -1396,6 +1397,7 @@ static void arp_format_pneigh_entry(stru
26810         int hatype = dev ? dev->type : 0;
26811         char tbuf[16];
26812  
26813 +       /* FIXME: check for network context */
26814         sprintf(tbuf, "%pI4", n->key);
26815         seq_printf(seq, "%-16s 0x%-10x0x%-10x%s     *        %s\n",
26816                    tbuf, hatype, ATF_PUBL | ATF_PERM, "00:00:00:00:00:00",
26817 diff -NurpP --minimal linux-3.0.4/net/ipv4/devinet.c linux-3.0.4-vs2.3.1/net/ipv4/devinet.c
26818 --- linux-3.0.4/net/ipv4/devinet.c      2011-08-31 18:56:42.000000000 +0200
26819 +++ linux-3.0.4-vs2.3.1/net/ipv4/devinet.c      2011-08-29 03:45:09.000000000 +0200
26820 @@ -518,6 +518,7 @@ struct in_device *inetdev_by_index(struc
26821  }
26822  EXPORT_SYMBOL(inetdev_by_index);
26823  
26824 +
26825  /* Called only from RTNL semaphored context. No locks. */
26826  
26827  struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
26828 @@ -759,6 +760,8 @@ int devinet_ioctl(struct net *net, unsig
26829  
26830         in_dev = __in_dev_get_rtnl(dev);
26831         if (in_dev) {
26832 +               struct nx_info *nxi = current_nx_info();
26833 +
26834                 if (tryaddrmatch) {
26835                         /* Matthias Andree */
26836                         /* compare label and address (4.4BSD style) */
26837 @@ -767,6 +770,8 @@ int devinet_ioctl(struct net *net, unsig
26838                            This is checked above. */
26839                         for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26840                              ifap = &ifa->ifa_next) {
26841 +                               if (!nx_v4_ifa_visible(nxi, ifa))
26842 +                                       continue;
26843                                 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
26844                                     sin_orig.sin_addr.s_addr ==
26845                                                         ifa->ifa_local) {
26846 @@ -779,9 +784,12 @@ int devinet_ioctl(struct net *net, unsig
26847                    comparing just the label */
26848                 if (!ifa) {
26849                         for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26850 -                            ifap = &ifa->ifa_next)
26851 +                            ifap = &ifa->ifa_next) {
26852 +                               if (!nx_v4_ifa_visible(nxi, ifa))
26853 +                                       continue;
26854                                 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
26855                                         break;
26856 +                       }
26857                 }
26858         }
26859  
26860 @@ -934,6 +942,8 @@ static int inet_gifconf(struct net_devic
26861                 goto out;
26862  
26863         for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
26864 +               if (!nx_v4_ifa_visible(current_nx_info(), ifa))
26865 +                       continue;
26866                 if (!buf) {
26867                         done += sizeof(ifr);
26868                         continue;
26869 @@ -1294,6 +1304,7 @@ static int inet_dump_ifaddr(struct sk_bu
26870         struct net_device *dev;
26871         struct in_device *in_dev;
26872         struct in_ifaddr *ifa;
26873 +       struct sock *sk = skb->sk;
26874         struct hlist_head *head;
26875         struct hlist_node *node;
26876  
26877 @@ -1316,6 +1327,8 @@ static int inet_dump_ifaddr(struct sk_bu
26878  
26879                         for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
26880                              ifa = ifa->ifa_next, ip_idx++) {
26881 +                       if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
26882 +                               continue;
26883                                 if (ip_idx < s_ip_idx)
26884                                         continue;
26885                                 if (inet_fill_ifaddr(skb, ifa,
26886 diff -NurpP --minimal linux-3.0.4/net/ipv4/fib_trie.c linux-3.0.4-vs2.3.1/net/ipv4/fib_trie.c
26887 --- linux-3.0.4/net/ipv4/fib_trie.c     2011-07-22 11:18:13.000000000 +0200
26888 +++ linux-3.0.4-vs2.3.1/net/ipv4/fib_trie.c     2011-08-29 04:56:47.000000000 +0200
26889 @@ -2554,6 +2554,7 @@ static int fib_route_seq_show(struct seq
26890                             || fa->fa_type == RTN_MULTICAST)
26891                                 continue;
26892  
26893 +                       /* FIXME: check for network context? */
26894                         if (fi)
26895                                 seq_printf(seq,
26896                                          "%s\t%08X\t%08X\t%04X\t%d\t%u\t"
26897 diff -NurpP --minimal linux-3.0.4/net/ipv4/inet_connection_sock.c linux-3.0.4-vs2.3.1/net/ipv4/inet_connection_sock.c
26898 --- linux-3.0.4/net/ipv4/inet_connection_sock.c 2011-07-22 11:18:13.000000000 +0200
26899 +++ linux-3.0.4-vs2.3.1/net/ipv4/inet_connection_sock.c 2011-06-10 22:11:24.000000000 +0200
26900 @@ -52,6 +52,37 @@ void inet_get_local_port_range(int *low,
26901  }
26902  EXPORT_SYMBOL(inet_get_local_port_range);
26903  
26904 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
26905 +{
26906 +       __be32  sk1_rcv_saddr = sk_rcv_saddr(sk1),
26907 +               sk2_rcv_saddr = sk_rcv_saddr(sk2);
26908 +
26909 +       if (inet_v6_ipv6only(sk2))
26910 +               return 0;
26911 +
26912 +       if (sk1_rcv_saddr &&
26913 +           sk2_rcv_saddr &&
26914 +           sk1_rcv_saddr == sk2_rcv_saddr)
26915 +               return 1;
26916 +
26917 +       if (sk1_rcv_saddr &&
26918 +           !sk2_rcv_saddr &&
26919 +           v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
26920 +               return 1;
26921 +
26922 +       if (sk2_rcv_saddr &&
26923 +           !sk1_rcv_saddr &&
26924 +           v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
26925 +               return 1;
26926 +
26927 +       if (!sk1_rcv_saddr &&
26928 +           !sk2_rcv_saddr &&
26929 +           nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
26930 +               return 1;
26931 +
26932 +       return 0;
26933 +}
26934 +
26935  int inet_csk_bind_conflict(const struct sock *sk,
26936                            const struct inet_bind_bucket *tb)
26937  {
26938 @@ -74,9 +105,7 @@ int inet_csk_bind_conflict(const struct 
26939                      sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
26940                         if (!reuse || !sk2->sk_reuse ||
26941                             sk2->sk_state == TCP_LISTEN) {
26942 -                               const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
26943 -                               if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
26944 -                                   sk2_rcv_saddr == sk_rcv_saddr(sk))
26945 +                               if (ipv4_rcv_saddr_equal(sk, sk2))
26946                                         break;
26947                         }
26948                 }
26949 diff -NurpP --minimal linux-3.0.4/net/ipv4/inet_diag.c linux-3.0.4-vs2.3.1/net/ipv4/inet_diag.c
26950 --- linux-3.0.4/net/ipv4/inet_diag.c    2011-07-22 11:18:13.000000000 +0200
26951 +++ linux-3.0.4-vs2.3.1/net/ipv4/inet_diag.c    2011-06-22 12:39:16.000000000 +0200
26952 @@ -33,6 +33,8 @@
26953  #include <linux/stddef.h>
26954  
26955  #include <linux/inet_diag.h>
26956 +#include <linux/vs_network.h>
26957 +#include <linux/vs_inet.h>
26958  
26959  static const struct inet_diag_handler **inet_diag_table;
26960  
26961 @@ -119,8 +121,10 @@ static int inet_csk_diag_fill(struct soc
26962  
26963         r->id.idiag_sport = inet->inet_sport;
26964         r->id.idiag_dport = inet->inet_dport;
26965 -       r->id.idiag_src[0] = inet->inet_rcv_saddr;
26966 -       r->id.idiag_dst[0] = inet->inet_daddr;
26967 +       r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
26968 +               inet->inet_rcv_saddr);
26969 +       r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
26970 +               inet->inet_daddr);
26971  
26972  #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
26973         if (r->idiag_family == AF_INET6) {
26974 @@ -205,8 +209,8 @@ static int inet_twsk_diag_fill(struct in
26975         r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
26976         r->id.idiag_sport     = tw->tw_sport;
26977         r->id.idiag_dport     = tw->tw_dport;
26978 -       r->id.idiag_src[0]    = tw->tw_rcv_saddr;
26979 -       r->id.idiag_dst[0]    = tw->tw_daddr;
26980 +       r->id.idiag_src[0]    = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
26981 +       r->id.idiag_dst[0]    = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
26982         r->idiag_state        = tw->tw_substate;
26983         r->idiag_timer        = 3;
26984         r->idiag_expires      = DIV_ROUND_UP(tmo * 1000, HZ);
26985 @@ -263,6 +267,7 @@ static int inet_diag_get_exact(struct sk
26986         err = -EINVAL;
26987  
26988         if (req->idiag_family == AF_INET) {
26989 +               /* TODO: lback */
26990                 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
26991                                  req->id.idiag_dport, req->id.idiag_src[0],
26992                                  req->id.idiag_sport, req->id.idiag_if);
26993 @@ -505,6 +510,7 @@ static int inet_csk_diag_dump(struct soc
26994                 } else
26995  #endif
26996                 {
26997 +                       /* TODO: lback */
26998                         entry.saddr = &inet->inet_rcv_saddr;
26999                         entry.daddr = &inet->inet_daddr;
27000                 }
27001 @@ -543,6 +549,7 @@ static int inet_twsk_diag_dump(struct in
27002                 } else
27003  #endif
27004                 {
27005 +                       /* TODO: lback */
27006                         entry.saddr = &tw->tw_rcv_saddr;
27007                         entry.daddr = &tw->tw_daddr;
27008                 }
27009 @@ -589,8 +596,8 @@ static int inet_diag_fill_req(struct sk_
27010  
27011         r->id.idiag_sport = inet->inet_sport;
27012         r->id.idiag_dport = ireq->rmt_port;
27013 -       r->id.idiag_src[0] = ireq->loc_addr;
27014 -       r->id.idiag_dst[0] = ireq->rmt_addr;
27015 +       r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
27016 +       r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
27017         r->idiag_expires = jiffies_to_msecs(tmo);
27018         r->idiag_rqueue = 0;
27019         r->idiag_wqueue = 0;
27020 @@ -661,6 +668,7 @@ static int inet_diag_dump_reqs(struct sk
27021                                 continue;
27022  
27023                         if (bc) {
27024 +                               /* TODO: lback */
27025                                 entry.saddr =
27026  #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
27027                                         (entry.family == AF_INET6) ?
27028 @@ -731,6 +739,8 @@ static int inet_diag_dump(struct sk_buff
27029                         sk_nulls_for_each(sk, node, &ilb->head) {
27030                                 struct inet_sock *inet = inet_sk(sk);
27031  
27032 +                               if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27033 +                                       continue;
27034                                 if (num < s_num) {
27035                                         num++;
27036                                         continue;
27037 @@ -797,6 +807,8 @@ skip_listen_ht:
27038                 sk_nulls_for_each(sk, node, &head->chain) {
27039                         struct inet_sock *inet = inet_sk(sk);
27040  
27041 +                       if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27042 +                               continue;
27043                         if (num < s_num)
27044                                 goto next_normal;
27045                         if (!(r->idiag_states & (1 << sk->sk_state)))
27046 @@ -821,6 +833,8 @@ next_normal:
27047                         inet_twsk_for_each(tw, node,
27048                                     &head->twchain) {
27049  
27050 +                               if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27051 +                                       continue;
27052                                 if (num < s_num)
27053                                         goto next_dying;
27054                                 if (r->id.idiag_sport != tw->tw_sport &&
27055 diff -NurpP --minimal linux-3.0.4/net/ipv4/inet_hashtables.c linux-3.0.4-vs2.3.1/net/ipv4/inet_hashtables.c
27056 --- linux-3.0.4/net/ipv4/inet_hashtables.c      2011-08-31 18:56:42.000000000 +0200
27057 +++ linux-3.0.4-vs2.3.1/net/ipv4/inet_hashtables.c      2011-08-29 03:45:56.000000000 +0200
27058 @@ -22,6 +22,7 @@
27059  #include <net/inet_connection_sock.h>
27060  #include <net/inet_hashtables.h>
27061  #include <net/secure_seq.h>
27062 +#include <net/route.h>
27063  #include <net/ip.h>
27064  
27065  /*
27066 @@ -156,6 +157,11 @@ static inline int compute_score(struct s
27067                         if (rcv_saddr != daddr)
27068                                 return -1;
27069                         score += 2;
27070 +               } else {
27071 +                       /* block non nx_info ips */
27072 +                       if (!v4_addr_in_nx_info(sk->sk_nx_info,
27073 +                               daddr, NXA_MASK_BIND))
27074 +                               return -1;
27075                 }
27076                 if (sk->sk_bound_dev_if) {
27077                         if (sk->sk_bound_dev_if != dif)
27078 @@ -173,7 +179,6 @@ static inline int compute_score(struct s
27079   * wildcarded during the search since they can never be otherwise.
27080   */
27081  
27082 -
27083  struct sock *__inet_lookup_listener(struct net *net,
27084                                     struct inet_hashinfo *hashinfo,
27085                                     const __be32 daddr, const unsigned short hnum,
27086 @@ -196,6 +201,7 @@ begin:
27087                         hiscore = score;
27088                 }
27089         }
27090 +
27091         /*
27092          * if the nulls value we got at the end of this lookup is
27093          * not the expected one, we must restart lookup.
27094 diff -NurpP --minimal linux-3.0.4/net/ipv4/netfilter/nf_nat_helper.c linux-3.0.4-vs2.3.1/net/ipv4/netfilter/nf_nat_helper.c
27095 --- linux-3.0.4/net/ipv4/netfilter/nf_nat_helper.c      2011-07-22 11:18:13.000000000 +0200
27096 +++ linux-3.0.4-vs2.3.1/net/ipv4/netfilter/nf_nat_helper.c      2011-06-15 02:40:14.000000000 +0200
27097 @@ -20,6 +20,7 @@
27098  #include <net/route.h>
27099  
27100  #include <linux/netfilter_ipv4.h>
27101 +#include <net/route.h>
27102  #include <net/netfilter/nf_conntrack.h>
27103  #include <net/netfilter/nf_conntrack_helper.h>
27104  #include <net/netfilter/nf_conntrack_ecache.h>
27105 diff -NurpP --minimal linux-3.0.4/net/ipv4/netfilter.c linux-3.0.4-vs2.3.1/net/ipv4/netfilter.c
27106 --- linux-3.0.4/net/ipv4/netfilter.c    2011-07-22 11:18:13.000000000 +0200
27107 +++ linux-3.0.4-vs2.3.1/net/ipv4/netfilter.c    2011-07-19 00:44:39.000000000 +0200
27108 @@ -5,7 +5,7 @@
27109  #include <linux/ip.h>
27110  #include <linux/skbuff.h>
27111  #include <linux/gfp.h>
27112 -#include <net/route.h>
27113 +// #include <net/route.h>
27114  #include <net/xfrm.h>
27115  #include <net/ip.h>
27116  #include <net/netfilter/nf_queue.h>
27117 diff -NurpP --minimal linux-3.0.4/net/ipv4/raw.c linux-3.0.4-vs2.3.1/net/ipv4/raw.c
27118 --- linux-3.0.4/net/ipv4/raw.c  2011-07-22 11:18:13.000000000 +0200
27119 +++ linux-3.0.4-vs2.3.1/net/ipv4/raw.c  2011-07-27 20:26:04.000000000 +0200
27120 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
27121  
27122                 if (net_eq(sock_net(sk), net) && inet->inet_num == num  &&
27123                     !(inet->inet_daddr && inet->inet_daddr != raddr)    &&
27124 -                   !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
27125 +                   v4_sock_addr_match(sk->sk_nx_info, inet, laddr)     &&
27126                     !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
27127                         goto found; /* gotcha */
27128         }
27129 @@ -385,6 +385,12 @@ static int raw_send_hdrinc(struct sock *
27130                 icmp_out_count(net, ((struct icmphdr *)
27131                         skb_transport_header(skb))->type);
27132  
27133 +       err = -EPERM;
27134 +       if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
27135 +               sk->sk_nx_info &&
27136 +               !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
27137 +               goto error_free;
27138 +
27139         err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
27140                       rt->dst.dev, dst_output);
27141         if (err > 0)
27142 @@ -571,6 +577,16 @@ static int raw_sendmsg(struct kiocb *ioc
27143                         goto done;
27144         }
27145  
27146 +       if (sk->sk_nx_info) {
27147 +               rt = ip_v4_find_src(sock_net(sk), sk->sk_nx_info, &fl4);
27148 +               if (IS_ERR(rt)) {
27149 +                       err = PTR_ERR(rt);
27150 +                       rt = NULL;
27151 +                       goto done;
27152 +               }
27153 +               ip_rt_put(rt);
27154 +       }
27155 +
27156         security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
27157         rt = ip_route_output_flow(sock_net(sk), &fl4, sk);
27158         if (IS_ERR(rt)) {
27159 @@ -647,17 +663,19 @@ static int raw_bind(struct sock *sk, str
27160  {
27161         struct inet_sock *inet = inet_sk(sk);
27162         struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
27163 +       struct nx_v4_sock_addr nsa = { 0 };
27164         int ret = -EINVAL;
27165         int chk_addr_ret;
27166  
27167         if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
27168                 goto out;
27169 -       chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
27170 +       v4_map_sock_addr(inet, addr, &nsa);
27171 +       chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
27172         ret = -EADDRNOTAVAIL;
27173 -       if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
27174 +       if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
27175             chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
27176                 goto out;
27177 -       inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
27178 +       v4_set_sock_addr(inet, &nsa);
27179         if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
27180                 inet->inet_saddr = 0;  /* Use device */
27181         sk_dst_reset(sk);
27182 @@ -709,7 +727,8 @@ static int raw_recvmsg(struct kiocb *ioc
27183         /* Copy the address. */
27184         if (sin) {
27185                 sin->sin_family = AF_INET;
27186 -               sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27187 +               sin->sin_addr.s_addr =
27188 +                       nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
27189                 sin->sin_port = 0;
27190                 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
27191         }
27192 @@ -905,7 +924,8 @@ static struct sock *raw_get_first(struct
27193                 struct hlist_node *node;
27194  
27195                 sk_for_each(sk, node, &state->h->ht[state->bucket])
27196 -                       if (sock_net(sk) == seq_file_net(seq))
27197 +                       if ((sock_net(sk) == seq_file_net(seq)) &&
27198 +                               nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27199                                 goto found;
27200         }
27201         sk = NULL;
27202 @@ -921,7 +941,8 @@ static struct sock *raw_get_next(struct 
27203                 sk = sk_next(sk);
27204  try_again:
27205                 ;
27206 -       } while (sk && sock_net(sk) != seq_file_net(seq));
27207 +       } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
27208 +               !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27209  
27210         if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
27211                 sk = sk_head(&state->h->ht[state->bucket]);
27212 diff -NurpP --minimal linux-3.0.4/net/ipv4/route.c linux-3.0.4-vs2.3.1/net/ipv4/route.c
27213 --- linux-3.0.4/net/ipv4/route.c        2011-08-31 18:56:42.000000000 +0200
27214 +++ linux-3.0.4-vs2.3.1/net/ipv4/route.c        2011-09-17 19:23:37.000000000 +0200
27215 @@ -2525,7 +2525,7 @@ static struct rtable *ip_route_output_sl
27216  
27217  
27218         if (fl4->flowi4_oif) {
27219 -               dev_out = dev_get_by_index_rcu(net, fl4->flowi4_oif);
27220 +               dev_out = dev_get_by_index_real_rcu(net, fl4->flowi4_oif);
27221                 rth = ERR_PTR(-ENODEV);
27222                 if (dev_out == NULL)
27223                         goto out;
27224 diff -NurpP --minimal linux-3.0.4/net/ipv4/tcp.c linux-3.0.4-vs2.3.1/net/ipv4/tcp.c
27225 --- linux-3.0.4/net/ipv4/tcp.c  2011-07-22 11:18:13.000000000 +0200
27226 +++ linux-3.0.4-vs2.3.1/net/ipv4/tcp.c  2011-07-19 00:44:39.000000000 +0200
27227 @@ -266,6 +266,7 @@
27228  #include <linux/crypto.h>
27229  #include <linux/time.h>
27230  #include <linux/slab.h>
27231 +#include <linux/in.h>
27232  
27233  #include <net/icmp.h>
27234  #include <net/tcp.h>
27235 diff -NurpP --minimal linux-3.0.4/net/ipv4/tcp_ipv4.c linux-3.0.4-vs2.3.1/net/ipv4/tcp_ipv4.c
27236 --- linux-3.0.4/net/ipv4/tcp_ipv4.c     2011-08-31 18:56:42.000000000 +0200
27237 +++ linux-3.0.4-vs2.3.1/net/ipv4/tcp_ipv4.c     2011-09-29 16:44:29.000000000 +0200
27238 @@ -2003,6 +2003,12 @@ static void *listening_get_next(struct s
27239                 req = req->dl_next;
27240                 while (1) {
27241                         while (req) {
27242 +                               vxdprintk(VXD_CBIT(net, 6),
27243 +                                       "sk,req: %p [#%d] (from %d)", req->sk,
27244 +                                       (req->sk)?req->sk->sk_nid:0, nx_current_nid());
27245 +                               if (req->sk &&
27246 +                                       !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
27247 +                                       continue;
27248                                 if (req->rsk_ops->family == st->family) {
27249                                         cur = req;
27250                                         goto out;
27251 @@ -2027,6 +2033,10 @@ get_req:
27252         }
27253  get_sk:
27254         sk_nulls_for_each_from(sk, node) {
27255 +               vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
27256 +                       sk, sk->sk_nid, nx_current_nid());
27257 +               if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27258 +                       continue;
27259                 if (!net_eq(sock_net(sk), net))
27260                         continue;
27261                 if (sk->sk_family == st->family) {
27262 @@ -2103,6 +2113,11 @@ static void *established_get_first(struc
27263  
27264                 spin_lock_bh(lock);
27265                 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
27266 +                       vxdprintk(VXD_CBIT(net, 6),
27267 +                               "sk,egf: %p [#%d] (from %d)",
27268 +                               sk, sk->sk_nid, nx_current_nid());
27269 +                       if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27270 +                               continue;
27271                         if (sk->sk_family != st->family ||
27272                             !net_eq(sock_net(sk), net)) {
27273                                 continue;
27274 @@ -2113,6 +2128,11 @@ static void *established_get_first(struc
27275                 st->state = TCP_SEQ_STATE_TIME_WAIT;
27276                 inet_twsk_for_each(tw, node,
27277                                    &tcp_hashinfo.ehash[st->bucket].twchain) {
27278 +                       vxdprintk(VXD_CBIT(net, 6),
27279 +                               "tw: %p [#%d] (from %d)",
27280 +                               tw, tw->tw_nid, nx_current_nid());
27281 +                       if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27282 +                               continue;
27283                         if (tw->tw_family != st->family ||
27284                             !net_eq(twsk_net(tw), net)) {
27285                                 continue;
27286 @@ -2142,7 +2162,9 @@ static void *established_get_next(struct
27287                 tw = cur;
27288                 tw = tw_next(tw);
27289  get_tw:
27290 -               while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
27291 +               while (tw && (tw->tw_family != st->family ||
27292 +                       !net_eq(twsk_net(tw), net) ||
27293 +                       !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
27294                         tw = tw_next(tw);
27295                 }
27296                 if (tw) {
27297 @@ -2166,6 +2188,11 @@ get_tw:
27298                 sk = sk_nulls_next(sk);
27299  
27300         sk_nulls_for_each_from(sk, node) {
27301 +               vxdprintk(VXD_CBIT(net, 6),
27302 +                       "sk,egn: %p [#%d] (from %d)",
27303 +                       sk, sk->sk_nid, nx_current_nid());
27304 +               if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27305 +                       continue;
27306                 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
27307                         goto found;
27308         }
27309 @@ -2375,9 +2402,9 @@ static void get_openreq4(struct sock *sk
27310         seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27311                 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %pK%n",
27312                 i,
27313 -               ireq->loc_addr,
27314 +               nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
27315                 ntohs(inet_sk(sk)->inet_sport),
27316 -               ireq->rmt_addr,
27317 +               nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
27318                 ntohs(ireq->rmt_port),
27319                 TCP_SYN_RECV,
27320                 0, 0, /* could print option size, but that is af dependent. */
27321 @@ -2399,8 +2426,8 @@ static void get_tcp4_sock(struct sock *s
27322         struct tcp_sock *tp = tcp_sk(sk);
27323         const struct inet_connection_sock *icsk = inet_csk(sk);
27324         struct inet_sock *inet = inet_sk(sk);
27325 -       __be32 dest = inet->inet_daddr;
27326 -       __be32 src = inet->inet_rcv_saddr;
27327 +       __be32 dest = nx_map_sock_lback(current_nx_info(), inet->inet_daddr);
27328 +       __be32 src = nx_map_sock_lback(current_nx_info(), inet->inet_rcv_saddr);
27329         __u16 destp = ntohs(inet->inet_dport);
27330         __u16 srcp = ntohs(inet->inet_sport);
27331         int rx_queue;
27332 @@ -2457,8 +2484,8 @@ static void get_timewait4_sock(struct in
27333         if (ttd < 0)
27334                 ttd = 0;
27335  
27336 -       dest  = tw->tw_daddr;
27337 -       src   = tw->tw_rcv_saddr;
27338 +       dest  = nx_map_sock_lback(current_nx_info(), tw->tw_daddr);
27339 +       src   = nx_map_sock_lback(current_nx_info(), tw->tw_rcv_saddr);
27340         destp = ntohs(tw->tw_dport);
27341         srcp  = ntohs(tw->tw_sport);
27342  
27343 diff -NurpP --minimal linux-3.0.4/net/ipv4/tcp_minisocks.c linux-3.0.4-vs2.3.1/net/ipv4/tcp_minisocks.c
27344 --- linux-3.0.4/net/ipv4/tcp_minisocks.c        2011-03-15 18:07:45.000000000 +0100
27345 +++ linux-3.0.4-vs2.3.1/net/ipv4/tcp_minisocks.c        2011-06-10 22:11:24.000000000 +0200
27346 @@ -23,6 +23,9 @@
27347  #include <linux/slab.h>
27348  #include <linux/sysctl.h>
27349  #include <linux/workqueue.h>
27350 +#include <linux/vs_limit.h>
27351 +#include <linux/vs_socket.h>
27352 +#include <linux/vs_context.h>
27353  #include <net/tcp.h>
27354  #include <net/inet_common.h>
27355  #include <net/xfrm.h>
27356 @@ -335,6 +338,11 @@ void tcp_time_wait(struct sock *sk, int 
27357                 tcptw->tw_ts_recent     = tp->rx_opt.ts_recent;
27358                 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
27359  
27360 +               tw->tw_xid              = sk->sk_xid;
27361 +               tw->tw_vx_info          = NULL;
27362 +               tw->tw_nid              = sk->sk_nid;
27363 +               tw->tw_nx_info          = NULL;
27364 +
27365  #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
27366                 if (tw->tw_family == PF_INET6) {
27367                         struct ipv6_pinfo *np = inet6_sk(sk);
27368 diff -NurpP --minimal linux-3.0.4/net/ipv4/udp.c linux-3.0.4-vs2.3.1/net/ipv4/udp.c
27369 --- linux-3.0.4/net/ipv4/udp.c  2011-07-22 11:18:13.000000000 +0200
27370 +++ linux-3.0.4-vs2.3.1/net/ipv4/udp.c  2011-07-27 20:26:14.000000000 +0200
27371 @@ -296,14 +296,7 @@ fail:
27372  }
27373  EXPORT_SYMBOL(udp_lib_get_port);
27374  
27375 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27376 -{
27377 -       struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
27378 -
27379 -       return  (!ipv6_only_sock(sk2)  &&
27380 -                (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
27381 -                  inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
27382 -}
27383 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
27384  
27385  static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
27386                                        unsigned int port)
27387 @@ -338,6 +331,11 @@ static inline int compute_score(struct s
27388                         if (inet->inet_rcv_saddr != daddr)
27389                                 return -1;
27390                         score += 2;
27391 +               } else {
27392 +                       /* block non nx_info ips */
27393 +                       if (!v4_addr_in_nx_info(sk->sk_nx_info,
27394 +                               daddr, NXA_MASK_BIND))
27395 +                               return -1;
27396                 }
27397                 if (inet->inet_daddr) {
27398                         if (inet->inet_daddr != saddr)
27399 @@ -441,6 +439,7 @@ exact_match:
27400         return result;
27401  }
27402  
27403 +
27404  /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
27405   * harder than this. -DaveM
27406   */
27407 @@ -486,6 +485,11 @@ begin:
27408         sk_nulls_for_each_rcu(sk, node, &hslot->head) {
27409                 score = compute_score(sk, net, saddr, hnum, sport,
27410                                       daddr, dport, dif);
27411 +               /* FIXME: disabled?
27412 +               if (score == 9) {
27413 +                       result = sk;
27414 +                       break;
27415 +               } else */
27416                 if (score > badness) {
27417                         result = sk;
27418                         badness = score;
27419 @@ -499,6 +503,7 @@ begin:
27420         if (get_nulls_value(node) != slot)
27421                 goto begin;
27422  
27423 +
27424         if (result) {
27425                 if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
27426                         result = NULL;
27427 @@ -508,6 +513,7 @@ begin:
27428                         goto begin;
27429                 }
27430         }
27431 +
27432         rcu_read_unlock();
27433         return result;
27434  }
27435 @@ -550,8 +556,7 @@ static inline struct sock *udp_v4_mcast_
27436                     udp_sk(s)->udp_port_hash != hnum ||
27437                     (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
27438                     (inet->inet_dport != rmt_port && inet->inet_dport) ||
27439 -                   (inet->inet_rcv_saddr &&
27440 -                    inet->inet_rcv_saddr != loc_addr) ||
27441 +                   !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
27442                     ipv6_only_sock(s) ||
27443                     (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
27444                         continue;
27445 @@ -929,6 +934,16 @@ int udp_sendmsg(struct kiocb *iocb, stru
27446                                    inet_sk_flowi_flags(sk)|FLOWI_FLAG_CAN_SLEEP,
27447                                    faddr, saddr, dport, inet->inet_sport);
27448  
27449 +               if (sk->sk_nx_info) {
27450 +                       rt = ip_v4_find_src(net, sk->sk_nx_info, fl4);
27451 +                       if (IS_ERR(rt)) {
27452 +                               err = PTR_ERR(rt);
27453 +                               rt = NULL;
27454 +                               goto out;
27455 +                       }
27456 +                       ip_rt_put(rt);
27457 +               }
27458 +
27459                 security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
27460                 rt = ip_route_output_flow(net, fl4, sk);
27461                 if (IS_ERR(rt)) {
27462 @@ -1226,7 +1241,8 @@ try_again:
27463         if (sin) {
27464                 sin->sin_family = AF_INET;
27465                 sin->sin_port = udp_hdr(skb)->source;
27466 -               sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27467 +               sin->sin_addr.s_addr = nx_map_sock_lback(
27468 +                       skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
27469                 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
27470         }
27471         if (inet->cmsg_flags)
27472 @@ -1970,6 +1986,8 @@ static struct sock *udp_get_first(struct
27473                 sk_nulls_for_each(sk, node, &hslot->head) {
27474                         if (!net_eq(sock_net(sk), net))
27475                                 continue;
27476 +                       if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27477 +                               continue;
27478                         if (sk->sk_family == state->family)
27479                                 goto found;
27480                 }
27481 @@ -1987,7 +2005,9 @@ static struct sock *udp_get_next(struct 
27482  
27483         do {
27484                 sk = sk_nulls_next(sk);
27485 -       } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
27486 +       } while (sk && (!net_eq(sock_net(sk), net) ||
27487 +               sk->sk_family != state->family ||
27488 +               !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27489  
27490         if (!sk) {
27491                 if (state->bucket <= state->udp_table->mask)
27492 diff -NurpP --minimal linux-3.0.4/net/ipv6/Kconfig linux-3.0.4-vs2.3.1/net/ipv6/Kconfig
27493 --- linux-3.0.4/net/ipv6/Kconfig        2010-08-02 16:52:59.000000000 +0200
27494 +++ linux-3.0.4-vs2.3.1/net/ipv6/Kconfig        2011-06-10 22:11:24.000000000 +0200
27495 @@ -4,8 +4,8 @@
27496  
27497  #   IPv6 as module will cause a CRASH if you try to unload it
27498  menuconfig IPV6
27499 -       tristate "The IPv6 protocol"
27500 -       default m
27501 +       bool "The IPv6 protocol"
27502 +       default n
27503         ---help---
27504           This is complemental support for the IP version 6.
27505           You will still be able to do traditional IPv4 networking as well.
27506 diff -NurpP --minimal linux-3.0.4/net/ipv6/addrconf.c linux-3.0.4-vs2.3.1/net/ipv6/addrconf.c
27507 --- linux-3.0.4/net/ipv6/addrconf.c     2011-07-22 11:18:13.000000000 +0200
27508 +++ linux-3.0.4-vs2.3.1/net/ipv6/addrconf.c     2011-06-10 22:11:24.000000000 +0200
27509 @@ -87,6 +87,8 @@
27510  
27511  #include <linux/proc_fs.h>
27512  #include <linux/seq_file.h>
27513 +#include <linux/vs_network.h>
27514 +#include <linux/vs_inet6.h>
27515  
27516  /* Set to 3 to get tracing... */
27517  #define ACONF_DEBUG 2
27518 @@ -1108,7 +1110,7 @@ out:
27519  
27520  int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
27521                        const struct in6_addr *daddr, unsigned int prefs,
27522 -                      struct in6_addr *saddr)
27523 +                      struct in6_addr *saddr, struct nx_info *nxi)
27524  {
27525         struct ipv6_saddr_score scores[2],
27526                                 *score = &scores[0], *hiscore = &scores[1];
27527 @@ -1180,6 +1182,8 @@ int ipv6_dev_get_saddr(struct net *net, 
27528                                                dev->name);
27529                                 continue;
27530                         }
27531 +                       if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
27532 +                               continue;
27533  
27534                         score->rule = -1;
27535                         bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
27536 @@ -3048,7 +3052,10 @@ static void if6_seq_stop(struct seq_file
27537  static int if6_seq_show(struct seq_file *seq, void *v)
27538  {
27539         struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
27540 -       seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
27541 +
27542 +       if (nx_check(0, VS_ADMIN|VS_WATCH) ||
27543 +           v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
27544 +               seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
27545                    &ifp->addr,
27546                    ifp->idev->dev->ifindex,
27547                    ifp->prefix_len,
27548 @@ -3554,6 +3561,11 @@ static int in6_dump_addrs(struct inet6_d
27549         struct ifacaddr6 *ifaca;
27550         int err = 1;
27551         int ip_idx = *p_ip_idx;
27552 +       struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27553 +
27554 +       /* disable ipv6 on non v6 guests */
27555 +       if (nxi && !nx_info_has_v6(nxi))
27556 +               return skb->len;
27557  
27558         read_lock_bh(&idev->lock);
27559         switch (type) {
27560 @@ -3564,6 +3576,8 @@ static int in6_dump_addrs(struct inet6_d
27561                 list_for_each_entry(ifa, &idev->addr_list, if_list) {
27562                         if (++ip_idx < s_ip_idx)
27563                                 continue;
27564 +                               if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
27565 +                                       continue;
27566                         err = inet6_fill_ifaddr(skb, ifa,
27567                                                 NETLINK_CB(cb->skb).pid,
27568                                                 cb->nlh->nlmsg_seq,
27569 @@ -3580,6 +3594,8 @@ static int in6_dump_addrs(struct inet6_d
27570                      ifmca = ifmca->next, ip_idx++) {
27571                         if (ip_idx < s_ip_idx)
27572                                 continue;
27573 +                               if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
27574 +                                       continue;
27575                         err = inet6_fill_ifmcaddr(skb, ifmca,
27576                                                   NETLINK_CB(cb->skb).pid,
27577                                                   cb->nlh->nlmsg_seq,
27578 @@ -3595,6 +3611,8 @@ static int in6_dump_addrs(struct inet6_d
27579                      ifaca = ifaca->aca_next, ip_idx++) {
27580                         if (ip_idx < s_ip_idx)
27581                                 continue;
27582 +                               if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
27583 +                                       continue;
27584                         err = inet6_fill_ifacaddr(skb, ifaca,
27585                                                   NETLINK_CB(cb->skb).pid,
27586                                                   cb->nlh->nlmsg_seq,
27587 @@ -3980,6 +3998,11 @@ static int inet6_dump_ifinfo(struct sk_b
27588         struct inet6_dev *idev;
27589         struct hlist_head *head;
27590         struct hlist_node *node;
27591 +       struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27592 +
27593 +       /* FIXME: maybe disable ipv6 on non v6 guests?
27594 +       if (skb->sk && skb->sk->sk_vx_info)
27595 +               return skb->len; */
27596  
27597         s_h = cb->args[0];
27598         s_idx = cb->args[1];
27599 @@ -3991,6 +4014,8 @@ static int inet6_dump_ifinfo(struct sk_b
27600                 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
27601                         if (idx < s_idx)
27602                                 goto cont;
27603 +                       if (!v6_dev_in_nx_info(dev, nxi))
27604 +                               goto cont;
27605                         idev = __in6_dev_get(dev);
27606                         if (!idev)
27607                                 goto cont;
27608 diff -NurpP --minimal linux-3.0.4/net/ipv6/af_inet6.c linux-3.0.4-vs2.3.1/net/ipv6/af_inet6.c
27609 --- linux-3.0.4/net/ipv6/af_inet6.c     2011-08-31 18:56:42.000000000 +0200
27610 +++ linux-3.0.4-vs2.3.1/net/ipv6/af_inet6.c     2011-08-29 03:45:10.000000000 +0200
27611 @@ -42,6 +42,8 @@
27612  #include <linux/netdevice.h>
27613  #include <linux/icmpv6.h>
27614  #include <linux/netfilter_ipv6.h>
27615 +#include <linux/vs_inet.h>
27616 +#include <linux/vs_inet6.h>
27617  
27618  #include <net/ip.h>
27619  #include <net/ipv6.h>
27620 @@ -160,9 +162,12 @@ lookup_protocol:
27621         }
27622  
27623         err = -EPERM;
27624 +       if ((protocol == IPPROTO_ICMPV6) &&
27625 +               nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
27626 +               goto override;
27627         if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
27628                 goto out_rcu_unlock;
27629 -
27630 +override:
27631         sock->ops = answer->ops;
27632         answer_prot = answer->prot;
27633         answer_no_check = answer->no_check;
27634 @@ -261,6 +266,7 @@ int inet6_bind(struct socket *sock, stru
27635         struct inet_sock *inet = inet_sk(sk);
27636         struct ipv6_pinfo *np = inet6_sk(sk);
27637         struct net *net = sock_net(sk);
27638 +       struct nx_v6_sock_addr nsa;
27639         __be32 v4addr = 0;
27640         unsigned short snum;
27641         int addr_type = 0;
27642 @@ -276,6 +282,10 @@ int inet6_bind(struct socket *sock, stru
27643         if (addr->sin6_family != AF_INET6)
27644                 return -EAFNOSUPPORT;
27645  
27646 +       err = v6_map_sock_addr(inet, addr, &nsa);
27647 +       if (err)
27648 +               return err;
27649 +
27650         addr_type = ipv6_addr_type(&addr->sin6_addr);
27651         if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
27652                 return -EINVAL;
27653 @@ -307,6 +317,7 @@ int inet6_bind(struct socket *sock, stru
27654                 /* Reproduce AF_INET checks to make the bindings consistent */
27655                 v4addr = addr->sin6_addr.s6_addr32[3];
27656                 chk_addr_ret = inet_addr_type(net, v4addr);
27657 +
27658                 if (!sysctl_ip_nonlocal_bind &&
27659                     !(inet->freebind || inet->transparent) &&
27660                     v4addr != htonl(INADDR_ANY) &&
27661 @@ -316,6 +327,10 @@ int inet6_bind(struct socket *sock, stru
27662                         err = -EADDRNOTAVAIL;
27663                         goto out;
27664                 }
27665 +               if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
27666 +                       err = -EADDRNOTAVAIL;
27667 +                       goto out;
27668 +               }
27669         } else {
27670                 if (addr_type != IPV6_ADDR_ANY) {
27671                         struct net_device *dev = NULL;
27672 @@ -342,6 +357,11 @@ int inet6_bind(struct socket *sock, stru
27673                                 }
27674                         }
27675  
27676 +                       if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27677 +                               err = -EADDRNOTAVAIL;
27678 +                               goto out;
27679 +                       }
27680 +
27681                         /* ipv4 addr of the socket is invalid.  Only the
27682                          * unspecified and mapped address have a v4 equivalent.
27683                          */
27684 @@ -358,6 +378,9 @@ int inet6_bind(struct socket *sock, stru
27685                 }
27686         }
27687  
27688 +       /* what's that for? */
27689 +       v6_set_sock_addr(inet, &nsa);
27690 +
27691         inet->inet_rcv_saddr = v4addr;
27692         inet->inet_saddr = v4addr;
27693  
27694 @@ -459,9 +482,11 @@ int inet6_getname(struct socket *sock, s
27695                         return -ENOTCONN;
27696                 sin->sin6_port = inet->inet_dport;
27697                 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
27698 +               /* FIXME: remap lback? */
27699                 if (np->sndflow)
27700                         sin->sin6_flowinfo = np->flow_label;
27701         } else {
27702 +               /* FIXME: remap lback? */
27703                 if (ipv6_addr_any(&np->rcv_saddr))
27704                         ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
27705                 else
27706 diff -NurpP --minimal linux-3.0.4/net/ipv6/datagram.c linux-3.0.4-vs2.3.1/net/ipv6/datagram.c
27707 --- linux-3.0.4/net/ipv6/datagram.c     2011-05-22 16:18:00.000000000 +0200
27708 +++ linux-3.0.4-vs2.3.1/net/ipv6/datagram.c     2011-09-17 19:24:15.000000000 +0200
27709 @@ -639,7 +639,7 @@ int datagram_send_ctl(struct net *net,
27710  
27711                         rcu_read_lock();
27712                         if (fl6->flowi6_oif) {
27713 -                               dev = dev_get_by_index_rcu(net, fl6->flowi6_oif);
27714 +                               dev = dev_get_by_index_real_rcu(net, fl6->flowi6_oif);
27715                                 if (!dev) {
27716                                         rcu_read_unlock();
27717                                         return -ENODEV;
27718 diff -NurpP --minimal linux-3.0.4/net/ipv6/fib6_rules.c linux-3.0.4-vs2.3.1/net/ipv6/fib6_rules.c
27719 --- linux-3.0.4/net/ipv6/fib6_rules.c   2011-05-22 16:18:00.000000000 +0200
27720 +++ linux-3.0.4-vs2.3.1/net/ipv6/fib6_rules.c   2011-06-10 22:11:24.000000000 +0200
27721 @@ -90,7 +90,7 @@ static int fib6_rule_action(struct fib_r
27722                                                ip6_dst_idev(&rt->dst)->dev,
27723                                                &flp6->daddr,
27724                                                rt6_flags2srcprefs(flags),
27725 -                                              &saddr))
27726 +                                              &saddr, NULL))
27727                                 goto again;
27728                         if (!ipv6_prefix_equal(&saddr, &r->src.addr,
27729                                                r->src.plen))
27730 diff -NurpP --minimal linux-3.0.4/net/ipv6/inet6_hashtables.c linux-3.0.4-vs2.3.1/net/ipv6/inet6_hashtables.c
27731 --- linux-3.0.4/net/ipv6/inet6_hashtables.c     2011-08-31 18:56:42.000000000 +0200
27732 +++ linux-3.0.4-vs2.3.1/net/ipv6/inet6_hashtables.c     2011-08-29 03:45:10.000000000 +0200
27733 @@ -16,6 +16,7 @@
27734  
27735  #include <linux/module.h>
27736  #include <linux/random.h>
27737 +#include <linux/vs_inet6.h>
27738  
27739  #include <net/inet_connection_sock.h>
27740  #include <net/inet_hashtables.h>
27741 @@ -83,7 +84,6 @@ struct sock *__inet6_lookup_established(
27742         unsigned int slot = hash & hashinfo->ehash_mask;
27743         struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
27744  
27745 -
27746         rcu_read_lock();
27747  begin:
27748         sk_nulls_for_each_rcu(sk, node, &head->chain) {
27749 @@ -95,7 +95,7 @@ begin:
27750                                 sock_put(sk);
27751                                 goto begin;
27752                         }
27753 -               goto out;
27754 +                       goto out;
27755                 }
27756         }
27757         if (get_nulls_value(node) != slot)
27758 @@ -141,6 +141,9 @@ static inline int compute_score(struct s
27759                         if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
27760                                 return -1;
27761                         score++;
27762 +               } else {
27763 +                       if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
27764 +                               return -1;
27765                 }
27766                 if (sk->sk_bound_dev_if) {
27767                         if (sk->sk_bound_dev_if != dif)
27768 diff -NurpP --minimal linux-3.0.4/net/ipv6/ip6_output.c linux-3.0.4-vs2.3.1/net/ipv6/ip6_output.c
27769 --- linux-3.0.4/net/ipv6/ip6_output.c   2011-08-31 18:56:42.000000000 +0200
27770 +++ linux-3.0.4-vs2.3.1/net/ipv6/ip6_output.c   2011-08-29 03:45:10.000000000 +0200
27771 @@ -962,7 +962,8 @@ static int ip6_dst_lookup_tail(struct so
27772                 struct rt6_info *rt = (struct rt6_info *) *dst;
27773                 err = ip6_route_get_saddr(net, rt, &fl6->daddr,
27774                                           sk ? inet6_sk(sk)->srcprefs : 0,
27775 -                                         &fl6->saddr);
27776 +                                         &fl6->saddr,
27777 +                                         sk ? sk->sk_nx_info : NULL);
27778                 if (err)
27779                         goto out_err_release;
27780         }
27781 diff -NurpP --minimal linux-3.0.4/net/ipv6/ndisc.c linux-3.0.4-vs2.3.1/net/ipv6/ndisc.c
27782 --- linux-3.0.4/net/ipv6/ndisc.c        2011-07-22 11:18:13.000000000 +0200
27783 +++ linux-3.0.4-vs2.3.1/net/ipv6/ndisc.c        2011-06-10 22:11:24.000000000 +0200
27784 @@ -597,7 +597,7 @@ static void ndisc_send_na(struct net_dev
27785         } else {
27786                 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
27787                                        inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
27788 -                                      &tmpaddr))
27789 +                                      &tmpaddr, NULL))
27790                         return;
27791                 src_addr = &tmpaddr;
27792         }
27793 diff -NurpP --minimal linux-3.0.4/net/ipv6/raw.c linux-3.0.4-vs2.3.1/net/ipv6/raw.c
27794 --- linux-3.0.4/net/ipv6/raw.c  2011-07-22 11:18:13.000000000 +0200
27795 +++ linux-3.0.4-vs2.3.1/net/ipv6/raw.c  2011-06-10 22:11:24.000000000 +0200
27796 @@ -30,6 +30,7 @@
27797  #include <linux/icmpv6.h>
27798  #include <linux/netfilter.h>
27799  #include <linux/netfilter_ipv6.h>
27800 +#include <linux/vs_inet6.h>
27801  #include <linux/skbuff.h>
27802  #include <linux/compat.h>
27803  #include <asm/uaccess.h>
27804 @@ -284,6 +285,13 @@ static int rawv6_bind(struct sock *sk, s
27805                                 goto out_unlock;
27806                 }
27807  
27808 +               if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27809 +                       err = -EADDRNOTAVAIL;
27810 +                       if (dev)
27811 +                               dev_put(dev);
27812 +                       goto out;
27813 +               }
27814 +
27815                 /* ipv4 addr of the socket is invalid.  Only the
27816                  * unspecified and mapped address have a v4 equivalent.
27817                  */
27818 diff -NurpP --minimal linux-3.0.4/net/ipv6/route.c linux-3.0.4-vs2.3.1/net/ipv6/route.c
27819 --- linux-3.0.4/net/ipv6/route.c        2011-07-22 11:18:13.000000000 +0200
27820 +++ linux-3.0.4-vs2.3.1/net/ipv6/route.c        2011-08-29 05:05:08.000000000 +0200
27821 @@ -54,6 +54,7 @@
27822  #include <net/xfrm.h>
27823  #include <net/netevent.h>
27824  #include <net/netlink.h>
27825 +#include <linux/vs_inet6.h>
27826  
27827  #include <asm/uaccess.h>
27828  
27829 @@ -2050,15 +2051,17 @@ int ip6_route_get_saddr(struct net *net,
27830                         struct rt6_info *rt,
27831                         const struct in6_addr *daddr,
27832                         unsigned int prefs,
27833 -                       struct in6_addr *saddr)
27834 +                       struct in6_addr *saddr,
27835 +                       struct nx_info *nxi)
27836  {
27837         struct inet6_dev *idev = ip6_dst_idev((struct dst_entry*)rt);
27838         int err = 0;
27839 -       if (rt->rt6i_prefsrc.plen)
27840 +       if (rt->rt6i_prefsrc.plen && (!nxi ||
27841 +           v6_addr_in_nx_info(nxi, &rt->rt6i_prefsrc.addr, NXA_TYPE_ADDR)))
27842                 ipv6_addr_copy(saddr, &rt->rt6i_prefsrc.addr);
27843         else
27844                 err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
27845 -                                        daddr, prefs, saddr);
27846 +                                        daddr, prefs, saddr, nxi);
27847         return err;
27848  }
27849  
27850 @@ -2387,7 +2390,8 @@ static int rt6_fill_node(struct net *net
27851                         NLA_PUT_U32(skb, RTA_IIF, iif);
27852         } else if (dst) {
27853                 struct in6_addr saddr_buf;
27854 -               if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf) == 0)
27855 +               if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf,
27856 +                                       (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
27857                         NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
27858         }
27859  
27860 @@ -2586,6 +2590,7 @@ static int rt6_info_route(struct rt6_inf
27861  {
27862         struct seq_file *m = p_arg;
27863  
27864 +       /* FIXME: check for network context? */
27865         seq_printf(m, "%pi6 %02x ", &rt->rt6i_dst.addr, rt->rt6i_dst.plen);
27866  
27867  #ifdef CONFIG_IPV6_SUBTREES
27868 diff -NurpP --minimal linux-3.0.4/net/ipv6/tcp_ipv6.c linux-3.0.4-vs2.3.1/net/ipv6/tcp_ipv6.c
27869 --- linux-3.0.4/net/ipv6/tcp_ipv6.c     2011-08-31 18:56:42.000000000 +0200
27870 +++ linux-3.0.4-vs2.3.1/net/ipv6/tcp_ipv6.c     2011-08-29 03:45:10.000000000 +0200
27871 @@ -70,6 +70,7 @@
27872  
27873  #include <linux/crypto.h>
27874  #include <linux/scatterlist.h>
27875 +#include <linux/vs_inet6.h>
27876  
27877  static void    tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
27878  static void    tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
27879 @@ -162,8 +163,15 @@ static int tcp_v6_connect(struct sock *s
27880          *      connect() to INADDR_ANY means loopback (BSD'ism).
27881          */
27882  
27883 -       if(ipv6_addr_any(&usin->sin6_addr))
27884 -               usin->sin6_addr.s6_addr[15] = 0x1;
27885 +       if(ipv6_addr_any(&usin->sin6_addr)) {
27886 +               struct nx_info *nxi =  sk->sk_nx_info;
27887 +
27888 +               if (nxi && nx_info_has_v6(nxi))
27889 +                       /* FIXME: remap lback? */
27890 +                       usin->sin6_addr = nxi->v6.ip;
27891 +               else
27892 +                       usin->sin6_addr.s6_addr[15] = 0x1;
27893 +       }
27894  
27895         addr_type = ipv6_addr_type(&usin->sin6_addr);
27896  
27897 diff -NurpP --minimal linux-3.0.4/net/ipv6/udp.c linux-3.0.4-vs2.3.1/net/ipv6/udp.c
27898 --- linux-3.0.4/net/ipv6/udp.c  2011-08-31 18:56:42.000000000 +0200
27899 +++ linux-3.0.4-vs2.3.1/net/ipv6/udp.c  2011-08-29 03:45:10.000000000 +0200
27900 @@ -45,41 +45,67 @@
27901  #include <net/tcp_states.h>
27902  #include <net/ip6_checksum.h>
27903  #include <net/xfrm.h>
27904 +#include <linux/vs_inet6.h>
27905  
27906  #include <linux/proc_fs.h>
27907  #include <linux/seq_file.h>
27908  #include "udp_impl.h"
27909  
27910 -int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
27911 +int ipv6_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27912  {
27913 -       const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
27914 +       const struct in6_addr *sk1_rcv_saddr6 = &inet6_sk(sk1)->rcv_saddr;
27915         const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
27916 -       __be32 sk1_rcv_saddr = sk_rcv_saddr(sk);
27917 +       __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1);
27918         __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
27919 -       int sk_ipv6only = ipv6_only_sock(sk);
27920 +       int sk1_ipv6only = ipv6_only_sock(sk1);
27921         int sk2_ipv6only = inet_v6_ipv6only(sk2);
27922 -       int addr_type = ipv6_addr_type(sk_rcv_saddr6);
27923 +       int addr_type = ipv6_addr_type(sk1_rcv_saddr6);
27924         int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
27925  
27926         /* if both are mapped, treat as IPv4 */
27927 -       if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
27928 -               return (!sk2_ipv6only &&
27929 +       if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
27930 +               if (!sk2_ipv6only &&
27931                         (!sk1_rcv_saddr || !sk2_rcv_saddr ||
27932 -                         sk1_rcv_saddr == sk2_rcv_saddr));
27933 +                         sk1_rcv_saddr == sk2_rcv_saddr))
27934 +                       goto vs_v4;
27935 +               else
27936 +                       return 0;
27937 +       }
27938  
27939         if (addr_type2 == IPV6_ADDR_ANY &&
27940             !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
27941 -               return 1;
27942 +               goto vs;
27943  
27944         if (addr_type == IPV6_ADDR_ANY &&
27945 -           !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
27946 -               return 1;
27947 +           !(sk1_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
27948 +               goto vs;
27949  
27950         if (sk2_rcv_saddr6 &&
27951 -           ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
27952 -               return 1;
27953 +           ipv6_addr_equal(sk1_rcv_saddr6, sk2_rcv_saddr6))
27954 +               goto vs;
27955  
27956         return 0;
27957 +
27958 +vs_v4:
27959 +       if (!sk1_rcv_saddr && !sk2_rcv_saddr)
27960 +               return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
27961 +       if (!sk2_rcv_saddr)
27962 +               return v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, -1);
27963 +       if (!sk1_rcv_saddr)
27964 +               return v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, -1);
27965 +       return 1;
27966 +vs:
27967 +       if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
27968 +               return nx_v6_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
27969 +       else if (addr_type2 == IPV6_ADDR_ANY)
27970 +               return v6_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr6, -1);
27971 +       else if (addr_type == IPV6_ADDR_ANY) {
27972 +               if (addr_type2 == IPV6_ADDR_MAPPED)
27973 +                       return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
27974 +               else
27975 +                       return v6_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr6, -1);
27976 +       }
27977 +       return 1;
27978  }
27979  
27980  static unsigned int udp6_portaddr_hash(struct net *net,
27981 @@ -143,6 +169,10 @@ static inline int compute_score(struct s
27982                         if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
27983                                 return -1;
27984                         score++;
27985 +               } else {
27986 +                       /* block non nx_info ips */
27987 +                       if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
27988 +                               return -1;
27989                 }
27990                 if (!ipv6_addr_any(&np->daddr)) {
27991                         if (!ipv6_addr_equal(&np->daddr, saddr))
27992 diff -NurpP --minimal linux-3.0.4/net/ipv6/xfrm6_policy.c linux-3.0.4-vs2.3.1/net/ipv6/xfrm6_policy.c
27993 --- linux-3.0.4/net/ipv6/xfrm6_policy.c 2011-07-22 11:18:13.000000000 +0200
27994 +++ linux-3.0.4-vs2.3.1/net/ipv6/xfrm6_policy.c 2011-06-10 22:11:24.000000000 +0200
27995 @@ -63,7 +63,7 @@ static int xfrm6_get_saddr(struct net *n
27996         dev = ip6_dst_idev(dst)->dev;
27997         ipv6_dev_get_saddr(dev_net(dev), dev,
27998                            (struct in6_addr *)&daddr->a6, 0,
27999 -                          (struct in6_addr *)&saddr->a6);
28000 +                          (struct in6_addr *)&saddr->a6, NULL);
28001         dst_release(dst);
28002         return 0;
28003  }
28004 diff -NurpP --minimal linux-3.0.4/net/netfilter/ipvs/ip_vs_xmit.c linux-3.0.4-vs2.3.1/net/netfilter/ipvs/ip_vs_xmit.c
28005 --- linux-3.0.4/net/netfilter/ipvs/ip_vs_xmit.c 2011-07-22 11:18:13.000000000 +0200
28006 +++ linux-3.0.4-vs2.3.1/net/netfilter/ipvs/ip_vs_xmit.c 2011-07-22 15:27:52.000000000 +0200
28007 @@ -226,7 +226,7 @@ __ip_vs_route_output_v6(struct net *net,
28008                 return dst;
28009         if (ipv6_addr_any(&fl6.saddr) &&
28010             ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
28011 -                              &fl6.daddr, 0, &fl6.saddr) < 0)
28012 +                              &fl6.daddr, 0, &fl6.saddr, NULL) < 0)
28013                 goto out_err;
28014         if (do_xfrm) {
28015                 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
28016 diff -NurpP --minimal linux-3.0.4/net/netlink/af_netlink.c linux-3.0.4-vs2.3.1/net/netlink/af_netlink.c
28017 --- linux-3.0.4/net/netlink/af_netlink.c        2011-07-22 11:18:13.000000000 +0200
28018 +++ linux-3.0.4-vs2.3.1/net/netlink/af_netlink.c        2011-06-10 22:11:24.000000000 +0200
28019 @@ -55,6 +55,9 @@
28020  #include <linux/types.h>
28021  #include <linux/audit.h>
28022  #include <linux/mutex.h>
28023 +#include <linux/vs_context.h>
28024 +#include <linux/vs_network.h>
28025 +#include <linux/vs_limit.h>
28026  
28027  #include <net/net_namespace.h>
28028  #include <net/sock.h>
28029 @@ -1907,6 +1910,8 @@ static struct sock *netlink_seq_socket_i
28030                         sk_for_each(s, node, &hash->table[j]) {
28031                                 if (sock_net(s) != seq_file_net(seq))
28032                                         continue;
28033 +                               if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28034 +                                       continue;
28035                                 if (off == pos) {
28036                                         iter->link = i;
28037                                         iter->hash_idx = j;
28038 @@ -1941,7 +1946,8 @@ static void *netlink_seq_next(struct seq
28039         s = v;
28040         do {
28041                 s = sk_next(s);
28042 -       } while (s && sock_net(s) != seq_file_net(seq));
28043 +       } while (s && (sock_net(s) != seq_file_net(seq) ||
28044 +               !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
28045         if (s)
28046                 return s;
28047  
28048 @@ -1953,7 +1959,8 @@ static void *netlink_seq_next(struct seq
28049  
28050                 for (; j <= hash->mask; j++) {
28051                         s = sk_head(&hash->table[j]);
28052 -                       while (s && sock_net(s) != seq_file_net(seq))
28053 +                       while (s && (sock_net(s) != seq_file_net(seq) ||
28054 +                               !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
28055                                 s = sk_next(s);
28056                         if (s) {
28057                                 iter->link = i;
28058 diff -NurpP --minimal linux-3.0.4/net/socket.c linux-3.0.4-vs2.3.1/net/socket.c
28059 --- linux-3.0.4/net/socket.c    2011-08-31 18:56:43.000000000 +0200
28060 +++ linux-3.0.4-vs2.3.1/net/socket.c    2011-08-29 03:45:10.000000000 +0200
28061 @@ -98,6 +98,10 @@
28062  
28063  #include <net/sock.h>
28064  #include <linux/netfilter.h>
28065 +#include <linux/vs_base.h>
28066 +#include <linux/vs_socket.h>
28067 +#include <linux/vs_inet.h>
28068 +#include <linux/vs_inet6.h>
28069  
28070  #include <linux/if_tun.h>
28071  #include <linux/ipv6_route.h>
28072 @@ -546,6 +550,7 @@ static inline int __sock_sendmsg_nosec(s
28073                                        struct msghdr *msg, size_t size)
28074  {
28075         struct sock_iocb *si = kiocb_to_siocb(iocb);
28076 +       size_t len;
28077  
28078         sock_update_classid(sock->sk);
28079  
28080 @@ -554,7 +559,22 @@ static inline int __sock_sendmsg_nosec(s
28081         si->msg = msg;
28082         si->size = size;
28083  
28084 -       return sock->ops->sendmsg(iocb, sock, msg, size);
28085 +       len = sock->ops->sendmsg(iocb, sock, msg, size);
28086 +       if (sock->sk) {
28087 +               if (len == size)
28088 +                       vx_sock_send(sock->sk, size);
28089 +               else
28090 +                       vx_sock_fail(sock->sk, size);
28091 +       }
28092 +       vxdprintk(VXD_CBIT(net, 7),
28093 +               "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%zu",
28094 +               sock, sock->sk,
28095 +               (sock->sk)?sock->sk->sk_nx_info:0,
28096 +               (sock->sk)?sock->sk->sk_vx_info:0,
28097 +               (sock->sk)?sock->sk->sk_xid:0,
28098 +               (sock->sk)?sock->sk->sk_nid:0,
28099 +               (unsigned int)size, len);
28100 +       return len;
28101  }
28102  
28103  static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock,
28104 @@ -694,6 +714,7 @@ static inline int __sock_recvmsg_nosec(s
28105                                        struct msghdr *msg, size_t size, int flags)
28106  {
28107         struct sock_iocb *si = kiocb_to_siocb(iocb);
28108 +       int len;
28109  
28110         sock_update_classid(sock->sk);
28111  
28112 @@ -703,7 +724,18 @@ static inline int __sock_recvmsg_nosec(s
28113         si->size = size;
28114         si->flags = flags;
28115  
28116 -       return sock->ops->recvmsg(iocb, sock, msg, size, flags);
28117 +       len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
28118 +       if ((len >= 0) && sock->sk)
28119 +               vx_sock_recv(sock->sk, len);
28120 +       vxdprintk(VXD_CBIT(net, 7),
28121 +               "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
28122 +               sock, sock->sk,
28123 +               (sock->sk)?sock->sk->sk_nx_info:0,
28124 +               (sock->sk)?sock->sk->sk_vx_info:0,
28125 +               (sock->sk)?sock->sk->sk_xid:0,
28126 +               (sock->sk)?sock->sk->sk_nid:0,
28127 +               (unsigned int)size, len);
28128 +       return len;
28129  }
28130  
28131  static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
28132 @@ -1188,6 +1220,13 @@ int __sock_create(struct net *net, int f
28133         if (type < 0 || type >= SOCK_MAX)
28134                 return -EINVAL;
28135  
28136 +       if (!nx_check(0, VS_ADMIN)) {
28137 +               if (family == PF_INET && !current_nx_info_has_v4())
28138 +                       return -EAFNOSUPPORT;
28139 +               if (family == PF_INET6 && !current_nx_info_has_v6())
28140 +                       return -EAFNOSUPPORT;
28141 +       }
28142 +
28143         /* Compatibility.
28144  
28145            This uglymoron is moved from INET layer to here to avoid
28146 @@ -1323,6 +1362,7 @@ SYSCALL_DEFINE3(socket, int, family, int
28147         if (retval < 0)
28148                 goto out;
28149  
28150 +       set_bit(SOCK_USER_SOCKET, &sock->flags);
28151         retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
28152         if (retval < 0)
28153                 goto out_release;
28154 @@ -1364,10 +1404,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
28155         err = sock_create(family, type, protocol, &sock1);
28156         if (err < 0)
28157                 goto out;
28158 +       set_bit(SOCK_USER_SOCKET, &sock1->flags);
28159  
28160         err = sock_create(family, type, protocol, &sock2);
28161         if (err < 0)
28162                 goto out_release_1;
28163 +       set_bit(SOCK_USER_SOCKET, &sock2->flags);
28164  
28165         err = sock1->ops->socketpair(sock1, sock2);
28166         if (err < 0)
28167 diff -NurpP --minimal linux-3.0.4/net/sunrpc/auth.c linux-3.0.4-vs2.3.1/net/sunrpc/auth.c
28168 --- linux-3.0.4/net/sunrpc/auth.c       2011-07-22 11:18:13.000000000 +0200
28169 +++ linux-3.0.4-vs2.3.1/net/sunrpc/auth.c       2011-06-10 22:11:24.000000000 +0200
28170 @@ -14,6 +14,7 @@
28171  #include <linux/hash.h>
28172  #include <linux/sunrpc/clnt.h>
28173  #include <linux/spinlock.h>
28174 +#include <linux/vs_tag.h>
28175  
28176  #ifdef RPC_DEBUG
28177  # define RPCDBG_FACILITY       RPCDBG_AUTH
28178 @@ -427,6 +428,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
28179         memset(&acred, 0, sizeof(acred));
28180         acred.uid = cred->fsuid;
28181         acred.gid = cred->fsgid;
28182 +       acred.tag = dx_current_tag();
28183         acred.group_info = get_group_info(((struct cred *)cred)->group_info);
28184  
28185         ret = auth->au_ops->lookup_cred(auth, &acred, flags);
28186 @@ -467,6 +469,7 @@ rpcauth_bind_root_cred(struct rpc_task *
28187         struct auth_cred acred = {
28188                 .uid = 0,
28189                 .gid = 0,
28190 +               .tag = dx_current_tag(),
28191         };
28192  
28193         dprintk("RPC: %5u looking up %s cred\n",
28194 diff -NurpP --minimal linux-3.0.4/net/sunrpc/auth_unix.c linux-3.0.4-vs2.3.1/net/sunrpc/auth_unix.c
28195 --- linux-3.0.4/net/sunrpc/auth_unix.c  2010-10-21 13:08:01.000000000 +0200
28196 +++ linux-3.0.4-vs2.3.1/net/sunrpc/auth_unix.c  2011-06-10 22:11:24.000000000 +0200
28197 @@ -12,12 +12,14 @@
28198  #include <linux/module.h>
28199  #include <linux/sunrpc/clnt.h>
28200  #include <linux/sunrpc/auth.h>
28201 +#include <linux/vs_tag.h>
28202  
28203  #define NFS_NGROUPS    16
28204  
28205  struct unx_cred {
28206         struct rpc_cred         uc_base;
28207         gid_t                   uc_gid;
28208 +       tag_t                   uc_tag;
28209         gid_t                   uc_gids[NFS_NGROUPS];
28210  };
28211  #define uc_uid                 uc_base.cr_uid
28212 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
28213                 groups = NFS_NGROUPS;
28214  
28215         cred->uc_gid = acred->gid;
28216 +       cred->uc_tag = acred->tag;
28217         for (i = 0; i < groups; i++)
28218                 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
28219         if (i < NFS_NGROUPS)
28220 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
28221         unsigned int i;
28222  
28223  
28224 -       if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
28225 +       if (cred->uc_uid != acred->uid ||
28226 +               cred->uc_gid != acred->gid ||
28227 +               cred->uc_tag != acred->tag)
28228                 return 0;
28229  
28230         if (acred->group_info != NULL)
28231 @@ -142,7 +147,7 @@ unx_marshal(struct rpc_task *task, __be3
28232         struct rpc_clnt *clnt = task->tk_client;
28233         struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base);
28234         __be32          *base, *hold;
28235 -       int             i;
28236 +       int             i, tag;
28237  
28238         *p++ = htonl(RPC_AUTH_UNIX);
28239         base = p++;
28240 @@ -152,9 +157,12 @@ unx_marshal(struct rpc_task *task, __be3
28241          * Copy the UTS nodename captured when the client was created.
28242          */
28243         p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
28244 +       tag = task->tk_client->cl_tag;
28245  
28246 -       *p++ = htonl((u32) cred->uc_uid);
28247 -       *p++ = htonl((u32) cred->uc_gid);
28248 +       *p++ = htonl((u32) TAGINO_UID(tag,
28249 +               cred->uc_uid, cred->uc_tag));
28250 +       *p++ = htonl((u32) TAGINO_GID(tag,
28251 +               cred->uc_gid, cred->uc_tag));
28252         hold = p++;
28253         for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
28254                 *p++ = htonl((u32) cred->uc_gids[i]);
28255 diff -NurpP --minimal linux-3.0.4/net/sunrpc/clnt.c linux-3.0.4-vs2.3.1/net/sunrpc/clnt.c
28256 --- linux-3.0.4/net/sunrpc/clnt.c       2011-07-22 11:18:13.000000000 +0200
28257 +++ linux-3.0.4-vs2.3.1/net/sunrpc/clnt.c       2011-07-01 11:35:35.000000000 +0200
28258 @@ -31,6 +31,7 @@
28259  #include <linux/in.h>
28260  #include <linux/in6.h>
28261  #include <linux/un.h>
28262 +#include <linux/vs_cvirt.h>
28263  
28264  #include <linux/sunrpc/clnt.h>
28265  #include <linux/sunrpc/rpc_pipe_fs.h>
28266 @@ -362,6 +363,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
28267         if (!(args->flags & RPC_CLNT_CREATE_QUIET))
28268                 clnt->cl_chatty = 1;
28269  
28270 +       /* TODO: handle RPC_CLNT_CREATE_TAGGED
28271 +       if (args->flags & RPC_CLNT_CREATE_TAGGED)
28272 +               clnt->cl_tag = 1; */
28273         return clnt;
28274  }
28275  EXPORT_SYMBOL_GPL(rpc_create);
28276 diff -NurpP --minimal linux-3.0.4/net/unix/af_unix.c linux-3.0.4-vs2.3.1/net/unix/af_unix.c
28277 --- linux-3.0.4/net/unix/af_unix.c      2011-07-22 11:18:13.000000000 +0200
28278 +++ linux-3.0.4-vs2.3.1/net/unix/af_unix.c      2011-06-10 22:11:24.000000000 +0200
28279 @@ -114,6 +114,8 @@
28280  #include <linux/mount.h>
28281  #include <net/checksum.h>
28282  #include <linux/security.h>
28283 +#include <linux/vs_context.h>
28284 +#include <linux/vs_limit.h>
28285  
28286  static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
28287  static DEFINE_SPINLOCK(unix_table_lock);
28288 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
28289                 if (!net_eq(sock_net(s), net))
28290                         continue;
28291  
28292 +               if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28293 +                       continue;
28294                 if (u->addr->len == len &&
28295                     !memcmp(u->addr->name, sunname, len))
28296                         goto found;
28297 @@ -2208,6 +2212,8 @@ static struct sock *unix_seq_idx(struct 
28298         for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
28299                 if (sock_net(s) != seq_file_net(seq))
28300                         continue;
28301 +               if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28302 +                       continue;
28303                 if (off == pos)
28304                         return s;
28305                 ++off;
28306 @@ -2232,7 +2238,8 @@ static void *unix_seq_next(struct seq_fi
28307                 sk = first_unix_socket(&iter->i);
28308         else
28309                 sk = next_unix_socket(&iter->i, sk);
28310 -       while (sk && (sock_net(sk) != seq_file_net(seq)))
28311 +       while (sk && (sock_net(sk) != seq_file_net(seq) ||
28312 +               !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
28313                 sk = next_unix_socket(&iter->i, sk);
28314         return sk;
28315  }
28316 diff -NurpP --minimal linux-3.0.4/scripts/checksyscalls.sh linux-3.0.4-vs2.3.1/scripts/checksyscalls.sh
28317 --- linux-3.0.4/scripts/checksyscalls.sh        2011-03-15 18:07:46.000000000 +0100
28318 +++ linux-3.0.4-vs2.3.1/scripts/checksyscalls.sh        2011-06-10 22:11:24.000000000 +0200
28319 @@ -193,7 +193,6 @@ cat << EOF
28320  #define __IGNORE_afs_syscall
28321  #define __IGNORE_getpmsg
28322  #define __IGNORE_putpmsg
28323 -#define __IGNORE_vserver
28324  EOF
28325  }
28326  
28327 diff -NurpP --minimal linux-3.0.4/security/commoncap.c linux-3.0.4-vs2.3.1/security/commoncap.c
28328 --- linux-3.0.4/security/commoncap.c    2011-07-22 11:18:14.000000000 +0200
28329 +++ linux-3.0.4-vs2.3.1/security/commoncap.c    2011-08-30 15:42:43.000000000 +0200
28330 @@ -62,6 +62,7 @@ int cap_netlink_recv(struct sk_buff *skb
28331                 return -EPERM;
28332         return 0;
28333  }
28334 +
28335  EXPORT_SYMBOL(cap_netlink_recv);
28336  
28337  /**
28338 @@ -83,14 +84,20 @@ EXPORT_SYMBOL(cap_netlink_recv);
28339  int cap_capable(struct task_struct *tsk, const struct cred *cred,
28340                 struct user_namespace *targ_ns, int cap, int audit)
28341  {
28342 +       struct vx_info *vxi = tsk->vx_info;
28343 +
28344         for (;;) {
28345                 /* The creator of the user namespace has all caps. */
28346                 if (targ_ns != &init_user_ns && targ_ns->creator == cred->user)
28347                         return 0;
28348  
28349                 /* Do we have the necessary capabilities? */
28350 -               if (targ_ns == cred->user->user_ns)
28351 -                       return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
28352 +               if (targ_ns == cred->user->user_ns) {
28353 +                       if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
28354 +                           cap_raised(cred->cap_effective, cap))
28355 +                               return 0;
28356 +                       return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
28357 +               }
28358  
28359                 /* Have we tried all of the parent namespaces? */
28360                 if (targ_ns == &init_user_ns)
28361 @@ -611,7 +618,7 @@ int cap_inode_setxattr(struct dentry *de
28362  
28363         if (!strncmp(name, XATTR_SECURITY_PREFIX,
28364                      sizeof(XATTR_SECURITY_PREFIX) - 1) &&
28365 -           !capable(CAP_SYS_ADMIN))
28366 +               !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
28367                 return -EPERM;
28368         return 0;
28369  }
28370 @@ -637,7 +644,7 @@ int cap_inode_removexattr(struct dentry 
28371  
28372         if (!strncmp(name, XATTR_SECURITY_PREFIX,
28373                      sizeof(XATTR_SECURITY_PREFIX) - 1) &&
28374 -           !capable(CAP_SYS_ADMIN))
28375 +               !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
28376                 return -EPERM;
28377         return 0;
28378  }
28379 diff -NurpP --minimal linux-3.0.4/security/selinux/hooks.c linux-3.0.4-vs2.3.1/security/selinux/hooks.c
28380 --- linux-3.0.4/security/selinux/hooks.c        2011-07-22 11:18:14.000000000 +0200
28381 +++ linux-3.0.4-vs2.3.1/security/selinux/hooks.c        2011-06-15 02:40:14.000000000 +0200
28382 @@ -67,7 +67,6 @@
28383  #include <linux/dccp.h>
28384  #include <linux/quota.h>
28385  #include <linux/un.h>          /* for Unix socket types */
28386 -#include <net/af_unix.h>       /* for Unix socket types */
28387  #include <linux/parser.h>
28388  #include <linux/nfs_mount.h>
28389  #include <net/ipv6.h>
This page took 2.544646 seconds and 4 git commands to generate.