1 diff -NurpP --minimal linux-3.1/.config.inet linux-3.1-vs2.3.1-rc2/.config.inet
2 --- linux-3.1/.config.inet 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-3.1-vs2.3.1-rc2/.config.inet 2011-10-24 18:53:33.000000000 +0200
6 +# Automatically generated make config: don't edit
7 +# Linux/x86_64 3.0.0-rc2-vs2.3.x Kernel Configuration
10 +# CONFIG_X86_32 is not set
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
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
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
48 +CONFIG_ARCH_POPULATES_NODE_MAP=y
50 +CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y
51 +CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=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
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
78 +# CONFIG_KERNEL_XZ is not set
79 +# CONFIG_KERNEL_LZO is not set
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
89 +CONFIG_TASK_DELAY_ACCT=y
91 +CONFIG_TASK_IO_ACCOUNTING=y
92 +# CONFIG_AUDIT is not set
93 +CONFIG_HAVE_GENERIC_HARDIRQS=y
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
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
116 +CONFIG_IKCONFIG_PROC=y
117 +CONFIG_LOG_BUF_SHIFT=18
118 +CONFIG_HAVE_UNSTABLE_SCHED_CLOCK=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
138 +# CONFIG_PID_NS is not set
139 +# CONFIG_NET_NS is not set
140 +CONFIG_SCHED_AUTOGROUP=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
147 +CONFIG_ANON_INODES=y
150 +CONFIG_SYSCTL_SYSCALL=y
152 +CONFIG_KALLSYMS_ALL=y
157 +CONFIG_PCSPKR_PLATFORM=y
166 +# CONFIG_EMBEDDED is not set
167 +CONFIG_HAVE_PERF_EVENTS=y
170 +# Kernel Performance Events And Counters
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
178 +# CONFIG_COMPAT_BRK is not set
179 +# CONFIG_SLAB is not set
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
202 +# GCOV-based kernel profiling
204 +# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
208 +# CONFIG_MODULES is not set
209 +CONFIG_STOP_MACHINE=y
211 +# CONFIG_BLK_DEV_BSG is not set
212 +# CONFIG_BLK_DEV_INTEGRITY is not set
213 +CONFIG_BLOCK_COMPAT=y
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
256 +# Processor type and features
258 +CONFIG_TICK_ONESHOT=y
259 +# CONFIG_NO_HZ is not set
260 +CONFIG_HIGH_RES_TIMERS=y
261 +CONFIG_GENERIC_CLOCKEVENTS_BUILD=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
269 +# CONFIG_MEMTEST is not set
270 +# CONFIG_MK8 is not set
271 +# CONFIG_MPSC is not set
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
280 +CONFIG_X86_WP_WORKS_OK=y
281 +CONFIG_X86_INTEL_USERCOPY=y
282 +CONFIG_X86_USE_PPRO_CHECKSUM=y
285 +CONFIG_X86_CMPXCHG64=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
294 +CONFIG_HPET_EMULATE_RTC=y
297 +# CONFIG_CALGARY_IOMMU is not set
298 +# CONFIG_AMD_IOMMU is not set
300 +CONFIG_IOMMU_HELPER=y
301 +# CONFIG_IOMMU_API is not set
302 +# CONFIG_MAXSMP is not set
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
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
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
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
345 +CONFIG_PHYS_ADDR_T_64BIT=y
346 +CONFIG_ZONE_DMA_FLAG=1
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
357 +# CONFIG_X86_CHECK_BIOS_CORRUPTION is not set
358 +CONFIG_X86_RESERVE_LOW=4
360 +CONFIG_MTRR_SANITIZER=y
361 +CONFIG_MTRR_SANITIZER_ENABLE_DEFAULT=0
362 +CONFIG_MTRR_SANITIZER_SPARE_REG_NR_DEFAULT=1
364 +CONFIG_ARCH_USES_PG_UNCACHED=y
365 +# CONFIG_EFI is not set
367 +# CONFIG_CC_STACKPROTECTOR is not set
369 +# CONFIG_HZ_250 is not set
370 +# CONFIG_HZ_300 is not set
371 +# CONFIG_HZ_1000 is not set
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
385 +# Power management and ACPI options
388 +CONFIG_SUSPEND_FREEZER=y
389 +# CONFIG_HIBERNATION is not set
391 +CONFIG_PM_SLEEP_SMP=y
392 +# CONFIG_PM_RUNTIME is not set
394 +# CONFIG_PM_DEBUG is not set
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
402 +CONFIG_ACPI_BATTERY=y
403 +CONFIG_ACPI_BUTTON=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
422 +# CPU Frequency scaling
424 +# CONFIG_CPU_FREQ is not set
426 +CONFIG_CPU_IDLE_GOV_LADDER=y
427 +# CONFIG_INTEL_IDLE is not set
430 +# Memory power savings
432 +# CONFIG_I7300_IDLE is not set
435 +# Bus options (PCI etc.)
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
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
451 +# CONFIG_PCI_IOV is not set
454 +CONFIG_ISA_DMA_API=y
456 +# CONFIG_PCCARD is not set
457 +# CONFIG_HOTPLUG_PCI is not set
458 +# CONFIG_RAPIDIO is not set
461 +# Executable file formats / Emulations
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
471 +CONFIG_COMPAT_FOR_U64_ALIGNMENT=y
472 +CONFIG_SYSVIPC_COMPAT=y
473 +CONFIG_HAVE_TEXT_POKE_SMP=y
477 +# Networking options
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
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
512 +# CONFIG_IPV6_PRIVACY is not set
513 +# CONFIG_IPV6_ROUTER_PREF is not set
514 +# CONFIG_IPV6_OPTIMISTIC_DAD is not set
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
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
534 +# CONFIG_NETFILTER_DEBUG is not set
535 +# CONFIG_NETFILTER_ADVANCED is not set
538 +# Core Netfilter Configuration
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
550 +# Xtables combined modules
552 +CONFIG_NETFILTER_XT_MARK=y
557 +CONFIG_NETFILTER_XT_TARGET_NFLOG=y
558 +CONFIG_NETFILTER_XT_TARGET_TCPMSS=y
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
569 +# CONFIG_IP_VS_DEBUG is not set
570 +CONFIG_IP_VS_TAB_BITS=12
573 +# IPVS transport protocol load balancing support
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
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
597 +# IPVS application helper
599 +# CONFIG_IP_VS_NFCT is not set
602 +# IP: Netfilter Configuration
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
613 +CONFIG_NF_NAT_NEEDED=y
614 +CONFIG_IP_NF_TARGET_MASQUERADE=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
622 +CONFIG_IP_NF_MANGLE=y
625 +# IPv6: Netfilter Configuration
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
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
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
665 +CONFIG_HAVE_BPF_JIT=y
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
688 +# Generic Driver Options
690 +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
692 +# CONFIG_DEVTMPFS_MOUNT is not set
694 +CONFIG_PREVENT_FIRMWARE_BUILD=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
705 +CONFIG_PNP_DEBUG_MESSAGES=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
722 +# DRBD disabled because PROC_FS, INET or CONNECTOR not selected
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
738 +# Please see Documentation/ide/ide.txt for help/info on IDE drives
740 +CONFIG_IDE_XFER_MODE=y
741 +# CONFIG_BLK_DEV_IDE_SATA is not set
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
752 +# IDE chipset support/bugfixes
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
761 +# PCI IDE chipsets support
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
798 +# SCSI device support
801 +# CONFIG_RAID_ATTRS is not set
804 +# CONFIG_SCSI_TGT is not set
805 +# CONFIG_SCSI_NETLINK is not set
806 +# CONFIG_SCSI_PROC_FS is not set
809 +# SCSI support type (disk, tape, CD-ROM)
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
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
835 +# CONFIG_ATA_NONSTANDARD is not set
836 +CONFIG_ATA_VERBOSE_ERROR=y
841 +# Controllers with non-SFF native interface
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
851 +CONFIG_MD_AUTODETECT=y
852 +# CONFIG_MD_LINEAR is not set
857 +# CONFIG_MULTICORE_RAID456 is not set
858 +# CONFIG_MD_MULTIPATH is not set
859 +# CONFIG_MD_FAULTY is not set
861 +# CONFIG_DM_DEBUG is not set
862 +# CONFIG_DM_CRYPT is not set
863 +CONFIG_DM_SNAPSHOT=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
876 +# IEEE 1394 (FireWire) support
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
883 +# CONFIG_DUMMY is not set
884 +# CONFIG_BONDING is not set
885 +# CONFIG_MACVLAN is not set
886 +# CONFIG_EQUALIZER is not set
888 +# CONFIG_VETH is not set
889 +# CONFIG_NET_SB1000 is not set
890 +# CONFIG_ARCNET is not set
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
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
925 +# Enable WiMAX (Networking options) to see the WiMAX drivers
927 +# CONFIG_WAN is not set
930 +# CAIF transport drivers
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
945 +# Input device support
948 +# CONFIG_INPUT_FF_MEMLESS is not set
949 +# CONFIG_INPUT_POLLDEV is not set
950 +# CONFIG_INPUT_SPARSEKMAP is not set
953 +# Userland interfaces
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
964 +# Input Device Drivers
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
981 +# Hardware I/O ports
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
998 +CONFIG_CONSOLE_TRANSLATIONS=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
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
1025 +# Non-8250 serial port support
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
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
1051 +# CONFIG_I2C is not set
1052 +# CONFIG_SPI is not set
1057 +# CONFIG_PPS is not set
1060 +# PPS generators support
1064 +# PTP clock support
1068 +# Enable Device Drivers -> PPS to see the PTP clock options.
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
1082 +# CONFIG_WATCHDOG is not set
1083 +CONFIG_SSB_POSSIBLE=y
1086 +# Sonics Silicon Backplane
1088 +# CONFIG_SSB is not set
1089 +CONFIG_BCMA_POSSIBLE=y
1092 +# Broadcom specific AMBA
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
1102 +# CONFIG_AGP is not set
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
1114 +# Display device support
1116 +# CONFIG_DISPLAY_SUPPORT is not set
1119 +# Console display driver support
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
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
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
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
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
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
1183 +CONFIG_JFS_POSIX_ACL=y
1184 +CONFIG_JFS_SECURITY=y
1186 +CONFIG_JFS_STATISTICS=y
1189 +CONFIG_XFS_POSIX_ACL=y
1191 +# CONFIG_XFS_DEBUG is not set
1193 +CONFIG_GFS2_FS_LOCKING_DLM=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
1200 +CONFIG_BTRFS_FS_POSIX_ACL=y
1201 +# CONFIG_NILFS2_FS is not set
1202 +CONFIG_FS_POSIX_ACL=y
1204 +CONFIG_FILE_LOCKING=y
1207 +CONFIG_INOTIFY_USER=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
1217 +CONFIG_QUOTACTL_COMPAT=y
1218 +# CONFIG_AUTOFS4_FS is not set
1219 +# CONFIG_FUSE_FS is not set
1220 +CONFIG_GENERIC_ACL=y
1225 +# CONFIG_FSCACHE is not set
1228 +# CD-ROM/DVD Filesystems
1230 +# CONFIG_ISO9660_FS is not set
1231 +# CONFIG_UDF_FS is not set
1234 +# DOS/FAT/NT Filesystems
1236 +# CONFIG_MSDOS_FS is not set
1237 +# CONFIG_VFAT_FS is not set
1238 +# CONFIG_NTFS_FS is not set
1241 +# Pseudo filesystems
1244 +# CONFIG_PROC_KCORE is not set
1245 +CONFIG_PROC_SYSCTL=y
1246 +CONFIG_PROC_PAGE_MONITOR=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
1258 +# CONFIG_NFS_V3_ACL is not set
1259 +# CONFIG_NFS_V4 is not set
1261 +CONFIG_NFSD_DEPRECATED=y
1263 +# CONFIG_NFSD_V3_ACL is not set
1264 +# CONFIG_NFSD_V4 is not set
1267 +CONFIG_NFS_COMMON=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
1278 +# CONFIG_PARTITION_ADVANCED is not set
1279 +CONFIG_MSDOS_PARTITION=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
1321 +# CONFIG_DLM_DEBUG is not set
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
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
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
1477 +CONFIG_ASYNC_RAID6_RECOV=y
1481 +# Crypto core or helper
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
1505 +# Authenticated Encryption with Associated Data
1507 +# CONFIG_CRYPTO_CCM is not set
1508 +# CONFIG_CRYPTO_GCM is not set
1509 +# CONFIG_CRYPTO_SEQIV is not set
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
1525 +CONFIG_CRYPTO_HMAC=y
1526 +# CONFIG_CRYPTO_XCBC is not set
1527 +# CONFIG_CRYPTO_VMAC is not set
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
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
1575 +CONFIG_CRYPTO_DEFLATE=y
1576 +# CONFIG_CRYPTO_ZLIB is not set
1577 +# CONFIG_CRYPTO_LZO is not set
1580 +# Random Number Generation
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
1587 +# CONFIG_CRYPTO_DEV_PADLOCK is not set
1588 +# CONFIG_CRYPTO_DEV_HIFN_795X is not set
1590 +# CONFIG_VIRTUALIZATION is not set
1591 +# CONFIG_BINARY_PRINTF is not set
1597 +CONFIG_BITREVERSE=y
1598 +CONFIG_GENERIC_FIND_FIRST_BIT=y
1599 +# CONFIG_CRC_CCITT is not set
1601 +# CONFIG_CRC_T10DIF is not set
1602 +# CONFIG_CRC_ITU_T is not set
1604 +# CONFIG_CRC7 is not set
1606 +CONFIG_ZLIB_INFLATE=y
1607 +CONFIG_ZLIB_DEFLATE=y
1608 +CONFIG_LZO_COMPRESS=y
1609 +CONFIG_LZO_DECOMPRESS=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
1620 +CONFIG_HAS_IOPORT=y
1624 +# CONFIG_AVERAGE is not set
1625 diff -NurpP --minimal linux-3.1/Documentation/vserver/debug.txt linux-3.1-vs2.3.1-rc2/Documentation/vserver/debug.txt
1626 --- linux-3.1/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
1627 +++ linux-3.1-vs2.3.1-rc2/Documentation/vserver/debug.txt 2011-10-24 18:53:33.000000000 +0200
1632 + 2 4 "vx_map_tgid: %p/%llx: %d -> %d"
1633 + "vx_rmap_tgid: %p/%llx: %d -> %d"
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"
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"
1668 + "path_lookup(old): %d"
1669 + "vfs_create(new): %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]"
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"
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])"
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)"
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"
1735 + 7 80 "dx_parse_tag(»%s«): %d:#%d"
1736 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d"
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]"
1777 + n 2^n "vx_acc_cres[%5d,%s,%2d]: %5d%s"
1778 + "vx_cres_avail[%5d,%s,%2d]: %5ld > %5d + %5d"
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.1/arch/alpha/Kconfig linux-3.1-vs2.3.1-rc2/arch/alpha/Kconfig
1784 --- linux-3.1/arch/alpha/Kconfig 2011-10-24 18:44:54.000000000 +0200
1785 +++ linux-3.1-vs2.3.1-rc2/arch/alpha/Kconfig 2011-10-24 18:53:33.000000000 +0200
1786 @@ -670,6 +670,8 @@ config DUMMY_CONSOLE
1790 +source "kernel/vserver/Kconfig"
1792 source "security/Kconfig"
1794 source "crypto/Kconfig"
1795 diff -NurpP --minimal linux-3.1/arch/alpha/kernel/entry.S linux-3.1-vs2.3.1-rc2/arch/alpha/kernel/entry.S
1796 --- linux-3.1/arch/alpha/kernel/entry.S 2010-10-21 13:06:45.000000000 +0200
1797 +++ linux-3.1-vs2.3.1-rc2/arch/alpha/kernel/entry.S 2011-10-24 18:53:33.000000000 +0200
1798 @@ -860,24 +860,15 @@ sys_getxgid:
1805 - ldq $2, TI_TASK($8)
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)
1816 - ldq $3, TASK_GROUP_LEADER($2)
1817 - ldq $4, TASK_REAL_PARENT($3)
1823 + jsr $26, do_getxpid
1830 diff -NurpP --minimal linux-3.1/arch/alpha/kernel/ptrace.c linux-3.1-vs2.3.1-rc2/arch/alpha/kernel/ptrace.c
1831 --- linux-3.1/arch/alpha/kernel/ptrace.c 2011-01-05 21:48:40.000000000 +0100
1832 +++ linux-3.1-vs2.3.1-rc2/arch/alpha/kernel/ptrace.c 2011-10-24 18:53:33.000000000 +0200
1834 #include <linux/user.h>
1835 #include <linux/security.h>
1836 #include <linux/signal.h>
1837 +#include <linux/vs_base.h>
1839 #include <asm/uaccess.h>
1840 #include <asm/pgtable.h>
1841 diff -NurpP --minimal linux-3.1/arch/alpha/kernel/systbls.S linux-3.1-vs2.3.1-rc2/arch/alpha/kernel/systbls.S
1842 --- linux-3.1/arch/alpha/kernel/systbls.S 2011-10-24 18:44:54.000000000 +0200
1843 +++ linux-3.1-vs2.3.1-rc2/arch/alpha/kernel/systbls.S 2011-10-24 18:53:33.000000000 +0200
1844 @@ -446,7 +446,7 @@ sys_call_table:
1845 .quad sys_stat64 /* 425 */
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.1/arch/alpha/kernel/traps.c linux-3.1-vs2.3.1-rc2/arch/alpha/kernel/traps.c
1854 --- linux-3.1/arch/alpha/kernel/traps.c 2010-10-21 13:06:46.000000000 +0200
1855 +++ linux-3.1-vs2.3.1-rc2/arch/alpha/kernel/traps.c 2011-10-24 18:53:33.000000000 +0200
1856 @@ -183,7 +183,8 @@ die_if_kernel(char * str, struct pt_regs
1858 printk("CPU %d ", hard_smp_processor_id());
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.1/arch/arm/Kconfig linux-3.1-vs2.3.1-rc2/arch/arm/Kconfig
1867 --- linux-3.1/arch/arm/Kconfig 2011-10-24 18:44:54.000000000 +0200
1868 +++ linux-3.1-vs2.3.1-rc2/arch/arm/Kconfig 2011-10-24 18:53:33.000000000 +0200
1869 @@ -2111,6 +2111,8 @@ source "fs/Kconfig"
1871 source "arch/arm/Kconfig.debug"
1873 +source "kernel/vserver/Kconfig"
1875 source "security/Kconfig"
1877 source "crypto/Kconfig"
1878 diff -NurpP --minimal linux-3.1/arch/arm/kernel/calls.S linux-3.1-vs2.3.1-rc2/arch/arm/kernel/calls.S
1879 --- linux-3.1/arch/arm/kernel/calls.S 2011-10-24 18:44:54.000000000 +0200
1880 +++ linux-3.1-vs2.3.1-rc2/arch/arm/kernel/calls.S 2011-10-24 18:53:33.000000000 +0200
1882 /* 310 */ CALL(sys_request_key)
1884 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
1885 -/* vserver */ CALL(sys_ni_syscall)
1887 CALL(sys_ioprio_set)
1888 /* 315 */ CALL(sys_ioprio_get)
1889 CALL(sys_inotify_init)
1890 diff -NurpP --minimal linux-3.1/arch/arm/kernel/process.c linux-3.1-vs2.3.1-rc2/arch/arm/kernel/process.c
1891 --- linux-3.1/arch/arm/kernel/process.c 2011-10-24 18:44:54.000000000 +0200
1892 +++ linux-3.1-vs2.3.1-rc2/arch/arm/kernel/process.c 2011-10-24 18:53:33.000000000 +0200
1893 @@ -317,7 +317,8 @@ void __show_regs(struct pt_regs *regs)
1894 void show_regs(struct pt_regs * regs)
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);
1903 diff -NurpP --minimal linux-3.1/arch/arm/kernel/traps.c linux-3.1-vs2.3.1-rc2/arch/arm/kernel/traps.c
1904 --- linux-3.1/arch/arm/kernel/traps.c 2011-10-24 18:44:54.000000000 +0200
1905 +++ linux-3.1-vs2.3.1-rc2/arch/arm/kernel/traps.c 2011-10-24 18:53:33.000000000 +0200
1906 @@ -242,8 +242,8 @@ static int __die(const char *str, int er
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);
1915 if (!user_mode(regs) || in_interrupt()) {
1916 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
1917 diff -NurpP --minimal linux-3.1/arch/cris/Kconfig linux-3.1-vs2.3.1-rc2/arch/cris/Kconfig
1918 --- linux-3.1/arch/cris/Kconfig 2011-07-22 11:17:35.000000000 +0200
1919 +++ linux-3.1-vs2.3.1-rc2/arch/cris/Kconfig 2011-10-24 18:53:33.000000000 +0200
1920 @@ -678,6 +678,8 @@ source "drivers/staging/Kconfig"
1922 source "arch/cris/Kconfig.debug"
1924 +source "kernel/vserver/Kconfig"
1926 source "security/Kconfig"
1928 source "crypto/Kconfig"
1929 diff -NurpP --minimal linux-3.1/arch/frv/kernel/kernel_thread.S linux-3.1-vs2.3.1-rc2/arch/frv/kernel/kernel_thread.S
1930 --- linux-3.1/arch/frv/kernel/kernel_thread.S 2008-12-25 00:26:37.000000000 +0100
1931 +++ linux-3.1-vs2.3.1-rc2/arch/frv/kernel/kernel_thread.S 2011-10-24 18:53:33.000000000 +0200
1932 @@ -37,7 +37,7 @@ kernel_thread:
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]
1940 setlos.p #0,gr10 ; third syscall arg [parent_tidptr]
1941 diff -NurpP --minimal linux-3.1/arch/h8300/Kconfig linux-3.1-vs2.3.1-rc2/arch/h8300/Kconfig
1942 --- linux-3.1/arch/h8300/Kconfig 2011-07-22 11:17:35.000000000 +0200
1943 +++ linux-3.1-vs2.3.1-rc2/arch/h8300/Kconfig 2011-10-24 18:53:33.000000000 +0200
1944 @@ -213,6 +213,8 @@ source "fs/Kconfig"
1946 source "arch/h8300/Kconfig.debug"
1948 +source "kernel/vserver/Kconfig"
1950 source "security/Kconfig"
1952 source "crypto/Kconfig"
1953 diff -NurpP --minimal linux-3.1/arch/ia64/Kconfig linux-3.1-vs2.3.1-rc2/arch/ia64/Kconfig
1954 --- linux-3.1/arch/ia64/Kconfig 2011-10-24 18:44:58.000000000 +0200
1955 +++ linux-3.1-vs2.3.1-rc2/arch/ia64/Kconfig 2011-10-24 18:53:33.000000000 +0200
1956 @@ -657,6 +657,8 @@ source "fs/Kconfig"
1958 source "arch/ia64/Kconfig.debug"
1960 +source "kernel/vserver/Kconfig"
1962 source "security/Kconfig"
1964 source "crypto/Kconfig"
1965 diff -NurpP --minimal linux-3.1/arch/ia64/include/asm/tlb.h linux-3.1-vs2.3.1-rc2/arch/ia64/include/asm/tlb.h
1966 --- linux-3.1/arch/ia64/include/asm/tlb.h 2011-07-22 11:17:35.000000000 +0200
1967 +++ linux-3.1-vs2.3.1-rc2/arch/ia64/include/asm/tlb.h 2011-10-24 18:53:33.000000000 +0200
1969 #include <linux/mm.h>
1970 #include <linux/pagemap.h>
1971 #include <linux/swap.h>
1972 +#include <linux/vs_memory.h>
1974 #include <asm/pgalloc.h>
1975 #include <asm/processor.h>
1976 diff -NurpP --minimal linux-3.1/arch/ia64/kernel/entry.S linux-3.1-vs2.3.1-rc2/arch/ia64/kernel/entry.S
1977 --- linux-3.1/arch/ia64/kernel/entry.S 2011-10-24 18:44:58.000000000 +0200
1978 +++ linux-3.1-vs2.3.1-rc2/arch/ia64/kernel/entry.S 2011-10-24 18:53:33.000000000 +0200
1979 @@ -1714,7 +1714,7 @@ sys_call_table:
1981 data8 sys_mq_getsetattr
1982 data8 sys_kexec_load
1983 - data8 sys_ni_syscall // reserved for vserver
1985 data8 sys_waitid // 1270
1987 data8 sys_request_key
1988 diff -NurpP --minimal linux-3.1/arch/ia64/kernel/perfmon.c linux-3.1-vs2.3.1-rc2/arch/ia64/kernel/perfmon.c
1989 --- linux-3.1/arch/ia64/kernel/perfmon.c 2011-03-15 18:06:39.000000000 +0100
1990 +++ linux-3.1-vs2.3.1-rc2/arch/ia64/kernel/perfmon.c 2011-10-24 18:53:33.000000000 +0200
1992 #include <linux/completion.h>
1993 #include <linux/tracehook.h>
1994 #include <linux/slab.h>
1995 +#include <linux/vs_memory.h>
1997 #include <asm/errno.h>
1998 #include <asm/intrinsics.h>
1999 diff -NurpP --minimal linux-3.1/arch/ia64/kernel/process.c linux-3.1-vs2.3.1-rc2/arch/ia64/kernel/process.c
2000 --- linux-3.1/arch/ia64/kernel/process.c 2011-03-15 18:06:39.000000000 +0100
2001 +++ linux-3.1-vs2.3.1-rc2/arch/ia64/kernel/process.c 2011-10-24 18:53:33.000000000 +0200
2002 @@ -109,8 +109,8 @@ show_regs (struct pt_regs *regs)
2003 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
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.1/arch/ia64/kernel/ptrace.c linux-3.1-vs2.3.1-rc2/arch/ia64/kernel/ptrace.c
2014 --- linux-3.1/arch/ia64/kernel/ptrace.c 2011-01-05 21:48:59.000000000 +0100
2015 +++ linux-3.1-vs2.3.1-rc2/arch/ia64/kernel/ptrace.c 2011-10-24 18:53:33.000000000 +0200
2017 #include <linux/regset.h>
2018 #include <linux/elf.h>
2019 #include <linux/tracehook.h>
2020 +#include <linux/vs_base.h>
2022 #include <asm/pgtable.h>
2023 #include <asm/processor.h>
2024 diff -NurpP --minimal linux-3.1/arch/ia64/kernel/traps.c linux-3.1-vs2.3.1-rc2/arch/ia64/kernel/traps.c
2025 --- linux-3.1/arch/ia64/kernel/traps.c 2010-07-07 18:31:01.000000000 +0200
2026 +++ linux-3.1-vs2.3.1-rc2/arch/ia64/kernel/traps.c 2011-10-24 18:53:33.000000000 +0200
2027 @@ -59,8 +59,9 @@ die (const char *str, struct pt_regs *re
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)
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;
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);
2051 diff -NurpP --minimal linux-3.1/arch/ia64/mm/fault.c linux-3.1-vs2.3.1-rc2/arch/ia64/mm/fault.c
2052 --- linux-3.1/arch/ia64/mm/fault.c 2011-07-22 11:17:35.000000000 +0200
2053 +++ linux-3.1-vs2.3.1-rc2/arch/ia64/mm/fault.c 2011-10-24 18:53:33.000000000 +0200
2055 #include <linux/kprobes.h>
2056 #include <linux/kdebug.h>
2057 #include <linux/prefetch.h>
2058 +#include <linux/vs_memory.h>
2060 #include <asm/pgtable.h>
2061 #include <asm/processor.h>
2062 diff -NurpP --minimal linux-3.1/arch/m32r/kernel/traps.c linux-3.1-vs2.3.1-rc2/arch/m32r/kernel/traps.c
2063 --- linux-3.1/arch/m32r/kernel/traps.c 2011-10-24 18:44:58.000000000 +0200
2064 +++ linux-3.1-vs2.3.1-rc2/arch/m32r/kernel/traps.c 2011-10-24 18:53:33.000000000 +0200
2065 @@ -196,8 +196,9 @@ static void show_registers(struct pt_reg
2067 printk("SPI: %08lx\n", sp);
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);
2076 * When in-kernel, we also print out the stack and code at the
2077 diff -NurpP --minimal linux-3.1/arch/m68k/Kconfig linux-3.1-vs2.3.1-rc2/arch/m68k/Kconfig
2078 --- linux-3.1/arch/m68k/Kconfig 2011-10-24 18:44:58.000000000 +0200
2079 +++ linux-3.1-vs2.3.1-rc2/arch/m68k/Kconfig 2011-10-24 18:53:33.000000000 +0200
2080 @@ -246,6 +246,8 @@ source "fs/Kconfig"
2082 source "arch/m68k/Kconfig.debug"
2084 +source "kernel/vserver/Kconfig"
2086 source "security/Kconfig"
2088 source "crypto/Kconfig"
2089 diff -NurpP --minimal linux-3.1/arch/mips/Kconfig linux-3.1-vs2.3.1-rc2/arch/mips/Kconfig
2090 --- linux-3.1/arch/mips/Kconfig 2011-10-24 18:44:59.000000000 +0200
2091 +++ linux-3.1-vs2.3.1-rc2/arch/mips/Kconfig 2011-10-24 18:53:33.000000000 +0200
2092 @@ -2495,6 +2495,8 @@ source "fs/Kconfig"
2094 source "arch/mips/Kconfig.debug"
2096 +source "kernel/vserver/Kconfig"
2098 source "security/Kconfig"
2100 source "crypto/Kconfig"
2101 diff -NurpP --minimal linux-3.1/arch/mips/kernel/ptrace.c linux-3.1-vs2.3.1-rc2/arch/mips/kernel/ptrace.c
2102 --- linux-3.1/arch/mips/kernel/ptrace.c 2011-07-22 11:17:36.000000000 +0200
2103 +++ linux-3.1-vs2.3.1-rc2/arch/mips/kernel/ptrace.c 2011-10-24 18:53:33.000000000 +0200
2105 #include <linux/security.h>
2106 #include <linux/audit.h>
2107 #include <linux/seccomp.h>
2108 +#include <linux/vs_base.h>
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;
2116 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
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.1/arch/mips/kernel/scall32-o32.S linux-3.1-vs2.3.1-rc2/arch/mips/kernel/scall32-o32.S
2123 --- linux-3.1/arch/mips/kernel/scall32-o32.S 2011-10-24 18:44:59.000000000 +0200
2124 +++ linux-3.1-vs2.3.1-rc2/arch/mips/kernel/scall32-o32.S 2011-10-24 18:53:33.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 */
2132 sys sys_ni_syscall 0 /* available, was setaltroot */
2133 sys sys_add_key 5 /* 4280 */
2134 diff -NurpP --minimal linux-3.1/arch/mips/kernel/scall64-64.S linux-3.1-vs2.3.1-rc2/arch/mips/kernel/scall64-64.S
2135 --- linux-3.1/arch/mips/kernel/scall64-64.S 2011-10-24 18:44:59.000000000 +0200
2136 +++ linux-3.1-vs2.3.1-rc2/arch/mips/kernel/scall64-64.S 2011-10-24 18:53:33.000000000 +0200
2137 @@ -362,7 +362,7 @@ sys_call_table:
2138 PTR sys_mq_timedreceive
2140 PTR sys_mq_getsetattr /* 5235 */
2141 - PTR sys_ni_syscall /* sys_vserver */
2144 PTR sys_ni_syscall /* available, was setaltroot */
2146 diff -NurpP --minimal linux-3.1/arch/mips/kernel/scall64-n32.S linux-3.1-vs2.3.1-rc2/arch/mips/kernel/scall64-n32.S
2147 --- linux-3.1/arch/mips/kernel/scall64-n32.S 2011-10-24 18:44:59.000000000 +0200
2148 +++ linux-3.1-vs2.3.1-rc2/arch/mips/kernel/scall64-n32.S 2011-10-24 18:53:33.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 */
2158 diff -NurpP --minimal linux-3.1/arch/mips/kernel/scall64-o32.S linux-3.1-vs2.3.1-rc2/arch/mips/kernel/scall64-o32.S
2159 --- linux-3.1/arch/mips/kernel/scall64-o32.S 2011-10-24 18:44:59.000000000 +0200
2160 +++ linux-3.1-vs2.3.1-rc2/arch/mips/kernel/scall64-o32.S 2011-10-24 18:53:33.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 */
2168 PTR sys_ni_syscall /* available, was setaltroot */
2169 PTR sys_add_key /* 4280 */
2170 diff -NurpP --minimal linux-3.1/arch/mips/kernel/traps.c linux-3.1-vs2.3.1-rc2/arch/mips/kernel/traps.c
2171 --- linux-3.1/arch/mips/kernel/traps.c 2011-10-24 18:44:59.000000000 +0200
2172 +++ linux-3.1-vs2.3.1-rc2/arch/mips/kernel/traps.c 2011-10-24 18:53:33.000000000 +0200
2173 @@ -344,9 +344,10 @@ void show_registers(struct pt_regs *regs
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) {
2187 diff -NurpP --minimal linux-3.1/arch/parisc/Kconfig linux-3.1-vs2.3.1-rc2/arch/parisc/Kconfig
2188 --- linux-3.1/arch/parisc/Kconfig 2011-10-24 18:44:59.000000000 +0200
2189 +++ linux-3.1-vs2.3.1-rc2/arch/parisc/Kconfig 2011-10-24 18:53:33.000000000 +0200
2190 @@ -280,6 +280,8 @@ source "fs/Kconfig"
2192 source "arch/parisc/Kconfig.debug"
2194 +source "kernel/vserver/Kconfig"
2196 source "security/Kconfig"
2198 source "crypto/Kconfig"
2199 diff -NurpP --minimal linux-3.1/arch/parisc/kernel/syscall_table.S linux-3.1-vs2.3.1-rc2/arch/parisc/kernel/syscall_table.S
2200 --- linux-3.1/arch/parisc/kernel/syscall_table.S 2011-10-24 18:45:00.000000000 +0200
2201 +++ linux-3.1-vs2.3.1-rc2/arch/parisc/kernel/syscall_table.S 2011-10-24 18:53:33.000000000 +0200
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)
2209 ENTRY_SAME(request_key) /* 265 */
2211 diff -NurpP --minimal linux-3.1/arch/parisc/kernel/traps.c linux-3.1-vs2.3.1-rc2/arch/parisc/kernel/traps.c
2212 --- linux-3.1/arch/parisc/kernel/traps.c 2011-10-24 18:45:00.000000000 +0200
2213 +++ linux-3.1-vs2.3.1-rc2/arch/parisc/kernel/traps.c 2011-10-24 18:53:33.000000000 +0200
2214 @@ -236,8 +236,9 @@ void die_if_kernel(char *str, struct pt_
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 */
2226 @@ -270,8 +271,8 @@ void die_if_kernel(char *str, struct pt_
2227 pdc_console_restart();
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);
2235 /* Wot's wrong wif bein' racy? */
2236 if (current->thread.flags & PARISC_KERNEL_DEATH) {
2237 diff -NurpP --minimal linux-3.1/arch/parisc/mm/fault.c linux-3.1-vs2.3.1-rc2/arch/parisc/mm/fault.c
2238 --- linux-3.1/arch/parisc/mm/fault.c 2010-08-02 16:52:06.000000000 +0200
2239 +++ linux-3.1-vs2.3.1-rc2/arch/parisc/mm/fault.c 2011-10-24 18:53:33.000000000 +0200
2240 @@ -237,8 +237,9 @@ bad_area:
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);
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.1/arch/powerpc/Kconfig linux-3.1-vs2.3.1-rc2/arch/powerpc/Kconfig
2253 --- linux-3.1/arch/powerpc/Kconfig 2011-10-24 18:45:00.000000000 +0200
2254 +++ linux-3.1-vs2.3.1-rc2/arch/powerpc/Kconfig 2011-10-24 18:53:33.000000000 +0200
2255 @@ -981,6 +981,8 @@ source "lib/Kconfig"
2257 source "arch/powerpc/Kconfig.debug"
2259 +source "kernel/vserver/Kconfig"
2261 source "security/Kconfig"
2264 diff -NurpP --minimal linux-3.1/arch/powerpc/include/asm/unistd.h linux-3.1-vs2.3.1-rc2/arch/powerpc/include/asm/unistd.h
2265 --- linux-3.1/arch/powerpc/include/asm/unistd.h 2011-07-22 11:17:40.000000000 +0200
2266 +++ linux-3.1-vs2.3.1-rc2/arch/powerpc/include/asm/unistd.h 2011-10-24 18:53:33.000000000 +0200
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.1/arch/powerpc/kernel/process.c linux-3.1-vs2.3.1-rc2/arch/powerpc/kernel/process.c
2277 --- linux-3.1/arch/powerpc/kernel/process.c 2011-10-24 18:45:00.000000000 +0200
2278 +++ linux-3.1-vs2.3.1-rc2/arch/powerpc/kernel/process.c 2011-10-24 18:53:33.000000000 +0200
2279 @@ -662,8 +662,9 @@ void show_regs(struct pt_regs * regs)
2281 printk("DAR: "REG", DSISR: %08lx\n", regs->dar, regs->dsisr);
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));
2290 printk(" CPU: %d", raw_smp_processor_id());
2291 diff -NurpP --minimal linux-3.1/arch/powerpc/kernel/traps.c linux-3.1-vs2.3.1-rc2/arch/powerpc/kernel/traps.c
2292 --- linux-3.1/arch/powerpc/kernel/traps.c 2011-10-24 18:45:00.000000000 +0200
2293 +++ linux-3.1-vs2.3.1-rc2/arch/powerpc/kernel/traps.c 2011-10-24 18:53:33.000000000 +0200
2294 @@ -1075,8 +1075,9 @@ void nonrecoverable_exception(struct pt_
2296 void trace_syscall(struct pt_regs *regs)
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());
2306 diff -NurpP --minimal linux-3.1/arch/powerpc/kernel/vdso.c linux-3.1-vs2.3.1-rc2/arch/powerpc/kernel/vdso.c
2307 --- linux-3.1/arch/powerpc/kernel/vdso.c 2011-05-22 16:17:02.000000000 +0200
2308 +++ linux-3.1-vs2.3.1-rc2/arch/powerpc/kernel/vdso.c 2011-10-24 18:53:33.000000000 +0200
2310 #include <linux/security.h>
2311 #include <linux/bootmem.h>
2312 #include <linux/memblock.h>
2313 +#include <linux/vs_memory.h>
2315 #include <asm/pgtable.h>
2316 #include <asm/system.h>
2317 diff -NurpP --minimal linux-3.1/arch/s390/Kconfig linux-3.1-vs2.3.1-rc2/arch/s390/Kconfig
2318 --- linux-3.1/arch/s390/Kconfig 2011-10-24 18:45:01.000000000 +0200
2319 +++ linux-3.1-vs2.3.1-rc2/arch/s390/Kconfig 2011-10-24 18:53:33.000000000 +0200
2320 @@ -629,6 +629,8 @@ source "fs/Kconfig"
2322 source "arch/s390/Kconfig.debug"
2324 +source "kernel/vserver/Kconfig"
2326 source "security/Kconfig"
2328 source "crypto/Kconfig"
2329 diff -NurpP --minimal linux-3.1/arch/s390/include/asm/tlb.h linux-3.1-vs2.3.1-rc2/arch/s390/include/asm/tlb.h
2330 --- linux-3.1/arch/s390/include/asm/tlb.h 2011-07-22 11:17:41.000000000 +0200
2331 +++ linux-3.1-vs2.3.1-rc2/arch/s390/include/asm/tlb.h 2011-10-24 18:53:33.000000000 +0200
2333 #include <linux/mm.h>
2334 #include <linux/pagemap.h>
2335 #include <linux/swap.h>
2336 +#include <linux/vs_memory.h>
2338 #include <asm/processor.h>
2339 #include <asm/pgalloc.h>
2340 #include <asm/tlbflush.h>
2341 diff -NurpP --minimal linux-3.1/arch/s390/include/asm/unistd.h linux-3.1-vs2.3.1-rc2/arch/s390/include/asm/unistd.h
2342 --- linux-3.1/arch/s390/include/asm/unistd.h 2011-07-22 11:17:41.000000000 +0200
2343 +++ linux-3.1-vs2.3.1-rc2/arch/s390/include/asm/unistd.h 2011-10-24 18:53:33.000000000 +0200
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.1/arch/s390/kernel/ptrace.c linux-3.1-vs2.3.1-rc2/arch/s390/kernel/ptrace.c
2354 --- linux-3.1/arch/s390/kernel/ptrace.c 2011-03-15 18:06:45.000000000 +0100
2355 +++ linux-3.1-vs2.3.1-rc2/arch/s390/kernel/ptrace.c 2011-10-24 18:53:33.000000000 +0200
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.1/arch/s390/kernel/syscalls.S linux-3.1-vs2.3.1-rc2/arch/s390/kernel/syscalls.S
2365 --- linux-3.1/arch/s390/kernel/syscalls.S 2011-10-24 18:45:01.000000000 +0200
2366 +++ linux-3.1-vs2.3.1-rc2/arch/s390/kernel/syscalls.S 2011-10-24 18:53:33.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.1/arch/sh/Kconfig linux-3.1-vs2.3.1-rc2/arch/sh/Kconfig
2377 --- linux-3.1/arch/sh/Kconfig 2011-10-24 18:45:01.000000000 +0200
2378 +++ linux-3.1-vs2.3.1-rc2/arch/sh/Kconfig 2011-10-24 18:53:33.000000000 +0200
2379 @@ -894,6 +894,8 @@ source "fs/Kconfig"
2381 source "arch/sh/Kconfig.debug"
2383 +source "kernel/vserver/Kconfig"
2385 source "security/Kconfig"
2387 source "crypto/Kconfig"
2388 diff -NurpP --minimal linux-3.1/arch/sh/kernel/irq.c linux-3.1-vs2.3.1-rc2/arch/sh/kernel/irq.c
2389 --- linux-3.1/arch/sh/kernel/irq.c 2011-07-22 11:17:41.000000000 +0200
2390 +++ linux-3.1-vs2.3.1-rc2/arch/sh/kernel/irq.c 2011-10-24 18:53:33.000000000 +0200
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.1/arch/sh/kernel/vsyscall/vsyscall.c linux-3.1-vs2.3.1-rc2/arch/sh/kernel/vsyscall/vsyscall.c
2400 --- linux-3.1/arch/sh/kernel/vsyscall/vsyscall.c 2011-05-22 16:17:07.000000000 +0200
2401 +++ linux-3.1-vs2.3.1-rc2/arch/sh/kernel/vsyscall/vsyscall.c 2011-10-24 18:53:33.000000000 +0200
2403 #include <linux/elf.h>
2404 #include <linux/sched.h>
2405 #include <linux/err.h>
2406 +#include <linux/vs_memory.h>
2409 * Should the kernel map a VDSO page into processes and pass its
2410 diff -NurpP --minimal linux-3.1/arch/sparc/Kconfig linux-3.1-vs2.3.1-rc2/arch/sparc/Kconfig
2411 --- linux-3.1/arch/sparc/Kconfig 2011-10-24 18:45:02.000000000 +0200
2412 +++ linux-3.1-vs2.3.1-rc2/arch/sparc/Kconfig 2011-10-24 18:53:33.000000000 +0200
2413 @@ -600,6 +600,8 @@ source "fs/Kconfig"
2415 source "arch/sparc/Kconfig.debug"
2417 +source "kernel/vserver/Kconfig"
2419 source "security/Kconfig"
2421 source "crypto/Kconfig"
2422 diff -NurpP --minimal linux-3.1/arch/sparc/include/asm/tlb_64.h linux-3.1-vs2.3.1-rc2/arch/sparc/include/asm/tlb_64.h
2423 --- linux-3.1/arch/sparc/include/asm/tlb_64.h 2011-07-22 11:17:42.000000000 +0200
2424 +++ linux-3.1-vs2.3.1-rc2/arch/sparc/include/asm/tlb_64.h 2011-10-24 18:53:33.000000000 +0200
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.1/arch/sparc/include/asm/unistd.h linux-3.1-vs2.3.1-rc2/arch/sparc/include/asm/unistd.h
2434 --- linux-3.1/arch/sparc/include/asm/unistd.h 2011-07-22 11:17:42.000000000 +0200
2435 +++ linux-3.1-vs2.3.1-rc2/arch/sparc/include/asm/unistd.h 2011-10-24 18:53:33.000000000 +0200
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.1/arch/sparc/kernel/systbls_32.S linux-3.1-vs2.3.1-rc2/arch/sparc/kernel/systbls_32.S
2446 --- linux-3.1/arch/sparc/kernel/systbls_32.S 2011-10-24 18:45:02.000000000 +0200
2447 +++ linux-3.1-vs2.3.1-rc2/arch/sparc/kernel/systbls_32.S 2011-10-24 18:53:33.000000000 +0200
2448 @@ -70,7 +70,7 @@ sys_call_table:
2449 /*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_ni_syscall
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.1/arch/sparc/kernel/systbls_64.S linux-3.1-vs2.3.1-rc2/arch/sparc/kernel/systbls_64.S
2458 --- linux-3.1/arch/sparc/kernel/systbls_64.S 2011-10-24 18:45:02.000000000 +0200
2459 +++ linux-3.1-vs2.3.1-rc2/arch/sparc/kernel/systbls_64.S 2011-10-24 18:53:33.000000000 +0200
2460 @@ -71,7 +71,7 @@ sys_call_table32:
2461 /*250*/ .word sys_mremap, compat_sys_sysctl, sys32_getsid, sys_fdatasync, sys_nis_syscall
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_nis_syscall
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.1/arch/um/Kconfig.rest linux-3.1-vs2.3.1-rc2/arch/um/Kconfig.rest
2479 --- linux-3.1/arch/um/Kconfig.rest 2009-06-11 17:12:19.000000000 +0200
2480 +++ linux-3.1-vs2.3.1-rc2/arch/um/Kconfig.rest 2011-10-24 18:53:33.000000000 +0200
2481 @@ -18,6 +18,8 @@ source "drivers/connector/Kconfig"
2485 +source "kernel/vserver/Kconfig"
2487 source "security/Kconfig"
2489 source "crypto/Kconfig"
2490 diff -NurpP --minimal linux-3.1/arch/um/include/asm/tlb.h linux-3.1-vs2.3.1-rc2/arch/um/include/asm/tlb.h
2491 --- linux-3.1/arch/um/include/asm/tlb.h 2011-07-22 11:17:42.000000000 +0200
2492 +++ linux-3.1-vs2.3.1-rc2/arch/um/include/asm/tlb.h 2011-10-24 18:53:33.000000000 +0200
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.1/arch/um/include/shared/kern_constants.h linux-3.1-vs2.3.1-rc2/arch/um/include/shared/kern_constants.h
2502 --- linux-3.1/arch/um/include/shared/kern_constants.h 1970-01-01 01:00:00.000000000 +0100
2503 +++ linux-3.1-vs2.3.1-rc2/arch/um/include/shared/kern_constants.h 2011-10-24 18:53:33.000000000 +0200
2505 +#include "../../../../include/generated/asm-offsets.h"
2506 diff -NurpP --minimal linux-3.1/arch/um/include/shared/user_constants.h linux-3.1-vs2.3.1-rc2/arch/um/include/shared/user_constants.h
2507 --- linux-3.1/arch/um/include/shared/user_constants.h 1970-01-01 01:00:00.000000000 +0100
2508 +++ linux-3.1-vs2.3.1-rc2/arch/um/include/shared/user_constants.h 2011-10-24 18:53:33.000000000 +0200
2513 + * This file was generated by arch/um/Makefile
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 # */
2550 diff -NurpP --minimal linux-3.1/arch/x86/Kconfig linux-3.1-vs2.3.1-rc2/arch/x86/Kconfig
2551 --- linux-3.1/arch/x86/Kconfig 2011-10-24 18:45:06.000000000 +0200
2552 +++ linux-3.1-vs2.3.1-rc2/arch/x86/Kconfig 2011-10-24 18:53:33.000000000 +0200
2553 @@ -2144,6 +2144,8 @@ source "fs/Kconfig"
2555 source "arch/x86/Kconfig.debug"
2557 +source "kernel/vserver/Kconfig"
2559 source "security/Kconfig"
2561 source "crypto/Kconfig"
2562 diff -NurpP --minimal linux-3.1/arch/x86/ia32/ia32entry.S linux-3.1-vs2.3.1-rc2/arch/x86/ia32/ia32entry.S
2563 --- linux-3.1/arch/x86/ia32/ia32entry.S 2011-10-24 18:45:06.000000000 +0200
2564 +++ linux-3.1-vs2.3.1-rc2/arch/x86/ia32/ia32entry.S 2011-10-24 18:53:33.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
2572 .quad compat_sys_get_mempolicy /* 275 */
2573 .quad sys_set_mempolicy
2574 diff -NurpP --minimal linux-3.1/arch/x86/include/asm/unistd_64.h linux-3.1-vs2.3.1-rc2/arch/x86/include/asm/unistd_64.h
2575 --- linux-3.1/arch/x86/include/asm/unistd_64.h 2011-10-24 18:45:07.000000000 +0200
2576 +++ linux-3.1-vs2.3.1-rc2/arch/x86/include/asm/unistd_64.h 2011-10-24 18:53:33.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.1/arch/x86/kernel/syscall_table_32.S linux-3.1-vs2.3.1-rc2/arch/x86/kernel/syscall_table_32.S
2587 --- linux-3.1/arch/x86/kernel/syscall_table_32.S 2011-10-24 18:45:07.000000000 +0200
2588 +++ linux-3.1-vs2.3.1-rc2/arch/x86/kernel/syscall_table_32.S 2011-10-24 18:53:33.000000000 +0200
2589 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
2590 .long sys_tgkill /* 270 */
2592 .long sys_fadvise64_64
2593 - .long sys_ni_syscall /* sys_vserver */
2596 .long sys_get_mempolicy
2597 .long sys_set_mempolicy
2598 diff -NurpP --minimal linux-3.1/drivers/block/Kconfig linux-3.1-vs2.3.1-rc2/drivers/block/Kconfig
2599 --- linux-3.1/drivers/block/Kconfig 2011-10-24 18:45:08.000000000 +0200
2600 +++ linux-3.1-vs2.3.1-rc2/drivers/block/Kconfig 2011-10-24 18:53:33.000000000 +0200
2601 @@ -288,6 +288,13 @@ config BLK_DEV_CRYPTOLOOP
2603 source "drivers/block/drbd/Kconfig"
2605 +config BLK_DEV_VROOT
2606 + tristate "Virtual Root device support"
2607 + depends on QUOTACTL
2609 + Saying Y here will allow you to use quota/fs ioctls on a shared
2610 + partition within a virtual server without compromising security.
2613 tristate "Network block device support"
2615 diff -NurpP --minimal linux-3.1/drivers/block/Makefile linux-3.1-vs2.3.1-rc2/drivers/block/Makefile
2616 --- linux-3.1/drivers/block/Makefile 2011-07-22 11:17:44.000000000 +0200
2617 +++ linux-3.1-vs2.3.1-rc2/drivers/block/Makefile 2011-10-24 18:53:33.000000000 +0200
2618 @@ -34,6 +34,7 @@ obj-$(CONFIG_VIODASD) += viodasd.o
2619 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
2620 obj-$(CONFIG_BLK_DEV_UB) += ub.o
2621 obj-$(CONFIG_BLK_DEV_HD) += hd.o
2622 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
2624 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
2625 obj-$(CONFIG_XEN_BLKDEV_BACKEND) += xen-blkback/
2626 diff -NurpP --minimal linux-3.1/drivers/block/loop.c linux-3.1-vs2.3.1-rc2/drivers/block/loop.c
2627 --- linux-3.1/drivers/block/loop.c 2011-10-24 18:45:08.000000000 +0200
2628 +++ linux-3.1-vs2.3.1-rc2/drivers/block/loop.c 2011-10-24 18:53:33.000000000 +0200
2630 #include <linux/splice.h>
2631 #include <linux/sysfs.h>
2632 #include <linux/miscdevice.h>
2633 +#include <linux/vs_context.h>
2634 #include <asm/uaccess.h>
2636 static DEFINE_IDR(loop_index_idr);
2637 @@ -884,6 +885,7 @@ static int loop_set_fd(struct loop_devic
2638 lo->lo_blocksize = lo_blocksize;
2639 lo->lo_device = bdev;
2640 lo->lo_flags = lo_flags;
2641 + lo->lo_xid = vx_current_xid();
2642 lo->lo_backing_file = file;
2643 lo->transfer = transfer_none;
2645 @@ -1014,6 +1016,7 @@ static int loop_clr_fd(struct loop_devic
2646 lo->lo_encrypt_key_size = 0;
2648 lo->lo_thread = NULL;
2650 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
2651 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
2652 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
2653 @@ -1052,7 +1055,7 @@ loop_set_status(struct loop_device *lo,
2655 if (lo->lo_encrypt_key_size &&
2656 lo->lo_key_owner != uid &&
2657 - !capable(CAP_SYS_ADMIN))
2658 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
2660 if (lo->lo_state != Lo_bound)
2662 @@ -1136,7 +1139,8 @@ loop_get_status(struct loop_device *lo,
2663 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
2664 info->lo_encrypt_type =
2665 lo->lo_encryption ? lo->lo_encryption->number : 0;
2666 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
2667 + if (lo->lo_encrypt_key_size &&
2668 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
2669 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
2670 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
2671 lo->lo_encrypt_key_size);
2672 @@ -1490,6 +1494,9 @@ static int lo_open(struct block_device *
2676 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P))
2679 mutex_lock(&lo->lo_ctl_mutex);
2681 mutex_unlock(&lo->lo_ctl_mutex);
2682 diff -NurpP --minimal linux-3.1/drivers/block/vroot.c linux-3.1-vs2.3.1-rc2/drivers/block/vroot.c
2683 --- linux-3.1/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
2684 +++ linux-3.1-vs2.3.1-rc2/drivers/block/vroot.c 2011-10-24 18:53:33.000000000 +0200
2687 + * linux/drivers/block/vroot.c
2689 + * written by Herbert Pötzl, 9/11/2002
2690 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
2692 + * based on the loop.c code by Theodore Ts'o.
2694 + * Copyright (C) 2002-2007 by Herbert Pötzl.
2695 + * Redistribution of this file is permitted under the
2696 + * GNU General Public License.
2700 +#include <linux/module.h>
2701 +#include <linux/moduleparam.h>
2702 +#include <linux/file.h>
2703 +#include <linux/major.h>
2704 +#include <linux/blkdev.h>
2705 +#include <linux/slab.h>
2707 +#include <linux/vroot.h>
2708 +#include <linux/vs_context.h>
2711 +static int max_vroot = 8;
2713 +static struct vroot_device *vroot_dev;
2714 +static struct gendisk **disks;
2717 +static int vroot_set_dev(
2718 + struct vroot_device *vr,
2719 + struct block_device *bdev,
2722 + struct block_device *real_bdev;
2723 + struct file *file;
2724 + struct inode *inode;
2728 + if (vr->vr_state != Vr_unbound)
2737 + inode = file->f_dentry->d_inode;
2740 + if (S_ISBLK(inode->i_mode)) {
2741 + real_bdev = inode->i_bdev;
2742 + vr->vr_device = real_bdev;
2743 + __iget(real_bdev->bd_inode);
2747 + vxdprintk(VXD_CBIT(misc, 0),
2748 + "vroot[%d]_set_dev: dev=" VXF_DEV,
2749 + vr->vr_number, VXD_DEV(real_bdev));
2751 + vr->vr_state = Vr_bound;
2760 +static int vroot_clr_dev(
2761 + struct vroot_device *vr,
2762 + struct block_device *bdev)
2764 + struct block_device *real_bdev;
2766 + if (vr->vr_state != Vr_bound)
2768 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
2771 + real_bdev = vr->vr_device;
2773 + vxdprintk(VXD_CBIT(misc, 0),
2774 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
2775 + vr->vr_number, VXD_DEV(real_bdev));
2778 + vr->vr_state = Vr_unbound;
2779 + vr->vr_device = NULL;
2784 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
2785 + unsigned int cmd, unsigned long arg)
2787 + struct vroot_device *vr = bdev->bd_disk->private_data;
2790 + down(&vr->vr_ctl_mutex);
2792 + case VROOT_SET_DEV:
2793 + err = vroot_set_dev(vr, bdev, arg);
2795 + case VROOT_CLR_DEV:
2796 + err = vroot_clr_dev(vr, bdev);
2802 + up(&vr->vr_ctl_mutex);
2806 +static int vr_open(struct block_device *bdev, fmode_t mode)
2808 + struct vroot_device *vr = bdev->bd_disk->private_data;
2810 + down(&vr->vr_ctl_mutex);
2812 + up(&vr->vr_ctl_mutex);
2816 +static int vr_release(struct gendisk *disk, fmode_t mode)
2818 + struct vroot_device *vr = disk->private_data;
2820 + down(&vr->vr_ctl_mutex);
2822 + up(&vr->vr_ctl_mutex);
2826 +static struct block_device_operations vr_fops = {
2827 + .owner = THIS_MODULE,
2829 + .release = vr_release,
2830 + .ioctl = vr_ioctl,
2833 +static int vroot_make_request(struct request_queue *q, struct bio *bio)
2835 + printk("vroot_make_request %p, %p\n", q, bio);
2836 + bio_io_error(bio);
2840 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
2842 + struct inode *inode = bdev->bd_inode;
2843 + struct vroot_device *vr;
2844 + struct block_device *real_bdev;
2845 + int minor = iminor(inode);
2847 + vr = &vroot_dev[minor];
2848 + real_bdev = vr->vr_device;
2850 + vxdprintk(VXD_CBIT(misc, 0),
2851 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
2852 + vr->vr_number, VXD_DEV(real_bdev));
2854 + if (vr->vr_state != Vr_bound)
2855 + return ERR_PTR(-ENXIO);
2857 + __iget(real_bdev->bd_inode);
2864 + * And now the modules code and kernel interface.
2867 +module_param(max_vroot, int, 0);
2869 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
2870 +MODULE_LICENSE("GPL");
2871 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
2873 +MODULE_AUTHOR ("Herbert Pötzl");
2874 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
2877 +int __init vroot_init(void)
2881 + if (max_vroot < 1 || max_vroot > 256) {
2882 + max_vroot = MAX_VROOT_DEFAULT;
2883 + printk(KERN_WARNING "vroot: invalid max_vroot "
2884 + "(must be between 1 and 256), "
2885 + "using default (%d)\n", max_vroot);
2888 + if (register_blkdev(VROOT_MAJOR, "vroot"))
2892 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
2895 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
2897 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
2901 + for (i = 0; i < max_vroot; i++) {
2902 + disks[i] = alloc_disk(1);
2905 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
2906 + if (!disks[i]->queue)
2908 + blk_queue_make_request(disks[i]->queue, vroot_make_request);
2911 + for (i = 0; i < max_vroot; i++) {
2912 + struct vroot_device *vr = &vroot_dev[i];
2913 + struct gendisk *disk = disks[i];
2915 + memset(vr, 0, sizeof(*vr));
2916 + sema_init(&vr->vr_ctl_mutex, 1);
2917 + vr->vr_number = i;
2918 + disk->major = VROOT_MAJOR;
2919 + disk->first_minor = i;
2920 + disk->fops = &vr_fops;
2921 + sprintf(disk->disk_name, "vroot%d", i);
2922 + disk->private_data = vr;
2925 + err = register_vroot_grb(&__vroot_get_real_bdev);
2929 + for (i = 0; i < max_vroot; i++)
2930 + add_disk(disks[i]);
2931 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
2936 + put_disk(disks[i]);
2941 + unregister_blkdev(VROOT_MAJOR, "vroot");
2942 + printk(KERN_ERR "vroot: ran out of memory\n");
2946 +void vroot_exit(void)
2950 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
2951 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
2953 + for (i = 0; i < max_vroot; i++) {
2954 + del_gendisk(disks[i]);
2955 + put_disk(disks[i]);
2957 + unregister_blkdev(VROOT_MAJOR, "vroot");
2963 +module_init(vroot_init);
2964 +module_exit(vroot_exit);
2968 +static int __init max_vroot_setup(char *str)
2970 + max_vroot = simple_strtol(str, NULL, 0);
2974 +__setup("max_vroot=", max_vroot_setup);
2978 diff -NurpP --minimal linux-3.1/drivers/infiniband/core/addr.c linux-3.1-vs2.3.1-rc2/drivers/infiniband/core/addr.c
2979 --- linux-3.1/drivers/infiniband/core/addr.c 2011-10-24 18:45:09.000000000 +0200
2980 +++ linux-3.1-vs2.3.1-rc2/drivers/infiniband/core/addr.c 2011-10-24 18:53:33.000000000 +0200
2981 @@ -252,7 +252,7 @@ static int addr6_resolve(struct sockaddr
2983 if (ipv6_addr_any(&fl6.saddr)) {
2984 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
2985 - &fl6.daddr, 0, &fl6.saddr);
2986 + &fl6.daddr, 0, &fl6.saddr, NULL);
2990 diff -NurpP --minimal linux-3.1/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-3.1-vs2.3.1-rc2/drivers/infiniband/hw/ipath/ipath_user_pages.c
2991 --- linux-3.1/drivers/infiniband/hw/ipath/ipath_user_pages.c 2011-05-22 16:17:16.000000000 +0200
2992 +++ linux-3.1-vs2.3.1-rc2/drivers/infiniband/hw/ipath/ipath_user_pages.c 2011-10-24 18:53:33.000000000 +0200
2994 #include <linux/device.h>
2995 #include <linux/slab.h>
2996 #include <linux/sched.h>
2997 +#include <linux/vs_memory.h>
2999 #include "ipath_kernel.h"
3001 diff -NurpP --minimal linux-3.1/drivers/md/dm-ioctl.c linux-3.1-vs2.3.1-rc2/drivers/md/dm-ioctl.c
3002 --- linux-3.1/drivers/md/dm-ioctl.c 2011-10-24 18:45:10.000000000 +0200
3003 +++ linux-3.1-vs2.3.1-rc2/drivers/md/dm-ioctl.c 2011-10-24 18:53:33.000000000 +0200
3005 #include <linux/dm-ioctl.h>
3006 #include <linux/hdreg.h>
3007 #include <linux/compat.h>
3008 +#include <linux/vs_context.h>
3010 #include <asm/uaccess.h>
3012 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
3013 unsigned int h = hash_str(str);
3015 list_for_each_entry (hc, _name_buckets + h, name_list)
3016 - if (!strcmp(hc->name, str)) {
3017 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
3018 + !strcmp(hc->name, str)) {
3022 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
3023 unsigned int h = hash_str(str);
3025 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
3026 - if (!strcmp(hc->uuid, str)) {
3027 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
3028 + !strcmp(hc->uuid, str)) {
3032 @@ -131,13 +134,15 @@ static struct hash_cell *__get_uuid_cell
3033 static struct hash_cell *__get_dev_cell(uint64_t dev)
3035 struct mapped_device *md;
3036 - struct hash_cell *hc;
3037 + struct hash_cell *hc = NULL;
3039 md = dm_get_md(huge_decode_dev(dev));
3043 - hc = dm_get_mdptr(md);
3044 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
3045 + hc = dm_get_mdptr(md);
3050 @@ -445,6 +450,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
3052 static int remove_all(struct dm_ioctl *param, size_t param_size)
3054 + if (!vx_check(0, VS_ADMIN))
3057 dm_hash_remove_all(1);
3058 param->data_size = 0;
3060 @@ -492,6 +500,8 @@ static int list_devices(struct dm_ioctl
3062 for (i = 0; i < NUM_BUCKETS; i++) {
3063 list_for_each_entry (hc, _name_buckets + i, name_list) {
3064 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
3066 needed += sizeof(struct dm_name_list);
3067 needed += strlen(hc->name) + 1;
3068 needed += ALIGN_MASK;
3069 @@ -515,6 +525,8 @@ static int list_devices(struct dm_ioctl
3071 for (i = 0; i < NUM_BUCKETS; i++) {
3072 list_for_each_entry (hc, _name_buckets + i, name_list) {
3073 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
3076 old_nl->next = (uint32_t) ((void *) nl -
3078 @@ -1604,8 +1616,8 @@ static int ctl_ioctl(uint command, struc
3080 size_t input_param_size;
3082 - /* only root can play with this */
3083 - if (!capable(CAP_SYS_ADMIN))
3084 + /* only root and certain contexts can play with this */
3085 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
3088 if (_IOC_TYPE(command) != DM_IOCTL)
3089 diff -NurpP --minimal linux-3.1/drivers/md/dm.c linux-3.1-vs2.3.1-rc2/drivers/md/dm.c
3090 --- linux-3.1/drivers/md/dm.c 2011-10-24 18:45:10.000000000 +0200
3091 +++ linux-3.1-vs2.3.1-rc2/drivers/md/dm.c 2011-10-24 18:53:33.000000000 +0200
3093 #include <linux/idr.h>
3094 #include <linux/hdreg.h>
3095 #include <linux/delay.h>
3096 +#include <linux/vs_base.h>
3098 #include <trace/events/block.h>
3100 @@ -122,6 +123,7 @@ struct mapped_device {
3103 atomic_t open_count;
3106 unsigned long flags;
3108 @@ -335,6 +337,7 @@ int dm_deleting_md(struct mapped_device
3109 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
3111 struct mapped_device *md;
3114 spin_lock(&_minor_lock);
3116 @@ -343,18 +346,19 @@ static int dm_blk_open(struct block_devi
3119 if (test_bit(DMF_FREEING, &md->flags) ||
3120 - dm_deleting_md(md)) {
3122 + dm_deleting_md(md))
3126 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
3131 atomic_inc(&md->open_count);
3135 spin_unlock(&_minor_lock);
3137 - return md ? 0 : -ENXIO;
3141 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
3142 @@ -575,6 +579,14 @@ int dm_set_geometry(struct mapped_device
3147 + * Get the xid associated with a dm device
3149 +xid_t dm_get_xid(struct mapped_device *md)
3154 /*-----------------------------------------------------------------
3156 * A more elegant soln is in the works that uses the queue
3157 @@ -1848,6 +1860,7 @@ static struct mapped_device *alloc_dev(i
3158 INIT_LIST_HEAD(&md->uevent_list);
3159 spin_lock_init(&md->uevent_lock);
3161 + md->xid = vx_current_xid();
3162 md->queue = blk_alloc_queue(GFP_KERNEL);
3165 diff -NurpP --minimal linux-3.1/drivers/md/dm.h linux-3.1-vs2.3.1-rc2/drivers/md/dm.h
3166 --- linux-3.1/drivers/md/dm.h 2011-10-24 18:45:10.000000000 +0200
3167 +++ linux-3.1-vs2.3.1-rc2/drivers/md/dm.h 2011-10-24 18:53:33.000000000 +0200
3168 @@ -41,6 +41,8 @@ struct dm_dev_internal {
3170 struct dm_md_mempools;
3172 +xid_t dm_get_xid(struct mapped_device *md);
3174 /*-----------------------------------------------------------------
3175 * Internal table functions.
3176 *---------------------------------------------------------------*/
3177 diff -NurpP --minimal linux-3.1/drivers/net/tun.c linux-3.1-vs2.3.1-rc2/drivers/net/tun.c
3178 --- linux-3.1/drivers/net/tun.c 2011-10-24 18:45:17.000000000 +0200
3179 +++ linux-3.1-vs2.3.1-rc2/drivers/net/tun.c 2011-10-24 18:53:33.000000000 +0200
3181 #include <linux/nsproxy.h>
3182 #include <linux/virtio_net.h>
3183 #include <linux/rcupdate.h>
3184 +#include <linux/vs_network.h>
3185 #include <net/net_namespace.h>
3186 #include <net/netns/generic.h>
3187 #include <net/rtnetlink.h>
3188 @@ -121,6 +122,7 @@ struct tun_struct {
3194 struct net_device *dev;
3196 @@ -909,6 +911,7 @@ static void tun_setup(struct net_device
3200 + tun->nid = current->nid;
3202 dev->ethtool_ops = &tun_ethtool_ops;
3203 dev->destructor = tun_free_netdev;
3204 @@ -1059,7 +1062,7 @@ static int tun_set_iff(struct net *net,
3206 if (((tun->owner != -1 && cred->euid != tun->owner) ||
3207 (tun->group != -1 && !in_egroup_p(tun->group))) &&
3208 - !capable(CAP_NET_ADMIN))
3209 + !cap_raised(current_cap(), CAP_NET_ADMIN))
3211 err = security_tun_dev_attach(tun->socket.sk);
3213 @@ -1073,7 +1076,7 @@ static int tun_set_iff(struct net *net,
3215 unsigned long flags = 0;
3217 - if (!capable(CAP_NET_ADMIN))
3218 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
3220 err = security_tun_dev_create();
3222 @@ -1141,6 +1144,9 @@ static int tun_set_iff(struct net *net,
3224 sk->sk_destruct = tun_sock_destruct;
3226 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
3229 err = tun_attach(tun, file);
3232 @@ -1322,6 +1328,16 @@ static long __tun_chr_ioctl(struct file
3233 tun_debug(KERN_INFO, tun, "group set to %d\n", tun->group);
3237 + if (!capable(CAP_CONTEXT))
3240 + /* Set nid owner of the device */
3241 + tun->nid = (nid_t) arg;
3243 + tun_debug(KERN_INFO, tun, "nid owner set to %u\n", tun->nid);
3247 /* Only allow setting the type when the interface is down */
3248 if (tun->dev->flags & IFF_UP) {
3249 diff -NurpP --minimal linux-3.1/drivers/tty/sysrq.c linux-3.1-vs2.3.1-rc2/drivers/tty/sysrq.c
3250 --- linux-3.1/drivers/tty/sysrq.c 2011-05-22 16:17:44.000000000 +0200
3251 +++ linux-3.1-vs2.3.1-rc2/drivers/tty/sysrq.c 2011-10-24 18:53:33.000000000 +0200
3253 #include <linux/oom.h>
3254 #include <linux/slab.h>
3255 #include <linux/input.h>
3256 +#include <linux/vserver/debug.h>
3258 #include <asm/ptrace.h>
3259 #include <asm/irq_regs.h>
3260 @@ -395,6 +396,21 @@ static struct sysrq_key_op sysrq_unrt_op
3261 .enable_mask = SYSRQ_ENABLE_RTNICE,
3265 +#ifdef CONFIG_VSERVER_DEBUG
3266 +static void sysrq_handle_vxinfo(int key)
3268 + dump_vx_info_inactive((key == 'x') ? 0 : 1);
3271 +static struct sysrq_key_op sysrq_showvxinfo_op = {
3272 + .handler = sysrq_handle_vxinfo,
3273 + .help_msg = "conteXt",
3274 + .action_msg = "Show Context Info",
3275 + .enable_mask = SYSRQ_ENABLE_DUMP,
3279 /* Key Operations table and lock */
3280 static DEFINE_SPINLOCK(sysrq_key_table_lock);
3282 @@ -449,7 +465,11 @@ static struct sysrq_key_op *sysrq_key_ta
3284 &sysrq_showstate_blocked_op, /* w */
3285 /* x: May be registered on ppc/powerpc for xmon */
3286 +#ifdef CONFIG_VSERVER_DEBUG
3287 + &sysrq_showvxinfo_op, /* x */
3291 /* y: May be registered on sparc64 for global register dump */
3293 &sysrq_ftrace_dump_op, /* z */
3294 @@ -464,6 +484,8 @@ static int sysrq_key_table_key2index(int
3296 else if ((key >= 'a') && (key <= 'z'))
3297 retval = key + 10 - 'a';
3298 + else if ((key >= 'A') && (key <= 'Z'))
3299 + retval = key + 10 - 'A';
3303 diff -NurpP --minimal linux-3.1/drivers/tty/tty_io.c linux-3.1-vs2.3.1-rc2/drivers/tty/tty_io.c
3304 --- linux-3.1/drivers/tty/tty_io.c 2011-10-24 18:45:24.000000000 +0200
3305 +++ linux-3.1-vs2.3.1-rc2/drivers/tty/tty_io.c 2011-10-24 18:53:33.000000000 +0200
3308 #include <linux/kmod.h>
3309 #include <linux/nsproxy.h>
3310 +#include <linux/vs_pid.h>
3312 #undef TTY_DEBUG_HANGUP
3314 @@ -2056,7 +2057,8 @@ static int tiocsti(struct tty_struct *tt
3316 struct tty_ldisc *ld;
3318 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
3319 + if (((current->signal->tty != tty) &&
3320 + !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
3322 if (get_user(ch, p))
3324 @@ -2344,6 +2346,7 @@ static int tiocspgrp(struct tty_struct *
3326 if (get_user(pgrp_nr, p))
3328 + pgrp_nr = vx_rmap_pid(pgrp_nr);
3332 diff -NurpP --minimal linux-3.1/fs/attr.c linux-3.1-vs2.3.1-rc2/fs/attr.c
3333 --- linux-3.1/fs/attr.c 2011-10-24 18:45:26.000000000 +0200
3334 +++ linux-3.1-vs2.3.1-rc2/fs/attr.c 2011-10-24 18:53:33.000000000 +0200
3336 #include <linux/fsnotify.h>
3337 #include <linux/fcntl.h>
3338 #include <linux/security.h>
3339 +#include <linux/proc_fs.h>
3340 +#include <linux/devpts_fs.h>
3341 +#include <linux/vs_tag.h>
3344 * inode_change_ok - check if attribute changes to an inode are allowed
3345 @@ -73,6 +76,10 @@ int inode_change_ok(const struct inode *
3349 + /* check for inode tag permission */
3350 + if (dx_permission(inode, MAY_WRITE))
3355 EXPORT_SYMBOL(inode_change_ok);
3356 @@ -143,6 +150,8 @@ void setattr_copy(struct inode *inode, c
3357 inode->i_uid = attr->ia_uid;
3358 if (ia_valid & ATTR_GID)
3359 inode->i_gid = attr->ia_gid;
3360 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3361 + inode->i_tag = attr->ia_tag;
3362 if (ia_valid & ATTR_ATIME)
3363 inode->i_atime = timespec_trunc(attr->ia_atime,
3364 inode->i_sb->s_time_gran);
3365 @@ -170,7 +179,8 @@ int notify_change(struct dentry * dentry
3366 struct timespec now;
3367 unsigned int ia_valid = attr->ia_valid;
3369 - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
3370 + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
3371 + ATTR_TAG | ATTR_TIMES_SET)) {
3372 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
3375 diff -NurpP --minimal linux-3.1/fs/binfmt_aout.c linux-3.1-vs2.3.1-rc2/fs/binfmt_aout.c
3376 --- linux-3.1/fs/binfmt_aout.c 2010-10-21 13:07:47.000000000 +0200
3377 +++ linux-3.1-vs2.3.1-rc2/fs/binfmt_aout.c 2011-10-24 18:53:33.000000000 +0200
3379 #include <linux/init.h>
3380 #include <linux/coredump.h>
3381 #include <linux/slab.h>
3382 +#include <linux/vs_memory.h>
3384 #include <asm/system.h>
3385 #include <asm/uaccess.h>
3386 diff -NurpP --minimal linux-3.1/fs/binfmt_elf.c linux-3.1-vs2.3.1-rc2/fs/binfmt_elf.c
3387 --- linux-3.1/fs/binfmt_elf.c 2011-10-24 18:45:26.000000000 +0200
3388 +++ linux-3.1-vs2.3.1-rc2/fs/binfmt_elf.c 2011-10-24 18:53:33.000000000 +0200
3390 #include <linux/elf.h>
3391 #include <linux/utsname.h>
3392 #include <linux/coredump.h>
3393 +#include <linux/vs_memory.h>
3394 #include <asm/uaccess.h>
3395 #include <asm/param.h>
3396 #include <asm/page.h>
3397 diff -NurpP --minimal linux-3.1/fs/binfmt_flat.c linux-3.1-vs2.3.1-rc2/fs/binfmt_flat.c
3398 --- linux-3.1/fs/binfmt_flat.c 2011-07-22 11:18:05.000000000 +0200
3399 +++ linux-3.1-vs2.3.1-rc2/fs/binfmt_flat.c 2011-10-24 18:53:33.000000000 +0200
3401 #include <linux/init.h>
3402 #include <linux/flat.h>
3403 #include <linux/syscalls.h>
3404 +#include <linux/vs_memory.h>
3406 #include <asm/byteorder.h>
3407 #include <asm/system.h>
3408 diff -NurpP --minimal linux-3.1/fs/binfmt_som.c linux-3.1-vs2.3.1-rc2/fs/binfmt_som.c
3409 --- linux-3.1/fs/binfmt_som.c 2010-02-25 11:52:04.000000000 +0100
3410 +++ linux-3.1-vs2.3.1-rc2/fs/binfmt_som.c 2011-10-24 18:53:33.000000000 +0200
3412 #include <linux/shm.h>
3413 #include <linux/personality.h>
3414 #include <linux/init.h>
3415 +#include <linux/vs_memory.h>
3417 #include <asm/uaccess.h>
3418 #include <asm/pgtable.h>
3419 diff -NurpP --minimal linux-3.1/fs/block_dev.c linux-3.1-vs2.3.1-rc2/fs/block_dev.c
3420 --- linux-3.1/fs/block_dev.c 2011-10-24 18:45:26.000000000 +0200
3421 +++ linux-3.1-vs2.3.1-rc2/fs/block_dev.c 2011-10-24 18:53:33.000000000 +0200
3423 #include <linux/namei.h>
3424 #include <linux/log2.h>
3425 #include <linux/kmemleak.h>
3426 +#include <linux/vs_device.h>
3427 #include <asm/uaccess.h>
3428 #include "internal.h"
3430 @@ -563,6 +564,7 @@ struct block_device *bdget(dev_t dev)
3431 bdev->bd_invalidated = 0;
3432 inode->i_mode = S_IFBLK;
3433 inode->i_rdev = dev;
3434 + inode->i_mdev = dev;
3435 inode->i_bdev = bdev;
3436 inode->i_data.a_ops = &def_blk_aops;
3437 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
3438 @@ -609,6 +611,11 @@ EXPORT_SYMBOL(bdput);
3439 static struct block_device *bd_acquire(struct inode *inode)
3441 struct block_device *bdev;
3444 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
3446 + inode->i_mdev = mdev;
3448 spin_lock(&bdev_lock);
3449 bdev = inode->i_bdev;
3450 @@ -619,7 +626,7 @@ static struct block_device *bd_acquire(s
3452 spin_unlock(&bdev_lock);
3454 - bdev = bdget(inode->i_rdev);
3455 + bdev = bdget(mdev);
3457 spin_lock(&bdev_lock);
3458 if (!inode->i_bdev) {
3459 diff -NurpP --minimal linux-3.1/fs/btrfs/ctree.h linux-3.1-vs2.3.1-rc2/fs/btrfs/ctree.h
3460 --- linux-3.1/fs/btrfs/ctree.h 2011-10-24 18:45:26.000000000 +0200
3461 +++ linux-3.1-vs2.3.1-rc2/fs/btrfs/ctree.h 2011-10-24 18:53:33.000000000 +0200
3462 @@ -600,11 +600,14 @@ struct btrfs_inode_item {
3463 /* modification sequence number for NFS */
3468 * a little future expansion, for more than this we can
3469 * just grow the inode item and version it
3471 - __le64 reserved[4];
3472 + __le16 reserved16;
3473 + __le32 reserved32;
3474 + __le64 reserved[3];
3475 struct btrfs_timespec atime;
3476 struct btrfs_timespec ctime;
3477 struct btrfs_timespec mtime;
3478 @@ -1364,6 +1367,8 @@ struct btrfs_ioctl_defrag_range_args {
3479 #define BTRFS_MOUNT_AUTO_DEFRAG (1 << 16)
3480 #define BTRFS_MOUNT_INODE_MAP_CACHE (1 << 17)
3482 +#define BTRFS_MOUNT_TAGGED (1 << 24)
3484 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
3485 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
3486 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
3487 @@ -1571,6 +1576,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
3488 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
3489 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
3490 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
3491 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
3492 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
3493 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
3494 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
3495 @@ -1624,6 +1630,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct
3497 BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
3499 +#define BTRFS_INODE_IXUNLINK (1 << 24)
3500 +#define BTRFS_INODE_BARRIER (1 << 25)
3501 +#define BTRFS_INODE_COW (1 << 26)
3504 BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
3506 @@ -2603,6 +2613,7 @@ extern const struct dentry_operations bt
3507 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
3508 void btrfs_update_iflags(struct inode *inode);
3509 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
3510 +int btrfs_sync_flags(struct inode *inode, int, int);
3511 int btrfs_defrag_file(struct inode *inode, struct file *file,
3512 struct btrfs_ioctl_defrag_range_args *range,
3513 u64 newer_than, unsigned long max_pages);
3514 diff -NurpP --minimal linux-3.1/fs/btrfs/disk-io.c linux-3.1-vs2.3.1-rc2/fs/btrfs/disk-io.c
3515 --- linux-3.1/fs/btrfs/disk-io.c 2011-10-24 18:45:26.000000000 +0200
3516 +++ linux-3.1-vs2.3.1-rc2/fs/btrfs/disk-io.c 2011-10-24 18:53:33.000000000 +0200
3517 @@ -1794,6 +1794,9 @@ struct btrfs_root *open_ctree(struct sup
3521 + if (btrfs_test_opt(tree_root, TAGGED))
3522 + sb->s_flags |= MS_TAGGED;
3524 features = btrfs_super_incompat_flags(disk_super) &
3525 ~BTRFS_FEATURE_INCOMPAT_SUPP;
3527 diff -NurpP --minimal linux-3.1/fs/btrfs/inode.c linux-3.1-vs2.3.1-rc2/fs/btrfs/inode.c
3528 --- linux-3.1/fs/btrfs/inode.c 2011-10-24 18:45:26.000000000 +0200
3529 +++ linux-3.1-vs2.3.1-rc2/fs/btrfs/inode.c 2011-10-24 18:53:33.000000000 +0200
3531 #include <linux/falloc.h>
3532 #include <linux/slab.h>
3533 #include <linux/ratelimit.h>
3534 +#include <linux/vs_tag.h>
3537 #include "disk-io.h"
3538 @@ -2508,6 +2509,8 @@ static void btrfs_read_locked_inode(stru
3539 struct btrfs_key location;
3545 bool filled = false;
3547 @@ -2535,8 +2538,13 @@ static void btrfs_read_locked_inode(stru
3548 struct btrfs_inode_item);
3549 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
3550 inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);
3551 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
3552 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
3554 + uid = btrfs_inode_uid(leaf, inode_item);
3555 + gid = btrfs_inode_gid(leaf, inode_item);
3556 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3557 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3558 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3559 + btrfs_inode_tag(leaf, inode_item));
3560 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
3562 tspec = btrfs_inode_atime(inode_item);
3563 @@ -2614,8 +2622,14 @@ static void fill_inode_item(struct btrfs
3564 struct btrfs_inode_item *item,
3565 struct inode *inode)
3567 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
3568 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
3569 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3570 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3572 + btrfs_set_inode_uid(leaf, item, uid);
3573 + btrfs_set_inode_gid(leaf, item, gid);
3574 +#ifdef CONFIG_TAGGING_INTERN
3575 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
3577 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
3578 btrfs_set_inode_mode(leaf, item, inode->i_mode);
3579 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
3580 @@ -7393,11 +7407,13 @@ static const struct inode_operations btr
3581 .listxattr = btrfs_listxattr,
3582 .removexattr = btrfs_removexattr,
3583 .permission = btrfs_permission,
3584 + .sync_flags = btrfs_sync_flags,
3585 .get_acl = btrfs_get_acl,
3587 static const struct inode_operations btrfs_dir_ro_inode_operations = {
3588 .lookup = btrfs_lookup,
3589 .permission = btrfs_permission,
3590 + .sync_flags = btrfs_sync_flags,
3591 .get_acl = btrfs_get_acl,
3594 diff -NurpP --minimal linux-3.1/fs/btrfs/ioctl.c linux-3.1-vs2.3.1-rc2/fs/btrfs/ioctl.c
3595 --- linux-3.1/fs/btrfs/ioctl.c 2011-10-24 18:45:26.000000000 +0200
3596 +++ linux-3.1-vs2.3.1-rc2/fs/btrfs/ioctl.c 2011-10-24 18:53:33.000000000 +0200
3597 @@ -70,10 +70,13 @@ static unsigned int btrfs_flags_to_ioctl
3599 unsigned int iflags = 0;
3601 - if (flags & BTRFS_INODE_SYNC)
3602 - iflags |= FS_SYNC_FL;
3603 if (flags & BTRFS_INODE_IMMUTABLE)
3604 iflags |= FS_IMMUTABLE_FL;
3605 + if (flags & BTRFS_INODE_IXUNLINK)
3606 + iflags |= FS_IXUNLINK_FL;
3608 + if (flags & BTRFS_INODE_SYNC)
3609 + iflags |= FS_SYNC_FL;
3610 if (flags & BTRFS_INODE_APPEND)
3611 iflags |= FS_APPEND_FL;
3612 if (flags & BTRFS_INODE_NODUMP)
3613 @@ -90,28 +93,78 @@ static unsigned int btrfs_flags_to_ioctl
3614 else if (flags & BTRFS_INODE_NOCOMPRESS)
3615 iflags |= FS_NOCOMP_FL;
3617 + if (flags & BTRFS_INODE_BARRIER)
3618 + iflags |= FS_BARRIER_FL;
3619 + if (flags & BTRFS_INODE_COW)
3620 + iflags |= FS_COW_FL;
3625 - * Update inode->i_flags based on the btrfs internal flags.
3626 + * Update inode->i_(v)flags based on the btrfs internal flags.
3628 void btrfs_update_iflags(struct inode *inode)
3630 struct btrfs_inode *ip = BTRFS_I(inode);
3632 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3633 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3634 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3636 - if (ip->flags & BTRFS_INODE_SYNC)
3637 - inode->i_flags |= S_SYNC;
3638 if (ip->flags & BTRFS_INODE_IMMUTABLE)
3639 inode->i_flags |= S_IMMUTABLE;
3640 + if (ip->flags & BTRFS_INODE_IXUNLINK)
3641 + inode->i_flags |= S_IXUNLINK;
3643 + if (ip->flags & BTRFS_INODE_SYNC)
3644 + inode->i_flags |= S_SYNC;
3645 if (ip->flags & BTRFS_INODE_APPEND)
3646 inode->i_flags |= S_APPEND;
3647 if (ip->flags & BTRFS_INODE_NOATIME)
3648 inode->i_flags |= S_NOATIME;
3649 if (ip->flags & BTRFS_INODE_DIRSYNC)
3650 inode->i_flags |= S_DIRSYNC;
3652 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3654 + if (ip->flags & BTRFS_INODE_BARRIER)
3655 + inode->i_vflags |= V_BARRIER;
3656 + if (ip->flags & BTRFS_INODE_COW)
3657 + inode->i_vflags |= V_COW;
3661 + * Update btrfs internal flags from inode->i_(v)flags.
3663 +void btrfs_update_flags(struct inode *inode)
3665 + struct btrfs_inode *ip = BTRFS_I(inode);
3667 + unsigned int flags = inode->i_flags;
3668 + unsigned int vflags = inode->i_vflags;
3670 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
3671 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
3672 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
3673 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
3675 + if (flags & S_IMMUTABLE)
3676 + ip->flags |= BTRFS_INODE_IMMUTABLE;
3677 + if (flags & S_IXUNLINK)
3678 + ip->flags |= BTRFS_INODE_IXUNLINK;
3680 + if (flags & S_SYNC)
3681 + ip->flags |= BTRFS_INODE_SYNC;
3682 + if (flags & S_APPEND)
3683 + ip->flags |= BTRFS_INODE_APPEND;
3684 + if (flags & S_NOATIME)
3685 + ip->flags |= BTRFS_INODE_NOATIME;
3686 + if (flags & S_DIRSYNC)
3687 + ip->flags |= BTRFS_INODE_DIRSYNC;
3689 + if (vflags & V_BARRIER)
3690 + ip->flags |= BTRFS_INODE_BARRIER;
3691 + if (vflags & V_COW)
3692 + ip->flags |= BTRFS_INODE_COW;
3696 @@ -129,7 +182,7 @@ void btrfs_inherit_iflags(struct inode *
3697 flags = BTRFS_I(dir)->flags;
3699 if (S_ISREG(inode->i_mode))
3700 - flags &= ~BTRFS_INODE_DIRSYNC;
3701 + flags &= ~(BTRFS_INODE_DIRSYNC | BTRFS_INODE_BARRIER);
3702 else if (!S_ISDIR(inode->i_mode))
3703 flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
3705 @@ -137,6 +190,30 @@ void btrfs_inherit_iflags(struct inode *
3706 btrfs_update_iflags(inode);
3709 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
3711 + struct btrfs_inode *ip = BTRFS_I(inode);
3712 + struct btrfs_root *root = ip->root;
3713 + struct btrfs_trans_handle *trans;
3716 + trans = btrfs_join_transaction(root);
3719 + inode->i_flags = flags;
3720 + inode->i_vflags = vflags;
3721 + btrfs_update_flags(inode);
3723 + ret = btrfs_update_inode(trans, root, inode);
3726 + btrfs_update_iflags(inode);
3727 + inode->i_ctime = CURRENT_TIME;
3728 + btrfs_end_transaction(trans, root);
3733 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
3735 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
3736 @@ -188,7 +265,8 @@ static int btrfs_ioctl_setflags(struct f
3738 flags = btrfs_mask_flags(inode->i_mode, flags);
3739 oldflags = btrfs_flags_to_ioctl(ip->flags);
3740 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
3741 + if ((flags ^ oldflags) & (FS_APPEND_FL |
3742 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
3743 if (!capable(CAP_LINUX_IMMUTABLE)) {
3746 @@ -199,14 +277,19 @@ static int btrfs_ioctl_setflags(struct f
3750 - if (flags & FS_SYNC_FL)
3751 - ip->flags |= BTRFS_INODE_SYNC;
3753 - ip->flags &= ~BTRFS_INODE_SYNC;
3754 if (flags & FS_IMMUTABLE_FL)
3755 ip->flags |= BTRFS_INODE_IMMUTABLE;
3757 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
3758 + if (flags & FS_IXUNLINK_FL)
3759 + ip->flags |= BTRFS_INODE_IXUNLINK;
3761 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
3763 + if (flags & FS_SYNC_FL)
3764 + ip->flags |= BTRFS_INODE_SYNC;
3766 + ip->flags &= ~BTRFS_INODE_SYNC;
3767 if (flags & FS_APPEND_FL)
3768 ip->flags |= BTRFS_INODE_APPEND;
3770 diff -NurpP --minimal linux-3.1/fs/btrfs/super.c linux-3.1-vs2.3.1-rc2/fs/btrfs/super.c
3771 --- linux-3.1/fs/btrfs/super.c 2011-07-22 11:18:05.000000000 +0200
3772 +++ linux-3.1-vs2.3.1-rc2/fs/btrfs/super.c 2011-10-24 18:53:33.000000000 +0200
3773 @@ -162,7 +162,7 @@ enum {
3774 Opt_notreelog, Opt_ratio, Opt_flushoncommit, Opt_discard,
3775 Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed,
3776 Opt_enospc_debug, Opt_subvolrootid, Opt_defrag,
3777 - Opt_inode_cache, Opt_err,
3778 + Opt_inode_cache, Opt_tag, Opt_notag, Opt_tagid, Opt_err,
3781 static match_table_t tokens = {
3782 @@ -195,6 +195,9 @@ static match_table_t tokens = {
3783 {Opt_subvolrootid, "subvolrootid=%d"},
3784 {Opt_defrag, "autodefrag"},
3785 {Opt_inode_cache, "inode_cache"},
3787 + {Opt_notag, "notag"},
3788 + {Opt_tagid, "tagid=%u"},
3792 @@ -381,6 +384,22 @@ int btrfs_parse_options(struct btrfs_roo
3793 printk(KERN_INFO "btrfs: enabling auto defrag");
3794 btrfs_set_opt(info->mount_opt, AUTO_DEFRAG);
3796 +#ifndef CONFIG_TAGGING_NONE
3798 + printk(KERN_INFO "btrfs: use tagging\n");
3799 + btrfs_set_opt(info->mount_opt, TAGGED);
3802 + printk(KERN_INFO "btrfs: disabled tagging\n");
3803 + btrfs_clear_opt(info->mount_opt, TAGGED);
3806 +#ifdef CONFIG_PROPAGATE
3809 + btrfs_set_opt(info->mount_opt, TAGGED);
3813 printk(KERN_INFO "btrfs: unrecognized mount option "
3815 @@ -907,6 +926,12 @@ static int btrfs_remount(struct super_bl
3819 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
3820 + printk("btrfs: %s: tagging not permitted on remount.\n",
3825 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
3828 diff -NurpP --minimal linux-3.1/fs/char_dev.c linux-3.1-vs2.3.1-rc2/fs/char_dev.c
3829 --- linux-3.1/fs/char_dev.c 2011-03-15 18:07:31.000000000 +0100
3830 +++ linux-3.1-vs2.3.1-rc2/fs/char_dev.c 2011-10-24 18:53:33.000000000 +0200
3832 #include <linux/mutex.h>
3833 #include <linux/backing-dev.h>
3834 #include <linux/tty.h>
3835 +#include <linux/vs_context.h>
3836 +#include <linux/vs_device.h>
3838 #include "internal.h"
3840 @@ -371,14 +373,21 @@ static int chrdev_open(struct inode *ino
3842 struct cdev *new = NULL;
3846 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
3848 + inode->i_mdev = mdev;
3850 spin_lock(&cdev_lock);
3853 struct kobject *kobj;
3856 spin_unlock(&cdev_lock);
3857 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
3859 + kobj = kobj_lookup(cdev_map, mdev, &idx);
3862 new = container_of(kobj, struct cdev, kobj);
3863 diff -NurpP --minimal linux-3.1/fs/dcache.c linux-3.1-vs2.3.1-rc2/fs/dcache.c
3864 --- linux-3.1/fs/dcache.c 2011-10-24 18:45:26.000000000 +0200
3865 +++ linux-3.1-vs2.3.1-rc2/fs/dcache.c 2011-10-24 18:53:33.000000000 +0200
3867 #include <linux/bit_spinlock.h>
3868 #include <linux/rculist_bl.h>
3869 #include <linux/prefetch.h>
3870 +#include <linux/vs_limit.h>
3871 #include "internal.h"
3874 @@ -513,6 +514,8 @@ int d_invalidate(struct dentry * dentry)
3875 spin_lock(&dentry->d_lock);
3878 + vx_dentry_dec(dentry);
3881 * Somebody else still using it?
3883 @@ -540,6 +543,7 @@ EXPORT_SYMBOL(d_invalidate);
3884 static inline void __dget_dlock(struct dentry *dentry)
3887 + vx_dentry_inc(dentry);
3890 static inline void __dget(struct dentry *dentry)
3891 @@ -1175,6 +1179,9 @@ struct dentry *__d_alloc(struct super_bl
3892 struct dentry *dentry;
3895 + if (!vx_dentry_avail(1))
3898 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
3901 @@ -1197,6 +1204,7 @@ struct dentry *__d_alloc(struct super_bl
3903 dentry->d_count = 1;
3904 dentry->d_flags = 0;
3905 + vx_dentry_inc(dentry);
3906 spin_lock_init(&dentry->d_lock);
3907 seqcount_init(&dentry->d_seq);
3908 dentry->d_inode = NULL;
3909 @@ -1853,6 +1861,7 @@ struct dentry *__d_lookup(struct dentry
3913 + vx_dentry_inc(dentry);
3915 spin_unlock(&dentry->d_lock);
3917 diff -NurpP --minimal linux-3.1/fs/devpts/inode.c linux-3.1-vs2.3.1-rc2/fs/devpts/inode.c
3918 --- linux-3.1/fs/devpts/inode.c 2011-05-22 16:17:50.000000000 +0200
3919 +++ linux-3.1-vs2.3.1-rc2/fs/devpts/inode.c 2011-10-24 18:53:33.000000000 +0200
3921 #include <linux/parser.h>
3922 #include <linux/fsnotify.h>
3923 #include <linux/seq_file.h>
3924 +#include <linux/vs_base.h>
3926 #define DEVPTS_DEFAULT_MODE 0600
3929 #define DEVPTS_DEFAULT_PTMX_MODE 0000
3930 #define PTMX_MINOR 2
3932 +static int devpts_permission(struct inode *inode, int mask)
3934 + int ret = -EACCES;
3936 + /* devpts is xid tagged */
3937 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
3938 + ret = generic_permission(inode, mask);
3942 +static struct inode_operations devpts_file_inode_operations = {
3943 + .permission = devpts_permission,
3946 extern int pty_limit; /* Config limit on Unix98 ptys */
3947 static DEFINE_MUTEX(allocated_ptys_lock);
3949 @@ -263,6 +278,34 @@ static int devpts_show_options(struct se
3953 +static int devpts_filter(struct dentry *de)
3957 + /* devpts is xid tagged */
3958 + if (de && de->d_inode)
3959 + xid = (xid_t)de->d_inode->i_tag;
3960 +#ifdef CONFIG_VSERVER_WARN_DEVPTS
3962 + vxwprintk_task(1, "devpts " VS_Q("%.*s") " without inode.",
3963 + de->d_name.len, de->d_name.name);
3965 + return vx_check(xid, VS_WATCH_P | VS_IDENT);
3968 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
3970 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
3973 +static struct file_operations devpts_dir_operations = {
3974 + .open = dcache_dir_open,
3975 + .release = dcache_dir_close,
3976 + .llseek = dcache_dir_lseek,
3977 + .read = generic_read_dir,
3978 + .readdir = devpts_readdir,
3981 static const struct super_operations devpts_sops = {
3982 .statfs = simple_statfs,
3983 .remount_fs = devpts_remount,
3984 @@ -302,12 +345,15 @@ devpts_fill_super(struct super_block *s,
3985 inode = new_inode(s);
3990 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
3991 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
3992 inode->i_op = &simple_dir_inode_operations;
3993 - inode->i_fop = &simple_dir_operations;
3994 + inode->i_fop = &devpts_dir_operations;
3996 + /* devpts is xid tagged */
3997 + inode->i_tag = (tag_t)vx_current_xid();
3999 s->s_root = d_alloc_root(inode);
4001 @@ -494,6 +540,9 @@ int devpts_pty_new(struct inode *ptmx_in
4002 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
4003 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
4004 init_special_inode(inode, S_IFCHR|opts->mode, device);
4005 + /* devpts is xid tagged */
4006 + inode->i_tag = (tag_t)vx_current_xid();
4007 + inode->i_op = &devpts_file_inode_operations;
4008 inode->i_private = tty;
4009 tty->driver_data = inode;
4011 diff -NurpP --minimal linux-3.1/fs/ext2/balloc.c linux-3.1-vs2.3.1-rc2/fs/ext2/balloc.c
4012 --- linux-3.1/fs/ext2/balloc.c 2011-05-22 16:17:51.000000000 +0200
4013 +++ linux-3.1-vs2.3.1-rc2/fs/ext2/balloc.c 2011-10-24 18:53:33.000000000 +0200
4014 @@ -701,7 +701,6 @@ ext2_try_to_allocate(struct super_block
4016 end = EXT2_BLOCKS_PER_GROUP(sb);
4019 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
4022 diff -NurpP --minimal linux-3.1/fs/ext2/ext2.h linux-3.1-vs2.3.1-rc2/fs/ext2/ext2.h
4023 --- linux-3.1/fs/ext2/ext2.h 2011-10-24 18:45:27.000000000 +0200
4024 +++ linux-3.1-vs2.3.1-rc2/fs/ext2/ext2.h 2011-10-24 18:53:33.000000000 +0200
4025 @@ -126,6 +126,7 @@ extern void ext2_set_inode_flags(struct
4026 extern void ext2_get_inode_flags(struct ext2_inode_info *);
4027 extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
4028 u64 start, u64 len);
4029 +extern int ext2_sync_flags(struct inode *, int, int);
4032 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
4033 diff -NurpP --minimal linux-3.1/fs/ext2/file.c linux-3.1-vs2.3.1-rc2/fs/ext2/file.c
4034 --- linux-3.1/fs/ext2/file.c 2011-10-24 18:45:27.000000000 +0200
4035 +++ linux-3.1-vs2.3.1-rc2/fs/ext2/file.c 2011-10-24 18:53:33.000000000 +0200
4036 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
4037 .setattr = ext2_setattr,
4038 .get_acl = ext2_get_acl,
4039 .fiemap = ext2_fiemap,
4040 + .sync_flags = ext2_sync_flags,
4042 diff -NurpP --minimal linux-3.1/fs/ext2/ialloc.c linux-3.1-vs2.3.1-rc2/fs/ext2/ialloc.c
4043 --- linux-3.1/fs/ext2/ialloc.c 2011-05-22 16:17:51.000000000 +0200
4044 +++ linux-3.1-vs2.3.1-rc2/fs/ext2/ialloc.c 2011-10-24 18:53:33.000000000 +0200
4046 #include <linux/backing-dev.h>
4047 #include <linux/buffer_head.h>
4048 #include <linux/random.h>
4049 +#include <linux/vs_tag.h>
4053 @@ -549,6 +550,7 @@ got:
4054 inode->i_mode = mode;
4055 inode->i_uid = current_fsuid();
4056 inode->i_gid = dir->i_gid;
4057 + inode->i_tag = dx_current_fstag(sb);
4059 inode_init_owner(inode, dir, mode);
4061 diff -NurpP --minimal linux-3.1/fs/ext2/inode.c linux-3.1-vs2.3.1-rc2/fs/ext2/inode.c
4062 --- linux-3.1/fs/ext2/inode.c 2011-10-24 18:45:27.000000000 +0200
4063 +++ linux-3.1-vs2.3.1-rc2/fs/ext2/inode.c 2011-10-24 18:53:33.000000000 +0200
4065 #include <linux/mpage.h>
4066 #include <linux/fiemap.h>
4067 #include <linux/namei.h>
4068 +#include <linux/vs_tag.h>
4072 @@ -1167,7 +1168,7 @@ static void ext2_truncate_blocks(struct
4074 if (ext2_inode_is_fast_symlink(inode))
4076 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4077 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4079 __ext2_truncate_blocks(inode, offset);
4081 @@ -1258,36 +1259,61 @@ void ext2_set_inode_flags(struct inode *
4083 unsigned int flags = EXT2_I(inode)->i_flags;
4085 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4086 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4087 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4090 + if (flags & EXT2_IMMUTABLE_FL)
4091 + inode->i_flags |= S_IMMUTABLE;
4092 + if (flags & EXT2_IXUNLINK_FL)
4093 + inode->i_flags |= S_IXUNLINK;
4095 if (flags & EXT2_SYNC_FL)
4096 inode->i_flags |= S_SYNC;
4097 if (flags & EXT2_APPEND_FL)
4098 inode->i_flags |= S_APPEND;
4099 - if (flags & EXT2_IMMUTABLE_FL)
4100 - inode->i_flags |= S_IMMUTABLE;
4101 if (flags & EXT2_NOATIME_FL)
4102 inode->i_flags |= S_NOATIME;
4103 if (flags & EXT2_DIRSYNC_FL)
4104 inode->i_flags |= S_DIRSYNC;
4106 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4108 + if (flags & EXT2_BARRIER_FL)
4109 + inode->i_vflags |= V_BARRIER;
4110 + if (flags & EXT2_COW_FL)
4111 + inode->i_vflags |= V_COW;
4114 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
4115 void ext2_get_inode_flags(struct ext2_inode_info *ei)
4117 unsigned int flags = ei->vfs_inode.i_flags;
4118 + unsigned int vflags = ei->vfs_inode.i_vflags;
4120 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
4121 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
4122 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
4123 + EXT2_BARRIER_FL | EXT2_COW_FL);
4125 + if (flags & S_IMMUTABLE)
4126 + ei->i_flags |= EXT2_IMMUTABLE_FL;
4127 + if (flags & S_IXUNLINK)
4128 + ei->i_flags |= EXT2_IXUNLINK_FL;
4130 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
4131 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
4133 ei->i_flags |= EXT2_SYNC_FL;
4134 if (flags & S_APPEND)
4135 ei->i_flags |= EXT2_APPEND_FL;
4136 - if (flags & S_IMMUTABLE)
4137 - ei->i_flags |= EXT2_IMMUTABLE_FL;
4138 if (flags & S_NOATIME)
4139 ei->i_flags |= EXT2_NOATIME_FL;
4140 if (flags & S_DIRSYNC)
4141 ei->i_flags |= EXT2_DIRSYNC_FL;
4143 + if (vflags & V_BARRIER)
4144 + ei->i_flags |= EXT2_BARRIER_FL;
4145 + if (vflags & V_COW)
4146 + ei->i_flags |= EXT2_COW_FL;
4149 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
4150 @@ -1297,6 +1323,8 @@ struct inode *ext2_iget (struct super_bl
4151 struct ext2_inode *raw_inode;
4152 struct inode *inode;
4158 inode = iget_locked(sb, ino);
4159 @@ -1315,12 +1343,17 @@ struct inode *ext2_iget (struct super_bl
4162 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
4163 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4164 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4165 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4166 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4167 if (!(test_opt (inode->i_sb, NO_UID32))) {
4168 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4169 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4170 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4171 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4173 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
4174 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
4175 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
4176 + le16_to_cpu(raw_inode->i_raw_tag));
4178 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
4179 inode->i_size = le32_to_cpu(raw_inode->i_size);
4180 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
4181 @@ -1418,8 +1451,8 @@ static int __ext2_write_inode(struct ino
4182 struct ext2_inode_info *ei = EXT2_I(inode);
4183 struct super_block *sb = inode->i_sb;
4184 ino_t ino = inode->i_ino;
4185 - uid_t uid = inode->i_uid;
4186 - gid_t gid = inode->i_gid;
4187 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
4188 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
4189 struct buffer_head * bh;
4190 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
4192 @@ -1455,6 +1488,9 @@ static int __ext2_write_inode(struct ino
4193 raw_inode->i_uid_high = 0;
4194 raw_inode->i_gid_high = 0;
4196 +#ifdef CONFIG_TAGGING_INTERN
4197 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4199 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4200 raw_inode->i_size = cpu_to_le32(inode->i_size);
4201 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
4202 @@ -1535,7 +1571,8 @@ int ext2_setattr(struct dentry *dentry,
4203 if (is_quota_modification(inode, iattr))
4204 dquot_initialize(inode);
4205 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
4206 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
4207 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
4208 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
4209 error = dquot_transfer(inode, iattr);
4212 diff -NurpP --minimal linux-3.1/fs/ext2/ioctl.c linux-3.1-vs2.3.1-rc2/fs/ext2/ioctl.c
4213 --- linux-3.1/fs/ext2/ioctl.c 2011-05-22 16:17:51.000000000 +0200
4214 +++ linux-3.1-vs2.3.1-rc2/fs/ext2/ioctl.c 2011-10-24 18:53:33.000000000 +0200
4216 #include <asm/uaccess.h>
4219 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
4221 + inode->i_flags = flags;
4222 + inode->i_vflags = vflags;
4223 + ext2_get_inode_flags(EXT2_I(inode));
4224 + inode->i_ctime = CURRENT_TIME_SEC;
4225 + mark_inode_dirty(inode);
4229 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4231 struct inode *inode = filp->f_dentry->d_inode;
4232 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
4234 flags = ext2_mask_flags(inode->i_mode, flags);
4236 + if (IS_BARRIER(inode)) {
4237 + vxwprintk_task(1, "messing with the barrier.");
4241 mutex_lock(&inode->i_mutex);
4242 /* Is it quota file? Do not allow user to mess with it */
4243 if (IS_NOQUOTA(inode)) {
4244 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
4246 * This test looks nicer. Thanks to Pauline Middelink
4248 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
4249 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
4250 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
4251 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
4252 if (!capable(CAP_LINUX_IMMUTABLE)) {
4253 mutex_unlock(&inode->i_mutex);
4255 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
4259 - flags = flags & EXT2_FL_USER_MODIFIABLE;
4260 + flags &= EXT2_FL_USER_MODIFIABLE;
4261 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
4262 ei->i_flags = flags;
4263 mutex_unlock(&inode->i_mutex);
4264 diff -NurpP --minimal linux-3.1/fs/ext2/namei.c linux-3.1-vs2.3.1-rc2/fs/ext2/namei.c
4265 --- linux-3.1/fs/ext2/namei.c 2011-10-24 18:45:27.000000000 +0200
4266 +++ linux-3.1-vs2.3.1-rc2/fs/ext2/namei.c 2011-10-24 18:53:33.000000000 +0200
4269 #include <linux/pagemap.h>
4270 #include <linux/quotaops.h>
4271 +#include <linux/vs_tag.h>
4275 @@ -73,6 +74,7 @@ static struct dentry *ext2_lookup(struct
4276 (unsigned long) ino);
4277 return ERR_PTR(-EIO);
4279 + dx_propagate_tag(nd, inode);
4281 return d_splice_alias(inode, dentry);
4283 @@ -408,6 +410,7 @@ const struct inode_operations ext2_dir_i
4284 .removexattr = generic_removexattr,
4286 .setattr = ext2_setattr,
4287 + .sync_flags = ext2_sync_flags,
4288 .get_acl = ext2_get_acl,
4291 diff -NurpP --minimal linux-3.1/fs/ext2/super.c linux-3.1-vs2.3.1-rc2/fs/ext2/super.c
4292 --- linux-3.1/fs/ext2/super.c 2011-07-22 11:18:05.000000000 +0200
4293 +++ linux-3.1-vs2.3.1-rc2/fs/ext2/super.c 2011-10-24 18:53:33.000000000 +0200
4294 @@ -394,7 +394,8 @@ enum {
4295 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
4296 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
4297 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
4298 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
4299 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
4300 + Opt_tag, Opt_notag, Opt_tagid
4303 static const match_table_t tokens = {
4304 @@ -422,6 +423,9 @@ static const match_table_t tokens = {
4306 {Opt_noacl, "noacl"},
4309 + {Opt_notag, "notag"},
4310 + {Opt_tagid, "tagid=%u"},
4311 {Opt_grpquota, "grpquota"},
4312 {Opt_ignore, "noquota"},
4313 {Opt_quota, "quota"},
4314 @@ -492,6 +496,20 @@ static int parse_options(char *options,
4316 set_opt (sbi->s_mount_opt, NO_UID32);
4318 +#ifndef CONFIG_TAGGING_NONE
4320 + set_opt (sbi->s_mount_opt, TAGGED);
4323 + clear_opt (sbi->s_mount_opt, TAGGED);
4326 +#ifdef CONFIG_PROPAGATE
4329 + set_opt (sbi->s_mount_opt, TAGGED);
4333 clear_opt (sbi->s_mount_opt, CHECK);
4335 @@ -850,6 +868,8 @@ static int ext2_fill_super(struct super_
4336 if (!parse_options((char *) data, sb))
4339 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
4340 + sb->s_flags |= MS_TAGGED;
4341 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4342 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
4344 @@ -1224,6 +1244,14 @@ static int ext2_remount (struct super_bl
4348 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
4349 + !(sb->s_flags & MS_TAGGED)) {
4350 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
4353 + goto restore_opts;
4356 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4357 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4359 diff -NurpP --minimal linux-3.1/fs/ext3/file.c linux-3.1-vs2.3.1-rc2/fs/ext3/file.c
4360 --- linux-3.1/fs/ext3/file.c 2011-10-24 18:45:27.000000000 +0200
4361 +++ linux-3.1-vs2.3.1-rc2/fs/ext3/file.c 2011-10-24 18:53:33.000000000 +0200
4362 @@ -80,5 +80,6 @@ const struct inode_operations ext3_file_
4364 .get_acl = ext3_get_acl,
4365 .fiemap = ext3_fiemap,
4366 + .sync_flags = ext3_sync_flags,
4369 diff -NurpP --minimal linux-3.1/fs/ext3/ialloc.c linux-3.1-vs2.3.1-rc2/fs/ext3/ialloc.c
4370 --- linux-3.1/fs/ext3/ialloc.c 2011-10-24 18:45:27.000000000 +0200
4371 +++ linux-3.1-vs2.3.1-rc2/fs/ext3/ialloc.c 2011-10-24 18:53:33.000000000 +0200
4373 #include <linux/buffer_head.h>
4374 #include <linux/random.h>
4375 #include <linux/bitops.h>
4376 +#include <linux/vs_tag.h>
4377 #include <trace/events/ext3.h>
4379 #include <asm/byteorder.h>
4380 @@ -535,6 +536,7 @@ got:
4381 inode->i_mode = mode;
4382 inode->i_uid = current_fsuid();
4383 inode->i_gid = dir->i_gid;
4384 + inode->i_tag = dx_current_fstag(sb);
4386 inode_init_owner(inode, dir, mode);
4388 diff -NurpP --minimal linux-3.1/fs/ext3/inode.c linux-3.1-vs2.3.1-rc2/fs/ext3/inode.c
4389 --- linux-3.1/fs/ext3/inode.c 2011-10-24 18:45:27.000000000 +0200
4390 +++ linux-3.1-vs2.3.1-rc2/fs/ext3/inode.c 2011-10-24 18:53:33.000000000 +0200
4392 #include <linux/bio.h>
4393 #include <linux/fiemap.h>
4394 #include <linux/namei.h>
4395 +#include <linux/vs_tag.h>
4396 #include <trace/events/ext3.h>
4399 @@ -2834,36 +2835,60 @@ void ext3_set_inode_flags(struct inode *
4401 unsigned int flags = EXT3_I(inode)->i_flags;
4403 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4404 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4405 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4407 + if (flags & EXT3_IMMUTABLE_FL)
4408 + inode->i_flags |= S_IMMUTABLE;
4409 + if (flags & EXT3_IXUNLINK_FL)
4410 + inode->i_flags |= S_IXUNLINK;
4412 if (flags & EXT3_SYNC_FL)
4413 inode->i_flags |= S_SYNC;
4414 if (flags & EXT3_APPEND_FL)
4415 inode->i_flags |= S_APPEND;
4416 - if (flags & EXT3_IMMUTABLE_FL)
4417 - inode->i_flags |= S_IMMUTABLE;
4418 if (flags & EXT3_NOATIME_FL)
4419 inode->i_flags |= S_NOATIME;
4420 if (flags & EXT3_DIRSYNC_FL)
4421 inode->i_flags |= S_DIRSYNC;
4423 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4425 + if (flags & EXT3_BARRIER_FL)
4426 + inode->i_vflags |= V_BARRIER;
4427 + if (flags & EXT3_COW_FL)
4428 + inode->i_vflags |= V_COW;
4431 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
4432 void ext3_get_inode_flags(struct ext3_inode_info *ei)
4434 unsigned int flags = ei->vfs_inode.i_flags;
4435 + unsigned int vflags = ei->vfs_inode.i_vflags;
4437 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
4438 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
4439 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
4440 + EXT3_BARRIER_FL | EXT3_COW_FL);
4442 + if (flags & S_IMMUTABLE)
4443 + ei->i_flags |= EXT3_IMMUTABLE_FL;
4444 + if (flags & S_IXUNLINK)
4445 + ei->i_flags |= EXT3_IXUNLINK_FL;
4447 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
4448 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
4450 ei->i_flags |= EXT3_SYNC_FL;
4451 if (flags & S_APPEND)
4452 ei->i_flags |= EXT3_APPEND_FL;
4453 - if (flags & S_IMMUTABLE)
4454 - ei->i_flags |= EXT3_IMMUTABLE_FL;
4455 if (flags & S_NOATIME)
4456 ei->i_flags |= EXT3_NOATIME_FL;
4457 if (flags & S_DIRSYNC)
4458 ei->i_flags |= EXT3_DIRSYNC_FL;
4460 + if (vflags & V_BARRIER)
4461 + ei->i_flags |= EXT3_BARRIER_FL;
4462 + if (vflags & V_COW)
4463 + ei->i_flags |= EXT3_COW_FL;
4466 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
4467 @@ -2877,6 +2902,8 @@ struct inode *ext3_iget(struct super_blo
4468 transaction_t *transaction;
4474 inode = iget_locked(sb, ino);
4476 @@ -2893,12 +2920,17 @@ struct inode *ext3_iget(struct super_blo
4478 raw_inode = ext3_raw_inode(&iloc);
4479 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
4480 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4481 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4482 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4483 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4484 if(!(test_opt (inode->i_sb, NO_UID32))) {
4485 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4486 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4487 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4488 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4490 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
4491 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
4492 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
4493 + le16_to_cpu(raw_inode->i_raw_tag));
4495 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
4496 inode->i_size = le32_to_cpu(raw_inode->i_size);
4497 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
4498 @@ -3053,6 +3085,8 @@ static int ext3_do_update_inode(handle_t
4499 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
4500 struct ext3_inode_info *ei = EXT3_I(inode);
4501 struct buffer_head *bh = iloc->bh;
4502 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
4503 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
4504 int err = 0, rc, block;
4507 @@ -3067,29 +3101,32 @@ again:
4508 ext3_get_inode_flags(ei);
4509 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
4510 if(!(test_opt(inode->i_sb, NO_UID32))) {
4511 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
4512 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
4513 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
4514 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
4516 * Fix up interoperability with old kernels. Otherwise, old inodes get
4517 * re-used with the upper 16 bits of the uid/gid intact
4520 raw_inode->i_uid_high =
4521 - cpu_to_le16(high_16_bits(inode->i_uid));
4522 + cpu_to_le16(high_16_bits(uid));
4523 raw_inode->i_gid_high =
4524 - cpu_to_le16(high_16_bits(inode->i_gid));
4525 + cpu_to_le16(high_16_bits(gid));
4527 raw_inode->i_uid_high = 0;
4528 raw_inode->i_gid_high = 0;
4531 raw_inode->i_uid_low =
4532 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
4533 + cpu_to_le16(fs_high2lowuid(uid));
4534 raw_inode->i_gid_low =
4535 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
4536 + cpu_to_le16(fs_high2lowgid(gid));
4537 raw_inode->i_uid_high = 0;
4538 raw_inode->i_gid_high = 0;
4540 +#ifdef CONFIG_TAGGING_INTERN
4541 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4543 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4544 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
4545 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
4546 @@ -3249,7 +3286,8 @@ int ext3_setattr(struct dentry *dentry,
4547 if (is_quota_modification(inode, attr))
4548 dquot_initialize(inode);
4549 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
4550 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
4551 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
4552 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
4555 /* (user+group)*(old+new) structure, inode write (sb,
4556 @@ -3271,6 +3309,8 @@ int ext3_setattr(struct dentry *dentry,
4557 inode->i_uid = attr->ia_uid;
4558 if (attr->ia_valid & ATTR_GID)
4559 inode->i_gid = attr->ia_gid;
4560 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
4561 + inode->i_tag = attr->ia_tag;
4562 error = ext3_mark_inode_dirty(handle, inode);
4563 ext3_journal_stop(handle);
4565 diff -NurpP --minimal linux-3.1/fs/ext3/ioctl.c linux-3.1-vs2.3.1-rc2/fs/ext3/ioctl.c
4566 --- linux-3.1/fs/ext3/ioctl.c 2011-10-24 18:45:27.000000000 +0200
4567 +++ linux-3.1-vs2.3.1-rc2/fs/ext3/ioctl.c 2011-10-24 18:53:33.000000000 +0200
4571 #include <linux/fs.h>
4572 +#include <linux/mount.h>
4573 #include <linux/jbd.h>
4574 #include <linux/capability.h>
4575 #include <linux/ext3_fs.h>
4577 #include <linux/compat.h>
4578 #include <asm/uaccess.h>
4581 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
4583 + handle_t *handle = NULL;
4584 + struct ext3_iloc iloc;
4587 + handle = ext3_journal_start(inode, 1);
4588 + if (IS_ERR(handle))
4589 + return PTR_ERR(handle);
4591 + if (IS_SYNC(inode))
4592 + handle->h_sync = 1;
4593 + err = ext3_reserve_inode_write(handle, inode, &iloc);
4597 + inode->i_flags = flags;
4598 + inode->i_vflags = vflags;
4599 + ext3_get_inode_flags(EXT3_I(inode));
4600 + inode->i_ctime = CURRENT_TIME_SEC;
4602 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
4604 + ext3_journal_stop(handle);
4608 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4610 struct inode *inode = filp->f_dentry->d_inode;
4611 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
4613 flags = ext3_mask_flags(inode->i_mode, flags);
4615 + if (IS_BARRIER(inode)) {
4616 + vxwprintk_task(1, "messing with the barrier.");
4620 mutex_lock(&inode->i_mutex);
4622 /* Is it quota file? Do not allow user to mess with it */
4623 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
4625 * This test looks nicer. Thanks to Pauline Middelink
4627 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
4628 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
4629 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
4630 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
4631 if (!capable(CAP_LINUX_IMMUTABLE))
4634 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
4638 - flags = flags & EXT3_FL_USER_MODIFIABLE;
4639 + flags &= EXT3_FL_USER_MODIFIABLE;
4640 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
4641 ei->i_flags = flags;
4643 diff -NurpP --minimal linux-3.1/fs/ext3/namei.c linux-3.1-vs2.3.1-rc2/fs/ext3/namei.c
4644 --- linux-3.1/fs/ext3/namei.c 2011-10-24 18:45:27.000000000 +0200
4645 +++ linux-3.1-vs2.3.1-rc2/fs/ext3/namei.c 2011-10-24 18:53:33.000000000 +0200
4647 #include <linux/quotaops.h>
4648 #include <linux/buffer_head.h>
4649 #include <linux/bio.h>
4650 +#include <linux/vs_tag.h>
4651 #include <trace/events/ext3.h>
4654 @@ -925,6 +926,7 @@ restart:
4655 ll_rw_block(READ | REQ_META | REQ_PRIO,
4658 + dx_propagate_tag(nd, inode);
4660 if ((bh = bh_use[ra_ptr++]) == NULL)
4662 @@ -2535,6 +2537,7 @@ const struct inode_operations ext3_dir_i
4663 .listxattr = ext3_listxattr,
4664 .removexattr = generic_removexattr,
4666 + .sync_flags = ext3_sync_flags,
4667 .get_acl = ext3_get_acl,
4670 diff -NurpP --minimal linux-3.1/fs/ext3/super.c linux-3.1-vs2.3.1-rc2/fs/ext3/super.c
4671 --- linux-3.1/fs/ext3/super.c 2011-10-24 18:45:27.000000000 +0200
4672 +++ linux-3.1-vs2.3.1-rc2/fs/ext3/super.c 2011-10-24 18:53:33.000000000 +0200
4673 @@ -833,7 +833,8 @@ enum {
4674 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
4675 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
4676 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
4677 - Opt_resize, Opt_usrquota, Opt_grpquota
4678 + Opt_resize, Opt_usrquota, Opt_grpquota,
4679 + Opt_tag, Opt_notag, Opt_tagid
4682 static const match_table_t tokens = {
4683 @@ -890,6 +891,9 @@ static const match_table_t tokens = {
4684 {Opt_barrier, "barrier"},
4685 {Opt_nobarrier, "nobarrier"},
4686 {Opt_resize, "resize"},
4688 + {Opt_notag, "notag"},
4689 + {Opt_tagid, "tagid=%u"},
4693 @@ -1042,6 +1046,20 @@ static int parse_options (char *options,
4695 set_opt (sbi->s_mount_opt, NO_UID32);
4697 +#ifndef CONFIG_TAGGING_NONE
4699 + set_opt (sbi->s_mount_opt, TAGGED);
4702 + clear_opt (sbi->s_mount_opt, TAGGED);
4705 +#ifdef CONFIG_PROPAGATE
4708 + set_opt (sbi->s_mount_opt, TAGGED);
4712 clear_opt (sbi->s_mount_opt, CHECK);
4714 @@ -1738,6 +1756,9 @@ static int ext3_fill_super (struct super
4718 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
4719 + sb->s_flags |= MS_TAGGED;
4721 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4722 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
4724 @@ -2619,6 +2640,14 @@ static int ext3_remount (struct super_bl
4725 if (test_opt(sb, ABORT))
4726 ext3_abort(sb, __func__, "Abort forced by user");
4728 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
4729 + !(sb->s_flags & MS_TAGGED)) {
4730 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
4733 + goto restore_opts;
4736 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4737 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
4739 diff -NurpP --minimal linux-3.1/fs/ext4/ext4.h linux-3.1-vs2.3.1-rc2/fs/ext4/ext4.h
4740 --- linux-3.1/fs/ext4/ext4.h 2011-10-24 18:45:27.000000000 +0200
4741 +++ linux-3.1-vs2.3.1-rc2/fs/ext4/ext4.h 2011-10-24 18:53:33.000000000 +0200
4742 @@ -351,8 +351,12 @@ struct flex_groups {
4743 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
4744 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
4745 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
4746 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
4747 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
4749 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
4750 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
4752 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
4753 #define EXT4_FL_USER_MODIFIABLE 0x004B80FF /* User modifiable flags */
4755 @@ -610,7 +614,8 @@ struct ext4_inode {
4756 __le16 l_i_file_acl_high;
4757 __le16 l_i_uid_high; /* these 2 fields */
4758 __le16 l_i_gid_high; /* were reserved2[0] */
4759 - __u32 l_i_reserved2;
4760 + __le16 l_i_tag; /* Context Tag */
4761 + __u16 l_i_reserved2;
4764 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
4765 @@ -728,6 +733,7 @@ do { \
4766 #define i_gid_low i_gid
4767 #define i_uid_high osd2.linux2.l_i_uid_high
4768 #define i_gid_high osd2.linux2.l_i_gid_high
4769 +#define i_raw_tag osd2.linux2.l_i_tag
4770 #define i_reserved2 osd2.linux2.l_i_reserved2
4772 #elif defined(__GNU__)
4773 @@ -904,6 +910,7 @@ struct ext4_inode_info {
4774 #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
4775 #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */
4776 #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
4777 +#define EXT4_MOUNT_TAGGED 0x40000 /* Enable Context Tags */
4778 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
4779 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
4780 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
4781 @@ -2218,6 +2225,7 @@ extern int ext4_map_blocks(handle_t *han
4782 struct ext4_map_blocks *map, int flags);
4783 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
4784 __u64 start, __u64 len);
4785 +extern int ext4_sync_flags(struct inode *, int, int);
4787 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
4788 __u64 start_orig, __u64 start_donor,
4789 diff -NurpP --minimal linux-3.1/fs/ext4/file.c linux-3.1-vs2.3.1-rc2/fs/ext4/file.c
4790 --- linux-3.1/fs/ext4/file.c 2011-10-24 18:45:27.000000000 +0200
4791 +++ linux-3.1-vs2.3.1-rc2/fs/ext4/file.c 2011-10-24 18:53:33.000000000 +0200
4792 @@ -303,5 +303,6 @@ const struct inode_operations ext4_file_
4794 .get_acl = ext4_get_acl,
4795 .fiemap = ext4_fiemap,
4796 + .sync_flags = ext4_sync_flags,
4799 diff -NurpP --minimal linux-3.1/fs/ext4/ialloc.c linux-3.1-vs2.3.1-rc2/fs/ext4/ialloc.c
4800 --- linux-3.1/fs/ext4/ialloc.c 2011-10-24 18:45:27.000000000 +0200
4801 +++ linux-3.1-vs2.3.1-rc2/fs/ext4/ialloc.c 2011-10-24 18:53:33.000000000 +0200
4803 #include <linux/random.h>
4804 #include <linux/bitops.h>
4805 #include <linux/blkdev.h>
4806 +#include <linux/vs_tag.h>
4807 #include <asm/byteorder.h>
4810 @@ -992,6 +993,7 @@ got:
4811 inode->i_mode = mode;
4812 inode->i_uid = current_fsuid();
4813 inode->i_gid = dir->i_gid;
4814 + inode->i_tag = dx_current_fstag(sb);
4816 inode_init_owner(inode, dir, mode);
4818 diff -NurpP --minimal linux-3.1/fs/ext4/inode.c linux-3.1-vs2.3.1-rc2/fs/ext4/inode.c
4819 --- linux-3.1/fs/ext4/inode.c 2011-10-24 18:45:27.000000000 +0200
4820 +++ linux-3.1-vs2.3.1-rc2/fs/ext4/inode.c 2011-10-24 18:53:33.000000000 +0200
4822 #include <linux/printk.h>
4823 #include <linux/slab.h>
4824 #include <linux/ratelimit.h>
4825 +#include <linux/vs_tag.h>
4827 #include "ext4_jbd2.h"
4829 @@ -3323,41 +3324,64 @@ void ext4_set_inode_flags(struct inode *
4831 unsigned int flags = EXT4_I(inode)->i_flags;
4833 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4834 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4835 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4837 + if (flags & EXT4_IMMUTABLE_FL)
4838 + inode->i_flags |= S_IMMUTABLE;
4839 + if (flags & EXT4_IXUNLINK_FL)
4840 + inode->i_flags |= S_IXUNLINK;
4842 if (flags & EXT4_SYNC_FL)
4843 inode->i_flags |= S_SYNC;
4844 if (flags & EXT4_APPEND_FL)
4845 inode->i_flags |= S_APPEND;
4846 - if (flags & EXT4_IMMUTABLE_FL)
4847 - inode->i_flags |= S_IMMUTABLE;
4848 if (flags & EXT4_NOATIME_FL)
4849 inode->i_flags |= S_NOATIME;
4850 if (flags & EXT4_DIRSYNC_FL)
4851 inode->i_flags |= S_DIRSYNC;
4853 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4855 + if (flags & EXT4_BARRIER_FL)
4856 + inode->i_vflags |= V_BARRIER;
4857 + if (flags & EXT4_COW_FL)
4858 + inode->i_vflags |= V_COW;
4861 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
4862 void ext4_get_inode_flags(struct ext4_inode_info *ei)
4864 - unsigned int vfs_fl;
4865 + unsigned int vfs_fl, vfs_vf;
4866 unsigned long old_fl, new_fl;
4869 vfs_fl = ei->vfs_inode.i_flags;
4870 + vfs_vf = ei->vfs_inode.i_vflags;
4871 old_fl = ei->i_flags;
4872 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
4873 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
4875 + EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
4878 + if (vfs_fl & S_IMMUTABLE)
4879 + new_fl |= EXT4_IMMUTABLE_FL;
4880 + if (vfs_fl & S_IXUNLINK)
4881 + new_fl |= EXT4_IXUNLINK_FL;
4883 if (vfs_fl & S_SYNC)
4884 new_fl |= EXT4_SYNC_FL;
4885 if (vfs_fl & S_APPEND)
4886 new_fl |= EXT4_APPEND_FL;
4887 - if (vfs_fl & S_IMMUTABLE)
4888 - new_fl |= EXT4_IMMUTABLE_FL;
4889 if (vfs_fl & S_NOATIME)
4890 new_fl |= EXT4_NOATIME_FL;
4891 if (vfs_fl & S_DIRSYNC)
4892 new_fl |= EXT4_DIRSYNC_FL;
4894 + if (vfs_vf & V_BARRIER)
4895 + new_fl |= EXT4_BARRIER_FL;
4896 + if (vfs_vf & V_COW)
4897 + new_fl |= EXT4_COW_FL;
4898 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
4901 @@ -3393,6 +3417,8 @@ struct inode *ext4_iget(struct super_blo
4902 journal_t *journal = EXT4_SB(sb)->s_journal;
4908 inode = iget_locked(sb, ino);
4910 @@ -3408,12 +3434,16 @@ struct inode *ext4_iget(struct super_blo
4912 raw_inode = ext4_raw_inode(&iloc);
4913 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
4914 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4915 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4916 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4917 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4918 if (!(test_opt(inode->i_sb, NO_UID32))) {
4919 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4920 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4921 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4922 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4924 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
4925 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
4926 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
4927 + le16_to_cpu(raw_inode->i_raw_tag));
4928 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
4930 ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
4931 @@ -3632,6 +3662,8 @@ static int ext4_do_update_inode(handle_t
4932 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
4933 struct ext4_inode_info *ei = EXT4_I(inode);
4934 struct buffer_head *bh = iloc->bh;
4935 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
4936 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
4937 int err = 0, rc, block;
4939 /* For fields not not tracking in the in-memory inode,
4940 @@ -3642,29 +3674,32 @@ static int ext4_do_update_inode(handle_t
4941 ext4_get_inode_flags(ei);
4942 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
4943 if (!(test_opt(inode->i_sb, NO_UID32))) {
4944 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
4945 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
4946 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
4947 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
4949 * Fix up interoperability with old kernels. Otherwise, old inodes get
4950 * re-used with the upper 16 bits of the uid/gid intact
4953 raw_inode->i_uid_high =
4954 - cpu_to_le16(high_16_bits(inode->i_uid));
4955 + cpu_to_le16(high_16_bits(uid));
4956 raw_inode->i_gid_high =
4957 - cpu_to_le16(high_16_bits(inode->i_gid));
4958 + cpu_to_le16(high_16_bits(gid));
4960 raw_inode->i_uid_high = 0;
4961 raw_inode->i_gid_high = 0;
4964 raw_inode->i_uid_low =
4965 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
4966 + cpu_to_le16(fs_high2lowuid(uid));
4967 raw_inode->i_gid_low =
4968 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
4969 + cpu_to_le16(fs_high2lowgid(gid));
4970 raw_inode->i_uid_high = 0;
4971 raw_inode->i_gid_high = 0;
4973 +#ifdef CONFIG_TAGGING_INTERN
4974 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4976 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4978 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
4979 @@ -3850,7 +3885,8 @@ int ext4_setattr(struct dentry *dentry,
4980 if (is_quota_modification(inode, attr))
4981 dquot_initialize(inode);
4982 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
4983 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
4984 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
4985 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
4988 /* (user+group)*(old+new) structure, inode write (sb,
4989 @@ -3872,6 +3908,8 @@ int ext4_setattr(struct dentry *dentry,
4990 inode->i_uid = attr->ia_uid;
4991 if (attr->ia_valid & ATTR_GID)
4992 inode->i_gid = attr->ia_gid;
4993 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
4994 + inode->i_tag = attr->ia_tag;
4995 error = ext4_mark_inode_dirty(handle, inode);
4996 ext4_journal_stop(handle);
4998 diff -NurpP --minimal linux-3.1/fs/ext4/ioctl.c linux-3.1-vs2.3.1-rc2/fs/ext4/ioctl.c
4999 --- linux-3.1/fs/ext4/ioctl.c 2011-10-24 18:45:27.000000000 +0200
5000 +++ linux-3.1-vs2.3.1-rc2/fs/ext4/ioctl.c 2011-10-24 18:53:33.000000000 +0200
5002 #include <linux/compat.h>
5003 #include <linux/mount.h>
5004 #include <linux/file.h>
5005 +#include <linux/vs_tag.h>
5006 #include <asm/uaccess.h>
5007 #include "ext4_jbd2.h"
5011 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
5013 + handle_t *handle = NULL;
5014 + struct ext4_iloc iloc;
5017 + handle = ext4_journal_start(inode, 1);
5018 + if (IS_ERR(handle))
5019 + return PTR_ERR(handle);
5021 + if (IS_SYNC(inode))
5022 + ext4_handle_sync(handle);
5023 + err = ext4_reserve_inode_write(handle, inode, &iloc);
5027 + inode->i_flags = flags;
5028 + inode->i_vflags = vflags;
5029 + ext4_get_inode_flags(EXT4_I(inode));
5030 + inode->i_ctime = ext4_current_time(inode);
5032 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
5034 + ext4_journal_stop(handle);
5038 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5040 struct inode *inode = filp->f_dentry->d_inode;
5041 @@ -50,6 +79,11 @@ long ext4_ioctl(struct file *filp, unsig
5043 flags = ext4_mask_flags(inode->i_mode, flags);
5045 + if (IS_BARRIER(inode)) {
5046 + vxwprintk_task(1, "messing with the barrier.");
5051 mutex_lock(&inode->i_mutex);
5052 /* Is it quota file? Do not allow user to mess with it */
5053 @@ -67,7 +101,9 @@ long ext4_ioctl(struct file *filp, unsig
5055 * This test looks nicer. Thanks to Pauline Middelink
5057 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
5058 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
5059 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
5060 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
5061 if (!capable(CAP_LINUX_IMMUTABLE))
5064 diff -NurpP --minimal linux-3.1/fs/ext4/namei.c linux-3.1-vs2.3.1-rc2/fs/ext4/namei.c
5065 --- linux-3.1/fs/ext4/namei.c 2011-10-24 18:45:27.000000000 +0200
5066 +++ linux-3.1-vs2.3.1-rc2/fs/ext4/namei.c 2011-10-24 18:53:33.000000000 +0200
5068 #include <linux/quotaops.h>
5069 #include <linux/buffer_head.h>
5070 #include <linux/bio.h>
5071 +#include <linux/vs_tag.h>
5073 #include "ext4_jbd2.h"
5075 @@ -925,6 +926,7 @@ restart:
5076 ll_rw_block(READ | REQ_META | REQ_PRIO,
5079 + dx_propagate_tag(nd, inode);
5081 if ((bh = bh_use[ra_ptr++]) == NULL)
5083 @@ -2588,6 +2590,7 @@ const struct inode_operations ext4_dir_i
5085 .get_acl = ext4_get_acl,
5086 .fiemap = ext4_fiemap,
5087 + .sync_flags = ext4_sync_flags,
5090 const struct inode_operations ext4_special_inode_operations = {
5091 diff -NurpP --minimal linux-3.1/fs/ext4/super.c linux-3.1-vs2.3.1-rc2/fs/ext4/super.c
5092 --- linux-3.1/fs/ext4/super.c 2011-10-24 18:45:27.000000000 +0200
5093 +++ linux-3.1-vs2.3.1-rc2/fs/ext4/super.c 2011-10-24 18:53:33.000000000 +0200
5094 @@ -1320,6 +1320,7 @@ enum {
5095 Opt_dioread_nolock, Opt_dioread_lock,
5096 Opt_discard, Opt_nodiscard,
5097 Opt_init_inode_table, Opt_noinit_inode_table,
5098 + Opt_tag, Opt_notag, Opt_tagid
5101 static const match_table_t tokens = {
5102 @@ -1395,6 +1396,9 @@ static const match_table_t tokens = {
5103 {Opt_init_inode_table, "init_itable=%u"},
5104 {Opt_init_inode_table, "init_itable"},
5105 {Opt_noinit_inode_table, "noinit_itable"},
5107 + {Opt_notag, "notag"},
5108 + {Opt_tagid, "tagid=%u"},
5112 @@ -1563,6 +1567,20 @@ static int parse_options(char *options,
5114 set_opt(sb, NO_UID32);
5116 +#ifndef CONFIG_TAGGING_NONE
5118 + set_opt(sb, TAGGED);
5121 + clear_opt(sb, TAGGED);
5124 +#ifdef CONFIG_PROPAGATE
5127 + set_opt(sb, TAGGED);
5133 @@ -3224,6 +3242,9 @@ static int ext4_fill_super(struct super_
5134 &journal_ioprio, NULL, 0))
5137 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
5138 + sb->s_flags |= MS_TAGGED;
5140 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
5141 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
5143 @@ -4351,6 +4372,14 @@ static int ext4_remount(struct super_blo
5144 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
5145 ext4_abort(sb, "Abort forced by user");
5147 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
5148 + !(sb->s_flags & MS_TAGGED)) {
5149 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
5152 + goto restore_opts;
5155 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
5156 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
5158 diff -NurpP --minimal linux-3.1/fs/fcntl.c linux-3.1-vs2.3.1-rc2/fs/fcntl.c
5159 --- linux-3.1/fs/fcntl.c 2011-05-22 16:17:52.000000000 +0200
5160 +++ linux-3.1-vs2.3.1-rc2/fs/fcntl.c 2011-10-24 18:53:33.000000000 +0200
5162 #include <linux/signal.h>
5163 #include <linux/rcupdate.h>
5164 #include <linux/pid_namespace.h>
5165 +#include <linux/vs_limit.h>
5167 #include <asm/poll.h>
5168 #include <asm/siginfo.h>
5169 @@ -103,6 +104,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
5172 filp_close(tofree, files);
5174 + vx_openfd_inc(newfd); /* fd was unused */
5178 @@ -447,6 +450,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
5179 filp = fget_raw(fd);
5182 + if (!vx_files_avail(1))
5185 if (unlikely(filp->f_mode & FMODE_PATH)) {
5186 if (!check_fcntl_cmd(cmd)) {
5187 diff -NurpP --minimal linux-3.1/fs/file.c linux-3.1-vs2.3.1-rc2/fs/file.c
5188 --- linux-3.1/fs/file.c 2011-05-22 16:17:52.000000000 +0200
5189 +++ linux-3.1-vs2.3.1-rc2/fs/file.c 2011-10-24 18:53:33.000000000 +0200
5191 #include <linux/spinlock.h>
5192 #include <linux/rcupdate.h>
5193 #include <linux/workqueue.h>
5194 +#include <linux/vs_limit.h>
5196 struct fdtable_defer {
5198 @@ -359,6 +360,8 @@ struct files_struct *dup_fd(struct files
5199 struct file *f = *old_fds++;
5202 + /* TODO: sum it first for check and performance */
5203 + vx_openfd_inc(open_files - i);
5206 * The fd may be claimed in the fd bitmap but not yet
5207 @@ -466,6 +469,7 @@ repeat:
5209 FD_CLR(fd, fdt->close_on_exec);
5211 + vx_openfd_inc(fd);
5214 if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
5215 diff -NurpP --minimal linux-3.1/fs/file_table.c linux-3.1-vs2.3.1-rc2/fs/file_table.c
5216 --- linux-3.1/fs/file_table.c 2011-10-24 18:45:27.000000000 +0200
5217 +++ linux-3.1-vs2.3.1-rc2/fs/file_table.c 2011-10-24 18:53:33.000000000 +0200
5219 #include <linux/percpu_counter.h>
5220 #include <linux/percpu.h>
5221 #include <linux/ima.h>
5222 +#include <linux/vs_limit.h>
5223 +#include <linux/vs_context.h>
5225 #include <linux/atomic.h>
5227 @@ -135,6 +137,8 @@ struct file *get_empty_filp(void)
5228 spin_lock_init(&f->f_lock);
5229 eventpoll_init_file(f);
5230 /* f->f_version: 0 */
5231 + f->f_xid = vx_current_xid();
5236 @@ -253,6 +257,8 @@ static void __fput(struct file *file)
5238 fops_put(file->f_op);
5239 put_pid(file->f_owner.pid);
5240 + vx_files_dec(file);
5242 file_sb_list_del(file);
5243 if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
5244 i_readcount_dec(inode);
5245 @@ -383,6 +389,8 @@ void put_filp(struct file *file)
5247 if (atomic_long_dec_and_test(&file->f_count)) {
5248 security_file_free(file);
5249 + vx_files_dec(file);
5251 file_sb_list_del(file);
5254 diff -NurpP --minimal linux-3.1/fs/fs_struct.c linux-3.1-vs2.3.1-rc2/fs/fs_struct.c
5255 --- linux-3.1/fs/fs_struct.c 2011-03-15 18:07:31.000000000 +0100
5256 +++ linux-3.1-vs2.3.1-rc2/fs/fs_struct.c 2011-10-24 18:53:33.000000000 +0200
5258 #include <linux/path.h>
5259 #include <linux/slab.h>
5260 #include <linux/fs_struct.h>
5261 +#include <linux/vserver/global.h>
5262 #include "internal.h"
5264 static inline void path_get_longterm(struct path *path)
5265 @@ -96,6 +97,7 @@ void free_fs_struct(struct fs_struct *fs
5267 path_put_longterm(&fs->root);
5268 path_put_longterm(&fs->pwd);
5269 + atomic_dec(&vs_global_fs);
5270 kmem_cache_free(fs_cachep, fs);
5273 @@ -135,6 +137,7 @@ struct fs_struct *copy_fs_struct(struct
5275 path_get_longterm(&fs->pwd);
5276 spin_unlock(&old->lock);
5277 + atomic_inc(&vs_global_fs);
5281 diff -NurpP --minimal linux-3.1/fs/gfs2/file.c linux-3.1-vs2.3.1-rc2/fs/gfs2/file.c
5282 --- linux-3.1/fs/gfs2/file.c 2011-10-24 18:45:27.000000000 +0200
5283 +++ linux-3.1-vs2.3.1-rc2/fs/gfs2/file.c 2011-10-24 18:53:33.000000000 +0200
5284 @@ -134,6 +134,9 @@ static const u32 fsflags_to_gfs2[32] = {
5285 [7] = GFS2_DIF_NOATIME,
5286 [12] = GFS2_DIF_EXHASH,
5287 [14] = GFS2_DIF_INHERIT_JDATA,
5288 + [27] = GFS2_DIF_IXUNLINK,
5289 + [26] = GFS2_DIF_BARRIER,
5290 + [29] = GFS2_DIF_COW,
5293 static const u32 gfs2_to_fsflags[32] = {
5294 @@ -143,6 +146,9 @@ static const u32 gfs2_to_fsflags[32] = {
5295 [gfs2fl_NoAtime] = FS_NOATIME_FL,
5296 [gfs2fl_ExHash] = FS_INDEX_FL,
5297 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
5298 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
5299 + [gfs2fl_Barrier] = FS_BARRIER_FL,
5300 + [gfs2fl_Cow] = FS_COW_FL,
5303 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
5304 @@ -173,12 +179,18 @@ void gfs2_set_inode_flags(struct inode *
5306 struct gfs2_inode *ip = GFS2_I(inode);
5307 unsigned int flags = inode->i_flags;
5308 + unsigned int vflags = inode->i_vflags;
5310 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5311 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC | S_NOSEC);
5313 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_NOSEC);
5314 if ((ip->i_eattr == 0) && !is_sxid(inode->i_mode))
5315 inode->i_flags |= S_NOSEC;
5316 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
5317 flags |= S_IMMUTABLE;
5318 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
5319 + flags |= S_IXUNLINK;
5321 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
5323 if (ip->i_diskflags & GFS2_DIF_NOATIME)
5324 @@ -186,6 +198,43 @@ void gfs2_set_inode_flags(struct inode *
5325 if (ip->i_diskflags & GFS2_DIF_SYNC)
5327 inode->i_flags = flags;
5329 + vflags &= ~(V_BARRIER | V_COW);
5331 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
5332 + vflags |= V_BARRIER;
5333 + if (ip->i_diskflags & GFS2_DIF_COW)
5335 + inode->i_vflags = vflags;
5338 +void gfs2_get_inode_flags(struct inode *inode)
5340 + struct gfs2_inode *ip = GFS2_I(inode);
5341 + unsigned int flags = inode->i_flags;
5342 + unsigned int vflags = inode->i_vflags;
5344 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
5345 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
5346 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
5347 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
5349 + if (flags & S_IMMUTABLE)
5350 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
5351 + if (flags & S_IXUNLINK)
5352 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
5354 + if (flags & S_APPEND)
5355 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
5356 + if (flags & S_NOATIME)
5357 + ip->i_diskflags |= GFS2_DIF_NOATIME;
5358 + if (flags & S_SYNC)
5359 + ip->i_diskflags |= GFS2_DIF_SYNC;
5361 + if (vflags & V_BARRIER)
5362 + ip->i_diskflags |= GFS2_DIF_BARRIER;
5363 + if (vflags & V_COW)
5364 + ip->i_diskflags |= GFS2_DIF_COW;
5367 /* Flags that can be set by user space */
5368 @@ -297,6 +346,37 @@ static int gfs2_set_flags(struct file *f
5369 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
5372 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
5374 + struct gfs2_inode *ip = GFS2_I(inode);
5375 + struct gfs2_sbd *sdp = GFS2_SB(inode);
5376 + struct buffer_head *bh;
5377 + struct gfs2_holder gh;
5380 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
5383 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
5386 + error = gfs2_meta_inode_buffer(ip, &bh);
5388 + goto out_trans_end;
5389 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
5390 + inode->i_flags = flags;
5391 + inode->i_vflags = vflags;
5392 + gfs2_get_inode_flags(inode);
5393 + gfs2_dinode_out(ip, bh->b_data);
5395 + gfs2_set_aops(inode);
5397 + gfs2_trans_end(sdp);
5399 + gfs2_glock_dq_uninit(&gh);
5403 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5406 diff -NurpP --minimal linux-3.1/fs/gfs2/inode.h linux-3.1-vs2.3.1-rc2/fs/gfs2/inode.h
5407 --- linux-3.1/fs/gfs2/inode.h 2011-10-24 18:45:27.000000000 +0200
5408 +++ linux-3.1-vs2.3.1-rc2/fs/gfs2/inode.h 2011-10-24 18:53:33.000000000 +0200
5409 @@ -120,6 +120,7 @@ extern const struct file_operations gfs2
5410 extern const struct file_operations gfs2_dir_fops_nolock;
5412 extern void gfs2_set_inode_flags(struct inode *inode);
5413 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
5415 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
5416 extern const struct file_operations gfs2_file_fops;
5417 diff -NurpP --minimal linux-3.1/fs/inode.c linux-3.1-vs2.3.1-rc2/fs/inode.c
5418 --- linux-3.1/fs/inode.c 2011-10-24 18:45:27.000000000 +0200
5419 +++ linux-3.1-vs2.3.1-rc2/fs/inode.c 2011-10-24 18:53:33.000000000 +0200
5421 #include <linux/ima.h>
5422 #include <linux/cred.h>
5423 #include <linux/buffer_head.h> /* for inode_has_buffers */
5424 +#include <linux/vs_tag.h>
5425 #include "internal.h"
5428 @@ -137,6 +138,9 @@ int inode_init_always(struct super_block
5429 struct address_space *const mapping = &inode->i_data;
5433 + /* essential because of inode slab reuse */
5435 inode->i_blkbits = sb->s_blocksize_bits;
5437 atomic_set(&inode->i_count, 1);
5438 @@ -158,6 +162,7 @@ int inode_init_always(struct super_block
5439 inode->i_bdev = NULL;
5440 inode->i_cdev = NULL;
5442 + inode->i_mdev = 0;
5443 inode->dirtied_when = 0;
5445 if (security_inode_alloc(inode))
5446 @@ -399,6 +404,8 @@ void __insert_inode_hash(struct inode *i
5448 EXPORT_SYMBOL(__insert_inode_hash);
5450 +EXPORT_SYMBOL_GPL(__iget);
5453 * __remove_inode_hash - remove an inode from the hash
5454 * @inode: inode to unhash
5455 @@ -1626,9 +1633,11 @@ void init_special_inode(struct inode *in
5456 if (S_ISCHR(mode)) {
5457 inode->i_fop = &def_chr_fops;
5458 inode->i_rdev = rdev;
5459 + inode->i_mdev = rdev;
5460 } else if (S_ISBLK(mode)) {
5461 inode->i_fop = &def_blk_fops;
5462 inode->i_rdev = rdev;
5463 + inode->i_mdev = rdev;
5464 } else if (S_ISFIFO(mode))
5465 inode->i_fop = &def_fifo_fops;
5466 else if (S_ISSOCK(mode))
5467 @@ -1657,6 +1666,7 @@ void inode_init_owner(struct inode *inod
5469 inode->i_gid = current_fsgid();
5470 inode->i_mode = mode;
5471 + inode->i_tag = dx_current_fstag(inode->i_sb);
5473 EXPORT_SYMBOL(inode_init_owner);
5475 diff -NurpP --minimal linux-3.1/fs/ioctl.c linux-3.1-vs2.3.1-rc2/fs/ioctl.c
5476 --- linux-3.1/fs/ioctl.c 2011-05-22 16:17:52.000000000 +0200
5477 +++ linux-3.1-vs2.3.1-rc2/fs/ioctl.c 2011-10-24 18:53:33.000000000 +0200
5479 #include <linux/writeback.h>
5480 #include <linux/buffer_head.h>
5481 #include <linux/falloc.h>
5482 +#include <linux/proc_fs.h>
5483 +#include <linux/vserver/inode.h>
5484 +#include <linux/vs_tag.h>
5486 #include <asm/ioctls.h>
5488 diff -NurpP --minimal linux-3.1/fs/ioprio.c linux-3.1-vs2.3.1-rc2/fs/ioprio.c
5489 --- linux-3.1/fs/ioprio.c 2011-01-05 21:50:24.000000000 +0100
5490 +++ linux-3.1-vs2.3.1-rc2/fs/ioprio.c 2011-10-24 18:53:33.000000000 +0200
5492 #include <linux/syscalls.h>
5493 #include <linux/security.h>
5494 #include <linux/pid_namespace.h>
5495 +#include <linux/vs_base.h>
5497 int set_task_ioprio(struct task_struct *task, int ioprio)
5499 @@ -119,6 +120,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
5501 pgrp = find_vpid(who);
5502 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
5503 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5505 ret = set_task_ioprio(p, ioprio);
5508 @@ -208,6 +211,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
5510 pgrp = find_vpid(who);
5511 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
5512 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5514 tmpio = get_task_ioprio(p);
5517 diff -NurpP --minimal linux-3.1/fs/jfs/file.c linux-3.1-vs2.3.1-rc2/fs/jfs/file.c
5518 --- linux-3.1/fs/jfs/file.c 2011-10-24 18:45:27.000000000 +0200
5519 +++ linux-3.1-vs2.3.1-rc2/fs/jfs/file.c 2011-10-24 18:53:33.000000000 +0200
5520 @@ -109,7 +109,8 @@ int jfs_setattr(struct dentry *dentry, s
5521 if (is_quota_modification(inode, iattr))
5522 dquot_initialize(inode);
5523 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
5524 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
5525 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
5526 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
5527 rc = dquot_transfer(inode, iattr);
5530 @@ -142,6 +143,7 @@ const struct inode_operations jfs_file_i
5531 #ifdef CONFIG_JFS_POSIX_ACL
5532 .get_acl = jfs_get_acl,
5534 + .sync_flags = jfs_sync_flags,
5537 const struct file_operations jfs_file_operations = {
5538 diff -NurpP --minimal linux-3.1/fs/jfs/ioctl.c linux-3.1-vs2.3.1-rc2/fs/jfs/ioctl.c
5539 --- linux-3.1/fs/jfs/ioctl.c 2011-05-22 16:17:52.000000000 +0200
5540 +++ linux-3.1-vs2.3.1-rc2/fs/jfs/ioctl.c 2011-10-24 18:53:33.000000000 +0200
5542 #include <linux/mount.h>
5543 #include <linux/time.h>
5544 #include <linux/sched.h>
5545 +#include <linux/mount.h>
5546 #include <asm/current.h>
5547 #include <asm/uaccess.h>
5549 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
5553 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
5555 + inode->i_flags = flags;
5556 + inode->i_vflags = vflags;
5557 + jfs_get_inode_flags(JFS_IP(inode));
5558 + inode->i_ctime = CURRENT_TIME_SEC;
5559 + mark_inode_dirty(inode);
5563 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5565 struct inode *inode = filp->f_dentry->d_inode;
5566 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
5567 if (!S_ISDIR(inode->i_mode))
5568 flags &= ~JFS_DIRSYNC_FL;
5570 + if (IS_BARRIER(inode)) {
5571 + vxwprintk_task(1, "messing with the barrier.");
5575 /* Is it quota file? Do not allow user to mess with it */
5576 if (IS_NOQUOTA(inode)) {
5578 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
5579 * the relevant capability.
5581 if ((oldflags & JFS_IMMUTABLE_FL) ||
5582 - ((flags ^ oldflags) &
5583 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
5584 + ((flags ^ oldflags) & (JFS_APPEND_FL |
5585 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
5586 if (!capable(CAP_LINUX_IMMUTABLE)) {
5587 mutex_unlock(&inode->i_mutex);
5589 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
5593 - flags = flags & JFS_FL_USER_MODIFIABLE;
5594 + flags &= JFS_FL_USER_MODIFIABLE;
5595 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
5596 jfs_inode->mode2 = flags;
5598 diff -NurpP --minimal linux-3.1/fs/jfs/jfs_dinode.h linux-3.1-vs2.3.1-rc2/fs/jfs/jfs_dinode.h
5599 --- linux-3.1/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
5600 +++ linux-3.1-vs2.3.1-rc2/fs/jfs/jfs_dinode.h 2011-10-24 18:53:33.000000000 +0200
5601 @@ -161,9 +161,13 @@ struct dinode {
5603 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
5604 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
5605 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
5607 -#define JFS_FL_USER_VISIBLE 0x03F80000
5608 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
5609 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
5610 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
5612 +#define JFS_FL_USER_VISIBLE 0x07F80000
5613 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
5614 #define JFS_FL_INHERIT 0x03C80000
5616 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
5617 diff -NurpP --minimal linux-3.1/fs/jfs/jfs_filsys.h linux-3.1-vs2.3.1-rc2/fs/jfs/jfs_filsys.h
5618 --- linux-3.1/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
5619 +++ linux-3.1-vs2.3.1-rc2/fs/jfs/jfs_filsys.h 2011-10-24 18:53:33.000000000 +0200
5621 #define JFS_NAME_MAX 255
5622 #define JFS_PATH_MAX BPSIZE
5624 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
5627 * file system state (superblock state)
5628 diff -NurpP --minimal linux-3.1/fs/jfs/jfs_imap.c linux-3.1-vs2.3.1-rc2/fs/jfs/jfs_imap.c
5629 --- linux-3.1/fs/jfs/jfs_imap.c 2011-07-22 11:18:05.000000000 +0200
5630 +++ linux-3.1-vs2.3.1-rc2/fs/jfs/jfs_imap.c 2011-10-24 18:53:33.000000000 +0200
5632 #include <linux/pagemap.h>
5633 #include <linux/quotaops.h>
5634 #include <linux/slab.h>
5635 +#include <linux/vs_tag.h>
5637 #include "jfs_incore.h"
5638 #include "jfs_inode.h"
5639 @@ -3058,6 +3059,8 @@ static int copy_from_dinode(struct dinod
5641 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
5642 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
5646 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
5647 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
5648 @@ -3078,14 +3081,18 @@ static int copy_from_dinode(struct dinod
5650 ip->i_nlink = le32_to_cpu(dip->di_nlink);
5652 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
5653 + uid = le32_to_cpu(dip->di_uid);
5654 + gid = le32_to_cpu(dip->di_gid);
5655 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
5657 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
5659 ip->i_uid = jfs_ip->saved_uid;
5661 ip->i_uid = sbi->uid;
5664 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
5665 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
5667 ip->i_gid = jfs_ip->saved_gid;
5669 @@ -3150,14 +3157,12 @@ static void copy_to_dinode(struct dinode
5670 dip->di_size = cpu_to_le64(ip->i_size);
5671 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
5672 dip->di_nlink = cpu_to_le32(ip->i_nlink);
5673 - if (sbi->uid == -1)
5674 - dip->di_uid = cpu_to_le32(ip->i_uid);
5676 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
5677 - if (sbi->gid == -1)
5678 - dip->di_gid = cpu_to_le32(ip->i_gid);
5680 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
5682 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
5683 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
5684 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
5685 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
5687 jfs_get_inode_flags(jfs_ip);
5689 * mode2 is only needed for storing the higher order bits.
5690 diff -NurpP --minimal linux-3.1/fs/jfs/jfs_inode.c linux-3.1-vs2.3.1-rc2/fs/jfs/jfs_inode.c
5691 --- linux-3.1/fs/jfs/jfs_inode.c 2010-08-02 16:52:49.000000000 +0200
5692 +++ linux-3.1-vs2.3.1-rc2/fs/jfs/jfs_inode.c 2011-10-24 18:53:33.000000000 +0200
5695 #include <linux/fs.h>
5696 #include <linux/quotaops.h>
5697 +#include <linux/vs_tag.h>
5698 #include "jfs_incore.h"
5699 #include "jfs_inode.h"
5700 #include "jfs_filsys.h"
5701 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
5703 unsigned int flags = JFS_IP(inode)->mode2;
5705 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
5706 - S_NOATIME | S_DIRSYNC | S_SYNC);
5707 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5708 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5710 if (flags & JFS_IMMUTABLE_FL)
5711 inode->i_flags |= S_IMMUTABLE;
5712 + if (flags & JFS_IXUNLINK_FL)
5713 + inode->i_flags |= S_IXUNLINK;
5715 + if (flags & JFS_SYNC_FL)
5716 + inode->i_flags |= S_SYNC;
5717 if (flags & JFS_APPEND_FL)
5718 inode->i_flags |= S_APPEND;
5719 if (flags & JFS_NOATIME_FL)
5720 inode->i_flags |= S_NOATIME;
5721 if (flags & JFS_DIRSYNC_FL)
5722 inode->i_flags |= S_DIRSYNC;
5723 - if (flags & JFS_SYNC_FL)
5724 - inode->i_flags |= S_SYNC;
5726 + inode->i_vflags &= ~(V_BARRIER | V_COW);
5728 + if (flags & JFS_BARRIER_FL)
5729 + inode->i_vflags |= V_BARRIER;
5730 + if (flags & JFS_COW_FL)
5731 + inode->i_vflags |= V_COW;
5734 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
5736 unsigned int flags = jfs_ip->vfs_inode.i_flags;
5737 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
5739 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
5740 + JFS_APPEND_FL | JFS_NOATIME_FL |
5741 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
5742 + JFS_BARRIER_FL | JFS_COW_FL);
5744 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
5745 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
5746 if (flags & S_IMMUTABLE)
5747 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
5748 + if (flags & S_IXUNLINK)
5749 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
5751 if (flags & S_APPEND)
5752 jfs_ip->mode2 |= JFS_APPEND_FL;
5753 if (flags & S_NOATIME)
5754 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
5755 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
5757 jfs_ip->mode2 |= JFS_SYNC_FL;
5759 + if (vflags & V_BARRIER)
5760 + jfs_ip->mode2 |= JFS_BARRIER_FL;
5761 + if (vflags & V_COW)
5762 + jfs_ip->mode2 |= JFS_COW_FL;
5766 diff -NurpP --minimal linux-3.1/fs/jfs/jfs_inode.h linux-3.1-vs2.3.1-rc2/fs/jfs/jfs_inode.h
5767 --- linux-3.1/fs/jfs/jfs_inode.h 2011-10-24 18:45:27.000000000 +0200
5768 +++ linux-3.1-vs2.3.1-rc2/fs/jfs/jfs_inode.h 2011-10-24 18:53:33.000000000 +0200
5769 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
5770 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
5771 int fh_len, int fh_type);
5772 extern void jfs_set_inode_flags(struct inode *);
5773 +extern int jfs_sync_flags(struct inode *, int, int);
5774 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
5775 extern int jfs_setattr(struct dentry *, struct iattr *);
5777 diff -NurpP --minimal linux-3.1/fs/jfs/namei.c linux-3.1-vs2.3.1-rc2/fs/jfs/namei.c
5778 --- linux-3.1/fs/jfs/namei.c 2011-10-24 18:45:27.000000000 +0200
5779 +++ linux-3.1-vs2.3.1-rc2/fs/jfs/namei.c 2011-10-24 18:53:33.000000000 +0200
5781 #include <linux/ctype.h>
5782 #include <linux/quotaops.h>
5783 #include <linux/exportfs.h>
5784 +#include <linux/vs_tag.h>
5785 #include "jfs_incore.h"
5786 #include "jfs_superblock.h"
5787 #include "jfs_inode.h"
5788 @@ -1474,6 +1475,7 @@ static struct dentry *jfs_lookup(struct
5789 jfs_err("jfs_lookup: iget failed on inum %d", (uint)inum);
5792 + dx_propagate_tag(nd, ip);
5793 return d_splice_alias(ip, dentry);
5796 @@ -1538,6 +1540,7 @@ const struct inode_operations jfs_dir_in
5797 #ifdef CONFIG_JFS_POSIX_ACL
5798 .get_acl = jfs_get_acl,
5800 + .sync_flags = jfs_sync_flags,
5803 const struct file_operations jfs_dir_operations = {
5804 diff -NurpP --minimal linux-3.1/fs/jfs/super.c linux-3.1-vs2.3.1-rc2/fs/jfs/super.c
5805 --- linux-3.1/fs/jfs/super.c 2011-05-22 16:17:53.000000000 +0200
5806 +++ linux-3.1-vs2.3.1-rc2/fs/jfs/super.c 2011-10-24 18:53:33.000000000 +0200
5807 @@ -198,7 +198,8 @@ static void jfs_put_super(struct super_b
5809 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
5810 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
5811 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
5812 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
5813 + Opt_tag, Opt_notag, Opt_tagid
5816 static const match_table_t tokens = {
5817 @@ -208,6 +209,10 @@ static const match_table_t tokens = {
5818 {Opt_resize, "resize=%u"},
5819 {Opt_resize_nosize, "resize"},
5820 {Opt_errors, "errors=%s"},
5822 + {Opt_notag, "notag"},
5823 + {Opt_tagid, "tagid=%u"},
5824 + {Opt_tag, "tagxid"},
5825 {Opt_ignore, "noquota"},
5826 {Opt_ignore, "quota"},
5827 {Opt_usrquota, "usrquota"},
5828 @@ -342,6 +347,20 @@ static int parse_options(char *options,
5832 +#ifndef CONFIG_TAGGING_NONE
5834 + *flag |= JFS_TAGGED;
5837 + *flag &= JFS_TAGGED;
5840 +#ifdef CONFIG_PROPAGATE
5843 + *flag |= JFS_TAGGED;
5847 printk("jfs: Unrecognized mount option \"%s\" "
5848 " or missing value\n", p);
5849 @@ -373,6 +392,12 @@ static int jfs_remount(struct super_bloc
5853 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
5854 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
5860 if (sb->s_flags & MS_RDONLY) {
5862 @@ -455,6 +480,9 @@ static int jfs_fill_super(struct super_b
5863 #ifdef CONFIG_JFS_POSIX_ACL
5864 sb->s_flags |= MS_POSIXACL;
5866 + /* map mount option tagxid */
5867 + if (sbi->flag & JFS_TAGGED)
5868 + sb->s_flags |= MS_TAGGED;
5871 printk(KERN_ERR "resize option for remount only\n");
5872 diff -NurpP --minimal linux-3.1/fs/libfs.c linux-3.1-vs2.3.1-rc2/fs/libfs.c
5873 --- linux-3.1/fs/libfs.c 2011-10-24 18:45:27.000000000 +0200
5874 +++ linux-3.1-vs2.3.1-rc2/fs/libfs.c 2011-10-24 18:53:33.000000000 +0200
5875 @@ -135,7 +135,8 @@ static inline unsigned char dt_type(stru
5876 * both impossible due to the lock on directory.
5879 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
5880 +static inline int do_dcache_readdir_filter(struct file *filp,
5881 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
5883 struct dentry *dentry = filp->f_path.dentry;
5884 struct dentry *cursor = filp->private_data;
5885 @@ -166,6 +167,8 @@ int dcache_readdir(struct file * filp, v
5886 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
5887 struct dentry *next;
5888 next = list_entry(p, struct dentry, d_u.d_child);
5889 + if (filter && !filter(next))
5891 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
5892 if (!simple_positive(next)) {
5893 spin_unlock(&next->d_lock);
5894 @@ -192,6 +195,17 @@ int dcache_readdir(struct file * filp, v
5898 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
5900 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
5903 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
5904 + int (*filter)(struct dentry *))
5906 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
5909 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
5912 @@ -975,6 +989,7 @@ EXPORT_SYMBOL(dcache_dir_close);
5913 EXPORT_SYMBOL(dcache_dir_lseek);
5914 EXPORT_SYMBOL(dcache_dir_open);
5915 EXPORT_SYMBOL(dcache_readdir);
5916 +EXPORT_SYMBOL(dcache_readdir_filter);
5917 EXPORT_SYMBOL(generic_read_dir);
5918 EXPORT_SYMBOL(mount_pseudo);
5919 EXPORT_SYMBOL(simple_write_begin);
5920 diff -NurpP --minimal linux-3.1/fs/locks.c linux-3.1-vs2.3.1-rc2/fs/locks.c
5921 --- linux-3.1/fs/locks.c 2011-10-24 18:45:27.000000000 +0200
5922 +++ linux-3.1-vs2.3.1-rc2/fs/locks.c 2011-10-24 18:53:33.000000000 +0200
5924 #include <linux/time.h>
5925 #include <linux/rcupdate.h>
5926 #include <linux/pid_namespace.h>
5927 +#include <linux/vs_base.h>
5928 +#include <linux/vs_limit.h>
5930 #include <asm/uaccess.h>
5932 @@ -170,11 +172,17 @@ static void locks_init_lock_heads(struct
5933 /* Allocate an empty lock structure. */
5934 struct file_lock *locks_alloc_lock(void)
5936 - struct file_lock *fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
5937 + struct file_lock *fl;
5940 - locks_init_lock_heads(fl);
5941 + if (!vx_locks_avail(1))
5944 + fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
5947 + locks_init_lock_heads(fl);
5952 EXPORT_SYMBOL_GPL(locks_alloc_lock);
5953 @@ -202,6 +210,7 @@ void locks_free_lock(struct file_lock *f
5954 BUG_ON(!list_empty(&fl->fl_block));
5955 BUG_ON(!list_empty(&fl->fl_link));
5958 locks_release_private(fl);
5959 kmem_cache_free(filelock_cache, fl);
5961 @@ -211,6 +220,7 @@ void locks_init_lock(struct file_lock *f
5963 memset(fl, 0, sizeof(struct file_lock));
5964 locks_init_lock_heads(fl);
5968 EXPORT_SYMBOL(locks_init_lock);
5969 @@ -251,6 +261,7 @@ void locks_copy_lock(struct file_lock *n
5970 new->fl_file = fl->fl_file;
5971 new->fl_ops = fl->fl_ops;
5972 new->fl_lmops = fl->fl_lmops;
5973 + new->fl_xid = fl->fl_xid;
5975 locks_copy_private(new, fl);
5977 @@ -289,6 +300,11 @@ static int flock_make_lock(struct file *
5978 fl->fl_flags = FL_FLOCK;
5980 fl->fl_end = OFFSET_MAX;
5982 + vxd_assert(filp->f_xid == vx_current_xid(),
5983 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
5984 + fl->fl_xid = filp->f_xid;
5989 @@ -438,6 +454,7 @@ static int lease_init(struct file *filp,
5991 fl->fl_owner = current->files;
5992 fl->fl_pid = current->tgid;
5993 + fl->fl_xid = vx_current_xid();
5996 fl->fl_flags = FL_LEASE;
5997 @@ -457,6 +474,11 @@ static struct file_lock *lease_alloc(str
5999 return ERR_PTR(error);
6001 + fl->fl_xid = vx_current_xid();
6003 + vxd_assert(filp->f_xid == fl->fl_xid,
6004 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
6006 error = lease_init(filp, type, fl);
6008 locks_free_lock(fl);
6009 @@ -758,6 +780,7 @@ static int flock_lock_file(struct file *
6013 + new_fl->fl_xid = -1;
6015 for_each_lock(inode, before) {
6016 struct file_lock *fl = *before;
6017 @@ -778,6 +801,7 @@ find_conflict:
6019 locks_copy_lock(new_fl, request);
6020 locks_insert_lock(before, new_fl);
6021 + vx_locks_inc(new_fl);
6025 @@ -788,7 +812,8 @@ out:
6029 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
6030 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
6031 + struct file_lock *conflock, xid_t xid)
6033 struct file_lock *fl;
6034 struct file_lock *new_fl = NULL;
6035 @@ -798,6 +823,8 @@ static int __posix_lock_file(struct inod
6036 struct file_lock **before;
6037 int error, added = 0;
6039 + vxd_assert(xid == vx_current_xid(),
6040 + "xid(%d) == current(%d)", xid, vx_current_xid());
6042 * We may need two file_lock structures for this operation,
6043 * so we get them in advance to avoid races.
6044 @@ -808,7 +835,11 @@ static int __posix_lock_file(struct inod
6045 (request->fl_type != F_UNLCK ||
6046 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
6047 new_fl = locks_alloc_lock();
6048 + new_fl->fl_xid = xid;
6049 + vx_locks_inc(new_fl);
6050 new_fl2 = locks_alloc_lock();
6051 + new_fl2->fl_xid = xid;
6052 + vx_locks_inc(new_fl2);
6056 @@ -1007,7 +1038,8 @@ static int __posix_lock_file(struct inod
6057 int posix_lock_file(struct file *filp, struct file_lock *fl,
6058 struct file_lock *conflock)
6060 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
6061 + return __posix_lock_file(filp->f_path.dentry->d_inode,
6062 + fl, conflock, filp->f_xid);
6064 EXPORT_SYMBOL(posix_lock_file);
6066 @@ -1097,7 +1129,7 @@ int locks_mandatory_area(int read_write,
6067 fl.fl_end = offset + count - 1;
6070 - error = __posix_lock_file(inode, &fl, NULL);
6071 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
6072 if (error != FILE_LOCK_DEFERRED)
6074 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
6075 @@ -1410,6 +1442,7 @@ int generic_setlease(struct file *filp,
6078 locks_insert_lock(before, lease);
6079 + vx_locks_inc(lease);
6083 @@ -1794,6 +1827,11 @@ int fcntl_setlk(unsigned int fd, struct
6084 if (file_lock == NULL)
6087 + vxd_assert(filp->f_xid == vx_current_xid(),
6088 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6089 + file_lock->fl_xid = filp->f_xid;
6090 + vx_locks_inc(file_lock);
6093 * This might block, so we do it before checking the inode.
6095 @@ -1912,6 +1950,11 @@ int fcntl_setlk64(unsigned int fd, struc
6096 if (file_lock == NULL)
6099 + vxd_assert(filp->f_xid == vx_current_xid(),
6100 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6101 + file_lock->fl_xid = filp->f_xid;
6102 + vx_locks_inc(file_lock);
6105 * This might block, so we do it before checking the inode.
6107 @@ -2177,8 +2220,11 @@ static int locks_show(struct seq_file *f
6109 lock_get_status(f, fl, *((loff_t *)f->private), "");
6111 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
6112 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
6113 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
6115 lock_get_status(f, bfl, *((loff_t *)f->private), " ->");
6120 diff -NurpP --minimal linux-3.1/fs/namei.c linux-3.1-vs2.3.1-rc2/fs/namei.c
6121 --- linux-3.1/fs/namei.c 2011-10-24 18:45:27.000000000 +0200
6122 +++ linux-3.1-vs2.3.1-rc2/fs/namei.c 2011-10-30 02:53:05.000000000 +0200
6124 #include <linux/device_cgroup.h>
6125 #include <linux/fs_struct.h>
6126 #include <linux/posix_acl.h>
6127 +#include <linux/proc_fs.h>
6128 +#include <linux/vserver/inode.h>
6129 +#include <linux/vs_base.h>
6130 +#include <linux/vs_tag.h>
6131 +#include <linux/vs_cowbl.h>
6132 +#include <linux/vs_device.h>
6133 +#include <linux/vs_context.h>
6134 +#include <linux/pid_namespace.h>
6135 #include <asm/uaccess.h>
6137 #include "internal.h"
6138 @@ -220,6 +228,84 @@ static int check_acl(struct inode *inode
6142 +static inline int dx_barrier(const struct inode *inode)
6144 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
6145 + vxwprintk_task(1, "did hit the barrier.");
6151 +static int __dx_permission(const struct inode *inode, int mask)
6153 + if (dx_barrier(inode))
6156 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
6157 + /* devpts is xid tagged */
6158 + if (S_ISDIR(inode->i_mode) ||
6159 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
6162 + /* just pretend we didn't find anything */
6165 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
6166 + struct proc_dir_entry *de = PDE(inode);
6168 + if (de && !vx_hide_check(0, de->vx_flags))
6171 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
6173 + struct task_struct *tsk;
6175 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
6176 + vx_flags(VXF_STATE_SETUP, 0))
6179 + pid = PROC_I(inode)->pid;
6183 + tsk = pid_task(pid, PIDTYPE_PID);
6184 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
6185 + tsk, (tsk ? vx_task_xid(tsk) : 0));
6186 + if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
6190 + /* FIXME: Should we block some entries here? */
6195 + if (dx_notagcheck(inode->i_sb) ||
6196 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
6205 +int dx_permission(const struct inode *inode, int mask)
6207 + int ret = __dx_permission(inode, mask);
6208 + if (unlikely(ret)) {
6209 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
6210 + if (inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
6213 + "denied [0x%x] access to inode %s:%p[#%d,%lu]",
6214 + mask, inode->i_sb->s_id, inode, inode->i_tag,
6221 * This does basic POSIX ACL permission checking
6223 @@ -355,10 +441,14 @@ int inode_permission(struct inode *inode
6225 * Nobody gets write access to an immutable file.
6227 - if (IS_IMMUTABLE(inode))
6228 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
6232 + retval = dx_permission(inode, mask);
6236 retval = do_inode_permission(inode, mask);
6239 @@ -1034,7 +1124,8 @@ static void follow_dotdot(struct nameida
6241 if (nd->path.dentry == nd->root.dentry &&
6242 nd->path.mnt == nd->root.mnt) {
6244 + /* for sane '/' avoid follow_mount() */
6247 if (nd->path.dentry != nd->path.mnt->mnt_root) {
6248 /* rare case of legitimate dget_parent()... */
6249 @@ -1143,6 +1234,9 @@ static int do_lookup(struct nameidata *n
6251 if (unlikely(d_need_lookup(dentry)))
6254 + /* FIXME: check dx permission */
6257 path->dentry = dentry;
6258 if (unlikely(!__follow_mount_rcu(nd, path, inode)))
6259 @@ -1204,6 +1298,8 @@ retry:
6263 + /* FIXME: check dx permission */
6266 path->dentry = dentry;
6267 err = follow_managed(path, nd->flags);
6268 @@ -1890,7 +1986,7 @@ static int may_delete(struct inode *dir,
6271 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
6272 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
6273 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
6276 if (!S_ISDIR(victim->d_inode->i_mode))
6277 @@ -1970,19 +2066,25 @@ int vfs_create(struct inode *dir, struct
6279 int error = may_create(dir, dentry);
6283 + vxdprintk(VXD_CBIT(misc, 3), "may_create failed with %d", error);
6287 if (!dir->i_op->create)
6288 return -EACCES; /* shouldn't it be ENOSYS? */
6291 error = security_inode_create(dir, dentry, mode);
6294 + vxdprintk(VXD_CBIT(misc, 3), "security_inode_create failed with %d", error);
6297 error = dir->i_op->create(dir, dentry, mode, nd);
6299 fsnotify_create(dir, dentry);
6301 + vxdprintk(VXD_CBIT(misc, 3), "i_op->create failed with %d", error);
6305 @@ -2017,6 +2119,15 @@ static int may_open(struct path *path, i
6309 +#ifdef CONFIG_VSERVER_COWBL
6310 + if (IS_COW(inode) &&
6311 + ((flag & O_ACCMODE) != O_RDONLY)) {
6312 + if (IS_COW_LINK(inode))
6314 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
6315 + mark_inode_dirty(inode);
6318 error = inode_permission(inode, acc_mode);
6321 @@ -2233,6 +2344,16 @@ ok:
6324 error = may_open(&nd->path, acc_mode, open_flag);
6325 +#ifdef CONFIG_VSERVER_COWBL
6326 + if (error == -EMLINK) {
6327 + struct dentry *dentry;
6328 + dentry = cow_break_link(pathname);
6329 + if (IS_ERR(dentry))
6330 + error = PTR_ERR(dentry);
6337 filp = nameidata_to_filp(nd);
6338 @@ -2275,6 +2396,7 @@ static struct file *path_openat(int dfd,
6343 filp = get_empty_filp();
6345 return ERR_PTR(-ENFILE);
6346 @@ -2312,6 +2434,17 @@ static struct file *path_openat(int dfd,
6347 filp = do_last(nd, &path, op, pathname);
6348 put_link(nd, &link, cookie);
6351 +#ifdef CONFIG_VSERVER_COWBL
6352 + if (filp == ERR_PTR(-EMLINK)) {
6353 + if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
6354 + path_put(&nd->root);
6357 + release_open_intent(nd);
6362 if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
6363 path_put(&nd->root);
6364 @@ -2401,6 +2534,11 @@ struct dentry *kern_path_create(int dfd,
6368 + vxdprintk(VXD_CBIT(misc, 3), "kern_path_create path.dentry = %p (%.*s), dentry = %p (%.*s), d_inode = %p",
6369 + path->dentry, path->dentry->d_name.len,
6370 + path->dentry->d_name.name, dentry,
6371 + dentry->d_name.len, dentry->d_name.name,
6372 + path->dentry->d_inode);
6376 @@ -2882,7 +3020,7 @@ int vfs_link(struct dentry *old_dentry,
6378 * A link to an append-only or immutable file cannot be created.
6380 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
6381 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
6383 if (!dir->i_op->link)
6385 @@ -3263,6 +3401,227 @@ int vfs_follow_link(struct nameidata *nd
6386 return __vfs_follow_link(nd, link);
6390 +#ifdef CONFIG_VSERVER_COWBL
6393 +long do_cow_splice(struct file *in, struct file *out, size_t len)
6397 + return do_splice_direct(in, &ppos, out, len, 0);
6400 +struct dentry *cow_break_link(const char *pathname)
6402 + int ret, mode, pathlen, redo = 0;
6403 + struct nameidata old_nd, dir_nd;
6404 + struct path old_path, dir_path;
6405 + struct dentry *dir, *old_dentry, *new_dentry = NULL;
6406 + struct file *old_file;
6407 + struct file *new_file;
6408 + char *to, *path, pad='\251';
6411 + vxdprintk(VXD_CBIT(misc, 1),
6412 + "cow_break_link(" VS_Q("%s") ")", pathname);
6413 + path = kmalloc(PATH_MAX, GFP_KERNEL);
6418 + /* old_nd will have refs to dentry and mnt */
6419 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
6420 + vxdprintk(VXD_CBIT(misc, 2),
6421 + "do_path_lookup(old): %d (%d mnt refs)",
6422 + ret, mnt_get_count(old_nd.path.mnt));
6424 + goto out_free_path;
6426 + old_path = old_nd.path;
6427 + old_dentry = old_path.dentry;
6428 + mode = old_dentry->d_inode->i_mode;
6430 + to = d_path(&old_path, path, PATH_MAX-2);
6431 + pathlen = strlen(to);
6432 + vxdprintk(VXD_CBIT(misc, 2),
6433 + "old path " VS_Q("%s") " [%p:" VS_Q("%.*s") ":%d]", to,
6435 + old_dentry->d_name.len, old_dentry->d_name.name,
6436 + old_dentry->d_name.len);
6438 + to[pathlen + 1] = 0;
6440 + new_dentry = NULL;
6441 + to[pathlen] = pad--;
6443 + if (pad <= '\240')
6446 + vxdprintk(VXD_CBIT(misc, 1), "temp copy " VS_Q("%s"), to);
6447 + /* dir_nd will have refs to dentry and mnt */
6448 + ret = do_path_lookup(AT_FDCWD, to,
6449 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
6450 + vxdprintk(VXD_CBIT(misc, 2), "do_path_lookup(new): %d", ret);
6454 + /* this puppy downs the dir inode mutex if successful */
6455 + new_dentry = kern_path_create(AT_FDCWD, to, &dir_path, 0);
6456 + if (!new_dentry || IS_ERR(new_dentry)) {
6457 + path_put(&dir_nd.path);
6458 + vxdprintk(VXD_CBIT(misc, 2),
6459 + "kern_path_create(new) failed with %ld",
6460 + PTR_ERR(new_dentry));
6463 + path_put(&dir_path);
6464 + vxdprintk(VXD_CBIT(misc, 2),
6465 + "kern_path_create(new): %p [" VS_Q("%.*s") ":%d]",
6467 + new_dentry->d_name.len, new_dentry->d_name.name,
6468 + new_dentry->d_name.len);
6470 + dir = dir_nd.path.dentry;
6472 + ret = vfs_create(dir->d_inode, new_dentry, mode, &dir_nd);
6473 + vxdprintk(VXD_CBIT(misc, 2),
6474 + "vfs_create(new): %d", ret);
6475 + if (ret == -EEXIST) {
6476 + mutex_unlock(&dir->d_inode->i_mutex);
6477 + path_put(&dir_nd.path);
6482 + goto out_unlock_new;
6484 + /* drop out early, ret passes ENOENT */
6486 + if ((redo = d_unhashed(old_dentry)))
6487 + goto out_unlock_new;
6489 + path_get(&old_path);
6490 + /* this one cleans up the dentry/mnt in case of failure */
6491 + old_file = dentry_open(old_dentry, old_path.mnt,
6492 + O_RDONLY, current_cred());
6493 + vxdprintk(VXD_CBIT(misc, 2),
6494 + "dentry_open(old): %p", old_file);
6495 + if (IS_ERR(old_file)) {
6496 + ret = PTR_ERR(old_file);
6497 + goto out_unlock_new;
6501 + mntget(old_path.mnt);
6502 + /* this one cleans up the dentry/mnt in case of failure */
6503 + new_file = dentry_open(new_dentry, old_path.mnt,
6504 + O_WRONLY, current_cred());
6505 + vxdprintk(VXD_CBIT(misc, 2),
6506 + "dentry_open(new): %p", new_file);
6507 + if (IS_ERR(new_file)) {
6508 + ret = PTR_ERR(new_file);
6509 + goto out_fput_old;
6512 + size = i_size_read(old_file->f_dentry->d_inode);
6513 + ret = do_cow_splice(old_file, new_file, size);
6514 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
6516 + goto out_fput_both;
6517 + } else if (ret < size) {
6519 + goto out_fput_both;
6521 + struct inode *old_inode = old_dentry->d_inode;
6522 + struct inode *new_inode = new_dentry->d_inode;
6523 + struct iattr attr = {
6524 + .ia_uid = old_inode->i_uid,
6525 + .ia_gid = old_inode->i_gid,
6526 + .ia_valid = ATTR_UID | ATTR_GID
6529 + setattr_copy(new_inode, &attr);
6530 + mark_inode_dirty(new_inode);
6533 + mutex_lock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
6535 + /* drop out late */
6537 + if ((redo = d_unhashed(old_dentry)))
6540 + vxdprintk(VXD_CBIT(misc, 2),
6541 + "vfs_rename: [" VS_Q("%*s") ":%d] -> [" VS_Q("%*s") ":%d]",
6542 + new_dentry->d_name.len, new_dentry->d_name.name,
6543 + new_dentry->d_name.len,
6544 + old_dentry->d_name.len, old_dentry->d_name.name,
6545 + old_dentry->d_name.len);
6546 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_dentry,
6547 + old_dentry->d_parent->d_inode, old_dentry);
6548 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
6551 + mutex_unlock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
6554 + vxdprintk(VXD_CBIT(misc, 3),
6555 + "fput(new_file=%p[#%ld])", new_file,
6556 + atomic_long_read(&new_file->f_count));
6560 + vxdprintk(VXD_CBIT(misc, 3),
6561 + "fput(old_file=%p[#%ld])", old_file,
6562 + atomic_long_read(&old_file->f_count));
6566 + mutex_unlock(&dir->d_inode->i_mutex);
6570 + /* error path cleanup */
6571 + vfs_unlink(dir->d_inode, new_dentry);
6575 + goto out_rel_both;
6576 + /* lookup dentry once again */
6577 + /* old_nd.path is freed as old_path in out_rel_old */
6578 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
6580 + goto out_rel_both;
6583 + new_dentry = old_nd.path.dentry;
6584 + vxdprintk(VXD_CBIT(misc, 2),
6585 + "do_path_lookup(redo): %p [" VS_Q("%.*s") ":%d]",
6587 + new_dentry->d_name.len, new_dentry->d_name.name,
6588 + new_dentry->d_name.len);
6592 + path_put(&dir_nd.path);
6594 + path_put(&old_path);
6600 + new_dentry = ERR_PTR(ret);
6602 + vxdprintk(VXD_CBIT(misc, 3),
6603 + "cow_break_link returning with %p (%d mount refs)",
6604 + new_dentry, mnt_get_count(old_nd.path.mnt));
6605 + return new_dentry;
6610 /* get the link contents into pagecache */
6611 static char *page_getlink(struct dentry * dentry, struct page **ppage)
6613 diff -NurpP --minimal linux-3.1/fs/namespace.c linux-3.1-vs2.3.1-rc2/fs/namespace.c
6614 --- linux-3.1/fs/namespace.c 2011-10-24 18:45:27.000000000 +0200
6615 +++ linux-3.1-vs2.3.1-rc2/fs/namespace.c 2011-10-24 18:53:33.000000000 +0200
6617 #include <linux/idr.h>
6618 #include <linux/fs_struct.h>
6619 #include <linux/fsnotify.h>
6620 +#include <linux/vs_base.h>
6621 +#include <linux/vs_context.h>
6622 +#include <linux/vs_tag.h>
6623 +#include <linux/vserver/space.h>
6624 +#include <linux/vserver/global.h>
6625 #include <asm/uaccess.h>
6626 #include <asm/unistd.h>
6628 @@ -679,6 +684,10 @@ vfs_kern_mount(struct file_system_type *
6630 return ERR_PTR(-ENODEV);
6632 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
6633 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
6634 + return ERR_PTR(-EPERM);
6636 mnt = alloc_vfsmnt(name);
6638 return ERR_PTR(-ENOMEM);
6639 @@ -724,6 +733,7 @@ static struct vfsmount *clone_mnt(struct
6640 mnt->mnt_root = dget(root);
6641 mnt->mnt_mountpoint = mnt->mnt_root;
6642 mnt->mnt_parent = mnt;
6643 + mnt->mnt_tag = old->mnt_tag;
6645 if (flag & CL_SLAVE) {
6646 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
6647 @@ -852,6 +862,31 @@ static inline void mangle(struct seq_fil
6648 seq_escape(m, s, " \t\n\\");
6651 +static int mnt_is_reachable(struct vfsmount *mnt)
6654 + struct dentry *point;
6657 + if (mnt == mnt->mnt_ns->root)
6660 + br_read_lock(vfsmount_lock);
6661 + root = current->fs->root;
6662 + point = root.dentry;
6664 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
6665 + point = mnt->mnt_mountpoint;
6666 + mnt = mnt->mnt_parent;
6669 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
6671 + br_read_unlock(vfsmount_lock);
6677 * Simple .show_options callback for filesystems which don't want to
6678 * implement more complex mount option showing.
6679 @@ -954,6 +989,8 @@ static int show_sb_opts(struct seq_file
6680 { MS_SYNCHRONOUS, ",sync" },
6681 { MS_DIRSYNC, ",dirsync" },
6682 { MS_MANDLOCK, ",mand" },
6683 + { MS_TAGGED, ",tag" },
6684 + { MS_NOTAGCHECK, ",notagcheck" },
6687 const struct proc_fs_info *fs_infop;
6688 @@ -1000,16 +1037,26 @@ static int show_vfsmnt(struct seq_file *
6690 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
6692 - if (mnt->mnt_sb->s_op->show_devname) {
6693 - err = mnt->mnt_sb->s_op->show_devname(m, mnt);
6696 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6698 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6701 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6702 + mnt == current->fs->root.mnt) {
6703 + seq_puts(m, "/dev/root / ");
6705 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
6706 + if (mnt->mnt_sb->s_op->show_devname) {
6707 + err = mnt->mnt_sb->s_op->show_devname(m, mnt);
6711 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
6714 + seq_path(m, &mnt_path, " \t\n\\");
6718 - seq_path(m, &mnt_path, " \t\n\\");
6720 show_type(m, mnt->mnt_sb);
6721 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
6722 err = show_sb_opts(m, mnt->mnt_sb);
6723 @@ -1039,6 +1086,11 @@ static int show_mountinfo(struct seq_fil
6724 struct path root = p->root;
6727 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6729 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6732 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
6733 MAJOR(sb->s_dev), MINOR(sb->s_dev));
6734 if (sb->s_op->show_path)
6735 @@ -1107,21 +1159,31 @@ static int show_vfsstat(struct seq_file
6736 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
6740 - if (mnt->mnt_sb->s_op->show_devname) {
6741 - err = mnt->mnt_sb->s_op->show_devname(m, mnt);
6742 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6744 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6747 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6748 + mnt == current->fs->root.mnt) {
6749 + seq_puts(m, "device /dev/root mounted on / ");
6751 - if (mnt->mnt_devname) {
6752 - seq_puts(m, "device ");
6753 - mangle(m, mnt->mnt_devname);
6755 - seq_puts(m, "no device");
6758 + if (mnt->mnt_sb->s_op->show_devname) {
6759 + err = mnt->mnt_sb->s_op->show_devname(m, mnt);
6761 + if (mnt->mnt_devname) {
6762 + seq_puts(m, "device ");
6763 + mangle(m, mnt->mnt_devname);
6765 + seq_puts(m, "no device");
6769 - seq_puts(m, " mounted on ");
6770 - seq_path(m, &mnt_path, " \t\n\\");
6773 + seq_puts(m, " mounted on ");
6774 + seq_path(m, &mnt_path, " \t\n\\");
6778 /* file system type */
6779 seq_puts(m, "with fstype ");
6780 @@ -1380,7 +1442,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
6784 - if (!capable(CAP_SYS_ADMIN))
6785 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
6788 retval = do_umount(path.mnt, flags);
6789 @@ -1406,7 +1468,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
6791 static int mount_is_safe(struct path *path)
6793 - if (capable(CAP_SYS_ADMIN))
6794 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
6798 @@ -1716,7 +1778,7 @@ static int do_change_type(struct path *p
6802 - if (!capable(CAP_SYS_ADMIN))
6803 + if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
6806 if (path->dentry != path->mnt->mnt_root)
6807 @@ -1732,6 +1794,7 @@ static int do_change_type(struct path *p
6811 + // mnt->mnt_flags = mnt_flags;
6813 br_write_lock(vfsmount_lock);
6814 for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
6815 @@ -1747,12 +1810,14 @@ static int do_change_type(struct path *p
6816 * do loopback mount.
6818 static int do_loopback(struct path *path, char *old_name,
6820 + tag_t tag, unsigned long flags, int mnt_flags)
6822 LIST_HEAD(umount_list);
6823 struct path old_path;
6824 struct vfsmount *mnt = NULL;
6825 int err = mount_is_safe(path);
6826 + int recurse = flags & MS_REC;
6830 if (!old_name || !*old_name)
6831 @@ -1818,12 +1883,12 @@ static int change_mount_flags(struct vfs
6832 * on it - tough luck.
6834 static int do_remount(struct path *path, int flags, int mnt_flags,
6836 + void *data, xid_t xid)
6839 struct super_block *sb = path->mnt->mnt_sb;
6841 - if (!capable(CAP_SYS_ADMIN))
6842 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
6845 if (!check_mnt(path->mnt))
6846 @@ -1871,7 +1936,7 @@ static int do_move_mount(struct path *pa
6847 struct path old_path, parent_path;
6850 - if (!capable(CAP_SYS_ADMIN))
6851 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
6853 if (!old_name || !*old_name)
6855 @@ -2022,7 +2087,7 @@ static int do_new_mount(struct path *pat
6858 /* we need capabilities... */
6859 - if (!capable(CAP_SYS_ADMIN))
6860 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
6863 mnt = do_kern_mount(type, flags, name, data);
6864 @@ -2291,6 +2356,7 @@ long do_mount(char *dev_name, char *dir_
6871 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
6872 @@ -2318,6 +2384,12 @@ long do_mount(char *dev_name, char *dir_
6873 if (!(flags & MS_NOATIME))
6874 mnt_flags |= MNT_RELATIME;
6876 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
6877 + /* FIXME: bind and re-mounts get the tag flag? */
6878 + if (flags & (MS_BIND|MS_REMOUNT))
6879 + flags |= MS_TAGID;
6882 /* Separate the per-mountpoint flags */
6883 if (flags & MS_NOSUID)
6884 mnt_flags |= MNT_NOSUID;
6885 @@ -2334,15 +2406,17 @@ long do_mount(char *dev_name, char *dir_
6886 if (flags & MS_RDONLY)
6887 mnt_flags |= MNT_READONLY;
6889 + if (!capable(CAP_SYS_ADMIN))
6890 + mnt_flags |= MNT_NODEV;
6891 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
6892 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
6895 if (flags & MS_REMOUNT)
6896 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
6899 else if (flags & MS_BIND)
6900 - retval = do_loopback(&path, dev_name, flags & MS_REC);
6901 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
6902 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
6903 retval = do_change_type(&path, flags);
6904 else if (flags & MS_MOVE)
6905 @@ -2442,6 +2516,7 @@ static struct mnt_namespace *dup_mnt_ns(
6906 q = next_mnt(q, new_ns->root);
6908 up_write(&namespace_sem);
6909 + atomic_inc(&vs_global_mnt_ns);
6913 @@ -2581,9 +2656,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
6917 - if (IS_MNT_SHARED(old.mnt) ||
6918 + if ((IS_MNT_SHARED(old.mnt) ||
6919 IS_MNT_SHARED(new.mnt->mnt_parent) ||
6920 - IS_MNT_SHARED(root.mnt->mnt_parent))
6921 + IS_MNT_SHARED(root.mnt->mnt_parent)) &&
6922 + !vx_flags(VXF_STATE_SETUP, 0))
6924 if (!check_mnt(root.mnt) || !check_mnt(new.mnt))
6926 @@ -2715,6 +2791,7 @@ void put_mnt_ns(struct mnt_namespace *ns
6927 br_write_unlock(vfsmount_lock);
6928 up_write(&namespace_sem);
6929 release_mounts(&umount_list);
6930 + atomic_dec(&vs_global_mnt_ns);
6933 EXPORT_SYMBOL(put_mnt_ns);
6934 diff -NurpP --minimal linux-3.1/fs/nfs/client.c linux-3.1-vs2.3.1-rc2/fs/nfs/client.c
6935 --- linux-3.1/fs/nfs/client.c 2011-10-24 18:45:27.000000000 +0200
6936 +++ linux-3.1-vs2.3.1-rc2/fs/nfs/client.c 2011-10-24 18:53:33.000000000 +0200
6937 @@ -778,6 +778,9 @@ static int nfs_init_server_rpcclient(str
6938 if (server->flags & NFS_MOUNT_SOFT)
6939 server->client->cl_softrtry = 1;
6941 + server->client->cl_tag = 0;
6942 + if (server->flags & NFS_MOUNT_TAGGED)
6943 + server->client->cl_tag = 1;
6947 @@ -952,6 +955,10 @@ static void nfs_server_set_fsinfo(struct
6948 server->acdirmin = server->acdirmax = 0;
6951 + /* FIXME: needs fsinfo
6952 + if (server->flags & NFS_MOUNT_TAGGED)
6953 + sb->s_flags |= MS_TAGGED; */
6955 server->maxfilesize = fsinfo->maxfilesize;
6957 server->time_delta = fsinfo->time_delta;
6958 diff -NurpP --minimal linux-3.1/fs/nfs/dir.c linux-3.1-vs2.3.1-rc2/fs/nfs/dir.c
6959 --- linux-3.1/fs/nfs/dir.c 2011-10-24 18:45:27.000000000 +0200
6960 +++ linux-3.1-vs2.3.1-rc2/fs/nfs/dir.c 2011-10-24 18:53:33.000000000 +0200
6962 #include <linux/sched.h>
6963 #include <linux/kmemleak.h>
6964 #include <linux/xattr.h>
6965 +#include <linux/vs_tag.h>
6967 #include "delegation.h"
6969 @@ -1311,6 +1312,7 @@ static struct dentry *nfs_lookup(struct
6971 goto out_unblock_sillyrename;
6973 + dx_propagate_tag(nd, inode);
6975 res = d_materialise_unique(dentry, inode);
6977 diff -NurpP --minimal linux-3.1/fs/nfs/inode.c linux-3.1-vs2.3.1-rc2/fs/nfs/inode.c
6978 --- linux-3.1/fs/nfs/inode.c 2011-10-24 18:45:27.000000000 +0200
6979 +++ linux-3.1-vs2.3.1-rc2/fs/nfs/inode.c 2011-10-24 18:53:33.000000000 +0200
6981 #include <linux/nfs_xdr.h>
6982 #include <linux/slab.h>
6983 #include <linux/compat.h>
6984 +#include <linux/vs_tag.h>
6986 #include <asm/system.h>
6987 #include <asm/uaccess.h>
6988 @@ -273,6 +274,8 @@ nfs_fhget(struct super_block *sb, struct
6989 if (inode->i_state & I_NEW) {
6990 struct nfs_inode *nfsi = NFS_I(inode);
6991 unsigned long now = jiffies;
6995 /* We set i_ino for the few things that still rely on it,
6996 * such as stat(2) */
6997 @@ -321,8 +324,8 @@ nfs_fhget(struct super_block *sb, struct
6998 nfsi->change_attr = 0;
7001 - inode->i_uid = -2;
7002 - inode->i_gid = -2;
7005 inode->i_blocks = 0;
7006 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
7008 @@ -359,13 +362,13 @@ nfs_fhget(struct super_block *sb, struct
7009 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
7010 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
7011 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
7012 - inode->i_uid = fattr->uid;
7014 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
7015 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
7016 | NFS_INO_INVALID_ACCESS
7017 | NFS_INO_INVALID_ACL;
7018 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
7019 - inode->i_gid = fattr->gid;
7021 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
7022 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
7023 | NFS_INO_INVALID_ACCESS
7024 @@ -378,6 +381,11 @@ nfs_fhget(struct super_block *sb, struct
7026 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
7028 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7029 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7030 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7031 + /* maybe fattr->xid someday */
7033 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
7034 nfsi->attrtimeo_timestamp = now;
7035 nfsi->access_cache = RB_ROOT;
7036 @@ -494,6 +502,8 @@ void nfs_setattr_update_inode(struct ino
7037 inode->i_uid = attr->ia_uid;
7038 if ((attr->ia_valid & ATTR_GID) != 0)
7039 inode->i_gid = attr->ia_gid;
7040 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
7041 + inode->i_tag = attr->ia_tag;
7042 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7043 spin_unlock(&inode->i_lock);
7045 @@ -943,6 +953,9 @@ static int nfs_check_inode_attributes(st
7046 struct nfs_inode *nfsi = NFS_I(inode);
7047 loff_t cur_size, new_isize;
7048 unsigned long invalid = 0;
7054 /* Has the inode gone and changed behind our back? */
7055 @@ -966,13 +979,18 @@ static int nfs_check_inode_attributes(st
7056 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
7059 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7060 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7061 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7063 /* Have any file permissions changed? */
7064 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
7065 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7066 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
7067 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
7068 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7069 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
7070 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
7071 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7072 + /* maybe check for tag too? */
7074 /* Has the link count changed? */
7075 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
7076 @@ -1207,6 +1225,9 @@ static int nfs_update_inode(struct inode
7077 unsigned long invalid = 0;
7078 unsigned long now = jiffies;
7079 unsigned long save_cache_validity;
7084 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
7085 __func__, inode->i_sb->s_id, inode->i_ino,
7086 @@ -1314,6 +1335,9 @@ static int nfs_update_inode(struct inode
7087 | NFS_INO_REVAL_PAGECACHE
7088 | NFS_INO_REVAL_FORCED);
7090 + uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
7091 + gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
7092 + tag = inode->i_tag;
7094 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
7095 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
7096 @@ -1335,9 +1359,9 @@ static int nfs_update_inode(struct inode
7097 | NFS_INO_REVAL_FORCED);
7099 if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
7100 - if (inode->i_uid != fattr->uid) {
7101 + if (uid != fattr->uid) {
7102 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7103 - inode->i_uid = fattr->uid;
7106 } else if (server->caps & NFS_CAP_OWNER)
7107 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
7108 @@ -1346,9 +1370,9 @@ static int nfs_update_inode(struct inode
7109 | NFS_INO_REVAL_FORCED);
7111 if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
7112 - if (inode->i_gid != fattr->gid) {
7113 + if (gid != fattr->gid) {
7114 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7115 - inode->i_gid = fattr->gid;
7118 } else if (server->caps & NFS_CAP_OWNER_GROUP)
7119 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
7120 @@ -1356,6 +1380,10 @@ static int nfs_update_inode(struct inode
7121 | NFS_INO_INVALID_ACL
7122 | NFS_INO_REVAL_FORCED);
7124 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7125 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7126 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, tag);
7128 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
7129 if (inode->i_nlink != fattr->nlink) {
7130 invalid |= NFS_INO_INVALID_ATTR;
7131 diff -NurpP --minimal linux-3.1/fs/nfs/nfs3xdr.c linux-3.1-vs2.3.1-rc2/fs/nfs/nfs3xdr.c
7132 --- linux-3.1/fs/nfs/nfs3xdr.c 2011-03-15 18:07:32.000000000 +0100
7133 +++ linux-3.1-vs2.3.1-rc2/fs/nfs/nfs3xdr.c 2011-10-24 18:53:33.000000000 +0200
7135 #include <linux/nfs3.h>
7136 #include <linux/nfs_fs.h>
7137 #include <linux/nfsacl.h>
7138 +#include <linux/vs_tag.h>
7139 #include "internal.h"
7141 #define NFSDBG_FACILITY NFSDBG_XDR
7142 @@ -562,7 +563,8 @@ static __be32 *xdr_decode_nfstime3(__be3
7146 -static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
7147 +static void encode_sattr3(struct xdr_stream *xdr,
7148 + const struct iattr *attr, int tag)
7152 @@ -594,15 +596,19 @@ static void encode_sattr3(struct xdr_str
7156 - if (attr->ia_valid & ATTR_UID) {
7157 + if (attr->ia_valid & ATTR_UID ||
7158 + (tag && (attr->ia_valid & ATTR_TAG))) {
7160 - *p++ = cpu_to_be32(attr->ia_uid);
7161 + *p++ = cpu_to_be32(TAGINO_UID(tag,
7162 + attr->ia_uid, attr->ia_tag));
7166 - if (attr->ia_valid & ATTR_GID) {
7167 + if (attr->ia_valid & ATTR_GID ||
7168 + (tag && (attr->ia_valid & ATTR_TAG))) {
7170 - *p++ = cpu_to_be32(attr->ia_gid);
7171 + *p++ = cpu_to_be32(TAGINO_GID(tag,
7172 + attr->ia_gid, attr->ia_tag));
7176 @@ -878,7 +884,7 @@ static void nfs3_xdr_enc_setattr3args(st
7177 const struct nfs3_sattrargs *args)
7179 encode_nfs_fh3(xdr, args->fh);
7180 - encode_sattr3(xdr, args->sattr);
7181 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
7182 encode_sattrguard3(xdr, args);
7185 @@ -1028,13 +1034,13 @@ static void nfs3_xdr_enc_write3args(stru
7188 static void encode_createhow3(struct xdr_stream *xdr,
7189 - const struct nfs3_createargs *args)
7190 + const struct nfs3_createargs *args, int tag)
7192 encode_uint32(xdr, args->createmode);
7193 switch (args->createmode) {
7194 case NFS3_CREATE_UNCHECKED:
7195 case NFS3_CREATE_GUARDED:
7196 - encode_sattr3(xdr, args->sattr);
7197 + encode_sattr3(xdr, args->sattr, tag);
7199 case NFS3_CREATE_EXCLUSIVE:
7200 encode_createverf3(xdr, args->verifier);
7201 @@ -1049,7 +1055,7 @@ static void nfs3_xdr_enc_create3args(str
7202 const struct nfs3_createargs *args)
7204 encode_diropargs3(xdr, args->fh, args->name, args->len);
7205 - encode_createhow3(xdr, args);
7206 + encode_createhow3(xdr, args, req->rq_task->tk_client->cl_tag);
7210 @@ -1065,7 +1071,7 @@ static void nfs3_xdr_enc_mkdir3args(stru
7211 const struct nfs3_mkdirargs *args)
7213 encode_diropargs3(xdr, args->fh, args->name, args->len);
7214 - encode_sattr3(xdr, args->sattr);
7215 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
7219 @@ -1082,9 +1088,9 @@ static void nfs3_xdr_enc_mkdir3args(stru
7222 static void encode_symlinkdata3(struct xdr_stream *xdr,
7223 - const struct nfs3_symlinkargs *args)
7224 + const struct nfs3_symlinkargs *args, int tag)
7226 - encode_sattr3(xdr, args->sattr);
7227 + encode_sattr3(xdr, args->sattr, tag);
7228 encode_nfspath3(xdr, args->pages, args->pathlen);
7231 @@ -1093,7 +1099,7 @@ static void nfs3_xdr_enc_symlink3args(st
7232 const struct nfs3_symlinkargs *args)
7234 encode_diropargs3(xdr, args->fromfh, args->fromname, args->fromlen);
7235 - encode_symlinkdata3(xdr, args);
7236 + encode_symlinkdata3(xdr, args, req->rq_task->tk_client->cl_tag);
7240 @@ -1121,24 +1127,24 @@ static void nfs3_xdr_enc_symlink3args(st
7243 static void encode_devicedata3(struct xdr_stream *xdr,
7244 - const struct nfs3_mknodargs *args)
7245 + const struct nfs3_mknodargs *args, int tag)
7247 - encode_sattr3(xdr, args->sattr);
7248 + encode_sattr3(xdr, args->sattr, tag);
7249 encode_specdata3(xdr, args->rdev);
7252 static void encode_mknoddata3(struct xdr_stream *xdr,
7253 - const struct nfs3_mknodargs *args)
7254 + const struct nfs3_mknodargs *args, int tag)
7256 encode_ftype3(xdr, args->type);
7257 switch (args->type) {
7260 - encode_devicedata3(xdr, args);
7261 + encode_devicedata3(xdr, args, tag);
7265 - encode_sattr3(xdr, args->sattr);
7266 + encode_sattr3(xdr, args->sattr, tag);
7270 @@ -1153,7 +1159,7 @@ static void nfs3_xdr_enc_mknod3args(stru
7271 const struct nfs3_mknodargs *args)
7273 encode_diropargs3(xdr, args->fh, args->name, args->len);
7274 - encode_mknoddata3(xdr, args);
7275 + encode_mknoddata3(xdr, args, req->rq_task->tk_client->cl_tag);
7279 diff -NurpP --minimal linux-3.1/fs/nfs/super.c linux-3.1-vs2.3.1-rc2/fs/nfs/super.c
7280 --- linux-3.1/fs/nfs/super.c 2011-10-24 18:45:27.000000000 +0200
7281 +++ linux-3.1-vs2.3.1-rc2/fs/nfs/super.c 2011-10-24 18:53:33.000000000 +0200
7283 #include <linux/nfs_xdr.h>
7284 #include <linux/magic.h>
7285 #include <linux/parser.h>
7286 +#include <linux/vs_tag.h>
7288 #include <asm/system.h>
7289 #include <asm/uaccess.h>
7290 @@ -87,6 +88,7 @@ enum {
7291 Opt_sharecache, Opt_nosharecache,
7292 Opt_resvport, Opt_noresvport,
7293 Opt_fscache, Opt_nofscache,
7294 + Opt_tag, Opt_notag,
7296 /* Mount options that take integer arguments */
7298 @@ -100,6 +102,7 @@ enum {
7304 /* Mount options that take string arguments */
7305 Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost,
7306 @@ -180,6 +183,10 @@ static const match_table_t nfs_mount_opt
7307 { Opt_fscache_uniq, "fsc=%s" },
7308 { Opt_local_lock, "local_lock=%s" },
7310 + { Opt_tag, "tag" },
7311 + { Opt_notag, "notag" },
7312 + { Opt_tagid, "tagid=%u" },
7317 @@ -650,6 +657,7 @@ static void nfs_show_mount_options(struc
7318 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
7319 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
7320 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
7321 + { NFS_MOUNT_TAGGED, ",tag", "" },
7324 const struct proc_nfs_info *nfs_infop;
7325 @@ -1198,6 +1206,14 @@ static int nfs_parse_mount_options(char
7326 kfree(mnt->fscache_uniq);
7327 mnt->fscache_uniq = NULL;
7329 +#ifndef CONFIG_TAGGING_NONE
7331 + mnt->flags |= NFS_MOUNT_TAGGED;
7334 + mnt->flags &= ~NFS_MOUNT_TAGGED;
7339 * options that take numeric values
7340 @@ -1304,6 +1320,12 @@ static int nfs_parse_mount_options(char
7341 goto out_invalid_value;
7342 mnt->minorversion = option;
7344 +#ifdef CONFIG_PROPAGATE
7347 + nfs_data.flags |= NFS_MOUNT_TAGGED;
7352 * options that take text values
7353 diff -NurpP --minimal linux-3.1/fs/nfsd/auth.c linux-3.1-vs2.3.1-rc2/fs/nfsd/auth.c
7354 --- linux-3.1/fs/nfsd/auth.c 2010-02-25 11:52:05.000000000 +0100
7355 +++ linux-3.1-vs2.3.1-rc2/fs/nfsd/auth.c 2011-10-24 18:53:33.000000000 +0200
7357 /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
7359 #include <linux/sched.h>
7360 +#include <linux/vs_tag.h>
7364 @@ -36,6 +37,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
7366 new->fsuid = rqstp->rq_cred.cr_uid;
7367 new->fsgid = rqstp->rq_cred.cr_gid;
7368 + /* FIXME: this desperately needs a tag :)
7369 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
7372 rqgi = rqstp->rq_cred.cr_group_info;
7374 diff -NurpP --minimal linux-3.1/fs/nfsd/nfs3xdr.c linux-3.1-vs2.3.1-rc2/fs/nfsd/nfs3xdr.c
7375 --- linux-3.1/fs/nfsd/nfs3xdr.c 2011-07-22 11:18:05.000000000 +0200
7376 +++ linux-3.1-vs2.3.1-rc2/fs/nfsd/nfs3xdr.c 2011-10-24 18:53:33.000000000 +0200
7380 #include <linux/namei.h>
7381 +#include <linux/vs_tag.h>
7385 @@ -95,6 +96,8 @@ static __be32 *
7386 decode_sattr3(__be32 *p, struct iattr *iap)
7394 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
7397 iap->ia_valid |= ATTR_UID;
7398 - iap->ia_uid = ntohl(*p++);
7399 + uid = ntohl(*p++);
7402 iap->ia_valid |= ATTR_GID;
7403 - iap->ia_gid = ntohl(*p++);
7404 + gid = ntohl(*p++);
7406 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7407 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7408 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7412 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
7413 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
7414 *p++ = htonl((u32) stat->mode);
7415 *p++ = htonl((u32) stat->nlink);
7416 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7417 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7418 + *p++ = htonl((u32) nfsd_ruid(rqstp,
7419 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
7420 + stat->uid, stat->tag)));
7421 + *p++ = htonl((u32) nfsd_rgid(rqstp,
7422 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
7423 + stat->gid, stat->tag)));
7424 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
7425 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
7427 diff -NurpP --minimal linux-3.1/fs/nfsd/nfs4xdr.c linux-3.1-vs2.3.1-rc2/fs/nfsd/nfs4xdr.c
7428 --- linux-3.1/fs/nfsd/nfs4xdr.c 2011-10-24 18:45:27.000000000 +0200
7429 +++ linux-3.1-vs2.3.1-rc2/fs/nfsd/nfs4xdr.c 2011-10-24 18:53:33.000000000 +0200
7431 #include <linux/utsname.h>
7432 #include <linux/pagemap.h>
7433 #include <linux/sunrpc/svcauth_gss.h>
7434 +#include <linux/vs_tag.h>
7438 @@ -2165,14 +2166,18 @@ out_acl:
7439 WRITE32(stat.nlink);
7441 if (bmval1 & FATTR4_WORD1_OWNER) {
7442 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
7443 + status = nfsd4_encode_user(rqstp,
7444 + TAGINO_UID(DX_TAG(dentry->d_inode),
7445 + stat.uid, stat.tag), &p, &buflen);
7446 if (status == nfserr_resource)
7451 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
7452 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
7453 + status = nfsd4_encode_group(rqstp,
7454 + TAGINO_GID(DX_TAG(dentry->d_inode),
7455 + stat.gid, stat.tag), &p, &buflen);
7456 if (status == nfserr_resource)
7459 diff -NurpP --minimal linux-3.1/fs/nfsd/nfsxdr.c linux-3.1-vs2.3.1-rc2/fs/nfsd/nfsxdr.c
7460 --- linux-3.1/fs/nfsd/nfsxdr.c 2011-05-22 16:17:53.000000000 +0200
7461 +++ linux-3.1-vs2.3.1-rc2/fs/nfsd/nfsxdr.c 2011-10-24 18:53:33.000000000 +0200
7466 +#include <linux/vs_tag.h>
7468 #define NFSDDBG_FACILITY NFSDDBG_XDR
7470 @@ -88,6 +89,8 @@ static __be32 *
7471 decode_sattr(__be32 *p, struct iattr *iap)
7479 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
7481 if ((tmp = ntohl(*p++)) != (u32)-1) {
7482 iap->ia_valid |= ATTR_UID;
7483 - iap->ia_uid = tmp;
7486 if ((tmp = ntohl(*p++)) != (u32)-1) {
7487 iap->ia_valid |= ATTR_GID;
7488 - iap->ia_gid = tmp;
7491 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7492 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7493 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7494 if ((tmp = ntohl(*p++)) != (u32)-1) {
7495 iap->ia_valid |= ATTR_SIZE;
7497 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
7498 *p++ = htonl(nfs_ftypes[type >> 12]);
7499 *p++ = htonl((u32) stat->mode);
7500 *p++ = htonl((u32) stat->nlink);
7501 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7502 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7503 + *p++ = htonl((u32) nfsd_ruid(rqstp,
7504 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
7505 + *p++ = htonl((u32) nfsd_rgid(rqstp,
7506 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
7508 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
7509 *p++ = htonl(NFS_MAXPATHLEN);
7510 diff -NurpP --minimal linux-3.1/fs/ocfs2/dlmglue.c linux-3.1-vs2.3.1-rc2/fs/ocfs2/dlmglue.c
7511 --- linux-3.1/fs/ocfs2/dlmglue.c 2011-05-22 16:17:53.000000000 +0200
7512 +++ linux-3.1-vs2.3.1-rc2/fs/ocfs2/dlmglue.c 2011-10-24 18:53:33.000000000 +0200
7513 @@ -2041,6 +2041,7 @@ static void __ocfs2_stuff_meta_lvb(struc
7514 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
7515 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
7516 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
7517 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
7518 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
7519 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
7520 lvb->lvb_iatime_packed =
7521 @@ -2091,6 +2092,7 @@ static void ocfs2_refresh_inode_from_lvb
7523 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
7524 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
7525 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
7526 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
7527 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
7528 ocfs2_unpack_timespec(&inode->i_atime,
7529 diff -NurpP --minimal linux-3.1/fs/ocfs2/dlmglue.h linux-3.1-vs2.3.1-rc2/fs/ocfs2/dlmglue.h
7530 --- linux-3.1/fs/ocfs2/dlmglue.h 2010-10-21 13:07:50.000000000 +0200
7531 +++ linux-3.1-vs2.3.1-rc2/fs/ocfs2/dlmglue.h 2011-10-24 18:53:33.000000000 +0200
7532 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
7535 __be32 lvb_igeneration;
7536 - __be32 lvb_reserved2;
7538 + __be16 lvb_reserved2;
7541 #define OCFS2_QINFO_LVB_VERSION 1
7542 diff -NurpP --minimal linux-3.1/fs/ocfs2/file.c linux-3.1-vs2.3.1-rc2/fs/ocfs2/file.c
7543 --- linux-3.1/fs/ocfs2/file.c 2011-10-24 18:45:27.000000000 +0200
7544 +++ linux-3.1-vs2.3.1-rc2/fs/ocfs2/file.c 2011-10-24 18:53:33.000000000 +0200
7545 @@ -1123,7 +1123,7 @@ int ocfs2_setattr(struct dentry *dentry,
7546 attr->ia_valid &= ~ATTR_SIZE;
7548 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
7549 - | ATTR_GID | ATTR_UID | ATTR_MODE)
7550 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
7551 if (!(attr->ia_valid & OCFS2_VALID_ATTRS))
7554 diff -NurpP --minimal linux-3.1/fs/ocfs2/inode.c linux-3.1-vs2.3.1-rc2/fs/ocfs2/inode.c
7555 --- linux-3.1/fs/ocfs2/inode.c 2011-05-22 16:17:53.000000000 +0200
7556 +++ linux-3.1-vs2.3.1-rc2/fs/ocfs2/inode.c 2011-10-24 18:53:33.000000000 +0200
7558 #include <linux/highmem.h>
7559 #include <linux/pagemap.h>
7560 #include <linux/quotaops.h>
7561 +#include <linux/vs_tag.h>
7563 #include <asm/byteorder.h>
7565 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
7567 unsigned int flags = OCFS2_I(inode)->ip_attr;
7569 - inode->i_flags &= ~(S_IMMUTABLE |
7570 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
7571 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
7573 if (flags & OCFS2_IMMUTABLE_FL)
7574 inode->i_flags |= S_IMMUTABLE;
7575 + if (flags & OCFS2_IXUNLINK_FL)
7576 + inode->i_flags |= S_IXUNLINK;
7578 if (flags & OCFS2_SYNC_FL)
7579 inode->i_flags |= S_SYNC;
7580 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode
7581 inode->i_flags |= S_NOATIME;
7582 if (flags & OCFS2_DIRSYNC_FL)
7583 inode->i_flags |= S_DIRSYNC;
7585 + inode->i_vflags &= ~(V_BARRIER | V_COW);
7587 + if (flags & OCFS2_BARRIER_FL)
7588 + inode->i_vflags |= V_BARRIER;
7589 + if (flags & OCFS2_COW_FL)
7590 + inode->i_vflags |= V_COW;
7593 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
7594 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
7596 unsigned int flags = oi->vfs_inode.i_flags;
7597 + unsigned int vflags = oi->vfs_inode.i_vflags;
7599 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
7600 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
7601 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
7602 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
7604 + if (flags & S_IMMUTABLE)
7605 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
7606 + if (flags & S_IXUNLINK)
7607 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
7609 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
7610 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
7612 oi->ip_attr |= OCFS2_SYNC_FL;
7613 if (flags & S_APPEND)
7614 oi->ip_attr |= OCFS2_APPEND_FL;
7615 - if (flags & S_IMMUTABLE)
7616 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
7617 if (flags & S_NOATIME)
7618 oi->ip_attr |= OCFS2_NOATIME_FL;
7619 if (flags & S_DIRSYNC)
7620 oi->ip_attr |= OCFS2_DIRSYNC_FL;
7622 + if (vflags & V_BARRIER)
7623 + oi->ip_attr |= OCFS2_BARRIER_FL;
7624 + if (vflags & V_COW)
7625 + oi->ip_attr |= OCFS2_COW_FL;
7628 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
7629 @@ -241,6 +263,8 @@ void ocfs2_populate_inode(struct inode *
7630 struct super_block *sb;
7631 struct ocfs2_super *osb;
7638 @@ -269,8 +293,12 @@ void ocfs2_populate_inode(struct inode *
7639 inode->i_generation = le32_to_cpu(fe->i_generation);
7640 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
7641 inode->i_mode = le16_to_cpu(fe->i_mode);
7642 - inode->i_uid = le32_to_cpu(fe->i_uid);
7643 - inode->i_gid = le32_to_cpu(fe->i_gid);
7644 + uid = le32_to_cpu(fe->i_uid);
7645 + gid = le32_to_cpu(fe->i_gid);
7646 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7647 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7648 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
7649 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
7651 /* Fast symlinks will have i_size but no allocated clusters. */
7652 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
7653 diff -NurpP --minimal linux-3.1/fs/ocfs2/inode.h linux-3.1-vs2.3.1-rc2/fs/ocfs2/inode.h
7654 --- linux-3.1/fs/ocfs2/inode.h 2011-01-05 21:50:26.000000000 +0100
7655 +++ linux-3.1-vs2.3.1-rc2/fs/ocfs2/inode.h 2011-10-24 18:53:33.000000000 +0200
7656 @@ -151,6 +151,7 @@ struct buffer_head *ocfs2_bread(struct i
7658 void ocfs2_set_inode_flags(struct inode *inode);
7659 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
7660 +int ocfs2_sync_flags(struct inode *inode, int, int);
7662 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
7664 diff -NurpP --minimal linux-3.1/fs/ocfs2/ioctl.c linux-3.1-vs2.3.1-rc2/fs/ocfs2/ioctl.c
7665 --- linux-3.1/fs/ocfs2/ioctl.c 2011-07-22 11:18:06.000000000 +0200
7666 +++ linux-3.1-vs2.3.1-rc2/fs/ocfs2/ioctl.c 2011-10-24 18:53:33.000000000 +0200
7667 @@ -78,7 +78,41 @@ static int ocfs2_get_inode_attr(struct i
7671 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
7672 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
7674 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
7675 + struct buffer_head *bh = NULL;
7676 + handle_t *handle = NULL;
7679 + status = ocfs2_inode_lock(inode, &bh, 1);
7681 + mlog_errno(status);
7684 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
7685 + if (IS_ERR(handle)) {
7686 + status = PTR_ERR(handle);
7687 + mlog_errno(status);
7691 + inode->i_flags = flags;
7692 + inode->i_vflags = vflags;
7693 + ocfs2_get_inode_flags(OCFS2_I(inode));
7695 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
7697 + mlog_errno(status);
7699 + ocfs2_commit_trans(osb, handle);
7701 + ocfs2_inode_unlock(inode, 1);
7706 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
7709 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
7710 @@ -103,6 +137,11 @@ static int ocfs2_set_inode_attr(struct i
7711 if (!S_ISDIR(inode->i_mode))
7712 flags &= ~OCFS2_DIRSYNC_FL;
7714 + if (IS_BARRIER(inode)) {
7715 + vxwprintk_task(1, "messing with the barrier.");
7719 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
7720 if (IS_ERR(handle)) {
7721 status = PTR_ERR(handle);
7722 @@ -880,6 +919,7 @@ bail:
7727 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7729 struct inode *inode = filp->f_path.dentry->d_inode;
7730 diff -NurpP --minimal linux-3.1/fs/ocfs2/namei.c linux-3.1-vs2.3.1-rc2/fs/ocfs2/namei.c
7731 --- linux-3.1/fs/ocfs2/namei.c 2011-10-24 18:45:27.000000000 +0200
7732 +++ linux-3.1-vs2.3.1-rc2/fs/ocfs2/namei.c 2011-10-24 18:53:33.000000000 +0200
7734 #include <linux/slab.h>
7735 #include <linux/highmem.h>
7736 #include <linux/quotaops.h>
7737 +#include <linux/vs_tag.h>
7739 #include <cluster/masklog.h>
7741 @@ -477,6 +478,7 @@ static int __ocfs2_mknod_locked(struct i
7742 struct ocfs2_dinode *fe = NULL;
7743 struct ocfs2_extent_list *fel;
7749 @@ -514,8 +516,11 @@ static int __ocfs2_mknod_locked(struct i
7750 fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
7751 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
7752 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
7753 - fe->i_uid = cpu_to_le32(inode->i_uid);
7754 - fe->i_gid = cpu_to_le32(inode->i_gid);
7756 + tag = dx_current_fstag(osb->sb);
7757 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
7758 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
7759 + inode->i_tag = tag;
7760 fe->i_mode = cpu_to_le16(inode->i_mode);
7761 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
7762 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
7763 diff -NurpP --minimal linux-3.1/fs/ocfs2/ocfs2.h linux-3.1-vs2.3.1-rc2/fs/ocfs2/ocfs2.h
7764 --- linux-3.1/fs/ocfs2/ocfs2.h 2011-05-22 16:17:53.000000000 +0200
7765 +++ linux-3.1-vs2.3.1-rc2/fs/ocfs2/ocfs2.h 2011-10-24 18:53:33.000000000 +0200
7766 @@ -272,6 +272,7 @@ enum ocfs2_mount_options
7768 OCFS2_MOUNT_HB_NONE = 1 << 13, /* No heartbeat */
7769 OCFS2_MOUNT_HB_GLOBAL = 1 << 14, /* Global heartbeat */
7770 + OCFS2_MOUNT_TAGGED = 1 << 15, /* use tagging */
7773 #define OCFS2_OSB_SOFT_RO 0x0001
7774 diff -NurpP --minimal linux-3.1/fs/ocfs2/ocfs2_fs.h linux-3.1-vs2.3.1-rc2/fs/ocfs2/ocfs2_fs.h
7775 --- linux-3.1/fs/ocfs2/ocfs2_fs.h 2011-05-22 16:17:53.000000000 +0200
7776 +++ linux-3.1-vs2.3.1-rc2/fs/ocfs2/ocfs2_fs.h 2011-10-24 18:53:33.000000000 +0200
7777 @@ -266,6 +266,11 @@
7778 #define OCFS2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
7779 #define OCFS2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
7781 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
7783 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
7784 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
7786 #define OCFS2_FL_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
7787 #define OCFS2_FL_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
7789 diff -NurpP --minimal linux-3.1/fs/ocfs2/super.c linux-3.1-vs2.3.1-rc2/fs/ocfs2/super.c
7790 --- linux-3.1/fs/ocfs2/super.c 2011-07-22 11:18:06.000000000 +0200
7791 +++ linux-3.1-vs2.3.1-rc2/fs/ocfs2/super.c 2011-10-24 18:53:33.000000000 +0200
7792 @@ -184,6 +184,7 @@ enum {
7796 + Opt_tag, Opt_notag, Opt_tagid,
7800 @@ -215,6 +216,9 @@ static const match_table_t tokens = {
7801 {Opt_coherency_full, "coherency=full"},
7802 {Opt_resv_level, "resv_level=%u"},
7803 {Opt_dir_resv_level, "dir_resv_level=%u"},
7805 + {Opt_notag, "notag"},
7806 + {Opt_tagid, "tagid=%u"},
7810 @@ -662,6 +666,13 @@ static int ocfs2_remount(struct super_bl
7814 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
7815 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
7817 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
7821 /* We're going to/from readonly mode. */
7822 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
7823 /* Disable quota accounting before remounting RO */
7824 @@ -1177,6 +1188,9 @@ static int ocfs2_fill_super(struct super
7826 ocfs2_complete_mount_recovery(osb);
7828 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
7829 + sb->s_flags |= MS_TAGGED;
7831 if (ocfs2_mount_local(osb))
7832 snprintf(nodestr, sizeof(nodestr), "local");
7834 @@ -1506,6 +1520,20 @@ static int ocfs2_parse_options(struct su
7835 option < OCFS2_MAX_RESV_LEVEL)
7836 mopt->dir_resv_level = option;
7838 +#ifndef CONFIG_TAGGING_NONE
7840 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
7843 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
7846 +#ifdef CONFIG_PROPAGATE
7849 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
7854 "Unrecognized mount option \"%s\" "
7855 diff -NurpP --minimal linux-3.1/fs/open.c linux-3.1-vs2.3.1-rc2/fs/open.c
7856 --- linux-3.1/fs/open.c 2011-10-24 18:45:27.000000000 +0200
7857 +++ linux-3.1-vs2.3.1-rc2/fs/open.c 2011-10-30 02:06:37.000000000 +0100
7859 #include <linux/fs_struct.h>
7860 #include <linux/ima.h>
7861 #include <linux/dnotify.h>
7862 +#include <linux/vs_base.h>
7863 +#include <linux/vs_limit.h>
7864 +#include <linux/vs_tag.h>
7865 +#include <linux/vs_cowbl.h>
7866 +#include <linux/vserver/dlimit.h>
7868 #include "internal.h"
7870 @@ -74,6 +79,12 @@ static long do_sys_truncate(const char _
7871 error = user_path(pathname, &path);
7875 +#ifdef CONFIG_VSERVER_COWBL
7876 + error = cow_check_and_break(&path);
7878 + goto dput_and_out;
7880 inode = path.dentry->d_inode;
7882 /* For directories it's -EISDIR, for other non-regulars - -EINVAL */
7883 @@ -489,6 +500,10 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
7885 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
7887 +#ifdef CONFIG_VSERVER_COWBL
7888 + error = cow_check_and_break(&path);
7891 error = chmod_common(&path, mode);
7894 @@ -509,11 +524,11 @@ static int chown_common(struct path *pat
7895 newattrs.ia_valid = ATTR_CTIME;
7896 if (user != (uid_t) -1) {
7897 newattrs.ia_valid |= ATTR_UID;
7898 - newattrs.ia_uid = user;
7899 + newattrs.ia_uid = dx_map_uid(user);
7901 if (group != (gid_t) -1) {
7902 newattrs.ia_valid |= ATTR_GID;
7903 - newattrs.ia_gid = group;
7904 + newattrs.ia_gid = dx_map_gid(group);
7906 if (!S_ISDIR(inode->i_mode))
7907 newattrs.ia_valid |=
7908 @@ -538,6 +553,10 @@ SYSCALL_DEFINE3(chown, const char __user
7909 error = mnt_want_write(path.mnt);
7912 +#ifdef CONFIG_VSERVER_COWBL
7913 + error = cow_check_and_break(&path);
7916 error = chown_common(&path, user, group);
7917 mnt_drop_write(path.mnt);
7919 @@ -565,6 +584,10 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
7920 error = mnt_want_write(path.mnt);
7923 +#ifdef CONFIG_VSERVER_COWBL
7924 + error = cow_check_and_break(&path);
7927 error = chown_common(&path, user, group);
7928 mnt_drop_write(path.mnt);
7930 @@ -584,6 +607,10 @@ SYSCALL_DEFINE3(lchown, const char __use
7931 error = mnt_want_write(path.mnt);
7934 +#ifdef CONFIG_VSERVER_COWBL
7935 + error = cow_check_and_break(&path);
7938 error = chown_common(&path, user, group);
7939 mnt_drop_write(path.mnt);
7941 @@ -835,6 +862,7 @@ static void __put_unused_fd(struct files
7942 __FD_CLR(fd, fdt->open_fds);
7943 if (fd < files->next_fd)
7944 files->next_fd = fd;
7945 + vx_openfd_dec(fd);
7948 void put_unused_fd(unsigned int fd)
7949 diff -NurpP --minimal linux-3.1/fs/proc/array.c linux-3.1-vs2.3.1-rc2/fs/proc/array.c
7950 --- linux-3.1/fs/proc/array.c 2011-10-24 18:45:27.000000000 +0200
7951 +++ linux-3.1-vs2.3.1-rc2/fs/proc/array.c 2011-10-24 18:53:33.000000000 +0200
7953 #include <linux/pid_namespace.h>
7954 #include <linux/ptrace.h>
7955 #include <linux/tracehook.h>
7956 +#include <linux/vs_context.h>
7957 +#include <linux/vs_network.h>
7959 #include <asm/pgtable.h>
7960 #include <asm/processor.h>
7961 @@ -170,6 +172,9 @@ static inline void task_state(struct seq
7963 ppid = pid_alive(p) ?
7964 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
7965 + if (unlikely(vx_current_initpid(p->pid)))
7970 struct task_struct *tracer = ptrace_parent(p);
7971 @@ -287,7 +292,7 @@ static inline void task_sig(struct seq_f
7974 static void render_cap_t(struct seq_file *m, const char *header,
7976 + struct vx_info *vxi, kernel_cap_t *a)
7980 @@ -312,10 +317,11 @@ static inline void task_cap(struct seq_f
7981 cap_bset = cred->cap_bset;
7984 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
7985 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
7986 - render_cap_t(m, "CapEff:\t", &cap_effective);
7987 - render_cap_t(m, "CapBnd:\t", &cap_bset);
7988 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
7989 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
7990 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
7991 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
7992 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
7995 static inline void task_context_switch_counts(struct seq_file *m,
7996 @@ -337,6 +343,42 @@ static void task_cpus_allowed(struct seq
8000 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
8001 + struct pid *pid, struct task_struct *task)
8003 + seq_printf(m, "Proxy:\t%p(%c)\n"
8011 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
8012 + atomic_read(&task->nsproxy->count),
8013 + task->nsproxy->uts_ns,
8014 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
8015 + task->nsproxy->ipc_ns,
8016 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
8017 + task->nsproxy->mnt_ns,
8018 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
8019 + task->nsproxy->pid_ns,
8020 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
8021 + task->nsproxy->net_ns,
8022 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
8026 +void task_vs_id(struct seq_file *m, struct task_struct *task)
8028 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
8031 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
8032 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
8036 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
8037 struct pid *pid, struct task_struct *task)
8039 @@ -353,6 +395,7 @@ int proc_pid_status(struct seq_file *m,
8041 task_cpus_allowed(m, task);
8042 cpuset_task_status_allowed(m, task);
8043 + task_vs_id(m, task);
8044 task_context_switch_counts(m, task);
8047 @@ -462,6 +505,17 @@ static int do_task_stat(struct seq_file
8048 /* convert nsec -> ticks */
8049 start_time = nsec_to_clock_t(start_time);
8051 + /* fixup start time for virt uptime */
8052 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
8053 + unsigned long long bias =
8054 + current->vx_info->cvirt.bias_clock;
8056 + if (start_time > bias)
8057 + start_time -= bias;
8062 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
8063 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
8064 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
8065 diff -NurpP --minimal linux-3.1/fs/proc/base.c linux-3.1-vs2.3.1-rc2/fs/proc/base.c
8066 --- linux-3.1/fs/proc/base.c 2011-10-24 18:45:27.000000000 +0200
8067 +++ linux-3.1-vs2.3.1-rc2/fs/proc/base.c 2011-10-24 18:53:33.000000000 +0200
8069 #include <linux/pid_namespace.h>
8070 #include <linux/fs_struct.h>
8071 #include <linux/slab.h>
8072 +#include <linux/vs_context.h>
8073 +#include <linux/vs_network.h>
8074 #ifdef CONFIG_HARDWALL
8075 #include <asm/hardwall.h>
8077 @@ -1102,11 +1104,16 @@ static ssize_t oom_adjust_write(struct f
8081 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
8082 + if (oom_adjust < task->signal->oom_adj &&
8083 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
8088 + /* prevent guest processes from circumventing the oom killer */
8089 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
8090 + oom_adjust = OOM_ADJUST_MIN;
8092 if (oom_adjust != task->signal->oom_adj) {
8093 if (oom_adjust == OOM_DISABLE)
8094 atomic_inc(&task->mm->oom_disable_count);
8095 @@ -1274,7 +1281,7 @@ static ssize_t proc_loginuid_write(struc
8099 - if (!capable(CAP_AUDIT_CONTROL))
8100 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
8104 @@ -1721,6 +1728,8 @@ struct inode *proc_pid_make_inode(struct
8105 inode->i_gid = cred->egid;
8108 + /* procfs is xid tagged */
8109 + inode->i_tag = (tag_t)vx_task_xid(task);
8110 security_task_to_inode(task, inode);
8113 @@ -1757,6 +1766,8 @@ int pid_getattr(struct vfsmount *mnt, st
8117 +static unsigned name_to_int(struct dentry *dentry);
8120 * Exceptional case: normally we are not allowed to unhash a busy
8121 * directory. In this case, however, we can do it - no aliasing problems
8122 @@ -1785,6 +1796,12 @@ int pid_revalidate(struct dentry *dentry
8123 task = get_proc_task(inode);
8126 + unsigned pid = name_to_int(dentry);
8128 + if (pid != ~0U && pid != vx_map_pid(task->pid)) {
8129 + put_task_struct(task);
8132 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
8133 task_dumpable(task)) {
8135 @@ -1801,6 +1818,7 @@ int pid_revalidate(struct dentry *dentry
8136 put_task_struct(task);
8143 @@ -2290,6 +2308,13 @@ static struct dentry *proc_pident_lookup
8147 + /* TODO: maybe we can come up with a generic approach? */
8148 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
8149 + (dentry->d_name.len == 5) &&
8150 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
8151 + !memcmp(dentry->d_name.name, "ninfo", 5)))
8155 * Yes, it does not scale. And it should not. Don't add
8156 * new entries into /proc/<tgid>/ without very good reasons.
8157 @@ -2675,7 +2700,7 @@ out_iput:
8158 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
8160 struct dentry *error;
8161 - struct task_struct *task = get_proc_task(dir);
8162 + struct task_struct *task = get_proc_task_real(dir);
8163 const struct pid_entry *p, *last;
8165 error = ERR_PTR(-ENOENT);
8166 @@ -2782,6 +2807,9 @@ static int proc_pid_personality(struct s
8167 static const struct file_operations proc_task_operations;
8168 static const struct inode_operations proc_task_inode_operations;
8170 +extern int proc_pid_vx_info(struct task_struct *, char *);
8171 +extern int proc_pid_nx_info(struct task_struct *, char *);
8173 static const struct pid_entry tgid_base_stuff[] = {
8174 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
8175 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
8176 @@ -2845,6 +2873,8 @@ static const struct pid_entry tgid_base_
8177 #ifdef CONFIG_CGROUPS
8178 REG("cgroup", S_IRUGO, proc_cgroup_operations),
8180 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
8181 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
8182 INF("oom_score", S_IRUGO, proc_oom_score),
8183 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
8184 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
8185 @@ -2864,6 +2894,7 @@ static const struct pid_entry tgid_base_
8186 #ifdef CONFIG_HARDWALL
8187 INF("hardwall", S_IRUGO, proc_pid_hardwall),
8189 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
8192 static int proc_tgid_base_readdir(struct file * filp,
8193 @@ -3056,7 +3087,7 @@ retry:
8195 pid = find_ge_pid(iter.tgid, ns);
8197 - iter.tgid = pid_nr_ns(pid, ns);
8198 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
8199 iter.task = pid_task(pid, PIDTYPE_PID);
8200 /* What we to know is if the pid we have find is the
8201 * pid of a thread_group_leader. Testing for task
8202 @@ -3086,7 +3117,7 @@ static int proc_pid_fill_cache(struct fi
8203 struct tgid_iter iter)
8205 char name[PROC_NUMBUF];
8206 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
8207 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
8208 return proc_fill_cache(filp, dirent, filldir, name, len,
8209 proc_pid_instantiate, iter.task, NULL);
8211 @@ -3103,7 +3134,7 @@ int proc_pid_readdir(struct file * filp,
8213 nr = filp->f_pos - FIRST_PROCESS_ENTRY;
8215 - reaper = get_proc_task(filp->f_path.dentry->d_inode);
8216 + reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
8220 @@ -3120,6 +3151,8 @@ int proc_pid_readdir(struct file * filp,
8222 iter.tgid += 1, iter = next_tgid(ns, iter)) {
8223 filp->f_pos = iter.tgid + TGID_OFFSET;
8224 + if (!vx_proc_task_visible(iter.task))
8226 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
8227 put_task_struct(iter.task);
8229 @@ -3273,6 +3306,8 @@ static struct dentry *proc_task_lookup(s
8230 tid = name_to_int(dentry);
8233 + if (vx_current_initpid(tid))
8236 ns = dentry->d_sb->s_fs_info;
8238 diff -NurpP --minimal linux-3.1/fs/proc/generic.c linux-3.1-vs2.3.1-rc2/fs/proc/generic.c
8239 --- linux-3.1/fs/proc/generic.c 2011-10-24 18:45:27.000000000 +0200
8240 +++ linux-3.1-vs2.3.1-rc2/fs/proc/generic.c 2011-10-24 18:53:33.000000000 +0200
8242 #include <linux/bitops.h>
8243 #include <linux/spinlock.h>
8244 #include <linux/completion.h>
8245 +#include <linux/vserver/inode.h>
8246 #include <asm/uaccess.h>
8248 #include "internal.h"
8249 @@ -424,11 +425,15 @@ struct dentry *proc_lookup_de(struct pro
8250 for (de = de->subdir; de ; de = de->next) {
8251 if (de->namelen != dentry->d_name.len)
8253 + if (!vx_hide_check(0, de->vx_flags))
8255 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
8257 spin_unlock(&proc_subdir_lock);
8259 inode = proc_get_inode(dir->i_sb, de);
8260 + /* generic proc entries belong to the host */
8265 @@ -506,6 +511,8 @@ int proc_readdir_de(struct proc_dir_entr
8267 /* filldir passes info to user space */
8269 + if (!vx_hide_check(0, de->vx_flags))
8271 spin_unlock(&proc_subdir_lock);
8272 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
8273 de->low_ino, de->mode >> 12) < 0) {
8274 @@ -513,6 +520,7 @@ int proc_readdir_de(struct proc_dir_entr
8277 spin_lock(&proc_subdir_lock);
8282 @@ -626,6 +634,7 @@ static struct proc_dir_entry *__proc_cre
8284 atomic_set(&ent->count, 1);
8286 + ent->vx_flags = IATTR_PROC_DEFAULT;
8287 spin_lock_init(&ent->pde_unload_lock);
8288 ent->pde_unload_completion = NULL;
8289 INIT_LIST_HEAD(&ent->pde_openers);
8290 @@ -649,7 +658,8 @@ struct proc_dir_entry *proc_symlink(cons
8296 + ent->vx_flags = IATTR_PROC_SYMLINK;
8300 diff -NurpP --minimal linux-3.1/fs/proc/inode.c linux-3.1-vs2.3.1-rc2/fs/proc/inode.c
8301 --- linux-3.1/fs/proc/inode.c 2011-10-24 18:45:27.000000000 +0200
8302 +++ linux-3.1-vs2.3.1-rc2/fs/proc/inode.c 2011-10-24 18:53:33.000000000 +0200
8303 @@ -442,6 +442,8 @@ struct inode *proc_get_inode(struct supe
8304 inode->i_uid = de->uid;
8305 inode->i_gid = de->gid;
8308 + PROC_I(inode)->vx_flags = de->vx_flags;
8310 inode->i_size = de->size;
8312 diff -NurpP --minimal linux-3.1/fs/proc/internal.h linux-3.1-vs2.3.1-rc2/fs/proc/internal.h
8313 --- linux-3.1/fs/proc/internal.h 2011-07-22 11:18:06.000000000 +0200
8314 +++ linux-3.1-vs2.3.1-rc2/fs/proc/internal.h 2011-10-24 18:53:33.000000000 +0200
8318 #include <linux/proc_fs.h>
8319 +#include <linux/vs_pid.h>
8321 extern struct proc_dir_entry proc_root;
8322 #ifdef CONFIG_PROC_SYSCTL
8323 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
8324 struct pid *pid, struct task_struct *task);
8325 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
8326 struct pid *pid, struct task_struct *task);
8327 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
8328 + struct pid *pid, struct task_struct *task);
8330 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
8332 extern const struct file_operations proc_maps_operations;
8333 @@ -76,11 +80,16 @@ static inline struct pid *proc_pid(struc
8334 return PROC_I(inode)->pid;
8337 -static inline struct task_struct *get_proc_task(struct inode *inode)
8338 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
8340 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
8343 +static inline struct task_struct *get_proc_task(struct inode *inode)
8345 + return vx_get_proc_task(inode, proc_pid(inode));
8348 static inline int proc_fd(struct inode *inode)
8350 return PROC_I(inode)->fd;
8351 diff -NurpP --minimal linux-3.1/fs/proc/loadavg.c linux-3.1-vs2.3.1-rc2/fs/proc/loadavg.c
8352 --- linux-3.1/fs/proc/loadavg.c 2009-09-10 15:26:23.000000000 +0200
8353 +++ linux-3.1-vs2.3.1-rc2/fs/proc/loadavg.c 2011-10-24 18:53:33.000000000 +0200
8356 static int loadavg_proc_show(struct seq_file *m, void *v)
8358 + unsigned long running;
8359 + unsigned int threads;
8360 unsigned long avnrun[3];
8362 get_avenrun(avnrun, FIXED_1/200, 0);
8364 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
8365 + struct vx_info *vxi = current_vx_info();
8367 + running = atomic_read(&vxi->cvirt.nr_running);
8368 + threads = atomic_read(&vxi->cvirt.nr_threads);
8370 + running = nr_running();
8371 + threads = nr_threads;
8374 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
8375 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
8376 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
8377 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
8378 - nr_running(), nr_threads,
8380 task_active_pid_ns(current)->last_pid);
8383 diff -NurpP --minimal linux-3.1/fs/proc/meminfo.c linux-3.1-vs2.3.1-rc2/fs/proc/meminfo.c
8384 --- linux-3.1/fs/proc/meminfo.c 2011-10-24 18:45:27.000000000 +0200
8385 +++ linux-3.1-vs2.3.1-rc2/fs/proc/meminfo.c 2011-10-24 18:53:33.000000000 +0200
8386 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
8387 allowed = ((totalram_pages - hugetlb_total_pages())
8388 * sysctl_overcommit_ratio / 100) + total_swap_pages;
8390 - cached = global_page_state(NR_FILE_PAGES) -
8391 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
8392 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
8393 total_swapcache_pages - i.bufferram;
8396 diff -NurpP --minimal linux-3.1/fs/proc/root.c linux-3.1-vs2.3.1-rc2/fs/proc/root.c
8397 --- linux-3.1/fs/proc/root.c 2011-10-24 18:45:27.000000000 +0200
8398 +++ linux-3.1-vs2.3.1-rc2/fs/proc/root.c 2011-10-24 18:53:33.000000000 +0200
8400 #include <linux/bitops.h>
8401 #include <linux/mount.h>
8402 #include <linux/pid_namespace.h>
8403 +#include <linux/vserver/inode.h>
8405 #include "internal.h"
8407 +struct proc_dir_entry *proc_virtual;
8409 +extern void proc_vx_init(void);
8411 static int proc_test_super(struct super_block *sb, void *data)
8413 return sb->s_fs_info == data;
8414 @@ -125,6 +130,7 @@ void __init proc_root_init(void)
8416 proc_mkdir("bus", NULL);
8421 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
8422 @@ -192,6 +198,7 @@ struct proc_dir_entry proc_root = {
8423 .proc_iops = &proc_root_inode_operations,
8424 .proc_fops = &proc_root_operations,
8425 .parent = &proc_root,
8426 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
8430 diff -NurpP --minimal linux-3.1/fs/proc/uptime.c linux-3.1-vs2.3.1-rc2/fs/proc/uptime.c
8431 --- linux-3.1/fs/proc/uptime.c 2009-12-03 20:02:53.000000000 +0100
8432 +++ linux-3.1-vs2.3.1-rc2/fs/proc/uptime.c 2011-10-24 18:53:33.000000000 +0200
8434 #include <linux/sched.h>
8435 #include <linux/seq_file.h>
8436 #include <linux/time.h>
8437 -#include <linux/kernel_stat.h>
8438 +#include <linux/vserver/cvirt.h>
8439 #include <asm/cputime.h>
8441 static int uptime_proc_show(struct seq_file *m, void *v)
8443 struct timespec uptime;
8444 struct timespec idle;
8446 - cputime_t idletime = cputime_zero;
8448 - for_each_possible_cpu(i)
8449 - idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
8450 + cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
8452 do_posix_clock_monotonic_gettime(&uptime);
8453 monotonic_to_bootbased(&uptime);
8454 cputime_to_timespec(idletime, &idle);
8456 + if (vx_flags(VXF_VIRT_UPTIME, 0))
8457 + vx_vsi_uptime(&uptime, &idle);
8459 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
8460 (unsigned long) uptime.tv_sec,
8461 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
8462 diff -NurpP --minimal linux-3.1/fs/quota/dquot.c linux-3.1-vs2.3.1-rc2/fs/quota/dquot.c
8463 --- linux-3.1/fs/quota/dquot.c 2011-07-22 11:18:06.000000000 +0200
8464 +++ linux-3.1-vs2.3.1-rc2/fs/quota/dquot.c 2011-10-24 18:53:33.000000000 +0200
8465 @@ -1548,6 +1548,9 @@ int __dquot_alloc_space(struct inode *in
8466 int reserve = flags & DQUOT_SPACE_RESERVE;
8467 int nofail = flags & DQUOT_SPACE_NOFAIL;
8469 + if ((ret = dl_alloc_space(inode, number)))
8473 * First test before acquiring mutex - solves deadlocks when we
8474 * re-enter the quota code and are already holding the mutex
8475 @@ -1602,6 +1605,9 @@ int dquot_alloc_inode(const struct inode
8477 char warntype[MAXQUOTAS];
8479 + if ((ret = dl_alloc_inode(inode)))
8482 /* First test before acquiring mutex - solves deadlocks when we
8483 * re-enter the quota code and are already holding the mutex */
8484 if (!dquot_active(inode))
8485 @@ -1672,6 +1678,8 @@ void __dquot_free_space(struct inode *in
8486 char warntype[MAXQUOTAS];
8487 int reserve = flags & DQUOT_SPACE_RESERVE;
8489 + dl_free_space(inode, number);
8491 /* First test before acquiring mutex - solves deadlocks when we
8492 * re-enter the quota code and are already holding the mutex */
8493 if (!dquot_active(inode)) {
8494 @@ -1710,6 +1718,8 @@ void dquot_free_inode(const struct inode
8496 char warntype[MAXQUOTAS];
8498 + dl_free_inode(inode);
8500 /* First test before acquiring mutex - solves deadlocks when we
8501 * re-enter the quota code and are already holding the mutex */
8502 if (!dquot_active(inode))
8503 diff -NurpP --minimal linux-3.1/fs/quota/quota.c linux-3.1-vs2.3.1-rc2/fs/quota/quota.c
8504 --- linux-3.1/fs/quota/quota.c 2011-10-24 18:45:27.000000000 +0200
8505 +++ linux-3.1-vs2.3.1-rc2/fs/quota/quota.c 2011-10-24 18:53:33.000000000 +0200
8507 #include <linux/fs.h>
8508 #include <linux/namei.h>
8509 #include <linux/slab.h>
8510 +#include <linux/vs_context.h>
8511 #include <asm/current.h>
8512 #include <asm/uaccess.h>
8513 #include <linux/kernel.h>
8514 @@ -38,7 +39,7 @@ static int check_quotactl_permission(str
8518 - if (!capable(CAP_SYS_ADMIN))
8519 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8523 @@ -293,6 +294,46 @@ static int do_quotactl(struct super_bloc
8527 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
8529 +#include <linux/vroot.h>
8530 +#include <linux/major.h>
8531 +#include <linux/module.h>
8532 +#include <linux/kallsyms.h>
8533 +#include <linux/vserver/debug.h>
8535 +static vroot_grb_func *vroot_get_real_bdev = NULL;
8537 +static DEFINE_SPINLOCK(vroot_grb_lock);
8539 +int register_vroot_grb(vroot_grb_func *func) {
8542 + spin_lock(&vroot_grb_lock);
8543 + if (!vroot_get_real_bdev) {
8544 + vroot_get_real_bdev = func;
8547 + spin_unlock(&vroot_grb_lock);
8550 +EXPORT_SYMBOL(register_vroot_grb);
8552 +int unregister_vroot_grb(vroot_grb_func *func) {
8553 + int ret = -EINVAL;
8555 + spin_lock(&vroot_grb_lock);
8556 + if (vroot_get_real_bdev) {
8557 + vroot_get_real_bdev = NULL;
8560 + spin_unlock(&vroot_grb_lock);
8563 +EXPORT_SYMBOL(unregister_vroot_grb);
8568 * look up a superblock on which quota ops will be performed
8569 * - use the name of a block device to find the superblock thereon
8570 @@ -310,6 +351,22 @@ static struct super_block *quotactl_bloc
8573 return ERR_CAST(bdev);
8574 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
8575 + if (bdev && bdev->bd_inode &&
8576 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
8577 + struct block_device *bdnew = (void *)-EINVAL;
8579 + if (vroot_get_real_bdev)
8580 + bdnew = vroot_get_real_bdev(bdev);
8582 + vxdprintk(VXD_CBIT(misc, 0),
8583 + "vroot_get_real_bdev not set");
8585 + if (IS_ERR(bdnew))
8586 + return ERR_PTR(PTR_ERR(bdnew));
8590 sb = get_super(bdev);
8593 diff -NurpP --minimal linux-3.1/fs/reiserfs/file.c linux-3.1-vs2.3.1-rc2/fs/reiserfs/file.c
8594 --- linux-3.1/fs/reiserfs/file.c 2011-10-24 18:45:27.000000000 +0200
8595 +++ linux-3.1-vs2.3.1-rc2/fs/reiserfs/file.c 2011-10-24 18:53:33.000000000 +0200
8596 @@ -319,5 +319,6 @@ const struct inode_operations reiserfs_f
8597 .listxattr = reiserfs_listxattr,
8598 .removexattr = reiserfs_removexattr,
8599 .permission = reiserfs_permission,
8600 + .sync_flags = reiserfs_sync_flags,
8601 .get_acl = reiserfs_get_acl,
8603 diff -NurpP --minimal linux-3.1/fs/reiserfs/inode.c linux-3.1-vs2.3.1-rc2/fs/reiserfs/inode.c
8604 --- linux-3.1/fs/reiserfs/inode.c 2011-10-24 18:45:27.000000000 +0200
8605 +++ linux-3.1-vs2.3.1-rc2/fs/reiserfs/inode.c 2011-10-24 18:53:33.000000000 +0200
8607 #include <linux/writeback.h>
8608 #include <linux/quotaops.h>
8609 #include <linux/swap.h>
8610 +#include <linux/vs_tag.h>
8612 int reiserfs_commit_write(struct file *f, struct page *page,
8613 unsigned from, unsigned to);
8614 @@ -1131,6 +1132,8 @@ static void init_inode(struct inode *ino
8615 struct buffer_head *bh;
8616 struct item_head *ih;
8620 //int version = ITEM_VERSION_1;
8622 bh = PATH_PLAST_BUFFER(path);
8623 @@ -1151,12 +1154,13 @@ static void init_inode(struct inode *ino
8624 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
8625 unsigned long blocks;
8627 + uid = sd_v1_uid(sd);
8628 + gid = sd_v1_gid(sd);
8630 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
8631 set_inode_sd_version(inode, STAT_DATA_V1);
8632 inode->i_mode = sd_v1_mode(sd);
8633 inode->i_nlink = sd_v1_nlink(sd);
8634 - inode->i_uid = sd_v1_uid(sd);
8635 - inode->i_gid = sd_v1_gid(sd);
8636 inode->i_size = sd_v1_size(sd);
8637 inode->i_atime.tv_sec = sd_v1_atime(sd);
8638 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
8639 @@ -1198,11 +1202,12 @@ static void init_inode(struct inode *ino
8640 // (directories and symlinks)
8641 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
8643 + uid = sd_v2_uid(sd);
8644 + gid = sd_v2_gid(sd);
8646 inode->i_mode = sd_v2_mode(sd);
8647 inode->i_nlink = sd_v2_nlink(sd);
8648 - inode->i_uid = sd_v2_uid(sd);
8649 inode->i_size = sd_v2_size(sd);
8650 - inode->i_gid = sd_v2_gid(sd);
8651 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
8652 inode->i_atime.tv_sec = sd_v2_atime(sd);
8653 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
8654 @@ -1232,6 +1237,10 @@ static void init_inode(struct inode *ino
8655 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
8658 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
8659 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
8660 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
8663 if (S_ISREG(inode->i_mode)) {
8664 inode->i_op = &reiserfs_file_inode_operations;
8665 @@ -1254,13 +1263,15 @@ static void init_inode(struct inode *ino
8666 static void inode2sd(void *sd, struct inode *inode, loff_t size)
8668 struct stat_data *sd_v2 = (struct stat_data *)sd;
8669 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
8670 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
8673 + set_sd_v2_uid(sd_v2, uid);
8674 + set_sd_v2_gid(sd_v2, gid);
8675 set_sd_v2_mode(sd_v2, inode->i_mode);
8676 set_sd_v2_nlink(sd_v2, inode->i_nlink);
8677 - set_sd_v2_uid(sd_v2, inode->i_uid);
8678 set_sd_v2_size(sd_v2, size);
8679 - set_sd_v2_gid(sd_v2, inode->i_gid);
8680 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
8681 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
8682 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
8683 @@ -2868,14 +2879,19 @@ int reiserfs_commit_write(struct file *f
8684 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
8686 if (reiserfs_attrs(inode->i_sb)) {
8687 - if (sd_attrs & REISERFS_SYNC_FL)
8688 - inode->i_flags |= S_SYNC;
8690 - inode->i_flags &= ~S_SYNC;
8691 if (sd_attrs & REISERFS_IMMUTABLE_FL)
8692 inode->i_flags |= S_IMMUTABLE;
8694 inode->i_flags &= ~S_IMMUTABLE;
8695 + if (sd_attrs & REISERFS_IXUNLINK_FL)
8696 + inode->i_flags |= S_IXUNLINK;
8698 + inode->i_flags &= ~S_IXUNLINK;
8700 + if (sd_attrs & REISERFS_SYNC_FL)
8701 + inode->i_flags |= S_SYNC;
8703 + inode->i_flags &= ~S_SYNC;
8704 if (sd_attrs & REISERFS_APPEND_FL)
8705 inode->i_flags |= S_APPEND;
8707 @@ -2888,6 +2904,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
8708 REISERFS_I(inode)->i_flags |= i_nopack_mask;
8710 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
8712 + if (sd_attrs & REISERFS_BARRIER_FL)
8713 + inode->i_vflags |= V_BARRIER;
8715 + inode->i_vflags &= ~V_BARRIER;
8716 + if (sd_attrs & REISERFS_COW_FL)
8717 + inode->i_vflags |= V_COW;
8719 + inode->i_vflags &= ~V_COW;
8723 @@ -2898,6 +2923,11 @@ void i_attrs_to_sd_attrs(struct inode *i
8724 *sd_attrs |= REISERFS_IMMUTABLE_FL;
8726 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
8727 + if (inode->i_flags & S_IXUNLINK)
8728 + *sd_attrs |= REISERFS_IXUNLINK_FL;
8730 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
8732 if (inode->i_flags & S_SYNC)
8733 *sd_attrs |= REISERFS_SYNC_FL;
8735 @@ -2910,6 +2940,15 @@ void i_attrs_to_sd_attrs(struct inode *i
8736 *sd_attrs |= REISERFS_NOTAIL_FL;
8738 *sd_attrs &= ~REISERFS_NOTAIL_FL;
8740 + if (inode->i_vflags & V_BARRIER)
8741 + *sd_attrs |= REISERFS_BARRIER_FL;
8743 + *sd_attrs &= ~REISERFS_BARRIER_FL;
8744 + if (inode->i_vflags & V_COW)
8745 + *sd_attrs |= REISERFS_COW_FL;
8747 + *sd_attrs &= ~REISERFS_COW_FL;
8751 @@ -3155,7 +3194,8 @@ int reiserfs_setattr(struct dentry *dent
8754 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
8755 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
8756 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
8757 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
8758 struct reiserfs_transaction_handle th;
8761 @@ -3184,6 +3224,9 @@ int reiserfs_setattr(struct dentry *dent
8762 inode->i_uid = attr->ia_uid;
8763 if (attr->ia_valid & ATTR_GID)
8764 inode->i_gid = attr->ia_gid;
8765 + if ((attr->ia_valid & ATTR_TAG) &&
8767 + inode->i_tag = attr->ia_tag;
8768 mark_inode_dirty(inode);
8769 error = journal_end(&th, inode->i_sb, jbegin_count);
8771 diff -NurpP --minimal linux-3.1/fs/reiserfs/ioctl.c linux-3.1-vs2.3.1-rc2/fs/reiserfs/ioctl.c
8772 --- linux-3.1/fs/reiserfs/ioctl.c 2011-05-22 16:17:53.000000000 +0200
8773 +++ linux-3.1-vs2.3.1-rc2/fs/reiserfs/ioctl.c 2011-10-24 18:53:33.000000000 +0200
8775 #include <linux/pagemap.h>
8776 #include <linux/compat.h>
8779 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
8781 + __u16 sd_attrs = 0;
8783 + inode->i_flags = flags;
8784 + inode->i_vflags = vflags;
8786 + i_attrs_to_sd_attrs(inode, &sd_attrs);
8787 + REISERFS_I(inode)->i_attrs = sd_attrs;
8788 + inode->i_ctime = CURRENT_TIME_SEC;
8789 + mark_inode_dirty(inode);
8794 * reiserfs_ioctl - handler for ioctl for inode
8795 * supported commands:
8797 long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
8799 struct inode *inode = filp->f_path.dentry->d_inode;
8800 - unsigned int flags;
8801 + unsigned int flags, oldflags;
8804 reiserfs_write_lock(inode->i_sb);
8805 @@ -47,6 +62,7 @@ long reiserfs_ioctl(struct file *filp, u
8807 flags = REISERFS_I(inode)->i_attrs;
8808 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
8809 + flags &= REISERFS_FL_USER_VISIBLE;
8810 err = put_user(flags, (int __user *)arg);
8812 case REISERFS_IOC_SETFLAGS:{
8813 @@ -67,6 +83,10 @@ long reiserfs_ioctl(struct file *filp, u
8817 + if (IS_BARRIER(inode)) {
8818 + vxwprintk_task(1, "messing with the barrier.");
8822 * Is it quota file? Do not allow user to mess with it
8824 @@ -91,6 +111,10 @@ long reiserfs_ioctl(struct file *filp, u
8829 + oldflags = REISERFS_I(inode)->i_attrs;
8830 + flags &= REISERFS_FL_USER_MODIFIABLE;
8831 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
8832 sd_attrs_to_i_attrs(flags, inode);
8833 REISERFS_I(inode)->i_attrs = flags;
8834 inode->i_ctime = CURRENT_TIME_SEC;
8835 diff -NurpP --minimal linux-3.1/fs/reiserfs/namei.c linux-3.1-vs2.3.1-rc2/fs/reiserfs/namei.c
8836 --- linux-3.1/fs/reiserfs/namei.c 2011-10-24 18:45:27.000000000 +0200
8837 +++ linux-3.1-vs2.3.1-rc2/fs/reiserfs/namei.c 2011-10-24 18:53:33.000000000 +0200
8839 #include <linux/reiserfs_acl.h>
8840 #include <linux/reiserfs_xattr.h>
8841 #include <linux/quotaops.h>
8842 +#include <linux/vs_tag.h>
8844 #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; }
8845 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
8846 @@ -362,6 +363,7 @@ static struct dentry *reiserfs_lookup(st
8847 if (retval == IO_ERROR) {
8848 return ERR_PTR(-EIO);
8850 + dx_propagate_tag(nd, inode);
8852 return d_splice_alias(inode, dentry);
8854 diff -NurpP --minimal linux-3.1/fs/reiserfs/super.c linux-3.1-vs2.3.1-rc2/fs/reiserfs/super.c
8855 --- linux-3.1/fs/reiserfs/super.c 2011-10-24 18:45:27.000000000 +0200
8856 +++ linux-3.1-vs2.3.1-rc2/fs/reiserfs/super.c 2011-10-24 18:53:33.000000000 +0200
8857 @@ -899,6 +899,14 @@ static int reiserfs_parse_options(struct
8858 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
8859 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
8861 +#ifndef CONFIG_TAGGING_NONE
8862 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
8863 + {"tag",.setmask = 1 << REISERFS_TAGGED},
8864 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
8866 +#ifdef CONFIG_PROPAGATE
8867 + {"tag",.arg_required = 'T',.values = NULL},
8869 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
8870 {"acl",.setmask = 1 << REISERFS_POSIXACL},
8871 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
8872 @@ -1208,6 +1216,14 @@ static int reiserfs_remount(struct super
8873 handle_quota_files(s, qf_names, &qfmt);
8876 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
8877 + !(s->s_flags & MS_TAGGED)) {
8878 + reiserfs_warning(s, "super-vs01",
8879 + "reiserfs: tagging not permitted on remount.");
8886 /* Add options that are safe here */
8887 @@ -1691,6 +1707,10 @@ static int reiserfs_fill_super(struct su
8891 + /* map mount option tagxid */
8892 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
8893 + s->s_flags |= MS_TAGGED;
8895 rs = SB_DISK_SUPER_BLOCK(s);
8896 /* Let's do basic sanity check to verify that underlying device is not
8897 smaller than the filesystem. If the check fails then abort and scream,
8898 diff -NurpP --minimal linux-3.1/fs/reiserfs/xattr.c linux-3.1-vs2.3.1-rc2/fs/reiserfs/xattr.c
8899 --- linux-3.1/fs/reiserfs/xattr.c 2011-10-24 18:45:27.000000000 +0200
8900 +++ linux-3.1-vs2.3.1-rc2/fs/reiserfs/xattr.c 2011-10-24 18:53:33.000000000 +0200
8902 #include <linux/errno.h>
8903 #include <linux/gfp.h>
8904 #include <linux/fs.h>
8905 +#include <linux/mount.h>
8906 #include <linux/file.h>
8907 #include <linux/pagemap.h>
8908 #include <linux/xattr.h>
8909 diff -NurpP --minimal linux-3.1/fs/stat.c linux-3.1-vs2.3.1-rc2/fs/stat.c
8910 --- linux-3.1/fs/stat.c 2011-10-24 18:45:27.000000000 +0200
8911 +++ linux-3.1-vs2.3.1-rc2/fs/stat.c 2011-10-24 18:53:33.000000000 +0200
8912 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
8913 stat->nlink = inode->i_nlink;
8914 stat->uid = inode->i_uid;
8915 stat->gid = inode->i_gid;
8916 + stat->tag = inode->i_tag;
8917 stat->rdev = inode->i_rdev;
8918 stat->size = i_size_read(inode);
8919 stat->atime = inode->i_atime;
8920 diff -NurpP --minimal linux-3.1/fs/statfs.c linux-3.1-vs2.3.1-rc2/fs/statfs.c
8921 --- linux-3.1/fs/statfs.c 2011-05-22 16:17:54.000000000 +0200
8922 +++ linux-3.1-vs2.3.1-rc2/fs/statfs.c 2011-10-24 18:53:33.000000000 +0200
8924 #include <linux/statfs.h>
8925 #include <linux/security.h>
8926 #include <linux/uaccess.h>
8927 +#include <linux/vs_base.h>
8928 +#include <linux/vs_dlimit.h>
8930 static int flags_by_mnt(int mnt_flags)
8932 @@ -59,6 +61,8 @@ int statfs_by_dentry(struct dentry *dent
8933 retval = dentry->d_sb->s_op->statfs(dentry, buf);
8934 if (retval == 0 && buf->f_frsize == 0)
8935 buf->f_frsize = buf->f_bsize;
8936 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
8937 + vx_vsi_statfs(dentry->d_sb, buf);
8941 diff -NurpP --minimal linux-3.1/fs/super.c linux-3.1-vs2.3.1-rc2/fs/super.c
8942 --- linux-3.1/fs/super.c 2011-10-24 18:45:27.000000000 +0200
8943 +++ linux-3.1-vs2.3.1-rc2/fs/super.c 2011-10-24 18:53:33.000000000 +0200
8945 #include <linux/backing-dev.h>
8946 #include <linux/rculist_bl.h>
8947 #include <linux/cleancache.h>
8948 +#include <linux/devpts_fs.h>
8949 +#include <linux/proc_fs.h>
8950 +#include <linux/vs_context.h>
8951 #include "internal.h"
8954 @@ -1095,6 +1098,13 @@ mount_fs(struct file_system_type *type,
8955 WARN_ON(sb->s_bdi == &default_backing_dev_info);
8956 sb->s_flags |= MS_BORN;
8959 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) &&
8961 + (sb->s_magic != PROC_SUPER_MAGIC) &&
8962 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
8965 error = security_sb_kern_mount(sb, flags, secdata);
8968 diff -NurpP --minimal linux-3.1/fs/sysfs/mount.c linux-3.1-vs2.3.1-rc2/fs/sysfs/mount.c
8969 --- linux-3.1/fs/sysfs/mount.c 2011-07-22 11:18:06.000000000 +0200
8970 +++ linux-3.1-vs2.3.1-rc2/fs/sysfs/mount.c 2011-10-24 18:53:33.000000000 +0200
8971 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
8973 sb->s_blocksize = PAGE_CACHE_SIZE;
8974 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
8975 - sb->s_magic = SYSFS_MAGIC;
8976 + sb->s_magic = SYSFS_SUPER_MAGIC;
8977 sb->s_op = &sysfs_ops;
8978 sb->s_time_gran = 1;
8980 diff -NurpP --minimal linux-3.1/fs/utimes.c linux-3.1-vs2.3.1-rc2/fs/utimes.c
8981 --- linux-3.1/fs/utimes.c 2011-05-22 16:17:54.000000000 +0200
8982 +++ linux-3.1-vs2.3.1-rc2/fs/utimes.c 2011-10-24 18:53:33.000000000 +0200
8984 #include <linux/stat.h>
8985 #include <linux/utime.h>
8986 #include <linux/syscalls.h>
8987 +#include <linux/mount.h>
8988 +#include <linux/vs_cowbl.h>
8989 #include <asm/uaccess.h>
8990 #include <asm/unistd.h>
8992 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
8995 struct iattr newattrs;
8996 - struct inode *inode = path->dentry->d_inode;
8997 + struct inode *inode;
8999 error = mnt_want_write(path->mnt);
9003 + error = cow_check_and_break(path);
9005 + goto mnt_drop_write_and_out;
9007 + inode = path->dentry->d_inode;
9009 if (times && times[0].tv_nsec == UTIME_NOW &&
9010 times[1].tv_nsec == UTIME_NOW)
9012 diff -NurpP --minimal linux-3.1/fs/xattr.c linux-3.1-vs2.3.1-rc2/fs/xattr.c
9013 --- linux-3.1/fs/xattr.c 2011-07-22 11:18:09.000000000 +0200
9014 +++ linux-3.1-vs2.3.1-rc2/fs/xattr.c 2011-10-24 18:53:33.000000000 +0200
9016 #include <linux/module.h>
9017 #include <linux/fsnotify.h>
9018 #include <linux/audit.h>
9019 +#include <linux/mount.h>
9020 #include <asm/uaccess.h>
9023 @@ -49,7 +50,7 @@ xattr_permission(struct inode *inode, co
9024 * The trusted.* namespace can only be accessed by privileged users.
9026 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) {
9027 - if (!capable(CAP_SYS_ADMIN))
9028 + if (!vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED))
9029 return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
9032 diff -NurpP --minimal linux-3.1/fs/xfs/xfs_dinode.h linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_dinode.h
9033 --- linux-3.1/fs/xfs/xfs_dinode.h 2011-10-24 18:45:31.000000000 +0200
9034 +++ linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_dinode.h 2011-10-24 18:53:33.000000000 +0200
9035 @@ -51,7 +51,9 @@ typedef struct xfs_dinode {
9036 __be32 di_nlink; /* number of links to file */
9037 __be16 di_projid_lo; /* lower part of owner's project id */
9038 __be16 di_projid_hi; /* higher part owner's project id */
9039 - __u8 di_pad[6]; /* unused, zeroed space */
9040 + __u8 di_pad[2]; /* unused, zeroed space */
9041 + __be16 di_tag; /* context tagging */
9042 + __be16 di_vflags; /* vserver specific flags */
9043 __be16 di_flushiter; /* incremented on flush */
9044 xfs_timestamp_t di_atime; /* time last accessed */
9045 xfs_timestamp_t di_mtime; /* time last modified */
9046 @@ -184,6 +186,8 @@ static inline void xfs_dinode_put_rdev(s
9047 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
9048 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
9049 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
9050 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
9052 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
9053 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
9054 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
9055 @@ -199,6 +203,7 @@ static inline void xfs_dinode_put_rdev(s
9056 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
9057 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
9058 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
9059 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
9061 #ifdef CONFIG_XFS_RT
9062 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
9063 @@ -211,6 +216,10 @@ static inline void xfs_dinode_put_rdev(s
9064 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
9065 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
9066 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
9067 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
9068 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
9069 + XFS_DIFLAG_IXUNLINK)
9071 +#define XFS_DIVFLAG_BARRIER 0x01
9072 +#define XFS_DIVFLAG_COW 0x02
9074 #endif /* __XFS_DINODE_H__ */
9075 diff -NurpP --minimal linux-3.1/fs/xfs/xfs_fs.h linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_fs.h
9076 --- linux-3.1/fs/xfs/xfs_fs.h 2011-10-24 18:45:31.000000000 +0200
9077 +++ linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_fs.h 2011-10-24 18:53:33.000000000 +0200
9078 @@ -67,6 +67,9 @@ struct fsxattr {
9079 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
9080 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
9081 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
9082 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
9083 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
9084 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
9085 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
9088 @@ -302,7 +305,8 @@ typedef struct xfs_bstat {
9089 #define bs_projid bs_projid_lo /* (previously just bs_projid) */
9090 __u16 bs_forkoff; /* inode fork offset in bytes */
9091 __u16 bs_projid_hi; /* higher part of project id */
9092 - unsigned char bs_pad[10]; /* pad space, unused */
9093 + unsigned char bs_pad[8]; /* pad space, unused */
9094 + __u16 bs_tag; /* context tagging */
9095 __u32 bs_dmevmask; /* DMIG event mask */
9096 __u16 bs_dmstate; /* DMIG state info */
9097 __u16 bs_aextents; /* attribute number of extents */
9098 diff -NurpP --minimal linux-3.1/fs/xfs/xfs_ialloc.c linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_ialloc.c
9099 --- linux-3.1/fs/xfs/xfs_ialloc.c 2011-10-24 18:45:31.000000000 +0200
9100 +++ linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_ialloc.c 2011-10-24 18:53:33.000000000 +0200
9102 #include "xfs_error.h"
9103 #include "xfs_bmap.h"
9107 * Allocation group level functions.
9109 diff -NurpP --minimal linux-3.1/fs/xfs/xfs_inode.c linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_inode.c
9110 --- linux-3.1/fs/xfs/xfs_inode.c 2011-10-24 18:45:31.000000000 +0200
9111 +++ linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_inode.c 2011-10-24 18:53:33.000000000 +0200
9112 @@ -242,6 +242,7 @@ xfs_inotobp(
9116 +#include <linux/vs_tag.h>
9119 * This routine is called to map an inode to the buffer containing
9120 @@ -640,15 +641,25 @@ xfs_iformat_btree(
9122 xfs_dinode_from_disk(
9124 - xfs_dinode_t *from)
9125 + xfs_dinode_t *from,
9128 + uint32_t uid, gid, tag;
9130 to->di_magic = be16_to_cpu(from->di_magic);
9131 to->di_mode = be16_to_cpu(from->di_mode);
9132 to->di_version = from ->di_version;
9133 to->di_format = from->di_format;
9134 to->di_onlink = be16_to_cpu(from->di_onlink);
9135 - to->di_uid = be32_to_cpu(from->di_uid);
9136 - to->di_gid = be32_to_cpu(from->di_gid);
9138 + uid = be32_to_cpu(from->di_uid);
9139 + gid = be32_to_cpu(from->di_gid);
9140 + tag = be16_to_cpu(from->di_tag);
9142 + to->di_uid = INOTAG_UID(tagged, uid, gid);
9143 + to->di_gid = INOTAG_GID(tagged, uid, gid);
9144 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
9146 to->di_nlink = be32_to_cpu(from->di_nlink);
9147 to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
9148 to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
9149 @@ -670,21 +681,26 @@ xfs_dinode_from_disk(
9150 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
9151 to->di_dmstate = be16_to_cpu(from->di_dmstate);
9152 to->di_flags = be16_to_cpu(from->di_flags);
9153 + to->di_vflags = be16_to_cpu(from->di_vflags);
9154 to->di_gen = be32_to_cpu(from->di_gen);
9160 - xfs_icdinode_t *from)
9161 + xfs_icdinode_t *from,
9164 to->di_magic = cpu_to_be16(from->di_magic);
9165 to->di_mode = cpu_to_be16(from->di_mode);
9166 to->di_version = from ->di_version;
9167 to->di_format = from->di_format;
9168 to->di_onlink = cpu_to_be16(from->di_onlink);
9169 - to->di_uid = cpu_to_be32(from->di_uid);
9170 - to->di_gid = cpu_to_be32(from->di_gid);
9172 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
9173 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
9174 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
9176 to->di_nlink = cpu_to_be32(from->di_nlink);
9177 to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
9178 to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
9179 @@ -706,12 +722,14 @@ xfs_dinode_to_disk(
9180 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
9181 to->di_dmstate = cpu_to_be16(from->di_dmstate);
9182 to->di_flags = cpu_to_be16(from->di_flags);
9183 + to->di_vflags = cpu_to_be16(from->di_vflags);
9184 to->di_gen = cpu_to_be32(from->di_gen);
9189 - __uint16_t di_flags)
9190 + __uint16_t di_flags,
9191 + __uint16_t di_vflags)
9195 @@ -722,6 +740,8 @@ _xfs_dic2xflags(
9196 flags |= XFS_XFLAG_PREALLOC;
9197 if (di_flags & XFS_DIFLAG_IMMUTABLE)
9198 flags |= XFS_XFLAG_IMMUTABLE;
9199 + if (di_flags & XFS_DIFLAG_IXUNLINK)
9200 + flags |= XFS_XFLAG_IXUNLINK;
9201 if (di_flags & XFS_DIFLAG_APPEND)
9202 flags |= XFS_XFLAG_APPEND;
9203 if (di_flags & XFS_DIFLAG_SYNC)
9204 @@ -746,6 +766,10 @@ _xfs_dic2xflags(
9205 flags |= XFS_XFLAG_FILESTREAM;
9208 + if (di_vflags & XFS_DIVFLAG_BARRIER)
9209 + flags |= FS_BARRIER_FL;
9210 + if (di_vflags & XFS_DIVFLAG_COW)
9211 + flags |= FS_COW_FL;
9215 @@ -755,7 +779,7 @@ xfs_ip2xflags(
9217 xfs_icdinode_t *dic = &ip->i_d;
9219 - return _xfs_dic2xflags(dic->di_flags) |
9220 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
9221 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
9224 @@ -763,7 +787,8 @@ uint
9228 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
9229 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
9230 + be16_to_cpu(dip->di_vflags)) |
9231 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
9234 @@ -796,7 +821,6 @@ xfs_iread(
9237 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
9240 * If we got something that isn't an inode it means someone
9241 * (nfs or dmi) has a stale handle.
9242 @@ -819,7 +843,8 @@ xfs_iread(
9243 * Otherwise, just get the truly permanent information.
9246 - xfs_dinode_from_disk(&ip->i_d, dip);
9247 + xfs_dinode_from_disk(&ip->i_d, dip,
9248 + mp->m_flags & XFS_MOUNT_TAGGED);
9249 error = xfs_iformat(ip, dip);
9252 @@ -1014,6 +1039,7 @@ xfs_ialloc(
9253 ASSERT(ip->i_d.di_nlink == nlink);
9254 ip->i_d.di_uid = current_fsuid();
9255 ip->i_d.di_gid = current_fsgid();
9256 + ip->i_d.di_tag = current_fstag(&ip->i_vnode);
9257 xfs_set_projid(ip, prid);
9258 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
9260 @@ -1074,6 +1100,7 @@ xfs_ialloc(
9261 ip->i_d.di_dmevmask = 0;
9262 ip->i_d.di_dmstate = 0;
9263 ip->i_d.di_flags = 0;
9264 + ip->i_d.di_vflags = 0;
9265 flags = XFS_ILOG_CORE;
9266 switch (mode & S_IFMT) {
9268 @@ -1845,6 +1872,7 @@ xfs_ifree(
9270 ip->i_d.di_mode = 0; /* mark incore inode as free */
9271 ip->i_d.di_flags = 0;
9272 + ip->i_d.di_vflags = 0;
9273 ip->i_d.di_dmevmask = 0;
9274 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
9275 ip->i_df.if_ext_max =
9276 @@ -2724,7 +2752,8 @@ xfs_iflush_int(
9277 * because if the inode is dirty at all the core must
9280 - xfs_dinode_to_disk(dip, &ip->i_d);
9281 + xfs_dinode_to_disk(dip, &ip->i_d,
9282 + mp->m_flags & XFS_MOUNT_TAGGED);
9284 /* Wrap, we never let the log put out DI_MAX_FLUSH */
9285 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
9286 diff -NurpP --minimal linux-3.1/fs/xfs/xfs_inode.h linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_inode.h
9287 --- linux-3.1/fs/xfs/xfs_inode.h 2011-10-24 18:45:31.000000000 +0200
9288 +++ linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_inode.h 2011-10-24 18:53:33.000000000 +0200
9289 @@ -135,7 +135,9 @@ typedef struct xfs_icdinode {
9290 __uint32_t di_nlink; /* number of links to file */
9291 __uint16_t di_projid_lo; /* lower part of owner's project id */
9292 __uint16_t di_projid_hi; /* higher part of owner's project id */
9293 - __uint8_t di_pad[6]; /* unused, zeroed space */
9294 + __uint8_t di_pad[2]; /* unused, zeroed space */
9295 + __uint16_t di_tag; /* context tagging */
9296 + __uint16_t di_vflags; /* vserver specific flags */
9297 __uint16_t di_flushiter; /* incremented on flush */
9298 xfs_ictimestamp_t di_atime; /* time last accessed */
9299 xfs_ictimestamp_t di_mtime; /* time last modified */
9300 @@ -536,7 +538,7 @@ int xfs_itobp(struct xfs_mount *, struc
9301 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
9302 struct xfs_inode *, uint);
9303 void xfs_dinode_to_disk(struct xfs_dinode *,
9304 - struct xfs_icdinode *);
9305 + struct xfs_icdinode *, int);
9306 void xfs_idestroy_fork(struct xfs_inode *, int);
9307 void xfs_idata_realloc(struct xfs_inode *, int, int);
9308 void xfs_iroot_realloc(struct xfs_inode *, int, int);
9309 diff -NurpP --minimal linux-3.1/fs/xfs/xfs_ioctl.c linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_ioctl.c
9310 --- linux-3.1/fs/xfs/xfs_ioctl.c 2011-10-24 18:45:31.000000000 +0200
9311 +++ linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_ioctl.c 2011-10-24 18:53:33.000000000 +0200
9313 #include "xfs_bmap_btree.h"
9314 #include "xfs_dinode.h"
9315 #include "xfs_inode.h"
9316 -#include "xfs_ioctl.h"
9317 +// #include "xfs_ioctl.h"
9318 #include "xfs_rtalloc.h"
9319 #include "xfs_itable.h"
9320 #include "xfs_error.h"
9321 @@ -748,6 +748,10 @@ xfs_merge_ioc_xflags(
9322 xflags |= XFS_XFLAG_IMMUTABLE;
9324 xflags &= ~XFS_XFLAG_IMMUTABLE;
9325 + if (flags & FS_IXUNLINK_FL)
9326 + xflags |= XFS_XFLAG_IXUNLINK;
9328 + xflags &= ~XFS_XFLAG_IXUNLINK;
9329 if (flags & FS_APPEND_FL)
9330 xflags |= XFS_XFLAG_APPEND;
9332 @@ -776,6 +780,8 @@ xfs_di2lxflags(
9334 if (di_flags & XFS_DIFLAG_IMMUTABLE)
9335 flags |= FS_IMMUTABLE_FL;
9336 + if (di_flags & XFS_DIFLAG_IXUNLINK)
9337 + flags |= FS_IXUNLINK_FL;
9338 if (di_flags & XFS_DIFLAG_APPEND)
9339 flags |= FS_APPEND_FL;
9340 if (di_flags & XFS_DIFLAG_SYNC)
9341 @@ -836,6 +842,8 @@ xfs_set_diflags(
9342 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
9343 if (xflags & XFS_XFLAG_IMMUTABLE)
9344 di_flags |= XFS_DIFLAG_IMMUTABLE;
9345 + if (xflags & XFS_XFLAG_IXUNLINK)
9346 + di_flags |= XFS_DIFLAG_IXUNLINK;
9347 if (xflags & XFS_XFLAG_APPEND)
9348 di_flags |= XFS_DIFLAG_APPEND;
9349 if (xflags & XFS_XFLAG_SYNC)
9350 @@ -878,6 +886,10 @@ xfs_diflags_to_linux(
9351 inode->i_flags |= S_IMMUTABLE;
9353 inode->i_flags &= ~S_IMMUTABLE;
9354 + if (xflags & XFS_XFLAG_IXUNLINK)
9355 + inode->i_flags |= S_IXUNLINK;
9357 + inode->i_flags &= ~S_IXUNLINK;
9358 if (xflags & XFS_XFLAG_APPEND)
9359 inode->i_flags |= S_APPEND;
9361 @@ -1370,10 +1382,18 @@ xfs_file_ioctl(
9362 case XFS_IOC_FSGETXATTRA:
9363 return xfs_ioc_fsgetxattr(ip, 1, arg);
9364 case XFS_IOC_FSSETXATTR:
9365 + if (IS_BARRIER(inode)) {
9366 + vxwprintk_task(1, "messing with the barrier.");
9367 + return -XFS_ERROR(EACCES);
9369 return xfs_ioc_fssetxattr(ip, filp, arg);
9370 case XFS_IOC_GETXFLAGS:
9371 return xfs_ioc_getxflags(ip, arg);
9372 case XFS_IOC_SETXFLAGS:
9373 + if (IS_BARRIER(inode)) {
9374 + vxwprintk_task(1, "messing with the barrier.");
9375 + return -XFS_ERROR(EACCES);
9377 return xfs_ioc_setxflags(ip, filp, arg);
9379 case XFS_IOC_FSSETDM: {
9380 diff -NurpP --minimal linux-3.1/fs/xfs/xfs_ioctl.h linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_ioctl.h
9381 --- linux-3.1/fs/xfs/xfs_ioctl.h 2011-10-24 18:45:31.000000000 +0200
9382 +++ linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_ioctl.h 2011-10-24 18:53:33.000000000 +0200
9383 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
9384 void __user *uhandle,
9389 + struct inode *inode,
9396 diff -NurpP --minimal linux-3.1/fs/xfs/xfs_iops.c linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_iops.c
9397 --- linux-3.1/fs/xfs/xfs_iops.c 2011-10-24 18:45:31.000000000 +0200
9398 +++ linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_iops.c 2011-10-24 18:53:33.000000000 +0200
9400 #include "xfs_bmap_btree.h"
9401 #include "xfs_dinode.h"
9402 #include "xfs_inode.h"
9403 +#include "xfs_ioctl.h"
9404 #include "xfs_bmap.h"
9405 #include "xfs_rtalloc.h"
9406 #include "xfs_error.h"
9408 #include <linux/security.h>
9409 #include <linux/fiemap.h>
9410 #include <linux/slab.h>
9411 +#include <linux/vs_tag.h>
9414 * Bring the timestamps in the XFS inode uptodate.
9415 @@ -473,6 +475,7 @@ xfs_vn_getattr(
9416 stat->nlink = ip->i_d.di_nlink;
9417 stat->uid = ip->i_d.di_uid;
9418 stat->gid = ip->i_d.di_gid;
9419 + stat->tag = ip->i_d.di_tag;
9420 stat->ino = ip->i_ino;
9421 stat->atime = inode->i_atime;
9422 stat->mtime = inode->i_mtime;
9423 @@ -1038,6 +1041,7 @@ static const struct inode_operations xfs
9424 .removexattr = generic_removexattr,
9425 .listxattr = xfs_vn_listxattr,
9426 .fiemap = xfs_vn_fiemap,
9427 + .sync_flags = xfs_sync_flags,
9430 static const struct inode_operations xfs_dir_inode_operations = {
9431 @@ -1063,6 +1067,7 @@ static const struct inode_operations xfs
9432 .getxattr = generic_getxattr,
9433 .removexattr = generic_removexattr,
9434 .listxattr = xfs_vn_listxattr,
9435 + .sync_flags = xfs_sync_flags,
9438 static const struct inode_operations xfs_dir_ci_inode_operations = {
9439 @@ -1112,6 +1117,10 @@ xfs_diflags_to_iflags(
9440 inode->i_flags |= S_IMMUTABLE;
9442 inode->i_flags &= ~S_IMMUTABLE;
9443 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
9444 + inode->i_flags |= S_IXUNLINK;
9446 + inode->i_flags &= ~S_IXUNLINK;
9447 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
9448 inode->i_flags |= S_APPEND;
9450 @@ -1124,6 +1133,15 @@ xfs_diflags_to_iflags(
9451 inode->i_flags |= S_NOATIME;
9453 inode->i_flags &= ~S_NOATIME;
9455 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
9456 + inode->i_vflags |= V_BARRIER;
9458 + inode->i_vflags &= ~V_BARRIER;
9459 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
9460 + inode->i_vflags |= V_COW;
9462 + inode->i_vflags &= ~V_COW;
9466 @@ -1155,6 +1173,7 @@ xfs_setup_inode(
9467 inode->i_nlink = ip->i_d.di_nlink;
9468 inode->i_uid = ip->i_d.di_uid;
9469 inode->i_gid = ip->i_d.di_gid;
9470 + inode->i_tag = ip->i_d.di_tag;
9472 switch (inode->i_mode & S_IFMT) {
9474 diff -NurpP --minimal linux-3.1/fs/xfs/xfs_itable.c linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_itable.c
9475 --- linux-3.1/fs/xfs/xfs_itable.c 2011-05-22 16:17:54.000000000 +0200
9476 +++ linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_itable.c 2011-10-24 18:53:33.000000000 +0200
9477 @@ -98,6 +98,7 @@ xfs_bulkstat_one_int(
9478 buf->bs_mode = dic->di_mode;
9479 buf->bs_uid = dic->di_uid;
9480 buf->bs_gid = dic->di_gid;
9481 + buf->bs_tag = dic->di_tag;
9482 buf->bs_size = dic->di_size;
9485 diff -NurpP --minimal linux-3.1/fs/xfs/xfs_linux.h linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_linux.h
9486 --- linux-3.1/fs/xfs/xfs_linux.h 2011-10-24 18:45:31.000000000 +0200
9487 +++ linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_linux.h 2011-10-24 18:53:33.000000000 +0200
9490 #define current_cpu() (raw_smp_processor_id())
9491 #define current_pid() (current->pid)
9492 +#define current_fstag(vp) (dx_current_fstag((vp)->i_sb))
9493 #define current_test_flags(f) (current->flags & (f))
9494 #define current_set_flags_nested(sp, f) \
9495 (*(sp) = current->flags, current->flags |= (f))
9496 diff -NurpP --minimal linux-3.1/fs/xfs/xfs_log_recover.c linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_log_recover.c
9497 --- linux-3.1/fs/xfs/xfs_log_recover.c 2011-10-24 18:45:31.000000000 +0200
9498 +++ linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_log_recover.c 2011-10-24 18:53:33.000000000 +0200
9499 @@ -2347,7 +2347,8 @@ xlog_recover_inode_pass2(
9502 /* The core is in in-core format */
9503 - xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr);
9504 + xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr,
9505 + mp->m_flags & XFS_MOUNT_TAGGED);
9507 /* the rest is in on-disk format */
9508 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
9509 diff -NurpP --minimal linux-3.1/fs/xfs/xfs_mount.h linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_mount.h
9510 --- linux-3.1/fs/xfs/xfs_mount.h 2011-10-24 18:45:31.000000000 +0200
9511 +++ linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_mount.h 2011-10-24 18:53:33.000000000 +0200
9512 @@ -249,6 +249,7 @@ typedef struct xfs_mount {
9514 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
9516 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
9519 * Default minimum read and write sizes.
9520 diff -NurpP --minimal linux-3.1/fs/xfs/xfs_super.c linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_super.c
9521 --- linux-3.1/fs/xfs/xfs_super.c 2011-10-24 18:45:31.000000000 +0200
9522 +++ linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_super.c 2011-10-24 18:53:33.000000000 +0200
9523 @@ -113,6 +113,9 @@ mempool_t *xfs_ioend_pool;
9524 #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed logging disabled */
9525 #define MNTOPT_DISCARD "discard" /* Discard unused blocks */
9526 #define MNTOPT_NODISCARD "nodiscard" /* Do not discard unused blocks */
9527 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
9528 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
9529 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
9532 * Table driven mount option parser.
9533 @@ -121,10 +124,14 @@ mempool_t *xfs_ioend_pool;
9534 * in the future, too.
9537 + Opt_tag, Opt_notag,
9538 Opt_barrier, Opt_nobarrier, Opt_err
9541 static const match_table_t tokens = {
9542 + {Opt_tag, "tagxid"},
9544 + {Opt_notag, "notag"},
9545 {Opt_barrier, "barrier"},
9546 {Opt_nobarrier, "nobarrier"},
9548 @@ -374,6 +381,19 @@ xfs_parseargs(
9549 } else if (!strcmp(this_char, "irixsgid")) {
9551 "irixsgid is now a sysctl(2) variable, option is deprecated.");
9552 +#ifndef CONFIG_TAGGING_NONE
9553 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
9554 + mp->m_flags |= XFS_MOUNT_TAGGED;
9555 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
9556 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
9557 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
9558 + mp->m_flags |= XFS_MOUNT_TAGGED;
9560 +#ifdef CONFIG_PROPAGATE
9561 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
9563 + mp->m_flags |= XFS_MOUNT_TAGGED;
9566 xfs_warn(mp, "unknown mount option [%s].", this_char);
9568 @@ -1162,6 +1182,16 @@ xfs_fs_remount(
9570 mp->m_flags &= ~XFS_MOUNT_BARRIER;
9573 + if (!(sb->s_flags & MS_TAGGED)) {
9575 + "XFS: %s: tagging not permitted on remount.\n",
9584 * Logically we would return an error here to prevent
9585 @@ -1377,6 +1407,9 @@ xfs_fs_fill_super(
9589 + if (mp->m_flags & XFS_MOUNT_TAGGED)
9590 + sb->s_flags |= MS_TAGGED;
9593 * we must configure the block size in the superblock before we run the
9594 * full mount process as the mount process can lookup and cache inodes.
9595 diff -NurpP --minimal linux-3.1/fs/xfs/xfs_vnodeops.c linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_vnodeops.c
9596 --- linux-3.1/fs/xfs/xfs_vnodeops.c 2011-10-24 18:45:31.000000000 +0200
9597 +++ linux-3.1-vs2.3.1-rc2/fs/xfs/xfs_vnodeops.c 2011-10-24 18:53:33.000000000 +0200
9598 @@ -107,6 +107,78 @@ xfs_readlink_bmap(
9604 +xfs_get_inode_flags(
9607 + struct inode *inode = VFS_I(ip);
9608 + unsigned int flags = inode->i_flags;
9609 + unsigned int vflags = inode->i_vflags;
9611 + if (flags & S_IMMUTABLE)
9612 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
9614 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
9615 + if (flags & S_IXUNLINK)
9616 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
9618 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
9620 + if (vflags & V_BARRIER)
9621 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
9623 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
9624 + if (vflags & V_COW)
9625 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
9627 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
9632 + struct inode *inode,
9636 + struct xfs_inode *ip = XFS_I(inode);
9637 + struct xfs_mount *mp = ip->i_mount;
9638 + struct xfs_trans *tp;
9639 + unsigned int lock_flags = 0;
9642 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
9643 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
9647 + xfs_ilock(ip, XFS_ILOCK_EXCL);
9649 + xfs_trans_ijoin(tp, ip);
9651 + inode->i_flags = flags;
9652 + inode->i_vflags = vflags;
9653 + xfs_get_inode_flags(ip);
9655 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
9656 + xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
9658 + XFS_STATS_INC(xs_ig_attrchg);
9660 + if (mp->m_flags & XFS_MOUNT_WSYNC)
9661 + xfs_trans_set_sync(tp);
9662 + code = xfs_trans_commit(tp, 0);
9663 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
9667 + xfs_trans_cancel(tp, 0);
9669 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
9677 diff -NurpP --minimal linux-3.1/include/asm-generic/tlb.h linux-3.1-vs2.3.1-rc2/include/asm-generic/tlb.h
9678 --- linux-3.1/include/asm-generic/tlb.h 2011-07-22 11:18:10.000000000 +0200
9679 +++ linux-3.1-vs2.3.1-rc2/include/asm-generic/tlb.h 2011-10-24 18:53:33.000000000 +0200
9681 #define _ASM_GENERIC__TLB_H
9683 #include <linux/swap.h>
9684 +#include <linux/vs_memory.h>
9685 #include <asm/pgalloc.h>
9686 #include <asm/tlbflush.h>
9688 diff -NurpP --minimal linux-3.1/include/linux/Kbuild linux-3.1-vs2.3.1-rc2/include/linux/Kbuild
9689 --- linux-3.1/include/linux/Kbuild 2011-10-24 18:45:31.000000000 +0200
9690 +++ linux-3.1-vs2.3.1-rc2/include/linux/Kbuild 2011-10-24 18:53:33.000000000 +0200
9691 @@ -17,6 +17,7 @@ header-y += netfilter_bridge/
9692 header-y += netfilter_ipv4/
9693 header-y += netfilter_ipv6/
9695 +header-y += vserver/
9698 objhdr-y += version.h
9699 diff -NurpP --minimal linux-3.1/include/linux/capability.h linux-3.1-vs2.3.1-rc2/include/linux/capability.h
9700 --- linux-3.1/include/linux/capability.h 2011-07-22 11:18:10.000000000 +0200
9701 +++ linux-3.1-vs2.3.1-rc2/include/linux/capability.h 2011-10-24 18:53:33.000000000 +0200
9702 @@ -279,6 +279,7 @@ struct cpu_vfs_cap_data {
9703 arbitrary SCSI commands */
9704 /* Allow setting encryption key on loopback filesystem */
9705 /* Allow setting zone reclaim policy */
9706 +/* Allow the selection of a security context */
9708 #define CAP_SYS_ADMIN 21
9710 @@ -362,7 +363,12 @@ struct cpu_vfs_cap_data {
9712 #define CAP_LAST_CAP CAP_WAKE_ALARM
9714 -#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
9715 +/* Allow context manipulations */
9716 +/* Allow changing context info on files */
9718 +#define CAP_CONTEXT 63
9720 +#define cap_valid(x) ((x) >= 0 && ((x) <= CAP_LAST_CAP || (x) == CAP_CONTEXT))
9723 * Bit location of each capability (used by user-space library and kernel)
9724 diff -NurpP --minimal linux-3.1/include/linux/cred.h linux-3.1-vs2.3.1-rc2/include/linux/cred.h
9725 --- linux-3.1/include/linux/cred.h 2011-10-24 18:45:31.000000000 +0200
9726 +++ linux-3.1-vs2.3.1-rc2/include/linux/cred.h 2011-10-24 18:53:33.000000000 +0200
9727 @@ -156,6 +156,7 @@ extern void exit_creds(struct task_struc
9728 extern int copy_creds(struct task_struct *, unsigned long);
9729 extern const struct cred *get_task_cred(struct task_struct *);
9730 extern struct cred *cred_alloc_blank(void);
9731 +extern struct cred *__prepare_creds(const struct cred *);
9732 extern struct cred *prepare_creds(void);
9733 extern struct cred *prepare_exec_creds(void);
9734 extern int commit_creds(struct cred *);
9735 @@ -209,6 +210,31 @@ static inline void validate_process_cred
9739 +static inline void set_cred_subscribers(struct cred *cred, int n)
9741 +#ifdef CONFIG_DEBUG_CREDENTIALS
9742 + atomic_set(&cred->subscribers, n);
9746 +static inline int read_cred_subscribers(const struct cred *cred)
9748 +#ifdef CONFIG_DEBUG_CREDENTIALS
9749 + return atomic_read(&cred->subscribers);
9755 +static inline void alter_cred_subscribers(const struct cred *_cred, int n)
9757 +#ifdef CONFIG_DEBUG_CREDENTIALS
9758 + struct cred *cred = (struct cred *) _cred;
9760 + atomic_add(n, &cred->subscribers);
9765 * get_new_cred - Get a reference on a new set of credentials
9766 * @cred: The new credentials to reference
9767 diff -NurpP --minimal linux-3.1/include/linux/devpts_fs.h linux-3.1-vs2.3.1-rc2/include/linux/devpts_fs.h
9768 --- linux-3.1/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
9769 +++ linux-3.1-vs2.3.1-rc2/include/linux/devpts_fs.h 2011-10-24 18:53:33.000000000 +0200
9770 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
9775 #endif /* _LINUX_DEVPTS_FS_H */
9776 diff -NurpP --minimal linux-3.1/include/linux/ext2_fs.h linux-3.1-vs2.3.1-rc2/include/linux/ext2_fs.h
9777 --- linux-3.1/include/linux/ext2_fs.h 2011-10-24 18:45:32.000000000 +0200
9778 +++ linux-3.1-vs2.3.1-rc2/include/linux/ext2_fs.h 2011-10-24 18:53:33.000000000 +0200
9779 @@ -190,8 +190,12 @@ struct ext2_group_desc
9780 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
9781 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
9782 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
9783 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
9784 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
9786 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
9787 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
9789 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
9790 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
9792 @@ -275,7 +279,8 @@ struct ext2_inode {
9794 __le16 l_i_uid_high; /* these 2 fields */
9795 __le16 l_i_gid_high; /* were reserved2[0] */
9796 - __u32 l_i_reserved2;
9797 + __le16 l_i_tag; /* Context Tag */
9798 + __u16 l_i_reserved2;
9801 __u8 h_i_frag; /* Fragment number */
9802 @@ -304,6 +309,7 @@ struct ext2_inode {
9803 #define i_gid_low i_gid
9804 #define i_uid_high osd2.linux2.l_i_uid_high
9805 #define i_gid_high osd2.linux2.l_i_gid_high
9806 +#define i_raw_tag osd2.linux2.l_i_tag
9807 #define i_reserved2 osd2.linux2.l_i_reserved2
9810 @@ -348,6 +354,7 @@ struct ext2_inode {
9811 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
9812 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
9813 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
9814 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
9817 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
9818 diff -NurpP --minimal linux-3.1/include/linux/ext3_fs.h linux-3.1-vs2.3.1-rc2/include/linux/ext3_fs.h
9819 --- linux-3.1/include/linux/ext3_fs.h 2011-10-24 18:45:32.000000000 +0200
9820 +++ linux-3.1-vs2.3.1-rc2/include/linux/ext3_fs.h 2011-10-24 18:53:33.000000000 +0200
9821 @@ -173,10 +173,14 @@ struct ext3_group_desc
9822 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
9823 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
9824 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
9825 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
9826 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
9828 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
9829 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
9830 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
9831 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
9833 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
9834 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
9836 /* Flags that should be inherited by new inodes from their parent. */
9837 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
9838 @@ -312,7 +316,8 @@ struct ext3_inode {
9840 __le16 l_i_uid_high; /* these 2 fields */
9841 __le16 l_i_gid_high; /* were reserved2[0] */
9842 - __u32 l_i_reserved2;
9843 + __le16 l_i_tag; /* Context Tag */
9844 + __u16 l_i_reserved2;
9847 __u8 h_i_frag; /* Fragment number */
9848 @@ -343,6 +348,7 @@ struct ext3_inode {
9849 #define i_gid_low i_gid
9850 #define i_uid_high osd2.linux2.l_i_uid_high
9851 #define i_gid_high osd2.linux2.l_i_gid_high
9852 +#define i_raw_tag osd2.linux2.l_i_tag
9853 #define i_reserved2 osd2.linux2.l_i_reserved2
9855 #elif defined(__GNU__)
9856 @@ -405,6 +411,7 @@ struct ext3_inode {
9857 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
9858 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
9859 * error in ordered mode */
9860 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
9862 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
9863 #ifndef _LINUX_EXT2_FS_H
9864 @@ -918,6 +925,7 @@ extern void ext3_get_inode_flags(struct
9865 extern void ext3_set_aops(struct inode *inode);
9866 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
9867 u64 start, u64 len);
9868 +extern int ext3_sync_flags(struct inode *, int, int);
9871 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
9872 diff -NurpP --minimal linux-3.1/include/linux/fs.h linux-3.1-vs2.3.1-rc2/include/linux/fs.h
9873 --- linux-3.1/include/linux/fs.h 2011-10-24 18:45:32.000000000 +0200
9874 +++ linux-3.1-vs2.3.1-rc2/include/linux/fs.h 2011-10-24 18:53:33.000000000 +0200
9875 @@ -209,6 +209,9 @@ struct inodes_stat_t {
9876 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
9877 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
9878 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
9879 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
9880 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
9881 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
9882 #define MS_NOSEC (1<<28)
9883 #define MS_BORN (1<<29)
9884 #define MS_ACTIVE (1<<30)
9885 @@ -240,6 +243,14 @@ struct inodes_stat_t {
9886 #define S_IMA 1024 /* Inode has an associated IMA struct */
9887 #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
9888 #define S_NOSEC 4096 /* no suid or xattr security attributes */
9889 +#define S_IXUNLINK 8192 /* Immutable Invert on unlink */
9891 +/* Linux-VServer related Inode flags */
9895 +#define V_BARRIER 4 /* Barrier for chroot() */
9896 +#define V_COW 8 /* Copy on Write */
9899 * Note that nosuid etc flags are inode-specific: setting some file-system
9900 @@ -262,12 +273,15 @@ struct inodes_stat_t {
9901 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
9902 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
9903 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
9904 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
9905 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
9906 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
9907 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
9908 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
9910 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
9911 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
9912 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
9913 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
9914 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
9915 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
9917 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
9918 @@ -278,6 +292,16 @@ struct inodes_stat_t {
9919 #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
9920 #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
9922 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
9924 +#ifdef CONFIG_VSERVER_COWBL
9925 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
9926 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
9928 +# define IS_COW(inode) (0)
9929 +# define IS_COW_LINK(inode) (0)
9932 /* the read-only stuff doesn't really belong here, but any other place is
9933 probably as bad and I don't want to create yet another include file. */
9935 @@ -363,11 +387,14 @@ struct inodes_stat_t {
9936 #define FS_EXTENT_FL 0x00080000 /* Extents */
9937 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
9938 #define FS_NOCOW_FL 0x00800000 /* Do not cow file */
9939 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
9940 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
9942 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
9943 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
9944 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
9945 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
9947 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
9948 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
9950 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
9951 #define SYNC_FILE_RANGE_WRITE 2
9952 @@ -448,6 +475,7 @@ typedef void (dio_iodone_t)(struct kiocb
9953 #define ATTR_KILL_PRIV (1 << 14)
9954 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
9955 #define ATTR_TIMES_SET (1 << 16)
9956 +#define ATTR_TAG (1 << 17)
9959 * This is the Inode Attributes structure, used for notify_change(). It
9960 @@ -463,6 +491,7 @@ struct iattr {
9966 struct timespec ia_atime;
9967 struct timespec ia_mtime;
9968 @@ -476,6 +505,9 @@ struct iattr {
9969 struct file *ia_file;
9972 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
9973 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
9976 * Includes for diskquotas.
9978 @@ -750,7 +782,9 @@ struct inode {
9979 unsigned short i_opflags;
9982 - unsigned int i_flags;
9984 + unsigned short i_flags;
9985 + unsigned short i_vflags;
9987 #ifdef CONFIG_FS_POSIX_ACL
9988 struct posix_acl *i_acl;
9989 @@ -769,6 +803,7 @@ struct inode {
9990 unsigned long i_ino;
9991 unsigned int i_nlink;
9995 struct timespec i_atime;
9996 struct timespec i_mtime;
9997 @@ -906,12 +941,12 @@ static inline void i_size_write(struct i
9999 static inline unsigned iminor(const struct inode *inode)
10001 - return MINOR(inode->i_rdev);
10002 + return MINOR(inode->i_mdev);
10005 static inline unsigned imajor(const struct inode *inode)
10007 - return MAJOR(inode->i_rdev);
10008 + return MAJOR(inode->i_mdev);
10011 extern struct block_device *I_BDEV(struct inode *inode);
10012 @@ -973,6 +1008,7 @@ struct file {
10014 struct fown_struct f_owner;
10015 const struct cred *f_cred;
10017 struct file_ra_state f_ra;
10020 @@ -1117,6 +1153,7 @@ struct file_lock {
10021 struct file *fl_file;
10026 struct fasync_struct * fl_fasync; /* for lease break notifications */
10027 unsigned long fl_break_time; /* for nonblocking lease breaks */
10028 @@ -1615,6 +1652,7 @@ struct inode_operations {
10029 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
10030 ssize_t (*listxattr) (struct dentry *, char *, size_t);
10031 int (*removexattr) (struct dentry *, const char *);
10032 + int (*sync_flags) (struct inode *, int, int);
10033 void (*truncate_range)(struct inode *, loff_t, loff_t);
10034 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
10036 @@ -1633,6 +1671,7 @@ extern ssize_t vfs_readv(struct file *,
10037 unsigned long, loff_t *);
10038 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
10039 unsigned long, loff_t *);
10040 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
10042 struct super_operations {
10043 struct inode *(*alloc_inode)(struct super_block *sb);
10044 @@ -2505,6 +2544,7 @@ extern int dcache_dir_open(struct inode
10045 extern int dcache_dir_close(struct inode *, struct file *);
10046 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
10047 extern int dcache_readdir(struct file *, void *, filldir_t);
10048 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
10049 extern int simple_setattr(struct dentry *, struct iattr *);
10050 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
10051 extern int simple_statfs(struct dentry *, struct kstatfs *);
10052 diff -NurpP --minimal linux-3.1/include/linux/gfs2_ondisk.h linux-3.1-vs2.3.1-rc2/include/linux/gfs2_ondisk.h
10053 --- linux-3.1/include/linux/gfs2_ondisk.h 2010-07-07 18:31:55.000000000 +0200
10054 +++ linux-3.1-vs2.3.1-rc2/include/linux/gfs2_ondisk.h 2011-10-24 18:53:33.000000000 +0200
10055 @@ -211,6 +211,9 @@ enum {
10056 gfs2fl_NoAtime = 7,
10059 + gfs2fl_IXUnlink = 16,
10060 + gfs2fl_Barrier = 17,
10062 gfs2fl_TruncInProg = 29,
10063 gfs2fl_InheritDirectio = 30,
10064 gfs2fl_InheritJdata = 31,
10065 @@ -227,6 +230,9 @@ enum {
10066 #define GFS2_DIF_NOATIME 0x00000080
10067 #define GFS2_DIF_SYNC 0x00000100
10068 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
10069 +#define GFS2_DIF_IXUNLINK 0x00010000
10070 +#define GFS2_DIF_BARRIER 0x00020000
10071 +#define GFS2_DIF_COW 0x00040000
10072 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
10073 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000
10074 #define GFS2_DIF_INHERIT_JDATA 0x80000000
10075 diff -NurpP --minimal linux-3.1/include/linux/if_tun.h linux-3.1-vs2.3.1-rc2/include/linux/if_tun.h
10076 --- linux-3.1/include/linux/if_tun.h 2010-08-02 16:52:54.000000000 +0200
10077 +++ linux-3.1-vs2.3.1-rc2/include/linux/if_tun.h 2011-10-24 18:53:33.000000000 +0200
10079 #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
10080 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
10081 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
10082 +#define TUNSETNID _IOW('T', 217, int)
10084 /* TUNSETIFF ifr flags */
10085 #define IFF_TUN 0x0001
10086 diff -NurpP --minimal linux-3.1/include/linux/init_task.h linux-3.1-vs2.3.1-rc2/include/linux/init_task.h
10087 --- linux-3.1/include/linux/init_task.h 2011-10-24 18:45:32.000000000 +0200
10088 +++ linux-3.1-vs2.3.1-rc2/include/linux/init_task.h 2011-10-24 18:53:33.000000000 +0200
10089 @@ -192,6 +192,10 @@ extern struct cred init_cred;
10090 INIT_FTRACE_GRAPH \
10091 INIT_TRACE_RECURSION \
10092 INIT_TASK_RCU_PREEMPT(tsk) \
10094 + .vx_info = NULL, \
10096 + .nx_info = NULL, \
10100 diff -NurpP --minimal linux-3.1/include/linux/ipc.h linux-3.1-vs2.3.1-rc2/include/linux/ipc.h
10101 --- linux-3.1/include/linux/ipc.h 2009-12-03 20:02:55.000000000 +0100
10102 +++ linux-3.1-vs2.3.1-rc2/include/linux/ipc.h 2011-10-24 18:53:33.000000000 +0200
10103 @@ -91,6 +91,7 @@ struct kern_ipc_perm
10111 diff -NurpP --minimal linux-3.1/include/linux/ipc_namespace.h linux-3.1-vs2.3.1-rc2/include/linux/ipc_namespace.h
10112 --- linux-3.1/include/linux/ipc_namespace.h 2011-10-24 18:45:32.000000000 +0200
10113 +++ linux-3.1-vs2.3.1-rc2/include/linux/ipc_namespace.h 2011-10-24 18:53:33.000000000 +0200
10114 @@ -101,7 +101,8 @@ static inline int mq_init_ns(struct ipc_
10116 #if defined(CONFIG_IPC_NS)
10117 extern struct ipc_namespace *copy_ipcs(unsigned long flags,
10118 - struct task_struct *tsk);
10119 + struct ipc_namespace *old_ns,
10120 + struct user_namespace *user_ns);
10121 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
10124 @@ -112,12 +113,13 @@ static inline struct ipc_namespace *get_
10125 extern void put_ipc_ns(struct ipc_namespace *ns);
10127 static inline struct ipc_namespace *copy_ipcs(unsigned long flags,
10128 - struct task_struct *tsk)
10129 + struct ipc_namespace *old_ns,
10130 + struct user_namespace *user_ns)
10132 if (flags & CLONE_NEWIPC)
10133 return ERR_PTR(-EINVAL);
10135 - return tsk->nsproxy->ipc_ns;
10139 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
10140 diff -NurpP --minimal linux-3.1/include/linux/loop.h linux-3.1-vs2.3.1-rc2/include/linux/loop.h
10141 --- linux-3.1/include/linux/loop.h 2011-10-24 18:45:32.000000000 +0200
10142 +++ linux-3.1-vs2.3.1-rc2/include/linux/loop.h 2011-10-24 18:53:33.000000000 +0200
10143 @@ -45,6 +45,7 @@ struct loop_device {
10144 struct loop_func_table *lo_encryption;
10146 uid_t lo_key_owner; /* Who set the key */
10148 int (*ioctl)(struct loop_device *, int cmd,
10149 unsigned long arg);
10151 diff -NurpP --minimal linux-3.1/include/linux/magic.h linux-3.1-vs2.3.1-rc2/include/linux/magic.h
10152 --- linux-3.1/include/linux/magic.h 2011-05-22 16:17:55.000000000 +0200
10153 +++ linux-3.1-vs2.3.1-rc2/include/linux/magic.h 2011-10-24 18:53:33.000000000 +0200
10156 #define ADFS_SUPER_MAGIC 0xadf5
10157 #define AFFS_SUPER_MAGIC 0xadff
10158 -#define AFS_SUPER_MAGIC 0x5346414F
10159 +#define AFS_SUPER_MAGIC 0x5346414F
10160 #define AUTOFS_SUPER_MAGIC 0x0187
10161 #define CODA_SUPER_MAGIC 0x73757245
10162 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
10164 #define NFS_SUPER_MAGIC 0x6969
10165 #define OPENPROM_SUPER_MAGIC 0x9fa1
10166 #define PROC_SUPER_MAGIC 0x9fa0
10167 +#define DEVPTS_SUPER_MAGIC 0x1cd1
10168 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
10170 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
10171 diff -NurpP --minimal linux-3.1/include/linux/major.h linux-3.1-vs2.3.1-rc2/include/linux/major.h
10172 --- linux-3.1/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
10173 +++ linux-3.1-vs2.3.1-rc2/include/linux/major.h 2011-10-24 18:53:33.000000000 +0200
10175 #define HD_MAJOR IDE0_MAJOR
10176 #define PTY_SLAVE_MAJOR 3
10177 #define TTY_MAJOR 4
10178 +#define VROOT_MAJOR 4
10179 #define TTYAUX_MAJOR 5
10181 #define VCS_MAJOR 7
10182 diff -NurpP --minimal linux-3.1/include/linux/memcontrol.h linux-3.1-vs2.3.1-rc2/include/linux/memcontrol.h
10183 --- linux-3.1/include/linux/memcontrol.h 2011-10-24 18:45:32.000000000 +0200
10184 +++ linux-3.1-vs2.3.1-rc2/include/linux/memcontrol.h 2011-10-24 18:53:33.000000000 +0200
10185 @@ -84,6 +84,13 @@ extern struct mem_cgroup *try_get_mem_cg
10186 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
10187 extern struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm);
10189 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
10190 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
10192 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
10193 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
10194 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
10197 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
10199 diff -NurpP --minimal linux-3.1/include/linux/mm_types.h linux-3.1-vs2.3.1-rc2/include/linux/mm_types.h
10200 --- linux-3.1/include/linux/mm_types.h 2011-10-24 18:45:32.000000000 +0200
10201 +++ linux-3.1-vs2.3.1-rc2/include/linux/mm_types.h 2011-10-24 18:53:33.000000000 +0200
10202 @@ -301,6 +301,7 @@ struct mm_struct {
10204 /* Architecture-specific MM context */
10205 mm_context_t context;
10206 + struct vx_info *mm_vx_info;
10208 /* Swap token stuff */
10210 diff -NurpP --minimal linux-3.1/include/linux/mmzone.h linux-3.1-vs2.3.1-rc2/include/linux/mmzone.h
10211 --- linux-3.1/include/linux/mmzone.h 2011-10-24 18:45:32.000000000 +0200
10212 +++ linux-3.1-vs2.3.1-rc2/include/linux/mmzone.h 2011-10-24 18:53:33.000000000 +0200
10213 @@ -660,6 +660,13 @@ typedef struct pglist_data {
10214 __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
10217 +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
10219 +#define node_end_pfn(nid) ({\
10220 + pg_data_t *__pgdat = NODE_DATA(nid);\
10221 + __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
10224 #include <linux/memory_hotplug.h>
10226 extern struct mutex zonelists_mutex;
10227 diff -NurpP --minimal linux-3.1/include/linux/mount.h linux-3.1-vs2.3.1-rc2/include/linux/mount.h
10228 --- linux-3.1/include/linux/mount.h 2011-10-24 18:45:32.000000000 +0200
10229 +++ linux-3.1-vs2.3.1-rc2/include/linux/mount.h 2011-10-24 18:53:33.000000000 +0200
10230 @@ -52,6 +52,9 @@ struct mnt_pcp {
10234 +#define MNT_TAGID 0x10000
10235 +#define MNT_NOTAG 0x20000
10238 struct list_head mnt_hash;
10239 struct vfsmount *mnt_parent; /* fs we are mounted on */
10240 @@ -86,6 +89,7 @@ struct vfsmount {
10241 int mnt_expiry_mark; /* true if marked for expiry */
10244 + tag_t mnt_tag; /* tagging used for vfsmount */
10247 struct file; /* forward dec */
10248 diff -NurpP --minimal linux-3.1/include/linux/net.h linux-3.1-vs2.3.1-rc2/include/linux/net.h
10249 --- linux-3.1/include/linux/net.h 2011-07-22 11:18:11.000000000 +0200
10250 +++ linux-3.1-vs2.3.1-rc2/include/linux/net.h 2011-10-24 18:53:33.000000000 +0200
10251 @@ -72,6 +72,7 @@ struct net;
10252 #define SOCK_NOSPACE 2
10253 #define SOCK_PASSCRED 3
10254 #define SOCK_PASSSEC 4
10255 +#define SOCK_USER_SOCKET 5
10257 #ifndef ARCH_HAS_SOCKET_TYPES
10259 diff -NurpP --minimal linux-3.1/include/linux/netdevice.h linux-3.1-vs2.3.1-rc2/include/linux/netdevice.h
10260 --- linux-3.1/include/linux/netdevice.h 2011-10-24 18:45:32.000000000 +0200
10261 +++ linux-3.1-vs2.3.1-rc2/include/linux/netdevice.h 2011-10-24 18:53:33.000000000 +0200
10262 @@ -1641,6 +1641,7 @@ extern void netdev_resync_ops(struct ne
10264 extern struct net_device *dev_get_by_index(struct net *net, int ifindex);
10265 extern struct net_device *__dev_get_by_index(struct net *net, int ifindex);
10266 +extern struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex);
10267 extern struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex);
10268 extern int dev_restart(struct net_device *dev);
10269 #ifdef CONFIG_NETPOLL_TRAP
10270 diff -NurpP --minimal linux-3.1/include/linux/nfs_mount.h linux-3.1-vs2.3.1-rc2/include/linux/nfs_mount.h
10271 --- linux-3.1/include/linux/nfs_mount.h 2011-01-05 21:50:31.000000000 +0100
10272 +++ linux-3.1-vs2.3.1-rc2/include/linux/nfs_mount.h 2011-10-24 18:53:33.000000000 +0200
10273 @@ -63,7 +63,8 @@ struct nfs_mount_data {
10274 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
10275 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
10276 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
10277 -#define NFS_MOUNT_FLAGMASK 0xFFFF
10278 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
10279 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
10281 /* The following are for internal use only */
10282 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
10283 diff -NurpP --minimal linux-3.1/include/linux/nsproxy.h linux-3.1-vs2.3.1-rc2/include/linux/nsproxy.h
10284 --- linux-3.1/include/linux/nsproxy.h 2011-10-24 18:45:32.000000000 +0200
10285 +++ linux-3.1-vs2.3.1-rc2/include/linux/nsproxy.h 2011-10-24 18:53:33.000000000 +0200
10288 #include <linux/spinlock.h>
10289 #include <linux/sched.h>
10290 +#include <linux/vserver/debug.h>
10292 struct mnt_namespace;
10293 struct uts_namespace;
10294 @@ -63,6 +64,7 @@ static inline struct nsproxy *task_nspro
10297 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
10298 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
10299 void exit_task_namespaces(struct task_struct *tsk);
10300 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
10301 void free_nsproxy(struct nsproxy *ns);
10302 @@ -70,16 +72,26 @@ int unshare_nsproxy_namespaces(unsigned
10303 struct fs_struct *);
10304 int __init nsproxy_cache_init(void);
10306 -static inline void put_nsproxy(struct nsproxy *ns)
10307 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
10309 +static inline void __get_nsproxy(struct nsproxy *ns,
10310 + const char *_file, int _line)
10312 - if (atomic_dec_and_test(&ns->count)) {
10313 - free_nsproxy(ns);
10315 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
10316 + ns, atomic_read(&ns->count), _file, _line);
10317 + atomic_inc(&ns->count);
10320 -static inline void get_nsproxy(struct nsproxy *ns)
10321 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
10323 +static inline void __put_nsproxy(struct nsproxy *ns,
10324 + const char *_file, int _line)
10326 - atomic_inc(&ns->count);
10327 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
10328 + ns, atomic_read(&ns->count), _file, _line);
10329 + if (atomic_dec_and_test(&ns->count)) {
10330 + free_nsproxy(ns);
10335 diff -NurpP --minimal linux-3.1/include/linux/pid.h linux-3.1-vs2.3.1-rc2/include/linux/pid.h
10336 --- linux-3.1/include/linux/pid.h 2011-07-22 11:18:11.000000000 +0200
10337 +++ linux-3.1-vs2.3.1-rc2/include/linux/pid.h 2011-10-24 18:53:33.000000000 +0200
10338 @@ -8,7 +8,8 @@ enum pid_type
10348 @@ -171,6 +172,7 @@ static inline pid_t pid_nr(struct pid *p
10351 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
10352 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
10353 pid_t pid_vnr(struct pid *pid);
10355 #define do_each_pid_task(pid, type, task) \
10356 diff -NurpP --minimal linux-3.1/include/linux/proc_fs.h linux-3.1-vs2.3.1-rc2/include/linux/proc_fs.h
10357 --- linux-3.1/include/linux/proc_fs.h 2011-10-24 18:45:32.000000000 +0200
10358 +++ linux-3.1-vs2.3.1-rc2/include/linux/proc_fs.h 2011-10-24 18:53:33.000000000 +0200
10359 @@ -54,6 +54,7 @@ struct proc_dir_entry {
10365 const struct inode_operations *proc_iops;
10367 @@ -252,12 +253,18 @@ extern const struct proc_ns_operations n
10368 extern const struct proc_ns_operations utsns_operations;
10369 extern const struct proc_ns_operations ipcns_operations;
10375 int (*proc_get_link)(struct inode *, struct path *);
10376 int (*proc_read)(struct task_struct *task, char *page);
10377 int (*proc_show)(struct seq_file *m,
10378 struct pid_namespace *ns, struct pid *pid,
10379 struct task_struct *task);
10380 + int (*proc_vs_read)(char *page);
10381 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
10382 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
10385 struct ctl_table_header;
10386 @@ -265,6 +272,7 @@ struct ctl_table;
10388 struct proc_inode {
10393 struct proc_dir_entry *pde;
10394 diff -NurpP --minimal linux-3.1/include/linux/quotaops.h linux-3.1-vs2.3.1-rc2/include/linux/quotaops.h
10395 --- linux-3.1/include/linux/quotaops.h 2011-05-22 16:17:57.000000000 +0200
10396 +++ linux-3.1-vs2.3.1-rc2/include/linux/quotaops.h 2011-10-24 18:53:33.000000000 +0200
10398 #define _LINUX_QUOTAOPS_
10400 #include <linux/fs.h>
10401 +#include <linux/vs_dlimit.h>
10403 #define DQUOT_SPACE_WARN 0x1
10404 #define DQUOT_SPACE_RESERVE 0x2
10405 @@ -204,11 +205,12 @@ static inline void dquot_drop(struct ino
10407 static inline int dquot_alloc_inode(const struct inode *inode)
10410 + return dl_alloc_inode(inode);
10413 static inline void dquot_free_inode(const struct inode *inode)
10415 + dl_free_inode(inode);
10418 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
10419 @@ -219,6 +221,10 @@ static inline int dquot_transfer(struct
10420 static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
10425 + if ((ret = dl_alloc_space(inode, number)))
10427 if (!(flags & DQUOT_SPACE_RESERVE))
10428 inode_add_bytes(inode, number);
10430 @@ -229,6 +235,7 @@ static inline void __dquot_free_space(st
10432 if (!(flags & DQUOT_SPACE_RESERVE))
10433 inode_sub_bytes(inode, number);
10434 + dl_free_space(inode, number);
10437 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
10438 diff -NurpP --minimal linux-3.1/include/linux/reboot.h linux-3.1-vs2.3.1-rc2/include/linux/reboot.h
10439 --- linux-3.1/include/linux/reboot.h 2011-10-24 18:45:32.000000000 +0200
10440 +++ linux-3.1-vs2.3.1-rc2/include/linux/reboot.h 2011-10-24 18:53:33.000000000 +0200
10442 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
10443 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
10444 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
10445 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
10449 diff -NurpP --minimal linux-3.1/include/linux/reiserfs_fs.h linux-3.1-vs2.3.1-rc2/include/linux/reiserfs_fs.h
10450 --- linux-3.1/include/linux/reiserfs_fs.h 2011-10-24 18:45:32.000000000 +0200
10451 +++ linux-3.1-vs2.3.1-rc2/include/linux/reiserfs_fs.h 2011-10-24 18:53:33.000000000 +0200
10452 @@ -976,6 +976,11 @@ struct stat_data_v1 {
10453 #define REISERFS_COMPR_FL FS_COMPR_FL
10454 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
10456 +/* unfortunately reiserfs sdattr is only 16 bit */
10457 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
10458 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
10459 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
10461 /* persistent flags that file inherits from the parent directory */
10462 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
10463 REISERFS_SYNC_FL | \
10464 @@ -985,6 +990,9 @@ struct stat_data_v1 {
10465 REISERFS_COMPR_FL | \
10466 REISERFS_NOTAIL_FL )
10468 +#define REISERFS_FL_USER_VISIBLE 0x80FF
10469 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
10471 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
10474 @@ -2073,6 +2081,7 @@ static inline void reiserfs_update_sd(st
10475 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
10476 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
10477 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
10478 +int reiserfs_sync_flags(struct inode *inode, int, int);
10480 int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len);
10482 diff -NurpP --minimal linux-3.1/include/linux/reiserfs_fs_sb.h linux-3.1-vs2.3.1-rc2/include/linux/reiserfs_fs_sb.h
10483 --- linux-3.1/include/linux/reiserfs_fs_sb.h 2010-02-25 11:52:07.000000000 +0100
10484 +++ linux-3.1-vs2.3.1-rc2/include/linux/reiserfs_fs_sb.h 2011-10-24 18:53:33.000000000 +0200
10485 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
10486 REISERFS_EXPOSE_PRIVROOT,
10487 REISERFS_BARRIER_NONE,
10488 REISERFS_BARRIER_FLUSH,
10491 /* Actions on error */
10492 REISERFS_ERROR_PANIC,
10493 diff -NurpP --minimal linux-3.1/include/linux/sched.h linux-3.1-vs2.3.1-rc2/include/linux/sched.h
10494 --- linux-3.1/include/linux/sched.h 2011-10-24 18:45:32.000000000 +0200
10495 +++ linux-3.1-vs2.3.1-rc2/include/linux/sched.h 2011-10-24 18:53:33.000000000 +0200
10496 @@ -1406,6 +1406,14 @@ struct task_struct {
10500 +/* vserver context data */
10501 + struct vx_info *vx_info;
10502 + struct nx_info *nx_info;
10508 /* Thread group tracking */
10509 u32 parent_exec_id;
10511 @@ -1648,6 +1656,11 @@ struct pid_namespace;
10512 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
10513 struct pid_namespace *ns);
10515 +#include <linux/vserver/base.h>
10516 +#include <linux/vserver/context.h>
10517 +#include <linux/vserver/debug.h>
10518 +#include <linux/vserver/pid.h>
10520 static inline pid_t task_pid_nr(struct task_struct *tsk)
10523 @@ -1661,7 +1674,8 @@ static inline pid_t task_pid_nr_ns(struc
10525 static inline pid_t task_pid_vnr(struct task_struct *tsk)
10527 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
10528 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
10529 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
10533 @@ -1674,7 +1688,7 @@ pid_t task_tgid_nr_ns(struct task_struct
10535 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
10537 - return pid_vnr(task_tgid(tsk));
10538 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
10542 diff -NurpP --minimal linux-3.1/include/linux/shmem_fs.h linux-3.1-vs2.3.1-rc2/include/linux/shmem_fs.h
10543 --- linux-3.1/include/linux/shmem_fs.h 2011-10-24 18:45:32.000000000 +0200
10544 +++ linux-3.1-vs2.3.1-rc2/include/linux/shmem_fs.h 2011-10-24 18:53:33.000000000 +0200
10547 /* inode in-kernel data */
10549 +#define TMPFS_SUPER_MAGIC 0x01021994
10552 struct shmem_inode_info {
10554 unsigned long flags;
10555 diff -NurpP --minimal linux-3.1/include/linux/stat.h linux-3.1-vs2.3.1-rc2/include/linux/stat.h
10556 --- linux-3.1/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
10557 +++ linux-3.1-vs2.3.1-rc2/include/linux/stat.h 2011-10-24 18:53:33.000000000 +0200
10558 @@ -66,6 +66,7 @@ struct kstat {
10559 unsigned int nlink;
10565 struct timespec atime;
10566 diff -NurpP --minimal linux-3.1/include/linux/sunrpc/auth.h linux-3.1-vs2.3.1-rc2/include/linux/sunrpc/auth.h
10567 --- linux-3.1/include/linux/sunrpc/auth.h 2011-10-24 18:45:32.000000000 +0200
10568 +++ linux-3.1-vs2.3.1-rc2/include/linux/sunrpc/auth.h 2011-10-24 18:53:33.000000000 +0200
10574 struct group_info *group_info;
10575 unsigned char machine_cred : 1;
10577 diff -NurpP --minimal linux-3.1/include/linux/sunrpc/clnt.h linux-3.1-vs2.3.1-rc2/include/linux/sunrpc/clnt.h
10578 --- linux-3.1/include/linux/sunrpc/clnt.h 2011-05-22 16:17:58.000000000 +0200
10579 +++ linux-3.1-vs2.3.1-rc2/include/linux/sunrpc/clnt.h 2011-10-24 18:53:33.000000000 +0200
10580 @@ -49,7 +49,8 @@ struct rpc_clnt {
10581 unsigned int cl_softrtry : 1,/* soft timeouts */
10582 cl_discrtry : 1,/* disconnect before retry */
10583 cl_autobind : 1,/* use getport() */
10584 - cl_chatty : 1;/* be verbose */
10585 + cl_chatty : 1,/* be verbose */
10586 + cl_tag : 1;/* context tagging */
10588 struct rpc_rtt * cl_rtt; /* RTO estimator data */
10589 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
10590 diff -NurpP --minimal linux-3.1/include/linux/syscalls.h linux-3.1-vs2.3.1-rc2/include/linux/syscalls.h
10591 --- linux-3.1/include/linux/syscalls.h 2011-10-24 18:45:32.000000000 +0200
10592 +++ linux-3.1-vs2.3.1-rc2/include/linux/syscalls.h 2011-10-24 18:53:33.000000000 +0200
10593 @@ -483,6 +483,8 @@ asmlinkage long sys_symlink(const char _
10594 asmlinkage long sys_unlink(const char __user *pathname);
10595 asmlinkage long sys_rename(const char __user *oldname,
10596 const char __user *newname);
10597 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
10599 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
10600 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
10602 diff -NurpP --minimal linux-3.1/include/linux/sysctl.h linux-3.1-vs2.3.1-rc2/include/linux/sysctl.h
10603 --- linux-3.1/include/linux/sysctl.h 2011-03-15 18:07:40.000000000 +0100
10604 +++ linux-3.1-vs2.3.1-rc2/include/linux/sysctl.h 2011-10-24 18:53:33.000000000 +0200
10605 @@ -60,6 +60,7 @@ enum
10606 CTL_ABI=9, /* Binary emulation */
10607 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
10608 CTL_ARLAN=254, /* arlan wireless driver */
10609 + CTL_VSERVER=4242, /* Linux-VServer debug */
10610 CTL_S390DBF=5677, /* s390 debug */
10611 CTL_SUNRPC=7249, /* sunrpc debug */
10612 CTL_PM=9899, /* frv power management */
10613 @@ -94,6 +95,7 @@ enum
10615 KERN_PANIC=15, /* int: panic timeout */
10616 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
10617 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
10619 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
10620 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
10621 diff -NurpP --minimal linux-3.1/include/linux/sysfs.h linux-3.1-vs2.3.1-rc2/include/linux/sysfs.h
10622 --- linux-3.1/include/linux/sysfs.h 2011-10-24 18:45:32.000000000 +0200
10623 +++ linux-3.1-vs2.3.1-rc2/include/linux/sysfs.h 2011-10-24 18:53:33.000000000 +0200
10625 #include <linux/kobject_ns.h>
10626 #include <linux/atomic.h>
10628 +#define SYSFS_SUPER_MAGIC 0x62656572
10633 diff -NurpP --minimal linux-3.1/include/linux/time.h linux-3.1-vs2.3.1-rc2/include/linux/time.h
10634 --- linux-3.1/include/linux/time.h 2011-07-22 11:18:11.000000000 +0200
10635 +++ linux-3.1-vs2.3.1-rc2/include/linux/time.h 2011-10-24 18:53:33.000000000 +0200
10636 @@ -256,6 +256,9 @@ static __always_inline void timespec_add
10637 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
10641 +#include <linux/vs_time.h>
10643 #endif /* __KERNEL__ */
10645 #define NFDBITS __NFDBITS
10646 diff -NurpP --minimal linux-3.1/include/linux/types.h linux-3.1-vs2.3.1-rc2/include/linux/types.h
10647 --- linux-3.1/include/linux/types.h 2011-05-22 16:17:58.000000000 +0200
10648 +++ linux-3.1-vs2.3.1-rc2/include/linux/types.h 2011-10-24 18:53:33.000000000 +0200
10649 @@ -40,6 +40,9 @@ typedef __kernel_uid32_t uid_t;
10650 typedef __kernel_gid32_t gid_t;
10651 typedef __kernel_uid16_t uid16_t;
10652 typedef __kernel_gid16_t gid16_t;
10653 +typedef unsigned int xid_t;
10654 +typedef unsigned int nid_t;
10655 +typedef unsigned int tag_t;
10657 typedef unsigned long uintptr_t;
10659 diff -NurpP --minimal linux-3.1/include/linux/utsname.h linux-3.1-vs2.3.1-rc2/include/linux/utsname.h
10660 --- linux-3.1/include/linux/utsname.h 2011-05-22 16:17:58.000000000 +0200
10661 +++ linux-3.1-vs2.3.1-rc2/include/linux/utsname.h 2011-10-24 18:53:33.000000000 +0200
10662 @@ -54,7 +54,8 @@ static inline void get_uts_ns(struct uts
10665 extern struct uts_namespace *copy_utsname(unsigned long flags,
10666 - struct task_struct *tsk);
10667 + struct uts_namespace *old_ns,
10668 + struct user_namespace *user_ns);
10669 extern void free_uts_ns(struct kref *kref);
10671 static inline void put_uts_ns(struct uts_namespace *ns)
10672 @@ -71,12 +72,13 @@ static inline void put_uts_ns(struct uts
10675 static inline struct uts_namespace *copy_utsname(unsigned long flags,
10676 - struct task_struct *tsk)
10677 + struct uts_namespace *old_ns,
10678 + struct user_namespace *user_ns)
10680 if (flags & CLONE_NEWUTS)
10681 return ERR_PTR(-EINVAL);
10683 - return tsk->nsproxy->uts_ns;
10688 diff -NurpP --minimal linux-3.1/include/linux/vroot.h linux-3.1-vs2.3.1-rc2/include/linux/vroot.h
10689 --- linux-3.1/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
10690 +++ linux-3.1-vs2.3.1-rc2/include/linux/vroot.h 2011-10-24 18:53:33.000000000 +0200
10694 + * include/linux/vroot.h
10696 + * written by Herbert Pötzl, 9/11/2002
10697 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
10699 + * Copyright (C) 2002-2007 by Herbert Pötzl.
10700 + * Redistribution of this file is permitted under the
10701 + * GNU General Public License.
10704 +#ifndef _LINUX_VROOT_H
10705 +#define _LINUX_VROOT_H
10710 +/* Possible states of device */
10716 +struct vroot_device {
10720 + struct semaphore vr_ctl_mutex;
10721 + struct block_device *vr_device;
10726 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
10728 +extern int register_vroot_grb(vroot_grb_func *);
10729 +extern int unregister_vroot_grb(vroot_grb_func *);
10731 +#endif /* __KERNEL__ */
10733 +#define MAX_VROOT_DEFAULT 8
10736 + * IOCTL commands --- we will commandeer 0x56 ('V')
10739 +#define VROOT_SET_DEV 0x5600
10740 +#define VROOT_CLR_DEV 0x5601
10742 +#endif /* _LINUX_VROOT_H */
10743 diff -NurpP --minimal linux-3.1/include/linux/vs_base.h linux-3.1-vs2.3.1-rc2/include/linux/vs_base.h
10744 --- linux-3.1/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
10745 +++ linux-3.1-vs2.3.1-rc2/include/linux/vs_base.h 2011-10-24 18:53:33.000000000 +0200
10747 +#ifndef _VS_BASE_H
10748 +#define _VS_BASE_H
10750 +#include "vserver/base.h"
10751 +#include "vserver/check.h"
10752 +#include "vserver/debug.h"
10755 +#warning duplicate inclusion
10757 diff -NurpP --minimal linux-3.1/include/linux/vs_context.h linux-3.1-vs2.3.1-rc2/include/linux/vs_context.h
10758 --- linux-3.1/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
10759 +++ linux-3.1-vs2.3.1-rc2/include/linux/vs_context.h 2011-10-24 18:53:33.000000000 +0200
10761 +#ifndef _VS_CONTEXT_H
10762 +#define _VS_CONTEXT_H
10764 +#include "vserver/base.h"
10765 +#include "vserver/check.h"
10766 +#include "vserver/context.h"
10767 +#include "vserver/history.h"
10768 +#include "vserver/debug.h"
10770 +#include <linux/sched.h>
10773 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
10775 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
10776 + const char *_file, int _line, void *_here)
10781 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
10782 + vxi, vxi ? vxi->vx_id : 0,
10783 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10785 + __vxh_get_vx_info(vxi, _here);
10787 + atomic_inc(&vxi->vx_usecnt);
10792 +extern void free_vx_info(struct vx_info *);
10794 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
10796 +static inline void __put_vx_info(struct vx_info *vxi,
10797 + const char *_file, int _line, void *_here)
10802 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
10803 + vxi, vxi ? vxi->vx_id : 0,
10804 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10806 + __vxh_put_vx_info(vxi, _here);
10808 + if (atomic_dec_and_test(&vxi->vx_usecnt))
10809 + free_vx_info(vxi);
10813 +#define init_vx_info(p, i) \
10814 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
10816 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
10817 + const char *_file, int _line, void *_here)
10820 + vxlprintk(VXD_CBIT(xid, 3),
10821 + "init_vx_info(%p[#%d.%d])",
10822 + vxi, vxi ? vxi->vx_id : 0,
10823 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10825 + __vxh_init_vx_info(vxi, vxp, _here);
10827 + atomic_inc(&vxi->vx_usecnt);
10833 +#define set_vx_info(p, i) \
10834 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
10836 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
10837 + const char *_file, int _line, void *_here)
10839 + struct vx_info *vxo;
10844 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
10845 + vxi, vxi ? vxi->vx_id : 0,
10846 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10848 + __vxh_set_vx_info(vxi, vxp, _here);
10850 + atomic_inc(&vxi->vx_usecnt);
10851 + vxo = xchg(vxp, vxi);
10856 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
10858 +static inline void __clr_vx_info(struct vx_info **vxp,
10859 + const char *_file, int _line, void *_here)
10861 + struct vx_info *vxo;
10863 + vxo = xchg(vxp, NULL);
10867 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
10868 + vxo, vxo ? vxo->vx_id : 0,
10869 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
10871 + __vxh_clr_vx_info(vxo, vxp, _here);
10873 + if (atomic_dec_and_test(&vxo->vx_usecnt))
10874 + free_vx_info(vxo);
10878 +#define claim_vx_info(v, p) \
10879 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
10881 +static inline void __claim_vx_info(struct vx_info *vxi,
10882 + struct task_struct *task,
10883 + const char *_file, int _line, void *_here)
10885 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
10886 + vxi, vxi ? vxi->vx_id : 0,
10887 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10888 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
10889 + task, _file, _line);
10890 + __vxh_claim_vx_info(vxi, task, _here);
10892 + atomic_inc(&vxi->vx_tasks);
10896 +extern void unhash_vx_info(struct vx_info *);
10898 +#define release_vx_info(v, p) \
10899 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
10901 +static inline void __release_vx_info(struct vx_info *vxi,
10902 + struct task_struct *task,
10903 + const char *_file, int _line, void *_here)
10905 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
10906 + vxi, vxi ? vxi->vx_id : 0,
10907 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
10908 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
10909 + task, _file, _line);
10910 + __vxh_release_vx_info(vxi, task, _here);
10914 + if (atomic_dec_and_test(&vxi->vx_tasks))
10915 + unhash_vx_info(vxi);
10919 +#define task_get_vx_info(p) \
10920 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
10922 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
10923 + const char *_file, int _line, void *_here)
10925 + struct vx_info *vxi;
10928 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
10929 + p, _file, _line);
10930 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
10936 +static inline void __wakeup_vx_info(struct vx_info *vxi)
10938 + if (waitqueue_active(&vxi->vx_wait))
10939 + wake_up_interruptible(&vxi->vx_wait);
10943 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
10945 +static inline void __enter_vx_info(struct vx_info *vxi,
10946 + struct vx_info_save *vxis, const char *_file, int _line)
10948 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
10949 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
10950 + current->xid, current->vx_info, _file, _line);
10951 + vxis->vxi = xchg(¤t->vx_info, vxi);
10952 + vxis->xid = current->xid;
10953 + current->xid = vxi ? vxi->vx_id : 0;
10956 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
10958 +static inline void __leave_vx_info(struct vx_info_save *vxis,
10959 + const char *_file, int _line)
10961 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
10962 + vxis, vxis->xid, vxis->vxi, current,
10963 + current->xid, current->vx_info, _file, _line);
10964 + (void)xchg(¤t->vx_info, vxis->vxi);
10965 + current->xid = vxis->xid;
10969 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
10971 + vxis->vxi = xchg(¤t->vx_info, NULL);
10972 + vxis->xid = xchg(¤t->xid, (xid_t)0);
10975 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
10977 + (void)xchg(¤t->xid, vxis->xid);
10978 + (void)xchg(¤t->vx_info, vxis->vxi);
10981 +#define task_is_init(p) \
10982 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
10984 +static inline int __task_is_init(struct task_struct *p,
10985 + const char *_file, int _line, void *_here)
10987 + int is_init = is_global_init(p);
10991 + is_init = p->vx_info->vx_initpid == p->pid;
10996 +extern void exit_vx_info(struct task_struct *, int);
10997 +extern void exit_vx_info_early(struct task_struct *, int);
11001 +#warning duplicate inclusion
11003 diff -NurpP --minimal linux-3.1/include/linux/vs_cowbl.h linux-3.1-vs2.3.1-rc2/include/linux/vs_cowbl.h
11004 --- linux-3.1/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
11005 +++ linux-3.1-vs2.3.1-rc2/include/linux/vs_cowbl.h 2011-10-24 18:53:33.000000000 +0200
11007 +#ifndef _VS_COWBL_H
11008 +#define _VS_COWBL_H
11010 +#include <linux/fs.h>
11011 +#include <linux/dcache.h>
11012 +#include <linux/namei.h>
11013 +#include <linux/slab.h>
11015 +extern struct dentry *cow_break_link(const char *pathname);
11017 +static inline int cow_check_and_break(struct path *path)
11019 + struct inode *inode = path->dentry->d_inode;
11022 + /* do we need this check? */
11023 + if (IS_RDONLY(inode))
11026 + if (IS_COW(inode)) {
11027 + if (IS_COW_LINK(inode)) {
11028 + struct dentry *new_dentry, *old_dentry = path->dentry;
11031 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
11035 + pp = d_path(path, buf, PATH_MAX);
11036 + new_dentry = cow_break_link(pp);
11038 + if (!IS_ERR(new_dentry)) {
11039 + path->dentry = new_dentry;
11040 + dput(old_dentry);
11042 + error = PTR_ERR(new_dentry);
11044 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
11045 + inode->i_ctime = CURRENT_TIME;
11046 + mark_inode_dirty(inode);
11053 +#warning duplicate inclusion
11055 diff -NurpP --minimal linux-3.1/include/linux/vs_cvirt.h linux-3.1-vs2.3.1-rc2/include/linux/vs_cvirt.h
11056 --- linux-3.1/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
11057 +++ linux-3.1-vs2.3.1-rc2/include/linux/vs_cvirt.h 2011-10-24 18:53:33.000000000 +0200
11059 +#ifndef _VS_CVIRT_H
11060 +#define _VS_CVIRT_H
11062 +#include "vserver/cvirt.h"
11063 +#include "vserver/context.h"
11064 +#include "vserver/base.h"
11065 +#include "vserver/check.h"
11066 +#include "vserver/debug.h"
11069 +static inline void vx_activate_task(struct task_struct *p)
11071 + struct vx_info *vxi;
11073 + if ((vxi = p->vx_info)) {
11074 + vx_update_load(vxi);
11075 + atomic_inc(&vxi->cvirt.nr_running);
11079 +static inline void vx_deactivate_task(struct task_struct *p)
11081 + struct vx_info *vxi;
11083 + if ((vxi = p->vx_info)) {
11084 + vx_update_load(vxi);
11085 + atomic_dec(&vxi->cvirt.nr_running);
11089 +static inline void vx_uninterruptible_inc(struct task_struct *p)
11091 + struct vx_info *vxi;
11093 + if ((vxi = p->vx_info))
11094 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
11097 +static inline void vx_uninterruptible_dec(struct task_struct *p)
11099 + struct vx_info *vxi;
11101 + if ((vxi = p->vx_info))
11102 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
11107 +#warning duplicate inclusion
11109 diff -NurpP --minimal linux-3.1/include/linux/vs_device.h linux-3.1-vs2.3.1-rc2/include/linux/vs_device.h
11110 --- linux-3.1/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
11111 +++ linux-3.1-vs2.3.1-rc2/include/linux/vs_device.h 2011-10-24 18:53:33.000000000 +0200
11113 +#ifndef _VS_DEVICE_H
11114 +#define _VS_DEVICE_H
11116 +#include "vserver/base.h"
11117 +#include "vserver/device.h"
11118 +#include "vserver/debug.h"
11121 +#ifdef CONFIG_VSERVER_DEVICE
11123 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
11125 +#define vs_device_perm(v, d, m, p) \
11126 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
11131 +int vs_map_device(struct vx_info *vxi,
11132 + dev_t device, dev_t *target, umode_t mode)
11135 + *target = device;
11139 +#define vs_device_perm(v, d, m, p) ((p) == (p))
11144 +#define vs_map_chrdev(d, t, p) \
11145 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
11146 +#define vs_map_blkdev(d, t, p) \
11147 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
11149 +#define vs_chrdev_perm(d, p) \
11150 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
11151 +#define vs_blkdev_perm(d, p) \
11152 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
11156 +#warning duplicate inclusion
11158 diff -NurpP --minimal linux-3.1/include/linux/vs_dlimit.h linux-3.1-vs2.3.1-rc2/include/linux/vs_dlimit.h
11159 --- linux-3.1/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
11160 +++ linux-3.1-vs2.3.1-rc2/include/linux/vs_dlimit.h 2011-10-24 18:53:33.000000000 +0200
11162 +#ifndef _VS_DLIMIT_H
11163 +#define _VS_DLIMIT_H
11165 +#include <linux/fs.h>
11167 +#include "vserver/dlimit.h"
11168 +#include "vserver/base.h"
11169 +#include "vserver/debug.h"
11172 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
11174 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
11175 + const char *_file, int _line)
11179 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
11180 + dli, dli ? dli->dl_tag : 0,
11181 + dli ? atomic_read(&dli->dl_usecnt) : 0,
11183 + atomic_inc(&dli->dl_usecnt);
11188 +#define free_dl_info(i) \
11189 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
11191 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
11193 +static inline void __put_dl_info(struct dl_info *dli,
11194 + const char *_file, int _line)
11198 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
11199 + dli, dli ? dli->dl_tag : 0,
11200 + dli ? atomic_read(&dli->dl_usecnt) : 0,
11202 + if (atomic_dec_and_test(&dli->dl_usecnt))
11203 + free_dl_info(dli);
11207 +#define __dlimit_char(d) ((d) ? '*' : ' ')
11209 +static inline int __dl_alloc_space(struct super_block *sb,
11210 + tag_t tag, dlsize_t nr, const char *file, int line)
11212 + struct dl_info *dli = NULL;
11217 + dli = locate_dl_info(sb, tag);
11221 + spin_lock(&dli->dl_lock);
11222 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
11224 + dli->dl_space_used += nr;
11225 + spin_unlock(&dli->dl_lock);
11226 + put_dl_info(dli);
11228 + vxlprintk(VXD_CBIT(dlim, 1),
11229 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
11230 + sb, tag, __dlimit_char(dli), (long long)nr,
11231 + ret, file, line);
11232 + return ret ? -ENOSPC : 0;
11235 +static inline void __dl_free_space(struct super_block *sb,
11236 + tag_t tag, dlsize_t nr, const char *_file, int _line)
11238 + struct dl_info *dli = NULL;
11242 + dli = locate_dl_info(sb, tag);
11246 + spin_lock(&dli->dl_lock);
11247 + if (dli->dl_space_used > nr)
11248 + dli->dl_space_used -= nr;
11250 + dli->dl_space_used = 0;
11251 + spin_unlock(&dli->dl_lock);
11252 + put_dl_info(dli);
11254 + vxlprintk(VXD_CBIT(dlim, 1),
11255 + "FREE (%p,#%d)%c %lld bytes",
11256 + sb, tag, __dlimit_char(dli), (long long)nr,
11260 +static inline int __dl_alloc_inode(struct super_block *sb,
11261 + tag_t tag, const char *_file, int _line)
11263 + struct dl_info *dli;
11266 + dli = locate_dl_info(sb, tag);
11270 + spin_lock(&dli->dl_lock);
11271 + dli->dl_inodes_used++;
11272 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
11273 + spin_unlock(&dli->dl_lock);
11274 + put_dl_info(dli);
11276 + vxlprintk(VXD_CBIT(dlim, 0),
11277 + "ALLOC (%p,#%d)%c inode (%d)",
11278 + sb, tag, __dlimit_char(dli), ret, _file, _line);
11279 + return ret ? -ENOSPC : 0;
11282 +static inline void __dl_free_inode(struct super_block *sb,
11283 + tag_t tag, const char *_file, int _line)
11285 + struct dl_info *dli;
11287 + dli = locate_dl_info(sb, tag);
11291 + spin_lock(&dli->dl_lock);
11292 + if (dli->dl_inodes_used > 1)
11293 + dli->dl_inodes_used--;
11295 + dli->dl_inodes_used = 0;
11296 + spin_unlock(&dli->dl_lock);
11297 + put_dl_info(dli);
11299 + vxlprintk(VXD_CBIT(dlim, 0),
11300 + "FREE (%p,#%d)%c inode",
11301 + sb, tag, __dlimit_char(dli), _file, _line);
11304 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
11305 + unsigned long long *free_blocks, unsigned long long *root_blocks,
11306 + const char *_file, int _line)
11308 + struct dl_info *dli;
11309 + uint64_t broot, bfree;
11311 + dli = locate_dl_info(sb, tag);
11315 + spin_lock(&dli->dl_lock);
11316 + broot = (dli->dl_space_total -
11317 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
11318 + >> sb->s_blocksize_bits;
11319 + bfree = (dli->dl_space_total - dli->dl_space_used)
11320 + >> sb->s_blocksize_bits;
11321 + spin_unlock(&dli->dl_lock);
11323 + vxlprintk(VXD_CBIT(dlim, 2),
11324 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
11325 + (long long)bfree, (long long)broot,
11326 + *free_blocks, *root_blocks, dli->dl_nrlmult,
11328 + if (free_blocks) {
11329 + if (*free_blocks > bfree)
11330 + *free_blocks = bfree;
11332 + if (root_blocks) {
11333 + if (*root_blocks > broot)
11334 + *root_blocks = broot;
11336 + put_dl_info(dli);
11339 +#define dl_prealloc_space(in, bytes) \
11340 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11341 + __FILE__, __LINE__ )
11343 +#define dl_alloc_space(in, bytes) \
11344 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11345 + __FILE__, __LINE__ )
11347 +#define dl_reserve_space(in, bytes) \
11348 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11349 + __FILE__, __LINE__ )
11351 +#define dl_claim_space(in, bytes) (0)
11353 +#define dl_release_space(in, bytes) \
11354 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11355 + __FILE__, __LINE__ )
11357 +#define dl_free_space(in, bytes) \
11358 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11359 + __FILE__, __LINE__ )
11363 +#define dl_alloc_inode(in) \
11364 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
11366 +#define dl_free_inode(in) \
11367 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
11370 +#define dl_adjust_block(sb, tag, fb, rb) \
11371 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
11375 +#warning duplicate inclusion
11377 diff -NurpP --minimal linux-3.1/include/linux/vs_inet.h linux-3.1-vs2.3.1-rc2/include/linux/vs_inet.h
11378 --- linux-3.1/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
11379 +++ linux-3.1-vs2.3.1-rc2/include/linux/vs_inet.h 2011-10-24 18:53:33.000000000 +0200
11381 +#ifndef _VS_INET_H
11382 +#define _VS_INET_H
11384 +#include "vserver/base.h"
11385 +#include "vserver/network.h"
11386 +#include "vserver/debug.h"
11388 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
11390 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
11391 + NIPQUAD((a)->mask), (a)->type
11392 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
11394 +#define NIPQUAD(addr) \
11395 + ((unsigned char *)&addr)[0], \
11396 + ((unsigned char *)&addr)[1], \
11397 + ((unsigned char *)&addr)[2], \
11398 + ((unsigned char *)&addr)[3]
11400 +#define NIPQUAD_FMT "%u.%u.%u.%u"
11404 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
11406 + __be32 ip = nxa->ip[0].s_addr;
11407 + __be32 mask = nxa->mask.s_addr;
11408 + __be32 bcast = ip | ~mask;
11411 + switch (nxa->type & tmask) {
11412 + case NXA_TYPE_MASK:
11413 + ret = (ip == (addr & mask));
11415 + case NXA_TYPE_ADDR:
11419 + /* fall through to broadcast */
11420 + case NXA_MOD_BCAST:
11421 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
11423 + case NXA_TYPE_RANGE:
11424 + ret = ((nxa->ip[0].s_addr <= addr) &&
11425 + (nxa->ip[1].s_addr > addr));
11427 + case NXA_TYPE_ANY:
11432 + vxdprintk(VXD_CBIT(net, 0),
11433 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
11434 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
11439 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
11441 + struct nx_addr_v4 *nxa;
11448 + /* allow 127.0.0.1 when remapping lback */
11449 + if ((tmask & NXA_LOOPBACK) &&
11450 + (addr == IPI_LOOPBACK) &&
11451 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
11454 + /* check for lback address */
11455 + if ((tmask & NXA_MOD_LBACK) &&
11456 + (nxi->v4_lback.s_addr == addr))
11459 + /* check for broadcast address */
11460 + if ((tmask & NXA_MOD_BCAST) &&
11461 + (nxi->v4_bcast.s_addr == addr))
11464 + /* check for v4 addresses */
11465 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
11466 + if (v4_addr_match(nxa, addr, tmask))
11470 + vxdprintk(VXD_CBIT(net, 0),
11471 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
11472 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
11477 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
11479 + /* FIXME: needs full range checks */
11480 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
11484 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
11486 + struct nx_addr_v4 *ptr;
11488 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
11489 + if (v4_nx_addr_match(ptr, nxa, mask))
11494 +#include <net/inet_sock.h>
11497 + * Check if a given address matches for a socket
11499 + * nxi: the socket's nx_info if any
11500 + * addr: to be verified address
11503 +int v4_sock_addr_match (
11504 + struct nx_info *nxi,
11505 + struct inet_sock *inet,
11508 + __be32 saddr = inet->inet_rcv_saddr;
11509 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
11511 + if (addr && (saddr == addr || bcast == addr))
11514 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
11519 +/* inet related checks and helpers */
11523 +struct net_device;
11526 +#ifdef CONFIG_INET
11528 +#include <linux/netdevice.h>
11529 +#include <linux/inetdevice.h>
11530 +#include <net/inet_sock.h>
11531 +#include <net/inet_timewait_sock.h>
11534 +int dev_in_nx_info(struct net_device *, struct nx_info *);
11535 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
11536 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
11540 + * check if address is covered by socket
11542 + * sk: the socket to check against
11543 + * addr: the address in question (must be != 0)
11547 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
11549 + struct nx_info *nxi = sk->sk_nx_info;
11550 + __be32 saddr = sk_rcv_saddr(sk);
11552 + vxdprintk(VXD_CBIT(net, 5),
11553 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
11554 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
11555 + (sk->sk_socket?sk->sk_socket->flags:0));
11557 + if (saddr) { /* direct address match */
11558 + return v4_addr_match(nxa, saddr, -1);
11559 + } else if (nxi) { /* match against nx_info */
11560 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
11561 + } else { /* unrestricted any socket */
11569 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
11571 + vxdprintk(VXD_CBIT(net, 1),
11572 + "nx_dev_visible(%p[#%u],%p " VS_Q("%s") ") %d",
11573 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
11574 + nxi ? dev_in_nx_info(dev, nxi) : 0);
11576 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
11578 + if (dev_in_nx_info(dev, nxi))
11585 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
11591 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
11595 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
11597 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
11598 + nxi, nxi ? nxi->nx_id : 0, ifa,
11599 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
11601 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
11603 + if (v4_ifa_in_nx_info(ifa, nxi))
11609 +struct nx_v4_sock_addr {
11610 + __be32 saddr; /* Address used for validation */
11611 + __be32 baddr; /* Address used for socket bind */
11615 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
11616 + struct nx_v4_sock_addr *nsa)
11618 + struct sock *sk = &inet->sk;
11619 + struct nx_info *nxi = sk->sk_nx_info;
11620 + __be32 saddr = addr->sin_addr.s_addr;
11621 + __be32 baddr = saddr;
11623 + vxdprintk(VXD_CBIT(net, 3),
11624 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
11625 + sk, sk->sk_nx_info, sk->sk_socket,
11626 + (sk->sk_socket ? sk->sk_socket->flags : 0),
11630 + if (saddr == INADDR_ANY) {
11631 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
11632 + baddr = nxi->v4.ip[0].s_addr;
11633 + } else if (saddr == IPI_LOOPBACK) {
11634 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
11635 + baddr = nxi->v4_lback.s_addr;
11636 + } else if (!ipv4_is_multicast(saddr) ||
11637 + !nx_info_ncaps(nxi, NXC_MULTICAST)) {
11638 + /* normal address bind */
11639 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
11640 + return -EADDRNOTAVAIL;
11644 + vxdprintk(VXD_CBIT(net, 3),
11645 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
11646 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
11648 + nsa->saddr = saddr;
11649 + nsa->baddr = baddr;
11654 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
11656 + inet->inet_saddr = nsa->baddr;
11657 + inet->inet_rcv_saddr = nsa->baddr;
11662 + * helper to simplify inet_lookup_listener
11664 + * nxi: the socket's nx_info if any
11665 + * addr: to be verified address
11666 + * saddr: socket address
11668 +static inline int v4_inet_addr_match (
11669 + struct nx_info *nxi,
11673 + if (addr && (saddr == addr))
11676 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
11680 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
11682 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
11683 + (addr == nxi->v4_lback.s_addr))
11684 + return IPI_LOOPBACK;
11689 +int nx_info_has_v4(struct nx_info *nxi)
11693 + if (NX_IPV4(nxi))
11695 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
11700 +#else /* CONFIG_INET */
11703 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
11709 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
11715 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
11721 +int nx_info_has_v4(struct nx_info *nxi)
11726 +#endif /* CONFIG_INET */
11728 +#define current_nx_info_has_v4() \
11729 + nx_info_has_v4(current_nx_info())
11732 +// #warning duplicate inclusion
11734 diff -NurpP --minimal linux-3.1/include/linux/vs_inet6.h linux-3.1-vs2.3.1-rc2/include/linux/vs_inet6.h
11735 --- linux-3.1/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
11736 +++ linux-3.1-vs2.3.1-rc2/include/linux/vs_inet6.h 2011-10-24 18:53:33.000000000 +0200
11738 +#ifndef _VS_INET6_H
11739 +#define _VS_INET6_H
11741 +#include "vserver/base.h"
11742 +#include "vserver/network.h"
11743 +#include "vserver/debug.h"
11745 +#include <net/ipv6.h>
11747 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
11748 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
11751 +#ifdef CONFIG_IPV6
11754 +int v6_addr_match(struct nx_addr_v6 *nxa,
11755 + const struct in6_addr *addr, uint16_t mask)
11759 + switch (nxa->type & mask) {
11760 + case NXA_TYPE_MASK:
11761 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
11763 + case NXA_TYPE_ADDR:
11764 + ret = ipv6_addr_equal(&nxa->ip, addr);
11766 + case NXA_TYPE_ANY:
11770 + vxdprintk(VXD_CBIT(net, 0),
11771 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
11772 + nxa, NXAV6(nxa), addr, mask, ret);
11777 +int v6_addr_in_nx_info(struct nx_info *nxi,
11778 + const struct in6_addr *addr, uint16_t mask)
11780 + struct nx_addr_v6 *nxa;
11785 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
11786 + if (v6_addr_match(nxa, addr, mask))
11790 + vxdprintk(VXD_CBIT(net, 0),
11791 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
11792 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
11797 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
11799 + /* FIXME: needs full range checks */
11800 + return v6_addr_match(nxa, &addr->ip, mask);
11804 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
11806 + struct nx_addr_v6 *ptr;
11808 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
11809 + if (v6_nx_addr_match(ptr, nxa, mask))
11816 + * Check if a given address matches for a socket
11818 + * nxi: the socket's nx_info if any
11819 + * addr: to be verified address
11822 +int v6_sock_addr_match (
11823 + struct nx_info *nxi,
11824 + struct inet_sock *inet,
11825 + struct in6_addr *addr)
11827 + struct sock *sk = &inet->sk;
11828 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
11830 + if (!ipv6_addr_any(addr) &&
11831 + ipv6_addr_equal(saddr, addr))
11833 + if (ipv6_addr_any(saddr))
11834 + return v6_addr_in_nx_info(nxi, addr, -1);
11839 + * check if address is covered by socket
11841 + * sk: the socket to check against
11842 + * addr: the address in question (must be != 0)
11846 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
11848 + struct nx_info *nxi = sk->sk_nx_info;
11849 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
11851 + vxdprintk(VXD_CBIT(net, 5),
11852 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
11853 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
11854 + (sk->sk_socket?sk->sk_socket->flags:0));
11856 + if (!ipv6_addr_any(saddr)) { /* direct address match */
11857 + return v6_addr_match(nxa, saddr, -1);
11858 + } else if (nxi) { /* match against nx_info */
11859 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
11860 + } else { /* unrestricted any socket */
11866 +/* inet related checks and helpers */
11870 +struct net_device;
11874 +#include <linux/netdevice.h>
11875 +#include <linux/inetdevice.h>
11876 +#include <net/inet_timewait_sock.h>
11879 +int dev_in_nx_info(struct net_device *, struct nx_info *);
11880 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
11881 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
11886 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
11892 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
11896 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
11898 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
11899 + nxi, nxi ? nxi->nx_id : 0, ifa,
11900 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
11902 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
11904 + if (v6_ifa_in_nx_info(ifa, nxi))
11910 +struct nx_v6_sock_addr {
11911 + struct in6_addr saddr; /* Address used for validation */
11912 + struct in6_addr baddr; /* Address used for socket bind */
11916 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
11917 + struct nx_v6_sock_addr *nsa)
11919 + // struct sock *sk = &inet->sk;
11920 + // struct nx_info *nxi = sk->sk_nx_info;
11921 + struct in6_addr saddr = addr->sin6_addr;
11922 + struct in6_addr baddr = saddr;
11924 + nsa->saddr = saddr;
11925 + nsa->baddr = baddr;
11930 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
11932 + // struct sock *sk = &inet->sk;
11933 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
11935 + // *saddr = nsa->baddr;
11936 + // inet->inet_saddr = nsa->baddr;
11940 +int nx_info_has_v6(struct nx_info *nxi)
11944 + if (NX_IPV6(nxi))
11949 +#else /* CONFIG_IPV6 */
11952 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
11959 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
11965 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
11971 +int nx_info_has_v6(struct nx_info *nxi)
11976 +#endif /* CONFIG_IPV6 */
11978 +#define current_nx_info_has_v6() \
11979 + nx_info_has_v6(current_nx_info())
11982 +#warning duplicate inclusion
11984 diff -NurpP --minimal linux-3.1/include/linux/vs_limit.h linux-3.1-vs2.3.1-rc2/include/linux/vs_limit.h
11985 --- linux-3.1/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
11986 +++ linux-3.1-vs2.3.1-rc2/include/linux/vs_limit.h 2011-10-24 18:53:33.000000000 +0200
11988 +#ifndef _VS_LIMIT_H
11989 +#define _VS_LIMIT_H
11991 +#include "vserver/limit.h"
11992 +#include "vserver/base.h"
11993 +#include "vserver/context.h"
11994 +#include "vserver/debug.h"
11995 +#include "vserver/context.h"
11996 +#include "vserver/limit_int.h"
11999 +#define vx_acc_cres(v, d, p, r) \
12000 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
12002 +#define vx_acc_cres_cond(x, d, p, r) \
12003 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
12004 + r, d, p, __FILE__, __LINE__)
12007 +#define vx_add_cres(v, a, p, r) \
12008 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
12009 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
12011 +#define vx_add_cres_cond(x, a, p, r) \
12012 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
12013 + r, a, p, __FILE__, __LINE__)
12014 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
12017 +/* process and file limits */
12019 +#define vx_nproc_inc(p) \
12020 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
12022 +#define vx_nproc_dec(p) \
12023 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
12025 +#define vx_files_inc(f) \
12026 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
12028 +#define vx_files_dec(f) \
12029 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
12031 +#define vx_locks_inc(l) \
12032 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
12034 +#define vx_locks_dec(l) \
12035 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
12037 +#define vx_openfd_inc(f) \
12038 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
12040 +#define vx_openfd_dec(f) \
12041 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
12044 +#define vx_cres_avail(v, n, r) \
12045 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
12048 +#define vx_nproc_avail(n) \
12049 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
12051 +#define vx_files_avail(n) \
12052 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
12054 +#define vx_locks_avail(n) \
12055 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
12057 +#define vx_openfd_avail(n) \
12058 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
12061 +/* dentry limits */
12063 +#define vx_dentry_inc(d) do { \
12064 + if ((d)->d_count == 1) \
12065 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
12068 +#define vx_dentry_dec(d) do { \
12069 + if ((d)->d_count == 0) \
12070 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
12073 +#define vx_dentry_avail(n) \
12074 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
12077 +/* socket limits */
12079 +#define vx_sock_inc(s) \
12080 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
12082 +#define vx_sock_dec(s) \
12083 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
12085 +#define vx_sock_avail(n) \
12086 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
12089 +/* ipc resource limits */
12091 +#define vx_ipcmsg_add(v, u, a) \
12092 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
12094 +#define vx_ipcmsg_sub(v, u, a) \
12095 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
12097 +#define vx_ipcmsg_avail(v, a) \
12098 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
12101 +#define vx_ipcshm_add(v, k, a) \
12102 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
12104 +#define vx_ipcshm_sub(v, k, a) \
12105 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
12107 +#define vx_ipcshm_avail(v, a) \
12108 + vx_cres_avail(v, a, VLIMIT_SHMEM)
12111 +#define vx_semary_inc(a) \
12112 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
12114 +#define vx_semary_dec(a) \
12115 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
12118 +#define vx_nsems_add(a,n) \
12119 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
12121 +#define vx_nsems_sub(a,n) \
12122 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
12126 +#warning duplicate inclusion
12128 diff -NurpP --minimal linux-3.1/include/linux/vs_memory.h linux-3.1-vs2.3.1-rc2/include/linux/vs_memory.h
12129 --- linux-3.1/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
12130 +++ linux-3.1-vs2.3.1-rc2/include/linux/vs_memory.h 2011-10-24 18:53:33.000000000 +0200
12132 +#ifndef _VS_MEMORY_H
12133 +#define _VS_MEMORY_H
12135 +#include "vserver/limit.h"
12136 +#include "vserver/base.h"
12137 +#include "vserver/context.h"
12138 +#include "vserver/debug.h"
12139 +#include "vserver/context.h"
12140 +#include "vserver/limit_int.h"
12143 + VXPT_UNKNOWN = 0,
12152 +#define vx_page_fault(mm, vma, type, ret)
12156 +void __vx_page_fault(struct mm_struct *mm,
12157 + struct vm_area_struct *vma, int type, int ret)
12159 + struct vx_info *vxi = mm->mm_vx_info;
12162 + static char *page_type[6] =
12163 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
12164 + static char *page_what[4] =
12165 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
12171 + what = (ret & 0x3);
12173 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
12174 + type, what, ret, page_type[type], page_what[what]);
12176 + if (ret & VM_FAULT_WRITE)
12178 + atomic_inc(&vxi->cacct.page[type][what]);
12181 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
12185 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
12188 +#warning duplicate inclusion
12190 diff -NurpP --minimal linux-3.1/include/linux/vs_network.h linux-3.1-vs2.3.1-rc2/include/linux/vs_network.h
12191 --- linux-3.1/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
12192 +++ linux-3.1-vs2.3.1-rc2/include/linux/vs_network.h 2011-10-24 18:53:33.000000000 +0200
12194 +#ifndef _NX_VS_NETWORK_H
12195 +#define _NX_VS_NETWORK_H
12197 +#include "vserver/context.h"
12198 +#include "vserver/network.h"
12199 +#include "vserver/base.h"
12200 +#include "vserver/check.h"
12201 +#include "vserver/debug.h"
12203 +#include <linux/sched.h>
12206 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
12208 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
12209 + const char *_file, int _line)
12214 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
12215 + nxi, nxi ? nxi->nx_id : 0,
12216 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
12219 + atomic_inc(&nxi->nx_usecnt);
12224 +extern void free_nx_info(struct nx_info *);
12226 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
12228 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
12233 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
12234 + nxi, nxi ? nxi->nx_id : 0,
12235 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
12238 + if (atomic_dec_and_test(&nxi->nx_usecnt))
12239 + free_nx_info(nxi);
12243 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
12245 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
12246 + const char *_file, int _line)
12249 + vxlprintk(VXD_CBIT(nid, 3),
12250 + "init_nx_info(%p[#%d.%d])",
12251 + nxi, nxi ? nxi->nx_id : 0,
12252 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
12255 + atomic_inc(&nxi->nx_usecnt);
12261 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
12263 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
12264 + const char *_file, int _line)
12266 + struct nx_info *nxo;
12271 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
12272 + nxi, nxi ? nxi->nx_id : 0,
12273 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
12276 + atomic_inc(&nxi->nx_usecnt);
12277 + nxo = xchg(nxp, nxi);
12281 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
12283 +static inline void __clr_nx_info(struct nx_info **nxp,
12284 + const char *_file, int _line)
12286 + struct nx_info *nxo;
12288 + nxo = xchg(nxp, NULL);
12292 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
12293 + nxo, nxo ? nxo->nx_id : 0,
12294 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
12297 + if (atomic_dec_and_test(&nxo->nx_usecnt))
12298 + free_nx_info(nxo);
12302 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
12304 +static inline void __claim_nx_info(struct nx_info *nxi,
12305 + struct task_struct *task, const char *_file, int _line)
12307 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
12308 + nxi, nxi ? nxi->nx_id : 0,
12309 + nxi?atomic_read(&nxi->nx_usecnt):0,
12310 + nxi?atomic_read(&nxi->nx_tasks):0,
12311 + task, _file, _line);
12313 + atomic_inc(&nxi->nx_tasks);
12317 +extern void unhash_nx_info(struct nx_info *);
12319 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
12321 +static inline void __release_nx_info(struct nx_info *nxi,
12322 + struct task_struct *task, const char *_file, int _line)
12324 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
12325 + nxi, nxi ? nxi->nx_id : 0,
12326 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
12327 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
12328 + task, _file, _line);
12332 + if (atomic_dec_and_test(&nxi->nx_tasks))
12333 + unhash_nx_info(nxi);
12337 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
12339 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
12340 + const char *_file, int _line)
12342 + struct nx_info *nxi;
12345 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
12346 + p, _file, _line);
12347 + nxi = __get_nx_info(p->nx_info, _file, _line);
12353 +static inline void exit_nx_info(struct task_struct *p)
12356 + release_nx_info(p->nx_info, p);
12361 +#warning duplicate inclusion
12363 diff -NurpP --minimal linux-3.1/include/linux/vs_pid.h linux-3.1-vs2.3.1-rc2/include/linux/vs_pid.h
12364 --- linux-3.1/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
12365 +++ linux-3.1-vs2.3.1-rc2/include/linux/vs_pid.h 2011-10-24 18:53:33.000000000 +0200
12370 +#include "vserver/base.h"
12371 +#include "vserver/check.h"
12372 +#include "vserver/context.h"
12373 +#include "vserver/debug.h"
12374 +#include "vserver/pid.h"
12375 +#include <linux/pid_namespace.h>
12378 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
12381 +int vx_proc_task_visible(struct task_struct *task)
12383 + if ((task->pid == 1) &&
12384 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
12385 + /* show a blend through init */
12387 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
12394 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
12398 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
12400 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
12402 + if (task && !vx_proc_task_visible(task)) {
12403 + vxdprintk(VXD_CBIT(misc, 6),
12404 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
12405 + task, task->xid, task->pid,
12406 + current, current->xid, current->pid);
12407 + put_task_struct(task);
12415 +#warning duplicate inclusion
12417 diff -NurpP --minimal linux-3.1/include/linux/vs_sched.h linux-3.1-vs2.3.1-rc2/include/linux/vs_sched.h
12418 --- linux-3.1/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
12419 +++ linux-3.1-vs2.3.1-rc2/include/linux/vs_sched.h 2011-10-24 18:53:33.000000000 +0200
12421 +#ifndef _VS_SCHED_H
12422 +#define _VS_SCHED_H
12424 +#include "vserver/base.h"
12425 +#include "vserver/context.h"
12426 +#include "vserver/sched.h"
12429 +#define MAX_PRIO_BIAS 20
12430 +#define MIN_PRIO_BIAS -20
12433 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
12435 + struct vx_info *vxi = p->vx_info;
12438 + prio += vx_cpu(vxi, sched_pc).prio_bias;
12442 +static inline void vx_account_user(struct vx_info *vxi,
12443 + cputime_t cputime, int nice)
12447 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
12450 +static inline void vx_account_system(struct vx_info *vxi,
12451 + cputime_t cputime, int idle)
12455 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
12459 +#warning duplicate inclusion
12461 diff -NurpP --minimal linux-3.1/include/linux/vs_socket.h linux-3.1-vs2.3.1-rc2/include/linux/vs_socket.h
12462 --- linux-3.1/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
12463 +++ linux-3.1-vs2.3.1-rc2/include/linux/vs_socket.h 2011-10-24 18:53:33.000000000 +0200
12465 +#ifndef _VS_SOCKET_H
12466 +#define _VS_SOCKET_H
12468 +#include "vserver/debug.h"
12469 +#include "vserver/base.h"
12470 +#include "vserver/cacct.h"
12471 +#include "vserver/context.h"
12472 +#include "vserver/tag.h"
12475 +/* socket accounting */
12477 +#include <linux/socket.h>
12479 +static inline int vx_sock_type(int family)
12481 + switch (family) {
12483 + return VXA_SOCK_UNSPEC;
12485 + return VXA_SOCK_UNIX;
12487 + return VXA_SOCK_INET;
12489 + return VXA_SOCK_INET6;
12491 + return VXA_SOCK_PACKET;
12493 + return VXA_SOCK_OTHER;
12497 +#define vx_acc_sock(v, f, p, s) \
12498 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
12500 +static inline void __vx_acc_sock(struct vx_info *vxi,
12501 + int family, int pos, int size, char *file, int line)
12504 + int type = vx_sock_type(family);
12506 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
12507 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
12511 +#define vx_sock_recv(sk, s) \
12512 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
12513 +#define vx_sock_send(sk, s) \
12514 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
12515 +#define vx_sock_fail(sk, s) \
12516 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
12519 +#define sock_vx_init(s) do { \
12520 + (s)->sk_xid = 0; \
12521 + (s)->sk_vx_info = NULL; \
12524 +#define sock_nx_init(s) do { \
12525 + (s)->sk_nid = 0; \
12526 + (s)->sk_nx_info = NULL; \
12530 +#warning duplicate inclusion
12532 diff -NurpP --minimal linux-3.1/include/linux/vs_tag.h linux-3.1-vs2.3.1-rc2/include/linux/vs_tag.h
12533 --- linux-3.1/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
12534 +++ linux-3.1-vs2.3.1-rc2/include/linux/vs_tag.h 2011-10-24 18:53:33.000000000 +0200
12539 +#include <linux/vserver/tag.h>
12541 +/* check conditions */
12543 +#define DX_ADMIN 0x0001
12544 +#define DX_WATCH 0x0002
12545 +#define DX_HOSTID 0x0008
12547 +#define DX_IDENT 0x0010
12549 +#define DX_ARG_MASK 0x0010
12552 +#define dx_task_tag(t) ((t)->tag)
12554 +#define dx_current_tag() dx_task_tag(current)
12556 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
12558 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
12562 + * check current context for ADMIN/WATCH and
12563 + * optionally against supplied argument
12565 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
12567 + if (mode & DX_ARG_MASK) {
12568 + if ((mode & DX_IDENT) && (id == cid))
12571 + return (((mode & DX_ADMIN) && (cid == 0)) ||
12572 + ((mode & DX_WATCH) && (cid == 1)) ||
12573 + ((mode & DX_HOSTID) && (id == 0)));
12577 +int dx_permission(const struct inode *inode, int mask);
12581 +#warning duplicate inclusion
12583 diff -NurpP --minimal linux-3.1/include/linux/vs_time.h linux-3.1-vs2.3.1-rc2/include/linux/vs_time.h
12584 --- linux-3.1/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
12585 +++ linux-3.1-vs2.3.1-rc2/include/linux/vs_time.h 2011-10-24 18:53:33.000000000 +0200
12587 +#ifndef _VS_TIME_H
12588 +#define _VS_TIME_H
12591 +/* time faking stuff */
12593 +#ifdef CONFIG_VSERVER_VTIME
12595 +extern void vx_adjust_timespec(struct timespec *ts);
12596 +extern int vx_settimeofday(const struct timespec *ts);
12599 +#define vx_adjust_timespec(t) do { } while (0)
12600 +#define vx_settimeofday(t) do_settimeofday(t)
12604 +#warning duplicate inclusion
12606 diff -NurpP --minimal linux-3.1/include/linux/vserver/Kbuild linux-3.1-vs2.3.1-rc2/include/linux/vserver/Kbuild
12607 --- linux-3.1/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
12608 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/Kbuild 2011-10-24 18:53:33.000000000 +0200
12611 +header-y += context_cmd.h network_cmd.h space_cmd.h \
12612 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
12613 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
12614 + debug_cmd.h device_cmd.h
12616 +header-y += switch.h network.h monitor.h inode.h device.h
12618 diff -NurpP --minimal linux-3.1/include/linux/vserver/base.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/base.h
12619 --- linux-3.1/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
12620 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/base.h 2011-10-24 18:53:33.000000000 +0200
12622 +#ifndef _VX_BASE_H
12623 +#define _VX_BASE_H
12626 +/* context state changes */
12638 +#define vx_task_xid(t) ((t)->xid)
12640 +#define vx_current_xid() vx_task_xid(current)
12642 +#define current_vx_info() (current->vx_info)
12645 +#define nx_task_nid(t) ((t)->nid)
12647 +#define nx_current_nid() nx_task_nid(current)
12649 +#define current_nx_info() (current->nx_info)
12652 +/* generic flag merging */
12654 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
12656 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
12658 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
12660 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
12663 +/* context flags */
12665 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
12667 +#define vx_current_flags() __vx_flags(current_vx_info())
12669 +#define vx_info_flags(v, m, f) \
12670 + vs_check_flags(__vx_flags(v), m, f)
12672 +#define task_vx_flags(t, m, f) \
12673 + ((t) && vx_info_flags((t)->vx_info, m, f))
12675 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
12678 +/* context caps */
12680 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
12682 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
12684 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
12686 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
12690 +/* network flags */
12692 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
12694 +#define nx_current_flags() __nx_flags(current_nx_info())
12696 +#define nx_info_flags(n, m, f) \
12697 + vs_check_flags(__nx_flags(n), m, f)
12699 +#define task_nx_flags(t, m, f) \
12700 + ((t) && nx_info_flags((t)->nx_info, m, f))
12702 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
12705 +/* network caps */
12707 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
12709 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
12711 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
12713 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
12716 +/* context mask capabilities */
12718 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
12720 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
12722 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
12725 +/* context bcap mask */
12727 +#define __vx_bcaps(v) ((v)->vx_bcaps)
12729 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
12732 +/* mask given bcaps */
12734 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
12736 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
12739 +/* masked cap_bset */
12741 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
12743 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
12746 +#define vx_info_mbcap(v, b) \
12747 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
12748 + vx_info_bcaps(v, b) : (b))
12750 +#define task_vx_mbcap(t, b) \
12751 + vx_info_mbcap((t)->vx_info, (t)->b)
12753 +#define vx_mbcap(b) task_vx_mbcap(current, b)
12756 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
12758 +#define vx_capable(b, c) (capable(b) || \
12759 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
12761 +#define vx_ns_capable(n, b, c) (ns_capable(n, b) || \
12762 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
12764 +#define nx_capable(b, c) (capable(b) || \
12765 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
12767 +#define vx_task_initpid(t, n) \
12768 + ((t)->vx_info && \
12769 + ((t)->vx_info->vx_initpid == (n)))
12771 +#define vx_current_initpid(n) vx_task_initpid(current, n)
12774 +/* context unshare mask */
12776 +#define __vx_umask(v) ((v)->vx_umask)
12778 +#define vx_current_umask() __vx_umask(current_vx_info())
12780 +#define vx_can_unshare(b, f) (capable(b) || \
12781 + (cap_raised(current_cap(), b) && \
12782 + !((f) & ~vx_current_umask())))
12785 +#define __vx_wmask(v) ((v)->vx_wmask)
12787 +#define vx_current_wmask() __vx_wmask(current_vx_info())
12790 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
12792 +#define vx_info_state(v, m) (__vx_state(v) & (m))
12795 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
12797 +#define nx_info_state(n, m) (__nx_state(n) & (m))
12800 diff -NurpP --minimal linux-3.1/include/linux/vserver/cacct.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/cacct.h
12801 --- linux-3.1/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
12802 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/cacct.h 2011-10-24 18:53:33.000000000 +0200
12804 +#ifndef _VX_CACCT_H
12805 +#define _VX_CACCT_H
12808 +enum sock_acc_field {
12809 + VXA_SOCK_UNSPEC = 0,
12815 + VXA_SOCK_SIZE /* array size */
12818 +#endif /* _VX_CACCT_H */
12819 diff -NurpP --minimal linux-3.1/include/linux/vserver/cacct_cmd.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/cacct_cmd.h
12820 --- linux-3.1/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
12821 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/cacct_cmd.h 2011-10-24 18:53:33.000000000 +0200
12823 +#ifndef _VX_CACCT_CMD_H
12824 +#define _VX_CACCT_CMD_H
12827 +/* virtual host info name commands */
12829 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
12831 +struct vcmd_sock_stat_v0 {
12833 + uint32_t count[3];
12834 + uint64_t total[3];
12840 +#include <linux/compiler.h>
12842 +extern int vc_sock_stat(struct vx_info *, void __user *);
12844 +#endif /* __KERNEL__ */
12845 +#endif /* _VX_CACCT_CMD_H */
12846 diff -NurpP --minimal linux-3.1/include/linux/vserver/cacct_def.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/cacct_def.h
12847 --- linux-3.1/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
12848 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/cacct_def.h 2011-10-24 18:53:33.000000000 +0200
12850 +#ifndef _VX_CACCT_DEF_H
12851 +#define _VX_CACCT_DEF_H
12853 +#include <asm/atomic.h>
12854 +#include <linux/vserver/cacct.h>
12857 +struct _vx_sock_acc {
12858 + atomic_long_t count;
12859 + atomic_long_t total;
12862 +/* context sub struct */
12864 +struct _vx_cacct {
12865 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
12866 + atomic_t slab[8];
12867 + atomic_t page[6][8];
12870 +#ifdef CONFIG_VSERVER_DEBUG
12872 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
12876 + printk("\t_vx_cacct:");
12877 + for (i = 0; i < 6; i++) {
12878 + struct _vx_sock_acc *ptr = cacct->sock[i];
12880 + printk("\t [%d] =", i);
12881 + for (j = 0; j < 3; j++) {
12882 + printk(" [%d] = %8lu, %8lu", j,
12883 + atomic_long_read(&ptr[j].count),
12884 + atomic_long_read(&ptr[j].total));
12892 +#endif /* _VX_CACCT_DEF_H */
12893 diff -NurpP --minimal linux-3.1/include/linux/vserver/cacct_int.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/cacct_int.h
12894 --- linux-3.1/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
12895 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/cacct_int.h 2011-10-24 18:53:33.000000000 +0200
12897 +#ifndef _VX_CACCT_INT_H
12898 +#define _VX_CACCT_INT_H
12904 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
12906 + return atomic_long_read(&cacct->sock[type][pos].count);
12911 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
12913 + return atomic_long_read(&cacct->sock[type][pos].total);
12916 +#endif /* __KERNEL__ */
12917 +#endif /* _VX_CACCT_INT_H */
12918 diff -NurpP --minimal linux-3.1/include/linux/vserver/check.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/check.h
12919 --- linux-3.1/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
12920 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/check.h 2011-10-24 18:53:33.000000000 +0200
12922 +#ifndef _VS_CHECK_H
12923 +#define _VS_CHECK_H
12926 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
12928 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
12929 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
12931 +#define MIN_D_CONTEXT 65536
12934 +/* check conditions */
12936 +#define VS_ADMIN 0x0001
12937 +#define VS_WATCH 0x0002
12938 +#define VS_HIDE 0x0004
12939 +#define VS_HOSTID 0x0008
12941 +#define VS_IDENT 0x0010
12942 +#define VS_EQUIV 0x0020
12943 +#define VS_PARENT 0x0040
12944 +#define VS_CHILD 0x0080
12946 +#define VS_ARG_MASK 0x00F0
12948 +#define VS_DYNAMIC 0x0100
12949 +#define VS_STATIC 0x0200
12951 +#define VS_ATR_MASK 0x0F00
12953 +#ifdef CONFIG_VSERVER_PRIVACY
12954 +#define VS_ADMIN_P (0)
12955 +#define VS_WATCH_P (0)
12957 +#define VS_ADMIN_P VS_ADMIN
12958 +#define VS_WATCH_P VS_WATCH
12961 +#define VS_HARDIRQ 0x1000
12962 +#define VS_SOFTIRQ 0x2000
12963 +#define VS_IRQ 0x4000
12965 +#define VS_IRQ_MASK 0xF000
12967 +#include <linux/hardirq.h>
12970 + * check current context for ADMIN/WATCH and
12971 + * optionally against supplied argument
12973 +static inline int __vs_check(int cid, int id, unsigned int mode)
12975 + if (mode & VS_ARG_MASK) {
12976 + if ((mode & VS_IDENT) && (id == cid))
12979 + if (mode & VS_ATR_MASK) {
12980 + if ((mode & VS_DYNAMIC) &&
12981 + (id >= MIN_D_CONTEXT) &&
12982 + (id <= MAX_S_CONTEXT))
12984 + if ((mode & VS_STATIC) &&
12985 + (id > 1) && (id < MIN_D_CONTEXT))
12988 + if (mode & VS_IRQ_MASK) {
12989 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
12991 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
12993 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
12996 + return (((mode & VS_ADMIN) && (cid == 0)) ||
12997 + ((mode & VS_WATCH) && (cid == 1)) ||
12998 + ((mode & VS_HOSTID) && (id == 0)));
13001 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
13003 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
13006 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
13008 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
13011 diff -NurpP --minimal linux-3.1/include/linux/vserver/context.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/context.h
13012 --- linux-3.1/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
13013 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/context.h 2011-10-24 18:53:33.000000000 +0200
13015 +#ifndef _VX_CONTEXT_H
13016 +#define _VX_CONTEXT_H
13018 +#include <linux/types.h>
13019 +#include <linux/capability.h>
13022 +/* context flags */
13024 +#define VXF_INFO_SCHED 0x00000002
13025 +#define VXF_INFO_NPROC 0x00000004
13026 +#define VXF_INFO_PRIVATE 0x00000008
13028 +#define VXF_INFO_INIT 0x00000010
13029 +#define VXF_INFO_HIDE 0x00000020
13030 +#define VXF_INFO_ULIMIT 0x00000040
13031 +#define VXF_INFO_NSPACE 0x00000080
13033 +#define VXF_SCHED_HARD 0x00000100
13034 +#define VXF_SCHED_PRIO 0x00000200
13035 +#define VXF_SCHED_PAUSE 0x00000400
13037 +#define VXF_VIRT_MEM 0x00010000
13038 +#define VXF_VIRT_UPTIME 0x00020000
13039 +#define VXF_VIRT_CPU 0x00040000
13040 +#define VXF_VIRT_LOAD 0x00080000
13041 +#define VXF_VIRT_TIME 0x00100000
13043 +#define VXF_HIDE_MOUNT 0x01000000
13044 +/* was VXF_HIDE_NETIF 0x02000000 */
13045 +#define VXF_HIDE_VINFO 0x04000000
13047 +#define VXF_STATE_SETUP (1ULL << 32)
13048 +#define VXF_STATE_INIT (1ULL << 33)
13049 +#define VXF_STATE_ADMIN (1ULL << 34)
13051 +#define VXF_SC_HELPER (1ULL << 36)
13052 +#define VXF_REBOOT_KILL (1ULL << 37)
13053 +#define VXF_PERSISTENT (1ULL << 38)
13055 +#define VXF_FORK_RSS (1ULL << 48)
13056 +#define VXF_PROLIFIC (1ULL << 49)
13058 +#define VXF_IGNEG_NICE (1ULL << 52)
13060 +#define VXF_ONE_TIME (0x0007ULL << 32)
13062 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
13065 +/* context migration */
13067 +#define VXM_SET_INIT 0x00000001
13068 +#define VXM_SET_REAPER 0x00000002
13070 +/* context caps */
13072 +#define VXC_CAP_MASK 0x00000000
13074 +#define VXC_SET_UTSNAME 0x00000001
13075 +#define VXC_SET_RLIMIT 0x00000002
13076 +#define VXC_FS_SECURITY 0x00000004
13077 +#define VXC_FS_TRUSTED 0x00000008
13078 +#define VXC_TIOCSTI 0x00000010
13080 +/* was VXC_RAW_ICMP 0x00000100 */
13081 +#define VXC_SYSLOG 0x00001000
13082 +#define VXC_OOM_ADJUST 0x00002000
13083 +#define VXC_AUDIT_CONTROL 0x00004000
13085 +#define VXC_SECURE_MOUNT 0x00010000
13086 +#define VXC_SECURE_REMOUNT 0x00020000
13087 +#define VXC_BINARY_MOUNT 0x00040000
13089 +#define VXC_QUOTA_CTL 0x00100000
13090 +#define VXC_ADMIN_MAPPER 0x00200000
13091 +#define VXC_ADMIN_CLOOP 0x00400000
13093 +#define VXC_KTHREAD 0x01000000
13094 +#define VXC_NAMESPACE 0x02000000
13099 +#include <linux/list.h>
13100 +#include <linux/spinlock.h>
13101 +#include <linux/rcupdate.h>
13103 +#include "limit_def.h"
13104 +#include "sched_def.h"
13105 +#include "cvirt_def.h"
13106 +#include "cacct_def.h"
13107 +#include "device_def.h"
13109 +#define VX_SPACES 2
13111 +struct _vx_info_pc {
13112 + struct _vx_sched_pc sched_pc;
13113 + struct _vx_cvirt_pc cvirt_pc;
13116 +struct _vx_space {
13117 + unsigned long vx_nsmask; /* assignment mask */
13118 + struct nsproxy *vx_nsproxy; /* private namespaces */
13119 + struct fs_struct *vx_fs; /* private namespace fs */
13120 + const struct cred *vx_cred; /* task credentials */
13124 + struct hlist_node vx_hlist; /* linked list of contexts */
13125 + xid_t vx_id; /* context id */
13126 + atomic_t vx_usecnt; /* usage count */
13127 + atomic_t vx_tasks; /* tasks count */
13128 + struct vx_info *vx_parent; /* parent context */
13129 + int vx_state; /* context state */
13131 + struct _vx_space space[VX_SPACES]; /* namespace store */
13133 + uint64_t vx_flags; /* context flags */
13134 + uint64_t vx_ccaps; /* context caps (vserver) */
13135 + uint64_t vx_umask; /* unshare mask (guest) */
13136 + uint64_t vx_wmask; /* warn mask (guest) */
13137 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
13139 + struct task_struct *vx_reaper; /* guest reaper process */
13140 + pid_t vx_initpid; /* PID of guest init */
13141 + int64_t vx_badness_bias; /* OOM points bias */
13143 + struct _vx_limit limit; /* vserver limits */
13144 + struct _vx_sched sched; /* vserver scheduler */
13145 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
13146 + struct _vx_cacct cacct; /* context accounting */
13148 + struct _vx_device dmap; /* default device map targets */
13150 +#ifndef CONFIG_SMP
13151 + struct _vx_info_pc info_pc; /* per cpu data */
13153 + struct _vx_info_pc *ptr_pc; /* per cpu array */
13156 + wait_queue_head_t vx_wait; /* context exit waitqueue */
13157 + int reboot_cmd; /* last sys_reboot() cmd */
13158 + int exit_code; /* last process exit code */
13160 + char vx_name[65]; /* vserver name */
13163 +#ifndef CONFIG_SMP
13164 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
13165 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
13167 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
13168 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
13171 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
13174 +struct vx_info_save {
13175 + struct vx_info *vxi;
13180 +/* status flags */
13182 +#define VXS_HASHED 0x0001
13183 +#define VXS_PAUSED 0x0010
13184 +#define VXS_SHUTDOWN 0x0100
13185 +#define VXS_HELPER 0x1000
13186 +#define VXS_RELEASED 0x8000
13189 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
13190 +extern void release_vx_info(struct vx_info *, struct task_struct *);
13192 +extern struct vx_info *lookup_vx_info(int);
13193 +extern struct vx_info *lookup_or_create_vx_info(int);
13195 +extern int get_xid_list(int, unsigned int *, int);
13196 +extern int xid_is_hashed(xid_t);
13198 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
13200 +extern long vs_state_change(struct vx_info *, unsigned int);
13203 +#endif /* __KERNEL__ */
13204 +#endif /* _VX_CONTEXT_H */
13205 diff -NurpP --minimal linux-3.1/include/linux/vserver/context_cmd.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/context_cmd.h
13206 --- linux-3.1/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
13207 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/context_cmd.h 2011-10-24 18:53:33.000000000 +0200
13209 +#ifndef _VX_CONTEXT_CMD_H
13210 +#define _VX_CONTEXT_CMD_H
13213 +/* vinfo commands */
13215 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
13218 +extern int vc_task_xid(uint32_t);
13220 +#endif /* __KERNEL__ */
13222 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
13224 +struct vcmd_vx_info_v0 {
13226 + uint32_t initpid;
13227 + /* more to come */
13231 +extern int vc_vx_info(struct vx_info *, void __user *);
13233 +#endif /* __KERNEL__ */
13235 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
13237 +struct vcmd_ctx_stat_v0 {
13240 + /* more to come */
13244 +extern int vc_ctx_stat(struct vx_info *, void __user *);
13246 +#endif /* __KERNEL__ */
13248 +/* context commands */
13250 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
13251 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
13253 +struct vcmd_ctx_create {
13254 + uint64_t flagword;
13257 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
13258 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
13260 +struct vcmd_ctx_migrate {
13261 + uint64_t flagword;
13265 +extern int vc_ctx_create(uint32_t, void __user *);
13266 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
13268 +#endif /* __KERNEL__ */
13271 +/* flag commands */
13273 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
13274 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
13276 +struct vcmd_ctx_flags_v0 {
13277 + uint64_t flagword;
13282 +extern int vc_get_cflags(struct vx_info *, void __user *);
13283 +extern int vc_set_cflags(struct vx_info *, void __user *);
13285 +#endif /* __KERNEL__ */
13288 +/* context caps commands */
13290 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
13291 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
13293 +struct vcmd_ctx_caps_v1 {
13299 +extern int vc_get_ccaps(struct vx_info *, void __user *);
13300 +extern int vc_set_ccaps(struct vx_info *, void __user *);
13302 +#endif /* __KERNEL__ */
13305 +/* bcaps commands */
13307 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
13308 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
13310 +struct vcmd_bcaps {
13316 +extern int vc_get_bcaps(struct vx_info *, void __user *);
13317 +extern int vc_set_bcaps(struct vx_info *, void __user *);
13319 +#endif /* __KERNEL__ */
13322 +/* umask commands */
13324 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
13325 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
13327 +struct vcmd_umask {
13333 +extern int vc_get_umask(struct vx_info *, void __user *);
13334 +extern int vc_set_umask(struct vx_info *, void __user *);
13336 +#endif /* __KERNEL__ */
13339 +/* wmask commands */
13341 +#define VCMD_get_wmask VC_CMD(FLAGS, 15, 0)
13342 +#define VCMD_set_wmask VC_CMD(FLAGS, 16, 0)
13344 +struct vcmd_wmask {
13350 +extern int vc_get_wmask(struct vx_info *, void __user *);
13351 +extern int vc_set_wmask(struct vx_info *, void __user *);
13353 +#endif /* __KERNEL__ */
13358 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
13359 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
13361 +struct vcmd_badness_v0 {
13366 +extern int vc_get_badness(struct vx_info *, void __user *);
13367 +extern int vc_set_badness(struct vx_info *, void __user *);
13369 +#endif /* __KERNEL__ */
13370 +#endif /* _VX_CONTEXT_CMD_H */
13371 diff -NurpP --minimal linux-3.1/include/linux/vserver/cvirt.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/cvirt.h
13372 --- linux-3.1/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
13373 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/cvirt.h 2011-10-24 18:53:33.000000000 +0200
13375 +#ifndef _VX_CVIRT_H
13376 +#define _VX_CVIRT_H
13383 +void vx_vsi_uptime(struct timespec *, struct timespec *);
13388 +void vx_update_load(struct vx_info *);
13391 +int vx_do_syslog(int, char __user *, int);
13393 +#endif /* __KERNEL__ */
13394 +#endif /* _VX_CVIRT_H */
13395 diff -NurpP --minimal linux-3.1/include/linux/vserver/cvirt_cmd.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/cvirt_cmd.h
13396 --- linux-3.1/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
13397 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/cvirt_cmd.h 2011-10-24 18:53:33.000000000 +0200
13399 +#ifndef _VX_CVIRT_CMD_H
13400 +#define _VX_CVIRT_CMD_H
13403 +/* virtual host info name commands */
13405 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
13406 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
13408 +struct vcmd_vhi_name_v0 {
13414 +enum vhi_name_field {
13415 + VHIN_CONTEXT = 0,
13427 +#include <linux/compiler.h>
13429 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
13430 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
13432 +#endif /* __KERNEL__ */
13434 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
13436 +struct vcmd_virt_stat_v0 {
13439 + uint32_t nr_threads;
13440 + uint32_t nr_running;
13441 + uint32_t nr_uninterruptible;
13442 + uint32_t nr_onhold;
13443 + uint32_t nr_forks;
13444 + uint32_t load[3];
13448 +extern int vc_virt_stat(struct vx_info *, void __user *);
13450 +#endif /* __KERNEL__ */
13451 +#endif /* _VX_CVIRT_CMD_H */
13452 diff -NurpP --minimal linux-3.1/include/linux/vserver/cvirt_def.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/cvirt_def.h
13453 --- linux-3.1/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
13454 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/cvirt_def.h 2011-10-24 18:53:33.000000000 +0200
13456 +#ifndef _VX_CVIRT_DEF_H
13457 +#define _VX_CVIRT_DEF_H
13459 +#include <linux/jiffies.h>
13460 +#include <linux/spinlock.h>
13461 +#include <linux/wait.h>
13462 +#include <linux/time.h>
13463 +#include <asm/atomic.h>
13466 +struct _vx_usage_stat {
13470 + uint64_t softirq;
13476 +struct _vx_syslog {
13477 + wait_queue_head_t log_wait;
13478 + spinlock_t logbuf_lock; /* lock for the log buffer */
13480 + unsigned long log_start; /* next char to be read by syslog() */
13481 + unsigned long con_start; /* next char to be sent to consoles */
13482 + unsigned long log_end; /* most-recently-written-char + 1 */
13483 + unsigned long logged_chars; /* #chars since last read+clear operation */
13485 + char log_buf[1024];
13489 +/* context sub struct */
13491 +struct _vx_cvirt {
13492 + atomic_t nr_threads; /* number of current threads */
13493 + atomic_t nr_running; /* number of running threads */
13494 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
13496 + atomic_t nr_onhold; /* processes on hold */
13497 + uint32_t onhold_last; /* jiffies when put on hold */
13499 + struct timespec bias_ts; /* time offset to the host */
13500 + struct timespec bias_idle;
13501 + struct timespec bias_uptime; /* context creation point */
13502 + uint64_t bias_clock; /* offset in clock_t */
13504 + spinlock_t load_lock; /* lock for the load averages */
13505 + atomic_t load_updates; /* nr of load updates done so far */
13506 + uint32_t load_last; /* last time load was calculated */
13507 + uint32_t load[3]; /* load averages 1,5,15 */
13509 + atomic_t total_forks; /* number of forks so far */
13511 + struct _vx_syslog syslog;
13514 +struct _vx_cvirt_pc {
13515 + struct _vx_usage_stat cpustat;
13519 +#ifdef CONFIG_VSERVER_DEBUG
13521 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
13523 + printk("\t_vx_cvirt:\n");
13524 + printk("\t threads: %4d, %4d, %4d, %4d\n",
13525 + atomic_read(&cvirt->nr_threads),
13526 + atomic_read(&cvirt->nr_running),
13527 + atomic_read(&cvirt->nr_uninterruptible),
13528 + atomic_read(&cvirt->nr_onhold));
13529 + /* add rest here */
13530 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
13535 +#endif /* _VX_CVIRT_DEF_H */
13536 diff -NurpP --minimal linux-3.1/include/linux/vserver/debug.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/debug.h
13537 --- linux-3.1/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
13538 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/debug.h 2011-10-24 18:53:33.000000000 +0200
13540 +#ifndef _VX_DEBUG_H
13541 +#define _VX_DEBUG_H
13544 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
13545 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
13546 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
13548 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
13549 + imajor((d)->bd_inode), iminor((d)->bd_inode)
13550 +#define VXF_DEV "%p[%lu,%d:%d]"
13552 +#if defined(CONFIG_QUOTES_UTF8)
13553 +#define VS_Q_LQM "\xc2\xbb"
13554 +#define VS_Q_RQM "\xc2\xab"
13555 +#elif defined(CONFIG_QUOTES_ASCII)
13556 +#define VS_Q_LQM "\x27"
13557 +#define VS_Q_RQM "\x27"
13559 +#define VS_Q_LQM "\xbb"
13560 +#define VS_Q_RQM "\xab"
13563 +#define VS_Q(f) VS_Q_LQM f VS_Q_RQM
13566 +#define vxd_path(p) \
13567 + ({ static char _buffer[PATH_MAX]; \
13568 + d_path(p, _buffer, sizeof(_buffer)); })
13570 +#define vxd_cond_path(n) \
13571 + ((n) ? vxd_path(&(n)->path) : "<null>" )
13574 +#ifdef CONFIG_VSERVER_DEBUG
13576 +extern unsigned int vx_debug_switch;
13577 +extern unsigned int vx_debug_xid;
13578 +extern unsigned int vx_debug_nid;
13579 +extern unsigned int vx_debug_tag;
13580 +extern unsigned int vx_debug_net;
13581 +extern unsigned int vx_debug_limit;
13582 +extern unsigned int vx_debug_cres;
13583 +extern unsigned int vx_debug_dlim;
13584 +extern unsigned int vx_debug_quota;
13585 +extern unsigned int vx_debug_cvirt;
13586 +extern unsigned int vx_debug_space;
13587 +extern unsigned int vx_debug_misc;
13590 +#define VX_LOGLEVEL "vxD: "
13591 +#define VX_PROC_FMT "%p: "
13592 +#define VX_PROCESS current
13594 +#define vxdprintk(c, f, x...) \
13597 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
13598 + VX_PROCESS , ##x); \
13601 +#define vxlprintk(c, f, x...) \
13604 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
13607 +#define vxfprintk(c, f, x...) \
13610 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
13616 +void dump_vx_info(struct vx_info *, int);
13617 +void dump_vx_info_inactive(int);
13619 +#else /* CONFIG_VSERVER_DEBUG */
13621 +#define vx_debug_switch 0
13622 +#define vx_debug_xid 0
13623 +#define vx_debug_nid 0
13624 +#define vx_debug_tag 0
13625 +#define vx_debug_net 0
13626 +#define vx_debug_limit 0
13627 +#define vx_debug_cres 0
13628 +#define vx_debug_dlim 0
13629 +#define vx_debug_cvirt 0
13631 +#define vxdprintk(x...) do { } while (0)
13632 +#define vxlprintk(x...) do { } while (0)
13633 +#define vxfprintk(x...) do { } while (0)
13635 +#endif /* CONFIG_VSERVER_DEBUG */
13638 +#ifdef CONFIG_VSERVER_WARN
13640 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
13641 +#define VX_WARN_TASK "[" VS_Q("%s") ",%u:#%u|%u|%u] "
13642 +#define VX_WARN_XID "[xid #%u] "
13643 +#define VX_WARN_NID "[nid #%u] "
13644 +#define VX_WARN_TAG "[tag #%u] "
13646 +#define vxwprintk(c, f, x...) \
13649 + printk(VX_WARNLEVEL f "\n", ##x); \
13652 +#else /* CONFIG_VSERVER_WARN */
13654 +#define vxwprintk(x...) do { } while (0)
13656 +#endif /* CONFIG_VSERVER_WARN */
13658 +#define vxwprintk_task(c, f, x...) \
13659 + vxwprintk(c, VX_WARN_TASK f, \
13660 + current->comm, current->pid, \
13661 + current->xid, current->nid, current->tag, ##x)
13662 +#define vxwprintk_xid(c, f, x...) \
13663 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
13664 +#define vxwprintk_nid(c, f, x...) \
13665 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
13666 +#define vxwprintk_tag(c, f, x...) \
13667 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
13669 +#ifdef CONFIG_VSERVER_DEBUG
13670 +#define vxd_assert_lock(l) assert_spin_locked(l)
13671 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
13672 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
13674 +#define vxd_assert_lock(l) do { } while (0)
13675 +#define vxd_assert(c, f, x...) do { } while (0)
13679 +#endif /* _VX_DEBUG_H */
13680 diff -NurpP --minimal linux-3.1/include/linux/vserver/debug_cmd.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/debug_cmd.h
13681 --- linux-3.1/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
13682 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/debug_cmd.h 2011-10-24 18:53:33.000000000 +0200
13684 +#ifndef _VX_DEBUG_CMD_H
13685 +#define _VX_DEBUG_CMD_H
13688 +/* debug commands */
13690 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
13692 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
13693 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
13695 +struct vcmd_read_history_v0 {
13698 + char __user *data;
13701 +struct vcmd_read_monitor_v0 {
13704 + char __user *data;
13710 +#ifdef CONFIG_COMPAT
13712 +#include <asm/compat.h>
13714 +struct vcmd_read_history_v0_x32 {
13717 + compat_uptr_t data_ptr;
13720 +struct vcmd_read_monitor_v0_x32 {
13723 + compat_uptr_t data_ptr;
13726 +#endif /* CONFIG_COMPAT */
13728 +extern int vc_dump_history(uint32_t);
13730 +extern int vc_read_history(uint32_t, void __user *);
13731 +extern int vc_read_monitor(uint32_t, void __user *);
13733 +#ifdef CONFIG_COMPAT
13735 +extern int vc_read_history_x32(uint32_t, void __user *);
13736 +extern int vc_read_monitor_x32(uint32_t, void __user *);
13738 +#endif /* CONFIG_COMPAT */
13740 +#endif /* __KERNEL__ */
13741 +#endif /* _VX_DEBUG_CMD_H */
13742 diff -NurpP --minimal linux-3.1/include/linux/vserver/device.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/device.h
13743 --- linux-3.1/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
13744 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/device.h 2011-10-24 18:53:33.000000000 +0200
13746 +#ifndef _VX_DEVICE_H
13747 +#define _VX_DEVICE_H
13750 +#define DATTR_CREATE 0x00000001
13751 +#define DATTR_OPEN 0x00000002
13753 +#define DATTR_REMAP 0x00000010
13755 +#define DATTR_MASK 0x00000013
13758 +#else /* _VX_DEVICE_H */
13759 +#warning duplicate inclusion
13760 +#endif /* _VX_DEVICE_H */
13761 diff -NurpP --minimal linux-3.1/include/linux/vserver/device_cmd.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/device_cmd.h
13762 --- linux-3.1/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
13763 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/device_cmd.h 2011-10-24 18:53:33.000000000 +0200
13765 +#ifndef _VX_DEVICE_CMD_H
13766 +#define _VX_DEVICE_CMD_H
13769 +/* device vserver commands */
13771 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
13772 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
13774 +struct vcmd_set_mapping_v0 {
13775 + const char __user *device;
13776 + const char __user *target;
13783 +#ifdef CONFIG_COMPAT
13785 +#include <asm/compat.h>
13787 +struct vcmd_set_mapping_v0_x32 {
13788 + compat_uptr_t device_ptr;
13789 + compat_uptr_t target_ptr;
13793 +#endif /* CONFIG_COMPAT */
13795 +#include <linux/compiler.h>
13797 +extern int vc_set_mapping(struct vx_info *, void __user *);
13798 +extern int vc_unset_mapping(struct vx_info *, void __user *);
13800 +#ifdef CONFIG_COMPAT
13802 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
13803 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
13805 +#endif /* CONFIG_COMPAT */
13807 +#endif /* __KERNEL__ */
13808 +#endif /* _VX_DEVICE_CMD_H */
13809 diff -NurpP --minimal linux-3.1/include/linux/vserver/device_def.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/device_def.h
13810 --- linux-3.1/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
13811 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/device_def.h 2011-10-24 18:53:33.000000000 +0200
13813 +#ifndef _VX_DEVICE_DEF_H
13814 +#define _VX_DEVICE_DEF_H
13816 +#include <linux/types.h>
13818 +struct vx_dmap_target {
13823 +struct _vx_device {
13824 +#ifdef CONFIG_VSERVER_DEVICE
13825 + struct vx_dmap_target targets[2];
13829 +#endif /* _VX_DEVICE_DEF_H */
13830 diff -NurpP --minimal linux-3.1/include/linux/vserver/dlimit.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/dlimit.h
13831 --- linux-3.1/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
13832 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/dlimit.h 2011-10-24 18:53:33.000000000 +0200
13834 +#ifndef _VX_DLIMIT_H
13835 +#define _VX_DLIMIT_H
13837 +#include "switch.h"
13842 +/* keep in sync with CDLIM_INFINITY */
13844 +#define DLIM_INFINITY (~0ULL)
13846 +#include <linux/spinlock.h>
13847 +#include <linux/rcupdate.h>
13849 +struct super_block;
13852 + struct hlist_node dl_hlist; /* linked list of contexts */
13853 + struct rcu_head dl_rcu; /* the rcu head */
13854 + tag_t dl_tag; /* context tag */
13855 + atomic_t dl_usecnt; /* usage count */
13856 + atomic_t dl_refcnt; /* reference count */
13858 + struct super_block *dl_sb; /* associated superblock */
13860 + spinlock_t dl_lock; /* protect the values */
13862 + unsigned long long dl_space_used; /* used space in bytes */
13863 + unsigned long long dl_space_total; /* maximum space in bytes */
13864 + unsigned long dl_inodes_used; /* used inodes */
13865 + unsigned long dl_inodes_total; /* maximum inodes */
13867 + unsigned int dl_nrlmult; /* non root limit mult */
13872 +extern void rcu_free_dl_info(struct rcu_head *);
13873 +extern void unhash_dl_info(struct dl_info *);
13875 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
13880 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
13882 +typedef uint64_t dlsize_t;
13884 +#endif /* __KERNEL__ */
13885 +#else /* _VX_DLIMIT_H */
13886 +#warning duplicate inclusion
13887 +#endif /* _VX_DLIMIT_H */
13888 diff -NurpP --minimal linux-3.1/include/linux/vserver/dlimit_cmd.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/dlimit_cmd.h
13889 --- linux-3.1/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
13890 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/dlimit_cmd.h 2011-10-24 18:53:33.000000000 +0200
13892 +#ifndef _VX_DLIMIT_CMD_H
13893 +#define _VX_DLIMIT_CMD_H
13896 +/* dlimit vserver commands */
13898 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
13899 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
13901 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
13902 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
13904 +struct vcmd_ctx_dlimit_base_v0 {
13905 + const char __user *name;
13909 +struct vcmd_ctx_dlimit_v0 {
13910 + const char __user *name;
13911 + uint32_t space_used; /* used space in kbytes */
13912 + uint32_t space_total; /* maximum space in kbytes */
13913 + uint32_t inodes_used; /* used inodes */
13914 + uint32_t inodes_total; /* maximum inodes */
13915 + uint32_t reserved; /* reserved for root in % */
13919 +#define CDLIM_UNSET ((uint32_t)0UL)
13920 +#define CDLIM_INFINITY ((uint32_t)~0UL)
13921 +#define CDLIM_KEEP ((uint32_t)~1UL)
13923 +#define DLIME_UNIT 0
13924 +#define DLIME_KILO 1
13925 +#define DLIME_MEGA 2
13926 +#define DLIME_GIGA 3
13928 +#define DLIMF_SHIFT 0x10
13930 +#define DLIMS_USED 0
13931 +#define DLIMS_TOTAL 2
13934 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
13936 + int exp = (flags & DLIMF_SHIFT) ?
13937 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
13938 + return ((uint64_t)val) << (10 * exp);
13942 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
13946 + if (*flags & DLIMF_SHIFT) {
13947 + while (val > (1LL << 32) && (exp < 3)) {
13951 + *flags &= ~(DLIME_GIGA << shift);
13952 + *flags |= exp << shift;
13960 +#ifdef CONFIG_COMPAT
13962 +#include <asm/compat.h>
13964 +struct vcmd_ctx_dlimit_base_v0_x32 {
13965 + compat_uptr_t name_ptr;
13969 +struct vcmd_ctx_dlimit_v0_x32 {
13970 + compat_uptr_t name_ptr;
13971 + uint32_t space_used; /* used space in kbytes */
13972 + uint32_t space_total; /* maximum space in kbytes */
13973 + uint32_t inodes_used; /* used inodes */
13974 + uint32_t inodes_total; /* maximum inodes */
13975 + uint32_t reserved; /* reserved for root in % */
13979 +#endif /* CONFIG_COMPAT */
13981 +#include <linux/compiler.h>
13983 +extern int vc_add_dlimit(uint32_t, void __user *);
13984 +extern int vc_rem_dlimit(uint32_t, void __user *);
13986 +extern int vc_set_dlimit(uint32_t, void __user *);
13987 +extern int vc_get_dlimit(uint32_t, void __user *);
13989 +#ifdef CONFIG_COMPAT
13991 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
13992 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
13994 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
13995 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
13997 +#endif /* CONFIG_COMPAT */
13999 +#endif /* __KERNEL__ */
14000 +#endif /* _VX_DLIMIT_CMD_H */
14001 diff -NurpP --minimal linux-3.1/include/linux/vserver/global.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/global.h
14002 --- linux-3.1/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
14003 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/global.h 2011-10-24 18:53:33.000000000 +0200
14005 +#ifndef _VX_GLOBAL_H
14006 +#define _VX_GLOBAL_H
14009 +extern atomic_t vx_global_ctotal;
14010 +extern atomic_t vx_global_cactive;
14012 +extern atomic_t nx_global_ctotal;
14013 +extern atomic_t nx_global_cactive;
14015 +extern atomic_t vs_global_nsproxy;
14016 +extern atomic_t vs_global_fs;
14017 +extern atomic_t vs_global_mnt_ns;
14018 +extern atomic_t vs_global_uts_ns;
14019 +extern atomic_t vs_global_user_ns;
14020 +extern atomic_t vs_global_pid_ns;
14023 +#endif /* _VX_GLOBAL_H */
14024 diff -NurpP --minimal linux-3.1/include/linux/vserver/history.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/history.h
14025 --- linux-3.1/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
14026 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/history.h 2011-10-24 18:53:33.000000000 +0200
14028 +#ifndef _VX_HISTORY_H
14029 +#define _VX_HISTORY_H
14034 + VXH_THROW_OOPS = 1,
14038 + VXH_INIT_VX_INFO,
14041 + VXH_CLAIM_VX_INFO,
14042 + VXH_RELEASE_VX_INFO,
14043 + VXH_ALLOC_VX_INFO,
14044 + VXH_DEALLOC_VX_INFO,
14045 + VXH_HASH_VX_INFO,
14046 + VXH_UNHASH_VX_INFO,
14048 + VXH_LOOKUP_VX_INFO,
14049 + VXH_CREATE_VX_INFO,
14052 +struct _vxhe_vxi {
14053 + struct vx_info *ptr;
14059 +struct _vxhe_set_clr {
14063 +struct _vxhe_loc_lookup {
14067 +struct _vx_hist_entry {
14069 + unsigned short seq;
14070 + unsigned short type;
14071 + struct _vxhe_vxi vxi;
14073 + struct _vxhe_set_clr sc;
14074 + struct _vxhe_loc_lookup ll;
14078 +#ifdef CONFIG_VSERVER_HISTORY
14080 +extern unsigned volatile int vxh_active;
14082 +struct _vx_hist_entry *vxh_advance(void *loc);
14086 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
14088 + entry->vxi.ptr = vxi;
14090 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
14091 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
14092 + entry->vxi.xid = vxi->vx_id;
14097 +#define __HERE__ current_text_addr()
14099 +#define __VXH_BODY(__type, __data, __here) \
14100 + struct _vx_hist_entry *entry; \
14102 + preempt_disable(); \
14103 + entry = vxh_advance(__here); \
14105 + entry->type = __type; \
14106 + preempt_enable();
14109 + /* pass vxi only */
14111 +#define __VXH_SMPL \
14112 + __vxh_copy_vxi(entry, vxi)
14115 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
14117 + __VXH_BODY(__type, __VXH_SMPL, __here)
14120 + /* pass vxi and data (void *) */
14122 +#define __VXH_DATA \
14123 + __vxh_copy_vxi(entry, vxi); \
14124 + entry->sc.data = data
14127 +void __vxh_data(struct vx_info *vxi, void *data,
14128 + int __type, void *__here)
14130 + __VXH_BODY(__type, __VXH_DATA, __here)
14133 + /* pass vxi and arg (long) */
14135 +#define __VXH_LONG \
14136 + __vxh_copy_vxi(entry, vxi); \
14137 + entry->ll.arg = arg
14140 +void __vxh_long(struct vx_info *vxi, long arg,
14141 + int __type, void *__here)
14143 + __VXH_BODY(__type, __VXH_LONG, __here)
14148 +void __vxh_throw_oops(void *__here)
14150 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
14151 + /* prevent further acquisition */
14156 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
14158 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
14159 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
14161 +#define __vxh_init_vx_info(v, d, h) \
14162 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
14163 +#define __vxh_set_vx_info(v, d, h) \
14164 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
14165 +#define __vxh_clr_vx_info(v, d, h) \
14166 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
14168 +#define __vxh_claim_vx_info(v, d, h) \
14169 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
14170 +#define __vxh_release_vx_info(v, d, h) \
14171 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
14173 +#define vxh_alloc_vx_info(v) \
14174 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
14175 +#define vxh_dealloc_vx_info(v) \
14176 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
14178 +#define vxh_hash_vx_info(v) \
14179 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
14180 +#define vxh_unhash_vx_info(v) \
14181 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
14183 +#define vxh_loc_vx_info(v, l) \
14184 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
14185 +#define vxh_lookup_vx_info(v, l) \
14186 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
14187 +#define vxh_create_vx_info(v, l) \
14188 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
14190 +extern void vxh_dump_history(void);
14193 +#else /* CONFIG_VSERVER_HISTORY */
14195 +#define __HERE__ 0
14197 +#define vxh_throw_oops() do { } while (0)
14199 +#define __vxh_get_vx_info(v, h) do { } while (0)
14200 +#define __vxh_put_vx_info(v, h) do { } while (0)
14202 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
14203 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
14204 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
14206 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
14207 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
14209 +#define vxh_alloc_vx_info(v) do { } while (0)
14210 +#define vxh_dealloc_vx_info(v) do { } while (0)
14212 +#define vxh_hash_vx_info(v) do { } while (0)
14213 +#define vxh_unhash_vx_info(v) do { } while (0)
14215 +#define vxh_loc_vx_info(v, l) do { } while (0)
14216 +#define vxh_lookup_vx_info(v, l) do { } while (0)
14217 +#define vxh_create_vx_info(v, l) do { } while (0)
14219 +#define vxh_dump_history() do { } while (0)
14222 +#endif /* CONFIG_VSERVER_HISTORY */
14224 +#endif /* _VX_HISTORY_H */
14225 diff -NurpP --minimal linux-3.1/include/linux/vserver/inode.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/inode.h
14226 --- linux-3.1/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
14227 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/inode.h 2011-10-24 18:53:33.000000000 +0200
14229 +#ifndef _VX_INODE_H
14230 +#define _VX_INODE_H
14233 +#define IATTR_TAG 0x01000000
14235 +#define IATTR_ADMIN 0x00000001
14236 +#define IATTR_WATCH 0x00000002
14237 +#define IATTR_HIDE 0x00000004
14238 +#define IATTR_FLAGS 0x00000007
14240 +#define IATTR_BARRIER 0x00010000
14241 +#define IATTR_IXUNLINK 0x00020000
14242 +#define IATTR_IMMUTABLE 0x00040000
14243 +#define IATTR_COW 0x00080000
14248 +#ifdef CONFIG_VSERVER_PROC_SECURE
14249 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
14250 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
14252 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
14253 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
14256 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
14258 +#endif /* __KERNEL__ */
14260 +/* inode ioctls */
14262 +#define FIOC_GETXFLG _IOR('x', 5, long)
14263 +#define FIOC_SETXFLG _IOW('x', 6, long)
14265 +#else /* _VX_INODE_H */
14266 +#warning duplicate inclusion
14267 +#endif /* _VX_INODE_H */
14268 diff -NurpP --minimal linux-3.1/include/linux/vserver/inode_cmd.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/inode_cmd.h
14269 --- linux-3.1/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
14270 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/inode_cmd.h 2011-10-24 18:53:33.000000000 +0200
14272 +#ifndef _VX_INODE_CMD_H
14273 +#define _VX_INODE_CMD_H
14276 +/* inode vserver commands */
14278 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
14279 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
14281 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
14282 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
14284 +struct vcmd_ctx_iattr_v1 {
14285 + const char __user *name;
14291 +struct vcmd_ctx_fiattr_v0 {
14301 +#ifdef CONFIG_COMPAT
14303 +#include <asm/compat.h>
14305 +struct vcmd_ctx_iattr_v1_x32 {
14306 + compat_uptr_t name_ptr;
14312 +#endif /* CONFIG_COMPAT */
14314 +#include <linux/compiler.h>
14316 +extern int vc_get_iattr(void __user *);
14317 +extern int vc_set_iattr(void __user *);
14319 +extern int vc_fget_iattr(uint32_t, void __user *);
14320 +extern int vc_fset_iattr(uint32_t, void __user *);
14322 +#ifdef CONFIG_COMPAT
14324 +extern int vc_get_iattr_x32(void __user *);
14325 +extern int vc_set_iattr_x32(void __user *);
14327 +#endif /* CONFIG_COMPAT */
14329 +#endif /* __KERNEL__ */
14330 +#endif /* _VX_INODE_CMD_H */
14331 diff -NurpP --minimal linux-3.1/include/linux/vserver/limit.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/limit.h
14332 --- linux-3.1/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
14333 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/limit.h 2011-10-24 18:53:33.000000000 +0200
14335 +#ifndef _VX_LIMIT_H
14336 +#define _VX_LIMIT_H
14338 +#define VLIMIT_NSOCK 16
14339 +#define VLIMIT_OPENFD 17
14340 +#define VLIMIT_ANON 18
14341 +#define VLIMIT_SHMEM 19
14342 +#define VLIMIT_SEMARY 20
14343 +#define VLIMIT_NSEMS 21
14344 +#define VLIMIT_DENTRY 22
14345 +#define VLIMIT_MAPPED 23
14350 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
14352 +/* keep in sync with CRLIM_INFINITY */
14354 +#define VLIM_INFINITY (~0ULL)
14356 +#include <asm/atomic.h>
14357 +#include <asm/resource.h>
14359 +#ifndef RLIM_INFINITY
14360 +#warning RLIM_INFINITY is undefined
14363 +#define __rlim_val(l, r, v) ((l)->res[r].v)
14365 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
14366 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
14368 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
14369 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
14370 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
14372 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
14373 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
14375 +typedef atomic_long_t rlim_atomic_t;
14376 +typedef unsigned long rlim_t;
14378 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
14379 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
14380 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
14381 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
14382 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
14383 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
14386 +#if (RLIM_INFINITY == VLIM_INFINITY)
14387 +#define VX_VLIM(r) ((long long)(long)(r))
14388 +#define VX_RLIM(v) ((rlim_t)(v))
14390 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
14391 + ? VLIM_INFINITY : (long long)(r))
14392 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
14393 + ? RLIM_INFINITY : (rlim_t)(v))
14398 +void vx_vsi_meminfo(struct sysinfo *);
14399 +void vx_vsi_swapinfo(struct sysinfo *);
14400 +long vx_vsi_cached(struct sysinfo *);
14402 +#define NUM_LIMITS 24
14404 +#endif /* __KERNEL__ */
14405 +#endif /* _VX_LIMIT_H */
14406 diff -NurpP --minimal linux-3.1/include/linux/vserver/limit_cmd.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/limit_cmd.h
14407 --- linux-3.1/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
14408 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/limit_cmd.h 2011-10-24 18:53:33.000000000 +0200
14410 +#ifndef _VX_LIMIT_CMD_H
14411 +#define _VX_LIMIT_CMD_H
14414 +/* rlimit vserver commands */
14416 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
14417 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
14418 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
14419 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
14420 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
14422 +struct vcmd_ctx_rlimit_v0 {
14424 + uint64_t minimum;
14425 + uint64_t softlimit;
14426 + uint64_t maximum;
14429 +struct vcmd_ctx_rlimit_mask_v0 {
14430 + uint32_t minimum;
14431 + uint32_t softlimit;
14432 + uint32_t maximum;
14435 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
14437 +struct vcmd_rlimit_stat_v0 {
14441 + uint64_t minimum;
14442 + uint64_t maximum;
14445 +#define CRLIM_UNSET (0ULL)
14446 +#define CRLIM_INFINITY (~0ULL)
14447 +#define CRLIM_KEEP (~1ULL)
14451 +#ifdef CONFIG_IA32_EMULATION
14453 +struct vcmd_ctx_rlimit_v0_x32 {
14455 + uint64_t minimum;
14456 + uint64_t softlimit;
14457 + uint64_t maximum;
14458 +} __attribute__ ((packed));
14460 +#endif /* CONFIG_IA32_EMULATION */
14462 +#include <linux/compiler.h>
14464 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
14465 +extern int vc_get_rlimit(struct vx_info *, void __user *);
14466 +extern int vc_set_rlimit(struct vx_info *, void __user *);
14467 +extern int vc_reset_hits(struct vx_info *, void __user *);
14468 +extern int vc_reset_minmax(struct vx_info *, void __user *);
14470 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
14472 +#ifdef CONFIG_IA32_EMULATION
14474 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
14475 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
14477 +#endif /* CONFIG_IA32_EMULATION */
14479 +#endif /* __KERNEL__ */
14480 +#endif /* _VX_LIMIT_CMD_H */
14481 diff -NurpP --minimal linux-3.1/include/linux/vserver/limit_def.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/limit_def.h
14482 --- linux-3.1/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
14483 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/limit_def.h 2011-10-24 18:53:33.000000000 +0200
14485 +#ifndef _VX_LIMIT_DEF_H
14486 +#define _VX_LIMIT_DEF_H
14488 +#include <asm/atomic.h>
14489 +#include <asm/resource.h>
14491 +#include "limit.h"
14494 +struct _vx_res_limit {
14495 + rlim_t soft; /* Context soft limit */
14496 + rlim_t hard; /* Context hard limit */
14498 + rlim_atomic_t rcur; /* Current value */
14499 + rlim_t rmin; /* Context minimum */
14500 + rlim_t rmax; /* Context maximum */
14502 + atomic_t lhit; /* Limit hits */
14505 +/* context sub struct */
14507 +struct _vx_limit {
14508 + struct _vx_res_limit res[NUM_LIMITS];
14511 +#ifdef CONFIG_VSERVER_DEBUG
14513 +static inline void __dump_vx_limit(struct _vx_limit *limit)
14517 + printk("\t_vx_limit:");
14518 + for (i = 0; i < NUM_LIMITS; i++) {
14519 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
14520 + i, (unsigned long)__rlim_get(limit, i),
14521 + (unsigned long)__rlim_rmin(limit, i),
14522 + (unsigned long)__rlim_rmax(limit, i),
14523 + (long)__rlim_soft(limit, i),
14524 + (long)__rlim_hard(limit, i),
14525 + atomic_read(&__rlim_lhit(limit, i)));
14531 +#endif /* _VX_LIMIT_DEF_H */
14532 diff -NurpP --minimal linux-3.1/include/linux/vserver/limit_int.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/limit_int.h
14533 --- linux-3.1/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
14534 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/limit_int.h 2011-10-24 18:53:33.000000000 +0200
14536 +#ifndef _VX_LIMIT_INT_H
14537 +#define _VX_LIMIT_INT_H
14539 +#include "context.h"
14543 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
14544 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
14546 +extern const char *vlimit_name[NUM_LIMITS];
14548 +static inline void __vx_acc_cres(struct vx_info *vxi,
14549 + int res, int dir, void *_data, char *_file, int _line)
14551 + if (VXD_RCRES_COND(res))
14552 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
14553 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
14554 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
14555 + (dir > 0) ? "++" : "--", _data, _file, _line);
14560 + __rlim_inc(&vxi->limit, res);
14562 + __rlim_dec(&vxi->limit, res);
14565 +static inline void __vx_add_cres(struct vx_info *vxi,
14566 + int res, int amount, void *_data, char *_file, int _line)
14568 + if (VXD_RCRES_COND(res))
14569 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
14570 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
14571 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
14572 + amount, _data, _file, _line);
14577 + __rlim_add(&vxi->limit, res, amount);
14581 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
14583 + int cond = (value > __rlim_rmax(limit, res));
14586 + __rlim_rmax(limit, res) = value;
14591 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
14593 + int cond = (value < __rlim_rmin(limit, res));
14596 + __rlim_rmin(limit, res) = value;
14601 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
14603 + if (!__vx_cres_adjust_max(limit, res, value))
14604 + __vx_cres_adjust_min(limit, res, value);
14609 + +1 ... no limit hit
14610 + -1 ... over soft limit
14611 + 0 ... over hard limit */
14613 +static inline int __vx_cres_avail(struct vx_info *vxi,
14614 + int res, int num, char *_file, int _line)
14616 + struct _vx_limit *limit;
14619 + if (VXD_RLIMIT_COND(res))
14620 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
14621 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
14622 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
14623 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
14624 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
14625 + num, _file, _line);
14629 + limit = &vxi->limit;
14630 + value = __rlim_get(limit, res);
14632 + if (!__vx_cres_adjust_max(limit, res, value))
14633 + __vx_cres_adjust_min(limit, res, value);
14638 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
14640 + if (value + num <= __rlim_soft(limit, res))
14643 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
14645 + if (value + num <= __rlim_hard(limit, res))
14648 + __rlim_hit(limit, res);
14653 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
14656 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
14658 + rlim_t value, sum = 0;
14661 + while ((res = *array++)) {
14662 + value = __rlim_get(limit, res);
14663 + __vx_cres_fixup(limit, res, value);
14670 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
14672 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
14673 + int res = *array;
14675 + if (value == __rlim_get(limit, res))
14678 + __rlim_set(limit, res, value);
14679 + /* now adjust min/max */
14680 + if (!__vx_cres_adjust_max(limit, res, value))
14681 + __vx_cres_adjust_min(limit, res, value);
14686 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
14687 + const int *array, int num, char *_file, int _line)
14689 + struct _vx_limit *limit;
14690 + rlim_t value = 0;
14698 + limit = &vxi->limit;
14700 + value = __vx_cres_array_sum(limit, array + 1);
14702 + __rlim_set(limit, res, value);
14703 + __vx_cres_fixup(limit, res, value);
14705 + return __vx_cres_avail(vxi, res, num, _file, _line);
14709 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
14714 + /* complex resources first */
14715 + if ((id < 0) || (id == RLIMIT_RSS))
14716 + __vx_cres_array_fixup(limit, VLA_RSS);
14718 + for (res = 0; res < NUM_LIMITS; res++) {
14719 + if ((id > 0) && (res != id))
14722 + value = __rlim_get(limit, res);
14723 + __vx_cres_fixup(limit, res, value);
14725 + /* not supposed to happen, maybe warn? */
14726 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
14727 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
14732 +#endif /* __KERNEL__ */
14733 +#endif /* _VX_LIMIT_INT_H */
14734 diff -NurpP --minimal linux-3.1/include/linux/vserver/monitor.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/monitor.h
14735 --- linux-3.1/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
14736 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/monitor.h 2011-10-24 18:53:33.000000000 +0200
14738 +#ifndef _VX_MONITOR_H
14739 +#define _VX_MONITOR_H
14741 +#include <linux/types.h>
14748 + VXM_UPDATE = 0x20,
14752 + VXM_RQINFO_1 = 0x24,
14755 + VXM_ACTIVATE = 0x40,
14762 + VXM_MIGRATE = 0x48,
14765 + /* all other bits are flags */
14766 + VXM_SCHED = 0x80,
14769 +struct _vxm_update_1 {
14770 + uint32_t tokens_max;
14771 + uint32_t fill_rate;
14772 + uint32_t interval;
14775 +struct _vxm_update_2 {
14776 + uint32_t tokens_min;
14777 + uint32_t fill_rate;
14778 + uint32_t interval;
14781 +struct _vxm_rqinfo_1 {
14782 + uint16_t running;
14786 + uint32_t idle_tokens;
14789 +struct _vxm_rqinfo_2 {
14790 + uint32_t norm_time;
14791 + uint32_t idle_time;
14792 + uint32_t idle_skip;
14795 +struct _vxm_sched {
14797 + uint32_t norm_time;
14798 + uint32_t idle_time;
14801 +struct _vxm_task {
14806 +struct _vxm_event {
14815 + struct _vxm_task tsk;
14819 +struct _vx_mon_entry {
14823 + struct _vxm_event ev;
14824 + struct _vxm_sched sd;
14825 + struct _vxm_update_1 u1;
14826 + struct _vxm_update_2 u2;
14827 + struct _vxm_rqinfo_1 q1;
14828 + struct _vxm_rqinfo_2 q2;
14833 +#endif /* _VX_MONITOR_H */
14834 diff -NurpP --minimal linux-3.1/include/linux/vserver/network.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/network.h
14835 --- linux-3.1/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
14836 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/network.h 2011-10-24 18:53:33.000000000 +0200
14838 +#ifndef _VX_NETWORK_H
14839 +#define _VX_NETWORK_H
14841 +#include <linux/types.h>
14844 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
14847 +/* network flags */
14849 +#define NXF_INFO_PRIVATE 0x00000008
14851 +#define NXF_SINGLE_IP 0x00000100
14852 +#define NXF_LBACK_REMAP 0x00000200
14853 +#define NXF_LBACK_ALLOW 0x00000400
14855 +#define NXF_HIDE_NETIF 0x02000000
14856 +#define NXF_HIDE_LBACK 0x04000000
14858 +#define NXF_STATE_SETUP (1ULL << 32)
14859 +#define NXF_STATE_ADMIN (1ULL << 34)
14861 +#define NXF_SC_HELPER (1ULL << 36)
14862 +#define NXF_PERSISTENT (1ULL << 38)
14864 +#define NXF_ONE_TIME (0x0005ULL << 32)
14867 +#define NXF_INIT_SET (__nxf_init_set())
14869 +static inline uint64_t __nxf_init_set(void) {
14870 + return NXF_STATE_ADMIN
14871 +#ifdef CONFIG_VSERVER_AUTO_LBACK
14872 + | NXF_LBACK_REMAP
14875 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
14878 + | NXF_HIDE_NETIF;
14882 +/* network caps */
14884 +#define NXC_TUN_CREATE 0x00000001
14886 +#define NXC_RAW_ICMP 0x00000100
14888 +#define NXC_MULTICAST 0x00001000
14891 +/* address types */
14893 +#define NXA_TYPE_IPV4 0x0001
14894 +#define NXA_TYPE_IPV6 0x0002
14896 +#define NXA_TYPE_NONE 0x0000
14897 +#define NXA_TYPE_ANY 0x00FF
14899 +#define NXA_TYPE_ADDR 0x0010
14900 +#define NXA_TYPE_MASK 0x0020
14901 +#define NXA_TYPE_RANGE 0x0040
14903 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
14905 +#define NXA_MOD_BCAST 0x0100
14906 +#define NXA_MOD_LBACK 0x0200
14908 +#define NXA_LOOPBACK 0x1000
14910 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
14911 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
14915 +#include <linux/list.h>
14916 +#include <linux/spinlock.h>
14917 +#include <linux/rcupdate.h>
14918 +#include <linux/in.h>
14919 +#include <linux/in6.h>
14920 +#include <asm/atomic.h>
14922 +struct nx_addr_v4 {
14923 + struct nx_addr_v4 *next;
14924 + struct in_addr ip[2];
14925 + struct in_addr mask;
14930 +struct nx_addr_v6 {
14931 + struct nx_addr_v6 *next;
14932 + struct in6_addr ip;
14933 + struct in6_addr mask;
14940 + struct hlist_node nx_hlist; /* linked list of nxinfos */
14941 + nid_t nx_id; /* vnet id */
14942 + atomic_t nx_usecnt; /* usage count */
14943 + atomic_t nx_tasks; /* tasks count */
14944 + int nx_state; /* context state */
14946 + uint64_t nx_flags; /* network flag word */
14947 + uint64_t nx_ncaps; /* network capabilities */
14949 + struct in_addr v4_lback; /* Loopback address */
14950 + struct in_addr v4_bcast; /* Broadcast address */
14951 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
14952 +#ifdef CONFIG_IPV6
14953 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
14955 + char nx_name[65]; /* network context name */
14959 +/* status flags */
14961 +#define NXS_HASHED 0x0001
14962 +#define NXS_SHUTDOWN 0x0100
14963 +#define NXS_RELEASED 0x8000
14965 +extern struct nx_info *lookup_nx_info(int);
14967 +extern int get_nid_list(int, unsigned int *, int);
14968 +extern int nid_is_hashed(nid_t);
14970 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
14972 +extern long vs_net_change(struct nx_info *, unsigned int);
14977 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
14978 +#ifdef CONFIG_IPV6
14979 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
14981 +#define NX_IPV6(n) (0)
14984 +#endif /* __KERNEL__ */
14985 +#endif /* _VX_NETWORK_H */
14986 diff -NurpP --minimal linux-3.1/include/linux/vserver/network_cmd.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/network_cmd.h
14987 --- linux-3.1/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
14988 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/network_cmd.h 2011-10-24 18:53:33.000000000 +0200
14990 +#ifndef _VX_NETWORK_CMD_H
14991 +#define _VX_NETWORK_CMD_H
14994 +/* vinfo commands */
14996 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
14999 +extern int vc_task_nid(uint32_t);
15001 +#endif /* __KERNEL__ */
15003 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
15005 +struct vcmd_nx_info_v0 {
15007 + /* more to come */
15011 +extern int vc_nx_info(struct nx_info *, void __user *);
15013 +#endif /* __KERNEL__ */
15015 +#include <linux/in.h>
15016 +#include <linux/in6.h>
15018 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
15019 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
15021 +struct vcmd_net_create {
15022 + uint64_t flagword;
15025 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
15027 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
15028 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
15030 +struct vcmd_net_addr_v0 {
15033 + struct in_addr ip[4];
15034 + struct in_addr mask[4];
15037 +#define VCMD_net_add_ipv4_v1 VC_CMD(NETALT, 1, 1)
15038 +#define VCMD_net_rem_ipv4_v1 VC_CMD(NETALT, 2, 1)
15040 +struct vcmd_net_addr_ipv4_v1 {
15043 + struct in_addr ip;
15044 + struct in_addr mask;
15047 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 2)
15048 +#define VCMD_net_rem_ipv4 VC_CMD(NETALT, 2, 2)
15050 +struct vcmd_net_addr_ipv4_v2 {
15053 + struct in_addr ip;
15054 + struct in_addr ip2;
15055 + struct in_addr mask;
15058 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
15059 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
15061 +struct vcmd_net_addr_ipv6_v1 {
15065 + struct in6_addr ip;
15066 + struct in6_addr mask;
15069 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
15070 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
15072 +struct vcmd_match_ipv4_v0 {
15077 + struct in_addr ip;
15078 + struct in_addr ip2;
15079 + struct in_addr mask;
15082 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
15083 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
15085 +struct vcmd_match_ipv6_v0 {
15090 + struct in6_addr ip;
15091 + struct in6_addr ip2;
15092 + struct in6_addr mask;
15097 +extern int vc_net_create(uint32_t, void __user *);
15098 +extern int vc_net_migrate(struct nx_info *, void __user *);
15100 +extern int vc_net_add(struct nx_info *, void __user *);
15101 +extern int vc_net_remove(struct nx_info *, void __user *);
15103 +extern int vc_net_add_ipv4_v1(struct nx_info *, void __user *);
15104 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
15106 +extern int vc_net_rem_ipv4_v1(struct nx_info *, void __user *);
15107 +extern int vc_net_rem_ipv4(struct nx_info *, void __user *);
15109 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
15110 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
15112 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
15113 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
15115 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
15116 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
15118 +#endif /* __KERNEL__ */
15121 +/* flag commands */
15123 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
15124 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
15126 +struct vcmd_net_flags_v0 {
15127 + uint64_t flagword;
15132 +extern int vc_get_nflags(struct nx_info *, void __user *);
15133 +extern int vc_set_nflags(struct nx_info *, void __user *);
15135 +#endif /* __KERNEL__ */
15138 +/* network caps commands */
15140 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
15141 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
15143 +struct vcmd_net_caps_v0 {
15149 +extern int vc_get_ncaps(struct nx_info *, void __user *);
15150 +extern int vc_set_ncaps(struct nx_info *, void __user *);
15152 +#endif /* __KERNEL__ */
15153 +#endif /* _VX_CONTEXT_CMD_H */
15154 diff -NurpP --minimal linux-3.1/include/linux/vserver/percpu.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/percpu.h
15155 --- linux-3.1/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
15156 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/percpu.h 2011-10-24 18:53:33.000000000 +0200
15158 +#ifndef _VX_PERCPU_H
15159 +#define _VX_PERCPU_H
15161 +#include "cvirt_def.h"
15162 +#include "sched_def.h"
15164 +struct _vx_percpu {
15165 + struct _vx_cvirt_pc cvirt;
15166 + struct _vx_sched_pc sched;
15169 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
15171 +#endif /* _VX_PERCPU_H */
15172 diff -NurpP --minimal linux-3.1/include/linux/vserver/pid.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/pid.h
15173 --- linux-3.1/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
15174 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/pid.h 2011-10-24 18:53:33.000000000 +0200
15176 +#ifndef _VSERVER_PID_H
15177 +#define _VSERVER_PID_H
15179 +/* pid faking stuff */
15181 +#define vx_info_map_pid(v, p) \
15182 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
15183 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
15184 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
15185 +#define vx_map_tgid(p) vx_map_pid(p)
15187 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
15188 + const char *func, const char *file, int line)
15190 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
15191 + vxfprintk(VXD_CBIT(cvirt, 2),
15192 + "vx_map_tgid: %p/%llx: %d -> %d",
15193 + vxi, (long long)vxi->vx_flags, pid,
15194 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
15195 + func, file, line);
15198 + if (pid == vxi->vx_initpid)
15204 +#define vx_info_rmap_pid(v, p) \
15205 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
15206 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
15207 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
15209 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
15210 + const char *func, const char *file, int line)
15212 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
15213 + vxfprintk(VXD_CBIT(cvirt, 2),
15214 + "vx_rmap_tgid: %p/%llx: %d -> %d",
15215 + vxi, (long long)vxi->vx_flags, pid,
15216 + (pid == 1) ? vxi->vx_initpid : pid,
15217 + func, file, line);
15218 + if ((pid == 1) && vxi->vx_initpid)
15219 + return vxi->vx_initpid;
15220 + if (pid == vxi->vx_initpid)
15227 diff -NurpP --minimal linux-3.1/include/linux/vserver/sched.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/sched.h
15228 --- linux-3.1/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
15229 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/sched.h 2011-10-24 18:53:33.000000000 +0200
15231 +#ifndef _VX_SCHED_H
15232 +#define _VX_SCHED_H
15239 +void vx_vsi_uptime(struct timespec *, struct timespec *);
15244 +void vx_update_load(struct vx_info *);
15247 +void vx_update_sched_param(struct _vx_sched *sched,
15248 + struct _vx_sched_pc *sched_pc);
15250 +#endif /* __KERNEL__ */
15251 +#else /* _VX_SCHED_H */
15252 +#warning duplicate inclusion
15253 +#endif /* _VX_SCHED_H */
15254 diff -NurpP --minimal linux-3.1/include/linux/vserver/sched_cmd.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/sched_cmd.h
15255 --- linux-3.1/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
15256 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/sched_cmd.h 2011-10-24 18:53:33.000000000 +0200
15258 +#ifndef _VX_SCHED_CMD_H
15259 +#define _VX_SCHED_CMD_H
15262 +struct vcmd_prio_bias {
15264 + int32_t prio_bias;
15267 +#define VCMD_set_prio_bias VC_CMD(SCHED, 4, 0)
15268 +#define VCMD_get_prio_bias VC_CMD(SCHED, 5, 0)
15272 +#include <linux/compiler.h>
15274 +extern int vc_set_prio_bias(struct vx_info *, void __user *);
15275 +extern int vc_get_prio_bias(struct vx_info *, void __user *);
15277 +#endif /* __KERNEL__ */
15278 +#endif /* _VX_SCHED_CMD_H */
15279 diff -NurpP --minimal linux-3.1/include/linux/vserver/sched_def.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/sched_def.h
15280 --- linux-3.1/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
15281 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/sched_def.h 2011-10-24 18:53:33.000000000 +0200
15283 +#ifndef _VX_SCHED_DEF_H
15284 +#define _VX_SCHED_DEF_H
15286 +#include <linux/spinlock.h>
15287 +#include <linux/jiffies.h>
15288 +#include <linux/cpumask.h>
15289 +#include <asm/atomic.h>
15290 +#include <asm/param.h>
15293 +/* context sub struct */
15295 +struct _vx_sched {
15296 + int prio_bias; /* bias offset for priority */
15298 + cpumask_t update; /* CPUs which should update */
15301 +struct _vx_sched_pc {
15302 + int prio_bias; /* bias offset for priority */
15304 + uint64_t user_ticks; /* token tick events */
15305 + uint64_t sys_ticks; /* token tick events */
15306 + uint64_t hold_ticks; /* token ticks paused */
15310 +#ifdef CONFIG_VSERVER_DEBUG
15312 +static inline void __dump_vx_sched(struct _vx_sched *sched)
15314 + printk("\t_vx_sched:\n");
15315 + printk("\t priority = %4d\n", sched->prio_bias);
15320 +#endif /* _VX_SCHED_DEF_H */
15321 diff -NurpP --minimal linux-3.1/include/linux/vserver/signal.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/signal.h
15322 --- linux-3.1/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
15323 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/signal.h 2011-10-24 18:53:33.000000000 +0200
15325 +#ifndef _VX_SIGNAL_H
15326 +#define _VX_SIGNAL_H
15333 +int vx_info_kill(struct vx_info *, int, int);
15335 +#endif /* __KERNEL__ */
15336 +#else /* _VX_SIGNAL_H */
15337 +#warning duplicate inclusion
15338 +#endif /* _VX_SIGNAL_H */
15339 diff -NurpP --minimal linux-3.1/include/linux/vserver/signal_cmd.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/signal_cmd.h
15340 --- linux-3.1/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
15341 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/signal_cmd.h 2011-10-24 18:53:33.000000000 +0200
15343 +#ifndef _VX_SIGNAL_CMD_H
15344 +#define _VX_SIGNAL_CMD_H
15347 +/* signalling vserver commands */
15349 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
15350 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
15352 +struct vcmd_ctx_kill_v0 {
15357 +struct vcmd_wait_exit_v0 {
15358 + int32_t reboot_cmd;
15359 + int32_t exit_code;
15364 +extern int vc_ctx_kill(struct vx_info *, void __user *);
15365 +extern int vc_wait_exit(struct vx_info *, void __user *);
15367 +#endif /* __KERNEL__ */
15369 +/* process alteration commands */
15371 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
15372 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
15374 +struct vcmd_pflags_v0 {
15375 + uint32_t flagword;
15381 +extern int vc_get_pflags(uint32_t pid, void __user *);
15382 +extern int vc_set_pflags(uint32_t pid, void __user *);
15384 +#endif /* __KERNEL__ */
15385 +#endif /* _VX_SIGNAL_CMD_H */
15386 diff -NurpP --minimal linux-3.1/include/linux/vserver/space.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/space.h
15387 --- linux-3.1/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
15388 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/space.h 2011-10-24 18:53:33.000000000 +0200
15390 +#ifndef _VX_SPACE_H
15391 +#define _VX_SPACE_H
15393 +#include <linux/types.h>
15397 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
15399 +#else /* _VX_SPACE_H */
15400 +#warning duplicate inclusion
15401 +#endif /* _VX_SPACE_H */
15402 diff -NurpP --minimal linux-3.1/include/linux/vserver/space_cmd.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/space_cmd.h
15403 --- linux-3.1/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
15404 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/space_cmd.h 2011-10-24 18:53:33.000000000 +0200
15406 +#ifndef _VX_SPACE_CMD_H
15407 +#define _VX_SPACE_CMD_H
15410 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
15411 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
15412 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
15414 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
15415 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
15416 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
15418 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
15420 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
15421 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
15424 +struct vcmd_space_mask_v1 {
15428 +struct vcmd_space_mask_v2 {
15436 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
15437 +extern int vc_set_space_v1(struct vx_info *, void __user *);
15438 +extern int vc_enter_space(struct vx_info *, void __user *);
15439 +extern int vc_set_space(struct vx_info *, void __user *);
15440 +extern int vc_get_space_mask(void __user *, int);
15442 +#endif /* __KERNEL__ */
15443 +#endif /* _VX_SPACE_CMD_H */
15444 diff -NurpP --minimal linux-3.1/include/linux/vserver/switch.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/switch.h
15445 --- linux-3.1/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
15446 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/switch.h 2011-10-24 18:53:33.000000000 +0200
15448 +#ifndef _VX_SWITCH_H
15449 +#define _VX_SWITCH_H
15451 +#include <linux/types.h>
15454 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
15455 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
15456 +#define VC_VERSION(c) ((c) & 0xFFF)
15458 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
15459 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
15463 + Syscall Matrix V2.8
15465 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
15466 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
15467 + |INFO |SETUP | |MOVE | | | | | |
15468 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15469 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
15470 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
15471 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15472 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
15473 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
15474 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15475 + MEMORY | | | | |MEMCTRL| | |SWAP | |
15476 + | 16| 17| 18| 19| 20| 21| | 22| 23|
15477 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15478 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
15479 + | 24| 25| 26| 27| 28| 29| | 30| 31|
15480 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15481 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
15482 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
15483 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15484 + OTHER |VSTAT | | | | | | |VINFO | |
15485 + | 40| 41| 42| 43| 44| 45| | 46| 47|
15486 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
15487 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
15488 + | 48| 49| 50| 51| 52| 53| | 54| 55|
15489 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15490 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
15491 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
15492 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15496 +#define VC_CAT_VERSION 0
15498 +#define VC_CAT_VSETUP 1
15499 +#define VC_CAT_VHOST 2
15501 +#define VC_CAT_DEVICE 6
15503 +#define VC_CAT_VPROC 9
15504 +#define VC_CAT_PROCALT 10
15505 +#define VC_CAT_PROCMIG 11
15506 +#define VC_CAT_PROCTRL 12
15508 +#define VC_CAT_SCHED 14
15509 +#define VC_CAT_MEMCTRL 20
15511 +#define VC_CAT_VNET 25
15512 +#define VC_CAT_NETALT 26
15513 +#define VC_CAT_NETMIG 27
15514 +#define VC_CAT_NETCTRL 28
15516 +#define VC_CAT_TAGMIG 35
15517 +#define VC_CAT_DLIMIT 36
15518 +#define VC_CAT_INODE 38
15520 +#define VC_CAT_VSTAT 40
15521 +#define VC_CAT_VINFO 46
15522 +#define VC_CAT_EVENT 48
15524 +#define VC_CAT_FLAGS 52
15525 +#define VC_CAT_VSPACE 54
15526 +#define VC_CAT_DEBUG 56
15527 +#define VC_CAT_RLIMIT 60
15529 +#define VC_CAT_SYSTEST 61
15530 +#define VC_CAT_COMPAT 63
15532 +/* query version */
15534 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
15535 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
15540 +#include <linux/errno.h>
15542 +#endif /* __KERNEL__ */
15544 +#endif /* _VX_SWITCH_H */
15546 diff -NurpP --minimal linux-3.1/include/linux/vserver/tag.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/tag.h
15547 --- linux-3.1/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
15548 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/tag.h 2011-10-24 18:53:33.000000000 +0200
15553 +#include <linux/types.h>
15556 +#define DX_TAG(in) (IS_TAGGED(in))
15559 +#ifdef CONFIG_TAG_NFSD
15560 +#define DX_TAG_NFSD 1
15562 +#define DX_TAG_NFSD 0
15566 +#ifdef CONFIG_TAGGING_NONE
15568 +#define MAX_UID 0xFFFFFFFF
15569 +#define MAX_GID 0xFFFFFFFF
15571 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
15573 +#define TAGINO_UID(cond, uid, tag) (uid)
15574 +#define TAGINO_GID(cond, gid, tag) (gid)
15579 +#ifdef CONFIG_TAGGING_GID16
15581 +#define MAX_UID 0xFFFFFFFF
15582 +#define MAX_GID 0x0000FFFF
15584 +#define INOTAG_TAG(cond, uid, gid, tag) \
15585 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
15587 +#define TAGINO_UID(cond, uid, tag) (uid)
15588 +#define TAGINO_GID(cond, gid, tag) \
15589 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
15594 +#ifdef CONFIG_TAGGING_ID24
15596 +#define MAX_UID 0x00FFFFFF
15597 +#define MAX_GID 0x00FFFFFF
15599 +#define INOTAG_TAG(cond, uid, gid, tag) \
15600 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
15602 +#define TAGINO_UID(cond, uid, tag) \
15603 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
15604 +#define TAGINO_GID(cond, gid, tag) \
15605 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
15610 +#ifdef CONFIG_TAGGING_UID16
15612 +#define MAX_UID 0x0000FFFF
15613 +#define MAX_GID 0xFFFFFFFF
15615 +#define INOTAG_TAG(cond, uid, gid, tag) \
15616 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
15618 +#define TAGINO_UID(cond, uid, tag) \
15619 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
15620 +#define TAGINO_GID(cond, gid, tag) (gid)
15625 +#ifdef CONFIG_TAGGING_INTERN
15627 +#define MAX_UID 0xFFFFFFFF
15628 +#define MAX_GID 0xFFFFFFFF
15630 +#define INOTAG_TAG(cond, uid, gid, tag) \
15631 + ((cond) ? (tag) : 0)
15633 +#define TAGINO_UID(cond, uid, tag) (uid)
15634 +#define TAGINO_GID(cond, gid, tag) (gid)
15639 +#ifndef CONFIG_TAGGING_NONE
15640 +#define dx_current_fstag(sb) \
15641 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
15643 +#define dx_current_fstag(sb) (0)
15646 +#ifndef CONFIG_TAGGING_INTERN
15647 +#define TAGINO_TAG(cond, tag) (0)
15649 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
15652 +#define INOTAG_UID(cond, uid, gid) \
15653 + ((cond) ? ((uid) & MAX_UID) : (uid))
15654 +#define INOTAG_GID(cond, uid, gid) \
15655 + ((cond) ? ((gid) & MAX_GID) : (gid))
15658 +static inline uid_t dx_map_uid(uid_t uid)
15660 + if ((uid > MAX_UID) && (uid != -1))
15662 + return (uid & MAX_UID);
15665 +static inline gid_t dx_map_gid(gid_t gid)
15667 + if ((gid > MAX_GID) && (gid != -1))
15669 + return (gid & MAX_GID);
15677 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
15679 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
15680 + unsigned long *flags);
15682 +#ifdef CONFIG_PROPAGATE
15684 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
15686 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
15689 +#define dx_propagate_tag(n, i) do { } while (0)
15692 +#endif /* _DX_TAG_H */
15693 diff -NurpP --minimal linux-3.1/include/linux/vserver/tag_cmd.h linux-3.1-vs2.3.1-rc2/include/linux/vserver/tag_cmd.h
15694 --- linux-3.1/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
15695 +++ linux-3.1-vs2.3.1-rc2/include/linux/vserver/tag_cmd.h 2011-10-24 18:53:33.000000000 +0200
15697 +#ifndef _VX_TAG_CMD_H
15698 +#define _VX_TAG_CMD_H
15701 +/* vinfo commands */
15703 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
15706 +extern int vc_task_tag(uint32_t);
15708 +#endif /* __KERNEL__ */
15710 +/* context commands */
15712 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
15715 +extern int vc_tag_migrate(uint32_t);
15717 +#endif /* __KERNEL__ */
15718 +#endif /* _VX_TAG_CMD_H */
15719 diff -NurpP --minimal linux-3.1/include/net/addrconf.h linux-3.1-vs2.3.1-rc2/include/net/addrconf.h
15720 --- linux-3.1/include/net/addrconf.h 2011-07-22 11:18:11.000000000 +0200
15721 +++ linux-3.1-vs2.3.1-rc2/include/net/addrconf.h 2011-10-24 18:53:33.000000000 +0200
15722 @@ -80,7 +80,8 @@ extern int ipv6_dev_get_saddr(struct n
15723 struct net_device *dev,
15724 const struct in6_addr *daddr,
15725 unsigned int srcprefs,
15726 - struct in6_addr *saddr);
15727 + struct in6_addr *saddr,
15728 + struct nx_info *nxi);
15729 extern int ipv6_get_lladdr(struct net_device *dev,
15730 struct in6_addr *addr,
15731 unsigned char banned_flags);
15732 diff -NurpP --minimal linux-3.1/include/net/af_unix.h linux-3.1-vs2.3.1-rc2/include/net/af_unix.h
15733 --- linux-3.1/include/net/af_unix.h 2011-07-22 11:18:11.000000000 +0200
15734 +++ linux-3.1-vs2.3.1-rc2/include/net/af_unix.h 2011-10-24 18:53:33.000000000 +0200
15736 #include <linux/socket.h>
15737 #include <linux/un.h>
15738 #include <linux/mutex.h>
15739 +#include <linux/vs_base.h>
15740 #include <net/sock.h>
15742 extern void unix_inflight(struct file *fp);
15743 diff -NurpP --minimal linux-3.1/include/net/inet_timewait_sock.h linux-3.1-vs2.3.1-rc2/include/net/inet_timewait_sock.h
15744 --- linux-3.1/include/net/inet_timewait_sock.h 2011-10-24 18:45:32.000000000 +0200
15745 +++ linux-3.1-vs2.3.1-rc2/include/net/inet_timewait_sock.h 2011-10-24 18:53:33.000000000 +0200
15746 @@ -113,6 +113,10 @@ struct inet_timewait_sock {
15747 #define tw_net __tw_common.skc_net
15748 #define tw_daddr __tw_common.skc_daddr
15749 #define tw_rcv_saddr __tw_common.skc_rcv_saddr
15750 +#define tw_xid __tw_common.skc_xid
15751 +#define tw_vx_info __tw_common.skc_vx_info
15752 +#define tw_nid __tw_common.skc_nid
15753 +#define tw_nx_info __tw_common.skc_nx_info
15755 volatile unsigned char tw_substate;
15756 unsigned char tw_rcv_wscale;
15757 diff -NurpP --minimal linux-3.1/include/net/ip6_route.h linux-3.1-vs2.3.1-rc2/include/net/ip6_route.h
15758 --- linux-3.1/include/net/ip6_route.h 2011-07-22 11:18:11.000000000 +0200
15759 +++ linux-3.1-vs2.3.1-rc2/include/net/ip6_route.h 2011-10-24 18:53:33.000000000 +0200
15760 @@ -86,7 +86,8 @@ extern int ip6_route_get_saddr(struct
15761 struct rt6_info *rt,
15762 const struct in6_addr *daddr,
15763 unsigned int prefs,
15764 - struct in6_addr *saddr);
15765 + struct in6_addr *saddr,
15766 + struct nx_info *nxi);
15768 extern struct rt6_info *rt6_lookup(struct net *net,
15769 const struct in6_addr *daddr,
15770 diff -NurpP --minimal linux-3.1/include/net/route.h linux-3.1-vs2.3.1-rc2/include/net/route.h
15771 --- linux-3.1/include/net/route.h 2011-07-22 11:18:11.000000000 +0200
15772 +++ linux-3.1-vs2.3.1-rc2/include/net/route.h 2011-10-24 18:53:33.000000000 +0200
15773 @@ -202,6 +202,9 @@ static inline void ip_rt_put(struct rtab
15774 dst_release(&rt->dst);
15777 +#include <linux/vs_base.h>
15778 +#include <linux/vs_inet.h>
15780 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
15782 extern const __u8 ip_tos2prio[16];
15783 @@ -253,6 +256,9 @@ static inline void ip_route_connect_init
15784 protocol, flow_flags, dst, src, dport, sport);
15787 +extern struct rtable *ip_v4_find_src(struct net *net, struct nx_info *,
15788 + struct flowi4 *);
15790 static inline struct rtable *ip_route_connect(struct flowi4 *fl4,
15791 __be32 dst, __be32 src, u32 tos,
15792 int oif, u8 protocol,
15793 @@ -261,11 +267,25 @@ static inline struct rtable *ip_route_co
15795 struct net *net = sock_net(sk);
15797 + struct nx_info *nx_info = current_nx_info();
15799 ip_route_connect_init(fl4, dst, src, tos, oif, protocol,
15800 sport, dport, sk, can_sleep);
15802 - if (!dst || !src) {
15804 + nx_info = sk->sk_nx_info;
15806 + vxdprintk(VXD_CBIT(net, 4),
15807 + "ip_route_connect(%p) %p,%p;%lx",
15808 + sk, nx_info, sk->sk_socket,
15809 + (sk->sk_socket?sk->sk_socket->flags:0));
15811 + rt = ip_v4_find_src(net, nx_info, fl4);
15816 + if (!fl4->daddr || !fl4->saddr) {
15817 rt = __ip_route_output_key(net, fl4);
15820 diff -NurpP --minimal linux-3.1/include/net/sock.h linux-3.1-vs2.3.1-rc2/include/net/sock.h
15821 --- linux-3.1/include/net/sock.h 2011-10-24 18:45:32.000000000 +0200
15822 +++ linux-3.1-vs2.3.1-rc2/include/net/sock.h 2011-10-24 18:53:33.000000000 +0200
15823 @@ -150,6 +150,10 @@ struct sock_common {
15824 #ifdef CONFIG_NET_NS
15825 struct net *skc_net;
15828 + struct vx_info *skc_vx_info;
15830 + struct nx_info *skc_nx_info;
15832 * fields between dontcopy_begin/dontcopy_end
15833 * are not copied in sock_copy()
15834 @@ -257,6 +261,10 @@ struct sock {
15835 #define sk_bind_node __sk_common.skc_bind_node
15836 #define sk_prot __sk_common.skc_prot
15837 #define sk_net __sk_common.skc_net
15838 +#define sk_xid __sk_common.skc_xid
15839 +#define sk_vx_info __sk_common.skc_vx_info
15840 +#define sk_nid __sk_common.skc_nid
15841 +#define sk_nx_info __sk_common.skc_nx_info
15842 socket_lock_t sk_lock;
15843 struct sk_buff_head sk_receive_queue;
15845 diff -NurpP --minimal linux-3.1/init/Kconfig linux-3.1-vs2.3.1-rc2/init/Kconfig
15846 --- linux-3.1/init/Kconfig 2011-10-24 18:45:33.000000000 +0200
15847 +++ linux-3.1-vs2.3.1-rc2/init/Kconfig 2011-10-24 18:53:33.000000000 +0200
15848 @@ -574,6 +574,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
15850 boolean "Control Group support"
15854 This option adds support for grouping sets of processes together, for
15855 use with process control subsystems such as Cpusets, CFS, memory
15856 @@ -790,6 +791,7 @@ config IPC_NS
15858 bool "User namespace (EXPERIMENTAL)"
15859 depends on EXPERIMENTAL
15860 + depends on VSERVER_DISABLED
15863 This allows containers, i.e. vservers, to use user namespaces
15864 diff -NurpP --minimal linux-3.1/init/main.c linux-3.1-vs2.3.1-rc2/init/main.c
15865 --- linux-3.1/init/main.c 2011-10-24 18:45:33.000000000 +0200
15866 +++ linux-3.1-vs2.3.1-rc2/init/main.c 2011-10-24 18:53:33.000000000 +0200
15868 #include <linux/shmem_fs.h>
15869 #include <linux/slab.h>
15870 #include <linux/perf_event.h>
15871 +#include <linux/vserver/percpu.h>
15873 #include <asm/io.h>
15874 #include <asm/bugs.h>
15875 diff -NurpP --minimal linux-3.1/ipc/mqueue.c linux-3.1-vs2.3.1-rc2/ipc/mqueue.c
15876 --- linux-3.1/ipc/mqueue.c 2011-10-24 18:45:33.000000000 +0200
15877 +++ linux-3.1-vs2.3.1-rc2/ipc/mqueue.c 2011-10-24 18:53:33.000000000 +0200
15879 #include <linux/pid.h>
15880 #include <linux/ipc_namespace.h>
15881 #include <linux/slab.h>
15882 +#include <linux/vs_context.h>
15883 +#include <linux/vs_limit.h>
15885 #include <net/sock.h>
15887 @@ -66,6 +68,7 @@ struct mqueue_inode_info {
15888 struct sigevent notify;
15889 struct pid* notify_owner;
15890 struct user_struct *user; /* user who created, for accounting */
15891 + struct vx_info *vxi;
15892 struct sock *notify_sock;
15893 struct sk_buff *notify_cookie;
15895 @@ -128,6 +131,7 @@ static struct inode *mqueue_get_inode(st
15896 if (S_ISREG(mode)) {
15897 struct mqueue_inode_info *info;
15898 struct task_struct *p = current;
15899 + struct vx_info *vxi = p->vx_info;
15900 unsigned long mq_bytes, mq_msg_tblsz;
15902 inode->i_fop = &mqueue_file_operations;
15903 @@ -141,6 +145,7 @@ static struct inode *mqueue_get_inode(st
15904 info->notify_owner = NULL;
15906 info->user = NULL; /* set when all is ok */
15907 + info->vxi = NULL;
15908 memset(&info->attr, 0, sizeof(info->attr));
15909 info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
15910 info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
15911 @@ -158,17 +163,20 @@ static struct inode *mqueue_get_inode(st
15913 spin_lock(&mq_lock);
15914 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
15915 - u->mq_bytes + mq_bytes > task_rlimit(p, RLIMIT_MSGQUEUE)) {
15916 + u->mq_bytes + mq_bytes > task_rlimit(p, RLIMIT_MSGQUEUE) ||
15917 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
15918 spin_unlock(&mq_lock);
15919 /* mqueue_evict_inode() releases info->messages */
15923 u->mq_bytes += mq_bytes;
15924 + vx_ipcmsg_add(vxi, u, mq_bytes);
15925 spin_unlock(&mq_lock);
15928 info->user = get_uid(u);
15929 + info->vxi = get_vx_info(vxi);
15930 } else if (S_ISDIR(mode)) {
15932 /* Some things misbehave if size == 0 on a directory */
15933 @@ -278,8 +286,11 @@ static void mqueue_evict_inode(struct in
15934 + info->attr.mq_msgsize);
15937 + struct vx_info *vxi = info->vxi;
15939 spin_lock(&mq_lock);
15940 user->mq_bytes -= mq_bytes;
15941 + vx_ipcmsg_sub(vxi, user, mq_bytes);
15943 * get_ns_from_inode() ensures that the
15944 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
15945 @@ -289,6 +300,7 @@ static void mqueue_evict_inode(struct in
15947 ipc_ns->mq_queues_count--;
15948 spin_unlock(&mq_lock);
15949 + put_vx_info(vxi);
15953 diff -NurpP --minimal linux-3.1/ipc/msg.c linux-3.1-vs2.3.1-rc2/ipc/msg.c
15954 --- linux-3.1/ipc/msg.c 2011-05-22 16:17:59.000000000 +0200
15955 +++ linux-3.1-vs2.3.1-rc2/ipc/msg.c 2011-10-24 18:53:33.000000000 +0200
15957 #include <linux/rwsem.h>
15958 #include <linux/nsproxy.h>
15959 #include <linux/ipc_namespace.h>
15960 +#include <linux/vs_base.h>
15962 #include <asm/current.h>
15963 #include <asm/uaccess.h>
15964 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
15966 msq->q_perm.mode = msgflg & S_IRWXUGO;
15967 msq->q_perm.key = key;
15968 + msq->q_perm.xid = vx_current_xid();
15970 msq->q_perm.security = NULL;
15971 retval = security_msg_queue_alloc(msq);
15972 diff -NurpP --minimal linux-3.1/ipc/namespace.c linux-3.1-vs2.3.1-rc2/ipc/namespace.c
15973 --- linux-3.1/ipc/namespace.c 2011-07-22 11:18:12.000000000 +0200
15974 +++ linux-3.1-vs2.3.1-rc2/ipc/namespace.c 2011-10-24 18:53:33.000000000 +0200
15975 @@ -13,11 +13,12 @@
15976 #include <linux/mount.h>
15977 #include <linux/user_namespace.h>
15978 #include <linux/proc_fs.h>
15979 +#include <linux/vs_base.h>
15980 +#include <linux/vserver/global.h>
15984 -static struct ipc_namespace *create_ipc_ns(struct task_struct *tsk,
15985 - struct ipc_namespace *old_ns)
15986 +static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns)
15988 struct ipc_namespace *ns;
15990 @@ -46,19 +47,18 @@ static struct ipc_namespace *create_ipc_
15991 ipcns_notify(IPCNS_CREATED);
15992 register_ipcns_notifier(ns);
15994 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
15995 + ns->user_ns = get_user_ns(user_ns);
16000 struct ipc_namespace *copy_ipcs(unsigned long flags,
16001 - struct task_struct *tsk)
16002 + struct ipc_namespace *old_ns,
16003 + struct user_namespace *user_ns)
16005 - struct ipc_namespace *ns = tsk->nsproxy->ipc_ns;
16007 if (!(flags & CLONE_NEWIPC))
16008 - return get_ipc_ns(ns);
16009 - return create_ipc_ns(tsk, ns);
16010 + return get_ipc_ns(old_ns);
16011 + return create_ipc_ns(user_ns);
16015 diff -NurpP --minimal linux-3.1/ipc/sem.c linux-3.1-vs2.3.1-rc2/ipc/sem.c
16016 --- linux-3.1/ipc/sem.c 2011-10-24 18:45:33.000000000 +0200
16017 +++ linux-3.1-vs2.3.1-rc2/ipc/sem.c 2011-10-24 18:53:33.000000000 +0200
16019 #include <linux/rwsem.h>
16020 #include <linux/nsproxy.h>
16021 #include <linux/ipc_namespace.h>
16022 +#include <linux/vs_base.h>
16023 +#include <linux/vs_limit.h>
16025 #include <asm/uaccess.h>
16027 @@ -260,6 +262,7 @@ static int newary(struct ipc_namespace *
16029 sma->sem_perm.mode = (semflg & S_IRWXUGO);
16030 sma->sem_perm.key = key;
16031 + sma->sem_perm.xid = vx_current_xid();
16033 sma->sem_perm.security = NULL;
16034 retval = security_sem_alloc(sma);
16035 @@ -275,6 +278,9 @@ static int newary(struct ipc_namespace *
16038 ns->used_sems += nsems;
16039 + /* FIXME: obsoleted? */
16040 + vx_semary_inc(sma);
16041 + vx_nsems_add(sma, nsems);
16043 sma->sem_base = (struct sem *) &sma[1];
16045 @@ -724,6 +730,9 @@ static void freeary(struct ipc_namespace
16047 wake_up_sem_queue_do(&tasks);
16048 ns->used_sems -= sma->sem_nsems;
16049 + /* FIXME: obsoleted? */
16050 + vx_nsems_sub(sma, sma->sem_nsems);
16051 + vx_semary_dec(sma);
16052 security_sem_free(sma);
16053 ipc_rcu_putref(sma);
16055 diff -NurpP --minimal linux-3.1/ipc/shm.c linux-3.1-vs2.3.1-rc2/ipc/shm.c
16056 --- linux-3.1/ipc/shm.c 2011-10-24 18:45:33.000000000 +0200
16057 +++ linux-3.1-vs2.3.1-rc2/ipc/shm.c 2011-10-24 18:53:33.000000000 +0200
16059 #include <linux/nsproxy.h>
16060 #include <linux/mount.h>
16061 #include <linux/ipc_namespace.h>
16062 +#include <linux/vs_context.h>
16063 +#include <linux/vs_limit.h>
16065 #include <asm/uaccess.h>
16067 @@ -187,7 +189,12 @@ static void shm_open(struct vm_area_stru
16069 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
16071 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
16072 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
16073 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
16075 + vx_ipcshm_sub(vxi, shp, numpages);
16076 + ns->shm_tot -= numpages;
16080 if (!is_file_hugepages(shp->shm_file))
16081 @@ -197,6 +204,7 @@ static void shm_destroy(struct ipc_names
16083 fput (shp->shm_file);
16084 security_shm_free(shp);
16085 + put_vx_info(vxi);
16086 ipc_rcu_putref(shp);
16089 @@ -462,11 +470,15 @@ static int newseg(struct ipc_namespace *
16090 if (ns->shm_tot + numpages > ns->shm_ctlall)
16093 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
16096 shp = ipc_rcu_alloc(sizeof(*shp));
16100 shp->shm_perm.key = key;
16101 + shp->shm_perm.xid = vx_current_xid();
16102 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
16103 shp->mlock_user = NULL;
16105 @@ -521,6 +533,7 @@ static int newseg(struct ipc_namespace *
16106 ns->shm_tot += numpages;
16107 error = shp->shm_perm.id;
16109 + vx_ipcshm_add(current_vx_info(), key, numpages);
16113 diff -NurpP --minimal linux-3.1/kernel/Makefile linux-3.1-vs2.3.1-rc2/kernel/Makefile
16114 --- linux-3.1/kernel/Makefile 2011-10-24 18:45:33.000000000 +0200
16115 +++ linux-3.1-vs2.3.1-rc2/kernel/Makefile 2011-10-24 18:53:33.000000000 +0200
16116 @@ -24,6 +24,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
16117 CFLAGS_REMOVE_irq_work.o = -pg
16121 obj-$(CONFIG_FREEZER) += freezer.o
16122 obj-$(CONFIG_PROFILING) += profile.o
16123 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
16124 diff -NurpP --minimal linux-3.1/kernel/capability.c linux-3.1-vs2.3.1-rc2/kernel/capability.c
16125 --- linux-3.1/kernel/capability.c 2011-07-22 11:18:12.000000000 +0200
16126 +++ linux-3.1-vs2.3.1-rc2/kernel/capability.c 2011-10-24 18:53:33.000000000 +0200
16128 #include <linux/syscalls.h>
16129 #include <linux/pid_namespace.h>
16130 #include <linux/user_namespace.h>
16131 +#include <linux/vs_context.h>
16132 #include <asm/uaccess.h>
16135 @@ -116,6 +117,7 @@ static int cap_validate_magic(cap_user_h
16141 * The only thing that can change the capabilities of the current
16142 * process is the current process. As such, we can't be in this code
16143 @@ -340,6 +342,8 @@ bool has_capability_noaudit(struct task_
16147 +#include <linux/vserver/base.h>
16150 * capable - Determine if the current task has a superior capability in effect
16151 * @cap: The capability to be tested for
16152 @@ -374,6 +378,9 @@ bool ns_capable(struct user_namespace *n
16156 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
16159 if (security_capable(ns, current_cred(), cap) == 0) {
16160 current->flags |= PF_SUPERPRIV;
16162 diff -NurpP --minimal linux-3.1/kernel/compat.c linux-3.1-vs2.3.1-rc2/kernel/compat.c
16163 --- linux-3.1/kernel/compat.c 2011-10-24 18:45:33.000000000 +0200
16164 +++ linux-3.1-vs2.3.1-rc2/kernel/compat.c 2011-10-24 18:53:33.000000000 +0200
16165 @@ -972,7 +972,7 @@ asmlinkage long compat_sys_stime(compat_
16169 - do_settimeofday(&tv);
16170 + vx_settimeofday(&tv);
16174 diff -NurpP --minimal linux-3.1/kernel/cred.c linux-3.1-vs2.3.1-rc2/kernel/cred.c
16175 --- linux-3.1/kernel/cred.c 2011-10-24 18:45:33.000000000 +0200
16176 +++ linux-3.1-vs2.3.1-rc2/kernel/cred.c 2011-10-24 18:53:33.000000000 +0200
16177 @@ -61,31 +61,6 @@ struct cred init_cred = {
16181 -static inline void set_cred_subscribers(struct cred *cred, int n)
16183 -#ifdef CONFIG_DEBUG_CREDENTIALS
16184 - atomic_set(&cred->subscribers, n);
16188 -static inline int read_cred_subscribers(const struct cred *cred)
16190 -#ifdef CONFIG_DEBUG_CREDENTIALS
16191 - return atomic_read(&cred->subscribers);
16197 -static inline void alter_cred_subscribers(const struct cred *_cred, int n)
16199 -#ifdef CONFIG_DEBUG_CREDENTIALS
16200 - struct cred *cred = (struct cred *) _cred;
16202 - atomic_add(n, &cred->subscribers);
16207 * Dispose of the shared task group credentials
16209 @@ -281,21 +256,16 @@ error:
16211 * Call commit_creds() or abort_creds() to clean up.
16213 -struct cred *prepare_creds(void)
16214 +struct cred *__prepare_creds(const struct cred *old)
16216 - struct task_struct *task = current;
16217 - const struct cred *old;
16220 - validate_process_creds();
16222 new = kmem_cache_alloc(cred_jar, GFP_KERNEL);
16226 kdebug("prepare_creds() alloc %p", new);
16228 - old = task->cred;
16229 memcpy(new, old, sizeof(struct cred));
16231 atomic_set(&new->usage, 1);
16232 @@ -322,6 +292,13 @@ error:
16237 +struct cred *prepare_creds(void)
16239 + validate_process_creds();
16241 + return __prepare_creds(current->cred);
16243 EXPORT_SYMBOL(prepare_creds);
16246 diff -NurpP --minimal linux-3.1/kernel/exit.c linux-3.1-vs2.3.1-rc2/kernel/exit.c
16247 --- linux-3.1/kernel/exit.c 2011-10-24 18:45:33.000000000 +0200
16248 +++ linux-3.1-vs2.3.1-rc2/kernel/exit.c 2011-10-24 18:53:33.000000000 +0200
16250 #include <linux/fs_struct.h>
16251 #include <linux/init_task.h>
16252 #include <linux/perf_event.h>
16253 +#include <linux/vs_limit.h>
16254 +#include <linux/vs_context.h>
16255 +#include <linux/vs_network.h>
16256 +#include <linux/vs_pid.h>
16257 #include <trace/events/sched.h>
16258 #include <linux/hw_breakpoint.h>
16259 #include <linux/oom.h>
16260 @@ -480,9 +484,11 @@ static void close_files(struct files_str
16261 filp_close(file, files);
16264 + vx_openfd_dec(i);
16272 @@ -1038,11 +1044,16 @@ NORET_TYPE void do_exit(long code)
16274 validate_creds_for_do_exit(tsk);
16276 + /* needs to stay after exit_notify() */
16277 + exit_vx_info(tsk, code);
16278 + exit_nx_info(tsk);
16282 /* causes final put_task_struct in finish_task_switch(). */
16283 tsk->state = TASK_DEAD;
16285 + printk("bad task: %p [%lx]\n", current, current->state);
16287 /* Avoid "noreturn function does return". */
16289 diff -NurpP --minimal linux-3.1/kernel/fork.c linux-3.1-vs2.3.1-rc2/kernel/fork.c
16290 --- linux-3.1/kernel/fork.c 2011-10-24 18:45:33.000000000 +0200
16291 +++ linux-3.1-vs2.3.1-rc2/kernel/fork.c 2011-10-24 18:53:33.000000000 +0200
16293 #include <linux/user-return-notifier.h>
16294 #include <linux/oom.h>
16295 #include <linux/khugepaged.h>
16296 +#include <linux/vs_context.h>
16297 +#include <linux/vs_network.h>
16298 +#include <linux/vs_limit.h>
16299 +#include <linux/vs_memory.h>
16301 #include <asm/pgtable.h>
16302 #include <asm/pgalloc.h>
16303 @@ -166,6 +170,8 @@ void free_task(struct task_struct *tsk)
16304 account_kernel_stack(tsk->stack, -1);
16305 free_thread_info(tsk->stack);
16306 rt_mutex_debug_task_free(tsk);
16307 + clr_vx_info(&tsk->vx_info);
16308 + clr_nx_info(&tsk->nx_info);
16309 ftrace_graph_exit_task(tsk);
16310 free_task_struct(tsk);
16312 @@ -506,6 +512,7 @@ static struct mm_struct *mm_init(struct
16313 if (likely(!mm_alloc_pgd(mm))) {
16315 mmu_notifier_mm_init(mm);
16316 + set_vx_info(&mm->mm_vx_info, p->vx_info);
16320 @@ -543,6 +550,7 @@ void __mmdrop(struct mm_struct *mm)
16321 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
16322 VM_BUG_ON(mm->pmd_huge_pte);
16324 + clr_vx_info(&mm->mm_vx_info);
16327 EXPORT_SYMBOL_GPL(__mmdrop);
16328 @@ -730,6 +738,7 @@ struct mm_struct *dup_mm(struct task_str
16331 memcpy(mm, oldmm, sizeof(*mm));
16332 + mm->mm_vx_info = NULL;
16333 mm_init_cpumask(mm);
16335 /* Initializing for Swap token stuff */
16336 @@ -773,6 +782,7 @@ fail_nocontext:
16337 * If init_new_context() failed, we cannot use mmput() to free the mm
16338 * because it calls destroy_context()
16340 + clr_vx_info(&mm->mm_vx_info);
16344 @@ -1058,6 +1068,8 @@ static struct task_struct *copy_process(
16346 struct task_struct *p;
16347 int cgroup_callbacks_done = 0;
16348 + struct vx_info *vxi;
16349 + struct nx_info *nxi;
16351 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
16352 return ERR_PTR(-EINVAL);
16353 @@ -1104,7 +1116,12 @@ static struct task_struct *copy_process(
16354 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
16355 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
16357 + init_vx_info(&p->vx_info, current_vx_info());
16358 + init_nx_info(&p->nx_info, current_nx_info());
16361 + if (!vx_nproc_avail(1))
16362 + goto bad_fork_free;
16363 if (atomic_read(&p->real_cred->user->processes) >=
16364 task_rlimit(p, RLIMIT_NPROC)) {
16365 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
16366 @@ -1374,6 +1391,18 @@ static struct task_struct *copy_process(
16369 spin_unlock(¤t->sighand->siglock);
16371 + /* p is copy of current */
16372 + vxi = p->vx_info;
16374 + claim_vx_info(vxi, p);
16375 + atomic_inc(&vxi->cvirt.nr_threads);
16376 + atomic_inc(&vxi->cvirt.total_forks);
16379 + nxi = p->nx_info;
16381 + claim_nx_info(nxi, p);
16382 write_unlock_irq(&tasklist_lock);
16383 proc_fork_connector(p);
16384 cgroup_post_fork(p);
16385 diff -NurpP --minimal linux-3.1/kernel/kthread.c linux-3.1-vs2.3.1-rc2/kernel/kthread.c
16386 --- linux-3.1/kernel/kthread.c 2011-07-22 11:18:12.000000000 +0200
16387 +++ linux-3.1-vs2.3.1-rc2/kernel/kthread.c 2011-10-24 18:53:33.000000000 +0200
16389 #include <linux/mutex.h>
16390 #include <linux/slab.h>
16391 #include <linux/freezer.h>
16392 +#include <linux/vs_pid.h>
16393 #include <trace/events/sched.h>
16395 static DEFINE_SPINLOCK(kthread_create_lock);
16396 diff -NurpP --minimal linux-3.1/kernel/nsproxy.c linux-3.1-vs2.3.1-rc2/kernel/nsproxy.c
16397 --- linux-3.1/kernel/nsproxy.c 2011-10-24 18:45:33.000000000 +0200
16398 +++ linux-3.1-vs2.3.1-rc2/kernel/nsproxy.c 2011-10-24 18:53:33.000000000 +0200
16400 #include <linux/mnt_namespace.h>
16401 #include <linux/utsname.h>
16402 #include <linux/pid_namespace.h>
16403 +#include <linux/vserver/global.h>
16404 +#include <linux/vserver/debug.h>
16405 #include <net/net_namespace.h>
16406 #include <linux/ipc_namespace.h>
16407 #include <linux/proc_fs.h>
16408 @@ -46,8 +48,11 @@ static inline struct nsproxy *create_nsp
16409 struct nsproxy *nsproxy;
16411 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
16414 atomic_set(&nsproxy->count, 1);
16415 + atomic_inc(&vs_global_nsproxy);
16417 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
16421 @@ -56,8 +61,11 @@ static inline struct nsproxy *create_nsp
16422 * Return the newly created nsproxy. Do not attach this to the task,
16423 * leave it to the caller to do proper locking and attach it to task.
16425 -static struct nsproxy *create_new_namespaces(unsigned long flags,
16426 - struct task_struct *tsk, struct fs_struct *new_fs)
16427 +static struct nsproxy *unshare_namespaces(unsigned long flags,
16428 + struct nsproxy *orig,
16429 + struct fs_struct *new_fs,
16430 + struct user_namespace *new_user,
16431 + struct pid_namespace *new_pid)
16433 struct nsproxy *new_nsp;
16435 @@ -66,31 +74,31 @@ static struct nsproxy *create_new_namesp
16437 return ERR_PTR(-ENOMEM);
16439 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
16440 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
16441 if (IS_ERR(new_nsp->mnt_ns)) {
16442 err = PTR_ERR(new_nsp->mnt_ns);
16446 - new_nsp->uts_ns = copy_utsname(flags, tsk);
16447 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns, new_user);
16448 if (IS_ERR(new_nsp->uts_ns)) {
16449 err = PTR_ERR(new_nsp->uts_ns);
16453 - new_nsp->ipc_ns = copy_ipcs(flags, tsk);
16454 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns, new_user);
16455 if (IS_ERR(new_nsp->ipc_ns)) {
16456 err = PTR_ERR(new_nsp->ipc_ns);
16460 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
16461 + new_nsp->pid_ns = copy_pid_ns(flags, new_pid);
16462 if (IS_ERR(new_nsp->pid_ns)) {
16463 err = PTR_ERR(new_nsp->pid_ns);
16467 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
16468 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
16469 if (IS_ERR(new_nsp->net_ns)) {
16470 err = PTR_ERR(new_nsp->net_ns);
16472 @@ -115,6 +123,40 @@ out_ns:
16473 return ERR_PTR(err);
16476 +static struct nsproxy *create_new_namespaces(unsigned long flags,
16477 + struct task_struct *tsk, struct fs_struct *new_fs)
16479 + return unshare_namespaces(flags, tsk->nsproxy,
16480 + new_fs, task_cred_xxx(tsk, user)->user_ns,
16481 + task_active_pid_ns(tsk));
16485 + * copies the nsproxy, setting refcount to 1, and grabbing a
16486 + * reference to all contained namespaces.
16488 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
16490 + struct nsproxy *ns = create_nsproxy();
16493 + memcpy(ns, orig, sizeof(struct nsproxy));
16494 + atomic_set(&ns->count, 1);
16497 + get_mnt_ns(ns->mnt_ns);
16499 + get_uts_ns(ns->uts_ns);
16501 + get_ipc_ns(ns->ipc_ns);
16503 + get_pid_ns(ns->pid_ns);
16505 + get_net(ns->net_ns);
16511 * called from clone. This now handles copy for nsproxy and all
16512 * namespaces therein.
16513 @@ -122,9 +164,12 @@ out_ns:
16514 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
16516 struct nsproxy *old_ns = tsk->nsproxy;
16517 - struct nsproxy *new_ns;
16518 + struct nsproxy *new_ns = NULL;
16521 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
16522 + flags, tsk, old_ns);
16527 @@ -134,7 +179,7 @@ int copy_namespaces(unsigned long flags,
16528 CLONE_NEWPID | CLONE_NEWNET)))
16531 - if (!capable(CAP_SYS_ADMIN)) {
16532 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
16536 @@ -161,6 +206,9 @@ int copy_namespaces(unsigned long flags,
16539 put_nsproxy(old_ns);
16540 + vxdprintk(VXD_CBIT(space, 3),
16541 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
16542 + flags, tsk, old_ns, err, new_ns);
16546 @@ -174,7 +222,9 @@ void free_nsproxy(struct nsproxy *ns)
16547 put_ipc_ns(ns->ipc_ns);
16549 put_pid_ns(ns->pid_ns);
16550 - put_net(ns->net_ns);
16552 + put_net(ns->net_ns);
16553 + atomic_dec(&vs_global_nsproxy);
16554 kmem_cache_free(nsproxy_cachep, ns);
16557 @@ -187,11 +237,15 @@ int unshare_nsproxy_namespaces(unsigned
16561 + vxdprintk(VXD_CBIT(space, 4),
16562 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
16563 + unshare_flags, current->nsproxy);
16565 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
16569 - if (!capable(CAP_SYS_ADMIN))
16570 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
16573 *new_nsp = create_new_namespaces(unshare_flags, current,
16574 diff -NurpP --minimal linux-3.1/kernel/pid.c linux-3.1-vs2.3.1-rc2/kernel/pid.c
16575 --- linux-3.1/kernel/pid.c 2011-10-24 18:45:33.000000000 +0200
16576 +++ linux-3.1-vs2.3.1-rc2/kernel/pid.c 2011-10-24 18:53:33.000000000 +0200
16578 #include <linux/pid_namespace.h>
16579 #include <linux/init_task.h>
16580 #include <linux/syscalls.h>
16581 +#include <linux/vs_pid.h>
16583 #define pid_hashfn(nr, ns) \
16584 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
16585 @@ -342,7 +343,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
16587 struct pid *find_vpid(int nr)
16589 - return find_pid_ns(nr, current->nsproxy->pid_ns);
16590 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
16592 EXPORT_SYMBOL_GPL(find_vpid);
16594 @@ -402,6 +403,9 @@ void transfer_pid(struct task_struct *ol
16595 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
16597 struct task_struct *result = NULL;
16599 + if (type == PIDTYPE_REALPID)
16600 + type = PIDTYPE_PID;
16602 struct hlist_node *first;
16603 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]),
16604 @@ -419,7 +423,7 @@ EXPORT_SYMBOL(pid_task);
16605 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
16607 rcu_lockdep_assert(rcu_read_lock_held());
16608 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
16609 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
16612 struct task_struct *find_task_by_vpid(pid_t vnr)
16613 @@ -463,7 +467,7 @@ struct pid *find_get_pid(pid_t nr)
16615 EXPORT_SYMBOL_GPL(find_get_pid);
16617 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
16618 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
16622 @@ -476,6 +480,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
16626 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
16628 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
16631 pid_t pid_vnr(struct pid *pid)
16633 return pid_nr_ns(pid, current->nsproxy->pid_ns);
16634 diff -NurpP --minimal linux-3.1/kernel/pid_namespace.c linux-3.1-vs2.3.1-rc2/kernel/pid_namespace.c
16635 --- linux-3.1/kernel/pid_namespace.c 2011-05-22 16:17:59.000000000 +0200
16636 +++ linux-3.1-vs2.3.1-rc2/kernel/pid_namespace.c 2011-10-24 18:53:33.000000000 +0200
16638 #include <linux/acct.h>
16639 #include <linux/slab.h>
16640 #include <linux/proc_fs.h>
16641 +#include <linux/vserver/global.h>
16643 #define BITS_PER_PAGE (PAGE_SIZE*8)
16645 @@ -88,6 +89,7 @@ static struct pid_namespace *create_pid_
16648 kref_init(&ns->kref);
16649 + atomic_inc(&vs_global_pid_ns);
16651 ns->parent = get_pid_ns(parent_pid_ns);
16653 @@ -119,6 +121,7 @@ static void destroy_pid_namespace(struct
16655 for (i = 0; i < PIDMAP_ENTRIES; i++)
16656 kfree(ns->pidmap[i].page);
16657 + atomic_dec(&vs_global_pid_ns);
16658 kmem_cache_free(pid_ns_cachep, ns);
16661 diff -NurpP --minimal linux-3.1/kernel/posix-timers.c linux-3.1-vs2.3.1-rc2/kernel/posix-timers.c
16662 --- linux-3.1/kernel/posix-timers.c 2011-07-22 11:18:12.000000000 +0200
16663 +++ linux-3.1-vs2.3.1-rc2/kernel/posix-timers.c 2011-10-24 18:53:33.000000000 +0200
16665 #include <linux/wait.h>
16666 #include <linux/workqueue.h>
16667 #include <linux/module.h>
16668 +#include <linux/vs_context.h>
16671 * Management arrays for POSIX timers. Timers are kept in slab memory
16672 @@ -340,6 +341,7 @@ int posix_timer_event(struct k_itimer *t
16674 struct task_struct *task;
16675 int shared, ret = -1;
16678 * FIXME: if ->sigq is queued we can race with
16679 * dequeue_signal()->do_schedule_next_timer().
16680 @@ -356,10 +358,18 @@ int posix_timer_event(struct k_itimer *t
16682 task = pid_task(timr->it_pid, PIDTYPE_PID);
16684 + struct vx_info_save vxis;
16685 + struct vx_info *vxi;
16687 + vxi = get_vx_info(task->vx_info);
16688 + enter_vx_info(vxi, &vxis);
16689 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
16690 ret = send_sigqueue(timr->sigq, task, shared);
16691 + leave_vx_info(&vxis);
16692 + put_vx_info(vxi);
16696 /* If we failed to send the signal the timer stops. */
16699 diff -NurpP --minimal linux-3.1/kernel/printk.c linux-3.1-vs2.3.1-rc2/kernel/printk.c
16700 --- linux-3.1/kernel/printk.c 2011-10-24 18:45:33.000000000 +0200
16701 +++ linux-3.1-vs2.3.1-rc2/kernel/printk.c 2011-10-24 18:53:33.000000000 +0200
16703 #include <linux/cpu.h>
16704 #include <linux/notifier.h>
16705 #include <linux/rculist.h>
16706 +#include <linux/vs_cvirt.h>
16708 #include <asm/uaccess.h>
16710 @@ -314,7 +315,7 @@ static int check_syslog_permissions(int
16713 if (syslog_action_restricted(type)) {
16714 - if (capable(CAP_SYSLOG))
16715 + if (vx_capable(CAP_SYSLOG, VXC_SYSLOG))
16717 /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */
16718 if (capable(CAP_SYS_ADMIN)) {
16719 @@ -344,12 +345,9 @@ int do_syslog(int type, char __user *buf
16724 - case SYSLOG_ACTION_CLOSE: /* Close log */
16726 - case SYSLOG_ACTION_OPEN: /* Open log */
16728 - case SYSLOG_ACTION_READ: /* Read from log */
16729 + if ((type == SYSLOG_ACTION_READ) ||
16730 + (type == SYSLOG_ACTION_READ_ALL) ||
16731 + (type == SYSLOG_ACTION_READ_CLEAR)) {
16733 if (!buf || len < 0)
16735 @@ -360,6 +358,16 @@ int do_syslog(int type, char __user *buf
16740 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
16741 + return vx_do_syslog(type, buf, len);
16744 + case SYSLOG_ACTION_CLOSE: /* Close log */
16746 + case SYSLOG_ACTION_OPEN: /* Open log */
16748 + case SYSLOG_ACTION_READ: /* Read from log */
16749 error = wait_event_interruptible(log_wait,
16750 (log_start - log_end));
16752 @@ -386,16 +394,6 @@ int do_syslog(int type, char __user *buf
16754 /* Read last kernel messages */
16755 case SYSLOG_ACTION_READ_ALL:
16757 - if (!buf || len < 0)
16762 - if (!access_ok(VERIFY_WRITE, buf, len)) {
16767 if (count > log_buf_len)
16768 count = log_buf_len;
16769 diff -NurpP --minimal linux-3.1/kernel/ptrace.c linux-3.1-vs2.3.1-rc2/kernel/ptrace.c
16770 --- linux-3.1/kernel/ptrace.c 2011-10-24 18:45:33.000000000 +0200
16771 +++ linux-3.1-vs2.3.1-rc2/kernel/ptrace.c 2011-10-24 18:53:33.000000000 +0200
16773 #include <linux/syscalls.h>
16774 #include <linux/uaccess.h>
16775 #include <linux/regset.h>
16776 +#include <linux/vs_context.h>
16777 #include <linux/hw_breakpoint.h>
16778 #include <linux/cn_proc.h>
16780 @@ -198,6 +199,11 @@ ok:
16781 dumpable = get_dumpable(task->mm);
16782 if (!dumpable && !task_ns_capable(task, CAP_SYS_PTRACE))
16784 + if (!vx_check(task->xid, VS_ADMIN_P|VS_WATCH_P|VS_IDENT))
16786 + if (!vx_check(task->xid, VS_IDENT) &&
16787 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
16790 return security_ptrace_access_check(task, mode);
16792 diff -NurpP --minimal linux-3.1/kernel/sched.c linux-3.1-vs2.3.1-rc2/kernel/sched.c
16793 --- linux-3.1/kernel/sched.c 2011-10-24 18:45:33.000000000 +0200
16794 +++ linux-3.1-vs2.3.1-rc2/kernel/sched.c 2011-10-24 18:53:33.000000000 +0200
16796 #include <linux/ctype.h>
16797 #include <linux/ftrace.h>
16798 #include <linux/slab.h>
16799 +#include <linux/vs_sched.h>
16800 +#include <linux/vs_cvirt.h>
16802 #include <asm/tlb.h>
16803 #include <asm/irq_regs.h>
16804 @@ -3473,9 +3475,17 @@ static void calc_global_nohz(unsigned lo
16806 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
16808 - loads[0] = (avenrun[0] + offset) << shift;
16809 - loads[1] = (avenrun[1] + offset) << shift;
16810 - loads[2] = (avenrun[2] + offset) << shift;
16811 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
16812 + struct vx_info *vxi = current_vx_info();
16814 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
16815 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
16816 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
16818 + loads[0] = (avenrun[0] + offset) << shift;
16819 + loads[1] = (avenrun[1] + offset) << shift;
16820 + loads[2] = (avenrun[2] + offset) << shift;
16825 @@ -3734,16 +3744,19 @@ void account_user_time(struct task_struc
16826 cputime_t cputime_scaled)
16828 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
16829 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
16831 + int nice = (TASK_NICE(p) > 0);
16833 /* Add user time to process. */
16834 p->utime = cputime_add(p->utime, cputime);
16835 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
16836 + vx_account_user(vxi, cputime, nice);
16837 account_group_user_time(p, cputime);
16839 /* Add user time to cpustat. */
16840 tmp = cputime_to_cputime64(cputime);
16841 - if (TASK_NICE(p) > 0)
16843 cpustat->nice = cputime64_add(cpustat->nice, tmp);
16845 cpustat->user = cputime64_add(cpustat->user, tmp);
16846 @@ -3795,10 +3808,12 @@ void __account_system_time(struct task_s
16847 cputime_t cputime_scaled, cputime64_t *target_cputime64)
16849 cputime64_t tmp = cputime_to_cputime64(cputime);
16850 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
16852 /* Add system time to process. */
16853 p->stime = cputime_add(p->stime, cputime);
16854 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
16855 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
16856 account_group_system_time(p, cputime);
16858 /* Add system time to cpustat. */
16859 @@ -4984,7 +4999,7 @@ SYSCALL_DEFINE1(nice, int, increment)
16862 if (increment < 0 && !can_nice(current, nice))
16864 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
16866 retval = security_task_setnice(current, nice);
16868 diff -NurpP --minimal linux-3.1/kernel/sched_fair.c linux-3.1-vs2.3.1-rc2/kernel/sched_fair.c
16869 --- linux-3.1/kernel/sched_fair.c 2011-10-24 18:45:33.000000000 +0200
16870 +++ linux-3.1-vs2.3.1-rc2/kernel/sched_fair.c 2011-10-24 18:53:33.000000000 +0200
16871 @@ -979,6 +979,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
16872 __enqueue_entity(cfs_rq, se);
16875 + if (entity_is_task(se))
16876 + vx_activate_task(task_of(se));
16877 if (cfs_rq->nr_running == 1)
16878 list_add_leaf_cfs_rq(cfs_rq);
16880 @@ -1055,6 +1057,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
16881 if (se != cfs_rq->curr)
16882 __dequeue_entity(cfs_rq, se);
16884 + if (entity_is_task(se))
16885 + vx_deactivate_task(task_of(se));
16886 update_cfs_load(cfs_rq, 0);
16887 account_entity_dequeue(cfs_rq, se);
16889 diff -NurpP --minimal linux-3.1/kernel/signal.c linux-3.1-vs2.3.1-rc2/kernel/signal.c
16890 --- linux-3.1/kernel/signal.c 2011-10-24 18:45:33.000000000 +0200
16891 +++ linux-3.1-vs2.3.1-rc2/kernel/signal.c 2011-10-24 18:53:33.000000000 +0200
16893 #include <linux/freezer.h>
16894 #include <linux/pid_namespace.h>
16895 #include <linux/nsproxy.h>
16896 +#include <linux/vs_context.h>
16897 +#include <linux/vs_pid.h>
16898 #define CREATE_TRACE_POINTS
16899 #include <trace/events/signal.h>
16901 @@ -789,9 +791,18 @@ static int check_kill_permission(int sig
16905 + vxdprintk(VXD_CBIT(misc, 7),
16906 + "check_kill_permission(%d,%p,%p[#%u,%u])",
16907 + sig, info, t, vx_task_xid(t), t->pid);
16909 if (!valid_signal(sig))
16912 +/* FIXME: needed? if so, why?
16913 + if ((info != SEND_SIG_NOINFO) &&
16914 + (is_si_special(info) || !si_fromuser(info)))
16917 if (!si_fromuser(info))
16920 @@ -815,6 +826,20 @@ static int check_kill_permission(int sig
16925 + if (t->pid == 1 && current->xid)
16929 + /* FIXME: we shouldn't return ESRCH ever, to avoid
16930 + loops, maybe ENOENT or EACCES? */
16931 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
16932 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
16933 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
16934 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
16938 return security_task_kill(t, info, sig, 0);
16941 @@ -1319,7 +1344,7 @@ int kill_pid_info(int sig, struct siginf
16944 p = pid_task(pid, PIDTYPE_PID);
16946 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
16947 error = group_send_sig_info(sig, info, p);
16948 if (unlikely(error == -ESRCH))
16950 @@ -1358,7 +1383,7 @@ int kill_pid_info_as_uid(int sig, struct
16953 p = pid_task(pid, PIDTYPE_PID);
16955 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
16959 @@ -1413,8 +1438,10 @@ static int kill_something_info(int sig,
16960 struct task_struct * p;
16962 for_each_process(p) {
16963 - if (task_pid_vnr(p) > 1 &&
16964 - !same_thread_group(p, current)) {
16965 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
16966 + task_pid_vnr(p) > 1 &&
16967 + !same_thread_group(p, current) &&
16968 + !vx_current_initpid(p->pid)) {
16969 int err = group_send_sig_info(sig, info, p);
16972 @@ -2249,6 +2276,11 @@ relock:
16973 !sig_kernel_only(signr))
16976 + /* virtual init is protected against user signals */
16977 + if ((info->si_code == SI_USER) &&
16978 + vx_current_initpid(current->pid))
16981 if (sig_kernel_stop(signr)) {
16983 * The default action is to stop all threads in
16984 diff -NurpP --minimal linux-3.1/kernel/softirq.c linux-3.1-vs2.3.1-rc2/kernel/softirq.c
16985 --- linux-3.1/kernel/softirq.c 2011-07-22 11:18:12.000000000 +0200
16986 +++ linux-3.1-vs2.3.1-rc2/kernel/softirq.c 2011-10-24 18:53:33.000000000 +0200
16988 #include <linux/ftrace.h>
16989 #include <linux/smp.h>
16990 #include <linux/tick.h>
16991 +#include <linux/vs_context.h>
16993 #define CREATE_TRACE_POINTS
16994 #include <trace/events/irq.h>
16995 diff -NurpP --minimal linux-3.1/kernel/sys.c linux-3.1-vs2.3.1-rc2/kernel/sys.c
16996 --- linux-3.1/kernel/sys.c 2011-10-24 18:45:33.000000000 +0200
16997 +++ linux-3.1-vs2.3.1-rc2/kernel/sys.c 2011-10-24 18:53:33.000000000 +0200
16999 #include <linux/syscalls.h>
17000 #include <linux/kprobes.h>
17001 #include <linux/user_namespace.h>
17002 +#include <linux/vs_pid.h>
17004 #include <linux/kmsg_dump.h>
17005 /* Move somewhere else to avoid recompiling? */
17006 @@ -154,7 +155,10 @@ static int set_one_prio(struct task_stru
17009 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
17011 + if (vx_flags(VXF_IGNEG_NICE, 0))
17017 no_nice = security_task_setnice(p, niceval);
17018 @@ -204,6 +208,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
17020 pgrp = task_pgrp(current);
17021 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17022 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17024 error = set_one_prio(p, niceval, error);
17025 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
17027 @@ -267,6 +273,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
17029 pgrp = task_pgrp(current);
17030 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17031 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17033 niceval = 20 - task_nice(p);
17034 if (niceval > retval)
17036 @@ -417,6 +425,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
17038 static DEFINE_MUTEX(reboot_mutex);
17040 +long vs_reboot(unsigned int, void __user *);
17043 * Reboot system call: for obvious reasons only root may call it,
17044 * and even root needs to set up some magic numbers in the registers
17045 @@ -449,6 +459,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
17046 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
17047 cmd = LINUX_REBOOT_CMD_HALT;
17049 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
17050 + return vs_reboot(cmd, arg);
17052 mutex_lock(&reboot_mutex);
17054 case LINUX_REBOOT_CMD_RESTART:
17055 @@ -1272,7 +1285,8 @@ SYSCALL_DEFINE2(sethostname, char __user
17057 char tmp[__NEW_UTS_LEN];
17059 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
17060 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
17061 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17064 if (len < 0 || len > __NEW_UTS_LEN)
17065 @@ -1322,7 +1336,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
17067 char tmp[__NEW_UTS_LEN];
17069 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
17070 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
17071 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17073 if (len < 0 || len > __NEW_UTS_LEN)
17075 @@ -1440,7 +1455,7 @@ int do_prlimit(struct task_struct *tsk,
17076 /* Keep the capable check against init_user_ns until
17077 cgroups can contain all limits */
17078 if (new_rlim->rlim_max > rlim->rlim_max &&
17079 - !capable(CAP_SYS_RESOURCE))
17080 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
17083 retval = security_task_setrlimit(tsk->group_leader,
17084 @@ -1494,7 +1509,8 @@ static int check_prlimit_permission(stru
17085 cred->gid == tcred->sgid &&
17086 cred->gid == tcred->gid))
17088 - if (ns_capable(tcred->user->user_ns, CAP_SYS_RESOURCE))
17089 + if (vx_ns_capable(tcred->user->user_ns,
17090 + CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
17094 diff -NurpP --minimal linux-3.1/kernel/sysctl.c linux-3.1-vs2.3.1-rc2/kernel/sysctl.c
17095 --- linux-3.1/kernel/sysctl.c 2011-10-24 18:45:33.000000000 +0200
17096 +++ linux-3.1-vs2.3.1-rc2/kernel/sysctl.c 2011-10-24 18:53:33.000000000 +0200
17098 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
17099 #include <linux/lockdep.h>
17101 +extern char vshelper_path[];
17102 #ifdef CONFIG_CHR_DEV_SG
17103 #include <scsi/sg.h>
17105 @@ -568,6 +569,13 @@ static struct ctl_table kern_table[] = {
17106 .proc_handler = proc_dostring,
17110 + .procname = "vshelper",
17111 + .data = &vshelper_path,
17114 + .proc_handler = &proc_dostring,
17116 #ifdef CONFIG_CHR_DEV_SG
17118 .procname = "sg-big-buff",
17119 diff -NurpP --minimal linux-3.1/kernel/sysctl_binary.c linux-3.1-vs2.3.1-rc2/kernel/sysctl_binary.c
17120 --- linux-3.1/kernel/sysctl_binary.c 2011-10-24 18:45:33.000000000 +0200
17121 +++ linux-3.1-vs2.3.1-rc2/kernel/sysctl_binary.c 2011-10-24 18:53:33.000000000 +0200
17122 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
17124 { CTL_INT, KERN_PANIC, "panic" },
17125 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
17126 + { CTL_STR, KERN_VSHELPER, "vshelper" },
17128 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
17129 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
17130 diff -NurpP --minimal linux-3.1/kernel/time/timekeeping.c linux-3.1-vs2.3.1-rc2/kernel/time/timekeeping.c
17131 --- linux-3.1/kernel/time/timekeeping.c 2011-10-24 18:45:33.000000000 +0200
17132 +++ linux-3.1-vs2.3.1-rc2/kernel/time/timekeeping.c 2011-10-24 18:53:33.000000000 +0200
17133 @@ -233,6 +233,7 @@ void getnstimeofday(struct timespec *ts)
17134 } while (read_seqretry(&xtime_lock, seq));
17136 timespec_add_ns(ts, nsecs);
17137 + vx_adjust_timespec(ts);
17140 EXPORT_SYMBOL(getnstimeofday);
17141 diff -NurpP --minimal linux-3.1/kernel/time.c linux-3.1-vs2.3.1-rc2/kernel/time.c
17142 --- linux-3.1/kernel/time.c 2011-05-22 16:17:59.000000000 +0200
17143 +++ linux-3.1-vs2.3.1-rc2/kernel/time.c 2011-10-24 18:53:33.000000000 +0200
17144 @@ -92,7 +92,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
17148 - do_settimeofday(&tv);
17149 + vx_settimeofday(&tv);
17153 @@ -177,7 +177,7 @@ int do_sys_settimeofday(const struct tim
17154 /* SMP safe, again the code in arch/foo/time.c should
17155 * globally block out interrupts when it runs.
17157 - return do_settimeofday(tv);
17158 + return vx_settimeofday(tv);
17162 diff -NurpP --minimal linux-3.1/kernel/timer.c linux-3.1-vs2.3.1-rc2/kernel/timer.c
17163 --- linux-3.1/kernel/timer.c 2011-07-22 11:18:12.000000000 +0200
17164 +++ linux-3.1-vs2.3.1-rc2/kernel/timer.c 2011-10-24 18:53:33.000000000 +0200
17166 #include <linux/irq_work.h>
17167 #include <linux/sched.h>
17168 #include <linux/slab.h>
17169 +#include <linux/vs_base.h>
17170 +#include <linux/vs_cvirt.h>
17171 +#include <linux/vs_pid.h>
17172 +#include <linux/vserver/sched.h>
17174 #include <asm/uaccess.h>
17175 #include <asm/unistd.h>
17176 @@ -1336,12 +1340,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
17183 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
17184 - * should be moved into arch/i386 instead?
17188 * sys_getpid - return the thread group id of the current process
17189 @@ -1370,10 +1368,23 @@ SYSCALL_DEFINE0(getppid)
17191 pid = task_tgid_vnr(current->real_parent);
17193 + return vx_map_pid(pid);
17200 + * The Alpha uses getxpid, getxuid, and getxgid instead.
17203 +asmlinkage long do_getxpid(long *ppid)
17205 + *ppid = sys_getppid();
17206 + return sys_getpid();
17209 +#else /* _alpha_ */
17211 SYSCALL_DEFINE0(getuid)
17213 /* Only we change this so SMP safe */
17214 diff -NurpP --minimal linux-3.1/kernel/user_namespace.c linux-3.1-vs2.3.1-rc2/kernel/user_namespace.c
17215 --- linux-3.1/kernel/user_namespace.c 2011-03-15 18:07:42.000000000 +0100
17216 +++ linux-3.1-vs2.3.1-rc2/kernel/user_namespace.c 2011-10-24 18:53:33.000000000 +0200
17218 #include <linux/user_namespace.h>
17219 #include <linux/highuid.h>
17220 #include <linux/cred.h>
17221 +#include <linux/vserver/global.h>
17223 static struct kmem_cache *user_ns_cachep __read_mostly;
17225 @@ -33,6 +34,7 @@ int create_user_ns(struct cred *new)
17228 kref_init(&ns->kref);
17229 + atomic_inc(&vs_global_user_ns);
17231 for (n = 0; n < UIDHASH_SZ; ++n)
17232 INIT_HLIST_HEAD(ns->uidhash_table + n);
17233 @@ -81,6 +83,8 @@ void free_user_ns(struct kref *kref)
17234 struct user_namespace *ns =
17235 container_of(kref, struct user_namespace, kref);
17237 + /* FIXME: maybe move into destroyer? */
17238 + atomic_dec(&vs_global_user_ns);
17239 INIT_WORK(&ns->destroyer, free_user_ns_work);
17240 schedule_work(&ns->destroyer);
17242 diff -NurpP --minimal linux-3.1/kernel/utsname.c linux-3.1-vs2.3.1-rc2/kernel/utsname.c
17243 --- linux-3.1/kernel/utsname.c 2011-07-22 11:18:12.000000000 +0200
17244 +++ linux-3.1-vs2.3.1-rc2/kernel/utsname.c 2011-10-24 18:53:33.000000000 +0200
17245 @@ -16,14 +16,17 @@
17246 #include <linux/slab.h>
17247 #include <linux/user_namespace.h>
17248 #include <linux/proc_fs.h>
17249 +#include <linux/vserver/global.h>
17251 static struct uts_namespace *create_uts_ns(void)
17253 struct uts_namespace *uts_ns;
17255 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
17258 kref_init(&uts_ns->kref);
17259 + atomic_inc(&vs_global_uts_ns);
17264 @@ -32,8 +35,8 @@ static struct uts_namespace *create_uts_
17265 * @old_ns: namespace to clone
17266 * Return NULL on error (failure to kmalloc), new ns otherwise
17268 -static struct uts_namespace *clone_uts_ns(struct task_struct *tsk,
17269 - struct uts_namespace *old_ns)
17270 +static struct uts_namespace *clone_uts_ns(struct uts_namespace *old_ns,
17271 + struct user_namespace *old_user)
17273 struct uts_namespace *ns;
17275 @@ -43,7 +46,7 @@ static struct uts_namespace *clone_uts_n
17277 down_read(&uts_sem);
17278 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
17279 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
17280 + ns->user_ns = get_user_ns(old_user);
17284 @@ -55,9 +58,9 @@ static struct uts_namespace *clone_uts_n
17287 struct uts_namespace *copy_utsname(unsigned long flags,
17288 - struct task_struct *tsk)
17289 + struct uts_namespace *old_ns,
17290 + struct user_namespace *user_ns)
17292 - struct uts_namespace *old_ns = tsk->nsproxy->uts_ns;
17293 struct uts_namespace *new_ns;
17296 @@ -66,7 +69,7 @@ struct uts_namespace *copy_utsname(unsig
17297 if (!(flags & CLONE_NEWUTS))
17300 - new_ns = clone_uts_ns(tsk, old_ns);
17301 + new_ns = clone_uts_ns(old_ns, user_ns);
17303 put_uts_ns(old_ns);
17305 @@ -78,6 +81,7 @@ void free_uts_ns(struct kref *kref)
17307 ns = container_of(kref, struct uts_namespace, kref);
17308 put_user_ns(ns->user_ns);
17309 + atomic_dec(&vs_global_uts_ns);
17313 diff -NurpP --minimal linux-3.1/kernel/vserver/Kconfig linux-3.1-vs2.3.1-rc2/kernel/vserver/Kconfig
17314 --- linux-3.1/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
17315 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/Kconfig 2011-10-24 18:53:33.000000000 +0200
17318 +# Linux VServer configuration
17321 +menu "Linux VServer"
17323 +config VSERVER_AUTO_LBACK
17324 + bool "Automatically Assign Loopback IP"
17327 + Automatically assign a guest specific loopback
17328 + IP and add it to the kernel network stack on
17331 +config VSERVER_AUTO_SINGLE
17332 + bool "Automatic Single IP Special Casing"
17333 + depends on EXPERIMENTAL
17336 + This allows network contexts with a single IP to
17337 + automatically remap 0.0.0.0 bindings to that IP,
17338 + avoiding further network checks and improving
17341 + (note: such guests do not allow to change the ip
17342 + on the fly and do not show loopback addresses)
17344 +config VSERVER_COWBL
17345 + bool "Enable COW Immutable Link Breaking"
17348 + This enables the COW (Copy-On-Write) link break code.
17349 + It allows you to treat unified files like normal files
17350 + when writing to them (which will implicitely break the
17351 + link and create a copy of the unified file)
17353 +config VSERVER_VTIME
17354 + bool "Enable Virtualized Guest Time"
17355 + depends on EXPERIMENTAL
17358 + This enables per guest time offsets to allow for
17359 + adjusting the system clock individually per guest.
17360 + this adds some overhead to the time functions and
17361 + therefore should not be enabled without good reason.
17363 +config VSERVER_DEVICE
17364 + bool "Enable Guest Device Mapping"
17365 + depends on EXPERIMENTAL
17368 + This enables generic device remapping.
17370 +config VSERVER_PROC_SECURE
17371 + bool "Enable Proc Security"
17372 + depends on PROC_FS
17375 + This configures ProcFS security to initially hide
17376 + non-process entries for all contexts except the main and
17377 + spectator context (i.e. for all guests), which is a secure
17380 + (note: on 1.2x the entries were visible by default)
17383 + prompt "Persistent Inode Tagging"
17384 + default TAGGING_ID24
17386 + This adds persistent context information to filesystems
17387 + mounted with the tagxid option. Tagging is a requirement
17388 + for per-context disk limits and per-context quota.
17391 +config TAGGING_NONE
17394 + do not store per-context information in inodes.
17396 +config TAGGING_UID16
17397 + bool "UID16/GID32"
17399 + reduces UID to 16 bit, but leaves GID at 32 bit.
17401 +config TAGGING_GID16
17402 + bool "UID32/GID16"
17404 + reduces GID to 16 bit, but leaves UID at 32 bit.
17406 +config TAGGING_ID24
17407 + bool "UID24/GID24"
17409 + uses the upper 8bit from UID and GID for XID tagging
17410 + which leaves 24bit for UID/GID each, which should be
17411 + more than sufficient for normal use.
17413 +config TAGGING_INTERN
17414 + bool "UID32/GID32"
17416 + this uses otherwise reserved inode fields in the on
17417 + disk representation, which limits the use to a few
17418 + filesystems (currently ext2 and ext3)
17423 + bool "Tag NFSD User Auth and Files"
17426 + Enable this if you do want the in-kernel NFS
17427 + Server to use the tagging specified above.
17428 + (will require patched clients too)
17430 +config VSERVER_PRIVACY
17431 + bool "Honor Privacy Aspects of Guests"
17434 + When enabled, most context checks will disallow
17435 + access to structures assigned to a specific context,
17436 + like ptys or loop devices.
17438 +config VSERVER_CONTEXTS
17439 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
17441 + default "768" if 64BIT
17444 + This setting will optimize certain data structures
17445 + and memory allocations according to the expected
17448 + note: this is not a strict upper limit.
17450 +config VSERVER_WARN
17451 + bool "VServer Warnings"
17454 + This enables various runtime warnings, which will
17455 + notify about potential manipulation attempts or
17456 + resource shortage. It is generally considered to
17457 + be a good idea to have that enabled.
17459 +config VSERVER_WARN_DEVPTS
17460 + bool "VServer DevPTS Warnings"
17461 + depends on VSERVER_WARN
17464 + This enables DevPTS related warnings, issued when a
17465 + process inside a context tries to lookup or access
17466 + a dynamic pts from the host or a different context.
17468 +config VSERVER_DEBUG
17469 + bool "VServer Debugging Code"
17472 + Set this to yes if you want to be able to activate
17473 + debugging output at runtime. It adds a very small
17474 + overhead to all vserver related functions and
17475 + increases the kernel size by about 20k.
17477 +config VSERVER_HISTORY
17478 + bool "VServer History Tracing"
17479 + depends on VSERVER_DEBUG
17482 + Set this to yes if you want to record the history of
17483 + linux-vserver activities, so they can be replayed in
17484 + the event of a kernel panic or oops.
17486 +config VSERVER_HISTORY_SIZE
17487 + int "Per-CPU History Size (32-65536)"
17488 + depends on VSERVER_HISTORY
17492 + This allows you to specify the number of entries in
17493 + the per-CPU history buffer.
17495 +config VSERVER_LEGACY_MEM
17496 + bool "Legacy Memory Limits"
17499 + This provides fake memory limits to keep
17500 + older tools happy in the face of memory
17504 + prompt "Quotes used in debug and warn messages"
17505 + default QUOTES_ISO8859
17507 +config QUOTES_ISO8859
17508 + bool "Extended ASCII (ISO 8859) angle quotes"
17510 + This uses the extended ASCII characters \xbb
17511 + and \xab for quoting file and process names.
17513 +config QUOTES_UTF8
17514 + bool "UTF-8 angle quotes"
17516 + This uses the the UTF-8 sequences for angle
17517 + quotes to quote file and process names.
17519 +config QUOTES_ASCII
17520 + bool "ASCII single quotes"
17522 + This uses the ASCII single quote character
17523 + (\x27) to quote file and process names.
17533 + select NAMESPACES
17539 +config VSERVER_SECURITY
17541 + depends on SECURITY
17543 + select SECURITY_CAPABILITIES
17545 +config VSERVER_DISABLED
17549 diff -NurpP --minimal linux-3.1/kernel/vserver/Makefile linux-3.1-vs2.3.1-rc2/kernel/vserver/Makefile
17550 --- linux-3.1/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
17551 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/Makefile 2011-10-24 18:53:33.000000000 +0200
17554 +# Makefile for the Linux vserver routines.
17558 +obj-y += vserver.o
17560 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
17561 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
17564 +vserver-$(CONFIG_INET) += inet.o
17565 +vserver-$(CONFIG_PROC_FS) += proc.o
17566 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
17567 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
17568 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
17569 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
17571 diff -NurpP --minimal linux-3.1/kernel/vserver/cacct.c linux-3.1-vs2.3.1-rc2/kernel/vserver/cacct.c
17572 --- linux-3.1/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
17573 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/cacct.c 2011-10-24 18:53:33.000000000 +0200
17576 + * linux/kernel/vserver/cacct.c
17578 + * Virtual Server: Context Accounting
17580 + * Copyright (C) 2006-2007 Herbert Pötzl
17582 + * V0.01 added accounting stats
17586 +#include <linux/types.h>
17587 +#include <linux/vs_context.h>
17588 +#include <linux/vserver/cacct_cmd.h>
17589 +#include <linux/vserver/cacct_int.h>
17591 +#include <asm/errno.h>
17592 +#include <asm/uaccess.h>
17595 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
17597 + struct vcmd_sock_stat_v0 vc_data;
17600 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17603 + field = vc_data.field;
17604 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
17607 + for (j = 0; j < 3; j++) {
17608 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
17609 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
17612 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17617 diff -NurpP --minimal linux-3.1/kernel/vserver/cacct_init.h linux-3.1-vs2.3.1-rc2/kernel/vserver/cacct_init.h
17618 --- linux-3.1/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
17619 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/cacct_init.h 2011-10-24 18:53:33.000000000 +0200
17623 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
17628 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
17629 + for (j = 0; j < 3; j++) {
17630 + atomic_long_set(&cacct->sock[i][j].count, 0);
17631 + atomic_long_set(&cacct->sock[i][j].total, 0);
17634 + for (i = 0; i < 8; i++)
17635 + atomic_set(&cacct->slab[i], 0);
17636 + for (i = 0; i < 5; i++)
17637 + for (j = 0; j < 4; j++)
17638 + atomic_set(&cacct->page[i][j], 0);
17641 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
17646 diff -NurpP --minimal linux-3.1/kernel/vserver/cacct_proc.h linux-3.1-vs2.3.1-rc2/kernel/vserver/cacct_proc.h
17647 --- linux-3.1/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
17648 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/cacct_proc.h 2011-10-24 18:53:33.000000000 +0200
17650 +#ifndef _VX_CACCT_PROC_H
17651 +#define _VX_CACCT_PROC_H
17653 +#include <linux/vserver/cacct_int.h>
17656 +#define VX_SOCKA_TOP \
17657 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
17659 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
17661 + int i, j, length = 0;
17662 + static char *type[VXA_SOCK_SIZE] = {
17663 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
17666 + length += sprintf(buffer + length, VX_SOCKA_TOP);
17667 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
17668 + length += sprintf(buffer + length, "%s:", type[i]);
17669 + for (j = 0; j < 3; j++) {
17670 + length += sprintf(buffer + length,
17671 + "\t%10lu/%-10lu",
17672 + vx_sock_count(cacct, i, j),
17673 + vx_sock_total(cacct, i, j));
17675 + buffer[length++] = '\n';
17678 + length += sprintf(buffer + length, "\n");
17679 + length += sprintf(buffer + length,
17680 + "slab:\t %8u %8u %8u %8u\n",
17681 + atomic_read(&cacct->slab[1]),
17682 + atomic_read(&cacct->slab[4]),
17683 + atomic_read(&cacct->slab[0]),
17684 + atomic_read(&cacct->slab[2]));
17686 + length += sprintf(buffer + length, "\n");
17687 + for (i = 0; i < 5; i++) {
17688 + length += sprintf(buffer + length,
17689 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
17690 + atomic_read(&cacct->page[i][0]),
17691 + atomic_read(&cacct->page[i][1]),
17692 + atomic_read(&cacct->page[i][2]),
17693 + atomic_read(&cacct->page[i][3]),
17694 + atomic_read(&cacct->page[i][4]),
17695 + atomic_read(&cacct->page[i][5]),
17696 + atomic_read(&cacct->page[i][6]),
17697 + atomic_read(&cacct->page[i][7]));
17702 +#endif /* _VX_CACCT_PROC_H */
17703 diff -NurpP --minimal linux-3.1/kernel/vserver/context.c linux-3.1-vs2.3.1-rc2/kernel/vserver/context.c
17704 --- linux-3.1/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
17705 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/context.c 2011-10-24 18:53:33.000000000 +0200
17708 + * linux/kernel/vserver/context.c
17710 + * Virtual Server: Context Support
17712 + * Copyright (C) 2003-2011 Herbert Pötzl
17714 + * V0.01 context helper
17715 + * V0.02 vx_ctx_kill syscall command
17716 + * V0.03 replaced context_info calls
17717 + * V0.04 redesign of struct (de)alloc
17718 + * V0.05 rlimit basic implementation
17719 + * V0.06 task_xid and info commands
17720 + * V0.07 context flags and caps
17721 + * V0.08 switch to RCU based hash
17722 + * V0.09 revert to non RCU for now
17723 + * V0.10 and back to working RCU hash
17724 + * V0.11 and back to locking again
17725 + * V0.12 referenced context store
17726 + * V0.13 separate per cpu data
17727 + * V0.14 changed vcmds to vxi arg
17728 + * V0.15 added context stat
17729 + * V0.16 have __create claim() the vxi
17730 + * V0.17 removed older and legacy stuff
17731 + * V0.18 added user credentials
17732 + * V0.19 added warn mask
17736 +#include <linux/slab.h>
17737 +#include <linux/types.h>
17738 +#include <linux/security.h>
17739 +#include <linux/pid_namespace.h>
17740 +#include <linux/capability.h>
17742 +#include <linux/vserver/context.h>
17743 +#include <linux/vserver/network.h>
17744 +#include <linux/vserver/debug.h>
17745 +#include <linux/vserver/limit.h>
17746 +#include <linux/vserver/limit_int.h>
17747 +#include <linux/vserver/space.h>
17748 +#include <linux/init_task.h>
17749 +#include <linux/fs_struct.h>
17750 +#include <linux/cred.h>
17752 +#include <linux/vs_context.h>
17753 +#include <linux/vs_limit.h>
17754 +#include <linux/vs_pid.h>
17755 +#include <linux/vserver/context_cmd.h>
17757 +#include "cvirt_init.h"
17758 +#include "cacct_init.h"
17759 +#include "limit_init.h"
17760 +#include "sched_init.h"
17763 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
17764 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
17767 +/* now inactive context structures */
17769 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
17771 +static DEFINE_SPINLOCK(vx_info_inactive_lock);
17774 +/* __alloc_vx_info()
17776 + * allocate an initialized vx_info struct
17777 + * doesn't make it visible (hash) */
17779 +static struct vx_info *__alloc_vx_info(xid_t xid)
17781 + struct vx_info *new = NULL;
17784 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
17786 + /* would this benefit from a slab cache? */
17787 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
17791 + memset(new, 0, sizeof(struct vx_info));
17793 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
17794 + if (!new->ptr_pc)
17797 + new->vx_id = xid;
17798 + INIT_HLIST_NODE(&new->vx_hlist);
17799 + atomic_set(&new->vx_usecnt, 0);
17800 + atomic_set(&new->vx_tasks, 0);
17801 + new->vx_parent = NULL;
17802 + new->vx_state = 0;
17803 + init_waitqueue_head(&new->vx_wait);
17805 + /* prepare reaper */
17806 + get_task_struct(init_pid_ns.child_reaper);
17807 + new->vx_reaper = init_pid_ns.child_reaper;
17808 + new->vx_badness_bias = 0;
17810 + /* rest of init goes here */
17811 + vx_info_init_limit(&new->limit);
17812 + vx_info_init_sched(&new->sched);
17813 + vx_info_init_cvirt(&new->cvirt);
17814 + vx_info_init_cacct(&new->cacct);
17816 + /* per cpu data structures */
17817 + for_each_possible_cpu(cpu) {
17818 + vx_info_init_sched_pc(
17819 + &vx_per_cpu(new, sched_pc, cpu), cpu);
17820 + vx_info_init_cvirt_pc(
17821 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
17824 + new->vx_flags = VXF_INIT_SET;
17825 + new->vx_bcaps = CAP_FULL_SET; // maybe ~CAP_SETPCAP
17826 + new->vx_ccaps = 0;
17827 + new->vx_umask = 0;
17828 + new->vx_wmask = 0;
17830 + new->reboot_cmd = 0;
17831 + new->exit_code = 0;
17833 + // preconfig spaces
17834 + for (index = 0; index < VX_SPACES; index++) {
17835 + struct _vx_space *space = &new->space[index];
17838 + spin_lock(&init_fs.lock);
17840 + spin_unlock(&init_fs.lock);
17841 + space->vx_fs = &init_fs;
17843 + /* FIXME: do we want defaults? */
17844 + // space->vx_real_cred = 0;
17845 + // space->vx_cred = 0;
17849 + vxdprintk(VXD_CBIT(xid, 0),
17850 + "alloc_vx_info(%d) = %p", xid, new);
17851 + vxh_alloc_vx_info(new);
17852 + atomic_inc(&vx_global_ctotal);
17861 +/* __dealloc_vx_info()
17863 + * final disposal of vx_info */
17865 +static void __dealloc_vx_info(struct vx_info *vxi)
17867 +#ifdef CONFIG_VSERVER_WARN
17868 + struct vx_info_save vxis;
17871 + vxdprintk(VXD_CBIT(xid, 0),
17872 + "dealloc_vx_info(%p)", vxi);
17873 + vxh_dealloc_vx_info(vxi);
17875 +#ifdef CONFIG_VSERVER_WARN
17876 + enter_vx_info(vxi, &vxis);
17877 + vx_info_exit_limit(&vxi->limit);
17878 + vx_info_exit_sched(&vxi->sched);
17879 + vx_info_exit_cvirt(&vxi->cvirt);
17880 + vx_info_exit_cacct(&vxi->cacct);
17882 + for_each_possible_cpu(cpu) {
17883 + vx_info_exit_sched_pc(
17884 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
17885 + vx_info_exit_cvirt_pc(
17886 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
17888 + leave_vx_info(&vxis);
17892 + vxi->vx_state |= VXS_RELEASED;
17895 + free_percpu(vxi->ptr_pc);
17898 + atomic_dec(&vx_global_ctotal);
17901 +static void __shutdown_vx_info(struct vx_info *vxi)
17903 + struct nsproxy *nsproxy;
17904 + struct fs_struct *fs;
17905 + struct cred *cred;
17910 + vxi->vx_state |= VXS_SHUTDOWN;
17911 + vs_state_change(vxi, VSC_SHUTDOWN);
17913 + for (index = 0; index < VX_SPACES; index++) {
17914 + struct _vx_space *space = &vxi->space[index];
17916 + nsproxy = xchg(&space->vx_nsproxy, NULL);
17918 + put_nsproxy(nsproxy);
17920 + fs = xchg(&space->vx_fs, NULL);
17921 + spin_lock(&fs->lock);
17922 + kill = !--fs->users;
17923 + spin_unlock(&fs->lock);
17925 + free_fs_struct(fs);
17927 + cred = (struct cred *)xchg(&space->vx_cred, NULL);
17929 + abort_creds(cred);
17933 +/* exported stuff */
17935 +void free_vx_info(struct vx_info *vxi)
17937 + unsigned long flags;
17940 + /* check for reference counts first */
17941 + BUG_ON(atomic_read(&vxi->vx_usecnt));
17942 + BUG_ON(atomic_read(&vxi->vx_tasks));
17944 + /* context must not be hashed */
17945 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
17947 + /* context shutdown is mandatory */
17948 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
17950 + /* spaces check */
17951 + for (index = 0; index < VX_SPACES; index++) {
17952 + struct _vx_space *space = &vxi->space[index];
17954 + BUG_ON(space->vx_nsproxy);
17955 + BUG_ON(space->vx_fs);
17956 + // BUG_ON(space->vx_real_cred);
17957 + // BUG_ON(space->vx_cred);
17960 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
17961 + hlist_del(&vxi->vx_hlist);
17962 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
17964 + __dealloc_vx_info(vxi);
17968 +/* hash table for vx_info hash */
17970 +#define VX_HASH_SIZE 13
17972 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
17973 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
17975 +static DEFINE_SPINLOCK(vx_info_hash_lock);
17978 +static inline unsigned int __hashval(xid_t xid)
17980 + return (xid % VX_HASH_SIZE);
17985 +/* __hash_vx_info()
17987 + * add the vxi to the global hash table
17988 + * requires the hash_lock to be held */
17990 +static inline void __hash_vx_info(struct vx_info *vxi)
17992 + struct hlist_head *head;
17994 + vxd_assert_lock(&vx_info_hash_lock);
17995 + vxdprintk(VXD_CBIT(xid, 4),
17996 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
17997 + vxh_hash_vx_info(vxi);
17999 + /* context must not be hashed */
18000 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
18002 + vxi->vx_state |= VXS_HASHED;
18003 + head = &vx_info_hash[__hashval(vxi->vx_id)];
18004 + hlist_add_head(&vxi->vx_hlist, head);
18005 + atomic_inc(&vx_global_cactive);
18008 +/* __unhash_vx_info()
18010 + * remove the vxi from the global hash table
18011 + * requires the hash_lock to be held */
18013 +static inline void __unhash_vx_info(struct vx_info *vxi)
18015 + unsigned long flags;
18017 + vxd_assert_lock(&vx_info_hash_lock);
18018 + vxdprintk(VXD_CBIT(xid, 4),
18019 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
18020 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
18021 + vxh_unhash_vx_info(vxi);
18023 + /* context must be hashed */
18024 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
18025 + /* but without tasks */
18026 + BUG_ON(atomic_read(&vxi->vx_tasks));
18028 + vxi->vx_state &= ~VXS_HASHED;
18029 + hlist_del_init(&vxi->vx_hlist);
18030 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
18031 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
18032 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
18033 + atomic_dec(&vx_global_cactive);
18037 +/* __lookup_vx_info()
18039 + * requires the hash_lock to be held
18040 + * doesn't increment the vx_refcnt */
18042 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
18044 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
18045 + struct hlist_node *pos;
18046 + struct vx_info *vxi;
18048 + vxd_assert_lock(&vx_info_hash_lock);
18049 + hlist_for_each(pos, head) {
18050 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
18052 + if (vxi->vx_id == xid)
18057 + vxdprintk(VXD_CBIT(xid, 0),
18058 + "__lookup_vx_info(#%u): %p[#%u]",
18059 + xid, vxi, vxi ? vxi->vx_id : 0);
18060 + vxh_lookup_vx_info(vxi, xid);
18065 +/* __create_vx_info()
18067 + * create the requested context
18068 + * get(), claim() and hash it */
18070 +static struct vx_info *__create_vx_info(int id)
18072 + struct vx_info *new, *vxi = NULL;
18074 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
18076 + if (!(new = __alloc_vx_info(id)))
18077 + return ERR_PTR(-ENOMEM);
18079 + /* required to make dynamic xids unique */
18080 + spin_lock(&vx_info_hash_lock);
18082 + /* static context requested */
18083 + if ((vxi = __lookup_vx_info(id))) {
18084 + vxdprintk(VXD_CBIT(xid, 0),
18085 + "create_vx_info(%d) = %p (already there)", id, vxi);
18086 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18087 + vxi = ERR_PTR(-EBUSY);
18089 + vxi = ERR_PTR(-EEXIST);
18092 + /* new context */
18093 + vxdprintk(VXD_CBIT(xid, 0),
18094 + "create_vx_info(%d) = %p (new)", id, new);
18095 + claim_vx_info(new, NULL);
18096 + __hash_vx_info(get_vx_info(new));
18097 + vxi = new, new = NULL;
18100 + spin_unlock(&vx_info_hash_lock);
18101 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
18103 + __dealloc_vx_info(new);
18108 +/* exported stuff */
18111 +void unhash_vx_info(struct vx_info *vxi)
18113 + spin_lock(&vx_info_hash_lock);
18114 + __unhash_vx_info(vxi);
18115 + spin_unlock(&vx_info_hash_lock);
18116 + __shutdown_vx_info(vxi);
18117 + __wakeup_vx_info(vxi);
18121 +/* lookup_vx_info()
18123 + * search for a vx_info and get() it
18124 + * negative id means current */
18126 +struct vx_info *lookup_vx_info(int id)
18128 + struct vx_info *vxi = NULL;
18131 + vxi = get_vx_info(current_vx_info());
18132 + } else if (id > 1) {
18133 + spin_lock(&vx_info_hash_lock);
18134 + vxi = get_vx_info(__lookup_vx_info(id));
18135 + spin_unlock(&vx_info_hash_lock);
18140 +/* xid_is_hashed()
18142 + * verify that xid is still hashed */
18144 +int xid_is_hashed(xid_t xid)
18148 + spin_lock(&vx_info_hash_lock);
18149 + hashed = (__lookup_vx_info(xid) != NULL);
18150 + spin_unlock(&vx_info_hash_lock);
18154 +#ifdef CONFIG_PROC_FS
18158 + * get a subset of hashed xids for proc
18159 + * assumes size is at least one */
18161 +int get_xid_list(int index, unsigned int *xids, int size)
18163 + int hindex, nr_xids = 0;
18165 + /* only show current and children */
18166 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
18169 + xids[nr_xids] = vx_current_xid();
18173 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
18174 + struct hlist_head *head = &vx_info_hash[hindex];
18175 + struct hlist_node *pos;
18177 + spin_lock(&vx_info_hash_lock);
18178 + hlist_for_each(pos, head) {
18179 + struct vx_info *vxi;
18184 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
18185 + xids[nr_xids] = vxi->vx_id;
18186 + if (++nr_xids >= size) {
18187 + spin_unlock(&vx_info_hash_lock);
18191 + /* keep the lock time short */
18192 + spin_unlock(&vx_info_hash_lock);
18199 +#ifdef CONFIG_VSERVER_DEBUG
18201 +void dump_vx_info_inactive(int level)
18203 + struct hlist_node *entry, *next;
18205 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
18206 + struct vx_info *vxi =
18207 + list_entry(entry, struct vx_info, vx_hlist);
18209 + dump_vx_info(vxi, level);
18216 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
18218 + struct user_struct *new_user, *old_user;
18223 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
18226 + new_user = alloc_uid(vxi->vx_id, p->uid);
18230 + old_user = p->user;
18231 + if (new_user != old_user) {
18232 + atomic_inc(&new_user->processes);
18233 + atomic_dec(&old_user->processes);
18234 + p->user = new_user;
18236 + free_uid(old_user);
18242 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
18244 + // p->cap_effective &= vxi->vx_cap_bset;
18245 + p->cap_effective =
18246 + cap_intersect(p->cap_effective, vxi->cap_bset);
18247 + // p->cap_inheritable &= vxi->vx_cap_bset;
18248 + p->cap_inheritable =
18249 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
18250 + // p->cap_permitted &= vxi->vx_cap_bset;
18251 + p->cap_permitted =
18252 + cap_intersect(p->cap_permitted, vxi->cap_bset);
18257 +#include <linux/file.h>
18258 +#include <linux/fdtable.h>
18260 +static int vx_openfd_task(struct task_struct *tsk)
18262 + struct files_struct *files = tsk->files;
18263 + struct fdtable *fdt;
18264 + const unsigned long *bptr;
18265 + int count, total;
18267 + /* no rcu_read_lock() because of spin_lock() */
18268 + spin_lock(&files->file_lock);
18269 + fdt = files_fdtable(files);
18270 + bptr = fdt->open_fds->fds_bits;
18271 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
18272 + for (total = 0; count > 0; count--) {
18274 + total += hweight_long(*bptr);
18277 + spin_unlock(&files->file_lock);
18282 +/* for *space compatibility */
18284 +asmlinkage long sys_unshare(unsigned long);
18287 + * migrate task to new context
18288 + * gets vxi, puts old_vxi on change
18289 + * optionally unshares namespaces (hack)
18292 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
18294 + struct vx_info *old_vxi;
18300 + vxdprintk(VXD_CBIT(xid, 5),
18301 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
18302 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
18304 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
18305 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18308 + if (vx_info_state(vxi, VXS_SHUTDOWN))
18311 + old_vxi = task_get_vx_info(p);
18312 + if (old_vxi == vxi)
18315 +// if (!(ret = vx_migrate_user(p, vxi))) {
18320 + openfd = vx_openfd_task(p);
18323 + atomic_dec(&old_vxi->cvirt.nr_threads);
18324 + atomic_dec(&old_vxi->cvirt.nr_running);
18325 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
18326 + /* FIXME: what about the struct files here? */
18327 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
18328 + /* account for the executable */
18329 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
18331 + atomic_inc(&vxi->cvirt.nr_threads);
18332 + atomic_inc(&vxi->cvirt.nr_running);
18333 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
18334 + /* FIXME: what about the struct files here? */
18335 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
18336 + /* account for the executable */
18337 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
18340 + release_vx_info(old_vxi, p);
18341 + clr_vx_info(&p->vx_info);
18343 + claim_vx_info(vxi, p);
18344 + set_vx_info(&p->vx_info, vxi);
18345 + p->xid = vxi->vx_id;
18347 + vxdprintk(VXD_CBIT(xid, 5),
18348 + "moved task %p into vxi:%p[#%d]",
18349 + p, vxi, vxi->vx_id);
18351 + // vx_mask_cap_bset(vxi, p);
18354 + /* hack for *spaces to provide compatibility */
18356 + struct nsproxy *old_nsp, *new_nsp;
18358 + ret = unshare_nsproxy_namespaces(
18359 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
18364 + old_nsp = xchg(&p->nsproxy, new_nsp);
18365 + vx_set_space(vxi,
18366 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
18367 + put_nsproxy(old_nsp);
18371 + put_vx_info(old_vxi);
18375 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
18377 + struct task_struct *old_reaper;
18382 + vxdprintk(VXD_CBIT(xid, 6),
18383 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
18384 + vxi, vxi->vx_id, p, p->xid, p->pid);
18386 + old_reaper = vxi->vx_reaper;
18387 + if (old_reaper == p)
18390 + /* set new child reaper */
18391 + get_task_struct(p);
18392 + vxi->vx_reaper = p;
18393 + put_task_struct(old_reaper);
18397 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
18402 + vxdprintk(VXD_CBIT(xid, 6),
18403 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
18404 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18406 + vxi->vx_flags &= ~VXF_STATE_INIT;
18407 + // vxi->vx_initpid = p->tgid;
18408 + vxi->vx_initpid = p->pid;
18412 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
18414 + vxdprintk(VXD_CBIT(xid, 6),
18415 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
18416 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18418 + vxi->exit_code = code;
18419 + vxi->vx_initpid = 0;
18423 +void vx_set_persistent(struct vx_info *vxi)
18425 + vxdprintk(VXD_CBIT(xid, 6),
18426 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
18428 + get_vx_info(vxi);
18429 + claim_vx_info(vxi, NULL);
18432 +void vx_clear_persistent(struct vx_info *vxi)
18434 + vxdprintk(VXD_CBIT(xid, 6),
18435 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
18437 + release_vx_info(vxi, NULL);
18438 + put_vx_info(vxi);
18441 +void vx_update_persistent(struct vx_info *vxi)
18443 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
18444 + vx_set_persistent(vxi);
18446 + vx_clear_persistent(vxi);
18450 +/* task must be current or locked */
18452 +void exit_vx_info(struct task_struct *p, int code)
18454 + struct vx_info *vxi = p->vx_info;
18457 + atomic_dec(&vxi->cvirt.nr_threads);
18460 + vxi->exit_code = code;
18461 + release_vx_info(vxi, p);
18465 +void exit_vx_info_early(struct task_struct *p, int code)
18467 + struct vx_info *vxi = p->vx_info;
18470 + if (vxi->vx_initpid == p->pid)
18471 + vx_exit_init(vxi, p, code);
18472 + if (vxi->vx_reaper == p)
18473 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
18478 +/* vserver syscall commands below here */
18480 +/* taks xid and vx_info functions */
18482 +#include <asm/uaccess.h>
18485 +int vc_task_xid(uint32_t id)
18490 + struct task_struct *tsk;
18493 + tsk = find_task_by_real_pid(id);
18494 + xid = (tsk) ? tsk->xid : -ESRCH;
18495 + rcu_read_unlock();
18497 + xid = vx_current_xid();
18502 +int vc_vx_info(struct vx_info *vxi, void __user *data)
18504 + struct vcmd_vx_info_v0 vc_data;
18506 + vc_data.xid = vxi->vx_id;
18507 + vc_data.initpid = vxi->vx_initpid;
18509 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18515 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
18517 + struct vcmd_ctx_stat_v0 vc_data;
18519 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
18520 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
18522 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18528 +/* context functions */
18530 +int vc_ctx_create(uint32_t xid, void __user *data)
18532 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
18533 + struct vx_info *new_vxi;
18536 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18539 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
18542 + new_vxi = __create_vx_info(xid);
18543 + if (IS_ERR(new_vxi))
18544 + return PTR_ERR(new_vxi);
18546 + /* initial flags */
18547 + new_vxi->vx_flags = vc_data.flagword;
18550 + if (vs_state_change(new_vxi, VSC_STARTUP))
18553 + ret = vx_migrate_task(current, new_vxi, (!data));
18557 + /* return context id on success */
18558 + ret = new_vxi->vx_id;
18560 + /* get a reference for persistent contexts */
18561 + if ((vc_data.flagword & VXF_PERSISTENT))
18562 + vx_set_persistent(new_vxi);
18564 + release_vx_info(new_vxi, NULL);
18565 + put_vx_info(new_vxi);
18570 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
18572 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
18575 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18578 + ret = vx_migrate_task(current, vxi, 0);
18581 + if (vc_data.flagword & VXM_SET_INIT)
18582 + ret = vx_set_init(vxi, current);
18585 + if (vc_data.flagword & VXM_SET_REAPER)
18586 + ret = vx_set_reaper(vxi, current);
18591 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
18593 + struct vcmd_ctx_flags_v0 vc_data;
18595 + vc_data.flagword = vxi->vx_flags;
18597 + /* special STATE flag handling */
18598 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
18600 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18605 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
18607 + struct vcmd_ctx_flags_v0 vc_data;
18608 + uint64_t mask, trigger;
18610 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18613 + /* special STATE flag handling */
18614 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
18615 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
18617 + if (vxi == current_vx_info()) {
18618 + /* if (trigger & VXF_STATE_SETUP)
18619 + vx_mask_cap_bset(vxi, current); */
18620 + if (trigger & VXF_STATE_INIT) {
18623 + ret = vx_set_init(vxi, current);
18626 + ret = vx_set_reaper(vxi, current);
18632 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
18633 + vc_data.flagword, mask);
18634 + if (trigger & VXF_PERSISTENT)
18635 + vx_update_persistent(vxi);
18641 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
18643 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
18645 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
18649 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
18651 + kernel_cap_t c = __cap_empty_set;
18653 + c.cap[0] = v & 0xFFFFFFFF;
18654 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
18656 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
18661 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
18664 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
18666 + *ccaps = vxi->vx_ccaps;
18671 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
18673 + struct vcmd_ctx_caps_v1 vc_data;
18676 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
18679 + vc_data.cmask = ~0ULL;
18681 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18686 +static int do_set_caps(struct vx_info *vxi,
18687 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
18689 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
18692 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
18693 + bcaps, bmask, ccaps, cmask);
18695 + vxi->vx_bcaps = cap_t_from_caps(
18696 + vs_mask_flags(bcold, bcaps, bmask));
18697 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
18702 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
18704 + struct vcmd_ctx_caps_v1 vc_data;
18706 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18709 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
18712 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
18714 + struct vcmd_bcaps vc_data;
18717 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
18720 + vc_data.bmask = ~0ULL;
18722 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18727 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
18729 + struct vcmd_bcaps vc_data;
18731 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18734 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
18738 +int vc_get_umask(struct vx_info *vxi, void __user *data)
18740 + struct vcmd_umask vc_data;
18742 + vc_data.umask = vxi->vx_umask;
18743 + vc_data.mask = ~0ULL;
18745 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18750 +int vc_set_umask(struct vx_info *vxi, void __user *data)
18752 + struct vcmd_umask vc_data;
18754 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18757 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
18758 + vc_data.umask, vc_data.mask);
18763 +int vc_get_wmask(struct vx_info *vxi, void __user *data)
18765 + struct vcmd_wmask vc_data;
18767 + vc_data.wmask = vxi->vx_wmask;
18768 + vc_data.mask = ~0ULL;
18770 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18775 +int vc_set_wmask(struct vx_info *vxi, void __user *data)
18777 + struct vcmd_wmask vc_data;
18779 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18782 + vxi->vx_wmask = vs_mask_flags(vxi->vx_wmask,
18783 + vc_data.wmask, vc_data.mask);
18788 +int vc_get_badness(struct vx_info *vxi, void __user *data)
18790 + struct vcmd_badness_v0 vc_data;
18792 + vc_data.bias = vxi->vx_badness_bias;
18794 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18799 +int vc_set_badness(struct vx_info *vxi, void __user *data)
18801 + struct vcmd_badness_v0 vc_data;
18803 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18806 + vxi->vx_badness_bias = vc_data.bias;
18810 +#include <linux/module.h>
18812 +EXPORT_SYMBOL_GPL(free_vx_info);
18814 diff -NurpP --minimal linux-3.1/kernel/vserver/cvirt.c linux-3.1-vs2.3.1-rc2/kernel/vserver/cvirt.c
18815 --- linux-3.1/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
18816 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/cvirt.c 2011-10-24 18:53:33.000000000 +0200
18819 + * linux/kernel/vserver/cvirt.c
18821 + * Virtual Server: Context Virtualization
18823 + * Copyright (C) 2004-2007 Herbert Pötzl
18825 + * V0.01 broken out from limit.c
18826 + * V0.02 added utsname stuff
18827 + * V0.03 changed vcmds to vxi arg
18831 +#include <linux/types.h>
18832 +#include <linux/utsname.h>
18833 +#include <linux/vs_cvirt.h>
18834 +#include <linux/vserver/switch.h>
18835 +#include <linux/vserver/cvirt_cmd.h>
18837 +#include <asm/uaccess.h>
18840 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
18842 + struct vx_info *vxi = current_vx_info();
18844 + set_normalized_timespec(uptime,
18845 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
18846 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
18849 + set_normalized_timespec(idle,
18850 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
18851 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
18855 +uint64_t vx_idle_jiffies(void)
18857 + return init_task.utime + init_task.stime;
18862 +static inline uint32_t __update_loadavg(uint32_t load,
18863 + int wsize, int delta, int n)
18865 + unsigned long long calc, prev;
18867 + /* just set it to n */
18868 + if (unlikely(delta >= wsize))
18869 + return (n << FSHIFT);
18871 + calc = delta * n;
18873 + prev = (wsize - delta);
18876 + do_div(calc, wsize);
18881 +void vx_update_load(struct vx_info *vxi)
18883 + uint32_t now, last, delta;
18884 + unsigned int nr_running, nr_uninterruptible;
18885 + unsigned int total;
18886 + unsigned long flags;
18888 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
18891 + last = vxi->cvirt.load_last;
18892 + delta = now - last;
18894 + if (delta < 5*HZ)
18897 + nr_running = atomic_read(&vxi->cvirt.nr_running);
18898 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
18899 + total = nr_running + nr_uninterruptible;
18901 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
18902 + 60*HZ, delta, total);
18903 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
18904 + 5*60*HZ, delta, total);
18905 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
18906 + 15*60*HZ, delta, total);
18908 + vxi->cvirt.load_last = now;
18910 + atomic_inc(&vxi->cvirt.load_updates);
18911 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
18916 + * Commands to do_syslog:
18918 + * 0 -- Close the log. Currently a NOP.
18919 + * 1 -- Open the log. Currently a NOP.
18920 + * 2 -- Read from the log.
18921 + * 3 -- Read all messages remaining in the ring buffer.
18922 + * 4 -- Read and clear all messages remaining in the ring buffer
18923 + * 5 -- Clear ring buffer.
18924 + * 6 -- Disable printk's to console
18925 + * 7 -- Enable printk's to console
18926 + * 8 -- Set level of messages printed to console
18927 + * 9 -- Return number of unread characters in the log buffer
18928 + * 10 -- Return size of the log buffer
18930 +int vx_do_syslog(int type, char __user *buf, int len)
18933 + int do_clear = 0;
18934 + struct vx_info *vxi = current_vx_info();
18935 + struct _vx_syslog *log;
18939 + log = &vxi->cvirt.syslog;
18942 + case 0: /* Close log */
18943 + case 1: /* Open log */
18945 + case 2: /* Read from log */
18946 + error = wait_event_interruptible(log->log_wait,
18947 + (log->log_start - log->log_end));
18950 + spin_lock_irq(&log->logbuf_lock);
18951 + spin_unlock_irq(&log->logbuf_lock);
18953 + case 4: /* Read/clear last kernel messages */
18955 + /* fall through */
18956 + case 3: /* Read last kernel messages */
18959 + case 5: /* Clear ring buffer */
18962 + case 6: /* Disable logging to console */
18963 + case 7: /* Enable logging to console */
18964 + case 8: /* Set level of messages printed to console */
18967 + case 9: /* Number of chars in the log buffer */
18969 + case 10: /* Size of the log buffer */
18979 +/* virtual host info names */
18981 +static char *vx_vhi_name(struct vx_info *vxi, int id)
18983 + struct nsproxy *nsproxy;
18984 + struct uts_namespace *uts;
18986 + if (id == VHIN_CONTEXT)
18987 + return vxi->vx_name;
18989 + nsproxy = vxi->space[0].vx_nsproxy;
18993 + uts = nsproxy->uts_ns;
18998 + case VHIN_SYSNAME:
18999 + return uts->name.sysname;
19000 + case VHIN_NODENAME:
19001 + return uts->name.nodename;
19002 + case VHIN_RELEASE:
19003 + return uts->name.release;
19004 + case VHIN_VERSION:
19005 + return uts->name.version;
19006 + case VHIN_MACHINE:
19007 + return uts->name.machine;
19008 + case VHIN_DOMAINNAME:
19009 + return uts->name.domainname;
19016 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
19018 + struct vcmd_vhi_name_v0 vc_data;
19021 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19024 + name = vx_vhi_name(vxi, vc_data.field);
19028 + memcpy(name, vc_data.name, 65);
19032 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
19034 + struct vcmd_vhi_name_v0 vc_data;
19037 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19040 + name = vx_vhi_name(vxi, vc_data.field);
19044 + memcpy(vc_data.name, name, 65);
19045 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19051 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
19053 + struct vcmd_virt_stat_v0 vc_data;
19054 + struct _vx_cvirt *cvirt = &vxi->cvirt;
19055 + struct timespec uptime;
19057 + do_posix_clock_monotonic_gettime(&uptime);
19058 + set_normalized_timespec(&uptime,
19059 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
19060 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
19062 + vc_data.offset = timespec_to_ns(&cvirt->bias_ts);
19063 + vc_data.uptime = timespec_to_ns(&uptime);
19064 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
19065 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
19066 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
19067 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
19068 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
19069 + vc_data.load[0] = cvirt->load[0];
19070 + vc_data.load[1] = cvirt->load[1];
19071 + vc_data.load[2] = cvirt->load[2];
19073 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19079 +#ifdef CONFIG_VSERVER_VTIME
19081 +/* virtualized time base */
19083 +void vx_adjust_timespec(struct timespec *ts)
19085 + struct vx_info *vxi;
19087 + if (!vx_flags(VXF_VIRT_TIME, 0))
19090 + vxi = current_vx_info();
19091 + ts->tv_sec += vxi->cvirt.bias_ts.tv_sec;
19092 + ts->tv_nsec += vxi->cvirt.bias_ts.tv_nsec;
19094 + if (ts->tv_nsec >= NSEC_PER_SEC) {
19096 + ts->tv_nsec -= NSEC_PER_SEC;
19097 + } else if (ts->tv_nsec < 0) {
19099 + ts->tv_nsec += NSEC_PER_SEC;
19103 +int vx_settimeofday(const struct timespec *ts)
19105 + struct timespec ats, delta;
19106 + struct vx_info *vxi;
19108 + if (!vx_flags(VXF_VIRT_TIME, 0))
19109 + return do_settimeofday(ts);
19111 + getnstimeofday(&ats);
19112 + delta = timespec_sub(*ts, ats);
19114 + vxi = current_vx_info();
19115 + vxi->cvirt.bias_ts = timespec_add(vxi->cvirt.bias_ts, delta);
19121 diff -NurpP --minimal linux-3.1/kernel/vserver/cvirt_init.h linux-3.1-vs2.3.1-rc2/kernel/vserver/cvirt_init.h
19122 --- linux-3.1/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
19123 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/cvirt_init.h 2011-10-24 18:53:33.000000000 +0200
19127 +extern uint64_t vx_idle_jiffies(void);
19129 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
19131 + uint64_t idle_jiffies = vx_idle_jiffies();
19132 + uint64_t nsuptime;
19134 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
19135 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
19136 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
19137 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
19138 + cvirt->bias_ts.tv_sec = 0;
19139 + cvirt->bias_ts.tv_nsec = 0;
19141 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
19142 + atomic_set(&cvirt->nr_threads, 0);
19143 + atomic_set(&cvirt->nr_running, 0);
19144 + atomic_set(&cvirt->nr_uninterruptible, 0);
19145 + atomic_set(&cvirt->nr_onhold, 0);
19147 + spin_lock_init(&cvirt->load_lock);
19148 + cvirt->load_last = jiffies;
19149 + atomic_set(&cvirt->load_updates, 0);
19150 + cvirt->load[0] = 0;
19151 + cvirt->load[1] = 0;
19152 + cvirt->load[2] = 0;
19153 + atomic_set(&cvirt->total_forks, 0);
19155 + spin_lock_init(&cvirt->syslog.logbuf_lock);
19156 + init_waitqueue_head(&cvirt->syslog.log_wait);
19157 + cvirt->syslog.log_start = 0;
19158 + cvirt->syslog.log_end = 0;
19159 + cvirt->syslog.con_start = 0;
19160 + cvirt->syslog.logged_chars = 0;
19164 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19166 + // cvirt_pc->cpustat = { 0 };
19169 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
19171 +#ifdef CONFIG_VSERVER_WARN
19174 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
19175 + "!!! cvirt: %p[nr_threads] = %d on exit.",
19177 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
19178 + "!!! cvirt: %p[nr_running] = %d on exit.",
19180 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
19181 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
19183 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
19184 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
19190 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19195 diff -NurpP --minimal linux-3.1/kernel/vserver/cvirt_proc.h linux-3.1-vs2.3.1-rc2/kernel/vserver/cvirt_proc.h
19196 --- linux-3.1/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
19197 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/cvirt_proc.h 2011-10-24 18:53:33.000000000 +0200
19199 +#ifndef _VX_CVIRT_PROC_H
19200 +#define _VX_CVIRT_PROC_H
19202 +#include <linux/nsproxy.h>
19203 +#include <linux/mnt_namespace.h>
19204 +#include <linux/ipc_namespace.h>
19205 +#include <linux/utsname.h>
19206 +#include <linux/ipc.h>
19210 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
19212 + struct mnt_namespace *ns;
19213 + struct uts_namespace *uts;
19214 + struct ipc_namespace *ipc;
19215 + struct path path;
19216 + char *pstr, *root;
19222 + length += sprintf(buffer + length,
19223 + "NSProxy:\t%p [%p,%p,%p]\n",
19224 + nsproxy, nsproxy->mnt_ns,
19225 + nsproxy->uts_ns, nsproxy->ipc_ns);
19227 + ns = nsproxy->mnt_ns;
19231 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
19235 + path.mnt = ns->root;
19236 + path.dentry = ns->root->mnt_root;
19237 + root = d_path(&path, pstr, PATH_MAX - 2);
19238 + length += sprintf(buffer + length,
19239 + "Namespace:\t%p [#%u]\n"
19240 + "RootPath:\t%s\n",
19241 + ns, atomic_read(&ns->count),
19246 + uts = nsproxy->uts_ns;
19250 + length += sprintf(buffer + length,
19251 + "SysName:\t%.*s\n"
19252 + "NodeName:\t%.*s\n"
19253 + "Release:\t%.*s\n"
19254 + "Version:\t%.*s\n"
19255 + "Machine:\t%.*s\n"
19256 + "DomainName:\t%.*s\n",
19257 + __NEW_UTS_LEN, uts->name.sysname,
19258 + __NEW_UTS_LEN, uts->name.nodename,
19259 + __NEW_UTS_LEN, uts->name.release,
19260 + __NEW_UTS_LEN, uts->name.version,
19261 + __NEW_UTS_LEN, uts->name.machine,
19262 + __NEW_UTS_LEN, uts->name.domainname);
19265 + ipc = nsproxy->ipc_ns;
19269 + length += sprintf(buffer + length,
19270 + "SEMS:\t\t%d %d %d %d %d\n"
19271 + "MSG:\t\t%d %d %d\n"
19272 + "SHM:\t\t%lu %lu %d %d\n",
19273 + ipc->sem_ctls[0], ipc->sem_ctls[1],
19274 + ipc->sem_ctls[2], ipc->sem_ctls[3],
19276 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
19277 + (unsigned long)ipc->shm_ctlmax,
19278 + (unsigned long)ipc->shm_ctlall,
19279 + ipc->shm_ctlmni, ipc->shm_tot);
19286 +#include <linux/sched.h>
19288 +#define LOAD_INT(x) ((x) >> FSHIFT)
19289 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
19292 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
19297 + length += sprintf(buffer + length,
19298 + "BiasUptime:\t%lu.%02lu\n",
19299 + (unsigned long)cvirt->bias_uptime.tv_sec,
19300 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
19302 + a = cvirt->load[0] + (FIXED_1 / 200);
19303 + b = cvirt->load[1] + (FIXED_1 / 200);
19304 + c = cvirt->load[2] + (FIXED_1 / 200);
19305 + length += sprintf(buffer + length,
19306 + "nr_threads:\t%d\n"
19307 + "nr_running:\t%d\n"
19308 + "nr_unintr:\t%d\n"
19309 + "nr_onhold:\t%d\n"
19310 + "load_updates:\t%d\n"
19311 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
19312 + "total_forks:\t%d\n",
19313 + atomic_read(&cvirt->nr_threads),
19314 + atomic_read(&cvirt->nr_running),
19315 + atomic_read(&cvirt->nr_uninterruptible),
19316 + atomic_read(&cvirt->nr_onhold),
19317 + atomic_read(&cvirt->load_updates),
19318 + LOAD_INT(a), LOAD_FRAC(a),
19319 + LOAD_INT(b), LOAD_FRAC(b),
19320 + LOAD_INT(c), LOAD_FRAC(c),
19321 + atomic_read(&cvirt->total_forks));
19326 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
19327 + char *buffer, int cpu)
19333 +#endif /* _VX_CVIRT_PROC_H */
19334 diff -NurpP --minimal linux-3.1/kernel/vserver/debug.c linux-3.1-vs2.3.1-rc2/kernel/vserver/debug.c
19335 --- linux-3.1/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
19336 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/debug.c 2011-10-24 18:53:33.000000000 +0200
19339 + * kernel/vserver/debug.c
19341 + * Copyright (C) 2005-2007 Herbert Pötzl
19343 + * V0.01 vx_info dump support
19347 +#include <linux/module.h>
19349 +#include <linux/vserver/context.h>
19352 +void dump_vx_info(struct vx_info *vxi, int level)
19354 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
19355 + atomic_read(&vxi->vx_usecnt),
19356 + atomic_read(&vxi->vx_tasks),
19359 + __dump_vx_limit(&vxi->limit);
19360 + __dump_vx_sched(&vxi->sched);
19361 + __dump_vx_cvirt(&vxi->cvirt);
19362 + __dump_vx_cacct(&vxi->cacct);
19368 +EXPORT_SYMBOL_GPL(dump_vx_info);
19370 diff -NurpP --minimal linux-3.1/kernel/vserver/device.c linux-3.1-vs2.3.1-rc2/kernel/vserver/device.c
19371 --- linux-3.1/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
19372 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/device.c 2011-10-24 18:53:33.000000000 +0200
19375 + * linux/kernel/vserver/device.c
19377 + * Linux-VServer: Device Support
19379 + * Copyright (C) 2006 Herbert Pötzl
19380 + * Copyright (C) 2007 Daniel Hokka Zakrisson
19382 + * V0.01 device mapping basics
19383 + * V0.02 added defaults
19387 +#include <linux/slab.h>
19388 +#include <linux/rcupdate.h>
19389 +#include <linux/fs.h>
19390 +#include <linux/namei.h>
19391 +#include <linux/hash.h>
19393 +#include <asm/errno.h>
19394 +#include <asm/uaccess.h>
19395 +#include <linux/vserver/base.h>
19396 +#include <linux/vserver/debug.h>
19397 +#include <linux/vserver/context.h>
19398 +#include <linux/vserver/device.h>
19399 +#include <linux/vserver/device_cmd.h>
19402 +#define DMAP_HASH_BITS 4
19405 +struct vs_mapping {
19407 + struct hlist_node hlist;
19408 + struct list_head list;
19410 +#define dm_hlist u.hlist
19411 +#define dm_list u.list
19414 + struct vx_dmap_target target;
19418 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
19420 +static DEFINE_SPINLOCK(dmap_main_hash_lock);
19422 +static struct vx_dmap_target dmap_defaults[2] = {
19423 + { .flags = DATTR_OPEN },
19424 + { .flags = DATTR_OPEN },
19428 +struct kmem_cache *dmap_cachep __read_mostly;
19430 +int __init dmap_cache_init(void)
19432 + dmap_cachep = kmem_cache_create("dmap_cache",
19433 + sizeof(struct vs_mapping), 0,
19434 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
19438 +__initcall(dmap_cache_init);
19441 +static inline unsigned int __hashval(dev_t dev, int bits)
19443 + return hash_long((unsigned long)dev, bits);
19447 +/* __hash_mapping()
19448 + * add the mapping to the hash table
19450 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
19452 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19453 + struct hlist_head *head, *hash = dmap_main_hash;
19454 + int device = vdm->device;
19456 + spin_lock(hash_lock);
19457 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
19458 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
19460 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
19461 + hlist_add_head(&vdm->dm_hlist, head);
19462 + spin_unlock(hash_lock);
19466 +static inline int __mode_to_default(umode_t mode)
19479 +/* __set_default()
19482 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
19483 + struct vx_dmap_target *vdmt)
19485 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19486 + spin_lock(hash_lock);
19489 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
19491 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
19494 + spin_unlock(hash_lock);
19496 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
19497 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
19501 +/* __remove_default()
19502 + * remove a default
19504 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
19506 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19507 + spin_lock(hash_lock);
19510 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
19511 + else /* remove == reset */
19512 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
19514 + spin_unlock(hash_lock);
19519 +/* __find_mapping()
19520 + * find a mapping in the hash table
19522 + * caller must hold hash_lock
19524 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
19525 + struct vs_mapping **local, struct vs_mapping **global)
19527 + struct hlist_head *hash = dmap_main_hash;
19528 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
19529 + struct hlist_node *pos;
19530 + struct vs_mapping *vdm;
19536 + hlist_for_each(pos, head) {
19537 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
19539 + if ((vdm->device == device) &&
19540 + !((vdm->target.flags ^ mode) & S_IFMT)) {
19541 + if (vdm->xid == xid) {
19544 + } else if (global && vdm->xid == 0)
19549 + if (global && *global)
19556 +/* __lookup_mapping()
19557 + * find a mapping and store the result in target and flags
19559 +static inline int __lookup_mapping(struct vx_info *vxi,
19560 + dev_t device, dev_t *target, int *flags, umode_t mode)
19562 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19563 + struct vs_mapping *vdm, *global;
19564 + struct vx_dmap_target *vdmt;
19566 + xid_t xid = vxi->vx_id;
19569 + spin_lock(hash_lock);
19570 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
19572 + vdmt = &vdm->target;
19576 + index = __mode_to_default(mode);
19577 + if (vxi && vxi->dmap.targets[index].flags) {
19579 + vdmt = &vxi->dmap.targets[index];
19580 + } else if (global) {
19582 + vdmt = &global->target;
19586 + vdmt = &dmap_defaults[index];
19590 + if (target && (vdmt->flags & DATTR_REMAP))
19591 + *target = vdmt->target;
19593 + *target = device;
19595 + *flags = vdmt->flags;
19597 + spin_unlock(hash_lock);
19603 +/* __remove_mapping()
19604 + * remove a mapping from the hash table
19606 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
19609 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19610 + struct vs_mapping *vdm = NULL;
19613 + spin_lock(hash_lock);
19615 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
19617 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
19618 + vxi, vxi ? vxi->vx_id : 0, device, mode);
19621 + hlist_del(&vdm->dm_hlist);
19624 + spin_unlock(hash_lock);
19626 + kmem_cache_free(dmap_cachep, vdm);
19632 +int vs_map_device(struct vx_info *vxi,
19633 + dev_t device, dev_t *target, umode_t mode)
19635 + int ret, flags = DATTR_MASK;
19639 + *target = device;
19642 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
19643 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
19644 + device, target ? *target : 0, flags, mode, ret);
19646 + return (flags & DATTR_MASK);
19651 +static int do_set_mapping(struct vx_info *vxi,
19652 + dev_t device, dev_t target, int flags, umode_t mode)
19655 + struct vs_mapping *new;
19657 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
19661 + INIT_HLIST_NODE(&new->dm_hlist);
19662 + new->device = device;
19663 + new->target.target = target;
19664 + new->target.flags = flags | mode;
19665 + new->xid = (vxi ? vxi->vx_id : 0);
19667 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
19668 + __hash_mapping(vxi, new);
19670 + struct vx_dmap_target new = {
19671 + .target = target,
19672 + .flags = flags | mode,
19674 + __set_default(vxi, mode, &new);
19680 +static int do_unset_mapping(struct vx_info *vxi,
19681 + dev_t device, dev_t target, int flags, umode_t mode)
19683 + int ret = -EINVAL;
19686 + ret = __remove_mapping(vxi, device, mode);
19690 + ret = __remove_default(vxi, mode);
19700 +static inline int __user_device(const char __user *name, dev_t *dev,
19703 + struct nameidata nd;
19710 + ret = user_lpath(name, &nd.path);
19713 + if (nd.path.dentry->d_inode) {
19714 + *dev = nd.path.dentry->d_inode->i_rdev;
19715 + *mode = nd.path.dentry->d_inode->i_mode;
19717 + path_put(&nd.path);
19721 +static inline int __mapping_mode(dev_t device, dev_t target,
19722 + umode_t device_mode, umode_t target_mode, umode_t *mode)
19725 + *mode = device_mode & S_IFMT;
19727 + *mode = target_mode & S_IFMT;
19731 + /* if both given, device and target mode have to match */
19732 + if (device && target &&
19733 + ((device_mode ^ target_mode) & S_IFMT))
19739 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
19740 + const char __user *target_path, int flags, int set)
19742 + dev_t device = ~0, target = ~0;
19743 + umode_t device_mode = 0, target_mode = 0, mode;
19746 + ret = __user_device(device_path, &device, &device_mode);
19749 + ret = __user_device(target_path, &target, &target_mode);
19753 + ret = __mapping_mode(device, target,
19754 + device_mode, target_mode, &mode);
19759 + return do_set_mapping(vxi, device, target,
19762 + return do_unset_mapping(vxi, device, target,
19767 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
19769 + struct vcmd_set_mapping_v0 vc_data;
19771 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19774 + return do_mapping(vxi, vc_data.device, vc_data.target,
19775 + vc_data.flags, 1);
19778 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
19780 + struct vcmd_set_mapping_v0 vc_data;
19782 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19785 + return do_mapping(vxi, vc_data.device, vc_data.target,
19786 + vc_data.flags, 0);
19790 +#ifdef CONFIG_COMPAT
19792 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
19794 + struct vcmd_set_mapping_v0_x32 vc_data;
19796 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19799 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19800 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
19803 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
19805 + struct vcmd_set_mapping_v0_x32 vc_data;
19807 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19810 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
19811 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
19814 +#endif /* CONFIG_COMPAT */
19817 diff -NurpP --minimal linux-3.1/kernel/vserver/dlimit.c linux-3.1-vs2.3.1-rc2/kernel/vserver/dlimit.c
19818 --- linux-3.1/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
19819 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/dlimit.c 2011-10-24 18:53:33.000000000 +0200
19822 + * linux/kernel/vserver/dlimit.c
19824 + * Virtual Server: Context Disk Limits
19826 + * Copyright (C) 2004-2009 Herbert Pötzl
19828 + * V0.01 initial version
19829 + * V0.02 compat32 splitup
19830 + * V0.03 extended interface
19834 +#include <linux/statfs.h>
19835 +#include <linux/sched.h>
19836 +#include <linux/namei.h>
19837 +#include <linux/vs_tag.h>
19838 +#include <linux/vs_dlimit.h>
19839 +#include <linux/vserver/dlimit_cmd.h>
19840 +#include <linux/slab.h>
19841 +// #include <linux/gfp.h>
19843 +#include <asm/uaccess.h>
19845 +/* __alloc_dl_info()
19847 + * allocate an initialized dl_info struct
19848 + * doesn't make it visible (hash) */
19850 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
19852 + struct dl_info *new = NULL;
19854 + vxdprintk(VXD_CBIT(dlim, 5),
19855 + "alloc_dl_info(%p,%d)*", sb, tag);
19857 + /* would this benefit from a slab cache? */
19858 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
19862 + memset(new, 0, sizeof(struct dl_info));
19863 + new->dl_tag = tag;
19865 + // INIT_RCU_HEAD(&new->dl_rcu);
19866 + INIT_HLIST_NODE(&new->dl_hlist);
19867 + spin_lock_init(&new->dl_lock);
19868 + atomic_set(&new->dl_refcnt, 0);
19869 + atomic_set(&new->dl_usecnt, 0);
19871 + /* rest of init goes here */
19873 + vxdprintk(VXD_CBIT(dlim, 4),
19874 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
19878 +/* __dealloc_dl_info()
19880 + * final disposal of dl_info */
19882 +static void __dealloc_dl_info(struct dl_info *dli)
19884 + vxdprintk(VXD_CBIT(dlim, 4),
19885 + "dealloc_dl_info(%p)", dli);
19887 + dli->dl_hlist.next = LIST_POISON1;
19888 + dli->dl_tag = -1;
19891 + BUG_ON(atomic_read(&dli->dl_usecnt));
19892 + BUG_ON(atomic_read(&dli->dl_refcnt));
19898 +/* hash table for dl_info hash */
19900 +#define DL_HASH_SIZE 13
19902 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
19904 +static DEFINE_SPINLOCK(dl_info_hash_lock);
19907 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
19909 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
19914 +/* __hash_dl_info()
19916 + * add the dli to the global hash table
19917 + * requires the hash_lock to be held */
19919 +static inline void __hash_dl_info(struct dl_info *dli)
19921 + struct hlist_head *head;
19923 + vxdprintk(VXD_CBIT(dlim, 6),
19924 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
19925 + get_dl_info(dli);
19926 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
19927 + hlist_add_head_rcu(&dli->dl_hlist, head);
19930 +/* __unhash_dl_info()
19932 + * remove the dli from the global hash table
19933 + * requires the hash_lock to be held */
19935 +static inline void __unhash_dl_info(struct dl_info *dli)
19937 + vxdprintk(VXD_CBIT(dlim, 6),
19938 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
19939 + hlist_del_rcu(&dli->dl_hlist);
19940 + put_dl_info(dli);
19944 +/* __lookup_dl_info()
19946 + * requires the rcu_read_lock()
19947 + * doesn't increment the dl_refcnt */
19949 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
19951 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
19952 + struct hlist_node *pos;
19953 + struct dl_info *dli;
19955 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
19957 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
19965 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
19967 + struct dl_info *dli;
19970 + dli = get_dl_info(__lookup_dl_info(sb, tag));
19971 + vxdprintk(VXD_CBIT(dlim, 7),
19972 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
19973 + rcu_read_unlock();
19977 +void rcu_free_dl_info(struct rcu_head *head)
19979 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
19980 + int usecnt, refcnt;
19982 + BUG_ON(!dli || !head);
19984 + usecnt = atomic_read(&dli->dl_usecnt);
19985 + BUG_ON(usecnt < 0);
19987 + refcnt = atomic_read(&dli->dl_refcnt);
19988 + BUG_ON(refcnt < 0);
19990 + vxdprintk(VXD_CBIT(dlim, 3),
19991 + "rcu_free_dl_info(%p)", dli);
19993 + __dealloc_dl_info(dli);
19995 + printk("!!! rcu didn't free\n");
20001 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
20002 + uint32_t flags, int add)
20004 + struct path path;
20007 + ret = user_lpath(name, &path);
20009 + struct super_block *sb;
20010 + struct dl_info *dli;
20013 + if (!path.dentry->d_inode)
20014 + goto out_release;
20015 + if (!(sb = path.dentry->d_inode->i_sb))
20016 + goto out_release;
20019 + dli = __alloc_dl_info(sb, id);
20020 + spin_lock(&dl_info_hash_lock);
20023 + if (__lookup_dl_info(sb, id))
20025 + __hash_dl_info(dli);
20028 + spin_lock(&dl_info_hash_lock);
20029 + dli = __lookup_dl_info(sb, id);
20034 + __unhash_dl_info(dli);
20038 + spin_unlock(&dl_info_hash_lock);
20040 + __dealloc_dl_info(dli);
20047 +int vc_add_dlimit(uint32_t id, void __user *data)
20049 + struct vcmd_ctx_dlimit_base_v0 vc_data;
20051 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20054 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
20057 +int vc_rem_dlimit(uint32_t id, void __user *data)
20059 + struct vcmd_ctx_dlimit_base_v0 vc_data;
20061 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20064 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
20067 +#ifdef CONFIG_COMPAT
20069 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
20071 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
20073 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20076 + return do_addrem_dlimit(id,
20077 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
20080 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
20082 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
20084 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20087 + return do_addrem_dlimit(id,
20088 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
20091 +#endif /* CONFIG_COMPAT */
20095 +int do_set_dlimit(uint32_t id, const char __user *name,
20096 + uint32_t space_used, uint32_t space_total,
20097 + uint32_t inodes_used, uint32_t inodes_total,
20098 + uint32_t reserved, uint32_t flags)
20100 + struct path path;
20103 + ret = user_lpath(name, &path);
20105 + struct super_block *sb;
20106 + struct dl_info *dli;
20109 + if (!path.dentry->d_inode)
20110 + goto out_release;
20111 + if (!(sb = path.dentry->d_inode->i_sb))
20112 + goto out_release;
20114 + /* sanity checks */
20115 + if ((reserved != CDLIM_KEEP &&
20116 + reserved > 100) ||
20117 + (inodes_used != CDLIM_KEEP &&
20118 + inodes_used > inodes_total) ||
20119 + (space_used != CDLIM_KEEP &&
20120 + space_used > space_total))
20121 + goto out_release;
20124 + dli = locate_dl_info(sb, id);
20126 + goto out_release;
20128 + spin_lock(&dli->dl_lock);
20130 + if (inodes_used != CDLIM_KEEP)
20131 + dli->dl_inodes_used = inodes_used;
20132 + if (inodes_total != CDLIM_KEEP)
20133 + dli->dl_inodes_total = inodes_total;
20134 + if (space_used != CDLIM_KEEP)
20135 + dli->dl_space_used = dlimit_space_32to64(
20136 + space_used, flags, DLIMS_USED);
20138 + if (space_total == CDLIM_INFINITY)
20139 + dli->dl_space_total = DLIM_INFINITY;
20140 + else if (space_total != CDLIM_KEEP)
20141 + dli->dl_space_total = dlimit_space_32to64(
20142 + space_total, flags, DLIMS_TOTAL);
20144 + if (reserved != CDLIM_KEEP)
20145 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
20147 + spin_unlock(&dli->dl_lock);
20149 + put_dl_info(dli);
20158 +int vc_set_dlimit(uint32_t id, void __user *data)
20160 + struct vcmd_ctx_dlimit_v0 vc_data;
20162 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20165 + return do_set_dlimit(id, vc_data.name,
20166 + vc_data.space_used, vc_data.space_total,
20167 + vc_data.inodes_used, vc_data.inodes_total,
20168 + vc_data.reserved, vc_data.flags);
20171 +#ifdef CONFIG_COMPAT
20173 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
20175 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
20177 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20180 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
20181 + vc_data.space_used, vc_data.space_total,
20182 + vc_data.inodes_used, vc_data.inodes_total,
20183 + vc_data.reserved, vc_data.flags);
20186 +#endif /* CONFIG_COMPAT */
20190 +int do_get_dlimit(uint32_t id, const char __user *name,
20191 + uint32_t *space_used, uint32_t *space_total,
20192 + uint32_t *inodes_used, uint32_t *inodes_total,
20193 + uint32_t *reserved, uint32_t *flags)
20195 + struct path path;
20198 + ret = user_lpath(name, &path);
20200 + struct super_block *sb;
20201 + struct dl_info *dli;
20204 + if (!path.dentry->d_inode)
20205 + goto out_release;
20206 + if (!(sb = path.dentry->d_inode->i_sb))
20207 + goto out_release;
20210 + dli = locate_dl_info(sb, id);
20212 + goto out_release;
20214 + spin_lock(&dli->dl_lock);
20215 + *inodes_used = dli->dl_inodes_used;
20216 + *inodes_total = dli->dl_inodes_total;
20218 + *space_used = dlimit_space_64to32(
20219 + dli->dl_space_used, flags, DLIMS_USED);
20221 + if (dli->dl_space_total == DLIM_INFINITY)
20222 + *space_total = CDLIM_INFINITY;
20224 + *space_total = dlimit_space_64to32(
20225 + dli->dl_space_total, flags, DLIMS_TOTAL);
20227 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
20228 + spin_unlock(&dli->dl_lock);
20230 + put_dl_info(dli);
20241 +int vc_get_dlimit(uint32_t id, void __user *data)
20243 + struct vcmd_ctx_dlimit_v0 vc_data;
20246 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20249 + ret = do_get_dlimit(id, vc_data.name,
20250 + &vc_data.space_used, &vc_data.space_total,
20251 + &vc_data.inodes_used, &vc_data.inodes_total,
20252 + &vc_data.reserved, &vc_data.flags);
20256 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20261 +#ifdef CONFIG_COMPAT
20263 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
20265 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
20268 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20271 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
20272 + &vc_data.space_used, &vc_data.space_total,
20273 + &vc_data.inodes_used, &vc_data.inodes_total,
20274 + &vc_data.reserved, &vc_data.flags);
20278 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20283 +#endif /* CONFIG_COMPAT */
20286 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
20288 + struct dl_info *dli;
20289 + __u64 blimit, bfree, bavail;
20292 + dli = locate_dl_info(sb, dx_current_tag());
20296 + spin_lock(&dli->dl_lock);
20297 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
20300 + /* reduce max inodes available to limit */
20301 + if (buf->f_files > dli->dl_inodes_total)
20302 + buf->f_files = dli->dl_inodes_total;
20304 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
20305 + /* reduce free inodes to min */
20306 + if (ifree < buf->f_ffree)
20307 + buf->f_ffree = ifree;
20310 + if (dli->dl_space_total == DLIM_INFINITY)
20313 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
20315 + if (dli->dl_space_total < dli->dl_space_used)
20318 + bfree = (dli->dl_space_total - dli->dl_space_used)
20319 + >> sb->s_blocksize_bits;
20321 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
20322 + if (bavail < dli->dl_space_used)
20325 + bavail = (bavail - dli->dl_space_used)
20326 + >> sb->s_blocksize_bits;
20328 + /* reduce max space available to limit */
20329 + if (buf->f_blocks > blimit)
20330 + buf->f_blocks = blimit;
20332 + /* reduce free space to min */
20333 + if (bfree < buf->f_bfree)
20334 + buf->f_bfree = bfree;
20336 + /* reduce avail space to min */
20337 + if (bavail < buf->f_bavail)
20338 + buf->f_bavail = bavail;
20341 + spin_unlock(&dli->dl_lock);
20342 + put_dl_info(dli);
20347 +#include <linux/module.h>
20349 +EXPORT_SYMBOL_GPL(locate_dl_info);
20350 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
20352 diff -NurpP --minimal linux-3.1/kernel/vserver/helper.c linux-3.1-vs2.3.1-rc2/kernel/vserver/helper.c
20353 --- linux-3.1/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
20354 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/helper.c 2011-10-24 18:53:33.000000000 +0200
20357 + * linux/kernel/vserver/helper.c
20359 + * Virtual Context Support
20361 + * Copyright (C) 2004-2007 Herbert Pötzl
20363 + * V0.01 basic helper
20367 +#include <linux/kmod.h>
20368 +#include <linux/reboot.h>
20369 +#include <linux/vs_context.h>
20370 +#include <linux/vs_network.h>
20371 +#include <linux/vserver/signal.h>
20374 +char vshelper_path[255] = "/sbin/vshelper";
20377 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
20381 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
20382 + printk( KERN_WARNING
20383 + "%s: (%s %s) returned %s with %d\n",
20384 + name, argv[1], argv[2],
20385 + sync ? "sync" : "async", ret);
20387 + vxdprintk(VXD_CBIT(switch, 4),
20388 + "%s: (%s %s) returned %s with %d",
20389 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
20394 + * vshelper path is set via /proc/sys
20395 + * invoked by vserver sys_reboot(), with
20396 + * the following arguments
20398 + * argv [0] = vshelper_path;
20399 + * argv [1] = action: "restart", "halt", "poweroff", ...
20400 + * argv [2] = context identifier
20402 + * envp [*] = type-specific parameters
20405 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
20407 + char id_buf[8], cmd_buf[16];
20408 + char uid_buf[16], pid_buf[16];
20411 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20412 + char *envp[] = {"HOME=/", "TERM=linux",
20413 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
20414 + uid_buf, pid_buf, cmd_buf, 0};
20416 + if (vx_info_state(vxi, VXS_HELPER))
20418 + vxi->vx_state |= VXS_HELPER;
20420 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20422 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20423 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
20424 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
20427 + case LINUX_REBOOT_CMD_RESTART:
20428 + argv[1] = "restart";
20431 + case LINUX_REBOOT_CMD_HALT:
20432 + argv[1] = "halt";
20435 + case LINUX_REBOOT_CMD_POWER_OFF:
20436 + argv[1] = "poweroff";
20439 + case LINUX_REBOOT_CMD_SW_SUSPEND:
20440 + argv[1] = "swsusp";
20443 + case LINUX_REBOOT_CMD_OOM:
20448 + vxi->vx_state &= ~VXS_HELPER;
20452 + ret = do_vshelper(vshelper_path, argv, envp, 0);
20453 + vxi->vx_state &= ~VXS_HELPER;
20454 + __wakeup_vx_info(vxi);
20455 + return (ret) ? -EPERM : 0;
20459 +long vs_reboot(unsigned int cmd, void __user *arg)
20461 + struct vx_info *vxi = current_vx_info();
20464 + vxdprintk(VXD_CBIT(misc, 5),
20465 + "vs_reboot(%p[#%d],%u)",
20466 + vxi, vxi ? vxi->vx_id : 0, cmd);
20468 + ret = vs_reboot_helper(vxi, cmd, arg);
20472 + vxi->reboot_cmd = cmd;
20473 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20475 + case LINUX_REBOOT_CMD_RESTART:
20476 + case LINUX_REBOOT_CMD_HALT:
20477 + case LINUX_REBOOT_CMD_POWER_OFF:
20478 + vx_info_kill(vxi, 0, SIGKILL);
20479 + vx_info_kill(vxi, 1, SIGKILL);
20487 +long vs_oom_action(unsigned int cmd)
20489 + struct vx_info *vxi = current_vx_info();
20492 + vxdprintk(VXD_CBIT(misc, 5),
20493 + "vs_oom_action(%p[#%d],%u)",
20494 + vxi, vxi ? vxi->vx_id : 0, cmd);
20496 + ret = vs_reboot_helper(vxi, cmd, NULL);
20500 + vxi->reboot_cmd = cmd;
20501 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20502 + vx_info_kill(vxi, 0, SIGKILL);
20503 + vx_info_kill(vxi, 1, SIGKILL);
20509 + * argv [0] = vshelper_path;
20510 + * argv [1] = action: "startup", "shutdown"
20511 + * argv [2] = context identifier
20513 + * envp [*] = type-specific parameters
20516 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
20518 + char id_buf[8], cmd_buf[16];
20519 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20520 + char *envp[] = {"HOME=/", "TERM=linux",
20521 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20523 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
20526 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20527 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20530 + case VSC_STARTUP:
20531 + argv[1] = "startup";
20533 + case VSC_SHUTDOWN:
20534 + argv[1] = "shutdown";
20540 + return do_vshelper(vshelper_path, argv, envp, 1);
20545 + * argv [0] = vshelper_path;
20546 + * argv [1] = action: "netup", "netdown"
20547 + * argv [2] = context identifier
20549 + * envp [*] = type-specific parameters
20552 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
20554 + char id_buf[8], cmd_buf[16];
20555 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20556 + char *envp[] = {"HOME=/", "TERM=linux",
20557 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20559 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
20562 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
20563 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20567 + argv[1] = "netup";
20569 + case VSC_NETDOWN:
20570 + argv[1] = "netdown";
20576 + return do_vshelper(vshelper_path, argv, envp, 1);
20579 diff -NurpP --minimal linux-3.1/kernel/vserver/history.c linux-3.1-vs2.3.1-rc2/kernel/vserver/history.c
20580 --- linux-3.1/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
20581 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/history.c 2011-10-24 18:53:33.000000000 +0200
20584 + * kernel/vserver/history.c
20586 + * Virtual Context History Backtrace
20588 + * Copyright (C) 2004-2007 Herbert Pötzl
20590 + * V0.01 basic structure
20591 + * V0.02 hash/unhash and trace
20592 + * V0.03 preemption fixes
20596 +#include <linux/module.h>
20597 +#include <asm/uaccess.h>
20599 +#include <linux/vserver/context.h>
20600 +#include <linux/vserver/debug.h>
20601 +#include <linux/vserver/debug_cmd.h>
20602 +#include <linux/vserver/history.h>
20605 +#ifdef CONFIG_VSERVER_HISTORY
20606 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
20608 +#define VXH_SIZE 64
20611 +struct _vx_history {
20612 + unsigned int counter;
20614 + struct _vx_hist_entry entry[VXH_SIZE + 1];
20618 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
20620 +unsigned volatile int vxh_active = 1;
20622 +static atomic_t sequence = ATOMIC_INIT(0);
20627 + * requires disabled preemption */
20629 +struct _vx_hist_entry *vxh_advance(void *loc)
20631 + unsigned int cpu = smp_processor_id();
20632 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20633 + struct _vx_hist_entry *entry;
20634 + unsigned int index;
20636 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
20637 + entry = &hist->entry[index];
20639 + entry->seq = atomic_inc_return(&sequence);
20640 + entry->loc = loc;
20644 +EXPORT_SYMBOL_GPL(vxh_advance);
20647 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
20649 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
20652 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
20654 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
20655 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
20656 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
20657 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
20659 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
20661 + switch (e->type) {
20662 + case VXH_THROW_OOPS:
20663 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
20666 + case VXH_GET_VX_INFO:
20667 + case VXH_PUT_VX_INFO:
20668 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20670 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
20671 + VXH_VXI_ARGS(e));
20674 + case VXH_INIT_VX_INFO:
20675 + case VXH_SET_VX_INFO:
20676 + case VXH_CLR_VX_INFO:
20677 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20679 + (e->type == VXH_INIT_VX_INFO) ? "init" :
20680 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
20681 + VXH_VXI_ARGS(e), e->sc.data);
20684 + case VXH_CLAIM_VX_INFO:
20685 + case VXH_RELEASE_VX_INFO:
20686 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20688 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
20689 + VXH_VXI_ARGS(e), e->sc.data);
20692 + case VXH_ALLOC_VX_INFO:
20693 + case VXH_DEALLOC_VX_INFO:
20694 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20696 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
20697 + VXH_VXI_ARGS(e));
20700 + case VXH_HASH_VX_INFO:
20701 + case VXH_UNHASH_VX_INFO:
20702 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
20704 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
20705 + VXH_VXI_ARGS(e));
20708 + case VXH_LOC_VX_INFO:
20709 + case VXH_LOOKUP_VX_INFO:
20710 + case VXH_CREATE_VX_INFO:
20711 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
20713 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
20714 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
20715 + e->ll.arg, VXH_VXI_ARGS(e));
20720 +static void __vxh_dump_history(void)
20722 + unsigned int i, cpu;
20724 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
20725 + atomic_read(&sequence), NR_CPUS);
20727 + for (i = 0; i < VXH_SIZE; i++) {
20728 + for_each_online_cpu(cpu) {
20729 + struct _vx_history *hist =
20730 + &per_cpu(vx_history_buffer, cpu);
20731 + unsigned int index = (hist->counter - i) % VXH_SIZE;
20732 + struct _vx_hist_entry *entry = &hist->entry[index];
20734 + vxh_dump_entry(entry, cpu);
20739 +void vxh_dump_history(void)
20743 + local_irq_enable();
20745 + local_irq_disable();
20747 + __vxh_dump_history();
20751 +/* vserver syscall commands below here */
20754 +int vc_dump_history(uint32_t id)
20757 + __vxh_dump_history();
20764 +int do_read_history(struct __user _vx_hist_entry *data,
20765 + int cpu, uint32_t *index, uint32_t *count)
20767 + int pos, ret = 0;
20768 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20769 + int end = hist->counter;
20770 + int start = end - VXH_SIZE + 2;
20771 + int idx = *index;
20773 + /* special case: get current pos */
20779 + /* have we lost some data? */
20783 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
20784 + struct _vx_hist_entry *entry =
20785 + &hist->entry[idx % VXH_SIZE];
20787 + /* send entry to userspace */
20788 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
20792 + /* save new index and count */
20795 + return ret ? ret : (*index < end);
20798 +int vc_read_history(uint32_t id, void __user *data)
20800 + struct vcmd_read_history_v0 vc_data;
20803 + if (id >= NR_CPUS)
20806 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20809 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
20810 + id, &vc_data.index, &vc_data.count);
20812 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20817 +#ifdef CONFIG_COMPAT
20819 +int vc_read_history_x32(uint32_t id, void __user *data)
20821 + struct vcmd_read_history_v0_x32 vc_data;
20824 + if (id >= NR_CPUS)
20827 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20830 + ret = do_read_history((struct __user _vx_hist_entry *)
20831 + compat_ptr(vc_data.data_ptr),
20832 + id, &vc_data.index, &vc_data.count);
20834 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20839 +#endif /* CONFIG_COMPAT */
20841 diff -NurpP --minimal linux-3.1/kernel/vserver/inet.c linux-3.1-vs2.3.1-rc2/kernel/vserver/inet.c
20842 --- linux-3.1/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
20843 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/inet.c 2011-10-24 18:53:33.000000000 +0200
20846 +#include <linux/in.h>
20847 +#include <linux/inetdevice.h>
20848 +#include <linux/vs_inet.h>
20849 +#include <linux/vs_inet6.h>
20850 +#include <linux/vserver/debug.h>
20851 +#include <net/route.h>
20852 +#include <net/addrconf.h>
20855 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20859 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
20862 + struct nx_addr_v4 *ptr;
20864 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
20865 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20872 + vxdprintk(VXD_CBIT(net, 2),
20873 + "nx_v4_addr_conflict(%p,%p): %d",
20874 + nxi1, nxi2, ret);
20880 +#ifdef CONFIG_IPV6
20882 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
20886 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
20889 + struct nx_addr_v6 *ptr;
20891 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
20892 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
20899 + vxdprintk(VXD_CBIT(net, 2),
20900 + "nx_v6_addr_conflict(%p,%p): %d",
20901 + nxi1, nxi2, ret);
20908 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20910 + struct in_device *in_dev;
20911 + struct in_ifaddr **ifap;
20912 + struct in_ifaddr *ifa;
20917 + in_dev = in_dev_get(dev);
20921 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
20922 + ifap = &ifa->ifa_next) {
20923 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
20928 + in_dev_put(in_dev);
20934 +#ifdef CONFIG_IPV6
20936 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20938 + struct inet6_dev *in_dev;
20939 + struct inet6_ifaddr *ifa;
20944 + in_dev = in6_dev_get(dev);
20948 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
20949 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
20950 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
20955 + in6_dev_put(in_dev);
20962 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
20968 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
20970 +#ifdef CONFIG_IPV6
20972 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
20977 + vxdprintk(VXD_CBIT(net, 3),
20978 + "dev_in_nx_info(%p,%p[#%d]) = %d",
20979 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
20983 +struct rtable *ip_v4_find_src(struct net *net, struct nx_info *nxi,
20984 + struct flowi4 *fl4)
20986 + struct rtable *rt;
20991 + /* FIXME: handle lback only case */
20992 + if (!NX_IPV4(nxi))
20993 + return ERR_PTR(-EPERM);
20995 + vxdprintk(VXD_CBIT(net, 4),
20996 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
20997 + nxi, nxi ? nxi->nx_id : 0,
20998 + NIPQUAD(fl4->saddr), NIPQUAD(fl4->daddr));
21000 + /* single IP is unconditional */
21001 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
21002 + (fl4->saddr == INADDR_ANY))
21003 + fl4->saddr = nxi->v4.ip[0].s_addr;
21005 + if (fl4->saddr == INADDR_ANY) {
21006 + struct nx_addr_v4 *ptr;
21007 + __be32 found = 0;
21009 + rt = __ip_route_output_key(net, fl4);
21010 + if (!IS_ERR(rt)) {
21011 + found = fl4->saddr;
21013 + vxdprintk(VXD_CBIT(net, 4),
21014 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
21015 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(found));
21016 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
21020 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
21021 + __be32 primary = ptr->ip[0].s_addr;
21022 + __be32 mask = ptr->mask.s_addr;
21023 + __be32 neta = primary & mask;
21025 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
21026 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
21027 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
21028 + NIPQUAD(mask), NIPQUAD(neta));
21029 + if ((found & mask) != neta)
21032 + fl4->saddr = primary;
21033 + rt = __ip_route_output_key(net, fl4);
21034 + vxdprintk(VXD_CBIT(net, 4),
21035 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
21036 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(primary));
21037 + if (!IS_ERR(rt)) {
21038 + found = fl4->saddr;
21040 + if (found == primary)
21044 + /* still no source ip? */
21045 + found = ipv4_is_loopback(fl4->daddr)
21046 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
21048 + /* assign src ip to flow */
21049 + fl4->saddr = found;
21052 + if (!v4_addr_in_nx_info(nxi, fl4->saddr, NXA_MASK_BIND))
21053 + return ERR_PTR(-EPERM);
21056 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
21057 + if (ipv4_is_loopback(fl4->daddr))
21058 + fl4->daddr = nxi->v4_lback.s_addr;
21059 + if (ipv4_is_loopback(fl4->saddr))
21060 + fl4->saddr = nxi->v4_lback.s_addr;
21061 + } else if (ipv4_is_loopback(fl4->daddr) &&
21062 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
21063 + return ERR_PTR(-EPERM);
21068 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
21070 diff -NurpP --minimal linux-3.1/kernel/vserver/init.c linux-3.1-vs2.3.1-rc2/kernel/vserver/init.c
21071 --- linux-3.1/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
21072 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/init.c 2011-10-24 18:53:33.000000000 +0200
21075 + * linux/kernel/init.c
21077 + * Virtual Server Init
21079 + * Copyright (C) 2004-2007 Herbert Pötzl
21081 + * V0.01 basic structure
21085 +#include <linux/init.h>
21087 +int vserver_register_sysctl(void);
21088 +void vserver_unregister_sysctl(void);
21091 +static int __init init_vserver(void)
21095 +#ifdef CONFIG_VSERVER_DEBUG
21096 + vserver_register_sysctl();
21102 +static void __exit exit_vserver(void)
21105 +#ifdef CONFIG_VSERVER_DEBUG
21106 + vserver_unregister_sysctl();
21111 +/* FIXME: GFP_ZONETYPES gone
21112 +long vx_slab[GFP_ZONETYPES]; */
21116 +module_init(init_vserver);
21117 +module_exit(exit_vserver);
21119 diff -NurpP --minimal linux-3.1/kernel/vserver/inode.c linux-3.1-vs2.3.1-rc2/kernel/vserver/inode.c
21120 --- linux-3.1/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
21121 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/inode.c 2011-10-24 18:53:33.000000000 +0200
21124 + * linux/kernel/vserver/inode.c
21126 + * Virtual Server: File System Support
21128 + * Copyright (C) 2004-2007 Herbert Pötzl
21130 + * V0.01 separated from vcontext V0.05
21131 + * V0.02 moved to tag (instead of xid)
21135 +#include <linux/tty.h>
21136 +#include <linux/proc_fs.h>
21137 +#include <linux/devpts_fs.h>
21138 +#include <linux/fs.h>
21139 +#include <linux/file.h>
21140 +#include <linux/mount.h>
21141 +#include <linux/parser.h>
21142 +#include <linux/namei.h>
21143 +#include <linux/vserver/inode.h>
21144 +#include <linux/vserver/inode_cmd.h>
21145 +#include <linux/vs_base.h>
21146 +#include <linux/vs_tag.h>
21148 +#include <asm/uaccess.h>
21151 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21153 + struct proc_dir_entry *entry;
21155 + if (!in || !in->i_sb)
21158 + *flags = IATTR_TAG
21159 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
21160 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
21161 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
21162 + | (IS_COW(in) ? IATTR_COW : 0);
21163 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
21165 + if (S_ISDIR(in->i_mode))
21166 + *mask |= IATTR_BARRIER;
21168 + if (IS_TAGGED(in)) {
21169 + *tag = in->i_tag;
21170 + *mask |= IATTR_TAG;
21173 + switch (in->i_sb->s_magic) {
21174 + case PROC_SUPER_MAGIC:
21175 + entry = PROC_I(in)->pde;
21177 + /* check for specific inodes? */
21179 + *mask |= IATTR_FLAGS;
21181 + *flags |= (entry->vx_flags & IATTR_FLAGS);
21183 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
21186 + case DEVPTS_SUPER_MAGIC:
21187 + *tag = in->i_tag;
21188 + *mask |= IATTR_TAG;
21197 +int vc_get_iattr(void __user *data)
21199 + struct path path;
21200 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
21203 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21206 + ret = user_lpath(vc_data.name, &path);
21208 + ret = __vc_get_iattr(path.dentry->d_inode,
21209 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21215 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21220 +#ifdef CONFIG_COMPAT
21222 +int vc_get_iattr_x32(void __user *data)
21224 + struct path path;
21225 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
21228 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21231 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21233 + ret = __vc_get_iattr(path.dentry->d_inode,
21234 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21240 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21245 +#endif /* CONFIG_COMPAT */
21248 +int vc_fget_iattr(uint32_t fd, void __user *data)
21250 + struct file *filp;
21251 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
21254 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21258 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21261 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
21262 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21266 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21272 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21274 + struct inode *in = de->d_inode;
21275 + int error = 0, is_proc = 0, has_tag = 0;
21276 + struct iattr attr = { 0 };
21278 + if (!in || !in->i_sb)
21281 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
21282 + if ((*mask & IATTR_FLAGS) && !is_proc)
21285 + has_tag = IS_TAGGED(in) ||
21286 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
21287 + if ((*mask & IATTR_TAG) && !has_tag)
21290 + mutex_lock(&in->i_mutex);
21291 + if (*mask & IATTR_TAG) {
21292 + attr.ia_tag = *tag;
21293 + attr.ia_valid |= ATTR_TAG;
21296 + if (*mask & IATTR_FLAGS) {
21297 + struct proc_dir_entry *entry = PROC_I(in)->pde;
21298 + unsigned int iflags = PROC_I(in)->vx_flags;
21300 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
21301 + | (*flags & IATTR_FLAGS);
21302 + PROC_I(in)->vx_flags = iflags;
21304 + entry->vx_flags = iflags;
21307 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
21308 + IATTR_BARRIER | IATTR_COW)) {
21309 + int iflags = in->i_flags;
21310 + int vflags = in->i_vflags;
21312 + if (*mask & IATTR_IMMUTABLE) {
21313 + if (*flags & IATTR_IMMUTABLE)
21314 + iflags |= S_IMMUTABLE;
21316 + iflags &= ~S_IMMUTABLE;
21318 + if (*mask & IATTR_IXUNLINK) {
21319 + if (*flags & IATTR_IXUNLINK)
21320 + iflags |= S_IXUNLINK;
21322 + iflags &= ~S_IXUNLINK;
21324 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
21325 + if (*flags & IATTR_BARRIER)
21326 + vflags |= V_BARRIER;
21328 + vflags &= ~V_BARRIER;
21330 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
21331 + if (*flags & IATTR_COW)
21334 + vflags &= ~V_COW;
21336 + if (in->i_op && in->i_op->sync_flags) {
21337 + error = in->i_op->sync_flags(in, iflags, vflags);
21343 + if (attr.ia_valid) {
21344 + if (in->i_op && in->i_op->setattr)
21345 + error = in->i_op->setattr(de, &attr);
21347 + error = inode_change_ok(in, &attr);
21349 + setattr_copy(in, &attr);
21350 + mark_inode_dirty(in);
21356 + mutex_unlock(&in->i_mutex);
21360 +int vc_set_iattr(void __user *data)
21362 + struct path path;
21363 + struct vcmd_ctx_iattr_v1 vc_data;
21366 + if (!capable(CAP_LINUX_IMMUTABLE))
21368 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21371 + ret = user_lpath(vc_data.name, &path);
21373 + ret = __vc_set_iattr(path.dentry,
21374 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21378 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21383 +#ifdef CONFIG_COMPAT
21385 +int vc_set_iattr_x32(void __user *data)
21387 + struct path path;
21388 + struct vcmd_ctx_iattr_v1_x32 vc_data;
21391 + if (!capable(CAP_LINUX_IMMUTABLE))
21393 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21396 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21398 + ret = __vc_set_iattr(path.dentry,
21399 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21403 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21408 +#endif /* CONFIG_COMPAT */
21410 +int vc_fset_iattr(uint32_t fd, void __user *data)
21412 + struct file *filp;
21413 + struct vcmd_ctx_fiattr_v0 vc_data;
21416 + if (!capable(CAP_LINUX_IMMUTABLE))
21418 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21422 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21425 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
21426 + &vc_data.flags, &vc_data.mask);
21430 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21436 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
21438 +static match_table_t tokens = {
21439 + {Opt_notagcheck, "notagcheck"},
21440 +#ifdef CONFIG_PROPAGATE
21441 + {Opt_notag, "notag"},
21442 + {Opt_tag, "tag"},
21443 + {Opt_tagid, "tagid=%u"},
21449 +static void __dx_parse_remove(char *string, char *opt)
21451 + char *p = strstr(string, opt);
21455 + while (*q != '\0' && *q != ',')
21464 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
21465 + unsigned long *flags)
21468 + substring_t args[MAX_OPT_ARGS];
21470 + char *s, *p, *opts;
21471 +#if defined(CONFIG_PROPAGATE) || defined(CONFIG_VSERVER_WARN)
21477 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
21482 + while ((p = strsep(&opts, ",")) != NULL) {
21483 + token = match_token(p, tokens, args);
21486 +#ifdef CONFIG_PROPAGATE
21491 + __dx_parse_remove(s, "tag");
21492 + *mnt_flags |= MNT_TAGID;
21493 + set |= MNT_TAGID;
21497 + __dx_parse_remove(s, "notag");
21498 + *mnt_flags |= MNT_NOTAG;
21499 + set |= MNT_NOTAG;
21502 + if (tag && !match_int(args, &option))
21505 + __dx_parse_remove(s, "tagid");
21506 + *mnt_flags |= MNT_TAGID;
21507 + set |= MNT_TAGID;
21510 + case Opt_notagcheck:
21512 + __dx_parse_remove(s, "notagcheck");
21513 + *flags |= MS_NOTAGCHECK;
21514 + set |= MS_NOTAGCHECK;
21517 + vxdprintk(VXD_CBIT(tag, 7),
21518 + "dx_parse_tag(" VS_Q("%s") "): %d:#%d",
21519 + p, token, option);
21522 + strcpy(string, s);
21527 +#ifdef CONFIG_PROPAGATE
21529 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
21531 + tag_t new_tag = 0;
21532 + struct vfsmount *mnt;
21537 + mnt = nd->path.mnt;
21541 + propagate = (mnt->mnt_flags & MNT_TAGID);
21543 + new_tag = mnt->mnt_tag;
21545 + vxdprintk(VXD_CBIT(tag, 7),
21546 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
21547 + inode, inode->i_ino, inode->i_tag,
21548 + new_tag, (propagate) ? 1 : 0);
21551 + inode->i_tag = new_tag;
21554 +#include <linux/module.h>
21556 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
21558 +#endif /* CONFIG_PROPAGATE */
21560 diff -NurpP --minimal linux-3.1/kernel/vserver/limit.c linux-3.1-vs2.3.1-rc2/kernel/vserver/limit.c
21561 --- linux-3.1/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
21562 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/limit.c 2011-10-24 18:53:33.000000000 +0200
21565 + * linux/kernel/vserver/limit.c
21567 + * Virtual Server: Context Limits
21569 + * Copyright (C) 2004-2010 Herbert Pötzl
21571 + * V0.01 broken out from vcontext V0.05
21572 + * V0.02 changed vcmds to vxi arg
21573 + * V0.03 added memory cgroup support
21577 +#include <linux/sched.h>
21578 +#include <linux/module.h>
21579 +#include <linux/memcontrol.h>
21580 +#include <linux/res_counter.h>
21581 +#include <linux/vs_limit.h>
21582 +#include <linux/vserver/limit.h>
21583 +#include <linux/vserver/limit_cmd.h>
21585 +#include <asm/uaccess.h>
21588 +const char *vlimit_name[NUM_LIMITS] = {
21589 +#ifdef CONFIG_VSERVER_LEGACY_MEM
21590 + [RLIMIT_RSS] = "RSS",
21591 + [RLIMIT_AS] = "VM",
21592 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
21593 + [RLIMIT_CPU] = "CPU",
21594 + [RLIMIT_NPROC] = "NPROC",
21595 + [RLIMIT_NOFILE] = "NOFILE",
21596 + [RLIMIT_LOCKS] = "LOCKS",
21597 + [RLIMIT_SIGPENDING] = "SIGP",
21598 + [RLIMIT_MSGQUEUE] = "MSGQ",
21600 + [VLIMIT_NSOCK] = "NSOCK",
21601 + [VLIMIT_OPENFD] = "OPENFD",
21602 + [VLIMIT_SHMEM] = "SHMEM",
21603 + [VLIMIT_DENTRY] = "DENTRY",
21606 +EXPORT_SYMBOL_GPL(vlimit_name);
21608 +#define MASK_ENTRY(x) (1 << (x))
21610 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
21613 + , /* softlimit */
21614 +#ifdef CONFIG_VSERVER_LEGACY_MEM
21615 + MASK_ENTRY( RLIMIT_RSS ) |
21616 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
21619 +#ifdef CONFIG_VSERVER_LEGACY_MEM
21620 + MASK_ENTRY( RLIMIT_RSS ) |
21621 + MASK_ENTRY( RLIMIT_AS ) |
21622 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
21623 + MASK_ENTRY( RLIMIT_NPROC ) |
21624 + MASK_ENTRY( RLIMIT_NOFILE ) |
21625 + MASK_ENTRY( RLIMIT_LOCKS ) |
21626 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
21628 + MASK_ENTRY( VLIMIT_NSOCK ) |
21629 + MASK_ENTRY( VLIMIT_OPENFD ) |
21630 + MASK_ENTRY( VLIMIT_SHMEM ) |
21631 + MASK_ENTRY( VLIMIT_DENTRY ) |
21634 + /* accounting only */
21635 +uint32_t account_mask =
21636 + MASK_ENTRY( VLIMIT_SEMARY ) |
21637 + MASK_ENTRY( VLIMIT_NSEMS ) |
21638 + MASK_ENTRY( VLIMIT_MAPPED ) |
21642 +static int is_valid_vlimit(int id)
21644 + uint32_t mask = vlimit_mask.minimum |
21645 + vlimit_mask.softlimit | vlimit_mask.maximum;
21646 + return mask & (1 << id);
21649 +static int is_accounted_vlimit(int id)
21651 + if (is_valid_vlimit(id))
21653 + return account_mask & (1 << id);
21657 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
21659 + rlim_t limit = __rlim_soft(&vxi->limit, id);
21660 + return VX_VLIM(limit);
21663 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
21665 + rlim_t limit = __rlim_hard(&vxi->limit, id);
21666 + return VX_VLIM(limit);
21669 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
21670 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
21672 + if (!is_valid_vlimit(id))
21676 + *minimum = CRLIM_UNSET;
21678 + *softlimit = vc_get_soft(vxi, id);
21680 + *maximum = vc_get_hard(vxi, id);
21684 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
21686 + struct vcmd_ctx_rlimit_v0 vc_data;
21689 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21692 + ret = do_get_rlimit(vxi, vc_data.id,
21693 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21697 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21702 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
21703 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
21705 + if (!is_valid_vlimit(id))
21708 + if (maximum != CRLIM_KEEP)
21709 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
21710 + if (softlimit != CRLIM_KEEP)
21711 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
21713 + /* clamp soft limit */
21714 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
21715 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
21720 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
21722 + struct vcmd_ctx_rlimit_v0 vc_data;
21724 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21727 + return do_set_rlimit(vxi, vc_data.id,
21728 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21731 +#ifdef CONFIG_IA32_EMULATION
21733 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
21735 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21737 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21740 + return do_set_rlimit(vxi, vc_data.id,
21741 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21744 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
21746 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21749 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21752 + ret = do_get_rlimit(vxi, vc_data.id,
21753 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21757 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21762 +#endif /* CONFIG_IA32_EMULATION */
21765 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
21767 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
21773 +static inline void vx_reset_hits(struct _vx_limit *limit)
21777 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21778 + atomic_set(&__rlim_lhit(limit, lim), 0);
21782 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
21784 + vx_reset_hits(&vxi->limit);
21788 +static inline void vx_reset_minmax(struct _vx_limit *limit)
21793 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21794 + value = __rlim_get(limit, lim);
21795 + __rlim_rmax(limit, lim) = value;
21796 + __rlim_rmin(limit, lim) = value;
21800 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
21802 + vx_reset_minmax(&vxi->limit);
21807 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
21809 + struct vcmd_rlimit_stat_v0 vc_data;
21810 + struct _vx_limit *limit = &vxi->limit;
21813 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21817 + if (!is_accounted_vlimit(id))
21820 + vx_limit_fixup(limit, id);
21821 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
21822 + vc_data.value = __rlim_get(limit, id);
21823 + vc_data.minimum = __rlim_rmin(limit, id);
21824 + vc_data.maximum = __rlim_rmax(limit, id);
21826 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21832 +void vx_vsi_meminfo(struct sysinfo *val)
21834 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
21835 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
21836 + u64 res_limit, res_usage;
21841 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
21842 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
21844 + if (res_limit != RESOURCE_MAX)
21845 + val->totalram = (res_limit >> PAGE_SHIFT);
21846 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
21847 + val->bufferram = 0;
21848 + val->totalhigh = 0;
21849 + val->freehigh = 0;
21850 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
21854 +void vx_vsi_swapinfo(struct sysinfo *val)
21856 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
21857 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
21858 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
21859 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
21860 + s64 swap_limit, swap_usage;
21865 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
21866 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
21867 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
21868 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
21870 + /* memory unlimited */
21871 + if (res_limit == RESOURCE_MAX)
21874 + swap_limit = memsw_limit - res_limit;
21875 + /* we have a swap limit? */
21876 + if (memsw_limit != RESOURCE_MAX)
21877 + val->totalswap = swap_limit >> PAGE_SHIFT;
21879 + /* calculate swap part */
21880 + swap_usage = (memsw_usage > res_usage) ?
21881 + memsw_usage - res_usage : 0;
21883 + /* total shown minus usage gives free swap */
21884 + val->freeswap = (swap_usage < swap_limit) ?
21885 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
21886 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
21887 + val->totalswap = 0;
21888 + val->freeswap = 0;
21889 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
21890 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
21894 +long vx_vsi_cached(struct sysinfo *val)
21896 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
21897 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
21899 + return mem_cgroup_stat_read_cache(mcg);
21906 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
21908 + struct vx_info *vxi = mm->mm_vx_info;
21909 + unsigned long points;
21915 + points = vxi->vx_badness_bias;
21917 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
21918 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
21919 + points += (v > w) ? (v - w) : 0;
21924 diff -NurpP --minimal linux-3.1/kernel/vserver/limit_init.h linux-3.1-vs2.3.1-rc2/kernel/vserver/limit_init.h
21925 --- linux-3.1/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
21926 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/limit_init.h 2011-10-24 18:53:33.000000000 +0200
21930 +static inline void vx_info_init_limit(struct _vx_limit *limit)
21934 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21935 + __rlim_soft(limit, lim) = RLIM_INFINITY;
21936 + __rlim_hard(limit, lim) = RLIM_INFINITY;
21937 + __rlim_set(limit, lim, 0);
21938 + atomic_set(&__rlim_lhit(limit, lim), 0);
21939 + __rlim_rmin(limit, lim) = 0;
21940 + __rlim_rmax(limit, lim) = 0;
21944 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
21949 + for (lim = 0; lim < NUM_LIMITS; lim++) {
21950 + if ((1 << lim) & VLIM_NOCHECK)
21952 + value = __rlim_get(limit, lim);
21953 + vxwprintk_xid(value,
21954 + "!!! limit: %p[%s,%d] = %ld on exit.",
21955 + limit, vlimit_name[lim], lim, (long)value);
21959 diff -NurpP --minimal linux-3.1/kernel/vserver/limit_proc.h linux-3.1-vs2.3.1-rc2/kernel/vserver/limit_proc.h
21960 --- linux-3.1/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
21961 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/limit_proc.h 2011-10-24 18:53:33.000000000 +0200
21963 +#ifndef _VX_LIMIT_PROC_H
21964 +#define _VX_LIMIT_PROC_H
21966 +#include <linux/vserver/limit_int.h>
21969 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
21970 +#define VX_LIMIT_TOP \
21971 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
21973 +#define VX_LIMIT_ARG(r) \
21974 + (unsigned long)__rlim_get(limit, r), \
21975 + (unsigned long)__rlim_rmin(limit, r), \
21976 + (unsigned long)__rlim_rmax(limit, r), \
21977 + VX_VLIM(__rlim_soft(limit, r)), \
21978 + VX_VLIM(__rlim_hard(limit, r)), \
21979 + atomic_read(&__rlim_lhit(limit, r))
21981 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
21983 + vx_limit_fixup(limit, -1);
21984 + return sprintf(buffer, VX_LIMIT_TOP
21985 + "PROC" VX_LIMIT_FMT
21986 + "VM" VX_LIMIT_FMT
21987 + "VML" VX_LIMIT_FMT
21988 + "RSS" VX_LIMIT_FMT
21989 + "ANON" VX_LIMIT_FMT
21990 + "RMAP" VX_LIMIT_FMT
21991 + "FILES" VX_LIMIT_FMT
21992 + "OFD" VX_LIMIT_FMT
21993 + "LOCKS" VX_LIMIT_FMT
21994 + "SOCK" VX_LIMIT_FMT
21995 + "MSGQ" VX_LIMIT_FMT
21996 + "SHM" VX_LIMIT_FMT
21997 + "SEMA" VX_LIMIT_FMT
21998 + "SEMS" VX_LIMIT_FMT
21999 + "DENT" VX_LIMIT_FMT,
22000 + VX_LIMIT_ARG(RLIMIT_NPROC),
22001 + VX_LIMIT_ARG(RLIMIT_AS),
22002 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
22003 + VX_LIMIT_ARG(RLIMIT_RSS),
22004 + VX_LIMIT_ARG(VLIMIT_ANON),
22005 + VX_LIMIT_ARG(VLIMIT_MAPPED),
22006 + VX_LIMIT_ARG(RLIMIT_NOFILE),
22007 + VX_LIMIT_ARG(VLIMIT_OPENFD),
22008 + VX_LIMIT_ARG(RLIMIT_LOCKS),
22009 + VX_LIMIT_ARG(VLIMIT_NSOCK),
22010 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
22011 + VX_LIMIT_ARG(VLIMIT_SHMEM),
22012 + VX_LIMIT_ARG(VLIMIT_SEMARY),
22013 + VX_LIMIT_ARG(VLIMIT_NSEMS),
22014 + VX_LIMIT_ARG(VLIMIT_DENTRY));
22017 +#endif /* _VX_LIMIT_PROC_H */
22020 diff -NurpP --minimal linux-3.1/kernel/vserver/network.c linux-3.1-vs2.3.1-rc2/kernel/vserver/network.c
22021 --- linux-3.1/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
22022 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/network.c 2011-10-24 18:53:33.000000000 +0200
22025 + * linux/kernel/vserver/network.c
22027 + * Virtual Server: Network Support
22029 + * Copyright (C) 2003-2007 Herbert Pötzl
22031 + * V0.01 broken out from vcontext V0.05
22032 + * V0.02 cleaned up implementation
22033 + * V0.03 added equiv nx commands
22034 + * V0.04 switch to RCU based hash
22035 + * V0.05 and back to locking again
22036 + * V0.06 changed vcmds to nxi arg
22037 + * V0.07 have __create claim() the nxi
22041 +#include <linux/err.h>
22042 +#include <linux/slab.h>
22043 +#include <linux/rcupdate.h>
22045 +#include <linux/vs_network.h>
22046 +#include <linux/vs_pid.h>
22047 +#include <linux/vserver/network_cmd.h>
22050 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
22051 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
22053 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
22054 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
22057 +static int __init init_network(void)
22059 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
22060 + sizeof(struct nx_addr_v4), 0,
22061 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22062 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
22063 + sizeof(struct nx_addr_v6), 0,
22064 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22069 +/* __alloc_nx_addr_v4() */
22071 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
22073 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
22074 + nx_addr_v4_cachep, GFP_KERNEL);
22076 + if (!IS_ERR(nxa))
22077 + memset(nxa, 0, sizeof(*nxa));
22081 +/* __dealloc_nx_addr_v4() */
22083 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
22085 + kmem_cache_free(nx_addr_v4_cachep, nxa);
22088 +/* __dealloc_nx_addr_v4_all() */
22090 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
22093 + struct nx_addr_v4 *next = nxa->next;
22095 + __dealloc_nx_addr_v4(nxa);
22101 +#ifdef CONFIG_IPV6
22103 +/* __alloc_nx_addr_v6() */
22105 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
22107 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
22108 + nx_addr_v6_cachep, GFP_KERNEL);
22110 + if (!IS_ERR(nxa))
22111 + memset(nxa, 0, sizeof(*nxa));
22115 +/* __dealloc_nx_addr_v6() */
22117 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
22119 + kmem_cache_free(nx_addr_v6_cachep, nxa);
22122 +/* __dealloc_nx_addr_v6_all() */
22124 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
22127 + struct nx_addr_v6 *next = nxa->next;
22129 + __dealloc_nx_addr_v6(nxa);
22134 +#endif /* CONFIG_IPV6 */
22136 +/* __alloc_nx_info()
22138 + * allocate an initialized nx_info struct
22139 + * doesn't make it visible (hash) */
22141 +static struct nx_info *__alloc_nx_info(nid_t nid)
22143 + struct nx_info *new = NULL;
22145 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
22147 + /* would this benefit from a slab cache? */
22148 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
22152 + memset(new, 0, sizeof(struct nx_info));
22153 + new->nx_id = nid;
22154 + INIT_HLIST_NODE(&new->nx_hlist);
22155 + atomic_set(&new->nx_usecnt, 0);
22156 + atomic_set(&new->nx_tasks, 0);
22157 + new->nx_state = 0;
22159 + new->nx_flags = NXF_INIT_SET;
22161 + /* rest of init goes here */
22163 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
22164 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
22166 + vxdprintk(VXD_CBIT(nid, 0),
22167 + "alloc_nx_info(%d) = %p", nid, new);
22168 + atomic_inc(&nx_global_ctotal);
22172 +/* __dealloc_nx_info()
22174 + * final disposal of nx_info */
22176 +static void __dealloc_nx_info(struct nx_info *nxi)
22178 + vxdprintk(VXD_CBIT(nid, 0),
22179 + "dealloc_nx_info(%p)", nxi);
22181 + nxi->nx_hlist.next = LIST_POISON1;
22184 + BUG_ON(atomic_read(&nxi->nx_usecnt));
22185 + BUG_ON(atomic_read(&nxi->nx_tasks));
22187 + __dealloc_nx_addr_v4_all(nxi->v4.next);
22189 + nxi->nx_state |= NXS_RELEASED;
22191 + atomic_dec(&nx_global_ctotal);
22194 +static void __shutdown_nx_info(struct nx_info *nxi)
22196 + nxi->nx_state |= NXS_SHUTDOWN;
22197 + vs_net_change(nxi, VSC_NETDOWN);
22200 +/* exported stuff */
22202 +void free_nx_info(struct nx_info *nxi)
22204 + /* context shutdown is mandatory */
22205 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
22207 + /* context must not be hashed */
22208 + BUG_ON(nxi->nx_state & NXS_HASHED);
22210 + BUG_ON(atomic_read(&nxi->nx_usecnt));
22211 + BUG_ON(atomic_read(&nxi->nx_tasks));
22213 + __dealloc_nx_info(nxi);
22217 +void __nx_set_lback(struct nx_info *nxi)
22219 + int nid = nxi->nx_id;
22220 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
22222 + nxi->v4_lback.s_addr = lback;
22225 +extern int __nx_inet_add_lback(__be32 addr);
22226 +extern int __nx_inet_del_lback(__be32 addr);
22229 +/* hash table for nx_info hash */
22231 +#define NX_HASH_SIZE 13
22233 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
22235 +static DEFINE_SPINLOCK(nx_info_hash_lock);
22238 +static inline unsigned int __hashval(nid_t nid)
22240 + return (nid % NX_HASH_SIZE);
22245 +/* __hash_nx_info()
22247 + * add the nxi to the global hash table
22248 + * requires the hash_lock to be held */
22250 +static inline void __hash_nx_info(struct nx_info *nxi)
22252 + struct hlist_head *head;
22254 + vxd_assert_lock(&nx_info_hash_lock);
22255 + vxdprintk(VXD_CBIT(nid, 4),
22256 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
22258 + /* context must not be hashed */
22259 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
22261 + nxi->nx_state |= NXS_HASHED;
22262 + head = &nx_info_hash[__hashval(nxi->nx_id)];
22263 + hlist_add_head(&nxi->nx_hlist, head);
22264 + atomic_inc(&nx_global_cactive);
22267 +/* __unhash_nx_info()
22269 + * remove the nxi from the global hash table
22270 + * requires the hash_lock to be held */
22272 +static inline void __unhash_nx_info(struct nx_info *nxi)
22274 + vxd_assert_lock(&nx_info_hash_lock);
22275 + vxdprintk(VXD_CBIT(nid, 4),
22276 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
22277 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
22279 + /* context must be hashed */
22280 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
22281 + /* but without tasks */
22282 + BUG_ON(atomic_read(&nxi->nx_tasks));
22284 + nxi->nx_state &= ~NXS_HASHED;
22285 + hlist_del(&nxi->nx_hlist);
22286 + atomic_dec(&nx_global_cactive);
22290 +/* __lookup_nx_info()
22292 + * requires the hash_lock to be held
22293 + * doesn't increment the nx_refcnt */
22295 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
22297 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
22298 + struct hlist_node *pos;
22299 + struct nx_info *nxi;
22301 + vxd_assert_lock(&nx_info_hash_lock);
22302 + hlist_for_each(pos, head) {
22303 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22305 + if (nxi->nx_id == nid)
22310 + vxdprintk(VXD_CBIT(nid, 0),
22311 + "__lookup_nx_info(#%u): %p[#%u]",
22312 + nid, nxi, nxi ? nxi->nx_id : 0);
22317 +/* __create_nx_info()
22319 + * create the requested context
22320 + * get(), claim() and hash it */
22322 +static struct nx_info *__create_nx_info(int id)
22324 + struct nx_info *new, *nxi = NULL;
22326 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
22328 + if (!(new = __alloc_nx_info(id)))
22329 + return ERR_PTR(-ENOMEM);
22331 + /* required to make dynamic xids unique */
22332 + spin_lock(&nx_info_hash_lock);
22334 + /* static context requested */
22335 + if ((nxi = __lookup_nx_info(id))) {
22336 + vxdprintk(VXD_CBIT(nid, 0),
22337 + "create_nx_info(%d) = %p (already there)", id, nxi);
22338 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22339 + nxi = ERR_PTR(-EBUSY);
22341 + nxi = ERR_PTR(-EEXIST);
22344 + /* new context */
22345 + vxdprintk(VXD_CBIT(nid, 0),
22346 + "create_nx_info(%d) = %p (new)", id, new);
22347 + claim_nx_info(new, NULL);
22348 + __nx_set_lback(new);
22349 + __hash_nx_info(get_nx_info(new));
22350 + nxi = new, new = NULL;
22353 + spin_unlock(&nx_info_hash_lock);
22355 + __dealloc_nx_info(new);
22361 +/* exported stuff */
22364 +void unhash_nx_info(struct nx_info *nxi)
22366 + __shutdown_nx_info(nxi);
22367 + spin_lock(&nx_info_hash_lock);
22368 + __unhash_nx_info(nxi);
22369 + spin_unlock(&nx_info_hash_lock);
22372 +/* lookup_nx_info()
22374 + * search for a nx_info and get() it
22375 + * negative id means current */
22377 +struct nx_info *lookup_nx_info(int id)
22379 + struct nx_info *nxi = NULL;
22382 + nxi = get_nx_info(current_nx_info());
22383 + } else if (id > 1) {
22384 + spin_lock(&nx_info_hash_lock);
22385 + nxi = get_nx_info(__lookup_nx_info(id));
22386 + spin_unlock(&nx_info_hash_lock);
22391 +/* nid_is_hashed()
22393 + * verify that nid is still hashed */
22395 +int nid_is_hashed(nid_t nid)
22399 + spin_lock(&nx_info_hash_lock);
22400 + hashed = (__lookup_nx_info(nid) != NULL);
22401 + spin_unlock(&nx_info_hash_lock);
22406 +#ifdef CONFIG_PROC_FS
22410 + * get a subset of hashed nids for proc
22411 + * assumes size is at least one */
22413 +int get_nid_list(int index, unsigned int *nids, int size)
22415 + int hindex, nr_nids = 0;
22417 + /* only show current and children */
22418 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
22421 + nids[nr_nids] = nx_current_nid();
22425 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
22426 + struct hlist_head *head = &nx_info_hash[hindex];
22427 + struct hlist_node *pos;
22429 + spin_lock(&nx_info_hash_lock);
22430 + hlist_for_each(pos, head) {
22431 + struct nx_info *nxi;
22436 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22437 + nids[nr_nids] = nxi->nx_id;
22438 + if (++nr_nids >= size) {
22439 + spin_unlock(&nx_info_hash_lock);
22443 + /* keep the lock time short */
22444 + spin_unlock(&nx_info_hash_lock);
22453 + * migrate task to new network
22454 + * gets nxi, puts old_nxi on change
22457 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
22459 + struct nx_info *old_nxi;
22465 + vxdprintk(VXD_CBIT(nid, 5),
22466 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
22467 + p, nxi, nxi->nx_id,
22468 + atomic_read(&nxi->nx_usecnt),
22469 + atomic_read(&nxi->nx_tasks));
22471 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
22472 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22475 + if (nx_info_state(nxi, NXS_SHUTDOWN))
22478 + /* maybe disallow this completely? */
22479 + old_nxi = task_get_nx_info(p);
22480 + if (old_nxi == nxi)
22485 + clr_nx_info(&p->nx_info);
22486 + claim_nx_info(nxi, p);
22487 + set_nx_info(&p->nx_info, nxi);
22488 + p->nid = nxi->nx_id;
22491 + vxdprintk(VXD_CBIT(nid, 5),
22492 + "moved task %p into nxi:%p[#%d]",
22493 + p, nxi, nxi->nx_id);
22496 + release_nx_info(old_nxi, p);
22499 + put_nx_info(old_nxi);
22504 +void nx_set_persistent(struct nx_info *nxi)
22506 + vxdprintk(VXD_CBIT(nid, 6),
22507 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
22509 + get_nx_info(nxi);
22510 + claim_nx_info(nxi, NULL);
22513 +void nx_clear_persistent(struct nx_info *nxi)
22515 + vxdprintk(VXD_CBIT(nid, 6),
22516 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
22518 + release_nx_info(nxi, NULL);
22519 + put_nx_info(nxi);
22522 +void nx_update_persistent(struct nx_info *nxi)
22524 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
22525 + nx_set_persistent(nxi);
22527 + nx_clear_persistent(nxi);
22530 +/* vserver syscall commands below here */
22532 +/* taks nid and nx_info functions */
22534 +#include <asm/uaccess.h>
22537 +int vc_task_nid(uint32_t id)
22542 + struct task_struct *tsk;
22545 + tsk = find_task_by_real_pid(id);
22546 + nid = (tsk) ? tsk->nid : -ESRCH;
22547 + rcu_read_unlock();
22549 + nid = nx_current_nid();
22554 +int vc_nx_info(struct nx_info *nxi, void __user *data)
22556 + struct vcmd_nx_info_v0 vc_data;
22558 + vc_data.nid = nxi->nx_id;
22560 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22566 +/* network functions */
22568 +int vc_net_create(uint32_t nid, void __user *data)
22570 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
22571 + struct nx_info *new_nxi;
22574 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22577 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
22580 + new_nxi = __create_nx_info(nid);
22581 + if (IS_ERR(new_nxi))
22582 + return PTR_ERR(new_nxi);
22584 + /* initial flags */
22585 + new_nxi->nx_flags = vc_data.flagword;
22588 + if (vs_net_change(new_nxi, VSC_NETUP))
22591 + ret = nx_migrate_task(current, new_nxi);
22595 + /* return context id on success */
22596 + ret = new_nxi->nx_id;
22598 + /* get a reference for persistent contexts */
22599 + if ((vc_data.flagword & NXF_PERSISTENT))
22600 + nx_set_persistent(new_nxi);
22602 + release_nx_info(new_nxi, NULL);
22603 + put_nx_info(new_nxi);
22608 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
22610 + return nx_migrate_task(current, nxi);
22615 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
22616 + uint16_t type, uint16_t flags)
22618 + struct nx_addr_v4 *nxa = &nxi->v4;
22620 + if (NX_IPV4(nxi)) {
22621 + /* locate last entry */
22622 + for (; nxa->next; nxa = nxa->next);
22623 + nxa->next = __alloc_nx_addr_v4();
22627 + return PTR_ERR(nxa);
22630 + if (nxi->v4.next)
22631 + /* remove single ip for ip list */
22632 + nxi->nx_flags &= ~NXF_SINGLE_IP;
22634 + nxa->ip[0].s_addr = ip;
22635 + nxa->ip[1].s_addr = ip2;
22636 + nxa->mask.s_addr = mask;
22637 + nxa->type = type;
22638 + nxa->flags = flags;
22642 +int do_remove_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
22643 + uint16_t type, uint16_t flags)
22645 + struct nx_addr_v4 *nxa = &nxi->v4;
22648 +/* case NXA_TYPE_ADDR:
22651 + case NXA_TYPE_ANY:
22652 + __dealloc_nx_addr_v4_all(xchg(&nxa->next, NULL));
22653 + memset(nxa, 0, sizeof(*nxa));
22663 +int vc_net_add(struct nx_info *nxi, void __user *data)
22665 + struct vcmd_net_addr_v0 vc_data;
22666 + int index, ret = 0;
22668 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22671 + switch (vc_data.type) {
22672 + case NXA_TYPE_IPV4:
22673 + if ((vc_data.count < 1) || (vc_data.count > 4))
22677 + while (index < vc_data.count) {
22678 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
22679 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
22687 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
22688 + nxi->v4_bcast = vc_data.ip[0];
22692 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
22693 + nxi->v4_lback = vc_data.ip[0];
22704 +int vc_net_remove(struct nx_info *nxi, void __user *data)
22706 + struct vcmd_net_addr_v0 vc_data;
22708 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22711 + switch (vc_data.type) {
22712 + case NXA_TYPE_ANY:
22713 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
22714 + memset(&nxi->v4, 0, sizeof(nxi->v4));
22724 +int vc_net_add_ipv4_v1(struct nx_info *nxi, void __user *data)
22726 + struct vcmd_net_addr_ipv4_v1 vc_data;
22728 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22731 + switch (vc_data.type) {
22732 + case NXA_TYPE_ADDR:
22733 + case NXA_TYPE_MASK:
22734 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
22735 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
22737 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
22738 + nxi->v4_bcast = vc_data.ip;
22741 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
22742 + nxi->v4_lback = vc_data.ip;
22751 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
22753 + struct vcmd_net_addr_ipv4_v2 vc_data;
22755 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22758 + switch (vc_data.type) {
22759 + case NXA_TYPE_ADDR:
22760 + case NXA_TYPE_MASK:
22761 + case NXA_TYPE_RANGE:
22762 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
22763 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
22765 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
22766 + nxi->v4_bcast = vc_data.ip;
22769 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
22770 + nxi->v4_lback = vc_data.ip;
22779 +int vc_net_rem_ipv4_v1(struct nx_info *nxi, void __user *data)
22781 + struct vcmd_net_addr_ipv4_v1 vc_data;
22783 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22786 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, 0,
22787 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
22790 +int vc_net_rem_ipv4(struct nx_info *nxi, void __user *data)
22792 + struct vcmd_net_addr_ipv4_v2 vc_data;
22794 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22797 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
22798 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
22801 +#ifdef CONFIG_IPV6
22803 +int do_add_v6_addr(struct nx_info *nxi,
22804 + struct in6_addr *ip, struct in6_addr *mask,
22805 + uint32_t prefix, uint16_t type, uint16_t flags)
22807 + struct nx_addr_v6 *nxa = &nxi->v6;
22809 + if (NX_IPV6(nxi)) {
22810 + /* locate last entry */
22811 + for (; nxa->next; nxa = nxa->next);
22812 + nxa->next = __alloc_nx_addr_v6();
22816 + return PTR_ERR(nxa);
22820 + nxa->mask = *mask;
22821 + nxa->prefix = prefix;
22822 + nxa->type = type;
22823 + nxa->flags = flags;
22828 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
22830 + struct vcmd_net_addr_ipv6_v1 vc_data;
22832 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22835 + switch (vc_data.type) {
22836 + case NXA_TYPE_ADDR:
22837 + memset(&vc_data.mask, ~0, sizeof(vc_data.mask));
22838 + /* fallthrough */
22839 + case NXA_TYPE_MASK:
22840 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
22841 + vc_data.prefix, vc_data.type, vc_data.flags);
22848 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
22850 + struct vcmd_net_addr_ipv6_v1 vc_data;
22852 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22855 + switch (vc_data.type) {
22856 + case NXA_TYPE_ANY:
22857 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
22858 + memset(&nxi->v6, 0, sizeof(nxi->v6));
22867 +#endif /* CONFIG_IPV6 */
22870 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
22872 + struct vcmd_net_flags_v0 vc_data;
22874 + vc_data.flagword = nxi->nx_flags;
22876 + /* special STATE flag handling */
22877 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
22879 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22884 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
22886 + struct vcmd_net_flags_v0 vc_data;
22887 + uint64_t mask, trigger;
22889 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22892 + /* special STATE flag handling */
22893 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
22894 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
22896 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
22897 + vc_data.flagword, mask);
22898 + if (trigger & NXF_PERSISTENT)
22899 + nx_update_persistent(nxi);
22904 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
22906 + struct vcmd_net_caps_v0 vc_data;
22908 + vc_data.ncaps = nxi->nx_ncaps;
22909 + vc_data.cmask = ~0ULL;
22911 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22916 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
22918 + struct vcmd_net_caps_v0 vc_data;
22920 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22923 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
22924 + vc_data.ncaps, vc_data.cmask);
22929 +#include <linux/module.h>
22931 +module_init(init_network);
22933 +EXPORT_SYMBOL_GPL(free_nx_info);
22934 +EXPORT_SYMBOL_GPL(unhash_nx_info);
22936 diff -NurpP --minimal linux-3.1/kernel/vserver/proc.c linux-3.1-vs2.3.1-rc2/kernel/vserver/proc.c
22937 --- linux-3.1/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
22938 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/proc.c 2011-10-24 18:53:33.000000000 +0200
22941 + * linux/kernel/vserver/proc.c
22943 + * Virtual Context Support
22945 + * Copyright (C) 2003-2011 Herbert Pötzl
22947 + * V0.01 basic structure
22948 + * V0.02 adaptation vs1.3.0
22949 + * V0.03 proc permissions
22950 + * V0.04 locking/generic
22951 + * V0.05 next generation procfs
22952 + * V0.06 inode validation
22953 + * V0.07 generic rewrite vid
22954 + * V0.08 remove inode type
22955 + * V0.09 added u/wmask info
22959 +#include <linux/proc_fs.h>
22960 +#include <linux/fs_struct.h>
22961 +#include <linux/mount.h>
22962 +#include <asm/unistd.h>
22964 +#include <linux/vs_context.h>
22965 +#include <linux/vs_network.h>
22966 +#include <linux/vs_cvirt.h>
22968 +#include <linux/in.h>
22969 +#include <linux/inetdevice.h>
22970 +#include <linux/vs_inet.h>
22971 +#include <linux/vs_inet6.h>
22973 +#include <linux/vserver/global.h>
22975 +#include "cvirt_proc.h"
22976 +#include "cacct_proc.h"
22977 +#include "limit_proc.h"
22978 +#include "sched_proc.h"
22979 +#include "vci_config.h"
22982 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
22986 + CAP_FOR_EACH_U32(__capi) {
22987 + buffer += sprintf(buffer, "%08x",
22988 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
22994 +static struct proc_dir_entry *proc_virtual;
22996 +static struct proc_dir_entry *proc_virtnet;
22999 +/* first the actual feeds */
23002 +static int proc_vci(char *buffer)
23004 + return sprintf(buffer,
23005 + "VCIVersion:\t%04x:%04x\n"
23006 + "VCISyscall:\t%d\n"
23007 + "VCIKernel:\t%08x\n",
23008 + VCI_VERSION >> 16,
23009 + VCI_VERSION & 0xFFFF,
23011 + vci_kernel_config());
23014 +static int proc_virtual_info(char *buffer)
23016 + return proc_vci(buffer);
23019 +static int proc_virtual_status(char *buffer)
23021 + return sprintf(buffer,
23023 + "#CActive:\t%d\n"
23024 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
23025 + "#InitTask:\t%d\t%d %d\n",
23026 + atomic_read(&vx_global_ctotal),
23027 + atomic_read(&vx_global_cactive),
23028 + atomic_read(&vs_global_nsproxy),
23029 + atomic_read(&vs_global_fs),
23030 + atomic_read(&vs_global_mnt_ns),
23031 + atomic_read(&vs_global_uts_ns),
23032 + atomic_read(&nr_ipc_ns),
23033 + atomic_read(&vs_global_user_ns),
23034 + atomic_read(&vs_global_pid_ns),
23035 + atomic_read(&init_task.usage),
23036 + atomic_read(&init_task.nsproxy->count),
23037 + init_task.fs->users);
23041 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
23045 + length = sprintf(buffer,
23053 + vxi->vx_badness_bias);
23057 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
23059 + char *orig = buffer;
23061 + buffer += sprintf(buffer,
23064 + "Flags:\t%016llx\n",
23065 + atomic_read(&vxi->vx_usecnt),
23066 + atomic_read(&vxi->vx_tasks),
23067 + (unsigned long long)vxi->vx_flags);
23069 + buffer += sprintf(buffer, "BCaps:\t");
23070 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
23071 + buffer += sprintf(buffer, "\n");
23073 + buffer += sprintf(buffer,
23074 + "CCaps:\t%016llx\n"
23075 + "Umask:\t%16llx\n"
23076 + "Wmask:\t%16llx\n"
23077 + "Spaces:\t%08lx %08lx\n",
23078 + (unsigned long long)vxi->vx_ccaps,
23079 + (unsigned long long)vxi->vx_umask,
23080 + (unsigned long long)vxi->vx_wmask,
23081 + vxi->space[0].vx_nsmask, vxi->space[1].vx_nsmask);
23082 + return buffer - orig;
23085 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
23087 + return vx_info_proc_limit(&vxi->limit, buffer);
23090 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
23094 + length = vx_info_proc_sched(&vxi->sched, buffer);
23095 + for_each_online_cpu(cpu) {
23096 + length += vx_info_proc_sched_pc(
23097 + &vx_per_cpu(vxi, sched_pc, cpu),
23098 + buffer + length, cpu);
23103 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
23105 + return vx_info_proc_nsproxy(vxi->space[0].vx_nsproxy, buffer);
23108 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
23110 + return vx_info_proc_nsproxy(vxi->space[1].vx_nsproxy, buffer);
23113 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
23117 + vx_update_load(vxi);
23118 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
23119 + for_each_online_cpu(cpu) {
23120 + length += vx_info_proc_cvirt_pc(
23121 + &vx_per_cpu(vxi, cvirt_pc, cpu),
23122 + buffer + length, cpu);
23127 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
23129 + return vx_info_proc_cacct(&vxi->cacct, buffer);
23133 +static int proc_virtnet_info(char *buffer)
23135 + return proc_vci(buffer);
23138 +static int proc_virtnet_status(char *buffer)
23140 + return sprintf(buffer,
23142 + "#CActive:\t%d\n",
23143 + atomic_read(&nx_global_ctotal),
23144 + atomic_read(&nx_global_cactive));
23147 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
23149 + struct nx_addr_v4 *v4a;
23150 +#ifdef CONFIG_IPV6
23151 + struct nx_addr_v6 *v6a;
23155 + length = sprintf(buffer,
23158 + "Bcast:\t" NIPQUAD_FMT "\n"
23159 + "Lback:\t" NIPQUAD_FMT "\n",
23162 + NIPQUAD(nxi->v4_bcast.s_addr),
23163 + NIPQUAD(nxi->v4_lback.s_addr));
23165 + if (!NX_IPV4(nxi))
23167 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
23168 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
23171 +#ifdef CONFIG_IPV6
23172 + if (!NX_IPV6(nxi))
23174 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
23175 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
23182 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
23186 + length = sprintf(buffer,
23189 + "Flags:\t%016llx\n"
23190 + "NCaps:\t%016llx\n",
23191 + atomic_read(&nxi->nx_usecnt),
23192 + atomic_read(&nxi->nx_tasks),
23193 + (unsigned long long)nxi->nx_flags,
23194 + (unsigned long long)nxi->nx_ncaps);
23200 +/* here the inode helpers */
23206 + struct inode_operations *iop;
23207 + struct file_operations *fop;
23208 + union proc_op op;
23211 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
23213 + struct inode *inode = new_inode(sb);
23218 + inode->i_mode = p->mode;
23220 + inode->i_op = p->iop;
23222 + inode->i_fop = p->fop;
23224 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
23225 + inode->i_flags |= S_IMMUTABLE;
23227 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
23229 + inode->i_uid = 0;
23230 + inode->i_gid = 0;
23231 + inode->i_tag = 0;
23236 +static struct dentry *vs_proc_instantiate(struct inode *dir,
23237 + struct dentry *dentry, int id, void *ptr)
23239 + struct vs_entry *p = ptr;
23240 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
23241 + struct dentry *error = ERR_PTR(-EINVAL);
23246 + PROC_I(inode)->op = p->op;
23247 + PROC_I(inode)->fd = id;
23248 + d_add(dentry, inode);
23256 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
23259 + * Fill a directory entry.
23261 + * If possible create the dcache entry and derive our inode number and
23262 + * file type from dcache entry.
23264 + * Since all of the proc inode numbers are dynamically generated, the inode
23265 + * numbers do not exist until the inode is cache. This means creating the
23266 + * the dcache entry in readdir is necessary to keep the inode numbers
23267 + * reported by readdir in sync with the inode numbers reported
23270 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
23271 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
23273 + struct dentry *child, *dir = filp->f_dentry;
23274 + struct inode *inode;
23275 + struct qstr qname;
23277 + unsigned type = DT_UNKNOWN;
23279 + qname.name = name;
23281 + qname.hash = full_name_hash(name, len);
23283 + child = d_lookup(dir, &qname);
23285 + struct dentry *new;
23286 + new = d_alloc(dir, &qname);
23288 + child = instantiate(dir->d_inode, new, id, ptr);
23295 + if (!child || IS_ERR(child) || !child->d_inode)
23296 + goto end_instantiate;
23297 + inode = child->d_inode;
23299 + ino = inode->i_ino;
23300 + type = inode->i_mode >> 12;
23305 + ino = find_inode_number(dir, &qname);
23308 + return filldir(dirent, name, len, filp->f_pos, ino, type);
23313 +/* get and revalidate vx_info/xid */
23316 +struct vx_info *get_proc_vx_info(struct inode *inode)
23318 + return lookup_vx_info(PROC_I(inode)->fd);
23321 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
23323 + struct inode *inode = dentry->d_inode;
23324 + xid_t xid = PROC_I(inode)->fd;
23326 + if (!xid || xid_is_hashed(xid))
23333 +/* get and revalidate nx_info/nid */
23335 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
23337 + struct inode *inode = dentry->d_inode;
23338 + nid_t nid = PROC_I(inode)->fd;
23340 + if (!nid || nid_is_hashed(nid))
23348 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
23350 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
23351 + size_t count, loff_t *ppos)
23353 + struct inode *inode = file->f_dentry->d_inode;
23354 + unsigned long page;
23355 + ssize_t length = 0;
23357 + if (count > PROC_BLOCK_SIZE)
23358 + count = PROC_BLOCK_SIZE;
23360 + /* fade that out as soon as stable */
23361 + WARN_ON(PROC_I(inode)->fd);
23363 + if (!(page = __get_free_page(GFP_KERNEL)))
23366 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
23367 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
23370 + length = simple_read_from_buffer(buf, count, ppos,
23371 + (char *)page, length);
23377 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
23378 + size_t count, loff_t *ppos)
23380 + struct inode *inode = file->f_dentry->d_inode;
23381 + struct vx_info *vxi = NULL;
23382 + xid_t xid = PROC_I(inode)->fd;
23383 + unsigned long page;
23384 + ssize_t length = 0;
23386 + if (count > PROC_BLOCK_SIZE)
23387 + count = PROC_BLOCK_SIZE;
23389 + /* fade that out as soon as stable */
23391 + vxi = lookup_vx_info(xid);
23395 + length = -ENOMEM;
23396 + if (!(page = __get_free_page(GFP_KERNEL)))
23399 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
23400 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
23403 + length = simple_read_from_buffer(buf, count, ppos,
23404 + (char *)page, length);
23408 + put_vx_info(vxi);
23413 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
23414 + size_t count, loff_t *ppos)
23416 + struct inode *inode = file->f_dentry->d_inode;
23417 + struct nx_info *nxi = NULL;
23418 + nid_t nid = PROC_I(inode)->fd;
23419 + unsigned long page;
23420 + ssize_t length = 0;
23422 + if (count > PROC_BLOCK_SIZE)
23423 + count = PROC_BLOCK_SIZE;
23425 + /* fade that out as soon as stable */
23427 + nxi = lookup_nx_info(nid);
23431 + length = -ENOMEM;
23432 + if (!(page = __get_free_page(GFP_KERNEL)))
23435 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
23436 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
23439 + length = simple_read_from_buffer(buf, count, ppos,
23440 + (char *)page, length);
23444 + put_nx_info(nxi);
23451 +/* here comes the lower level */
23454 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
23455 + .len = sizeof(NAME) - 1, \
23456 + .name = (NAME), \
23464 +#define DIR(NAME, MODE, OTYPE) \
23465 + NOD(NAME, (S_IFDIR | (MODE)), \
23466 + &proc_ ## OTYPE ## _inode_operations, \
23467 + &proc_ ## OTYPE ## _file_operations, { } )
23469 +#define INF(NAME, MODE, OTYPE) \
23470 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23471 + &proc_vs_info_file_operations, \
23472 + { .proc_vs_read = &proc_##OTYPE } )
23474 +#define VINF(NAME, MODE, OTYPE) \
23475 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23476 + &proc_vx_info_file_operations, \
23477 + { .proc_vxi_read = &proc_##OTYPE } )
23479 +#define NINF(NAME, MODE, OTYPE) \
23480 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23481 + &proc_nx_info_file_operations, \
23482 + { .proc_nxi_read = &proc_##OTYPE } )
23485 +static struct file_operations proc_vs_info_file_operations = {
23486 + .read = proc_vs_info_read,
23489 +static struct file_operations proc_vx_info_file_operations = {
23490 + .read = proc_vx_info_read,
23493 +static struct dentry_operations proc_xid_dentry_operations = {
23494 + .d_revalidate = proc_xid_revalidate,
23497 +static struct vs_entry vx_base_stuff[] = {
23498 + VINF("info", S_IRUGO, vxi_info),
23499 + VINF("status", S_IRUGO, vxi_status),
23500 + VINF("limit", S_IRUGO, vxi_limit),
23501 + VINF("sched", S_IRUGO, vxi_sched),
23502 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
23503 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
23504 + VINF("cvirt", S_IRUGO, vxi_cvirt),
23505 + VINF("cacct", S_IRUGO, vxi_cacct),
23512 +static struct dentry *proc_xid_instantiate(struct inode *dir,
23513 + struct dentry *dentry, int id, void *ptr)
23515 + dentry->d_op = &proc_xid_dentry_operations;
23516 + return vs_proc_instantiate(dir, dentry, id, ptr);
23519 +static struct dentry *proc_xid_lookup(struct inode *dir,
23520 + struct dentry *dentry, struct nameidata *nd)
23522 + struct vs_entry *p = vx_base_stuff;
23523 + struct dentry *error = ERR_PTR(-ENOENT);
23525 + for (; p->name; p++) {
23526 + if (p->len != dentry->d_name.len)
23528 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23534 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23539 +static int proc_xid_readdir(struct file *filp,
23540 + void *dirent, filldir_t filldir)
23542 + struct dentry *dentry = filp->f_dentry;
23543 + struct inode *inode = dentry->d_inode;
23544 + struct vs_entry *p = vx_base_stuff;
23545 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
23549 + pos = filp->f_pos;
23552 + ino = inode->i_ino;
23553 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23556 + /* fall through */
23558 + ino = parent_ino(dentry);
23559 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23562 + /* fall through */
23565 + if (index >= size)
23567 + for (p += index; p->name; p++) {
23568 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23569 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23575 + filp->f_pos = pos;
23581 +static struct file_operations proc_nx_info_file_operations = {
23582 + .read = proc_nx_info_read,
23585 +static struct dentry_operations proc_nid_dentry_operations = {
23586 + .d_revalidate = proc_nid_revalidate,
23589 +static struct vs_entry nx_base_stuff[] = {
23590 + NINF("info", S_IRUGO, nxi_info),
23591 + NINF("status", S_IRUGO, nxi_status),
23596 +static struct dentry *proc_nid_instantiate(struct inode *dir,
23597 + struct dentry *dentry, int id, void *ptr)
23599 + dentry->d_op = &proc_nid_dentry_operations;
23600 + return vs_proc_instantiate(dir, dentry, id, ptr);
23603 +static struct dentry *proc_nid_lookup(struct inode *dir,
23604 + struct dentry *dentry, struct nameidata *nd)
23606 + struct vs_entry *p = nx_base_stuff;
23607 + struct dentry *error = ERR_PTR(-ENOENT);
23609 + for (; p->name; p++) {
23610 + if (p->len != dentry->d_name.len)
23612 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23618 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23623 +static int proc_nid_readdir(struct file *filp,
23624 + void *dirent, filldir_t filldir)
23626 + struct dentry *dentry = filp->f_dentry;
23627 + struct inode *inode = dentry->d_inode;
23628 + struct vs_entry *p = nx_base_stuff;
23629 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
23633 + pos = filp->f_pos;
23636 + ino = inode->i_ino;
23637 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23640 + /* fall through */
23642 + ino = parent_ino(dentry);
23643 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23646 + /* fall through */
23649 + if (index >= size)
23651 + for (p += index; p->name; p++) {
23652 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23653 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23659 + filp->f_pos = pos;
23664 +#define MAX_MULBY10 ((~0U - 9) / 10)
23666 +static inline int atovid(const char *str, int len)
23671 + while (len-- > 0) {
23676 + if (vid >= MAX_MULBY10)
23686 +/* now the upper level (virtual) */
23689 +static struct file_operations proc_xid_file_operations = {
23690 + .read = generic_read_dir,
23691 + .readdir = proc_xid_readdir,
23694 +static struct inode_operations proc_xid_inode_operations = {
23695 + .lookup = proc_xid_lookup,
23698 +static struct vs_entry vx_virtual_stuff[] = {
23699 + INF("info", S_IRUGO, virtual_info),
23700 + INF("status", S_IRUGO, virtual_status),
23701 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
23705 +static struct dentry *proc_virtual_lookup(struct inode *dir,
23706 + struct dentry *dentry, struct nameidata *nd)
23708 + struct vs_entry *p = vx_virtual_stuff;
23709 + struct dentry *error = ERR_PTR(-ENOENT);
23712 + for (; p->name; p++) {
23713 + if (p->len != dentry->d_name.len)
23715 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23719 + goto instantiate;
23721 + id = atovid(dentry->d_name.name, dentry->d_name.len);
23722 + if ((id < 0) || !xid_is_hashed(id))
23726 + error = proc_xid_instantiate(dir, dentry, id, p);
23731 +static struct file_operations proc_nid_file_operations = {
23732 + .read = generic_read_dir,
23733 + .readdir = proc_nid_readdir,
23736 +static struct inode_operations proc_nid_inode_operations = {
23737 + .lookup = proc_nid_lookup,
23740 +static struct vs_entry nx_virtnet_stuff[] = {
23741 + INF("info", S_IRUGO, virtnet_info),
23742 + INF("status", S_IRUGO, virtnet_status),
23743 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
23747 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
23748 + struct dentry *dentry, struct nameidata *nd)
23750 + struct vs_entry *p = nx_virtnet_stuff;
23751 + struct dentry *error = ERR_PTR(-ENOENT);
23754 + for (; p->name; p++) {
23755 + if (p->len != dentry->d_name.len)
23757 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23761 + goto instantiate;
23763 + id = atovid(dentry->d_name.name, dentry->d_name.len);
23764 + if ((id < 0) || !nid_is_hashed(id))
23768 + error = proc_nid_instantiate(dir, dentry, id, p);
23774 +#define PROC_MAXVIDS 32
23776 +int proc_virtual_readdir(struct file *filp,
23777 + void *dirent, filldir_t filldir)
23779 + struct dentry *dentry = filp->f_dentry;
23780 + struct inode *inode = dentry->d_inode;
23781 + struct vs_entry *p = vx_virtual_stuff;
23782 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
23784 + unsigned int xid_array[PROC_MAXVIDS];
23785 + char buf[PROC_NUMBUF];
23786 + unsigned int nr_xids, i;
23789 + pos = filp->f_pos;
23792 + ino = inode->i_ino;
23793 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23796 + /* fall through */
23798 + ino = parent_ino(dentry);
23799 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23802 + /* fall through */
23805 + if (index >= size)
23807 + for (p += index; p->name; p++) {
23808 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23809 + vs_proc_instantiate, 0, p))
23814 + index = pos - size;
23815 + p = &vx_virtual_stuff[size - 1];
23816 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
23817 + for (i = 0; i < nr_xids; i++) {
23818 + int n, xid = xid_array[i];
23819 + unsigned int j = PROC_NUMBUF;
23823 + buf[--j] = '0' + (n % 10);
23826 + if (proc_fill_cache(filp, dirent, filldir,
23827 + buf + j, PROC_NUMBUF - j,
23828 + vs_proc_instantiate, xid, p))
23834 + filp->f_pos = pos;
23838 +static int proc_virtual_getattr(struct vfsmount *mnt,
23839 + struct dentry *dentry, struct kstat *stat)
23841 + struct inode *inode = dentry->d_inode;
23843 + generic_fillattr(inode, stat);
23844 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
23848 +static struct file_operations proc_virtual_dir_operations = {
23849 + .read = generic_read_dir,
23850 + .readdir = proc_virtual_readdir,
23853 +static struct inode_operations proc_virtual_dir_inode_operations = {
23854 + .getattr = proc_virtual_getattr,
23855 + .lookup = proc_virtual_lookup,
23862 +int proc_virtnet_readdir(struct file *filp,
23863 + void *dirent, filldir_t filldir)
23865 + struct dentry *dentry = filp->f_dentry;
23866 + struct inode *inode = dentry->d_inode;
23867 + struct vs_entry *p = nx_virtnet_stuff;
23868 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
23870 + unsigned int nid_array[PROC_MAXVIDS];
23871 + char buf[PROC_NUMBUF];
23872 + unsigned int nr_nids, i;
23875 + pos = filp->f_pos;
23878 + ino = inode->i_ino;
23879 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23882 + /* fall through */
23884 + ino = parent_ino(dentry);
23885 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23888 + /* fall through */
23891 + if (index >= size)
23893 + for (p += index; p->name; p++) {
23894 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23895 + vs_proc_instantiate, 0, p))
23900 + index = pos - size;
23901 + p = &nx_virtnet_stuff[size - 1];
23902 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
23903 + for (i = 0; i < nr_nids; i++) {
23904 + int n, nid = nid_array[i];
23905 + unsigned int j = PROC_NUMBUF;
23909 + buf[--j] = '0' + (n % 10);
23912 + if (proc_fill_cache(filp, dirent, filldir,
23913 + buf + j, PROC_NUMBUF - j,
23914 + vs_proc_instantiate, nid, p))
23920 + filp->f_pos = pos;
23924 +static int proc_virtnet_getattr(struct vfsmount *mnt,
23925 + struct dentry *dentry, struct kstat *stat)
23927 + struct inode *inode = dentry->d_inode;
23929 + generic_fillattr(inode, stat);
23930 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
23934 +static struct file_operations proc_virtnet_dir_operations = {
23935 + .read = generic_read_dir,
23936 + .readdir = proc_virtnet_readdir,
23939 +static struct inode_operations proc_virtnet_dir_inode_operations = {
23940 + .getattr = proc_virtnet_getattr,
23941 + .lookup = proc_virtnet_lookup,
23946 +void proc_vx_init(void)
23948 + struct proc_dir_entry *ent;
23950 + ent = proc_mkdir("virtual", 0);
23952 + ent->proc_fops = &proc_virtual_dir_operations;
23953 + ent->proc_iops = &proc_virtual_dir_inode_operations;
23955 + proc_virtual = ent;
23957 + ent = proc_mkdir("virtnet", 0);
23959 + ent->proc_fops = &proc_virtnet_dir_operations;
23960 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
23962 + proc_virtnet = ent;
23968 +/* per pid info */
23971 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
23973 + struct vx_info *vxi;
23974 + char *orig = buffer;
23976 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
23978 + vxi = task_get_vx_info(p);
23982 + buffer += sprintf(buffer, "BCaps:\t");
23983 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
23984 + buffer += sprintf(buffer, "\n");
23985 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
23986 + (unsigned long long)vxi->vx_ccaps);
23987 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
23988 + (unsigned long long)vxi->vx_flags);
23989 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
23991 + put_vx_info(vxi);
23993 + return buffer - orig;
23997 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
23999 + struct nx_info *nxi;
24000 + struct nx_addr_v4 *v4a;
24001 +#ifdef CONFIG_IPV6
24002 + struct nx_addr_v6 *v6a;
24004 + char *orig = buffer;
24007 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
24009 + nxi = task_get_nx_info(p);
24013 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
24014 + (unsigned long long)nxi->nx_ncaps);
24015 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
24016 + (unsigned long long)nxi->nx_flags);
24018 + buffer += sprintf(buffer,
24019 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
24020 + NIPQUAD(nxi->v4_bcast.s_addr));
24021 + buffer += sprintf (buffer,
24022 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
24023 + NIPQUAD(nxi->v4_lback.s_addr));
24024 + if (!NX_IPV4(nxi))
24026 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
24027 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
24030 +#ifdef CONFIG_IPV6
24031 + if (!NX_IPV6(nxi))
24033 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
24034 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
24038 + put_nx_info(nxi);
24040 + return buffer - orig;
24043 diff -NurpP --minimal linux-3.1/kernel/vserver/sched.c linux-3.1-vs2.3.1-rc2/kernel/vserver/sched.c
24044 --- linux-3.1/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
24045 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/sched.c 2011-10-24 18:53:33.000000000 +0200
24048 + * linux/kernel/vserver/sched.c
24050 + * Virtual Server: Scheduler Support
24052 + * Copyright (C) 2004-2010 Herbert Pötzl
24054 + * V0.01 adapted Sam Vilains version to 2.6.3
24055 + * V0.02 removed legacy interface
24056 + * V0.03 changed vcmds to vxi arg
24057 + * V0.04 removed older and legacy interfaces
24058 + * V0.05 removed scheduler code/commands
24062 +#include <linux/vs_context.h>
24063 +#include <linux/vs_sched.h>
24064 +#include <linux/vserver/sched_cmd.h>
24066 +#include <asm/uaccess.h>
24069 +void vx_update_sched_param(struct _vx_sched *sched,
24070 + struct _vx_sched_pc *sched_pc)
24072 + sched_pc->prio_bias = sched->prio_bias;
24075 +static int do_set_prio_bias(struct vx_info *vxi, struct vcmd_prio_bias *data)
24079 + if (data->prio_bias > MAX_PRIO_BIAS)
24080 + data->prio_bias = MAX_PRIO_BIAS;
24081 + if (data->prio_bias < MIN_PRIO_BIAS)
24082 + data->prio_bias = MIN_PRIO_BIAS;
24084 + if (data->cpu_id != ~0) {
24085 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
24086 + cpus_and(vxi->sched.update, cpu_online_map,
24087 + vxi->sched.update);
24089 + vxi->sched.update = cpu_online_map;
24091 + for_each_cpu_mask(cpu, vxi->sched.update)
24092 + vx_update_sched_param(&vxi->sched,
24093 + &vx_per_cpu(vxi, sched_pc, cpu));
24097 +int vc_set_prio_bias(struct vx_info *vxi, void __user *data)
24099 + struct vcmd_prio_bias vc_data;
24101 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24104 + return do_set_prio_bias(vxi, &vc_data);
24107 +int vc_get_prio_bias(struct vx_info *vxi, void __user *data)
24109 + struct vcmd_prio_bias vc_data;
24110 + struct _vx_sched_pc *pcd;
24113 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24116 + cpu = vc_data.cpu_id;
24118 + if (!cpu_possible(cpu))
24121 + pcd = &vx_per_cpu(vxi, sched_pc, cpu);
24122 + vc_data.prio_bias = pcd->prio_bias;
24124 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24129 diff -NurpP --minimal linux-3.1/kernel/vserver/sched_init.h linux-3.1-vs2.3.1-rc2/kernel/vserver/sched_init.h
24130 --- linux-3.1/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
24131 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/sched_init.h 2011-10-24 18:53:33.000000000 +0200
24134 +static inline void vx_info_init_sched(struct _vx_sched *sched)
24136 + /* scheduling; hard code starting values as constants */
24137 + sched->prio_bias = 0;
24141 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24143 + sched_pc->prio_bias = 0;
24145 + sched_pc->user_ticks = 0;
24146 + sched_pc->sys_ticks = 0;
24147 + sched_pc->hold_ticks = 0;
24150 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
24156 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24160 diff -NurpP --minimal linux-3.1/kernel/vserver/sched_proc.h linux-3.1-vs2.3.1-rc2/kernel/vserver/sched_proc.h
24161 --- linux-3.1/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
24162 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/sched_proc.h 2011-10-24 18:53:33.000000000 +0200
24164 +#ifndef _VX_SCHED_PROC_H
24165 +#define _VX_SCHED_PROC_H
24169 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
24173 + length += sprintf(buffer,
24174 + "PrioBias:\t%8d\n",
24175 + sched->prio_bias);
24180 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
24181 + char *buffer, int cpu)
24185 + length += sprintf(buffer + length,
24186 + "cpu %d: %lld %lld %lld", cpu,
24187 + (unsigned long long)sched_pc->user_ticks,
24188 + (unsigned long long)sched_pc->sys_ticks,
24189 + (unsigned long long)sched_pc->hold_ticks);
24190 + length += sprintf(buffer + length,
24191 + " %d\n", sched_pc->prio_bias);
24195 +#endif /* _VX_SCHED_PROC_H */
24196 diff -NurpP --minimal linux-3.1/kernel/vserver/signal.c linux-3.1-vs2.3.1-rc2/kernel/vserver/signal.c
24197 --- linux-3.1/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
24198 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/signal.c 2011-10-24 18:53:33.000000000 +0200
24201 + * linux/kernel/vserver/signal.c
24203 + * Virtual Server: Signal Support
24205 + * Copyright (C) 2003-2007 Herbert Pötzl
24207 + * V0.01 broken out from vcontext V0.05
24208 + * V0.02 changed vcmds to vxi arg
24209 + * V0.03 adjusted siginfo for kill
24213 +#include <asm/uaccess.h>
24215 +#include <linux/vs_context.h>
24216 +#include <linux/vs_pid.h>
24217 +#include <linux/vserver/signal_cmd.h>
24220 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
24222 + int retval, count = 0;
24223 + struct task_struct *p;
24224 + struct siginfo *sip = SEND_SIG_PRIV;
24227 + vxdprintk(VXD_CBIT(misc, 4),
24228 + "vx_info_kill(%p[#%d],%d,%d)*",
24229 + vxi, vxi->vx_id, pid, sig);
24230 + read_lock(&tasklist_lock);
24234 + for_each_process(p) {
24237 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
24238 + (pid && vxi->vx_initpid == p->pid))
24241 + err = group_send_sig_info(sig, sip, p);
24243 + if (err != -EPERM)
24249 + if (vxi->vx_initpid) {
24250 + pid = vxi->vx_initpid;
24251 + /* for now, only SIGINT to private init ... */
24252 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24253 + /* ... as long as there are tasks left */
24254 + (atomic_read(&vxi->vx_tasks) > 1))
24257 + /* fallthrough */
24260 + p = find_task_by_real_pid(pid);
24261 + rcu_read_unlock();
24263 + if (vx_task_xid(p) == vxi->vx_id)
24264 + retval = group_send_sig_info(sig, sip, p);
24268 + read_unlock(&tasklist_lock);
24269 + vxdprintk(VXD_CBIT(misc, 4),
24270 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
24271 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
24275 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
24277 + struct vcmd_ctx_kill_v0 vc_data;
24279 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24282 + /* special check to allow guest shutdown */
24283 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24284 + /* forbid killall pid=0 when init is present */
24285 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
24286 + (vc_data.pid > 1)))
24289 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
24293 +static int __wait_exit(struct vx_info *vxi)
24295 + DECLARE_WAITQUEUE(wait, current);
24298 + add_wait_queue(&vxi->vx_wait, &wait);
24299 + set_current_state(TASK_INTERRUPTIBLE);
24302 + if (vx_info_state(vxi,
24303 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
24305 + if (signal_pending(current)) {
24306 + ret = -ERESTARTSYS;
24313 + set_current_state(TASK_RUNNING);
24314 + remove_wait_queue(&vxi->vx_wait, &wait);
24320 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
24322 + struct vcmd_wait_exit_v0 vc_data;
24325 + ret = __wait_exit(vxi);
24326 + vc_data.reboot_cmd = vxi->reboot_cmd;
24327 + vc_data.exit_code = vxi->exit_code;
24329 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24334 diff -NurpP --minimal linux-3.1/kernel/vserver/space.c linux-3.1-vs2.3.1-rc2/kernel/vserver/space.c
24335 --- linux-3.1/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
24336 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/space.c 2011-10-24 18:53:33.000000000 +0200
24339 + * linux/kernel/vserver/space.c
24341 + * Virtual Server: Context Space Support
24343 + * Copyright (C) 2003-2010 Herbert Pötzl
24345 + * V0.01 broken out from context.c 0.07
24346 + * V0.02 added task locking for namespace
24347 + * V0.03 broken out vx_enter_namespace
24348 + * V0.04 added *space support and commands
24349 + * V0.05 added credential support
24353 +#include <linux/utsname.h>
24354 +#include <linux/nsproxy.h>
24355 +#include <linux/err.h>
24356 +#include <linux/fs_struct.h>
24357 +#include <linux/cred.h>
24358 +#include <asm/uaccess.h>
24360 +#include <linux/vs_context.h>
24361 +#include <linux/vserver/space.h>
24362 +#include <linux/vserver/space_cmd.h>
24364 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
24365 +atomic_t vs_global_fs = ATOMIC_INIT(0);
24366 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
24367 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
24368 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
24369 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
24372 +/* namespace functions */
24374 +#include <linux/mnt_namespace.h>
24375 +#include <linux/user_namespace.h>
24376 +#include <linux/pid_namespace.h>
24377 +#include <linux/ipc_namespace.h>
24378 +#include <net/net_namespace.h>
24381 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
24382 + .mask = CLONE_FS |
24384 +#ifdef CONFIG_UTS_NS
24387 +#ifdef CONFIG_IPC_NS
24390 +#ifdef CONFIG_USER_NS
24396 +static const struct vcmd_space_mask_v1 space_mask = {
24397 + .mask = CLONE_FS |
24399 +#ifdef CONFIG_UTS_NS
24402 +#ifdef CONFIG_IPC_NS
24405 +#ifdef CONFIG_USER_NS
24408 +#ifdef CONFIG_PID_NS
24411 +#ifdef CONFIG_NET_NS
24417 +static const struct vcmd_space_mask_v1 default_space_mask = {
24418 + .mask = CLONE_FS |
24420 +#ifdef CONFIG_UTS_NS
24423 +#ifdef CONFIG_IPC_NS
24426 +#ifdef CONFIG_USER_NS
24429 +#ifdef CONFIG_PID_NS
24436 + * build a new nsproxy mix
24437 + * assumes that both proxies are 'const'
24438 + * does not touch nsproxy refcounts
24439 + * will hold a reference on the result.
24442 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
24443 + struct nsproxy *new_nsproxy, unsigned long mask)
24445 + struct mnt_namespace *old_ns;
24446 + struct uts_namespace *old_uts;
24447 + struct ipc_namespace *old_ipc;
24448 +#ifdef CONFIG_PID_NS
24449 + struct pid_namespace *old_pid;
24451 +#ifdef CONFIG_NET_NS
24452 + struct net *old_net;
24454 + struct nsproxy *nsproxy;
24456 + nsproxy = copy_nsproxy(old_nsproxy);
24460 + if (mask & CLONE_NEWNS) {
24461 + old_ns = nsproxy->mnt_ns;
24462 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
24463 + if (nsproxy->mnt_ns)
24464 + get_mnt_ns(nsproxy->mnt_ns);
24468 + if (mask & CLONE_NEWUTS) {
24469 + old_uts = nsproxy->uts_ns;
24470 + nsproxy->uts_ns = new_nsproxy->uts_ns;
24471 + if (nsproxy->uts_ns)
24472 + get_uts_ns(nsproxy->uts_ns);
24476 + if (mask & CLONE_NEWIPC) {
24477 + old_ipc = nsproxy->ipc_ns;
24478 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
24479 + if (nsproxy->ipc_ns)
24480 + get_ipc_ns(nsproxy->ipc_ns);
24484 +#ifdef CONFIG_PID_NS
24485 + if (mask & CLONE_NEWPID) {
24486 + old_pid = nsproxy->pid_ns;
24487 + nsproxy->pid_ns = new_nsproxy->pid_ns;
24488 + if (nsproxy->pid_ns)
24489 + get_pid_ns(nsproxy->pid_ns);
24493 +#ifdef CONFIG_NET_NS
24494 + if (mask & CLONE_NEWNET) {
24495 + old_net = nsproxy->net_ns;
24496 + nsproxy->net_ns = new_nsproxy->net_ns;
24497 + if (nsproxy->net_ns)
24498 + get_net(nsproxy->net_ns);
24503 + put_mnt_ns(old_ns);
24505 + put_uts_ns(old_uts);
24507 + put_ipc_ns(old_ipc);
24508 +#ifdef CONFIG_PID_NS
24510 + put_pid_ns(old_pid);
24512 +#ifdef CONFIG_NET_NS
24514 + put_net(old_net);
24522 + * merge two nsproxy structs into a new one.
24523 + * will hold a reference on the result.
24527 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
24528 + struct nsproxy *proxy, unsigned long mask)
24530 + struct nsproxy null_proxy = { .mnt_ns = NULL };
24536 + /* vs_mix_nsproxy returns with reference */
24537 + return vs_mix_nsproxy(old ? old : &null_proxy,
24540 + get_nsproxy(proxy);
24545 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
24547 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
24548 + struct fs_struct *fs_cur, *fs = NULL;
24549 + struct _vx_space *space;
24550 + int ret, kill = 0;
24552 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
24553 + vxi, vxi->vx_id, mask, index);
24555 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
24558 + if (index >= VX_SPACES)
24561 + space = &vxi->space[index];
24564 + mask = space->vx_nsmask;
24566 + if ((mask & space->vx_nsmask) != mask)
24569 + if (mask & CLONE_FS) {
24570 + fs = copy_fs_struct(space->vx_fs);
24574 + proxy = space->vx_nsproxy;
24576 + vxdprintk(VXD_CBIT(space, 9),
24577 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
24578 + vxi, vxi->vx_id, mask, index, proxy, fs);
24580 + task_lock(current);
24581 + fs_cur = current->fs;
24583 + if (mask & CLONE_FS) {
24584 + spin_lock(&fs_cur->lock);
24585 + current->fs = fs;
24586 + kill = !--fs_cur->users;
24587 + spin_unlock(&fs_cur->lock);
24590 + proxy_cur = current->nsproxy;
24591 + get_nsproxy(proxy_cur);
24592 + task_unlock(current);
24595 + free_fs_struct(fs_cur);
24597 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
24598 + if (IS_ERR(proxy_new)) {
24599 + ret = PTR_ERR(proxy_new);
24603 + proxy_new = xchg(¤t->nsproxy, proxy_new);
24605 + if (mask & CLONE_NEWUSER) {
24606 + struct cred *cred;
24608 + vxdprintk(VXD_CBIT(space, 10),
24609 + "vx_enter_space(%p[#%u],%p) cred (%p,%p)",
24610 + vxi, vxi->vx_id, space->vx_cred,
24611 + current->real_cred, current->cred);
24613 + if (space->vx_cred) {
24614 + cred = __prepare_creds(space->vx_cred);
24616 + commit_creds(cred);
24623 + put_nsproxy(proxy_new);
24626 + put_nsproxy(proxy_cur);
24631 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
24633 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
24634 + struct fs_struct *fs_vxi, *fs;
24635 + struct _vx_space *space;
24636 + int ret, kill = 0;
24638 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
24639 + vxi, vxi->vx_id, mask, index);
24641 + if ((mask & space_mask.mask) != mask)
24644 + if (index >= VX_SPACES)
24647 + space = &vxi->space[index];
24649 + proxy_vxi = space->vx_nsproxy;
24650 + fs_vxi = space->vx_fs;
24652 + if (mask & CLONE_FS) {
24653 + fs = copy_fs_struct(current->fs);
24658 + task_lock(current);
24660 + if (mask & CLONE_FS) {
24661 + spin_lock(&fs_vxi->lock);
24662 + space->vx_fs = fs;
24663 + kill = !--fs_vxi->users;
24664 + spin_unlock(&fs_vxi->lock);
24667 + proxy_cur = current->nsproxy;
24668 + get_nsproxy(proxy_cur);
24669 + task_unlock(current);
24672 + free_fs_struct(fs_vxi);
24674 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
24675 + if (IS_ERR(proxy_new)) {
24676 + ret = PTR_ERR(proxy_new);
24680 + proxy_new = xchg(&space->vx_nsproxy, proxy_new);
24681 + space->vx_nsmask |= mask;
24683 + if (mask & CLONE_NEWUSER) {
24684 + struct cred *cred;
24686 + vxdprintk(VXD_CBIT(space, 10),
24687 + "vx_set_space(%p[#%u],%p) cred (%p,%p)",
24688 + vxi, vxi->vx_id, space->vx_cred,
24689 + current->real_cred, current->cred);
24691 + cred = prepare_creds();
24692 + cred = (struct cred *)xchg(&space->vx_cred, cred);
24694 + abort_creds(cred);
24700 + put_nsproxy(proxy_new);
24703 + put_nsproxy(proxy_cur);
24708 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
24710 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
24712 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24715 + return vx_enter_space(vxi, vc_data.mask, 0);
24718 +int vc_enter_space(struct vx_info *vxi, void __user *data)
24720 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
24722 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24725 + if (vc_data.index >= VX_SPACES)
24728 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
24731 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
24733 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
24735 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24738 + return vx_set_space(vxi, vc_data.mask, 0);
24741 +int vc_set_space(struct vx_info *vxi, void __user *data)
24743 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
24745 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24748 + if (vc_data.index >= VX_SPACES)
24751 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
24754 +int vc_get_space_mask(void __user *data, int type)
24756 + const struct vcmd_space_mask_v1 *mask;
24759 + mask = &space_mask_v0;
24760 + else if (type == 1)
24761 + mask = &space_mask;
24763 + mask = &default_space_mask;
24765 + vxdprintk(VXD_CBIT(space, 10),
24766 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
24768 + if (copy_to_user(data, mask, sizeof(*mask)))
24773 diff -NurpP --minimal linux-3.1/kernel/vserver/switch.c linux-3.1-vs2.3.1-rc2/kernel/vserver/switch.c
24774 --- linux-3.1/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
24775 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/switch.c 2011-10-24 18:53:33.000000000 +0200
24778 + * linux/kernel/vserver/switch.c
24780 + * Virtual Server: Syscall Switch
24782 + * Copyright (C) 2003-2011 Herbert Pötzl
24784 + * V0.01 syscall switch
24785 + * V0.02 added signal to context
24786 + * V0.03 added rlimit functions
24787 + * V0.04 added iattr, task/xid functions
24788 + * V0.05 added debug/history stuff
24789 + * V0.06 added compat32 layer
24790 + * V0.07 vcmd args and perms
24791 + * V0.08 added status commands
24792 + * V0.09 added tag commands
24793 + * V0.10 added oom bias
24794 + * V0.11 added device commands
24795 + * V0.12 added warn mask
24799 +#include <linux/vs_context.h>
24800 +#include <linux/vs_network.h>
24801 +#include <linux/vserver/switch.h>
24803 +#include "vci_config.h"
24807 +int vc_get_version(uint32_t id)
24809 + return VCI_VERSION;
24813 +int vc_get_vci(uint32_t id)
24815 + return vci_kernel_config();
24818 +#include <linux/vserver/context_cmd.h>
24819 +#include <linux/vserver/cvirt_cmd.h>
24820 +#include <linux/vserver/cacct_cmd.h>
24821 +#include <linux/vserver/limit_cmd.h>
24822 +#include <linux/vserver/network_cmd.h>
24823 +#include <linux/vserver/sched_cmd.h>
24824 +#include <linux/vserver/debug_cmd.h>
24825 +#include <linux/vserver/inode_cmd.h>
24826 +#include <linux/vserver/dlimit_cmd.h>
24827 +#include <linux/vserver/signal_cmd.h>
24828 +#include <linux/vserver/space_cmd.h>
24829 +#include <linux/vserver/tag_cmd.h>
24830 +#include <linux/vserver/device_cmd.h>
24832 +#include <linux/vserver/inode.h>
24833 +#include <linux/vserver/dlimit.h>
24836 +#ifdef CONFIG_COMPAT
24837 +#define __COMPAT(name, id, data, compat) \
24838 + (compat) ? name ## _x32(id, data) : name(id, data)
24839 +#define __COMPAT_NO_ID(name, data, compat) \
24840 + (compat) ? name ## _x32(data) : name(data)
24842 +#define __COMPAT(name, id, data, compat) \
24844 +#define __COMPAT_NO_ID(name, data, compat) \
24850 +long do_vcmd(uint32_t cmd, uint32_t id,
24851 + struct vx_info *vxi, struct nx_info *nxi,
24852 + void __user *data, int compat)
24856 + case VCMD_get_version:
24857 + return vc_get_version(id);
24858 + case VCMD_get_vci:
24859 + return vc_get_vci(id);
24861 + case VCMD_task_xid:
24862 + return vc_task_xid(id);
24863 + case VCMD_vx_info:
24864 + return vc_vx_info(vxi, data);
24866 + case VCMD_task_nid:
24867 + return vc_task_nid(id);
24868 + case VCMD_nx_info:
24869 + return vc_nx_info(nxi, data);
24871 + case VCMD_task_tag:
24872 + return vc_task_tag(id);
24874 + case VCMD_set_space_v1:
24875 + return vc_set_space_v1(vxi, data);
24876 + /* this is version 2 */
24877 + case VCMD_set_space:
24878 + return vc_set_space(vxi, data);
24880 + case VCMD_get_space_mask_v0:
24881 + return vc_get_space_mask(data, 0);
24882 + /* this is version 1 */
24883 + case VCMD_get_space_mask:
24884 + return vc_get_space_mask(data, 1);
24886 + case VCMD_get_space_default:
24887 + return vc_get_space_mask(data, -1);
24889 + case VCMD_set_umask:
24890 + return vc_set_umask(vxi, data);
24892 + case VCMD_get_umask:
24893 + return vc_get_umask(vxi, data);
24895 + case VCMD_set_wmask:
24896 + return vc_set_wmask(vxi, data);
24898 + case VCMD_get_wmask:
24899 + return vc_get_wmask(vxi, data);
24900 +#ifdef CONFIG_IA32_EMULATION
24901 + case VCMD_get_rlimit:
24902 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
24903 + case VCMD_set_rlimit:
24904 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
24906 + case VCMD_get_rlimit:
24907 + return vc_get_rlimit(vxi, data);
24908 + case VCMD_set_rlimit:
24909 + return vc_set_rlimit(vxi, data);
24911 + case VCMD_get_rlimit_mask:
24912 + return vc_get_rlimit_mask(id, data);
24913 + case VCMD_reset_hits:
24914 + return vc_reset_hits(vxi, data);
24915 + case VCMD_reset_minmax:
24916 + return vc_reset_minmax(vxi, data);
24918 + case VCMD_get_vhi_name:
24919 + return vc_get_vhi_name(vxi, data);
24920 + case VCMD_set_vhi_name:
24921 + return vc_set_vhi_name(vxi, data);
24923 + case VCMD_ctx_stat:
24924 + return vc_ctx_stat(vxi, data);
24925 + case VCMD_virt_stat:
24926 + return vc_virt_stat(vxi, data);
24927 + case VCMD_sock_stat:
24928 + return vc_sock_stat(vxi, data);
24929 + case VCMD_rlimit_stat:
24930 + return vc_rlimit_stat(vxi, data);
24932 + case VCMD_set_cflags:
24933 + return vc_set_cflags(vxi, data);
24934 + case VCMD_get_cflags:
24935 + return vc_get_cflags(vxi, data);
24937 + /* this is version 1 */
24938 + case VCMD_set_ccaps:
24939 + return vc_set_ccaps(vxi, data);
24940 + /* this is version 1 */
24941 + case VCMD_get_ccaps:
24942 + return vc_get_ccaps(vxi, data);
24943 + case VCMD_set_bcaps:
24944 + return vc_set_bcaps(vxi, data);
24945 + case VCMD_get_bcaps:
24946 + return vc_get_bcaps(vxi, data);
24948 + case VCMD_set_badness:
24949 + return vc_set_badness(vxi, data);
24950 + case VCMD_get_badness:
24951 + return vc_get_badness(vxi, data);
24953 + case VCMD_set_nflags:
24954 + return vc_set_nflags(nxi, data);
24955 + case VCMD_get_nflags:
24956 + return vc_get_nflags(nxi, data);
24958 + case VCMD_set_ncaps:
24959 + return vc_set_ncaps(nxi, data);
24960 + case VCMD_get_ncaps:
24961 + return vc_get_ncaps(nxi, data);
24963 + case VCMD_set_prio_bias:
24964 + return vc_set_prio_bias(vxi, data);
24965 + case VCMD_get_prio_bias:
24966 + return vc_get_prio_bias(vxi, data);
24967 + case VCMD_add_dlimit:
24968 + return __COMPAT(vc_add_dlimit, id, data, compat);
24969 + case VCMD_rem_dlimit:
24970 + return __COMPAT(vc_rem_dlimit, id, data, compat);
24971 + case VCMD_set_dlimit:
24972 + return __COMPAT(vc_set_dlimit, id, data, compat);
24973 + case VCMD_get_dlimit:
24974 + return __COMPAT(vc_get_dlimit, id, data, compat);
24976 + case VCMD_ctx_kill:
24977 + return vc_ctx_kill(vxi, data);
24979 + case VCMD_wait_exit:
24980 + return vc_wait_exit(vxi, data);
24982 + case VCMD_get_iattr:
24983 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
24984 + case VCMD_set_iattr:
24985 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
24987 + case VCMD_fget_iattr:
24988 + return vc_fget_iattr(id, data);
24989 + case VCMD_fset_iattr:
24990 + return vc_fset_iattr(id, data);
24992 + case VCMD_enter_space_v0:
24993 + return vc_enter_space_v1(vxi, NULL);
24994 + case VCMD_enter_space_v1:
24995 + return vc_enter_space_v1(vxi, data);
24996 + /* this is version 2 */
24997 + case VCMD_enter_space:
24998 + return vc_enter_space(vxi, data);
25000 + case VCMD_ctx_create_v0:
25001 + return vc_ctx_create(id, NULL);
25002 + case VCMD_ctx_create:
25003 + return vc_ctx_create(id, data);
25004 + case VCMD_ctx_migrate_v0:
25005 + return vc_ctx_migrate(vxi, NULL);
25006 + case VCMD_ctx_migrate:
25007 + return vc_ctx_migrate(vxi, data);
25009 + case VCMD_net_create_v0:
25010 + return vc_net_create(id, NULL);
25011 + case VCMD_net_create:
25012 + return vc_net_create(id, data);
25013 + case VCMD_net_migrate:
25014 + return vc_net_migrate(nxi, data);
25016 + case VCMD_tag_migrate:
25017 + return vc_tag_migrate(id);
25019 + case VCMD_net_add:
25020 + return vc_net_add(nxi, data);
25021 + case VCMD_net_remove:
25022 + return vc_net_remove(nxi, data);
25024 + case VCMD_net_add_ipv4_v1:
25025 + return vc_net_add_ipv4_v1(nxi, data);
25026 + /* this is version 2 */
25027 + case VCMD_net_add_ipv4:
25028 + return vc_net_add_ipv4(nxi, data);
25030 + case VCMD_net_rem_ipv4_v1:
25031 + return vc_net_rem_ipv4_v1(nxi, data);
25032 + /* this is version 2 */
25033 + case VCMD_net_rem_ipv4:
25034 + return vc_net_rem_ipv4(nxi, data);
25035 +#ifdef CONFIG_IPV6
25036 + case VCMD_net_add_ipv6:
25037 + return vc_net_add_ipv6(nxi, data);
25038 + case VCMD_net_remove_ipv6:
25039 + return vc_net_remove_ipv6(nxi, data);
25041 +/* case VCMD_add_match_ipv4:
25042 + return vc_add_match_ipv4(nxi, data);
25043 + case VCMD_get_match_ipv4:
25044 + return vc_get_match_ipv4(nxi, data);
25045 +#ifdef CONFIG_IPV6
25046 + case VCMD_add_match_ipv6:
25047 + return vc_add_match_ipv6(nxi, data);
25048 + case VCMD_get_match_ipv6:
25049 + return vc_get_match_ipv6(nxi, data);
25052 +#ifdef CONFIG_VSERVER_DEVICE
25053 + case VCMD_set_mapping:
25054 + return __COMPAT(vc_set_mapping, vxi, data, compat);
25055 + case VCMD_unset_mapping:
25056 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
25058 +#ifdef CONFIG_VSERVER_HISTORY
25059 + case VCMD_dump_history:
25060 + return vc_dump_history(id);
25061 + case VCMD_read_history:
25062 + return __COMPAT(vc_read_history, id, data, compat);
25065 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
25066 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
25072 +#define __VCMD(vcmd, _perm, _args, _flags) \
25073 + case VCMD_ ## vcmd: perm = _perm; \
25074 + args = _args; flags = _flags; break
25077 +#define VCA_NONE 0x00
25078 +#define VCA_VXI 0x01
25079 +#define VCA_NXI 0x02
25081 +#define VCF_NONE 0x00
25082 +#define VCF_INFO 0x01
25083 +#define VCF_ADMIN 0x02
25084 +#define VCF_ARES 0x06 /* includes admin */
25085 +#define VCF_SETUP 0x08
25087 +#define VCF_ZIDOK 0x10 /* zero id okay */
25091 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
25094 + int permit = -1, state = 0;
25095 + int perm = -1, args = 0, flags = 0;
25096 + struct vx_info *vxi = NULL;
25097 + struct nx_info *nxi = NULL;
25100 + /* unpriviledged commands */
25101 + __VCMD(get_version, 0, VCA_NONE, 0);
25102 + __VCMD(get_vci, 0, VCA_NONE, 0);
25103 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
25104 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
25105 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
25106 + __VCMD(get_space_default,0, VCA_NONE, 0);
25108 + /* info commands */
25109 + __VCMD(task_xid, 2, VCA_NONE, 0);
25110 + __VCMD(reset_hits, 2, VCA_VXI, 0);
25111 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
25112 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
25113 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
25114 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
25115 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
25116 + __VCMD(get_umask, 3, VCA_VXI, VCF_INFO);
25117 + __VCMD(get_wmask, 3, VCA_VXI, VCF_INFO);
25118 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
25119 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
25120 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
25122 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
25123 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
25124 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
25125 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
25127 + __VCMD(task_nid, 2, VCA_NONE, 0);
25128 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
25129 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
25130 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
25132 + __VCMD(task_tag, 2, VCA_NONE, 0);
25134 + __VCMD(get_iattr, 2, VCA_NONE, 0);
25135 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
25136 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
25137 + __VCMD(get_prio_bias, 3, VCA_VXI, VCF_INFO);
25139 + /* lower admin commands */
25140 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
25141 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
25142 + __VCMD(ctx_create, 5, VCA_NONE, 0);
25143 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
25144 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
25145 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
25146 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
25147 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
25149 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
25150 + __VCMD(net_create, 5, VCA_NONE, 0);
25151 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
25153 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
25155 + /* higher admin commands */
25156 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
25157 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25158 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25160 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25161 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25162 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25163 + __VCMD(set_umask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25164 + __VCMD(set_wmask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25165 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25167 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25168 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25169 + __VCMD(set_prio_bias, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25171 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25172 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25173 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25174 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25175 + __VCMD(net_add_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25176 + __VCMD(net_rem_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25177 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25178 + __VCMD(net_rem_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25179 +#ifdef CONFIG_IPV6
25180 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25181 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25183 + __VCMD(set_iattr, 7, VCA_NONE, 0);
25184 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
25185 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
25186 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
25187 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
25189 +#ifdef CONFIG_VSERVER_DEVICE
25190 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
25191 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
25193 + /* debug level admin commands */
25194 +#ifdef CONFIG_VSERVER_HISTORY
25195 + __VCMD(dump_history, 9, VCA_NONE, 0);
25196 + __VCMD(read_history, 9, VCA_NONE, 0);
25203 + vxdprintk(VXD_CBIT(switch, 0),
25204 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
25205 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25206 + VC_VERSION(cmd), id, data, compat,
25207 + perm, args, flags);
25214 + if (!capable(CAP_CONTEXT))
25218 + /* moved here from the individual commands */
25220 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
25224 + /* vcmd involves resource management */
25226 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
25230 + /* various legacy exceptions */
25232 + /* will go away when spectator is a cap */
25233 + case VCMD_ctx_migrate_v0:
25234 + case VCMD_ctx_migrate:
25236 + current->xid = 1;
25242 + /* will go away when spectator is a cap */
25243 + case VCMD_net_migrate:
25245 + current->nid = 1;
25252 + /* vcmds are fine by default */
25255 + /* admin type vcmds require admin ... */
25256 + if (flags & VCF_ADMIN)
25257 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
25259 + /* ... but setup type vcmds override that */
25260 + if (!permit && (flags & VCF_SETUP))
25261 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
25269 + if (!id && (flags & VCF_ZIDOK))
25273 + if (args & VCA_VXI) {
25274 + vxi = lookup_vx_info(id);
25278 + if ((flags & VCF_ADMIN) &&
25279 + /* special case kill for shutdown */
25280 + (cmd != VCMD_ctx_kill) &&
25281 + /* can context be administrated? */
25282 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
25288 + if (args & VCA_NXI) {
25289 + nxi = lookup_nx_info(id);
25293 + if ((flags & VCF_ADMIN) &&
25294 + /* can context be administrated? */
25295 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
25302 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
25305 + if ((args & VCA_NXI) && nxi)
25306 + put_nx_info(nxi);
25308 + if ((args & VCA_VXI) && vxi)
25309 + put_vx_info(vxi);
25311 + vxdprintk(VXD_CBIT(switch, 1),
25312 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
25313 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25314 + VC_VERSION(cmd), ret, ret, state, permit);
25319 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
25321 + return do_vserver(cmd, id, data, 0);
25324 +#ifdef CONFIG_COMPAT
25327 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
25329 + return do_vserver(cmd, id, data, 1);
25332 +#endif /* CONFIG_COMPAT */
25333 diff -NurpP --minimal linux-3.1/kernel/vserver/sysctl.c linux-3.1-vs2.3.1-rc2/kernel/vserver/sysctl.c
25334 --- linux-3.1/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
25335 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/sysctl.c 2011-10-24 18:53:33.000000000 +0200
25338 + * kernel/vserver/sysctl.c
25340 + * Virtual Context Support
25342 + * Copyright (C) 2004-2007 Herbert Pötzl
25344 + * V0.01 basic structure
25348 +#include <linux/module.h>
25349 +#include <linux/ctype.h>
25350 +#include <linux/sysctl.h>
25351 +#include <linux/parser.h>
25352 +#include <asm/uaccess.h>
25355 + CTL_DEBUG_ERROR = 0,
25356 + CTL_DEBUG_SWITCH = 1,
25371 +unsigned int vx_debug_switch = 0;
25372 +unsigned int vx_debug_xid = 0;
25373 +unsigned int vx_debug_nid = 0;
25374 +unsigned int vx_debug_tag = 0;
25375 +unsigned int vx_debug_net = 0;
25376 +unsigned int vx_debug_limit = 0;
25377 +unsigned int vx_debug_cres = 0;
25378 +unsigned int vx_debug_dlim = 0;
25379 +unsigned int vx_debug_quota = 0;
25380 +unsigned int vx_debug_cvirt = 0;
25381 +unsigned int vx_debug_space = 0;
25382 +unsigned int vx_debug_misc = 0;
25385 +static struct ctl_table_header *vserver_table_header;
25386 +static ctl_table vserver_root_table[];
25389 +void vserver_register_sysctl(void)
25391 + if (!vserver_table_header) {
25392 + vserver_table_header = register_sysctl_table(vserver_root_table);
25397 +void vserver_unregister_sysctl(void)
25399 + if (vserver_table_header) {
25400 + unregister_sysctl_table(vserver_table_header);
25401 + vserver_table_header = NULL;
25406 +static int proc_dodebug(ctl_table *table, int write,
25407 + void __user *buffer, size_t *lenp, loff_t *ppos)
25409 + char tmpbuf[20], *p, c;
25410 + unsigned int value;
25411 + size_t left, len;
25413 + if ((*ppos && !write) || !*lenp) {
25421 + if (!access_ok(VERIFY_READ, buffer, left))
25423 + p = (char *)buffer;
25424 + while (left && __get_user(c, p) >= 0 && isspace(c))
25429 + if (left > sizeof(tmpbuf) - 1)
25431 + if (copy_from_user(tmpbuf, p, left))
25433 + tmpbuf[left] = '\0';
25435 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
25436 + value = 10 * value + (*p - '0');
25437 + if (*p && !isspace(*p))
25439 + while (left && isspace(*p))
25441 + *(unsigned int *)table->data = value;
25443 + if (!access_ok(VERIFY_WRITE, buffer, left))
25445 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
25448 + if (__copy_to_user(buffer, tmpbuf, len))
25450 + if ((left -= len) > 0) {
25451 + if (put_user('\n', (char *)buffer + len))
25465 +#define CTL_ENTRY(ctl, name) \
25467 + .procname = #name, \
25468 + .data = &vx_ ## name, \
25469 + .maxlen = sizeof(int), \
25471 + .proc_handler = &proc_dodebug, \
25472 + .extra1 = &zero, \
25473 + .extra2 = &zero, \
25476 +static ctl_table vserver_debug_table[] = {
25477 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
25478 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
25479 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
25480 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
25481 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
25482 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
25483 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
25484 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
25485 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
25486 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
25487 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
25488 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
25492 +static ctl_table vserver_root_table[] = {
25494 + .procname = "vserver",
25496 + .child = vserver_debug_table
25502 +static match_table_t tokens = {
25503 + { CTL_DEBUG_SWITCH, "switch=%x" },
25504 + { CTL_DEBUG_XID, "xid=%x" },
25505 + { CTL_DEBUG_NID, "nid=%x" },
25506 + { CTL_DEBUG_TAG, "tag=%x" },
25507 + { CTL_DEBUG_NET, "net=%x" },
25508 + { CTL_DEBUG_LIMIT, "limit=%x" },
25509 + { CTL_DEBUG_CRES, "cres=%x" },
25510 + { CTL_DEBUG_DLIM, "dlim=%x" },
25511 + { CTL_DEBUG_QUOTA, "quota=%x" },
25512 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
25513 + { CTL_DEBUG_SPACE, "space=%x" },
25514 + { CTL_DEBUG_MISC, "misc=%x" },
25515 + { CTL_DEBUG_ERROR, NULL }
25518 +#define HANDLE_CASE(id, name, val) \
25519 + case CTL_DEBUG_ ## id: \
25520 + vx_debug_ ## name = val; \
25521 + printk("vs_debug_" #name "=0x%x\n", val); \
25525 +static int __init vs_debug_setup(char *str)
25530 + printk("vs_debug_setup(%s)\n", str);
25531 + while ((p = strsep(&str, ",")) != NULL) {
25532 + substring_t args[MAX_OPT_ARGS];
25533 + unsigned int value;
25538 + token = match_token(p, tokens, args);
25539 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
25542 + HANDLE_CASE(SWITCH, switch, value);
25543 + HANDLE_CASE(XID, xid, value);
25544 + HANDLE_CASE(NID, nid, value);
25545 + HANDLE_CASE(TAG, tag, value);
25546 + HANDLE_CASE(NET, net, value);
25547 + HANDLE_CASE(LIMIT, limit, value);
25548 + HANDLE_CASE(CRES, cres, value);
25549 + HANDLE_CASE(DLIM, dlim, value);
25550 + HANDLE_CASE(QUOTA, quota, value);
25551 + HANDLE_CASE(CVIRT, cvirt, value);
25552 + HANDLE_CASE(SPACE, space, value);
25553 + HANDLE_CASE(MISC, misc, value);
25562 +__setup("vsdebug=", vs_debug_setup);
25566 +EXPORT_SYMBOL_GPL(vx_debug_switch);
25567 +EXPORT_SYMBOL_GPL(vx_debug_xid);
25568 +EXPORT_SYMBOL_GPL(vx_debug_nid);
25569 +EXPORT_SYMBOL_GPL(vx_debug_net);
25570 +EXPORT_SYMBOL_GPL(vx_debug_limit);
25571 +EXPORT_SYMBOL_GPL(vx_debug_cres);
25572 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
25573 +EXPORT_SYMBOL_GPL(vx_debug_quota);
25574 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
25575 +EXPORT_SYMBOL_GPL(vx_debug_space);
25576 +EXPORT_SYMBOL_GPL(vx_debug_misc);
25578 diff -NurpP --minimal linux-3.1/kernel/vserver/tag.c linux-3.1-vs2.3.1-rc2/kernel/vserver/tag.c
25579 --- linux-3.1/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
25580 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/tag.c 2011-10-24 18:53:33.000000000 +0200
25583 + * linux/kernel/vserver/tag.c
25585 + * Virtual Server: Shallow Tag Space
25587 + * Copyright (C) 2007 Herbert Pötzl
25589 + * V0.01 basic implementation
25593 +#include <linux/sched.h>
25594 +#include <linux/vserver/debug.h>
25595 +#include <linux/vs_pid.h>
25596 +#include <linux/vs_tag.h>
25598 +#include <linux/vserver/tag_cmd.h>
25601 +int dx_migrate_task(struct task_struct *p, tag_t tag)
25606 + vxdprintk(VXD_CBIT(tag, 5),
25607 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
25613 + vxdprintk(VXD_CBIT(tag, 5),
25614 + "moved task %p into [#%d]", p, tag);
25618 +/* vserver syscall commands below here */
25620 +/* taks xid and vx_info functions */
25623 +int vc_task_tag(uint32_t id)
25628 + struct task_struct *tsk;
25630 + tsk = find_task_by_real_pid(id);
25631 + tag = (tsk) ? tsk->tag : -ESRCH;
25632 + rcu_read_unlock();
25634 + tag = dx_current_tag();
25639 +int vc_tag_migrate(uint32_t tag)
25641 + return dx_migrate_task(current, tag & 0xFFFF);
25645 diff -NurpP --minimal linux-3.1/kernel/vserver/vci_config.h linux-3.1-vs2.3.1-rc2/kernel/vserver/vci_config.h
25646 --- linux-3.1/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
25647 +++ linux-3.1-vs2.3.1-rc2/kernel/vserver/vci_config.h 2011-10-24 18:53:33.000000000 +0200
25650 +/* interface version */
25652 +#define VCI_VERSION 0x00020308
25656 + VCI_KCBIT_NO_DYNAMIC = 0,
25658 + VCI_KCBIT_PROC_SECURE = 4,
25659 + /* VCI_KCBIT_HARDCPU = 5, */
25660 + /* VCI_KCBIT_IDLELIMIT = 6, */
25661 + /* VCI_KCBIT_IDLETIME = 7, */
25663 + VCI_KCBIT_COWBL = 8,
25664 + VCI_KCBIT_FULLCOWBL = 9,
25665 + VCI_KCBIT_SPACES = 10,
25666 + VCI_KCBIT_NETV2 = 11,
25667 + VCI_KCBIT_MEMCG = 12,
25669 + VCI_KCBIT_DEBUG = 16,
25670 + VCI_KCBIT_HISTORY = 20,
25671 + VCI_KCBIT_TAGGED = 24,
25672 + VCI_KCBIT_PPTAG = 28,
25674 + VCI_KCBIT_MORE = 31,
25678 +static inline uint32_t vci_kernel_config(void)
25681 + (1 << VCI_KCBIT_NO_DYNAMIC) |
25683 + /* configured features */
25684 +#ifdef CONFIG_VSERVER_PROC_SECURE
25685 + (1 << VCI_KCBIT_PROC_SECURE) |
25687 +#ifdef CONFIG_VSERVER_COWBL
25688 + (1 << VCI_KCBIT_COWBL) |
25689 + (1 << VCI_KCBIT_FULLCOWBL) |
25691 + (1 << VCI_KCBIT_SPACES) |
25692 + (1 << VCI_KCBIT_NETV2) |
25693 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
25694 + (1 << VCI_KCBIT_MEMCG) |
25697 + /* debug options */
25698 +#ifdef CONFIG_VSERVER_DEBUG
25699 + (1 << VCI_KCBIT_DEBUG) |
25701 +#ifdef CONFIG_VSERVER_HISTORY
25702 + (1 << VCI_KCBIT_HISTORY) |
25705 + /* inode context tagging */
25706 +#if defined(CONFIG_TAGGING_NONE)
25707 + (0 << VCI_KCBIT_TAGGED) |
25708 +#elif defined(CONFIG_TAGGING_UID16)
25709 + (1 << VCI_KCBIT_TAGGED) |
25710 +#elif defined(CONFIG_TAGGING_GID16)
25711 + (2 << VCI_KCBIT_TAGGED) |
25712 +#elif defined(CONFIG_TAGGING_ID24)
25713 + (3 << VCI_KCBIT_TAGGED) |
25714 +#elif defined(CONFIG_TAGGING_INTERN)
25715 + (4 << VCI_KCBIT_TAGGED) |
25716 +#elif defined(CONFIG_TAGGING_RUNTIME)
25717 + (5 << VCI_KCBIT_TAGGED) |
25719 + (7 << VCI_KCBIT_TAGGED) |
25721 + (1 << VCI_KCBIT_PPTAG) |
25725 diff -NurpP --minimal linux-3.1/mm/filemap_xip.c linux-3.1-vs2.3.1-rc2/mm/filemap_xip.c
25726 --- linux-3.1/mm/filemap_xip.c 2011-07-22 11:18:12.000000000 +0200
25727 +++ linux-3.1-vs2.3.1-rc2/mm/filemap_xip.c 2011-10-24 18:53:33.000000000 +0200
25729 #include <linux/seqlock.h>
25730 #include <linux/mutex.h>
25731 #include <linux/gfp.h>
25732 +#include <linux/vs_memory.h>
25733 #include <asm/tlbflush.h>
25734 #include <asm/io.h>
25736 diff -NurpP --minimal linux-3.1/mm/fremap.c linux-3.1-vs2.3.1-rc2/mm/fremap.c
25737 --- linux-3.1/mm/fremap.c 2011-07-22 11:18:12.000000000 +0200
25738 +++ linux-3.1-vs2.3.1-rc2/mm/fremap.c 2011-10-24 18:53:33.000000000 +0200
25740 #include <linux/module.h>
25741 #include <linux/syscalls.h>
25742 #include <linux/mmu_notifier.h>
25743 +#include <linux/vs_memory.h>
25745 #include <asm/mmu_context.h>
25746 #include <asm/cacheflush.h>
25747 diff -NurpP --minimal linux-3.1/mm/hugetlb.c linux-3.1-vs2.3.1-rc2/mm/hugetlb.c
25748 --- linux-3.1/mm/hugetlb.c 2011-10-24 18:45:33.000000000 +0200
25749 +++ linux-3.1-vs2.3.1-rc2/mm/hugetlb.c 2011-10-24 18:53:33.000000000 +0200
25752 #include <linux/hugetlb.h>
25753 #include <linux/node.h>
25754 +#include <linux/vs_memory.h>
25755 #include "internal.h"
25757 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
25758 diff -NurpP --minimal linux-3.1/mm/memcontrol.c linux-3.1-vs2.3.1-rc2/mm/memcontrol.c
25759 --- linux-3.1/mm/memcontrol.c 2011-10-24 18:45:33.000000000 +0200
25760 +++ linux-3.1-vs2.3.1-rc2/mm/memcontrol.c 2011-10-24 18:53:33.000000000 +0200
25761 @@ -760,6 +760,31 @@ struct mem_cgroup *mem_cgroup_from_task(
25762 struct mem_cgroup, css);
25765 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
25767 + return res_counter_read_u64(&mem->res, member);
25770 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
25772 + return res_counter_read_u64(&mem->memsw, member);
25775 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
25777 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
25780 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
25782 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
25785 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
25787 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
25790 struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
25792 struct mem_cgroup *mem = NULL;
25793 diff -NurpP --minimal linux-3.1/mm/memory.c linux-3.1-vs2.3.1-rc2/mm/memory.c
25794 --- linux-3.1/mm/memory.c 2011-10-24 18:45:33.000000000 +0200
25795 +++ linux-3.1-vs2.3.1-rc2/mm/memory.c 2011-10-24 18:53:33.000000000 +0200
25796 @@ -3389,6 +3389,7 @@ int handle_pte_fault(struct mm_struct *m
25800 + int ret = 0, type = VXPT_UNKNOWN;
25803 if (!pte_present(entry)) {
25804 @@ -3413,9 +3414,12 @@ int handle_pte_fault(struct mm_struct *m
25805 if (unlikely(!pte_same(*pte, entry)))
25807 if (flags & FAULT_FLAG_WRITE) {
25808 - if (!pte_write(entry))
25809 - return do_wp_page(mm, vma, address,
25810 + if (!pte_write(entry)) {
25811 + ret = do_wp_page(mm, vma, address,
25812 pte, pmd, ptl, entry);
25813 + type = VXPT_WRITE;
25816 entry = pte_mkdirty(entry);
25818 entry = pte_mkyoung(entry);
25819 @@ -3433,7 +3437,10 @@ int handle_pte_fault(struct mm_struct *m
25822 pte_unmap_unlock(pte, ptl);
25826 + vx_page_fault(mm, vma, type, ret);
25831 diff -NurpP --minimal linux-3.1/mm/mremap.c linux-3.1-vs2.3.1-rc2/mm/mremap.c
25832 --- linux-3.1/mm/mremap.c 2011-07-22 11:18:12.000000000 +0200
25833 +++ linux-3.1-vs2.3.1-rc2/mm/mremap.c 2011-10-24 18:53:33.000000000 +0200
25835 #include <linux/security.h>
25836 #include <linux/syscalls.h>
25837 #include <linux/mmu_notifier.h>
25838 +#include <linux/vs_memory.h>
25840 #include <asm/uaccess.h>
25841 #include <asm/cacheflush.h>
25842 diff -NurpP --minimal linux-3.1/mm/oom_kill.c linux-3.1-vs2.3.1-rc2/mm/oom_kill.c
25843 --- linux-3.1/mm/oom_kill.c 2011-10-24 18:45:33.000000000 +0200
25844 +++ linux-3.1-vs2.3.1-rc2/mm/oom_kill.c 2011-10-24 18:53:33.000000000 +0200
25846 #include <linux/mempolicy.h>
25847 #include <linux/security.h>
25848 #include <linux/ptrace.h>
25849 +#include <linux/reboot.h>
25850 +#include <linux/vs_memory.h>
25851 +#include <linux/vs_context.h>
25853 int sysctl_panic_on_oom;
25854 int sysctl_oom_kill_allocating_task;
25855 @@ -134,11 +137,18 @@ struct task_struct *find_lock_task_mm(st
25856 static bool oom_unkillable_task(struct task_struct *p,
25857 const struct mem_cgroup *mem, const nodemask_t *nodemask)
25859 - if (is_global_init(p))
25860 + unsigned xid = vx_current_xid();
25862 + /* skip the init task, global and per guest */
25863 + if (task_is_init(p))
25865 if (p->flags & PF_KTHREAD)
25868 + /* skip other guest and host processes if oom in guest */
25869 + if (xid && vx_task_xid(p) != xid)
25872 /* When mem_cgroup_out_of_memory() and p is not member of the group */
25873 if (mem && !task_in_mem_cgroup(p, mem))
25875 @@ -214,6 +224,18 @@ unsigned int oom_badness(struct task_str
25876 points += p->signal->oom_score_adj;
25879 + * add points for context badness and
25880 + * reduce badness for processes belonging to
25881 + * a different context
25884 + points += vx_badness(p, p->mm);
25886 + if ((vx_current_xid() > 1) &&
25887 + vx_current_xid() != vx_task_xid(p))
25891 * Never return 0 for an eligible task that may be killed since it's
25892 * possible that no single user task uses more than 0.1% of memory and
25893 * no single admin tasks uses more than 3.0%.
25894 @@ -428,8 +450,8 @@ static int oom_kill_task(struct task_str
25895 /* mm cannot be safely dereferenced after task_unlock(p) */
25898 - pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
25899 - task_pid_nr(p), p->comm, K(p->mm->total_vm),
25900 + pr_err("Killed process %d:#%u (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
25901 + task_pid_nr(p), p->xid, p->comm, K(p->mm->total_vm),
25902 K(get_mm_counter(p->mm, MM_ANONPAGES)),
25903 K(get_mm_counter(p->mm, MM_FILEPAGES)));
25905 @@ -483,8 +505,8 @@ static int oom_kill_process(struct task_
25909 - pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
25910 - message, task_pid_nr(p), p->comm, points);
25911 + pr_err("%s: Kill process %d:#%u (%s) score %d or sacrifice child\n",
25912 + message, task_pid_nr(p), p->xid, p->comm, points);
25916 @@ -585,6 +607,8 @@ int unregister_oom_notifier(struct notif
25918 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
25920 +long vs_oom_action(unsigned int);
25923 * Try to acquire the OOM killer lock for the zones in zonelist. Returns zero
25924 * if a parallel OOM killing is already taking place that includes a zone in
25925 @@ -743,7 +767,12 @@ retry:
25927 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
25928 read_unlock(&tasklist_lock);
25929 - panic("Out of memory and no killable processes...\n");
25931 + /* avoid panic for guest OOM */
25932 + if (current->xid)
25933 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
25935 + panic("Out of memory and no killable processes...\n");
25938 if (oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
25939 diff -NurpP --minimal linux-3.1/mm/page_alloc.c linux-3.1-vs2.3.1-rc2/mm/page_alloc.c
25940 --- linux-3.1/mm/page_alloc.c 2011-10-24 18:45:33.000000000 +0200
25941 +++ linux-3.1-vs2.3.1-rc2/mm/page_alloc.c 2011-10-24 18:53:33.000000000 +0200
25943 #include <linux/ftrace_event.h>
25944 #include <linux/memcontrol.h>
25945 #include <linux/prefetch.h>
25946 +#include <linux/vs_base.h>
25947 +#include <linux/vs_limit.h>
25949 #include <asm/tlbflush.h>
25950 #include <asm/div64.h>
25951 @@ -2484,6 +2486,9 @@ void si_meminfo(struct sysinfo *val)
25952 val->totalhigh = totalhigh_pages;
25953 val->freehigh = nr_free_highpages();
25954 val->mem_unit = PAGE_SIZE;
25956 + if (vx_flags(VXF_VIRT_MEM, 0))
25957 + vx_vsi_meminfo(val);
25960 EXPORT_SYMBOL(si_meminfo);
25961 @@ -2504,6 +2509,9 @@ void si_meminfo_node(struct sysinfo *val
25964 val->mem_unit = PAGE_SIZE;
25966 + if (vx_flags(VXF_VIRT_MEM, 0))
25967 + vx_vsi_meminfo(val);
25971 diff -NurpP --minimal linux-3.1/mm/pgtable-generic.c linux-3.1-vs2.3.1-rc2/mm/pgtable-generic.c
25972 --- linux-3.1/mm/pgtable-generic.c 2011-03-15 18:07:42.000000000 +0100
25973 +++ linux-3.1-vs2.3.1-rc2/mm/pgtable-generic.c 2011-10-24 18:53:33.000000000 +0200
25975 * Copyright (C) 2010 Linus Torvalds
25978 +#include <linux/mm.h>
25980 #include <linux/pagemap.h>
25981 #include <asm/tlb.h>
25982 #include <asm-generic/pgtable.h>
25983 diff -NurpP --minimal linux-3.1/mm/rmap.c linux-3.1-vs2.3.1-rc2/mm/rmap.c
25984 --- linux-3.1/mm/rmap.c 2011-10-24 18:45:33.000000000 +0200
25985 +++ linux-3.1-vs2.3.1-rc2/mm/rmap.c 2011-10-24 18:53:33.000000000 +0200
25987 #include <linux/mmu_notifier.h>
25988 #include <linux/migrate.h>
25989 #include <linux/hugetlb.h>
25990 +#include <linux/vs_memory.h>
25992 #include <asm/tlbflush.h>
25994 diff -NurpP --minimal linux-3.1/mm/shmem.c linux-3.1-vs2.3.1-rc2/mm/shmem.c
25995 --- linux-3.1/mm/shmem.c 2011-10-24 18:45:33.000000000 +0200
25996 +++ linux-3.1-vs2.3.1-rc2/mm/shmem.c 2011-10-24 18:53:33.000000000 +0200
25997 @@ -1429,7 +1429,7 @@ static int shmem_statfs(struct dentry *d
25999 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
26001 - buf->f_type = TMPFS_MAGIC;
26002 + buf->f_type = TMPFS_SUPER_MAGIC;
26003 buf->f_bsize = PAGE_CACHE_SIZE;
26004 buf->f_namelen = NAME_MAX;
26005 if (sbinfo->max_blocks) {
26006 @@ -2186,7 +2186,7 @@ int shmem_fill_super(struct super_block
26007 sb->s_maxbytes = MAX_LFS_FILESIZE;
26008 sb->s_blocksize = PAGE_CACHE_SIZE;
26009 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
26010 - sb->s_magic = TMPFS_MAGIC;
26011 + sb->s_magic = TMPFS_SUPER_MAGIC;
26012 sb->s_op = &shmem_ops;
26013 sb->s_time_gran = 1;
26014 #ifdef CONFIG_TMPFS_XATTR
26015 diff -NurpP --minimal linux-3.1/mm/slab.c linux-3.1-vs2.3.1-rc2/mm/slab.c
26016 --- linux-3.1/mm/slab.c 2011-10-24 18:45:33.000000000 +0200
26017 +++ linux-3.1-vs2.3.1-rc2/mm/slab.c 2011-10-24 18:53:33.000000000 +0200
26018 @@ -411,6 +411,8 @@ static void kmem_list3_init(struct kmem_
26019 #define STATS_INC_FREEMISS(x) do { } while (0)
26022 +#include "slab_vs.h"
26027 @@ -3399,6 +3401,7 @@ retry:
26029 obj = slab_get_obj(cachep, slabp, nodeid);
26030 check_slabp(cachep, slabp);
26031 + vx_slab_alloc(cachep, flags);
26032 l3->free_objects--;
26033 /* move slabp to correct slabp list: */
26034 list_del(&slabp->list);
26035 @@ -3476,6 +3479,7 @@ __cache_alloc_node(struct kmem_cache *ca
26036 /* ___cache_alloc_node can fall back to other nodes */
26037 ptr = ____cache_alloc_node(cachep, flags, nodeid);
26039 + vx_slab_alloc(cachep, flags);
26040 local_irq_restore(save_flags);
26041 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
26042 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
26043 @@ -3663,6 +3667,7 @@ static inline void __cache_free(struct k
26045 kmemleak_free_recursive(objp, cachep->flags);
26046 objp = cache_free_debugcheck(cachep, objp, caller);
26047 + vx_slab_free(cachep);
26049 kmemcheck_slab_free(cachep, objp, obj_size(cachep));
26051 diff -NurpP --minimal linux-3.1/mm/slab_vs.h linux-3.1-vs2.3.1-rc2/mm/slab_vs.h
26052 --- linux-3.1/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
26053 +++ linux-3.1-vs2.3.1-rc2/mm/slab_vs.h 2011-10-24 18:53:33.000000000 +0200
26056 +#include <linux/vserver/context.h>
26058 +#include <linux/vs_context.h>
26061 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
26063 + int what = gfp_zone(cachep->gfpflags);
26064 + struct vx_info *vxi = current_vx_info();
26069 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
26073 +void vx_slab_free(struct kmem_cache *cachep)
26075 + int what = gfp_zone(cachep->gfpflags);
26076 + struct vx_info *vxi = current_vx_info();
26081 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
26084 diff -NurpP --minimal linux-3.1/mm/swapfile.c linux-3.1-vs2.3.1-rc2/mm/swapfile.c
26085 --- linux-3.1/mm/swapfile.c 2011-10-24 18:45:33.000000000 +0200
26086 +++ linux-3.1-vs2.3.1-rc2/mm/swapfile.c 2011-10-24 18:53:33.000000000 +0200
26088 #include <asm/tlbflush.h>
26089 #include <linux/swapops.h>
26090 #include <linux/page_cgroup.h>
26091 +#include <linux/vs_base.h>
26092 +#include <linux/vs_memory.h>
26094 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
26096 @@ -1754,6 +1756,16 @@ static int swap_show(struct seq_file *sw
26098 if (si == SEQ_START_TOKEN) {
26099 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
26100 + if (vx_flags(VXF_VIRT_MEM, 0)) {
26101 + struct sysinfo si;
26103 + vx_vsi_swapinfo(&si);
26104 + if (si.totalswap < (1 << 10))
26106 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
26107 + "hdv0", "partition", si.totalswap >> 10,
26108 + (si.totalswap - si.freeswap) >> 10, -1);
26113 @@ -2177,6 +2189,8 @@ void si_swapinfo(struct sysinfo *val)
26114 val->freeswap = nr_swap_pages + nr_to_be_unused;
26115 val->totalswap = total_swap_pages + nr_to_be_unused;
26116 spin_unlock(&swap_lock);
26117 + if (vx_flags(VXF_VIRT_MEM, 0))
26118 + vx_vsi_swapinfo(val);
26122 diff -NurpP --minimal linux-3.1/net/bridge/br_multicast.c linux-3.1-vs2.3.1-rc2/net/bridge/br_multicast.c
26123 --- linux-3.1/net/bridge/br_multicast.c 2011-10-24 18:45:34.000000000 +0200
26124 +++ linux-3.1-vs2.3.1-rc2/net/bridge/br_multicast.c 2011-10-24 18:53:33.000000000 +0200
26125 @@ -447,7 +447,7 @@ static struct sk_buff *br_ip6_multicast_
26126 ip6h->hop_limit = 1;
26127 ipv6_addr_set(&ip6h->daddr, htonl(0xff020000), 0, 0, htonl(1));
26128 ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0,
26130 + &ip6h->saddr, NULL);
26131 ipv6_eth_mc_map(&ip6h->daddr, eth->h_dest);
26133 hopopt = (u8 *)(ip6h + 1);
26134 diff -NurpP --minimal linux-3.1/net/core/dev.c linux-3.1-vs2.3.1-rc2/net/core/dev.c
26135 --- linux-3.1/net/core/dev.c 2011-10-24 18:45:34.000000000 +0200
26136 +++ linux-3.1-vs2.3.1-rc2/net/core/dev.c 2011-10-24 18:53:33.000000000 +0200
26137 @@ -127,6 +127,7 @@
26138 #include <linux/in.h>
26139 #include <linux/jhash.h>
26140 #include <linux/random.h>
26141 +#include <linux/vs_inet.h>
26142 #include <trace/events/napi.h>
26143 #include <trace/events/net.h>
26144 #include <trace/events/skb.h>
26145 @@ -619,7 +620,8 @@ struct net_device *__dev_get_by_name(str
26146 struct hlist_head *head = dev_name_hash(net, name);
26148 hlist_for_each_entry(dev, p, head, name_hlist)
26149 - if (!strncmp(dev->name, name, IFNAMSIZ))
26150 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
26151 + nx_dev_visible(current_nx_info(), dev))
26155 @@ -645,7 +647,8 @@ struct net_device *dev_get_by_name_rcu(s
26156 struct hlist_head *head = dev_name_hash(net, name);
26158 hlist_for_each_entry_rcu(dev, p, head, name_hlist)
26159 - if (!strncmp(dev->name, name, IFNAMSIZ))
26160 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
26161 + nx_dev_visible(current_nx_info(), dev))
26165 @@ -696,7 +699,8 @@ struct net_device *__dev_get_by_index(st
26166 struct hlist_head *head = dev_index_hash(net, ifindex);
26168 hlist_for_each_entry(dev, p, head, index_hlist)
26169 - if (dev->ifindex == ifindex)
26170 + if ((dev->ifindex == ifindex) &&
26171 + nx_dev_visible(current_nx_info(), dev))
26175 @@ -714,7 +718,7 @@ EXPORT_SYMBOL(__dev_get_by_index);
26176 * about locking. The caller must hold RCU lock.
26179 -struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
26180 +struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex)
26182 struct hlist_node *p;
26183 struct net_device *dev;
26184 @@ -726,6 +730,16 @@ struct net_device *dev_get_by_index_rcu(
26188 +EXPORT_SYMBOL(dev_get_by_index_real_rcu);
26190 +struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
26192 + struct net_device *dev = dev_get_by_index_real_rcu(net, ifindex);
26194 + if (nx_dev_visible(current_nx_info(), dev))
26198 EXPORT_SYMBOL(dev_get_by_index_rcu);
26201 @@ -774,7 +788,8 @@ struct net_device *dev_getbyhwaddr_rcu(s
26203 for_each_netdev_rcu(net, dev)
26204 if (dev->type == type &&
26205 - !memcmp(dev->dev_addr, ha, dev->addr_len))
26206 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
26207 + nx_dev_visible(current_nx_info(), dev))
26211 @@ -786,9 +801,11 @@ struct net_device *__dev_getfirstbyhwtyp
26212 struct net_device *dev;
26215 - for_each_netdev(net, dev)
26216 - if (dev->type == type)
26217 + for_each_netdev(net, dev) {
26218 + if ((dev->type == type) &&
26219 + nx_dev_visible(current_nx_info(), dev))
26225 @@ -906,6 +923,8 @@ static int __dev_alloc_name(struct net *
26227 if (i < 0 || i >= max_netdevices)
26229 + if (!nx_dev_visible(current_nx_info(), d))
26232 /* avoid cases where sscanf is not exact inverse of printf */
26233 snprintf(buf, IFNAMSIZ, name, i);
26234 @@ -3955,6 +3974,8 @@ static int dev_ifconf(struct net *net, c
26237 for_each_netdev(net, dev) {
26238 + if (!nx_dev_visible(current_nx_info(), dev))
26240 for (i = 0; i < NPROTO; i++) {
26241 if (gifconf_list[i]) {
26243 @@ -4029,6 +4050,10 @@ static void dev_seq_printf_stats(struct
26244 struct rtnl_link_stats64 temp;
26245 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
26247 + /* device visible inside network context? */
26248 + if (!nx_dev_visible(current_nx_info(), dev))
26251 seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
26252 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
26253 dev->name, stats->rx_bytes, stats->rx_packets,
26254 diff -NurpP --minimal linux-3.1/net/core/rtnetlink.c linux-3.1-vs2.3.1-rc2/net/core/rtnetlink.c
26255 --- linux-3.1/net/core/rtnetlink.c 2011-10-24 18:45:34.000000000 +0200
26256 +++ linux-3.1-vs2.3.1-rc2/net/core/rtnetlink.c 2011-10-24 18:53:33.000000000 +0200
26257 @@ -1040,6 +1040,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
26258 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
26261 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
26263 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
26264 NETLINK_CB(cb->skb).pid,
26265 cb->nlh->nlmsg_seq, 0,
26266 @@ -1881,6 +1883,9 @@ void rtmsg_ifinfo(int type, struct net_d
26267 int err = -ENOBUFS;
26268 size_t if_info_size;
26270 + if (!nx_dev_visible(current_nx_info(), dev))
26273 skb = nlmsg_new((if_info_size = if_nlmsg_size(dev)), GFP_KERNEL);
26276 diff -NurpP --minimal linux-3.1/net/core/sock.c linux-3.1-vs2.3.1-rc2/net/core/sock.c
26277 --- linux-3.1/net/core/sock.c 2011-10-24 18:45:34.000000000 +0200
26278 +++ linux-3.1-vs2.3.1-rc2/net/core/sock.c 2011-10-24 18:53:33.000000000 +0200
26279 @@ -127,6 +127,10 @@
26280 #include <net/cls_cgroup.h>
26282 #include <linux/filter.h>
26283 +#include <linux/vs_socket.h>
26284 +#include <linux/vs_limit.h>
26285 +#include <linux/vs_context.h>
26286 +#include <linux/vs_network.h>
26288 #include <trace/events/sock.h>
26290 @@ -1073,6 +1077,8 @@ static struct sock *sk_prot_alloc(struct
26292 sk_tx_queue_clear(sk);
26294 + sock_vx_init(sk);
26295 + sock_nx_init(sk);
26299 @@ -1172,6 +1178,11 @@ static void __sk_free(struct sock *sk)
26300 put_cred(sk->sk_peer_cred);
26301 put_pid(sk->sk_peer_pid);
26302 put_net(sock_net(sk));
26304 + clr_vx_info(&sk->sk_vx_info);
26306 + clr_nx_info(&sk->sk_nx_info);
26308 sk_prot_free(sk->sk_prot_creator, sk);
26311 @@ -1219,6 +1230,8 @@ struct sock *sk_clone(const struct sock
26314 get_net(sock_net(newsk));
26315 + sock_vx_init(newsk);
26316 + sock_nx_init(newsk);
26317 sk_node_init(&newsk->sk_node);
26318 sock_lock_init(newsk);
26319 bh_lock_sock(newsk);
26320 @@ -1274,6 +1287,12 @@ struct sock *sk_clone(const struct sock
26322 atomic_set(&newsk->sk_refcnt, 2);
26324 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
26325 + newsk->sk_xid = sk->sk_xid;
26326 + vx_sock_inc(newsk);
26327 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
26328 + newsk->sk_nid = sk->sk_nid;
26331 * Increment the counter in the same struct proto as the master
26332 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
26333 @@ -2022,6 +2041,12 @@ void sock_init_data(struct socket *sock,
26335 sk->sk_stamp = ktime_set(-1L, 0);
26337 + set_vx_info(&sk->sk_vx_info, current_vx_info());
26338 + sk->sk_xid = vx_current_xid();
26340 + set_nx_info(&sk->sk_nx_info, current_nx_info());
26341 + sk->sk_nid = nx_current_nid();
26344 * Before updating sk_refcnt, we must commit prior changes to memory
26345 * (Documentation/RCU/rculist_nulls.txt for details)
26346 diff -NurpP --minimal linux-3.1/net/ipv4/af_inet.c linux-3.1-vs2.3.1-rc2/net/ipv4/af_inet.c
26347 --- linux-3.1/net/ipv4/af_inet.c 2011-10-24 18:45:34.000000000 +0200
26348 +++ linux-3.1-vs2.3.1-rc2/net/ipv4/af_inet.c 2011-10-24 18:53:33.000000000 +0200
26349 @@ -117,6 +117,7 @@
26350 #ifdef CONFIG_IP_MROUTE
26351 #include <linux/mroute.h>
26353 +#include <linux/vs_limit.h>
26356 /* The inetsw table contains everything that inet_create needs to
26357 @@ -326,9 +327,13 @@ lookup_protocol:
26361 + if ((protocol == IPPROTO_ICMP) &&
26362 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
26365 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
26366 goto out_rcu_unlock;
26369 err = -EAFNOSUPPORT;
26370 if (!inet_netns_ok(net, protocol))
26371 goto out_rcu_unlock;
26372 @@ -452,6 +457,7 @@ int inet_bind(struct socket *sock, struc
26373 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
26374 struct sock *sk = sock->sk;
26375 struct inet_sock *inet = inet_sk(sk);
26376 + struct nx_v4_sock_addr nsa;
26377 unsigned short snum;
26380 @@ -475,7 +481,11 @@ int inet_bind(struct socket *sock, struc
26384 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
26385 + err = v4_map_sock_addr(inet, addr, &nsa);
26389 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
26391 /* Not specified by any standard per-se, however it breaks too
26392 * many applications when removed. It is unfortunate since
26393 @@ -487,7 +497,7 @@ int inet_bind(struct socket *sock, struc
26394 err = -EADDRNOTAVAIL;
26395 if (!sysctl_ip_nonlocal_bind &&
26396 !(inet->freebind || inet->transparent) &&
26397 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
26398 + nsa.saddr != htonl(INADDR_ANY) &&
26399 chk_addr_ret != RTN_LOCAL &&
26400 chk_addr_ret != RTN_MULTICAST &&
26401 chk_addr_ret != RTN_BROADCAST)
26402 @@ -512,7 +522,7 @@ int inet_bind(struct socket *sock, struc
26403 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
26404 goto out_release_sock;
26406 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
26407 + v4_set_sock_addr(inet, &nsa);
26408 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
26409 inet->inet_saddr = 0; /* Use device */
26411 @@ -715,11 +725,13 @@ int inet_getname(struct socket *sock, st
26414 sin->sin_port = inet->inet_dport;
26415 - sin->sin_addr.s_addr = inet->inet_daddr;
26416 + sin->sin_addr.s_addr =
26417 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
26419 __be32 addr = inet->inet_rcv_saddr;
26421 addr = inet->inet_saddr;
26422 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
26423 sin->sin_port = inet->inet_sport;
26424 sin->sin_addr.s_addr = addr;
26426 diff -NurpP --minimal linux-3.1/net/ipv4/arp.c linux-3.1-vs2.3.1-rc2/net/ipv4/arp.c
26427 --- linux-3.1/net/ipv4/arp.c 2011-10-24 18:45:34.000000000 +0200
26428 +++ linux-3.1-vs2.3.1-rc2/net/ipv4/arp.c 2011-10-24 18:53:33.000000000 +0200
26429 @@ -1332,6 +1332,7 @@ static void arp_format_neigh_entry(struc
26430 struct net_device *dev = n->dev;
26431 int hatype = dev->type;
26433 + /* FIXME: check for network context */
26434 read_lock(&n->lock);
26435 /* Convert hardware address to XX:XX:XX:XX ... form. */
26436 #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
26437 @@ -1363,6 +1364,7 @@ static void arp_format_pneigh_entry(stru
26438 int hatype = dev ? dev->type : 0;
26441 + /* FIXME: check for network context */
26442 sprintf(tbuf, "%pI4", n->key);
26443 seq_printf(seq, "%-16s 0x%-10x0x%-10x%s * %s\n",
26444 tbuf, hatype, ATF_PUBL | ATF_PERM, "00:00:00:00:00:00",
26445 diff -NurpP --minimal linux-3.1/net/ipv4/devinet.c linux-3.1-vs2.3.1-rc2/net/ipv4/devinet.c
26446 --- linux-3.1/net/ipv4/devinet.c 2011-10-24 18:45:34.000000000 +0200
26447 +++ linux-3.1-vs2.3.1-rc2/net/ipv4/devinet.c 2011-10-24 18:53:33.000000000 +0200
26448 @@ -518,6 +518,7 @@ struct in_device *inetdev_by_index(struc
26450 EXPORT_SYMBOL(inetdev_by_index);
26453 /* Called only from RTNL semaphored context. No locks. */
26455 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
26456 @@ -759,6 +760,8 @@ int devinet_ioctl(struct net *net, unsig
26458 in_dev = __in_dev_get_rtnl(dev);
26460 + struct nx_info *nxi = current_nx_info();
26462 if (tryaddrmatch) {
26463 /* Matthias Andree */
26464 /* compare label and address (4.4BSD style) */
26465 @@ -767,6 +770,8 @@ int devinet_ioctl(struct net *net, unsig
26466 This is checked above. */
26467 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26468 ifap = &ifa->ifa_next) {
26469 + if (!nx_v4_ifa_visible(nxi, ifa))
26471 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
26472 sin_orig.sin_addr.s_addr ==
26474 @@ -779,9 +784,12 @@ int devinet_ioctl(struct net *net, unsig
26475 comparing just the label */
26477 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26478 - ifap = &ifa->ifa_next)
26479 + ifap = &ifa->ifa_next) {
26480 + if (!nx_v4_ifa_visible(nxi, ifa))
26482 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
26488 @@ -934,6 +942,8 @@ static int inet_gifconf(struct net_devic
26491 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
26492 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
26495 done += sizeof(ifr);
26497 @@ -1294,6 +1304,7 @@ static int inet_dump_ifaddr(struct sk_bu
26498 struct net_device *dev;
26499 struct in_device *in_dev;
26500 struct in_ifaddr *ifa;
26501 + struct sock *sk = skb->sk;
26502 struct hlist_head *head;
26503 struct hlist_node *node;
26505 @@ -1316,6 +1327,8 @@ static int inet_dump_ifaddr(struct sk_bu
26507 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
26508 ifa = ifa->ifa_next, ip_idx++) {
26509 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
26511 if (ip_idx < s_ip_idx)
26513 if (inet_fill_ifaddr(skb, ifa,
26514 diff -NurpP --minimal linux-3.1/net/ipv4/fib_trie.c linux-3.1-vs2.3.1-rc2/net/ipv4/fib_trie.c
26515 --- linux-3.1/net/ipv4/fib_trie.c 2011-10-24 18:45:34.000000000 +0200
26516 +++ linux-3.1-vs2.3.1-rc2/net/ipv4/fib_trie.c 2011-10-24 18:53:33.000000000 +0200
26517 @@ -2554,6 +2554,7 @@ static int fib_route_seq_show(struct seq
26518 || fa->fa_type == RTN_MULTICAST)
26521 + /* FIXME: check for network context? */
26524 "%s\t%08X\t%08X\t%04X\t%d\t%u\t"
26525 diff -NurpP --minimal linux-3.1/net/ipv4/inet_connection_sock.c linux-3.1-vs2.3.1-rc2/net/ipv4/inet_connection_sock.c
26526 --- linux-3.1/net/ipv4/inet_connection_sock.c 2011-07-22 11:18:13.000000000 +0200
26527 +++ linux-3.1-vs2.3.1-rc2/net/ipv4/inet_connection_sock.c 2011-10-24 18:53:33.000000000 +0200
26528 @@ -52,6 +52,37 @@ void inet_get_local_port_range(int *low,
26530 EXPORT_SYMBOL(inet_get_local_port_range);
26532 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
26534 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1),
26535 + sk2_rcv_saddr = sk_rcv_saddr(sk2);
26537 + if (inet_v6_ipv6only(sk2))
26540 + if (sk1_rcv_saddr &&
26542 + sk1_rcv_saddr == sk2_rcv_saddr)
26545 + if (sk1_rcv_saddr &&
26546 + !sk2_rcv_saddr &&
26547 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
26550 + if (sk2_rcv_saddr &&
26551 + !sk1_rcv_saddr &&
26552 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
26555 + if (!sk1_rcv_saddr &&
26556 + !sk2_rcv_saddr &&
26557 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
26563 int inet_csk_bind_conflict(const struct sock *sk,
26564 const struct inet_bind_bucket *tb)
26566 @@ -74,9 +105,7 @@ int inet_csk_bind_conflict(const struct
26567 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
26568 if (!reuse || !sk2->sk_reuse ||
26569 sk2->sk_state == TCP_LISTEN) {
26570 - const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
26571 - if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
26572 - sk2_rcv_saddr == sk_rcv_saddr(sk))
26573 + if (ipv4_rcv_saddr_equal(sk, sk2))
26577 diff -NurpP --minimal linux-3.1/net/ipv4/inet_diag.c linux-3.1-vs2.3.1-rc2/net/ipv4/inet_diag.c
26578 --- linux-3.1/net/ipv4/inet_diag.c 2011-10-24 18:45:34.000000000 +0200
26579 +++ linux-3.1-vs2.3.1-rc2/net/ipv4/inet_diag.c 2011-10-24 18:53:33.000000000 +0200
26581 #include <linux/stddef.h>
26583 #include <linux/inet_diag.h>
26584 +#include <linux/vs_network.h>
26585 +#include <linux/vs_inet.h>
26587 static const struct inet_diag_handler **inet_diag_table;
26589 @@ -119,8 +121,10 @@ static int inet_csk_diag_fill(struct soc
26591 r->id.idiag_sport = inet->inet_sport;
26592 r->id.idiag_dport = inet->inet_dport;
26593 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
26594 - r->id.idiag_dst[0] = inet->inet_daddr;
26595 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
26596 + inet->inet_rcv_saddr);
26597 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
26598 + inet->inet_daddr);
26600 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
26601 if (r->idiag_family == AF_INET6) {
26602 @@ -205,8 +209,8 @@ static int inet_twsk_diag_fill(struct in
26603 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
26604 r->id.idiag_sport = tw->tw_sport;
26605 r->id.idiag_dport = tw->tw_dport;
26606 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
26607 - r->id.idiag_dst[0] = tw->tw_daddr;
26608 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
26609 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
26610 r->idiag_state = tw->tw_substate;
26611 r->idiag_timer = 3;
26612 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
26613 @@ -263,6 +267,7 @@ static int inet_diag_get_exact(struct sk
26616 if (req->idiag_family == AF_INET) {
26617 + /* TODO: lback */
26618 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
26619 req->id.idiag_dport, req->id.idiag_src[0],
26620 req->id.idiag_sport, req->id.idiag_if);
26621 @@ -505,6 +510,7 @@ static int inet_csk_diag_dump(struct soc
26625 + /* TODO: lback */
26626 entry.saddr = &inet->inet_rcv_saddr;
26627 entry.daddr = &inet->inet_daddr;
26629 @@ -543,6 +549,7 @@ static int inet_twsk_diag_dump(struct in
26633 + /* TODO: lback */
26634 entry.saddr = &tw->tw_rcv_saddr;
26635 entry.daddr = &tw->tw_daddr;
26637 @@ -589,8 +596,8 @@ static int inet_diag_fill_req(struct sk_
26639 r->id.idiag_sport = inet->inet_sport;
26640 r->id.idiag_dport = ireq->rmt_port;
26641 - r->id.idiag_src[0] = ireq->loc_addr;
26642 - r->id.idiag_dst[0] = ireq->rmt_addr;
26643 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
26644 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
26645 r->idiag_expires = jiffies_to_msecs(tmo);
26646 r->idiag_rqueue = 0;
26647 r->idiag_wqueue = 0;
26648 @@ -661,6 +668,7 @@ static int inet_diag_dump_reqs(struct sk
26652 + /* TODO: lback */
26654 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
26655 (entry.family == AF_INET6) ?
26656 @@ -731,6 +739,8 @@ static int inet_diag_dump(struct sk_buff
26657 sk_nulls_for_each(sk, node, &ilb->head) {
26658 struct inet_sock *inet = inet_sk(sk);
26660 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26665 @@ -797,6 +807,8 @@ skip_listen_ht:
26666 sk_nulls_for_each(sk, node, &head->chain) {
26667 struct inet_sock *inet = inet_sk(sk);
26669 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26673 if (!(r->idiag_states & (1 << sk->sk_state)))
26674 @@ -821,6 +833,8 @@ next_normal:
26675 inet_twsk_for_each(tw, node,
26678 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
26682 if (r->id.idiag_sport != tw->tw_sport &&
26683 diff -NurpP --minimal linux-3.1/net/ipv4/inet_hashtables.c linux-3.1-vs2.3.1-rc2/net/ipv4/inet_hashtables.c
26684 --- linux-3.1/net/ipv4/inet_hashtables.c 2011-10-24 18:45:34.000000000 +0200
26685 +++ linux-3.1-vs2.3.1-rc2/net/ipv4/inet_hashtables.c 2011-10-24 18:53:33.000000000 +0200
26687 #include <net/inet_connection_sock.h>
26688 #include <net/inet_hashtables.h>
26689 #include <net/secure_seq.h>
26690 +#include <net/route.h>
26691 #include <net/ip.h>
26694 @@ -156,6 +157,11 @@ static inline int compute_score(struct s
26695 if (rcv_saddr != daddr)
26699 + /* block non nx_info ips */
26700 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
26701 + daddr, NXA_MASK_BIND))
26704 if (sk->sk_bound_dev_if) {
26705 if (sk->sk_bound_dev_if != dif)
26706 @@ -173,7 +179,6 @@ static inline int compute_score(struct s
26707 * wildcarded during the search since they can never be otherwise.
26711 struct sock *__inet_lookup_listener(struct net *net,
26712 struct inet_hashinfo *hashinfo,
26713 const __be32 daddr, const unsigned short hnum,
26714 @@ -196,6 +201,7 @@ begin:
26720 * if the nulls value we got at the end of this lookup is
26721 * not the expected one, we must restart lookup.
26722 diff -NurpP --minimal linux-3.1/net/ipv4/netfilter/nf_nat_helper.c linux-3.1-vs2.3.1-rc2/net/ipv4/netfilter/nf_nat_helper.c
26723 --- linux-3.1/net/ipv4/netfilter/nf_nat_helper.c 2011-07-22 11:18:13.000000000 +0200
26724 +++ linux-3.1-vs2.3.1-rc2/net/ipv4/netfilter/nf_nat_helper.c 2011-10-24 18:53:33.000000000 +0200
26726 #include <net/route.h>
26728 #include <linux/netfilter_ipv4.h>
26729 +#include <net/route.h>
26730 #include <net/netfilter/nf_conntrack.h>
26731 #include <net/netfilter/nf_conntrack_helper.h>
26732 #include <net/netfilter/nf_conntrack_ecache.h>
26733 diff -NurpP --minimal linux-3.1/net/ipv4/netfilter.c linux-3.1-vs2.3.1-rc2/net/ipv4/netfilter.c
26734 --- linux-3.1/net/ipv4/netfilter.c 2011-10-24 18:45:34.000000000 +0200
26735 +++ linux-3.1-vs2.3.1-rc2/net/ipv4/netfilter.c 2011-10-24 18:53:33.000000000 +0200
26737 #include <linux/ip.h>
26738 #include <linux/skbuff.h>
26739 #include <linux/gfp.h>
26740 -#include <net/route.h>
26741 +// #include <net/route.h>
26742 #include <net/xfrm.h>
26743 #include <net/ip.h>
26744 #include <net/netfilter/nf_queue.h>
26745 diff -NurpP --minimal linux-3.1/net/ipv4/raw.c linux-3.1-vs2.3.1-rc2/net/ipv4/raw.c
26746 --- linux-3.1/net/ipv4/raw.c 2011-10-24 18:45:34.000000000 +0200
26747 +++ linux-3.1-vs2.3.1-rc2/net/ipv4/raw.c 2011-10-24 18:53:33.000000000 +0200
26748 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
26750 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
26751 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
26752 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
26753 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
26754 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
26755 goto found; /* gotcha */
26757 @@ -385,6 +385,12 @@ static int raw_send_hdrinc(struct sock *
26758 icmp_out_count(net, ((struct icmphdr *)
26759 skb_transport_header(skb))->type);
26762 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
26763 + sk->sk_nx_info &&
26764 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
26767 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
26768 rt->dst.dev, dst_output);
26770 @@ -572,6 +578,16 @@ static int raw_sendmsg(struct kiocb *ioc
26774 + if (sk->sk_nx_info) {
26775 + rt = ip_v4_find_src(sock_net(sk), sk->sk_nx_info, &fl4);
26776 + if (IS_ERR(rt)) {
26777 + err = PTR_ERR(rt);
26784 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
26785 rt = ip_route_output_flow(sock_net(sk), &fl4, sk);
26787 @@ -648,17 +664,19 @@ static int raw_bind(struct sock *sk, str
26789 struct inet_sock *inet = inet_sk(sk);
26790 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
26791 + struct nx_v4_sock_addr nsa = { 0 };
26795 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
26797 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
26798 + v4_map_sock_addr(inet, addr, &nsa);
26799 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
26800 ret = -EADDRNOTAVAIL;
26801 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
26802 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
26803 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
26805 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
26806 + v4_set_sock_addr(inet, &nsa);
26807 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
26808 inet->inet_saddr = 0; /* Use device */
26810 @@ -710,7 +728,8 @@ static int raw_recvmsg(struct kiocb *ioc
26811 /* Copy the address. */
26813 sin->sin_family = AF_INET;
26814 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
26815 + sin->sin_addr.s_addr =
26816 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
26818 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
26820 @@ -906,7 +925,8 @@ static struct sock *raw_get_first(struct
26821 struct hlist_node *node;
26823 sk_for_each(sk, node, &state->h->ht[state->bucket])
26824 - if (sock_net(sk) == seq_file_net(seq))
26825 + if ((sock_net(sk) == seq_file_net(seq)) &&
26826 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26830 @@ -922,7 +942,8 @@ static struct sock *raw_get_next(struct
26834 - } while (sk && sock_net(sk) != seq_file_net(seq));
26835 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
26836 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
26838 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
26839 sk = sk_head(&state->h->ht[state->bucket]);
26840 diff -NurpP --minimal linux-3.1/net/ipv4/route.c linux-3.1-vs2.3.1-rc2/net/ipv4/route.c
26841 --- linux-3.1/net/ipv4/route.c 2011-10-24 18:45:34.000000000 +0200
26842 +++ linux-3.1-vs2.3.1-rc2/net/ipv4/route.c 2011-10-24 18:53:33.000000000 +0200
26843 @@ -2562,7 +2562,7 @@ static struct rtable *ip_route_output_sl
26846 if (fl4->flowi4_oif) {
26847 - dev_out = dev_get_by_index_rcu(net, fl4->flowi4_oif);
26848 + dev_out = dev_get_by_index_real_rcu(net, fl4->flowi4_oif);
26849 rth = ERR_PTR(-ENODEV);
26850 if (dev_out == NULL)
26852 diff -NurpP --minimal linux-3.1/net/ipv4/tcp.c linux-3.1-vs2.3.1-rc2/net/ipv4/tcp.c
26853 --- linux-3.1/net/ipv4/tcp.c 2011-07-22 11:18:13.000000000 +0200
26854 +++ linux-3.1-vs2.3.1-rc2/net/ipv4/tcp.c 2011-10-24 18:53:33.000000000 +0200
26855 @@ -266,6 +266,7 @@
26856 #include <linux/crypto.h>
26857 #include <linux/time.h>
26858 #include <linux/slab.h>
26859 +#include <linux/in.h>
26861 #include <net/icmp.h>
26862 #include <net/tcp.h>
26863 diff -NurpP --minimal linux-3.1/net/ipv4/tcp_ipv4.c linux-3.1-vs2.3.1-rc2/net/ipv4/tcp_ipv4.c
26864 --- linux-3.1/net/ipv4/tcp_ipv4.c 2011-10-24 18:45:34.000000000 +0200
26865 +++ linux-3.1-vs2.3.1-rc2/net/ipv4/tcp_ipv4.c 2011-10-24 18:53:33.000000000 +0200
26866 @@ -2018,6 +2018,12 @@ static void *listening_get_next(struct s
26867 req = req->dl_next;
26870 + vxdprintk(VXD_CBIT(net, 6),
26871 + "sk,req: %p [#%d] (from %d)", req->sk,
26872 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
26874 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
26876 if (req->rsk_ops->family == st->family) {
26879 @@ -2042,6 +2048,10 @@ get_req:
26882 sk_nulls_for_each_from(sk, node) {
26883 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
26884 + sk, sk->sk_nid, nx_current_nid());
26885 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26887 if (!net_eq(sock_net(sk), net))
26889 if (sk->sk_family == st->family) {
26890 @@ -2118,6 +2128,11 @@ static void *established_get_first(struc
26892 spin_lock_bh(lock);
26893 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
26894 + vxdprintk(VXD_CBIT(net, 6),
26895 + "sk,egf: %p [#%d] (from %d)",
26896 + sk, sk->sk_nid, nx_current_nid());
26897 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26899 if (sk->sk_family != st->family ||
26900 !net_eq(sock_net(sk), net)) {
26902 @@ -2128,6 +2143,11 @@ static void *established_get_first(struc
26903 st->state = TCP_SEQ_STATE_TIME_WAIT;
26904 inet_twsk_for_each(tw, node,
26905 &tcp_hashinfo.ehash[st->bucket].twchain) {
26906 + vxdprintk(VXD_CBIT(net, 6),
26907 + "tw: %p [#%d] (from %d)",
26908 + tw, tw->tw_nid, nx_current_nid());
26909 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
26911 if (tw->tw_family != st->family ||
26912 !net_eq(twsk_net(tw), net)) {
26914 @@ -2157,7 +2177,9 @@ static void *established_get_next(struct
26918 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
26919 + while (tw && (tw->tw_family != st->family ||
26920 + !net_eq(twsk_net(tw), net) ||
26921 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
26925 @@ -2181,6 +2203,11 @@ get_tw:
26926 sk = sk_nulls_next(sk);
26928 sk_nulls_for_each_from(sk, node) {
26929 + vxdprintk(VXD_CBIT(net, 6),
26930 + "sk,egn: %p [#%d] (from %d)",
26931 + sk, sk->sk_nid, nx_current_nid());
26932 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26934 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
26937 @@ -2390,9 +2417,9 @@ static void get_openreq4(struct sock *sk
26938 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
26939 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %pK%n",
26942 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
26943 ntohs(inet_sk(sk)->inet_sport),
26945 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
26946 ntohs(ireq->rmt_port),
26948 0, 0, /* could print option size, but that is af dependent. */
26949 @@ -2414,8 +2441,8 @@ static void get_tcp4_sock(struct sock *s
26950 struct tcp_sock *tp = tcp_sk(sk);
26951 const struct inet_connection_sock *icsk = inet_csk(sk);
26952 struct inet_sock *inet = inet_sk(sk);
26953 - __be32 dest = inet->inet_daddr;
26954 - __be32 src = inet->inet_rcv_saddr;
26955 + __be32 dest = nx_map_sock_lback(current_nx_info(), inet->inet_daddr);
26956 + __be32 src = nx_map_sock_lback(current_nx_info(), inet->inet_rcv_saddr);
26957 __u16 destp = ntohs(inet->inet_dport);
26958 __u16 srcp = ntohs(inet->inet_sport);
26960 @@ -2472,8 +2499,8 @@ static void get_timewait4_sock(struct in
26964 - dest = tw->tw_daddr;
26965 - src = tw->tw_rcv_saddr;
26966 + dest = nx_map_sock_lback(current_nx_info(), tw->tw_daddr);
26967 + src = nx_map_sock_lback(current_nx_info(), tw->tw_rcv_saddr);
26968 destp = ntohs(tw->tw_dport);
26969 srcp = ntohs(tw->tw_sport);
26971 diff -NurpP --minimal linux-3.1/net/ipv4/tcp_minisocks.c linux-3.1-vs2.3.1-rc2/net/ipv4/tcp_minisocks.c
26972 --- linux-3.1/net/ipv4/tcp_minisocks.c 2011-10-24 18:45:34.000000000 +0200
26973 +++ linux-3.1-vs2.3.1-rc2/net/ipv4/tcp_minisocks.c 2011-10-24 18:53:33.000000000 +0200
26975 #include <linux/slab.h>
26976 #include <linux/sysctl.h>
26977 #include <linux/workqueue.h>
26978 +#include <linux/vs_limit.h>
26979 +#include <linux/vs_socket.h>
26980 +#include <linux/vs_context.h>
26981 #include <net/tcp.h>
26982 #include <net/inet_common.h>
26983 #include <net/xfrm.h>
26984 @@ -336,6 +339,11 @@ void tcp_time_wait(struct sock *sk, int
26985 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
26986 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
26988 + tw->tw_xid = sk->sk_xid;
26989 + tw->tw_vx_info = NULL;
26990 + tw->tw_nid = sk->sk_nid;
26991 + tw->tw_nx_info = NULL;
26993 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
26994 if (tw->tw_family == PF_INET6) {
26995 struct ipv6_pinfo *np = inet6_sk(sk);
26996 diff -NurpP --minimal linux-3.1/net/ipv4/udp.c linux-3.1-vs2.3.1-rc2/net/ipv4/udp.c
26997 --- linux-3.1/net/ipv4/udp.c 2011-10-24 18:45:34.000000000 +0200
26998 +++ linux-3.1-vs2.3.1-rc2/net/ipv4/udp.c 2011-10-24 18:53:33.000000000 +0200
26999 @@ -297,14 +297,7 @@ fail:
27001 EXPORT_SYMBOL(udp_lib_get_port);
27003 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27005 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
27007 - return (!ipv6_only_sock(sk2) &&
27008 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
27009 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
27011 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
27013 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
27015 @@ -339,6 +332,11 @@ static inline int compute_score(struct s
27016 if (inet->inet_rcv_saddr != daddr)
27020 + /* block non nx_info ips */
27021 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
27022 + daddr, NXA_MASK_BIND))
27025 if (inet->inet_daddr) {
27026 if (inet->inet_daddr != saddr)
27027 @@ -442,6 +440,7 @@ exact_match:
27032 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
27033 * harder than this. -DaveM
27035 @@ -487,6 +486,11 @@ begin:
27036 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
27037 score = compute_score(sk, net, saddr, hnum, sport,
27038 daddr, dport, dif);
27039 + /* FIXME: disabled?
27040 + if (score == 9) {
27044 if (score > badness) {
27047 @@ -500,6 +504,7 @@ begin:
27048 if (get_nulls_value(node) != slot)
27053 if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
27055 @@ -509,6 +514,7 @@ begin:
27063 @@ -551,8 +557,7 @@ static inline struct sock *udp_v4_mcast_
27064 udp_sk(s)->udp_port_hash != hnum ||
27065 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
27066 (inet->inet_dport != rmt_port && inet->inet_dport) ||
27067 - (inet->inet_rcv_saddr &&
27068 - inet->inet_rcv_saddr != loc_addr) ||
27069 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
27070 ipv6_only_sock(s) ||
27071 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
27073 @@ -930,6 +935,16 @@ int udp_sendmsg(struct kiocb *iocb, stru
27074 inet_sk_flowi_flags(sk)|FLOWI_FLAG_CAN_SLEEP,
27075 faddr, saddr, dport, inet->inet_sport);
27077 + if (sk->sk_nx_info) {
27078 + rt = ip_v4_find_src(net, sk->sk_nx_info, fl4);
27079 + if (IS_ERR(rt)) {
27080 + err = PTR_ERR(rt);
27087 security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
27088 rt = ip_route_output_flow(net, fl4, sk);
27090 @@ -1227,7 +1242,8 @@ try_again:
27092 sin->sin_family = AF_INET;
27093 sin->sin_port = udp_hdr(skb)->source;
27094 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27095 + sin->sin_addr.s_addr = nx_map_sock_lback(
27096 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
27097 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
27099 if (inet->cmsg_flags)
27100 @@ -1972,6 +1988,8 @@ static struct sock *udp_get_first(struct
27101 sk_nulls_for_each(sk, node, &hslot->head) {
27102 if (!net_eq(sock_net(sk), net))
27104 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27106 if (sk->sk_family == state->family)
27109 @@ -1989,7 +2007,9 @@ static struct sock *udp_get_next(struct
27112 sk = sk_nulls_next(sk);
27113 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
27114 + } while (sk && (!net_eq(sock_net(sk), net) ||
27115 + sk->sk_family != state->family ||
27116 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27119 if (state->bucket <= state->udp_table->mask)
27120 diff -NurpP --minimal linux-3.1/net/ipv6/Kconfig linux-3.1-vs2.3.1-rc2/net/ipv6/Kconfig
27121 --- linux-3.1/net/ipv6/Kconfig 2010-08-02 16:52:59.000000000 +0200
27122 +++ linux-3.1-vs2.3.1-rc2/net/ipv6/Kconfig 2011-10-24 18:53:33.000000000 +0200
27125 # IPv6 as module will cause a CRASH if you try to unload it
27127 - tristate "The IPv6 protocol"
27129 + bool "The IPv6 protocol"
27132 This is complemental support for the IP version 6.
27133 You will still be able to do traditional IPv4 networking as well.
27134 diff -NurpP --minimal linux-3.1/net/ipv6/addrconf.c linux-3.1-vs2.3.1-rc2/net/ipv6/addrconf.c
27135 --- linux-3.1/net/ipv6/addrconf.c 2011-10-24 18:45:34.000000000 +0200
27136 +++ linux-3.1-vs2.3.1-rc2/net/ipv6/addrconf.c 2011-10-24 18:53:33.000000000 +0200
27139 #include <linux/proc_fs.h>
27140 #include <linux/seq_file.h>
27141 +#include <linux/vs_network.h>
27142 +#include <linux/vs_inet6.h>
27144 /* Set to 3 to get tracing... */
27145 #define ACONF_DEBUG 2
27146 @@ -1108,7 +1110,7 @@ out:
27148 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
27149 const struct in6_addr *daddr, unsigned int prefs,
27150 - struct in6_addr *saddr)
27151 + struct in6_addr *saddr, struct nx_info *nxi)
27153 struct ipv6_saddr_score scores[2],
27154 *score = &scores[0], *hiscore = &scores[1];
27155 @@ -1180,6 +1182,8 @@ int ipv6_dev_get_saddr(struct net *net,
27159 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
27163 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
27164 @@ -3087,7 +3091,10 @@ static void if6_seq_stop(struct seq_file
27165 static int if6_seq_show(struct seq_file *seq, void *v)
27167 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
27168 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
27170 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
27171 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
27172 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
27174 ifp->idev->dev->ifindex,
27176 @@ -3593,6 +3600,11 @@ static int in6_dump_addrs(struct inet6_d
27177 struct ifacaddr6 *ifaca;
27179 int ip_idx = *p_ip_idx;
27180 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27182 + /* disable ipv6 on non v6 guests */
27183 + if (nxi && !nx_info_has_v6(nxi))
27186 read_lock_bh(&idev->lock);
27188 @@ -3603,6 +3615,8 @@ static int in6_dump_addrs(struct inet6_d
27189 list_for_each_entry(ifa, &idev->addr_list, if_list) {
27190 if (++ip_idx < s_ip_idx)
27192 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
27194 err = inet6_fill_ifaddr(skb, ifa,
27195 NETLINK_CB(cb->skb).pid,
27196 cb->nlh->nlmsg_seq,
27197 @@ -3619,6 +3633,8 @@ static int in6_dump_addrs(struct inet6_d
27198 ifmca = ifmca->next, ip_idx++) {
27199 if (ip_idx < s_ip_idx)
27201 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
27203 err = inet6_fill_ifmcaddr(skb, ifmca,
27204 NETLINK_CB(cb->skb).pid,
27205 cb->nlh->nlmsg_seq,
27206 @@ -3634,6 +3650,8 @@ static int in6_dump_addrs(struct inet6_d
27207 ifaca = ifaca->aca_next, ip_idx++) {
27208 if (ip_idx < s_ip_idx)
27210 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
27212 err = inet6_fill_ifacaddr(skb, ifaca,
27213 NETLINK_CB(cb->skb).pid,
27214 cb->nlh->nlmsg_seq,
27215 @@ -4019,6 +4037,11 @@ static int inet6_dump_ifinfo(struct sk_b
27216 struct inet6_dev *idev;
27217 struct hlist_head *head;
27218 struct hlist_node *node;
27219 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27221 + /* FIXME: maybe disable ipv6 on non v6 guests?
27222 + if (skb->sk && skb->sk->sk_vx_info)
27223 + return skb->len; */
27226 s_idx = cb->args[1];
27227 @@ -4030,6 +4053,8 @@ static int inet6_dump_ifinfo(struct sk_b
27228 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
27231 + if (!v6_dev_in_nx_info(dev, nxi))
27233 idev = __in6_dev_get(dev);
27236 diff -NurpP --minimal linux-3.1/net/ipv6/af_inet6.c linux-3.1-vs2.3.1-rc2/net/ipv6/af_inet6.c
27237 --- linux-3.1/net/ipv6/af_inet6.c 2011-10-24 18:45:34.000000000 +0200
27238 +++ linux-3.1-vs2.3.1-rc2/net/ipv6/af_inet6.c 2011-10-24 18:53:33.000000000 +0200
27240 #include <linux/netdevice.h>
27241 #include <linux/icmpv6.h>
27242 #include <linux/netfilter_ipv6.h>
27243 +#include <linux/vs_inet.h>
27244 +#include <linux/vs_inet6.h>
27246 #include <net/ip.h>
27247 #include <net/ipv6.h>
27248 @@ -160,9 +162,12 @@ lookup_protocol:
27252 + if ((protocol == IPPROTO_ICMPV6) &&
27253 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
27255 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
27256 goto out_rcu_unlock;
27259 sock->ops = answer->ops;
27260 answer_prot = answer->prot;
27261 answer_no_check = answer->no_check;
27262 @@ -261,6 +266,7 @@ int inet6_bind(struct socket *sock, stru
27263 struct inet_sock *inet = inet_sk(sk);
27264 struct ipv6_pinfo *np = inet6_sk(sk);
27265 struct net *net = sock_net(sk);
27266 + struct nx_v6_sock_addr nsa;
27268 unsigned short snum;
27270 @@ -276,6 +282,10 @@ int inet6_bind(struct socket *sock, stru
27271 if (addr->sin6_family != AF_INET6)
27272 return -EAFNOSUPPORT;
27274 + err = v6_map_sock_addr(inet, addr, &nsa);
27278 addr_type = ipv6_addr_type(&addr->sin6_addr);
27279 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
27281 @@ -307,6 +317,7 @@ int inet6_bind(struct socket *sock, stru
27282 /* Reproduce AF_INET checks to make the bindings consistent */
27283 v4addr = addr->sin6_addr.s6_addr32[3];
27284 chk_addr_ret = inet_addr_type(net, v4addr);
27286 if (!sysctl_ip_nonlocal_bind &&
27287 !(inet->freebind || inet->transparent) &&
27288 v4addr != htonl(INADDR_ANY) &&
27289 @@ -316,6 +327,10 @@ int inet6_bind(struct socket *sock, stru
27290 err = -EADDRNOTAVAIL;
27293 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
27294 + err = -EADDRNOTAVAIL;
27298 if (addr_type != IPV6_ADDR_ANY) {
27299 struct net_device *dev = NULL;
27300 @@ -342,6 +357,11 @@ int inet6_bind(struct socket *sock, stru
27304 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27305 + err = -EADDRNOTAVAIL;
27309 /* ipv4 addr of the socket is invalid. Only the
27310 * unspecified and mapped address have a v4 equivalent.
27312 @@ -358,6 +378,9 @@ int inet6_bind(struct socket *sock, stru
27316 + /* what's that for? */
27317 + v6_set_sock_addr(inet, &nsa);
27319 inet->inet_rcv_saddr = v4addr;
27320 inet->inet_saddr = v4addr;
27322 @@ -459,9 +482,11 @@ int inet6_getname(struct socket *sock, s
27324 sin->sin6_port = inet->inet_dport;
27325 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
27326 + /* FIXME: remap lback? */
27328 sin->sin6_flowinfo = np->flow_label;
27330 + /* FIXME: remap lback? */
27331 if (ipv6_addr_any(&np->rcv_saddr))
27332 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
27334 diff -NurpP --minimal linux-3.1/net/ipv6/datagram.c linux-3.1-vs2.3.1-rc2/net/ipv6/datagram.c
27335 --- linux-3.1/net/ipv6/datagram.c 2011-10-24 18:45:34.000000000 +0200
27336 +++ linux-3.1-vs2.3.1-rc2/net/ipv6/datagram.c 2011-10-24 18:53:33.000000000 +0200
27337 @@ -646,7 +646,7 @@ int datagram_send_ctl(struct net *net, s
27340 if (fl6->flowi6_oif) {
27341 - dev = dev_get_by_index_rcu(net, fl6->flowi6_oif);
27342 + dev = dev_get_by_index_real_rcu(net, fl6->flowi6_oif);
27346 diff -NurpP --minimal linux-3.1/net/ipv6/fib6_rules.c linux-3.1-vs2.3.1-rc2/net/ipv6/fib6_rules.c
27347 --- linux-3.1/net/ipv6/fib6_rules.c 2011-05-22 16:18:00.000000000 +0200
27348 +++ linux-3.1-vs2.3.1-rc2/net/ipv6/fib6_rules.c 2011-10-24 18:53:33.000000000 +0200
27349 @@ -90,7 +90,7 @@ static int fib6_rule_action(struct fib_r
27350 ip6_dst_idev(&rt->dst)->dev,
27352 rt6_flags2srcprefs(flags),
27356 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
27358 diff -NurpP --minimal linux-3.1/net/ipv6/inet6_hashtables.c linux-3.1-vs2.3.1-rc2/net/ipv6/inet6_hashtables.c
27359 --- linux-3.1/net/ipv6/inet6_hashtables.c 2011-10-24 18:45:34.000000000 +0200
27360 +++ linux-3.1-vs2.3.1-rc2/net/ipv6/inet6_hashtables.c 2011-10-24 18:53:33.000000000 +0200
27363 #include <linux/module.h>
27364 #include <linux/random.h>
27365 +#include <linux/vs_inet6.h>
27367 #include <net/inet_connection_sock.h>
27368 #include <net/inet_hashtables.h>
27369 @@ -83,7 +84,6 @@ struct sock *__inet6_lookup_established(
27370 unsigned int slot = hash & hashinfo->ehash_mask;
27371 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
27376 sk_nulls_for_each_rcu(sk, node, &head->chain) {
27377 @@ -95,7 +95,7 @@ begin:
27385 if (get_nulls_value(node) != slot)
27386 @@ -141,6 +141,9 @@ static inline int compute_score(struct s
27387 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
27391 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
27394 if (sk->sk_bound_dev_if) {
27395 if (sk->sk_bound_dev_if != dif)
27396 diff -NurpP --minimal linux-3.1/net/ipv6/ip6_output.c linux-3.1-vs2.3.1-rc2/net/ipv6/ip6_output.c
27397 --- linux-3.1/net/ipv6/ip6_output.c 2011-10-24 18:45:34.000000000 +0200
27398 +++ linux-3.1-vs2.3.1-rc2/net/ipv6/ip6_output.c 2011-10-24 18:53:33.000000000 +0200
27399 @@ -966,7 +966,8 @@ static int ip6_dst_lookup_tail(struct so
27400 struct rt6_info *rt = (struct rt6_info *) *dst;
27401 err = ip6_route_get_saddr(net, rt, &fl6->daddr,
27402 sk ? inet6_sk(sk)->srcprefs : 0,
27405 + sk ? sk->sk_nx_info : NULL);
27407 goto out_err_release;
27409 diff -NurpP --minimal linux-3.1/net/ipv6/ndisc.c linux-3.1-vs2.3.1-rc2/net/ipv6/ndisc.c
27410 --- linux-3.1/net/ipv6/ndisc.c 2011-10-24 18:45:34.000000000 +0200
27411 +++ linux-3.1-vs2.3.1-rc2/net/ipv6/ndisc.c 2011-10-24 18:53:33.000000000 +0200
27412 @@ -591,7 +591,7 @@ static void ndisc_send_na(struct net_dev
27414 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
27415 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
27419 src_addr = &tmpaddr;
27421 diff -NurpP --minimal linux-3.1/net/ipv6/raw.c linux-3.1-vs2.3.1-rc2/net/ipv6/raw.c
27422 --- linux-3.1/net/ipv6/raw.c 2011-10-24 18:45:34.000000000 +0200
27423 +++ linux-3.1-vs2.3.1-rc2/net/ipv6/raw.c 2011-10-24 18:53:33.000000000 +0200
27425 #include <linux/icmpv6.h>
27426 #include <linux/netfilter.h>
27427 #include <linux/netfilter_ipv6.h>
27428 +#include <linux/vs_inet6.h>
27429 #include <linux/skbuff.h>
27430 #include <linux/compat.h>
27431 #include <asm/uaccess.h>
27432 @@ -284,6 +285,13 @@ static int rawv6_bind(struct sock *sk, s
27436 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27437 + err = -EADDRNOTAVAIL;
27443 /* ipv4 addr of the socket is invalid. Only the
27444 * unspecified and mapped address have a v4 equivalent.
27446 diff -NurpP --minimal linux-3.1/net/ipv6/route.c linux-3.1-vs2.3.1-rc2/net/ipv6/route.c
27447 --- linux-3.1/net/ipv6/route.c 2011-10-24 18:45:34.000000000 +0200
27448 +++ linux-3.1-vs2.3.1-rc2/net/ipv6/route.c 2011-10-24 18:53:33.000000000 +0200
27450 #include <net/xfrm.h>
27451 #include <net/netevent.h>
27452 #include <net/netlink.h>
27453 +#include <linux/vs_inet6.h>
27455 #include <asm/uaccess.h>
27457 @@ -2086,15 +2087,17 @@ int ip6_route_get_saddr(struct net *net,
27458 struct rt6_info *rt,
27459 const struct in6_addr *daddr,
27460 unsigned int prefs,
27461 - struct in6_addr *saddr)
27462 + struct in6_addr *saddr,
27463 + struct nx_info *nxi)
27465 struct inet6_dev *idev = ip6_dst_idev((struct dst_entry*)rt);
27467 - if (rt->rt6i_prefsrc.plen)
27468 + if (rt->rt6i_prefsrc.plen && (!nxi ||
27469 + v6_addr_in_nx_info(nxi, &rt->rt6i_prefsrc.addr, NXA_TYPE_ADDR)))
27470 ipv6_addr_copy(saddr, &rt->rt6i_prefsrc.addr);
27472 err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
27473 - daddr, prefs, saddr);
27474 + daddr, prefs, saddr, nxi);
27478 @@ -2424,7 +2427,8 @@ static int rt6_fill_node(struct net *net
27479 NLA_PUT_U32(skb, RTA_IIF, iif);
27481 struct in6_addr saddr_buf;
27482 - if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf) == 0)
27483 + if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf,
27484 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
27485 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
27488 @@ -2627,6 +2631,7 @@ static int rt6_info_route(struct rt6_inf
27489 struct seq_file *m = p_arg;
27490 struct neighbour *n;
27492 + /* FIXME: check for network context? */
27493 seq_printf(m, "%pi6 %02x ", &rt->rt6i_dst.addr, rt->rt6i_dst.plen);
27495 #ifdef CONFIG_IPV6_SUBTREES
27496 diff -NurpP --minimal linux-3.1/net/ipv6/tcp_ipv6.c linux-3.1-vs2.3.1-rc2/net/ipv6/tcp_ipv6.c
27497 --- linux-3.1/net/ipv6/tcp_ipv6.c 2011-10-24 18:45:34.000000000 +0200
27498 +++ linux-3.1-vs2.3.1-rc2/net/ipv6/tcp_ipv6.c 2011-10-24 18:53:33.000000000 +0200
27501 #include <linux/crypto.h>
27502 #include <linux/scatterlist.h>
27503 +#include <linux/vs_inet6.h>
27505 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
27506 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
27507 @@ -162,8 +163,15 @@ static int tcp_v6_connect(struct sock *s
27508 * connect() to INADDR_ANY means loopback (BSD'ism).
27511 - if(ipv6_addr_any(&usin->sin6_addr))
27512 - usin->sin6_addr.s6_addr[15] = 0x1;
27513 + if(ipv6_addr_any(&usin->sin6_addr)) {
27514 + struct nx_info *nxi = sk->sk_nx_info;
27516 + if (nxi && nx_info_has_v6(nxi))
27517 + /* FIXME: remap lback? */
27518 + usin->sin6_addr = nxi->v6.ip;
27520 + usin->sin6_addr.s6_addr[15] = 0x1;
27523 addr_type = ipv6_addr_type(&usin->sin6_addr);
27525 diff -NurpP --minimal linux-3.1/net/ipv6/udp.c linux-3.1-vs2.3.1-rc2/net/ipv6/udp.c
27526 --- linux-3.1/net/ipv6/udp.c 2011-10-24 18:45:34.000000000 +0200
27527 +++ linux-3.1-vs2.3.1-rc2/net/ipv6/udp.c 2011-10-24 18:53:33.000000000 +0200
27528 @@ -45,41 +45,67 @@
27529 #include <net/tcp_states.h>
27530 #include <net/ip6_checksum.h>
27531 #include <net/xfrm.h>
27532 +#include <linux/vs_inet6.h>
27534 #include <linux/proc_fs.h>
27535 #include <linux/seq_file.h>
27536 #include "udp_impl.h"
27538 -int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
27539 +int ipv6_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27541 - const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
27542 + const struct in6_addr *sk1_rcv_saddr6 = &inet6_sk(sk1)->rcv_saddr;
27543 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
27544 - __be32 sk1_rcv_saddr = sk_rcv_saddr(sk);
27545 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1);
27546 __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
27547 - int sk_ipv6only = ipv6_only_sock(sk);
27548 + int sk1_ipv6only = ipv6_only_sock(sk1);
27549 int sk2_ipv6only = inet_v6_ipv6only(sk2);
27550 - int addr_type = ipv6_addr_type(sk_rcv_saddr6);
27551 + int addr_type = ipv6_addr_type(sk1_rcv_saddr6);
27552 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
27554 /* if both are mapped, treat as IPv4 */
27555 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
27556 - return (!sk2_ipv6only &&
27557 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
27558 + if (!sk2_ipv6only &&
27559 (!sk1_rcv_saddr || !sk2_rcv_saddr ||
27560 - sk1_rcv_saddr == sk2_rcv_saddr));
27561 + sk1_rcv_saddr == sk2_rcv_saddr))
27567 if (addr_type2 == IPV6_ADDR_ANY &&
27568 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
27572 if (addr_type == IPV6_ADDR_ANY &&
27573 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
27575 + !(sk1_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
27578 if (sk2_rcv_saddr6 &&
27579 - ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
27581 + ipv6_addr_equal(sk1_rcv_saddr6, sk2_rcv_saddr6))
27587 + if (!sk1_rcv_saddr && !sk2_rcv_saddr)
27588 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
27589 + if (!sk2_rcv_saddr)
27590 + return v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, -1);
27591 + if (!sk1_rcv_saddr)
27592 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, -1);
27595 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
27596 + return nx_v6_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
27597 + else if (addr_type2 == IPV6_ADDR_ANY)
27598 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr6, -1);
27599 + else if (addr_type == IPV6_ADDR_ANY) {
27600 + if (addr_type2 == IPV6_ADDR_MAPPED)
27601 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
27603 + return v6_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr6, -1);
27608 static unsigned int udp6_portaddr_hash(struct net *net,
27609 @@ -143,6 +169,10 @@ static inline int compute_score(struct s
27610 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
27614 + /* block non nx_info ips */
27615 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
27618 if (!ipv6_addr_any(&np->daddr)) {
27619 if (!ipv6_addr_equal(&np->daddr, saddr))
27620 diff -NurpP --minimal linux-3.1/net/ipv6/xfrm6_policy.c linux-3.1-vs2.3.1-rc2/net/ipv6/xfrm6_policy.c
27621 --- linux-3.1/net/ipv6/xfrm6_policy.c 2011-07-22 11:18:13.000000000 +0200
27622 +++ linux-3.1-vs2.3.1-rc2/net/ipv6/xfrm6_policy.c 2011-10-24 18:53:33.000000000 +0200
27623 @@ -63,7 +63,7 @@ static int xfrm6_get_saddr(struct net *n
27624 dev = ip6_dst_idev(dst)->dev;
27625 ipv6_dev_get_saddr(dev_net(dev), dev,
27626 (struct in6_addr *)&daddr->a6, 0,
27627 - (struct in6_addr *)&saddr->a6);
27628 + (struct in6_addr *)&saddr->a6, NULL);
27632 diff -NurpP --minimal linux-3.1/net/netfilter/ipvs/ip_vs_xmit.c linux-3.1-vs2.3.1-rc2/net/netfilter/ipvs/ip_vs_xmit.c
27633 --- linux-3.1/net/netfilter/ipvs/ip_vs_xmit.c 2011-07-22 11:18:13.000000000 +0200
27634 +++ linux-3.1-vs2.3.1-rc2/net/netfilter/ipvs/ip_vs_xmit.c 2011-10-24 18:53:33.000000000 +0200
27635 @@ -226,7 +226,7 @@ __ip_vs_route_output_v6(struct net *net,
27637 if (ipv6_addr_any(&fl6.saddr) &&
27638 ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
27639 - &fl6.daddr, 0, &fl6.saddr) < 0)
27640 + &fl6.daddr, 0, &fl6.saddr, NULL) < 0)
27643 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
27644 diff -NurpP --minimal linux-3.1/net/netlink/af_netlink.c linux-3.1-vs2.3.1-rc2/net/netlink/af_netlink.c
27645 --- linux-3.1/net/netlink/af_netlink.c 2011-10-24 18:45:34.000000000 +0200
27646 +++ linux-3.1-vs2.3.1-rc2/net/netlink/af_netlink.c 2011-10-24 18:53:33.000000000 +0200
27648 #include <linux/types.h>
27649 #include <linux/audit.h>
27650 #include <linux/mutex.h>
27651 +#include <linux/vs_context.h>
27652 +#include <linux/vs_network.h>
27653 +#include <linux/vs_limit.h>
27655 #include <net/net_namespace.h>
27656 #include <net/sock.h>
27657 @@ -1913,6 +1916,8 @@ static struct sock *netlink_seq_socket_i
27658 sk_for_each(s, node, &hash->table[j]) {
27659 if (sock_net(s) != seq_file_net(seq))
27661 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
27665 iter->hash_idx = j;
27666 @@ -1947,7 +1952,8 @@ static void *netlink_seq_next(struct seq
27670 - } while (s && sock_net(s) != seq_file_net(seq));
27671 + } while (s && (sock_net(s) != seq_file_net(seq) ||
27672 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
27676 @@ -1959,7 +1965,8 @@ static void *netlink_seq_next(struct seq
27678 for (; j <= hash->mask; j++) {
27679 s = sk_head(&hash->table[j]);
27680 - while (s && sock_net(s) != seq_file_net(seq))
27681 + while (s && (sock_net(s) != seq_file_net(seq) ||
27682 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
27686 diff -NurpP --minimal linux-3.1/net/socket.c linux-3.1-vs2.3.1-rc2/net/socket.c
27687 --- linux-3.1/net/socket.c 2011-10-24 18:45:34.000000000 +0200
27688 +++ linux-3.1-vs2.3.1-rc2/net/socket.c 2011-10-24 18:53:33.000000000 +0200
27691 #include <net/sock.h>
27692 #include <linux/netfilter.h>
27693 +#include <linux/vs_base.h>
27694 +#include <linux/vs_socket.h>
27695 +#include <linux/vs_inet.h>
27696 +#include <linux/vs_inet6.h>
27698 #include <linux/if_tun.h>
27699 #include <linux/ipv6_route.h>
27700 @@ -546,6 +550,7 @@ static inline int __sock_sendmsg_nosec(s
27701 struct msghdr *msg, size_t size)
27703 struct sock_iocb *si = kiocb_to_siocb(iocb);
27706 sock_update_classid(sock->sk);
27708 @@ -554,7 +559,22 @@ static inline int __sock_sendmsg_nosec(s
27712 - return sock->ops->sendmsg(iocb, sock, msg, size);
27713 + len = sock->ops->sendmsg(iocb, sock, msg, size);
27716 + vx_sock_send(sock->sk, size);
27718 + vx_sock_fail(sock->sk, size);
27720 + vxdprintk(VXD_CBIT(net, 7),
27721 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%zu",
27723 + (sock->sk)?sock->sk->sk_nx_info:0,
27724 + (sock->sk)?sock->sk->sk_vx_info:0,
27725 + (sock->sk)?sock->sk->sk_xid:0,
27726 + (sock->sk)?sock->sk->sk_nid:0,
27727 + (unsigned int)size, len);
27731 static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock,
27732 @@ -694,6 +714,7 @@ static inline int __sock_recvmsg_nosec(s
27733 struct msghdr *msg, size_t size, int flags)
27735 struct sock_iocb *si = kiocb_to_siocb(iocb);
27738 sock_update_classid(sock->sk);
27740 @@ -703,7 +724,18 @@ static inline int __sock_recvmsg_nosec(s
27744 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
27745 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
27746 + if ((len >= 0) && sock->sk)
27747 + vx_sock_recv(sock->sk, len);
27748 + vxdprintk(VXD_CBIT(net, 7),
27749 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
27751 + (sock->sk)?sock->sk->sk_nx_info:0,
27752 + (sock->sk)?sock->sk->sk_vx_info:0,
27753 + (sock->sk)?sock->sk->sk_xid:0,
27754 + (sock->sk)?sock->sk->sk_nid:0,
27755 + (unsigned int)size, len);
27759 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
27760 @@ -1188,6 +1220,13 @@ int __sock_create(struct net *net, int f
27761 if (type < 0 || type >= SOCK_MAX)
27764 + if (!nx_check(0, VS_ADMIN)) {
27765 + if (family == PF_INET && !current_nx_info_has_v4())
27766 + return -EAFNOSUPPORT;
27767 + if (family == PF_INET6 && !current_nx_info_has_v6())
27768 + return -EAFNOSUPPORT;
27773 This uglymoron is moved from INET layer to here to avoid
27774 @@ -1323,6 +1362,7 @@ SYSCALL_DEFINE3(socket, int, family, int
27778 + set_bit(SOCK_USER_SOCKET, &sock->flags);
27779 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
27782 @@ -1364,10 +1404,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
27783 err = sock_create(family, type, protocol, &sock1);
27786 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
27788 err = sock_create(family, type, protocol, &sock2);
27790 goto out_release_1;
27791 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
27793 err = sock1->ops->socketpair(sock1, sock2);
27795 diff -NurpP --minimal linux-3.1/net/sunrpc/auth.c linux-3.1-vs2.3.1-rc2/net/sunrpc/auth.c
27796 --- linux-3.1/net/sunrpc/auth.c 2011-10-24 18:45:34.000000000 +0200
27797 +++ linux-3.1-vs2.3.1-rc2/net/sunrpc/auth.c 2011-10-24 18:53:33.000000000 +0200
27799 #include <linux/hash.h>
27800 #include <linux/sunrpc/clnt.h>
27801 #include <linux/spinlock.h>
27802 +#include <linux/vs_tag.h>
27805 # define RPCDBG_FACILITY RPCDBG_AUTH
27806 @@ -427,6 +428,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
27807 memset(&acred, 0, sizeof(acred));
27808 acred.uid = cred->fsuid;
27809 acred.gid = cred->fsgid;
27810 + acred.tag = dx_current_tag();
27811 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
27813 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
27814 @@ -467,6 +469,7 @@ rpcauth_bind_root_cred(struct rpc_task *
27815 struct auth_cred acred = {
27818 + .tag = dx_current_tag(),
27821 dprintk("RPC: %5u looking up %s cred\n",
27822 diff -NurpP --minimal linux-3.1/net/sunrpc/auth_unix.c linux-3.1-vs2.3.1-rc2/net/sunrpc/auth_unix.c
27823 --- linux-3.1/net/sunrpc/auth_unix.c 2010-10-21 13:08:01.000000000 +0200
27824 +++ linux-3.1-vs2.3.1-rc2/net/sunrpc/auth_unix.c 2011-10-24 18:53:33.000000000 +0200
27825 @@ -12,12 +12,14 @@
27826 #include <linux/module.h>
27827 #include <linux/sunrpc/clnt.h>
27828 #include <linux/sunrpc/auth.h>
27829 +#include <linux/vs_tag.h>
27831 #define NFS_NGROUPS 16
27834 struct rpc_cred uc_base;
27837 gid_t uc_gids[NFS_NGROUPS];
27839 #define uc_uid uc_base.cr_uid
27840 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
27841 groups = NFS_NGROUPS;
27843 cred->uc_gid = acred->gid;
27844 + cred->uc_tag = acred->tag;
27845 for (i = 0; i < groups; i++)
27846 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
27847 if (i < NFS_NGROUPS)
27848 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
27852 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
27853 + if (cred->uc_uid != acred->uid ||
27854 + cred->uc_gid != acred->gid ||
27855 + cred->uc_tag != acred->tag)
27858 if (acred->group_info != NULL)
27859 @@ -142,7 +147,7 @@ unx_marshal(struct rpc_task *task, __be3
27860 struct rpc_clnt *clnt = task->tk_client;
27861 struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base);
27862 __be32 *base, *hold;
27866 *p++ = htonl(RPC_AUTH_UNIX);
27868 @@ -152,9 +157,12 @@ unx_marshal(struct rpc_task *task, __be3
27869 * Copy the UTS nodename captured when the client was created.
27871 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
27872 + tag = task->tk_client->cl_tag;
27874 - *p++ = htonl((u32) cred->uc_uid);
27875 - *p++ = htonl((u32) cred->uc_gid);
27876 + *p++ = htonl((u32) TAGINO_UID(tag,
27877 + cred->uc_uid, cred->uc_tag));
27878 + *p++ = htonl((u32) TAGINO_GID(tag,
27879 + cred->uc_gid, cred->uc_tag));
27881 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
27882 *p++ = htonl((u32) cred->uc_gids[i]);
27883 diff -NurpP --minimal linux-3.1/net/sunrpc/clnt.c linux-3.1-vs2.3.1-rc2/net/sunrpc/clnt.c
27884 --- linux-3.1/net/sunrpc/clnt.c 2011-10-24 18:45:34.000000000 +0200
27885 +++ linux-3.1-vs2.3.1-rc2/net/sunrpc/clnt.c 2011-10-24 18:53:33.000000000 +0200
27887 #include <linux/in.h>
27888 #include <linux/in6.h>
27889 #include <linux/un.h>
27890 +#include <linux/vs_cvirt.h>
27892 #include <linux/sunrpc/clnt.h>
27893 #include <linux/sunrpc/rpc_pipe_fs.h>
27894 @@ -361,6 +362,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
27895 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
27896 clnt->cl_chatty = 1;
27898 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
27899 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
27900 + clnt->cl_tag = 1; */
27903 EXPORT_SYMBOL_GPL(rpc_create);
27904 diff -NurpP --minimal linux-3.1/net/unix/af_unix.c linux-3.1-vs2.3.1-rc2/net/unix/af_unix.c
27905 --- linux-3.1/net/unix/af_unix.c 2011-10-24 18:45:34.000000000 +0200
27906 +++ linux-3.1-vs2.3.1-rc2/net/unix/af_unix.c 2011-10-24 18:53:33.000000000 +0200
27907 @@ -114,6 +114,8 @@
27908 #include <linux/mount.h>
27909 #include <net/checksum.h>
27910 #include <linux/security.h>
27911 +#include <linux/vs_context.h>
27912 +#include <linux/vs_limit.h>
27914 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
27915 static DEFINE_SPINLOCK(unix_table_lock);
27916 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
27917 if (!net_eq(sock_net(s), net))
27920 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
27922 if (u->addr->len == len &&
27923 !memcmp(u->addr->name, sunname, len))
27925 @@ -2204,6 +2208,8 @@ static struct sock *unix_seq_idx(struct
27926 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
27927 if (sock_net(s) != seq_file_net(seq))
27929 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
27934 @@ -2228,7 +2234,8 @@ static void *unix_seq_next(struct seq_fi
27935 sk = first_unix_socket(&iter->i);
27937 sk = next_unix_socket(&iter->i, sk);
27938 - while (sk && (sock_net(sk) != seq_file_net(seq)))
27939 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
27940 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
27941 sk = next_unix_socket(&iter->i, sk);
27944 diff -NurpP --minimal linux-3.1/scripts/checksyscalls.sh linux-3.1-vs2.3.1-rc2/scripts/checksyscalls.sh
27945 --- linux-3.1/scripts/checksyscalls.sh 2011-03-15 18:07:46.000000000 +0100
27946 +++ linux-3.1-vs2.3.1-rc2/scripts/checksyscalls.sh 2011-10-24 18:53:33.000000000 +0200
27947 @@ -193,7 +193,6 @@ cat << EOF
27948 #define __IGNORE_afs_syscall
27949 #define __IGNORE_getpmsg
27950 #define __IGNORE_putpmsg
27951 -#define __IGNORE_vserver
27955 diff -NurpP --minimal linux-3.1/security/commoncap.c linux-3.1-vs2.3.1-rc2/security/commoncap.c
27956 --- linux-3.1/security/commoncap.c 2011-07-22 11:18:14.000000000 +0200
27957 +++ linux-3.1-vs2.3.1-rc2/security/commoncap.c 2011-10-24 18:53:33.000000000 +0200
27958 @@ -62,6 +62,7 @@ int cap_netlink_recv(struct sk_buff *skb
27963 EXPORT_SYMBOL(cap_netlink_recv);
27966 @@ -83,14 +84,20 @@ EXPORT_SYMBOL(cap_netlink_recv);
27967 int cap_capable(struct task_struct *tsk, const struct cred *cred,
27968 struct user_namespace *targ_ns, int cap, int audit)
27970 + struct vx_info *vxi = tsk->vx_info;
27973 /* The creator of the user namespace has all caps. */
27974 if (targ_ns != &init_user_ns && targ_ns->creator == cred->user)
27977 /* Do we have the necessary capabilities? */
27978 - if (targ_ns == cred->user->user_ns)
27979 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
27980 + if (targ_ns == cred->user->user_ns) {
27981 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
27982 + cap_raised(cred->cap_effective, cap))
27984 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
27987 /* Have we tried all of the parent namespaces? */
27988 if (targ_ns == &init_user_ns)
27989 @@ -611,7 +618,7 @@ int cap_inode_setxattr(struct dentry *de
27991 if (!strncmp(name, XATTR_SECURITY_PREFIX,
27992 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
27993 - !capable(CAP_SYS_ADMIN))
27994 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
27998 @@ -637,7 +644,7 @@ int cap_inode_removexattr(struct dentry
28000 if (!strncmp(name, XATTR_SECURITY_PREFIX,
28001 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
28002 - !capable(CAP_SYS_ADMIN))
28003 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
28007 diff -NurpP --minimal linux-3.1/security/selinux/hooks.c linux-3.1-vs2.3.1-rc2/security/selinux/hooks.c
28008 --- linux-3.1/security/selinux/hooks.c 2011-10-24 18:45:35.000000000 +0200
28009 +++ linux-3.1-vs2.3.1-rc2/security/selinux/hooks.c 2011-10-24 18:53:33.000000000 +0200
28011 #include <linux/dccp.h>
28012 #include <linux/quota.h>
28013 #include <linux/un.h> /* for Unix socket types */
28014 -#include <net/af_unix.h> /* for Unix socket types */
28015 #include <linux/parser.h>
28016 #include <linux/nfs_mount.h>
28017 #include <net/ipv6.h>