1 diff -NurpP --minimal linux-3.0/.config.inet linux-3.0-vs2.3.1-pre7/.config.inet
2 --- linux-3.0/.config.inet 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-3.0-vs2.3.1-pre7/.config.inet 2011-06-13 14:55:18.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.0/Documentation/vserver/debug.txt linux-3.0-vs2.3.1-pre7/Documentation/vserver/debug.txt
1626 --- linux-3.0/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
1627 +++ linux-3.0-vs2.3.1-pre7/Documentation/vserver/debug.txt 2011-06-10 22:11:24.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.0/arch/alpha/Kconfig linux-3.0-vs2.3.1-pre7/arch/alpha/Kconfig
1784 --- linux-3.0/arch/alpha/Kconfig 2011-07-22 11:17:32.000000000 +0200
1785 +++ linux-3.0-vs2.3.1-pre7/arch/alpha/Kconfig 2011-06-10 22:11:24.000000000 +0200
1786 @@ -668,6 +668,8 @@ config DUMMY_CONSOLE
1790 +source "kernel/vserver/Kconfig"
1792 source "security/Kconfig"
1794 source "crypto/Kconfig"
1795 diff -NurpP --minimal linux-3.0/arch/alpha/kernel/entry.S linux-3.0-vs2.3.1-pre7/arch/alpha/kernel/entry.S
1796 --- linux-3.0/arch/alpha/kernel/entry.S 2010-10-21 13:06:45.000000000 +0200
1797 +++ linux-3.0-vs2.3.1-pre7/arch/alpha/kernel/entry.S 2011-06-10 22:11:24.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.0/arch/alpha/kernel/ptrace.c linux-3.0-vs2.3.1-pre7/arch/alpha/kernel/ptrace.c
1831 --- linux-3.0/arch/alpha/kernel/ptrace.c 2011-01-05 21:48:40.000000000 +0100
1832 +++ linux-3.0-vs2.3.1-pre7/arch/alpha/kernel/ptrace.c 2011-06-10 22:11:24.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.0/arch/alpha/kernel/systbls.S linux-3.0-vs2.3.1-pre7/arch/alpha/kernel/systbls.S
1842 --- linux-3.0/arch/alpha/kernel/systbls.S 2011-07-22 11:17:32.000000000 +0200
1843 +++ linux-3.0-vs2.3.1-pre7/arch/alpha/kernel/systbls.S 2011-06-10 22:11:24.000000000 +0200
1844 @@ -446,7 +446,7 @@ sys_call_table:
1845 .quad sys_stat64 /* 425 */
1848 - .quad sys_ni_syscall /* sys_vserver */
1849 + .quad sys_vserver /* sys_vserver */
1850 .quad sys_ni_syscall /* sys_mbind */
1851 .quad sys_ni_syscall /* sys_get_mempolicy */
1852 .quad sys_ni_syscall /* sys_set_mempolicy */
1853 diff -NurpP --minimal linux-3.0/arch/alpha/kernel/traps.c linux-3.0-vs2.3.1-pre7/arch/alpha/kernel/traps.c
1854 --- linux-3.0/arch/alpha/kernel/traps.c 2010-10-21 13:06:46.000000000 +0200
1855 +++ linux-3.0-vs2.3.1-pre7/arch/alpha/kernel/traps.c 2011-06-10 22:11:24.000000000 +0200
1856 @@ -183,7 +183,8 @@ die_if_kernel(char * str, struct pt_regs
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.0/arch/arm/Kconfig linux-3.0-vs2.3.1-pre7/arch/arm/Kconfig
1867 --- linux-3.0/arch/arm/Kconfig 2011-07-22 11:17:32.000000000 +0200
1868 +++ linux-3.0-vs2.3.1-pre7/arch/arm/Kconfig 2011-06-10 22:11:24.000000000 +0200
1869 @@ -2035,6 +2035,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.0/arch/arm/kernel/calls.S linux-3.0-vs2.3.1-pre7/arch/arm/kernel/calls.S
1879 --- linux-3.0/arch/arm/kernel/calls.S 2011-07-22 11:17:32.000000000 +0200
1880 +++ linux-3.0-vs2.3.1-pre7/arch/arm/kernel/calls.S 2011-06-10 22:11:24.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.0/arch/arm/kernel/process.c linux-3.0-vs2.3.1-pre7/arch/arm/kernel/process.c
1891 --- linux-3.0/arch/arm/kernel/process.c 2011-05-22 16:16:47.000000000 +0200
1892 +++ linux-3.0-vs2.3.1-pre7/arch/arm/kernel/process.c 2011-06-10 22:11:24.000000000 +0200
1893 @@ -315,7 +315,8 @@ void __show_regs(struct pt_regs *regs)
1894 void show_regs(struct pt_regs * regs)
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.0/arch/arm/kernel/traps.c linux-3.0-vs2.3.1-pre7/arch/arm/kernel/traps.c
1904 --- linux-3.0/arch/arm/kernel/traps.c 2011-07-22 11:17:32.000000000 +0200
1905 +++ linux-3.0-vs2.3.1-pre7/arch/arm/kernel/traps.c 2011-06-22 12:39:12.000000000 +0200
1906 @@ -242,8 +242,8 @@ static int __die(const char *str, int er
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.0/arch/cris/Kconfig linux-3.0-vs2.3.1-pre7/arch/cris/Kconfig
1918 --- linux-3.0/arch/cris/Kconfig 2011-07-22 11:17:35.000000000 +0200
1919 +++ linux-3.0-vs2.3.1-pre7/arch/cris/Kconfig 2011-06-10 22:11:24.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.0/arch/frv/kernel/kernel_thread.S linux-3.0-vs2.3.1-pre7/arch/frv/kernel/kernel_thread.S
1930 --- linux-3.0/arch/frv/kernel/kernel_thread.S 2008-12-25 00:26:37.000000000 +0100
1931 +++ linux-3.0-vs2.3.1-pre7/arch/frv/kernel/kernel_thread.S 2011-06-10 22:11:24.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.0/arch/h8300/Kconfig linux-3.0-vs2.3.1-pre7/arch/h8300/Kconfig
1942 --- linux-3.0/arch/h8300/Kconfig 2011-07-22 11:17:35.000000000 +0200
1943 +++ linux-3.0-vs2.3.1-pre7/arch/h8300/Kconfig 2011-06-10 22:11:24.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.0/arch/ia64/Kconfig linux-3.0-vs2.3.1-pre7/arch/ia64/Kconfig
1954 --- linux-3.0/arch/ia64/Kconfig 2011-07-22 11:17:35.000000000 +0200
1955 +++ linux-3.0-vs2.3.1-pre7/arch/ia64/Kconfig 2011-06-10 22:11:24.000000000 +0200
1956 @@ -671,6 +671,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.0/arch/ia64/include/asm/tlb.h linux-3.0-vs2.3.1-pre7/arch/ia64/include/asm/tlb.h
1966 --- linux-3.0/arch/ia64/include/asm/tlb.h 2011-07-22 11:17:35.000000000 +0200
1967 +++ linux-3.0-vs2.3.1-pre7/arch/ia64/include/asm/tlb.h 2011-06-10 22:11:24.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.0/arch/ia64/kernel/entry.S linux-3.0-vs2.3.1-pre7/arch/ia64/kernel/entry.S
1977 --- linux-3.0/arch/ia64/kernel/entry.S 2011-07-22 11:17:35.000000000 +0200
1978 +++ linux-3.0-vs2.3.1-pre7/arch/ia64/kernel/entry.S 2011-06-10 22:11:24.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.0/arch/ia64/kernel/perfmon.c linux-3.0-vs2.3.1-pre7/arch/ia64/kernel/perfmon.c
1989 --- linux-3.0/arch/ia64/kernel/perfmon.c 2011-03-15 18:06:39.000000000 +0100
1990 +++ linux-3.0-vs2.3.1-pre7/arch/ia64/kernel/perfmon.c 2011-06-10 22:11:24.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.0/arch/ia64/kernel/process.c linux-3.0-vs2.3.1-pre7/arch/ia64/kernel/process.c
2000 --- linux-3.0/arch/ia64/kernel/process.c 2011-03-15 18:06:39.000000000 +0100
2001 +++ linux-3.0-vs2.3.1-pre7/arch/ia64/kernel/process.c 2011-06-10 22:11:24.000000000 +0200
2002 @@ -109,8 +109,8 @@ show_regs (struct pt_regs *regs)
2003 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
2006 - printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
2007 - smp_processor_id(), current->comm);
2008 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
2009 + current->xid, smp_processor_id(), current->comm);
2010 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s (%s)\n",
2011 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
2012 init_utsname()->release);
2013 diff -NurpP --minimal linux-3.0/arch/ia64/kernel/ptrace.c linux-3.0-vs2.3.1-pre7/arch/ia64/kernel/ptrace.c
2014 --- linux-3.0/arch/ia64/kernel/ptrace.c 2011-01-05 21:48:59.000000000 +0100
2015 +++ linux-3.0-vs2.3.1-pre7/arch/ia64/kernel/ptrace.c 2011-06-10 22:11:24.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.0/arch/ia64/kernel/traps.c linux-3.0-vs2.3.1-pre7/arch/ia64/kernel/traps.c
2025 --- linux-3.0/arch/ia64/kernel/traps.c 2010-07-07 18:31:01.000000000 +0200
2026 +++ linux-3.0-vs2.3.1-pre7/arch/ia64/kernel/traps.c 2011-06-10 22:11:24.000000000 +0200
2027 @@ -59,8 +59,9 @@ die (const char *str, struct pt_regs *re
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.0/arch/ia64/mm/fault.c linux-3.0-vs2.3.1-pre7/arch/ia64/mm/fault.c
2052 --- linux-3.0/arch/ia64/mm/fault.c 2011-07-22 11:17:35.000000000 +0200
2053 +++ linux-3.0-vs2.3.1-pre7/arch/ia64/mm/fault.c 2011-06-10 22:28:23.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.0/arch/m32r/kernel/traps.c linux-3.0-vs2.3.1-pre7/arch/m32r/kernel/traps.c
2063 --- linux-3.0/arch/m32r/kernel/traps.c 2009-12-03 20:01:57.000000000 +0100
2064 +++ linux-3.0-vs2.3.1-pre7/arch/m32r/kernel/traps.c 2011-06-10 22:11:24.000000000 +0200
2065 @@ -196,8 +196,9 @@ static void show_registers(struct pt_reg
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.0/arch/m68k/Kconfig linux-3.0-vs2.3.1-pre7/arch/m68k/Kconfig
2078 --- linux-3.0/arch/m68k/Kconfig 2011-07-22 11:17:35.000000000 +0200
2079 +++ linux-3.0-vs2.3.1-pre7/arch/m68k/Kconfig 2011-06-10 22:11:24.000000000 +0200
2080 @@ -241,6 +241,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.0/arch/mips/Kconfig linux-3.0-vs2.3.1-pre7/arch/mips/Kconfig
2090 --- linux-3.0/arch/mips/Kconfig 2011-07-22 11:17:35.000000000 +0200
2091 +++ linux-3.0-vs2.3.1-pre7/arch/mips/Kconfig 2011-06-10 22:11:24.000000000 +0200
2092 @@ -2485,6 +2485,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.0/arch/mips/kernel/ptrace.c linux-3.0-vs2.3.1-pre7/arch/mips/kernel/ptrace.c
2102 --- linux-3.0/arch/mips/kernel/ptrace.c 2011-07-22 11:17:36.000000000 +0200
2103 +++ linux-3.0-vs2.3.1-pre7/arch/mips/kernel/ptrace.c 2011-06-10 22:11:24.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.0/arch/mips/kernel/scall32-o32.S linux-3.0-vs2.3.1-pre7/arch/mips/kernel/scall32-o32.S
2123 --- linux-3.0/arch/mips/kernel/scall32-o32.S 2011-07-22 11:17:36.000000000 +0200
2124 +++ linux-3.0-vs2.3.1-pre7/arch/mips/kernel/scall32-o32.S 2011-06-10 22:11:24.000000000 +0200
2125 @@ -523,7 +523,7 @@ einval: li v0, -ENOSYS
2126 sys sys_mq_timedreceive 5
2127 sys sys_mq_notify 2 /* 4275 */
2128 sys sys_mq_getsetattr 3
2129 - sys sys_ni_syscall 0 /* sys_vserver */
2132 sys sys_ni_syscall 0 /* available, was setaltroot */
2133 sys sys_add_key 5 /* 4280 */
2134 diff -NurpP --minimal linux-3.0/arch/mips/kernel/scall64-64.S linux-3.0-vs2.3.1-pre7/arch/mips/kernel/scall64-64.S
2135 --- linux-3.0/arch/mips/kernel/scall64-64.S 2011-07-22 11:17:36.000000000 +0200
2136 +++ linux-3.0-vs2.3.1-pre7/arch/mips/kernel/scall64-64.S 2011-06-10 22:11:24.000000000 +0200
2137 @@ -362,7 +362,7 @@ sys_call_table:
2138 PTR sys_mq_timedreceive
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.0/arch/mips/kernel/scall64-n32.S linux-3.0-vs2.3.1-pre7/arch/mips/kernel/scall64-n32.S
2147 --- linux-3.0/arch/mips/kernel/scall64-n32.S 2011-07-22 11:17:36.000000000 +0200
2148 +++ linux-3.0-vs2.3.1-pre7/arch/mips/kernel/scall64-n32.S 2011-06-10 22:11:24.000000000 +0200
2149 @@ -361,7 +361,7 @@ EXPORT(sysn32_call_table)
2150 PTR compat_sys_mq_timedreceive
2151 PTR compat_sys_mq_notify
2152 PTR compat_sys_mq_getsetattr
2153 - PTR sys_ni_syscall /* 6240, sys_vserver */
2154 + PTR sys32_vserver /* 6240 */
2155 PTR compat_sys_waitid
2156 PTR sys_ni_syscall /* available, was setaltroot */
2158 diff -NurpP --minimal linux-3.0/arch/mips/kernel/scall64-o32.S linux-3.0-vs2.3.1-pre7/arch/mips/kernel/scall64-o32.S
2159 --- linux-3.0/arch/mips/kernel/scall64-o32.S 2011-07-22 11:17:36.000000000 +0200
2160 +++ linux-3.0-vs2.3.1-pre7/arch/mips/kernel/scall64-o32.S 2011-06-10 22:11:24.000000000 +0200
2161 @@ -480,7 +480,7 @@ sys_call_table:
2162 PTR compat_sys_mq_timedreceive
2163 PTR compat_sys_mq_notify /* 4275 */
2164 PTR compat_sys_mq_getsetattr
2165 - PTR sys_ni_syscall /* sys_vserver */
2168 PTR sys_ni_syscall /* available, was setaltroot */
2169 PTR sys_add_key /* 4280 */
2170 diff -NurpP --minimal linux-3.0/arch/mips/kernel/traps.c linux-3.0-vs2.3.1-pre7/arch/mips/kernel/traps.c
2171 --- linux-3.0/arch/mips/kernel/traps.c 2011-05-22 16:17:00.000000000 +0200
2172 +++ linux-3.0-vs2.3.1-pre7/arch/mips/kernel/traps.c 2011-06-10 22:11:24.000000000 +0200
2173 @@ -343,9 +343,10 @@ void show_registers(struct pt_regs *regs
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.0/arch/parisc/Kconfig linux-3.0-vs2.3.1-pre7/arch/parisc/Kconfig
2188 --- linux-3.0/arch/parisc/Kconfig 2011-07-22 11:17:36.000000000 +0200
2189 +++ linux-3.0-vs2.3.1-pre7/arch/parisc/Kconfig 2011-06-10 22:11:24.000000000 +0200
2190 @@ -279,6 +279,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.0/arch/parisc/kernel/syscall_table.S linux-3.0-vs2.3.1-pre7/arch/parisc/kernel/syscall_table.S
2200 --- linux-3.0/arch/parisc/kernel/syscall_table.S 2011-07-22 11:17:36.000000000 +0200
2201 +++ linux-3.0-vs2.3.1-pre7/arch/parisc/kernel/syscall_table.S 2011-06-10 22:11:24.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.0/arch/parisc/kernel/traps.c linux-3.0-vs2.3.1-pre7/arch/parisc/kernel/traps.c
2212 --- linux-3.0/arch/parisc/kernel/traps.c 2009-09-10 15:25:40.000000000 +0200
2213 +++ linux-3.0-vs2.3.1-pre7/arch/parisc/kernel/traps.c 2011-06-10 22:11:24.000000000 +0200
2214 @@ -236,8 +236,9 @@ void die_if_kernel(char *str, struct pt_
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.0/arch/parisc/mm/fault.c linux-3.0-vs2.3.1-pre7/arch/parisc/mm/fault.c
2238 --- linux-3.0/arch/parisc/mm/fault.c 2010-08-02 16:52:06.000000000 +0200
2239 +++ linux-3.0-vs2.3.1-pre7/arch/parisc/mm/fault.c 2011-06-10 22:11:24.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.0/arch/powerpc/Kconfig linux-3.0-vs2.3.1-pre7/arch/powerpc/Kconfig
2253 --- linux-3.0/arch/powerpc/Kconfig 2011-07-22 11:17:36.000000000 +0200
2254 +++ linux-3.0-vs2.3.1-pre7/arch/powerpc/Kconfig 2011-06-10 22:11:24.000000000 +0200
2255 @@ -978,6 +978,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.0/arch/powerpc/include/asm/unistd.h linux-3.0-vs2.3.1-pre7/arch/powerpc/include/asm/unistd.h
2265 --- linux-3.0/arch/powerpc/include/asm/unistd.h 2011-07-22 11:17:40.000000000 +0200
2266 +++ linux-3.0-vs2.3.1-pre7/arch/powerpc/include/asm/unistd.h 2011-06-10 22:11:24.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.0/arch/powerpc/kernel/process.c linux-3.0-vs2.3.1-pre7/arch/powerpc/kernel/process.c
2277 --- linux-3.0/arch/powerpc/kernel/process.c 2011-07-22 11:17:40.000000000 +0200
2278 +++ linux-3.0-vs2.3.1-pre7/arch/powerpc/kernel/process.c 2011-06-10 22:11:24.000000000 +0200
2279 @@ -656,8 +656,9 @@ void show_regs(struct pt_regs * regs)
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.0/arch/powerpc/kernel/traps.c linux-3.0-vs2.3.1-pre7/arch/powerpc/kernel/traps.c
2292 --- linux-3.0/arch/powerpc/kernel/traps.c 2011-07-22 11:17:40.000000000 +0200
2293 +++ linux-3.0-vs2.3.1-pre7/arch/powerpc/kernel/traps.c 2011-07-19 00:44:39.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.0/arch/powerpc/kernel/vdso.c linux-3.0-vs2.3.1-pre7/arch/powerpc/kernel/vdso.c
2307 --- linux-3.0/arch/powerpc/kernel/vdso.c 2011-05-22 16:17:02.000000000 +0200
2308 +++ linux-3.0-vs2.3.1-pre7/arch/powerpc/kernel/vdso.c 2011-06-10 22:11:24.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.0/arch/s390/Kconfig linux-3.0-vs2.3.1-pre7/arch/s390/Kconfig
2318 --- linux-3.0/arch/s390/Kconfig 2011-07-22 11:17:41.000000000 +0200
2319 +++ linux-3.0-vs2.3.1-pre7/arch/s390/Kconfig 2011-07-01 11:35:34.000000000 +0200
2320 @@ -628,6 +628,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.0/arch/s390/include/asm/tlb.h linux-3.0-vs2.3.1-pre7/arch/s390/include/asm/tlb.h
2330 --- linux-3.0/arch/s390/include/asm/tlb.h 2011-07-22 11:17:41.000000000 +0200
2331 +++ linux-3.0-vs2.3.1-pre7/arch/s390/include/asm/tlb.h 2011-06-15 02:40:14.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.0/arch/s390/include/asm/unistd.h linux-3.0-vs2.3.1-pre7/arch/s390/include/asm/unistd.h
2342 --- linux-3.0/arch/s390/include/asm/unistd.h 2011-07-22 11:17:41.000000000 +0200
2343 +++ linux-3.0-vs2.3.1-pre7/arch/s390/include/asm/unistd.h 2011-06-10 22:11:24.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.0/arch/s390/kernel/ptrace.c linux-3.0-vs2.3.1-pre7/arch/s390/kernel/ptrace.c
2354 --- linux-3.0/arch/s390/kernel/ptrace.c 2011-03-15 18:06:45.000000000 +0100
2355 +++ linux-3.0-vs2.3.1-pre7/arch/s390/kernel/ptrace.c 2011-06-10 22:11:24.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.0/arch/s390/kernel/syscalls.S linux-3.0-vs2.3.1-pre7/arch/s390/kernel/syscalls.S
2365 --- linux-3.0/arch/s390/kernel/syscalls.S 2011-07-22 11:17:41.000000000 +0200
2366 +++ linux-3.0-vs2.3.1-pre7/arch/s390/kernel/syscalls.S 2011-06-10 22:11:24.000000000 +0200
2367 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
2368 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
2369 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
2370 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
2371 -NI_SYSCALL /* reserved for vserver */
2372 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
2373 SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
2374 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
2375 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
2376 diff -NurpP --minimal linux-3.0/arch/sh/Kconfig linux-3.0-vs2.3.1-pre7/arch/sh/Kconfig
2377 --- linux-3.0/arch/sh/Kconfig 2011-07-22 11:17:41.000000000 +0200
2378 +++ linux-3.0-vs2.3.1-pre7/arch/sh/Kconfig 2011-07-19 00:44:39.000000000 +0200
2379 @@ -893,6 +893,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.0/arch/sh/kernel/irq.c linux-3.0-vs2.3.1-pre7/arch/sh/kernel/irq.c
2389 --- linux-3.0/arch/sh/kernel/irq.c 2011-07-22 11:17:41.000000000 +0200
2390 +++ linux-3.0-vs2.3.1-pre7/arch/sh/kernel/irq.c 2011-07-19 00:45:06.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.0/arch/sh/kernel/vsyscall/vsyscall.c linux-3.0-vs2.3.1-pre7/arch/sh/kernel/vsyscall/vsyscall.c
2400 --- linux-3.0/arch/sh/kernel/vsyscall/vsyscall.c 2011-05-22 16:17:07.000000000 +0200
2401 +++ linux-3.0-vs2.3.1-pre7/arch/sh/kernel/vsyscall/vsyscall.c 2011-06-10 22:11:24.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.0/arch/sparc/Kconfig linux-3.0-vs2.3.1-pre7/arch/sparc/Kconfig
2411 --- linux-3.0/arch/sparc/Kconfig 2011-07-22 11:17:41.000000000 +0200
2412 +++ linux-3.0-vs2.3.1-pre7/arch/sparc/Kconfig 2011-06-15 02:40:14.000000000 +0200
2413 @@ -601,6 +601,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.0/arch/sparc/include/asm/tlb_64.h linux-3.0-vs2.3.1-pre7/arch/sparc/include/asm/tlb_64.h
2423 --- linux-3.0/arch/sparc/include/asm/tlb_64.h 2011-07-22 11:17:42.000000000 +0200
2424 +++ linux-3.0-vs2.3.1-pre7/arch/sparc/include/asm/tlb_64.h 2011-06-10 22:11:24.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.0/arch/sparc/include/asm/unistd.h linux-3.0-vs2.3.1-pre7/arch/sparc/include/asm/unistd.h
2434 --- linux-3.0/arch/sparc/include/asm/unistd.h 2011-07-22 11:17:42.000000000 +0200
2435 +++ linux-3.0-vs2.3.1-pre7/arch/sparc/include/asm/unistd.h 2011-06-10 22:11:24.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.0/arch/sparc/kernel/systbls_32.S linux-3.0-vs2.3.1-pre7/arch/sparc/kernel/systbls_32.S
2446 --- linux-3.0/arch/sparc/kernel/systbls_32.S 2011-07-22 11:17:42.000000000 +0200
2447 +++ linux-3.0-vs2.3.1-pre7/arch/sparc/kernel/systbls_32.S 2011-06-10 22:11:24.000000000 +0200
2448 @@ -70,7 +70,7 @@ sys_call_table:
2449 /*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
2450 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
2451 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
2452 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
2453 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
2454 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
2455 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
2456 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
2457 diff -NurpP --minimal linux-3.0/arch/sparc/kernel/systbls_64.S linux-3.0-vs2.3.1-pre7/arch/sparc/kernel/systbls_64.S
2458 --- linux-3.0/arch/sparc/kernel/systbls_64.S 2011-07-22 11:17:42.000000000 +0200
2459 +++ linux-3.0-vs2.3.1-pre7/arch/sparc/kernel/systbls_64.S 2011-06-10 22:11:24.000000000 +0200
2460 @@ -71,7 +71,7 @@ sys_call_table32:
2461 /*250*/ .word sys_mremap, compat_sys_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
2462 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
2463 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
2464 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
2465 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
2466 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
2467 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
2468 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
2469 @@ -148,7 +148,7 @@ sys_call_table:
2470 /*250*/ .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
2471 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
2472 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
2473 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
2474 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
2475 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
2476 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
2477 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
2478 diff -NurpP --minimal linux-3.0/arch/um/Kconfig.rest linux-3.0-vs2.3.1-pre7/arch/um/Kconfig.rest
2479 --- linux-3.0/arch/um/Kconfig.rest 2009-06-11 17:12:19.000000000 +0200
2480 +++ linux-3.0-vs2.3.1-pre7/arch/um/Kconfig.rest 2011-06-10 22:11:24.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.0/arch/um/include/asm/tlb.h linux-3.0-vs2.3.1-pre7/arch/um/include/asm/tlb.h
2491 --- linux-3.0/arch/um/include/asm/tlb.h 2011-07-22 11:17:42.000000000 +0200
2492 +++ linux-3.0-vs2.3.1-pre7/arch/um/include/asm/tlb.h 2011-06-10 22:11:24.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.0/arch/um/include/shared/kern_constants.h linux-3.0-vs2.3.1-pre7/arch/um/include/shared/kern_constants.h
2502 --- linux-3.0/arch/um/include/shared/kern_constants.h 1970-01-01 01:00:00.000000000 +0100
2503 +++ linux-3.0-vs2.3.1-pre7/arch/um/include/shared/kern_constants.h 2011-06-10 22:11:24.000000000 +0200
2505 +#include "../../../../include/generated/asm-offsets.h"
2506 diff -NurpP --minimal linux-3.0/arch/um/include/shared/user_constants.h linux-3.0-vs2.3.1-pre7/arch/um/include/shared/user_constants.h
2507 --- linux-3.0/arch/um/include/shared/user_constants.h 1970-01-01 01:00:00.000000000 +0100
2508 +++ linux-3.0-vs2.3.1-pre7/arch/um/include/shared/user_constants.h 2011-06-10 22:11:24.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.0/arch/x86/Kconfig linux-3.0-vs2.3.1-pre7/arch/x86/Kconfig
2551 --- linux-3.0/arch/x86/Kconfig 2011-07-22 11:17:42.000000000 +0200
2552 +++ linux-3.0-vs2.3.1-pre7/arch/x86/Kconfig 2011-07-22 11:20:39.000000000 +0200
2553 @@ -2159,6 +2159,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.0/arch/x86/ia32/ia32entry.S linux-3.0-vs2.3.1-pre7/arch/x86/ia32/ia32entry.S
2563 --- linux-3.0/arch/x86/ia32/ia32entry.S 2011-07-22 11:17:42.000000000 +0200
2564 +++ linux-3.0-vs2.3.1-pre7/arch/x86/ia32/ia32entry.S 2011-06-10 22:11:24.000000000 +0200
2565 @@ -776,7 +776,7 @@ ia32_sys_call_table:
2566 .quad sys_tgkill /* 270 */
2567 .quad compat_sys_utimes
2568 .quad sys32_fadvise64_64
2569 - .quad quiet_ni_syscall /* sys_vserver */
2570 + .quad sys32_vserver
2572 .quad compat_sys_get_mempolicy /* 275 */
2573 .quad sys_set_mempolicy
2574 diff -NurpP --minimal linux-3.0/arch/x86/include/asm/unistd_64.h linux-3.0-vs2.3.1-pre7/arch/x86/include/asm/unistd_64.h
2575 --- linux-3.0/arch/x86/include/asm/unistd_64.h 2011-07-22 11:17:43.000000000 +0200
2576 +++ linux-3.0-vs2.3.1-pre7/arch/x86/include/asm/unistd_64.h 2011-06-10 22:11:24.000000000 +0200
2577 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
2578 #define __NR_utimes 235
2579 __SYSCALL(__NR_utimes, sys_utimes)
2580 #define __NR_vserver 236
2581 -__SYSCALL(__NR_vserver, sys_ni_syscall)
2582 +__SYSCALL(__NR_vserver, sys_vserver)
2583 #define __NR_mbind 237
2584 __SYSCALL(__NR_mbind, sys_mbind)
2585 #define __NR_set_mempolicy 238
2586 diff -NurpP --minimal linux-3.0/arch/x86/kernel/syscall_table_32.S linux-3.0-vs2.3.1-pre7/arch/x86/kernel/syscall_table_32.S
2587 --- linux-3.0/arch/x86/kernel/syscall_table_32.S 2011-07-22 11:17:43.000000000 +0200
2588 +++ linux-3.0-vs2.3.1-pre7/arch/x86/kernel/syscall_table_32.S 2011-06-10 22:11:24.000000000 +0200
2589 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
2590 .long sys_tgkill /* 270 */
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.0/block/genhd.c linux-3.0-vs2.3.1-pre7/block/genhd.c
2599 --- linux-3.0/block/genhd.c 2011-07-22 11:17:43.000000000 +0200
2600 +++ linux-3.0-vs2.3.1-pre7/block/genhd.c 2011-07-01 11:35:34.000000000 +0200
2601 @@ -1154,17 +1154,17 @@ static int diskstats_show(struct seq_fil
2602 cpu = part_stat_lock();
2603 part_round_stats(cpu, hd);
2605 - seq_printf(seqf, "%4d %7d %s %lu %lu %llu "
2606 - "%u %lu %lu %llu %u %u %u %u\n",
2607 + seq_printf(seqf, "%4d %7d %s %lu %lu %lu "
2608 + "%u %lu %lu %lu %u %u %u %u\n",
2609 MAJOR(part_devt(hd)), MINOR(part_devt(hd)),
2610 disk_name(gp, hd->partno, buf),
2611 part_stat_read(hd, ios[READ]),
2612 part_stat_read(hd, merges[READ]),
2613 - (unsigned long long)part_stat_read(hd, sectors[READ]),
2614 + part_stat_read(hd, sectors[READ]),
2615 jiffies_to_msecs(part_stat_read(hd, ticks[READ])),
2616 part_stat_read(hd, ios[WRITE]),
2617 part_stat_read(hd, merges[WRITE]),
2618 - (unsigned long long)part_stat_read(hd, sectors[WRITE]),
2619 + part_stat_read(hd, sectors[WRITE]),
2620 jiffies_to_msecs(part_stat_read(hd, ticks[WRITE])),
2622 jiffies_to_msecs(part_stat_read(hd, io_ticks)),
2623 diff -NurpP --minimal linux-3.0/drivers/block/Kconfig linux-3.0-vs2.3.1-pre7/drivers/block/Kconfig
2624 --- linux-3.0/drivers/block/Kconfig 2011-07-22 11:17:44.000000000 +0200
2625 +++ linux-3.0-vs2.3.1-pre7/drivers/block/Kconfig 2011-06-10 22:11:24.000000000 +0200
2626 @@ -273,6 +273,13 @@ config BLK_DEV_CRYPTOLOOP
2628 source "drivers/block/drbd/Kconfig"
2630 +config BLK_DEV_VROOT
2631 + tristate "Virtual Root device support"
2632 + depends on QUOTACTL
2634 + Saying Y here will allow you to use quota/fs ioctls on a shared
2635 + partition within a virtual server without compromising security.
2638 tristate "Network block device support"
2640 diff -NurpP --minimal linux-3.0/drivers/block/Makefile linux-3.0-vs2.3.1-pre7/drivers/block/Makefile
2641 --- linux-3.0/drivers/block/Makefile 2011-07-22 11:17:44.000000000 +0200
2642 +++ linux-3.0-vs2.3.1-pre7/drivers/block/Makefile 2011-06-10 22:11:24.000000000 +0200
2643 @@ -34,6 +34,7 @@ obj-$(CONFIG_VIODASD) += viodasd.o
2644 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
2645 obj-$(CONFIG_BLK_DEV_UB) += ub.o
2646 obj-$(CONFIG_BLK_DEV_HD) += hd.o
2647 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
2649 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
2650 obj-$(CONFIG_XEN_BLKDEV_BACKEND) += xen-blkback/
2651 diff -NurpP --minimal linux-3.0/drivers/block/loop.c linux-3.0-vs2.3.1-pre7/drivers/block/loop.c
2652 --- linux-3.0/drivers/block/loop.c 2011-07-22 11:17:44.000000000 +0200
2653 +++ linux-3.0-vs2.3.1-pre7/drivers/block/loop.c 2011-06-10 22:11:24.000000000 +0200
2655 #include <linux/kthread.h>
2656 #include <linux/splice.h>
2657 #include <linux/sysfs.h>
2658 +#include <linux/vs_context.h>
2660 #include <asm/uaccess.h>
2662 @@ -891,6 +892,7 @@ static int loop_set_fd(struct loop_devic
2663 lo->lo_blocksize = lo_blocksize;
2664 lo->lo_device = bdev;
2665 lo->lo_flags = lo_flags;
2666 + lo->lo_xid = vx_current_xid();
2667 lo->lo_backing_file = file;
2668 lo->transfer = transfer_none;
2670 @@ -1019,6 +1021,7 @@ static int loop_clr_fd(struct loop_devic
2671 lo->lo_encrypt_key_size = 0;
2673 lo->lo_thread = NULL;
2675 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
2676 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
2677 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
2678 @@ -1057,7 +1060,7 @@ loop_set_status(struct loop_device *lo,
2680 if (lo->lo_encrypt_key_size &&
2681 lo->lo_key_owner != uid &&
2682 - !capable(CAP_SYS_ADMIN))
2683 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
2685 if (lo->lo_state != Lo_bound)
2687 @@ -1141,7 +1144,8 @@ loop_get_status(struct loop_device *lo,
2688 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
2689 info->lo_encrypt_type =
2690 lo->lo_encryption ? lo->lo_encryption->number : 0;
2691 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
2692 + if (lo->lo_encrypt_key_size &&
2693 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
2694 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
2695 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
2696 lo->lo_encrypt_key_size);
2697 @@ -1487,6 +1491,9 @@ static int lo_open(struct block_device *
2699 struct loop_device *lo = bdev->bd_disk->private_data;
2701 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P))
2704 mutex_lock(&lo->lo_ctl_mutex);
2706 mutex_unlock(&lo->lo_ctl_mutex);
2707 diff -NurpP --minimal linux-3.0/drivers/block/vroot.c linux-3.0-vs2.3.1-pre7/drivers/block/vroot.c
2708 --- linux-3.0/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
2709 +++ linux-3.0-vs2.3.1-pre7/drivers/block/vroot.c 2011-06-10 22:11:24.000000000 +0200
2712 + * linux/drivers/block/vroot.c
2714 + * written by Herbert Pötzl, 9/11/2002
2715 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
2717 + * based on the loop.c code by Theodore Ts'o.
2719 + * Copyright (C) 2002-2007 by Herbert Pötzl.
2720 + * Redistribution of this file is permitted under the
2721 + * GNU General Public License.
2725 +#include <linux/module.h>
2726 +#include <linux/moduleparam.h>
2727 +#include <linux/file.h>
2728 +#include <linux/major.h>
2729 +#include <linux/blkdev.h>
2730 +#include <linux/slab.h>
2732 +#include <linux/vroot.h>
2733 +#include <linux/vs_context.h>
2736 +static int max_vroot = 8;
2738 +static struct vroot_device *vroot_dev;
2739 +static struct gendisk **disks;
2742 +static int vroot_set_dev(
2743 + struct vroot_device *vr,
2744 + struct block_device *bdev,
2747 + struct block_device *real_bdev;
2748 + struct file *file;
2749 + struct inode *inode;
2753 + if (vr->vr_state != Vr_unbound)
2762 + inode = file->f_dentry->d_inode;
2765 + if (S_ISBLK(inode->i_mode)) {
2766 + real_bdev = inode->i_bdev;
2767 + vr->vr_device = real_bdev;
2768 + __iget(real_bdev->bd_inode);
2772 + vxdprintk(VXD_CBIT(misc, 0),
2773 + "vroot[%d]_set_dev: dev=" VXF_DEV,
2774 + vr->vr_number, VXD_DEV(real_bdev));
2776 + vr->vr_state = Vr_bound;
2785 +static int vroot_clr_dev(
2786 + struct vroot_device *vr,
2787 + struct block_device *bdev)
2789 + struct block_device *real_bdev;
2791 + if (vr->vr_state != Vr_bound)
2793 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
2796 + real_bdev = vr->vr_device;
2798 + vxdprintk(VXD_CBIT(misc, 0),
2799 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
2800 + vr->vr_number, VXD_DEV(real_bdev));
2803 + vr->vr_state = Vr_unbound;
2804 + vr->vr_device = NULL;
2809 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
2810 + unsigned int cmd, unsigned long arg)
2812 + struct vroot_device *vr = bdev->bd_disk->private_data;
2815 + down(&vr->vr_ctl_mutex);
2817 + case VROOT_SET_DEV:
2818 + err = vroot_set_dev(vr, bdev, arg);
2820 + case VROOT_CLR_DEV:
2821 + err = vroot_clr_dev(vr, bdev);
2827 + up(&vr->vr_ctl_mutex);
2831 +static int vr_open(struct block_device *bdev, fmode_t mode)
2833 + struct vroot_device *vr = bdev->bd_disk->private_data;
2835 + down(&vr->vr_ctl_mutex);
2837 + up(&vr->vr_ctl_mutex);
2841 +static int vr_release(struct gendisk *disk, fmode_t mode)
2843 + struct vroot_device *vr = disk->private_data;
2845 + down(&vr->vr_ctl_mutex);
2847 + up(&vr->vr_ctl_mutex);
2851 +static struct block_device_operations vr_fops = {
2852 + .owner = THIS_MODULE,
2854 + .release = vr_release,
2855 + .ioctl = vr_ioctl,
2858 +static int vroot_make_request(struct request_queue *q, struct bio *bio)
2860 + printk("vroot_make_request %p, %p\n", q, bio);
2861 + bio_io_error(bio);
2865 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
2867 + struct inode *inode = bdev->bd_inode;
2868 + struct vroot_device *vr;
2869 + struct block_device *real_bdev;
2870 + int minor = iminor(inode);
2872 + vr = &vroot_dev[minor];
2873 + real_bdev = vr->vr_device;
2875 + vxdprintk(VXD_CBIT(misc, 0),
2876 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
2877 + vr->vr_number, VXD_DEV(real_bdev));
2879 + if (vr->vr_state != Vr_bound)
2880 + return ERR_PTR(-ENXIO);
2882 + __iget(real_bdev->bd_inode);
2889 + * And now the modules code and kernel interface.
2892 +module_param(max_vroot, int, 0);
2894 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
2895 +MODULE_LICENSE("GPL");
2896 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
2898 +MODULE_AUTHOR ("Herbert Pötzl");
2899 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
2902 +int __init vroot_init(void)
2906 + if (max_vroot < 1 || max_vroot > 256) {
2907 + max_vroot = MAX_VROOT_DEFAULT;
2908 + printk(KERN_WARNING "vroot: invalid max_vroot "
2909 + "(must be between 1 and 256), "
2910 + "using default (%d)\n", max_vroot);
2913 + if (register_blkdev(VROOT_MAJOR, "vroot"))
2917 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
2920 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
2922 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
2926 + for (i = 0; i < max_vroot; i++) {
2927 + disks[i] = alloc_disk(1);
2930 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
2931 + if (!disks[i]->queue)
2933 + blk_queue_make_request(disks[i]->queue, vroot_make_request);
2936 + for (i = 0; i < max_vroot; i++) {
2937 + struct vroot_device *vr = &vroot_dev[i];
2938 + struct gendisk *disk = disks[i];
2940 + memset(vr, 0, sizeof(*vr));
2941 + sema_init(&vr->vr_ctl_mutex, 1);
2942 + vr->vr_number = i;
2943 + disk->major = VROOT_MAJOR;
2944 + disk->first_minor = i;
2945 + disk->fops = &vr_fops;
2946 + sprintf(disk->disk_name, "vroot%d", i);
2947 + disk->private_data = vr;
2950 + err = register_vroot_grb(&__vroot_get_real_bdev);
2954 + for (i = 0; i < max_vroot; i++)
2955 + add_disk(disks[i]);
2956 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
2961 + put_disk(disks[i]);
2966 + unregister_blkdev(VROOT_MAJOR, "vroot");
2967 + printk(KERN_ERR "vroot: ran out of memory\n");
2971 +void vroot_exit(void)
2975 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
2976 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
2978 + for (i = 0; i < max_vroot; i++) {
2979 + del_gendisk(disks[i]);
2980 + put_disk(disks[i]);
2982 + unregister_blkdev(VROOT_MAJOR, "vroot");
2988 +module_init(vroot_init);
2989 +module_exit(vroot_exit);
2993 +static int __init max_vroot_setup(char *str)
2995 + max_vroot = simple_strtol(str, NULL, 0);
2999 +__setup("max_vroot=", max_vroot_setup);
3003 diff -NurpP --minimal linux-3.0/drivers/gpu/drm/radeon/r100_reg_safe.h linux-3.0-vs2.3.1-pre7/drivers/gpu/drm/radeon/r100_reg_safe.h
3004 --- linux-3.0/drivers/gpu/drm/radeon/r100_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
3005 +++ linux-3.0-vs2.3.1-pre7/drivers/gpu/drm/radeon/r100_reg_safe.h 2011-06-10 22:11:24.000000000 +0200
3007 +static const unsigned r100_reg_safe_bm[102] = {
3008 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3009 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3010 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3011 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3012 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3013 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3014 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3015 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3016 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3017 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3018 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3019 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3020 + 0xFFFFFFCF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3021 + 0xFFFFFF9F, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3022 + 0x38E7FE1F, 0xFFC3FF8E, 0x7FF8FFFF, 0xFFFF803C,
3023 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3024 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFEFFFF, 0xFFFFFFFF,
3025 + 0x00000000, 0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFF,
3026 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3027 + 0xFFFFFFFF, 0xFFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3028 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3029 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3030 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3031 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3032 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3033 + 0xFFFFFFFF, 0xFFFFFFEF,
3035 diff -NurpP --minimal linux-3.0/drivers/gpu/drm/radeon/r200_reg_safe.h linux-3.0-vs2.3.1-pre7/drivers/gpu/drm/radeon/r200_reg_safe.h
3036 --- linux-3.0/drivers/gpu/drm/radeon/r200_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
3037 +++ linux-3.0-vs2.3.1-pre7/drivers/gpu/drm/radeon/r200_reg_safe.h 2011-06-10 22:11:24.000000000 +0200
3039 +static const unsigned r200_reg_safe_bm[102] = {
3040 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3041 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3042 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3043 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3044 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3045 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3046 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3047 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3048 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3049 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3050 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3051 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3052 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3053 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3054 + 0xFFE7FE1F, 0xF003FFFF, 0x7EFFFFFF, 0xFFFF803C,
3055 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3056 + 0xFFFFFFFF, 0xFFFFEFCE, 0xFFFEFFFF, 0xFFFFFFFE,
3057 + 0x020E0FF0, 0xFFCC83FD, 0xFFFFFFFF, 0xFFFFFFFF,
3058 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3059 + 0xFFFBFFFF, 0xEFFCFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3060 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3061 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3062 + 0xDFDFDFDF, 0x3FFDDFDF, 0xFFFFFFFF, 0xFFFFFF7F,
3063 + 0xFFFFFFFF, 0x00FFFFFF, 0x00000000, 0x00000000,
3064 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3065 + 0xFFFFFE3F, 0xFFFFFFEF,
3067 diff -NurpP --minimal linux-3.0/drivers/gpu/drm/radeon/r300_reg_safe.h linux-3.0-vs2.3.1-pre7/drivers/gpu/drm/radeon/r300_reg_safe.h
3068 --- linux-3.0/drivers/gpu/drm/radeon/r300_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
3069 +++ linux-3.0-vs2.3.1-pre7/drivers/gpu/drm/radeon/r300_reg_safe.h 2011-06-10 22:11:24.000000000 +0200
3071 +static const unsigned r300_reg_safe_bm[159] = {
3072 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3073 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3074 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3075 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3076 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3077 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3078 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3079 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3080 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3081 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3082 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3083 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3084 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3085 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3086 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
3087 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3088 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
3089 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
3090 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3091 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3092 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3093 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3094 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3095 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3096 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3097 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3098 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3099 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3100 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3101 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3102 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3103 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3104 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
3105 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
3106 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3107 + 0x00000000, 0x0000C100, 0x00000000, 0x00000000,
3108 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3109 + 0x00000000, 0xFFFF0000, 0xFFFFFFFF, 0xFF80FFFF,
3110 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3111 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
3113 diff -NurpP --minimal linux-3.0/drivers/gpu/drm/radeon/r420_reg_safe.h linux-3.0-vs2.3.1-pre7/drivers/gpu/drm/radeon/r420_reg_safe.h
3114 --- linux-3.0/drivers/gpu/drm/radeon/r420_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
3115 +++ linux-3.0-vs2.3.1-pre7/drivers/gpu/drm/radeon/r420_reg_safe.h 2011-06-10 22:11:24.000000000 +0200
3117 +static const unsigned r420_reg_safe_bm[159] = {
3118 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3119 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3120 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3121 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3122 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3123 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3124 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3125 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3126 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3127 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3128 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3129 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3130 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3131 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3132 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
3133 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3134 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
3135 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
3136 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3137 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3138 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3139 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3140 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3141 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3142 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3143 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3144 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3145 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3146 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3147 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3148 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3149 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3150 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
3151 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
3152 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3153 + 0x00000000, 0x00000100, 0x00000000, 0x00000000,
3154 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3155 + 0x00000000, 0x00000000, 0x00000000, 0xFF800000,
3156 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3157 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19,
3159 diff -NurpP --minimal linux-3.0/drivers/gpu/drm/radeon/rn50_reg_safe.h linux-3.0-vs2.3.1-pre7/drivers/gpu/drm/radeon/rn50_reg_safe.h
3160 --- linux-3.0/drivers/gpu/drm/radeon/rn50_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
3161 +++ linux-3.0-vs2.3.1-pre7/drivers/gpu/drm/radeon/rn50_reg_safe.h 2011-06-10 22:11:24.000000000 +0200
3163 +static const unsigned rn50_reg_safe_bm[102] = {
3164 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3165 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3166 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3167 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3168 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3169 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3170 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3171 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3172 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3173 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3174 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3175 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3176 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3177 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3178 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3179 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3180 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3181 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3182 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3183 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3184 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3185 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3186 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3187 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3188 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3189 + 0xFFFFFFFF, 0xFFFFFFFF,
3191 diff -NurpP --minimal linux-3.0/drivers/gpu/drm/radeon/rs600_reg_safe.h linux-3.0-vs2.3.1-pre7/drivers/gpu/drm/radeon/rs600_reg_safe.h
3192 --- linux-3.0/drivers/gpu/drm/radeon/rs600_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
3193 +++ linux-3.0-vs2.3.1-pre7/drivers/gpu/drm/radeon/rs600_reg_safe.h 2011-06-10 22:11:24.000000000 +0200
3195 +static const unsigned rs600_reg_safe_bm[219] = {
3196 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3197 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3198 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3199 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3200 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3201 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3202 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3203 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3204 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3205 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3206 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3207 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3208 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3209 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3210 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
3211 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3212 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
3213 + 0xF0000078, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
3214 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3215 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3216 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3217 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3218 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3219 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3220 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3221 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3222 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3223 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3224 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3225 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3226 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3227 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3228 + 0xFFFFFC78, 0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFF,
3229 + 0x38FF8F50, 0xFFF88082, 0xF000000C, 0xFAE009FF,
3230 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3231 + 0x00000000, 0x00000100, 0x00000000, 0x00000000,
3232 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3233 + 0x00000000, 0x00000000, 0x00000000, 0xFF800000,
3234 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3235 + 0x0003FC01, 0xFFFFFCF8, 0xFF800B19, 0xFFFFFFFF,
3236 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3237 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3238 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3239 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3240 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3241 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3242 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3243 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3244 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3245 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3246 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3247 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3248 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3249 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3250 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3252 diff -NurpP --minimal linux-3.0/drivers/gpu/drm/radeon/rv515_reg_safe.h linux-3.0-vs2.3.1-pre7/drivers/gpu/drm/radeon/rv515_reg_safe.h
3253 --- linux-3.0/drivers/gpu/drm/radeon/rv515_reg_safe.h 1970-01-01 01:00:00.000000000 +0100
3254 +++ linux-3.0-vs2.3.1-pre7/drivers/gpu/drm/radeon/rv515_reg_safe.h 2011-06-10 22:11:24.000000000 +0200
3256 +static const unsigned rv515_reg_safe_bm[219] = {
3257 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3258 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3259 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3260 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3261 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3262 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3263 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3264 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3265 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3266 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3267 + 0x17FF1FFF, 0xFFFFFFFC, 0xFFFFFFFF, 0xFF30FFBF,
3268 + 0xFFFFFFF8, 0xC3E6FFFF, 0xFFFFF6DF, 0xFFFFFFFF,
3269 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3270 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3271 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFF03F,
3272 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3273 + 0xFFFFFFFF, 0xFFFFEFCE, 0xF00EBFFF, 0x007C0000,
3274 + 0xF0000038, 0xFF000009, 0xFFFFFFFF, 0xFFFFFFFF,
3275 + 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0xFFFFFFFF,
3276 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3277 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3278 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3279 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3280 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3281 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3282 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3283 + 0xFFFFF7FF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3284 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3285 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3286 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3287 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3288 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3289 + 0x1FFFF878, 0xFFFFE000, 0xFFFFFE1E, 0xFFFFFFFF,
3290 + 0x388F8F50, 0xFFF88082, 0xFF0000FC, 0xFAE009FF,
3291 + 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000,
3292 + 0xFFFF8CFC, 0xFFFFC1FF, 0xFFFFFFFF, 0xFFFFFFFF,
3293 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3294 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFF80FFFF,
3295 + 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3296 + 0x0003FC01, 0x3FFFFCF8, 0xFF800B19, 0xFFDFFFFF,
3297 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3298 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3299 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3300 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3301 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3302 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3303 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3304 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3305 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3306 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3307 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3308 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3309 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3310 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3311 + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
3313 diff -NurpP --minimal linux-3.0/drivers/infiniband/core/addr.c linux-3.0-vs2.3.1-pre7/drivers/infiniband/core/addr.c
3314 --- linux-3.0/drivers/infiniband/core/addr.c 2011-07-22 11:17:45.000000000 +0200
3315 +++ linux-3.0-vs2.3.1-pre7/drivers/infiniband/core/addr.c 2011-06-16 14:16:51.000000000 +0200
3316 @@ -252,7 +252,7 @@ static int addr6_resolve(struct sockaddr
3318 if (ipv6_addr_any(&fl6.saddr)) {
3319 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
3320 - &fl6.daddr, 0, &fl6.saddr);
3321 + &fl6.daddr, 0, &fl6.saddr, NULL);
3325 diff -NurpP --minimal linux-3.0/drivers/infiniband/hw/ipath/ipath_user_pages.c linux-3.0-vs2.3.1-pre7/drivers/infiniband/hw/ipath/ipath_user_pages.c
3326 --- linux-3.0/drivers/infiniband/hw/ipath/ipath_user_pages.c 2011-05-22 16:17:16.000000000 +0200
3327 +++ linux-3.0-vs2.3.1-pre7/drivers/infiniband/hw/ipath/ipath_user_pages.c 2011-06-10 22:11:24.000000000 +0200
3329 #include <linux/device.h>
3330 #include <linux/slab.h>
3331 #include <linux/sched.h>
3332 +#include <linux/vs_memory.h>
3334 #include "ipath_kernel.h"
3336 diff -NurpP --minimal linux-3.0/drivers/md/dm-ioctl.c linux-3.0-vs2.3.1-pre7/drivers/md/dm-ioctl.c
3337 --- linux-3.0/drivers/md/dm-ioctl.c 2011-05-22 16:17:18.000000000 +0200
3338 +++ linux-3.0-vs2.3.1-pre7/drivers/md/dm-ioctl.c 2011-06-10 22:11:24.000000000 +0200
3340 #include <linux/dm-ioctl.h>
3341 #include <linux/hdreg.h>
3342 #include <linux/compat.h>
3343 +#include <linux/vs_context.h>
3345 #include <asm/uaccess.h>
3347 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
3348 unsigned int h = hash_str(str);
3350 list_for_each_entry (hc, _name_buckets + h, name_list)
3351 - if (!strcmp(hc->name, str)) {
3352 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
3353 + !strcmp(hc->name, str)) {
3357 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
3358 unsigned int h = hash_str(str);
3360 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
3361 - if (!strcmp(hc->uuid, str)) {
3362 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
3363 + !strcmp(hc->uuid, str)) {
3367 @@ -427,6 +430,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
3369 static int remove_all(struct dm_ioctl *param, size_t param_size)
3371 + if (!vx_check(0, VS_ADMIN))
3374 dm_hash_remove_all(1);
3375 param->data_size = 0;
3377 @@ -474,6 +480,8 @@ static int list_devices(struct dm_ioctl
3379 for (i = 0; i < NUM_BUCKETS; i++) {
3380 list_for_each_entry (hc, _name_buckets + i, name_list) {
3381 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
3383 needed += sizeof(struct dm_name_list);
3384 needed += strlen(hc->name) + 1;
3385 needed += ALIGN_MASK;
3386 @@ -497,6 +505,8 @@ static int list_devices(struct dm_ioctl
3388 for (i = 0; i < NUM_BUCKETS; i++) {
3389 list_for_each_entry (hc, _name_buckets + i, name_list) {
3390 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
3393 old_nl->next = (uint32_t) ((void *) nl -
3395 @@ -731,10 +741,11 @@ static struct hash_cell *__find_device_h
3399 - mdptr = dm_get_mdptr(md);
3400 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
3401 + mdptr = dm_get_mdptr(md);
3409 @@ -1577,8 +1588,8 @@ static int ctl_ioctl(uint command, struc
3411 size_t input_param_size;
3413 - /* only root can play with this */
3414 - if (!capable(CAP_SYS_ADMIN))
3415 + /* only root and certain contexts can play with this */
3416 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
3419 if (_IOC_TYPE(command) != DM_IOCTL)
3420 diff -NurpP --minimal linux-3.0/drivers/md/dm.c linux-3.0-vs2.3.1-pre7/drivers/md/dm.c
3421 --- linux-3.0/drivers/md/dm.c 2011-05-22 16:17:18.000000000 +0200
3422 +++ linux-3.0-vs2.3.1-pre7/drivers/md/dm.c 2011-06-10 22:11:24.000000000 +0200
3424 #include <linux/idr.h>
3425 #include <linux/hdreg.h>
3426 #include <linux/delay.h>
3427 +#include <linux/vs_base.h>
3429 #include <trace/events/block.h>
3431 @@ -119,6 +120,7 @@ struct mapped_device {
3434 atomic_t open_count;
3437 unsigned long flags;
3439 @@ -326,6 +328,7 @@ int dm_deleting_md(struct mapped_device
3440 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
3442 struct mapped_device *md;
3445 spin_lock(&_minor_lock);
3447 @@ -334,18 +337,19 @@ static int dm_blk_open(struct block_devi
3450 if (test_bit(DMF_FREEING, &md->flags) ||
3451 - dm_deleting_md(md)) {
3453 + dm_deleting_md(md))
3457 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
3462 atomic_inc(&md->open_count);
3466 spin_unlock(&_minor_lock);
3468 - return md ? 0 : -ENXIO;
3472 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
3473 @@ -566,6 +570,14 @@ int dm_set_geometry(struct mapped_device
3478 + * Get the xid associated with a dm device
3480 +xid_t dm_get_xid(struct mapped_device *md)
3485 /*-----------------------------------------------------------------
3487 * A more elegant soln is in the works that uses the queue
3488 @@ -1841,6 +1853,7 @@ static struct mapped_device *alloc_dev(i
3489 INIT_LIST_HEAD(&md->uevent_list);
3490 spin_lock_init(&md->uevent_lock);
3492 + md->xid = vx_current_xid();
3493 md->queue = blk_alloc_queue(GFP_KERNEL);
3496 diff -NurpP --minimal linux-3.0/drivers/md/dm.h linux-3.0-vs2.3.1-pre7/drivers/md/dm.h
3497 --- linux-3.0/drivers/md/dm.h 2011-05-22 16:17:18.000000000 +0200
3498 +++ linux-3.0-vs2.3.1-pre7/drivers/md/dm.h 2011-06-10 22:11:24.000000000 +0200
3499 @@ -41,6 +41,8 @@ struct dm_dev_internal {
3501 struct dm_md_mempools;
3503 +xid_t dm_get_xid(struct mapped_device *md);
3505 /*-----------------------------------------------------------------
3506 * Internal table functions.
3507 *---------------------------------------------------------------*/
3508 diff -NurpP --minimal linux-3.0/drivers/net/tun.c linux-3.0-vs2.3.1-pre7/drivers/net/tun.c
3509 --- linux-3.0/drivers/net/tun.c 2011-07-22 11:17:54.000000000 +0200
3510 +++ linux-3.0-vs2.3.1-pre7/drivers/net/tun.c 2011-06-22 12:39:14.000000000 +0200
3512 #include <linux/nsproxy.h>
3513 #include <linux/virtio_net.h>
3514 #include <linux/rcupdate.h>
3515 +#include <linux/vs_network.h>
3516 #include <net/net_namespace.h>
3517 #include <net/netns/generic.h>
3518 #include <net/rtnetlink.h>
3519 @@ -121,6 +122,7 @@ struct tun_struct {
3525 struct net_device *dev;
3527 @@ -904,6 +906,7 @@ static void tun_setup(struct net_device
3531 + tun->nid = current->nid;
3533 dev->ethtool_ops = &tun_ethtool_ops;
3534 dev->destructor = tun_free_netdev;
3535 @@ -1054,7 +1057,7 @@ static int tun_set_iff(struct net *net,
3537 if (((tun->owner != -1 && cred->euid != tun->owner) ||
3538 (tun->group != -1 && !in_egroup_p(tun->group))) &&
3539 - !capable(CAP_NET_ADMIN))
3540 + !cap_raised(current_cap(), CAP_NET_ADMIN))
3542 err = security_tun_dev_attach(tun->socket.sk);
3544 @@ -1068,7 +1071,7 @@ static int tun_set_iff(struct net *net,
3546 unsigned long flags = 0;
3548 - if (!capable(CAP_NET_ADMIN))
3549 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
3551 err = security_tun_dev_create();
3553 @@ -1136,6 +1139,9 @@ static int tun_set_iff(struct net *net,
3555 sk->sk_destruct = tun_sock_destruct;
3557 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
3560 err = tun_attach(tun, file);
3563 @@ -1317,6 +1323,16 @@ static long __tun_chr_ioctl(struct file
3564 tun_debug(KERN_INFO, tun, "group set to %d\n", tun->group);
3568 + if (!capable(CAP_CONTEXT))
3571 + /* Set nid owner of the device */
3572 + tun->nid = (nid_t) arg;
3574 + tun_debug(KERN_INFO, tun, "nid owner set to %u\n", tun->nid);
3578 /* Only allow setting the type when the interface is down */
3579 if (tun->dev->flags & IFF_UP) {
3580 diff -NurpP --minimal linux-3.0/drivers/tty/sysrq.c linux-3.0-vs2.3.1-pre7/drivers/tty/sysrq.c
3581 --- linux-3.0/drivers/tty/sysrq.c 2011-05-22 16:17:44.000000000 +0200
3582 +++ linux-3.0-vs2.3.1-pre7/drivers/tty/sysrq.c 2011-06-10 22:11:24.000000000 +0200
3584 #include <linux/oom.h>
3585 #include <linux/slab.h>
3586 #include <linux/input.h>
3587 +#include <linux/vserver/debug.h>
3589 #include <asm/ptrace.h>
3590 #include <asm/irq_regs.h>
3591 @@ -395,6 +396,21 @@ static struct sysrq_key_op sysrq_unrt_op
3592 .enable_mask = SYSRQ_ENABLE_RTNICE,
3596 +#ifdef CONFIG_VSERVER_DEBUG
3597 +static void sysrq_handle_vxinfo(int key)
3599 + dump_vx_info_inactive((key == 'x') ? 0 : 1);
3602 +static struct sysrq_key_op sysrq_showvxinfo_op = {
3603 + .handler = sysrq_handle_vxinfo,
3604 + .help_msg = "conteXt",
3605 + .action_msg = "Show Context Info",
3606 + .enable_mask = SYSRQ_ENABLE_DUMP,
3610 /* Key Operations table and lock */
3611 static DEFINE_SPINLOCK(sysrq_key_table_lock);
3613 @@ -449,7 +465,11 @@ static struct sysrq_key_op *sysrq_key_ta
3615 &sysrq_showstate_blocked_op, /* w */
3616 /* x: May be registered on ppc/powerpc for xmon */
3617 +#ifdef CONFIG_VSERVER_DEBUG
3618 + &sysrq_showvxinfo_op, /* x */
3622 /* y: May be registered on sparc64 for global register dump */
3624 &sysrq_ftrace_dump_op, /* z */
3625 @@ -464,6 +484,8 @@ static int sysrq_key_table_key2index(int
3627 else if ((key >= 'a') && (key <= 'z'))
3628 retval = key + 10 - 'a';
3629 + else if ((key >= 'A') && (key <= 'Z'))
3630 + retval = key + 10 - 'A';
3634 diff -NurpP --minimal linux-3.0/drivers/tty/tty_io.c linux-3.0-vs2.3.1-pre7/drivers/tty/tty_io.c
3635 --- linux-3.0/drivers/tty/tty_io.c 2011-07-22 11:18:03.000000000 +0200
3636 +++ linux-3.0-vs2.3.1-pre7/drivers/tty/tty_io.c 2011-06-10 22:11:24.000000000 +0200
3639 #include <linux/kmod.h>
3640 #include <linux/nsproxy.h>
3641 +#include <linux/vs_pid.h>
3643 #undef TTY_DEBUG_HANGUP
3645 @@ -2057,7 +2058,8 @@ static int tiocsti(struct tty_struct *tt
3647 struct tty_ldisc *ld;
3649 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
3650 + if (((current->signal->tty != tty) &&
3651 + !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
3653 if (get_user(ch, p))
3655 @@ -2345,6 +2347,7 @@ static int tiocspgrp(struct tty_struct *
3657 if (get_user(pgrp_nr, p))
3659 + pgrp_nr = vx_rmap_pid(pgrp_nr);
3663 diff -NurpP --minimal linux-3.0/fs/attr.c linux-3.0-vs2.3.1-pre7/fs/attr.c
3664 --- linux-3.0/fs/attr.c 2011-07-22 11:18:05.000000000 +0200
3665 +++ linux-3.0-vs2.3.1-pre7/fs/attr.c 2011-06-10 22:11:24.000000000 +0200
3667 #include <linux/fsnotify.h>
3668 #include <linux/fcntl.h>
3669 #include <linux/security.h>
3670 +#include <linux/proc_fs.h>
3671 +#include <linux/devpts_fs.h>
3672 +#include <linux/vs_tag.h>
3675 * inode_change_ok - check if attribute changes to an inode are allowed
3676 @@ -73,6 +76,10 @@ int inode_change_ok(const struct inode *
3680 + /* check for inode tag permission */
3681 + if (dx_permission(inode, MAY_WRITE))
3686 EXPORT_SYMBOL(inode_change_ok);
3687 @@ -143,6 +150,8 @@ void setattr_copy(struct inode *inode, c
3688 inode->i_uid = attr->ia_uid;
3689 if (ia_valid & ATTR_GID)
3690 inode->i_gid = attr->ia_gid;
3691 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3692 + inode->i_tag = attr->ia_tag;
3693 if (ia_valid & ATTR_ATIME)
3694 inode->i_atime = timespec_trunc(attr->ia_atime,
3695 inode->i_sb->s_time_gran);
3696 @@ -170,7 +179,8 @@ int notify_change(struct dentry * dentry
3697 struct timespec now;
3698 unsigned int ia_valid = attr->ia_valid;
3700 - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
3701 + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
3702 + ATTR_TAG | ATTR_TIMES_SET)) {
3703 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
3706 diff -NurpP --minimal linux-3.0/fs/binfmt_aout.c linux-3.0-vs2.3.1-pre7/fs/binfmt_aout.c
3707 --- linux-3.0/fs/binfmt_aout.c 2010-10-21 13:07:47.000000000 +0200
3708 +++ linux-3.0-vs2.3.1-pre7/fs/binfmt_aout.c 2011-06-10 22:11:24.000000000 +0200
3710 #include <linux/init.h>
3711 #include <linux/coredump.h>
3712 #include <linux/slab.h>
3713 +#include <linux/vs_memory.h>
3715 #include <asm/system.h>
3716 #include <asm/uaccess.h>
3717 diff -NurpP --minimal linux-3.0/fs/binfmt_elf.c linux-3.0-vs2.3.1-pre7/fs/binfmt_elf.c
3718 --- linux-3.0/fs/binfmt_elf.c 2011-05-22 16:17:48.000000000 +0200
3719 +++ linux-3.0-vs2.3.1-pre7/fs/binfmt_elf.c 2011-06-10 22:11:24.000000000 +0200
3721 #include <linux/elf.h>
3722 #include <linux/utsname.h>
3723 #include <linux/coredump.h>
3724 +#include <linux/vs_memory.h>
3725 #include <asm/uaccess.h>
3726 #include <asm/param.h>
3727 #include <asm/page.h>
3728 diff -NurpP --minimal linux-3.0/fs/binfmt_flat.c linux-3.0-vs2.3.1-pre7/fs/binfmt_flat.c
3729 --- linux-3.0/fs/binfmt_flat.c 2011-07-22 11:18:05.000000000 +0200
3730 +++ linux-3.0-vs2.3.1-pre7/fs/binfmt_flat.c 2011-06-10 22:11:24.000000000 +0200
3732 #include <linux/init.h>
3733 #include <linux/flat.h>
3734 #include <linux/syscalls.h>
3735 +#include <linux/vs_memory.h>
3737 #include <asm/byteorder.h>
3738 #include <asm/system.h>
3739 diff -NurpP --minimal linux-3.0/fs/binfmt_som.c linux-3.0-vs2.3.1-pre7/fs/binfmt_som.c
3740 --- linux-3.0/fs/binfmt_som.c 2010-02-25 11:52:04.000000000 +0100
3741 +++ linux-3.0-vs2.3.1-pre7/fs/binfmt_som.c 2011-06-10 22:11:24.000000000 +0200
3743 #include <linux/shm.h>
3744 #include <linux/personality.h>
3745 #include <linux/init.h>
3746 +#include <linux/vs_memory.h>
3748 #include <asm/uaccess.h>
3749 #include <asm/pgtable.h>
3750 diff -NurpP --minimal linux-3.0/fs/block_dev.c linux-3.0-vs2.3.1-pre7/fs/block_dev.c
3751 --- linux-3.0/fs/block_dev.c 2011-07-22 11:18:05.000000000 +0200
3752 +++ linux-3.0-vs2.3.1-pre7/fs/block_dev.c 2011-07-01 11:35:34.000000000 +0200
3754 #include <linux/namei.h>
3755 #include <linux/log2.h>
3756 #include <linux/kmemleak.h>
3757 +#include <linux/vs_device.h>
3758 #include <asm/uaccess.h>
3759 #include "internal.h"
3761 @@ -553,6 +554,7 @@ struct block_device *bdget(dev_t dev)
3762 bdev->bd_invalidated = 0;
3763 inode->i_mode = S_IFBLK;
3764 inode->i_rdev = dev;
3765 + inode->i_mdev = dev;
3766 inode->i_bdev = bdev;
3767 inode->i_data.a_ops = &def_blk_aops;
3768 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
3769 @@ -599,6 +601,11 @@ EXPORT_SYMBOL(bdput);
3770 static struct block_device *bd_acquire(struct inode *inode)
3772 struct block_device *bdev;
3775 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
3777 + inode->i_mdev = mdev;
3779 spin_lock(&bdev_lock);
3780 bdev = inode->i_bdev;
3781 @@ -609,7 +616,7 @@ static struct block_device *bd_acquire(s
3783 spin_unlock(&bdev_lock);
3785 - bdev = bdget(inode->i_rdev);
3786 + bdev = bdget(mdev);
3788 spin_lock(&bdev_lock);
3789 if (!inode->i_bdev) {
3790 diff -NurpP --minimal linux-3.0/fs/btrfs/ctree.h linux-3.0-vs2.3.1-pre7/fs/btrfs/ctree.h
3791 --- linux-3.0/fs/btrfs/ctree.h 2011-07-22 11:18:05.000000000 +0200
3792 +++ linux-3.0-vs2.3.1-pre7/fs/btrfs/ctree.h 2011-07-19 00:44:39.000000000 +0200
3793 @@ -600,11 +600,14 @@ struct btrfs_inode_item {
3794 /* modification sequence number for NFS */
3799 * a little future expansion, for more than this we can
3800 * just grow the inode item and version it
3802 - __le64 reserved[4];
3803 + __le16 reserved16;
3804 + __le32 reserved32;
3805 + __le64 reserved[3];
3806 struct btrfs_timespec atime;
3807 struct btrfs_timespec ctime;
3808 struct btrfs_timespec mtime;
3809 @@ -1359,6 +1362,8 @@ struct btrfs_ioctl_defrag_range_args {
3810 #define BTRFS_MOUNT_AUTO_DEFRAG (1 << 16)
3811 #define BTRFS_MOUNT_INODE_MAP_CACHE (1 << 17)
3813 +#define BTRFS_MOUNT_TAGGED (1 << 24)
3815 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
3816 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
3817 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
3818 @@ -1568,6 +1573,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
3819 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
3820 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
3821 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
3822 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
3823 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
3824 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
3825 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
3826 @@ -1621,6 +1627,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct
3828 BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
3830 +#define BTRFS_INODE_IXUNLINK (1 << 24)
3831 +#define BTRFS_INODE_BARRIER (1 << 25)
3832 +#define BTRFS_INODE_COW (1 << 26)
3835 BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
3837 @@ -2595,6 +2605,7 @@ extern const struct dentry_operations bt
3838 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
3839 void btrfs_update_iflags(struct inode *inode);
3840 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
3841 +int btrfs_sync_flags(struct inode *inode, int, int);
3842 int btrfs_defrag_file(struct inode *inode, struct file *file,
3843 struct btrfs_ioctl_defrag_range_args *range,
3844 u64 newer_than, unsigned long max_pages);
3845 diff -NurpP --minimal linux-3.0/fs/btrfs/disk-io.c linux-3.0-vs2.3.1-pre7/fs/btrfs/disk-io.c
3846 --- linux-3.0/fs/btrfs/disk-io.c 2011-07-22 11:18:05.000000000 +0200
3847 +++ linux-3.0-vs2.3.1-pre7/fs/btrfs/disk-io.c 2011-06-22 12:39:15.000000000 +0200
3848 @@ -1765,6 +1765,9 @@ struct btrfs_root *open_ctree(struct sup
3852 + if (btrfs_test_opt(tree_root, TAGGED))
3853 + sb->s_flags |= MS_TAGGED;
3855 features = btrfs_super_incompat_flags(disk_super) &
3856 ~BTRFS_FEATURE_INCOMPAT_SUPP;
3858 diff -NurpP --minimal linux-3.0/fs/btrfs/inode.c linux-3.0-vs2.3.1-pre7/fs/btrfs/inode.c
3859 --- linux-3.0/fs/btrfs/inode.c 2011-07-22 11:18:05.000000000 +0200
3860 +++ linux-3.0-vs2.3.1-pre7/fs/btrfs/inode.c 2011-07-19 00:44:39.000000000 +0200
3862 #include <linux/falloc.h>
3863 #include <linux/slab.h>
3864 #include <linux/ratelimit.h>
3865 +#include <linux/vs_tag.h>
3868 #include "disk-io.h"
3869 @@ -2508,6 +2509,8 @@ static void btrfs_read_locked_inode(stru
3870 struct btrfs_key location;
3876 bool filled = false;
3878 @@ -2540,8 +2543,13 @@ static void btrfs_read_locked_inode(stru
3880 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
3881 inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);
3882 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
3883 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
3885 + uid = btrfs_inode_uid(leaf, inode_item);
3886 + gid = btrfs_inode_gid(leaf, inode_item);
3887 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3888 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3889 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3890 + btrfs_inode_tag(leaf, inode_item));
3891 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
3893 tspec = btrfs_inode_atime(inode_item);
3894 @@ -2624,6 +2632,9 @@ static void fill_inode_item(struct btrfs
3895 struct btrfs_inode_item *item,
3896 struct inode *inode)
3898 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3899 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3901 if (!leaf->map_token)
3902 map_private_extent_buffer(leaf, (unsigned long)item,
3903 sizeof(struct btrfs_inode_item),
3904 @@ -2631,8 +2642,11 @@ static void fill_inode_item(struct btrfs
3905 &leaf->map_start, &leaf->map_len,
3908 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
3909 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
3910 + btrfs_set_inode_uid(leaf, item, uid);
3911 + btrfs_set_inode_gid(leaf, item, gid);
3912 +#ifdef CONFIG_TAGGING_INTERN
3913 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
3915 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
3916 btrfs_set_inode_mode(leaf, item, inode->i_mode);
3917 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
3918 @@ -7359,6 +7373,7 @@ static const struct inode_operations btr
3919 .listxattr = btrfs_listxattr,
3920 .removexattr = btrfs_removexattr,
3921 .permission = btrfs_permission,
3922 + .sync_flags = btrfs_sync_flags,
3924 static const struct inode_operations btrfs_dir_ro_inode_operations = {
3925 .lookup = btrfs_lookup,
3926 @@ -7431,6 +7446,7 @@ static const struct inode_operations btr
3927 .removexattr = btrfs_removexattr,
3928 .permission = btrfs_permission,
3929 .fiemap = btrfs_fiemap,
3930 + .sync_flags = btrfs_sync_flags,
3932 static const struct inode_operations btrfs_special_inode_operations = {
3933 .getattr = btrfs_getattr,
3934 diff -NurpP --minimal linux-3.0/fs/btrfs/ioctl.c linux-3.0-vs2.3.1-pre7/fs/btrfs/ioctl.c
3935 --- linux-3.0/fs/btrfs/ioctl.c 2011-07-22 11:18:05.000000000 +0200
3936 +++ linux-3.0-vs2.3.1-pre7/fs/btrfs/ioctl.c 2011-06-22 12:39:15.000000000 +0200
3937 @@ -70,10 +70,13 @@ static unsigned int btrfs_flags_to_ioctl
3939 unsigned int iflags = 0;
3941 - if (flags & BTRFS_INODE_SYNC)
3942 - iflags |= FS_SYNC_FL;
3943 if (flags & BTRFS_INODE_IMMUTABLE)
3944 iflags |= FS_IMMUTABLE_FL;
3945 + if (flags & BTRFS_INODE_IXUNLINK)
3946 + iflags |= FS_IXUNLINK_FL;
3948 + if (flags & BTRFS_INODE_SYNC)
3949 + iflags |= FS_SYNC_FL;
3950 if (flags & BTRFS_INODE_APPEND)
3951 iflags |= FS_APPEND_FL;
3952 if (flags & BTRFS_INODE_NODUMP)
3953 @@ -90,28 +93,78 @@ static unsigned int btrfs_flags_to_ioctl
3954 else if (flags & BTRFS_INODE_NOCOMPRESS)
3955 iflags |= FS_NOCOMP_FL;
3957 + if (flags & BTRFS_INODE_BARRIER)
3958 + iflags |= FS_BARRIER_FL;
3959 + if (flags & BTRFS_INODE_COW)
3960 + iflags |= FS_COW_FL;
3965 - * Update inode->i_flags based on the btrfs internal flags.
3966 + * Update inode->i_(v)flags based on the btrfs internal flags.
3968 void btrfs_update_iflags(struct inode *inode)
3970 struct btrfs_inode *ip = BTRFS_I(inode);
3972 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3973 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3974 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3976 - if (ip->flags & BTRFS_INODE_SYNC)
3977 - inode->i_flags |= S_SYNC;
3978 if (ip->flags & BTRFS_INODE_IMMUTABLE)
3979 inode->i_flags |= S_IMMUTABLE;
3980 + if (ip->flags & BTRFS_INODE_IXUNLINK)
3981 + inode->i_flags |= S_IXUNLINK;
3983 + if (ip->flags & BTRFS_INODE_SYNC)
3984 + inode->i_flags |= S_SYNC;
3985 if (ip->flags & BTRFS_INODE_APPEND)
3986 inode->i_flags |= S_APPEND;
3987 if (ip->flags & BTRFS_INODE_NOATIME)
3988 inode->i_flags |= S_NOATIME;
3989 if (ip->flags & BTRFS_INODE_DIRSYNC)
3990 inode->i_flags |= S_DIRSYNC;
3992 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3994 + if (ip->flags & BTRFS_INODE_BARRIER)
3995 + inode->i_vflags |= V_BARRIER;
3996 + if (ip->flags & BTRFS_INODE_COW)
3997 + inode->i_vflags |= V_COW;
4001 + * Update btrfs internal flags from inode->i_(v)flags.
4003 +void btrfs_update_flags(struct inode *inode)
4005 + struct btrfs_inode *ip = BTRFS_I(inode);
4007 + unsigned int flags = inode->i_flags;
4008 + unsigned int vflags = inode->i_vflags;
4010 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
4011 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
4012 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
4013 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
4015 + if (flags & S_IMMUTABLE)
4016 + ip->flags |= BTRFS_INODE_IMMUTABLE;
4017 + if (flags & S_IXUNLINK)
4018 + ip->flags |= BTRFS_INODE_IXUNLINK;
4020 + if (flags & S_SYNC)
4021 + ip->flags |= BTRFS_INODE_SYNC;
4022 + if (flags & S_APPEND)
4023 + ip->flags |= BTRFS_INODE_APPEND;
4024 + if (flags & S_NOATIME)
4025 + ip->flags |= BTRFS_INODE_NOATIME;
4026 + if (flags & S_DIRSYNC)
4027 + ip->flags |= BTRFS_INODE_DIRSYNC;
4029 + if (vflags & V_BARRIER)
4030 + ip->flags |= BTRFS_INODE_BARRIER;
4031 + if (vflags & V_COW)
4032 + ip->flags |= BTRFS_INODE_COW;
4036 @@ -129,7 +182,7 @@ void btrfs_inherit_iflags(struct inode *
4037 flags = BTRFS_I(dir)->flags;
4039 if (S_ISREG(inode->i_mode))
4040 - flags &= ~BTRFS_INODE_DIRSYNC;
4041 + flags &= ~(BTRFS_INODE_DIRSYNC | BTRFS_INODE_BARRIER);
4042 else if (!S_ISDIR(inode->i_mode))
4043 flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
4045 @@ -137,6 +190,30 @@ void btrfs_inherit_iflags(struct inode *
4046 btrfs_update_iflags(inode);
4049 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
4051 + struct btrfs_inode *ip = BTRFS_I(inode);
4052 + struct btrfs_root *root = ip->root;
4053 + struct btrfs_trans_handle *trans;
4056 + trans = btrfs_join_transaction(root);
4059 + inode->i_flags = flags;
4060 + inode->i_vflags = vflags;
4061 + btrfs_update_flags(inode);
4063 + ret = btrfs_update_inode(trans, root, inode);
4066 + btrfs_update_iflags(inode);
4067 + inode->i_ctime = CURRENT_TIME;
4068 + btrfs_end_transaction(trans, root);
4073 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
4075 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
4076 @@ -188,7 +265,8 @@ static int btrfs_ioctl_setflags(struct f
4078 flags = btrfs_mask_flags(inode->i_mode, flags);
4079 oldflags = btrfs_flags_to_ioctl(ip->flags);
4080 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
4081 + if ((flags ^ oldflags) & (FS_APPEND_FL |
4082 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
4083 if (!capable(CAP_LINUX_IMMUTABLE)) {
4086 @@ -199,14 +277,19 @@ static int btrfs_ioctl_setflags(struct f
4090 - if (flags & FS_SYNC_FL)
4091 - ip->flags |= BTRFS_INODE_SYNC;
4093 - ip->flags &= ~BTRFS_INODE_SYNC;
4094 if (flags & FS_IMMUTABLE_FL)
4095 ip->flags |= BTRFS_INODE_IMMUTABLE;
4097 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
4098 + if (flags & FS_IXUNLINK_FL)
4099 + ip->flags |= BTRFS_INODE_IXUNLINK;
4101 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
4103 + if (flags & FS_SYNC_FL)
4104 + ip->flags |= BTRFS_INODE_SYNC;
4106 + ip->flags &= ~BTRFS_INODE_SYNC;
4107 if (flags & FS_APPEND_FL)
4108 ip->flags |= BTRFS_INODE_APPEND;
4110 diff -NurpP --minimal linux-3.0/fs/btrfs/super.c linux-3.0-vs2.3.1-pre7/fs/btrfs/super.c
4111 --- linux-3.0/fs/btrfs/super.c 2011-07-22 11:18:05.000000000 +0200
4112 +++ linux-3.0-vs2.3.1-pre7/fs/btrfs/super.c 2011-07-19 00:44:39.000000000 +0200
4113 @@ -162,7 +162,7 @@ enum {
4114 Opt_notreelog, Opt_ratio, Opt_flushoncommit, Opt_discard,
4115 Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed,
4116 Opt_enospc_debug, Opt_subvolrootid, Opt_defrag,
4117 - Opt_inode_cache, Opt_err,
4118 + Opt_inode_cache, Opt_tag, Opt_notag, Opt_tagid, Opt_err,
4121 static match_table_t tokens = {
4122 @@ -195,6 +195,9 @@ static match_table_t tokens = {
4123 {Opt_subvolrootid, "subvolrootid=%d"},
4124 {Opt_defrag, "autodefrag"},
4125 {Opt_inode_cache, "inode_cache"},
4127 + {Opt_notag, "notag"},
4128 + {Opt_tagid, "tagid=%u"},
4132 @@ -381,6 +384,22 @@ int btrfs_parse_options(struct btrfs_roo
4133 printk(KERN_INFO "btrfs: enabling auto defrag");
4134 btrfs_set_opt(info->mount_opt, AUTO_DEFRAG);
4136 +#ifndef CONFIG_TAGGING_NONE
4138 + printk(KERN_INFO "btrfs: use tagging\n");
4139 + btrfs_set_opt(info->mount_opt, TAGGED);
4142 + printk(KERN_INFO "btrfs: disabled tagging\n");
4143 + btrfs_clear_opt(info->mount_opt, TAGGED);
4146 +#ifdef CONFIG_PROPAGATE
4149 + btrfs_set_opt(info->mount_opt, TAGGED);
4153 printk(KERN_INFO "btrfs: unrecognized mount option "
4155 @@ -907,6 +926,12 @@ static int btrfs_remount(struct super_bl
4159 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4160 + printk("btrfs: %s: tagging not permitted on remount.\n",
4165 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
4168 diff -NurpP --minimal linux-3.0/fs/char_dev.c linux-3.0-vs2.3.1-pre7/fs/char_dev.c
4169 --- linux-3.0/fs/char_dev.c 2011-03-15 18:07:31.000000000 +0100
4170 +++ linux-3.0-vs2.3.1-pre7/fs/char_dev.c 2011-06-10 22:11:24.000000000 +0200
4172 #include <linux/mutex.h>
4173 #include <linux/backing-dev.h>
4174 #include <linux/tty.h>
4175 +#include <linux/vs_context.h>
4176 +#include <linux/vs_device.h>
4178 #include "internal.h"
4180 @@ -371,14 +373,21 @@ static int chrdev_open(struct inode *ino
4182 struct cdev *new = NULL;
4186 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
4188 + inode->i_mdev = mdev;
4190 spin_lock(&cdev_lock);
4193 struct kobject *kobj;
4196 spin_unlock(&cdev_lock);
4197 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
4199 + kobj = kobj_lookup(cdev_map, mdev, &idx);
4202 new = container_of(kobj, struct cdev, kobj);
4203 diff -NurpP --minimal linux-3.0/fs/dcache.c linux-3.0-vs2.3.1-pre7/fs/dcache.c
4204 --- linux-3.0/fs/dcache.c 2011-07-22 11:18:05.000000000 +0200
4205 +++ linux-3.0-vs2.3.1-pre7/fs/dcache.c 2011-07-22 11:20:39.000000000 +0200
4207 #include <linux/bit_spinlock.h>
4208 #include <linux/rculist_bl.h>
4209 #include <linux/prefetch.h>
4210 +#include <linux/vs_limit.h>
4211 #include "internal.h"
4214 @@ -479,6 +480,8 @@ int d_invalidate(struct dentry * dentry)
4215 spin_lock(&dentry->d_lock);
4218 + vx_dentry_dec(dentry);
4221 * Somebody else still using it?
4223 @@ -506,6 +509,7 @@ EXPORT_SYMBOL(d_invalidate);
4224 static inline void __dget_dlock(struct dentry *dentry)
4227 + vx_dentry_inc(dentry);
4230 static inline void __dget(struct dentry *dentry)
4231 @@ -1266,6 +1270,9 @@ struct dentry *d_alloc(struct dentry * p
4232 struct dentry *dentry;
4235 + if (!vx_dentry_avail(1))
4238 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
4241 @@ -1288,6 +1295,7 @@ struct dentry *d_alloc(struct dentry * p
4243 dentry->d_count = 1;
4244 dentry->d_flags = 0;
4245 + vx_dentry_inc(dentry);
4246 spin_lock_init(&dentry->d_lock);
4247 seqcount_init(&dentry->d_seq);
4248 dentry->d_inode = NULL;
4249 @@ -1945,6 +1953,7 @@ struct dentry *__d_lookup(struct dentry
4253 + vx_dentry_inc(dentry);
4255 spin_unlock(&dentry->d_lock);
4257 diff -NurpP --minimal linux-3.0/fs/devpts/inode.c linux-3.0-vs2.3.1-pre7/fs/devpts/inode.c
4258 --- linux-3.0/fs/devpts/inode.c 2011-05-22 16:17:50.000000000 +0200
4259 +++ linux-3.0-vs2.3.1-pre7/fs/devpts/inode.c 2011-06-10 22:11:24.000000000 +0200
4261 #include <linux/parser.h>
4262 #include <linux/fsnotify.h>
4263 #include <linux/seq_file.h>
4264 +#include <linux/vs_base.h>
4266 #define DEVPTS_DEFAULT_MODE 0600
4269 #define DEVPTS_DEFAULT_PTMX_MODE 0000
4270 #define PTMX_MINOR 2
4272 +static int devpts_permission(struct inode *inode, int mask, unsigned int flags)
4274 + int ret = -EACCES;
4276 + /* devpts is xid tagged */
4277 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
4278 + ret = generic_permission(inode, mask, flags, NULL);
4282 +static struct inode_operations devpts_file_inode_operations = {
4283 + .permission = devpts_permission,
4286 extern int pty_limit; /* Config limit on Unix98 ptys */
4287 static DEFINE_MUTEX(allocated_ptys_lock);
4289 @@ -263,6 +278,34 @@ static int devpts_show_options(struct se
4293 +static int devpts_filter(struct dentry *de)
4297 + /* devpts is xid tagged */
4298 + if (de && de->d_inode)
4299 + xid = (xid_t)de->d_inode->i_tag;
4300 +#ifdef CONFIG_VSERVER_WARN_DEVPTS
4302 + vxwprintk_task(1, "devpts " VS_Q("%.*s") " without inode.",
4303 + de->d_name.len, de->d_name.name);
4305 + return vx_check(xid, VS_WATCH_P | VS_IDENT);
4308 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
4310 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
4313 +static struct file_operations devpts_dir_operations = {
4314 + .open = dcache_dir_open,
4315 + .release = dcache_dir_close,
4316 + .llseek = dcache_dir_lseek,
4317 + .read = generic_read_dir,
4318 + .readdir = devpts_readdir,
4321 static const struct super_operations devpts_sops = {
4322 .statfs = simple_statfs,
4323 .remount_fs = devpts_remount,
4324 @@ -302,12 +345,15 @@ devpts_fill_super(struct super_block *s,
4325 inode = new_inode(s);
4330 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
4331 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
4332 inode->i_op = &simple_dir_inode_operations;
4333 - inode->i_fop = &simple_dir_operations;
4334 + inode->i_fop = &devpts_dir_operations;
4336 + /* devpts is xid tagged */
4337 + inode->i_tag = (tag_t)vx_current_xid();
4339 s->s_root = d_alloc_root(inode);
4341 @@ -494,6 +540,9 @@ int devpts_pty_new(struct inode *ptmx_in
4342 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
4343 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
4344 init_special_inode(inode, S_IFCHR|opts->mode, device);
4345 + /* devpts is xid tagged */
4346 + inode->i_tag = (tag_t)vx_current_xid();
4347 + inode->i_op = &devpts_file_inode_operations;
4348 inode->i_private = tty;
4349 tty->driver_data = inode;
4351 diff -NurpP --minimal linux-3.0/fs/ext2/balloc.c linux-3.0-vs2.3.1-pre7/fs/ext2/balloc.c
4352 --- linux-3.0/fs/ext2/balloc.c 2011-05-22 16:17:51.000000000 +0200
4353 +++ linux-3.0-vs2.3.1-pre7/fs/ext2/balloc.c 2011-06-10 22:11:24.000000000 +0200
4354 @@ -701,7 +701,6 @@ ext2_try_to_allocate(struct super_block
4356 end = EXT2_BLOCKS_PER_GROUP(sb);
4359 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
4362 diff -NurpP --minimal linux-3.0/fs/ext2/ext2.h linux-3.0-vs2.3.1-pre7/fs/ext2/ext2.h
4363 --- linux-3.0/fs/ext2/ext2.h 2011-05-22 16:17:51.000000000 +0200
4364 +++ linux-3.0-vs2.3.1-pre7/fs/ext2/ext2.h 2011-06-10 22:11:24.000000000 +0200
4365 @@ -126,6 +126,7 @@ extern void ext2_set_inode_flags(struct
4366 extern void ext2_get_inode_flags(struct ext2_inode_info *);
4367 extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
4368 u64 start, u64 len);
4369 +extern int ext2_sync_flags(struct inode *, int, int);
4372 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
4373 diff -NurpP --minimal linux-3.0/fs/ext2/file.c linux-3.0-vs2.3.1-pre7/fs/ext2/file.c
4374 --- linux-3.0/fs/ext2/file.c 2010-08-02 16:52:48.000000000 +0200
4375 +++ linux-3.0-vs2.3.1-pre7/fs/ext2/file.c 2011-06-10 22:11:24.000000000 +0200
4376 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
4377 .setattr = ext2_setattr,
4378 .check_acl = ext2_check_acl,
4379 .fiemap = ext2_fiemap,
4380 + .sync_flags = ext2_sync_flags,
4382 diff -NurpP --minimal linux-3.0/fs/ext2/ialloc.c linux-3.0-vs2.3.1-pre7/fs/ext2/ialloc.c
4383 --- linux-3.0/fs/ext2/ialloc.c 2011-05-22 16:17:51.000000000 +0200
4384 +++ linux-3.0-vs2.3.1-pre7/fs/ext2/ialloc.c 2011-06-10 22:11:24.000000000 +0200
4386 #include <linux/backing-dev.h>
4387 #include <linux/buffer_head.h>
4388 #include <linux/random.h>
4389 +#include <linux/vs_tag.h>
4393 @@ -549,6 +550,7 @@ got:
4394 inode->i_mode = mode;
4395 inode->i_uid = current_fsuid();
4396 inode->i_gid = dir->i_gid;
4397 + inode->i_tag = dx_current_fstag(sb);
4399 inode_init_owner(inode, dir, mode);
4401 diff -NurpP --minimal linux-3.0/fs/ext2/inode.c linux-3.0-vs2.3.1-pre7/fs/ext2/inode.c
4402 --- linux-3.0/fs/ext2/inode.c 2011-05-22 16:17:51.000000000 +0200
4403 +++ linux-3.0-vs2.3.1-pre7/fs/ext2/inode.c 2011-06-10 22:11:24.000000000 +0200
4405 #include <linux/mpage.h>
4406 #include <linux/fiemap.h>
4407 #include <linux/namei.h>
4408 +#include <linux/vs_tag.h>
4412 @@ -1167,7 +1168,7 @@ static void ext2_truncate_blocks(struct
4414 if (ext2_inode_is_fast_symlink(inode))
4416 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4417 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4419 __ext2_truncate_blocks(inode, offset);
4421 @@ -1256,36 +1257,61 @@ void ext2_set_inode_flags(struct inode *
4423 unsigned int flags = EXT2_I(inode)->i_flags;
4425 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4426 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4427 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4430 + if (flags & EXT2_IMMUTABLE_FL)
4431 + inode->i_flags |= S_IMMUTABLE;
4432 + if (flags & EXT2_IXUNLINK_FL)
4433 + inode->i_flags |= S_IXUNLINK;
4435 if (flags & EXT2_SYNC_FL)
4436 inode->i_flags |= S_SYNC;
4437 if (flags & EXT2_APPEND_FL)
4438 inode->i_flags |= S_APPEND;
4439 - if (flags & EXT2_IMMUTABLE_FL)
4440 - inode->i_flags |= S_IMMUTABLE;
4441 if (flags & EXT2_NOATIME_FL)
4442 inode->i_flags |= S_NOATIME;
4443 if (flags & EXT2_DIRSYNC_FL)
4444 inode->i_flags |= S_DIRSYNC;
4446 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4448 + if (flags & EXT2_BARRIER_FL)
4449 + inode->i_vflags |= V_BARRIER;
4450 + if (flags & EXT2_COW_FL)
4451 + inode->i_vflags |= V_COW;
4454 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
4455 void ext2_get_inode_flags(struct ext2_inode_info *ei)
4457 unsigned int flags = ei->vfs_inode.i_flags;
4458 + unsigned int vflags = ei->vfs_inode.i_vflags;
4460 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
4461 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
4462 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
4463 + EXT2_BARRIER_FL | EXT2_COW_FL);
4465 + if (flags & S_IMMUTABLE)
4466 + ei->i_flags |= EXT2_IMMUTABLE_FL;
4467 + if (flags & S_IXUNLINK)
4468 + ei->i_flags |= EXT2_IXUNLINK_FL;
4470 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
4471 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
4473 ei->i_flags |= EXT2_SYNC_FL;
4474 if (flags & S_APPEND)
4475 ei->i_flags |= EXT2_APPEND_FL;
4476 - if (flags & S_IMMUTABLE)
4477 - ei->i_flags |= EXT2_IMMUTABLE_FL;
4478 if (flags & S_NOATIME)
4479 ei->i_flags |= EXT2_NOATIME_FL;
4480 if (flags & S_DIRSYNC)
4481 ei->i_flags |= EXT2_DIRSYNC_FL;
4483 + if (vflags & V_BARRIER)
4484 + ei->i_flags |= EXT2_BARRIER_FL;
4485 + if (vflags & V_COW)
4486 + ei->i_flags |= EXT2_COW_FL;
4489 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
4490 @@ -1295,6 +1321,8 @@ struct inode *ext2_iget (struct super_bl
4491 struct ext2_inode *raw_inode;
4492 struct inode *inode;
4498 inode = iget_locked(sb, ino);
4499 @@ -1313,12 +1341,17 @@ struct inode *ext2_iget (struct super_bl
4502 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
4503 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4504 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4505 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4506 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4507 if (!(test_opt (inode->i_sb, NO_UID32))) {
4508 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4509 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4510 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4511 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4513 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
4514 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
4515 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
4516 + le16_to_cpu(raw_inode->i_raw_tag));
4518 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
4519 inode->i_size = le32_to_cpu(raw_inode->i_size);
4520 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
4521 @@ -1416,8 +1449,8 @@ static int __ext2_write_inode(struct ino
4522 struct ext2_inode_info *ei = EXT2_I(inode);
4523 struct super_block *sb = inode->i_sb;
4524 ino_t ino = inode->i_ino;
4525 - uid_t uid = inode->i_uid;
4526 - gid_t gid = inode->i_gid;
4527 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
4528 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
4529 struct buffer_head * bh;
4530 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
4532 @@ -1453,6 +1486,9 @@ static int __ext2_write_inode(struct ino
4533 raw_inode->i_uid_high = 0;
4534 raw_inode->i_gid_high = 0;
4536 +#ifdef CONFIG_TAGGING_INTERN
4537 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4539 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4540 raw_inode->i_size = cpu_to_le32(inode->i_size);
4541 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
4542 @@ -1533,7 +1569,8 @@ int ext2_setattr(struct dentry *dentry,
4543 if (is_quota_modification(inode, iattr))
4544 dquot_initialize(inode);
4545 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
4546 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
4547 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
4548 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
4549 error = dquot_transfer(inode, iattr);
4552 diff -NurpP --minimal linux-3.0/fs/ext2/ioctl.c linux-3.0-vs2.3.1-pre7/fs/ext2/ioctl.c
4553 --- linux-3.0/fs/ext2/ioctl.c 2011-05-22 16:17:51.000000000 +0200
4554 +++ linux-3.0-vs2.3.1-pre7/fs/ext2/ioctl.c 2011-06-10 22:11:24.000000000 +0200
4556 #include <asm/uaccess.h>
4559 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
4561 + inode->i_flags = flags;
4562 + inode->i_vflags = vflags;
4563 + ext2_get_inode_flags(EXT2_I(inode));
4564 + inode->i_ctime = CURRENT_TIME_SEC;
4565 + mark_inode_dirty(inode);
4569 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4571 struct inode *inode = filp->f_dentry->d_inode;
4572 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
4574 flags = ext2_mask_flags(inode->i_mode, flags);
4576 + if (IS_BARRIER(inode)) {
4577 + vxwprintk_task(1, "messing with the barrier.");
4581 mutex_lock(&inode->i_mutex);
4582 /* Is it quota file? Do not allow user to mess with it */
4583 if (IS_NOQUOTA(inode)) {
4584 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
4586 * This test looks nicer. Thanks to Pauline Middelink
4588 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
4589 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
4590 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
4591 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
4592 if (!capable(CAP_LINUX_IMMUTABLE)) {
4593 mutex_unlock(&inode->i_mutex);
4595 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
4599 - flags = flags & EXT2_FL_USER_MODIFIABLE;
4600 + flags &= EXT2_FL_USER_MODIFIABLE;
4601 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
4602 ei->i_flags = flags;
4603 mutex_unlock(&inode->i_mutex);
4604 diff -NurpP --minimal linux-3.0/fs/ext2/namei.c linux-3.0-vs2.3.1-pre7/fs/ext2/namei.c
4605 --- linux-3.0/fs/ext2/namei.c 2011-05-22 16:17:51.000000000 +0200
4606 +++ linux-3.0-vs2.3.1-pre7/fs/ext2/namei.c 2011-06-10 22:11:24.000000000 +0200
4609 #include <linux/pagemap.h>
4610 #include <linux/quotaops.h>
4611 +#include <linux/vs_tag.h>
4615 @@ -75,6 +76,7 @@ static struct dentry *ext2_lookup(struct
4616 return ERR_PTR(-EIO);
4618 return ERR_CAST(inode);
4619 + dx_propagate_tag(nd, inode);
4623 @@ -413,6 +415,7 @@ const struct inode_operations ext2_dir_i
4625 .setattr = ext2_setattr,
4626 .check_acl = ext2_check_acl,
4627 + .sync_flags = ext2_sync_flags,
4630 const struct inode_operations ext2_special_inode_operations = {
4631 diff -NurpP --minimal linux-3.0/fs/ext2/super.c linux-3.0-vs2.3.1-pre7/fs/ext2/super.c
4632 --- linux-3.0/fs/ext2/super.c 2011-07-22 11:18:05.000000000 +0200
4633 +++ linux-3.0-vs2.3.1-pre7/fs/ext2/super.c 2011-06-10 22:11:24.000000000 +0200
4634 @@ -394,7 +394,8 @@ enum {
4635 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
4636 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
4637 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
4638 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
4639 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
4640 + Opt_tag, Opt_notag, Opt_tagid
4643 static const match_table_t tokens = {
4644 @@ -422,6 +423,9 @@ static const match_table_t tokens = {
4646 {Opt_noacl, "noacl"},
4649 + {Opt_notag, "notag"},
4650 + {Opt_tagid, "tagid=%u"},
4651 {Opt_grpquota, "grpquota"},
4652 {Opt_ignore, "noquota"},
4653 {Opt_quota, "quota"},
4654 @@ -492,6 +496,20 @@ static int parse_options(char *options,
4656 set_opt (sbi->s_mount_opt, NO_UID32);
4658 +#ifndef CONFIG_TAGGING_NONE
4660 + set_opt (sbi->s_mount_opt, TAGGED);
4663 + clear_opt (sbi->s_mount_opt, TAGGED);
4666 +#ifdef CONFIG_PROPAGATE
4669 + set_opt (sbi->s_mount_opt, TAGGED);
4673 clear_opt (sbi->s_mount_opt, CHECK);
4675 @@ -850,6 +868,8 @@ static int ext2_fill_super(struct super_
4676 if (!parse_options((char *) data, sb))
4679 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
4680 + sb->s_flags |= MS_TAGGED;
4681 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4682 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
4684 @@ -1224,6 +1244,14 @@ static int ext2_remount (struct super_bl
4688 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
4689 + !(sb->s_flags & MS_TAGGED)) {
4690 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
4693 + goto restore_opts;
4696 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
4697 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
4699 diff -NurpP --minimal linux-3.0/fs/ext3/file.c linux-3.0-vs2.3.1-pre7/fs/ext3/file.c
4700 --- linux-3.0/fs/ext3/file.c 2010-07-07 18:31:51.000000000 +0200
4701 +++ linux-3.0-vs2.3.1-pre7/fs/ext3/file.c 2011-06-10 22:11:24.000000000 +0200
4702 @@ -81,5 +81,6 @@ const struct inode_operations ext3_file_
4704 .check_acl = ext3_check_acl,
4705 .fiemap = ext3_fiemap,
4706 + .sync_flags = ext3_sync_flags,
4709 diff -NurpP --minimal linux-3.0/fs/ext3/ialloc.c linux-3.0-vs2.3.1-pre7/fs/ext3/ialloc.c
4710 --- linux-3.0/fs/ext3/ialloc.c 2011-05-22 16:17:52.000000000 +0200
4711 +++ linux-3.0-vs2.3.1-pre7/fs/ext3/ialloc.c 2011-06-10 22:11:24.000000000 +0200
4713 #include <linux/buffer_head.h>
4714 #include <linux/random.h>
4715 #include <linux/bitops.h>
4716 +#include <linux/vs_tag.h>
4718 #include <asm/byteorder.h>
4720 @@ -532,6 +533,7 @@ got:
4721 inode->i_mode = mode;
4722 inode->i_uid = current_fsuid();
4723 inode->i_gid = dir->i_gid;
4724 + inode->i_tag = dx_current_fstag(sb);
4726 inode_init_owner(inode, dir, mode);
4728 diff -NurpP --minimal linux-3.0/fs/ext3/inode.c linux-3.0-vs2.3.1-pre7/fs/ext3/inode.c
4729 --- linux-3.0/fs/ext3/inode.c 2011-07-22 11:18:05.000000000 +0200
4730 +++ linux-3.0-vs2.3.1-pre7/fs/ext3/inode.c 2011-06-10 22:11:24.000000000 +0200
4732 #include <linux/bio.h>
4733 #include <linux/fiemap.h>
4734 #include <linux/namei.h>
4735 +#include <linux/vs_tag.h>
4739 @@ -2391,7 +2392,7 @@ static void ext3_free_branches(handle_t
4741 int ext3_can_truncate(struct inode *inode)
4743 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4744 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4746 if (S_ISREG(inode->i_mode))
4748 @@ -2775,36 +2776,60 @@ void ext3_set_inode_flags(struct inode *
4750 unsigned int flags = EXT3_I(inode)->i_flags;
4752 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
4753 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
4754 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
4756 + if (flags & EXT3_IMMUTABLE_FL)
4757 + inode->i_flags |= S_IMMUTABLE;
4758 + if (flags & EXT3_IXUNLINK_FL)
4759 + inode->i_flags |= S_IXUNLINK;
4761 if (flags & EXT3_SYNC_FL)
4762 inode->i_flags |= S_SYNC;
4763 if (flags & EXT3_APPEND_FL)
4764 inode->i_flags |= S_APPEND;
4765 - if (flags & EXT3_IMMUTABLE_FL)
4766 - inode->i_flags |= S_IMMUTABLE;
4767 if (flags & EXT3_NOATIME_FL)
4768 inode->i_flags |= S_NOATIME;
4769 if (flags & EXT3_DIRSYNC_FL)
4770 inode->i_flags |= S_DIRSYNC;
4772 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4774 + if (flags & EXT3_BARRIER_FL)
4775 + inode->i_vflags |= V_BARRIER;
4776 + if (flags & EXT3_COW_FL)
4777 + inode->i_vflags |= V_COW;
4780 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
4781 void ext3_get_inode_flags(struct ext3_inode_info *ei)
4783 unsigned int flags = ei->vfs_inode.i_flags;
4784 + unsigned int vflags = ei->vfs_inode.i_vflags;
4786 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
4787 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
4788 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
4789 + EXT3_BARRIER_FL | EXT3_COW_FL);
4791 + if (flags & S_IMMUTABLE)
4792 + ei->i_flags |= EXT3_IMMUTABLE_FL;
4793 + if (flags & S_IXUNLINK)
4794 + ei->i_flags |= EXT3_IXUNLINK_FL;
4796 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
4797 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
4799 ei->i_flags |= EXT3_SYNC_FL;
4800 if (flags & S_APPEND)
4801 ei->i_flags |= EXT3_APPEND_FL;
4802 - if (flags & S_IMMUTABLE)
4803 - ei->i_flags |= EXT3_IMMUTABLE_FL;
4804 if (flags & S_NOATIME)
4805 ei->i_flags |= EXT3_NOATIME_FL;
4806 if (flags & S_DIRSYNC)
4807 ei->i_flags |= EXT3_DIRSYNC_FL;
4809 + if (vflags & V_BARRIER)
4810 + ei->i_flags |= EXT3_BARRIER_FL;
4811 + if (vflags & V_COW)
4812 + ei->i_flags |= EXT3_COW_FL;
4815 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
4816 @@ -2818,6 +2843,8 @@ struct inode *ext3_iget(struct super_blo
4817 transaction_t *transaction;
4823 inode = iget_locked(sb, ino);
4825 @@ -2834,12 +2861,17 @@ struct inode *ext3_iget(struct super_blo
4827 raw_inode = ext3_raw_inode(&iloc);
4828 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
4829 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4830 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4831 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
4832 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
4833 if(!(test_opt (inode->i_sb, NO_UID32))) {
4834 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4835 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4836 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
4837 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
4839 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
4840 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
4841 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
4842 + le16_to_cpu(raw_inode->i_raw_tag));
4844 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
4845 inode->i_size = le32_to_cpu(raw_inode->i_size);
4846 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
4847 @@ -2994,6 +3026,8 @@ static int ext3_do_update_inode(handle_t
4848 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
4849 struct ext3_inode_info *ei = EXT3_I(inode);
4850 struct buffer_head *bh = iloc->bh;
4851 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
4852 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
4853 int err = 0, rc, block;
4856 @@ -3008,29 +3042,32 @@ again:
4857 ext3_get_inode_flags(ei);
4858 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
4859 if(!(test_opt(inode->i_sb, NO_UID32))) {
4860 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
4861 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
4862 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
4863 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
4865 * Fix up interoperability with old kernels. Otherwise, old inodes get
4866 * re-used with the upper 16 bits of the uid/gid intact
4869 raw_inode->i_uid_high =
4870 - cpu_to_le16(high_16_bits(inode->i_uid));
4871 + cpu_to_le16(high_16_bits(uid));
4872 raw_inode->i_gid_high =
4873 - cpu_to_le16(high_16_bits(inode->i_gid));
4874 + cpu_to_le16(high_16_bits(gid));
4876 raw_inode->i_uid_high = 0;
4877 raw_inode->i_gid_high = 0;
4880 raw_inode->i_uid_low =
4881 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
4882 + cpu_to_le16(fs_high2lowuid(uid));
4883 raw_inode->i_gid_low =
4884 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
4885 + cpu_to_le16(fs_high2lowgid(gid));
4886 raw_inode->i_uid_high = 0;
4887 raw_inode->i_gid_high = 0;
4889 +#ifdef CONFIG_TAGGING_INTERN
4890 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
4892 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
4893 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
4894 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
4895 @@ -3190,7 +3227,8 @@ int ext3_setattr(struct dentry *dentry,
4896 if (is_quota_modification(inode, attr))
4897 dquot_initialize(inode);
4898 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
4899 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
4900 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
4901 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
4904 /* (user+group)*(old+new) structure, inode write (sb,
4905 @@ -3212,6 +3250,8 @@ int ext3_setattr(struct dentry *dentry,
4906 inode->i_uid = attr->ia_uid;
4907 if (attr->ia_valid & ATTR_GID)
4908 inode->i_gid = attr->ia_gid;
4909 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
4910 + inode->i_tag = attr->ia_tag;
4911 error = ext3_mark_inode_dirty(handle, inode);
4912 ext3_journal_stop(handle);
4914 diff -NurpP --minimal linux-3.0/fs/ext3/ioctl.c linux-3.0-vs2.3.1-pre7/fs/ext3/ioctl.c
4915 --- linux-3.0/fs/ext3/ioctl.c 2011-05-22 16:17:52.000000000 +0200
4916 +++ linux-3.0-vs2.3.1-pre7/fs/ext3/ioctl.c 2011-06-10 22:11:24.000000000 +0200
4920 #include <linux/fs.h>
4921 +#include <linux/mount.h>
4922 #include <linux/jbd.h>
4923 #include <linux/capability.h>
4924 #include <linux/ext3_fs.h>
4926 #include <linux/compat.h>
4927 #include <asm/uaccess.h>
4930 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
4932 + handle_t *handle = NULL;
4933 + struct ext3_iloc iloc;
4936 + handle = ext3_journal_start(inode, 1);
4937 + if (IS_ERR(handle))
4938 + return PTR_ERR(handle);
4940 + if (IS_SYNC(inode))
4941 + handle->h_sync = 1;
4942 + err = ext3_reserve_inode_write(handle, inode, &iloc);
4946 + inode->i_flags = flags;
4947 + inode->i_vflags = vflags;
4948 + ext3_get_inode_flags(EXT3_I(inode));
4949 + inode->i_ctime = CURRENT_TIME_SEC;
4951 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
4953 + ext3_journal_stop(handle);
4957 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
4959 struct inode *inode = filp->f_dentry->d_inode;
4960 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
4962 flags = ext3_mask_flags(inode->i_mode, flags);
4964 + if (IS_BARRIER(inode)) {
4965 + vxwprintk_task(1, "messing with the barrier.");
4969 mutex_lock(&inode->i_mutex);
4971 /* Is it quota file? Do not allow user to mess with it */
4972 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
4974 * This test looks nicer. Thanks to Pauline Middelink
4976 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
4977 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
4978 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
4979 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
4980 if (!capable(CAP_LINUX_IMMUTABLE))
4983 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
4987 - flags = flags & EXT3_FL_USER_MODIFIABLE;
4988 + flags &= EXT3_FL_USER_MODIFIABLE;
4989 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
4990 ei->i_flags = flags;
4992 diff -NurpP --minimal linux-3.0/fs/ext3/namei.c linux-3.0-vs2.3.1-pre7/fs/ext3/namei.c
4993 --- linux-3.0/fs/ext3/namei.c 2011-07-22 11:18:05.000000000 +0200
4994 +++ linux-3.0-vs2.3.1-pre7/fs/ext3/namei.c 2011-06-10 22:11:24.000000000 +0200
4996 #include <linux/quotaops.h>
4997 #include <linux/buffer_head.h>
4998 #include <linux/bio.h>
4999 +#include <linux/vs_tag.h>
5003 @@ -923,6 +924,7 @@ restart:
5005 ll_rw_block(READ_META, 1, &bh);
5007 + dx_propagate_tag(nd, inode);
5009 if ((bh = bh_use[ra_ptr++]) == NULL)
5011 @@ -2534,6 +2536,7 @@ const struct inode_operations ext3_dir_i
5012 .removexattr = generic_removexattr,
5014 .check_acl = ext3_check_acl,
5015 + .sync_flags = ext3_sync_flags,
5018 const struct inode_operations ext3_special_inode_operations = {
5019 diff -NurpP --minimal linux-3.0/fs/ext3/super.c linux-3.0-vs2.3.1-pre7/fs/ext3/super.c
5020 --- linux-3.0/fs/ext3/super.c 2011-07-22 11:18:05.000000000 +0200
5021 +++ linux-3.0-vs2.3.1-pre7/fs/ext3/super.c 2011-06-10 22:11:24.000000000 +0200
5022 @@ -821,7 +821,8 @@ enum {
5023 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
5024 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
5025 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
5026 - Opt_resize, Opt_usrquota, Opt_grpquota
5027 + Opt_resize, Opt_usrquota, Opt_grpquota,
5028 + Opt_tag, Opt_notag, Opt_tagid
5031 static const match_table_t tokens = {
5032 @@ -878,6 +879,9 @@ static const match_table_t tokens = {
5033 {Opt_barrier, "barrier"},
5034 {Opt_nobarrier, "nobarrier"},
5035 {Opt_resize, "resize"},
5037 + {Opt_notag, "notag"},
5038 + {Opt_tagid, "tagid=%u"},
5042 @@ -1030,6 +1034,20 @@ static int parse_options (char *options,
5044 set_opt (sbi->s_mount_opt, NO_UID32);
5046 +#ifndef CONFIG_TAGGING_NONE
5048 + set_opt (sbi->s_mount_opt, TAGGED);
5051 + clear_opt (sbi->s_mount_opt, TAGGED);
5054 +#ifdef CONFIG_PROPAGATE
5057 + set_opt (sbi->s_mount_opt, TAGGED);
5061 clear_opt (sbi->s_mount_opt, CHECK);
5063 @@ -1724,6 +1742,9 @@ static int ext3_fill_super (struct super
5067 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
5068 + sb->s_flags |= MS_TAGGED;
5070 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
5071 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
5073 @@ -2604,6 +2625,14 @@ static int ext3_remount (struct super_bl
5074 if (test_opt(sb, ABORT))
5075 ext3_abort(sb, __func__, "Abort forced by user");
5077 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
5078 + !(sb->s_flags & MS_TAGGED)) {
5079 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
5082 + goto restore_opts;
5085 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
5086 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
5088 diff -NurpP --minimal linux-3.0/fs/ext4/ext4.h linux-3.0-vs2.3.1-pre7/fs/ext4/ext4.h
5089 --- linux-3.0/fs/ext4/ext4.h 2011-07-22 11:18:05.000000000 +0200
5090 +++ linux-3.0-vs2.3.1-pre7/fs/ext4/ext4.h 2011-06-10 22:11:24.000000000 +0200
5091 @@ -350,8 +350,12 @@ struct flex_groups {
5092 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
5093 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
5094 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
5095 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
5096 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
5098 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
5099 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
5101 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
5102 #define EXT4_FL_USER_MODIFIABLE 0x004B80FF /* User modifiable flags */
5104 @@ -608,7 +612,8 @@ struct ext4_inode {
5105 __le16 l_i_file_acl_high;
5106 __le16 l_i_uid_high; /* these 2 fields */
5107 __le16 l_i_gid_high; /* were reserved2[0] */
5108 - __u32 l_i_reserved2;
5109 + __le16 l_i_tag; /* Context Tag */
5110 + __u16 l_i_reserved2;
5113 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
5114 @@ -726,6 +731,7 @@ do { \
5115 #define i_gid_low i_gid
5116 #define i_uid_high osd2.linux2.l_i_uid_high
5117 #define i_gid_high osd2.linux2.l_i_gid_high
5118 +#define i_raw_tag osd2.linux2.l_i_tag
5119 #define i_reserved2 osd2.linux2.l_i_reserved2
5121 #elif defined(__GNU__)
5122 @@ -902,6 +908,7 @@ struct ext4_inode_info {
5123 #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
5124 #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */
5125 #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
5126 +#define EXT4_MOUNT_TAGGED 0x40000 /* Enable Context Tags */
5127 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
5128 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
5129 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
5130 @@ -2172,6 +2179,7 @@ extern int ext4_map_blocks(handle_t *han
5131 struct ext4_map_blocks *map, int flags);
5132 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
5133 __u64 start, __u64 len);
5134 +extern int ext4_sync_flags(struct inode *, int, int);
5136 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
5137 __u64 start_orig, __u64 start_donor,
5138 diff -NurpP --minimal linux-3.0/fs/ext4/file.c linux-3.0-vs2.3.1-pre7/fs/ext4/file.c
5139 --- linux-3.0/fs/ext4/file.c 2011-07-22 11:18:05.000000000 +0200
5140 +++ linux-3.0-vs2.3.1-pre7/fs/ext4/file.c 2011-06-10 22:11:24.000000000 +0200
5141 @@ -282,5 +282,6 @@ const struct inode_operations ext4_file_
5143 .check_acl = ext4_check_acl,
5144 .fiemap = ext4_fiemap,
5145 + .sync_flags = ext4_sync_flags,
5148 diff -NurpP --minimal linux-3.0/fs/ext4/ialloc.c linux-3.0-vs2.3.1-pre7/fs/ext4/ialloc.c
5149 --- linux-3.0/fs/ext4/ialloc.c 2011-05-22 16:17:52.000000000 +0200
5150 +++ linux-3.0-vs2.3.1-pre7/fs/ext4/ialloc.c 2011-06-10 22:11:24.000000000 +0200
5152 #include <linux/random.h>
5153 #include <linux/bitops.h>
5154 #include <linux/blkdev.h>
5155 +#include <linux/vs_tag.h>
5156 #include <asm/byteorder.h>
5159 @@ -992,6 +993,7 @@ got:
5160 inode->i_mode = mode;
5161 inode->i_uid = current_fsuid();
5162 inode->i_gid = dir->i_gid;
5163 + inode->i_tag = dx_current_fstag(sb);
5165 inode_init_owner(inode, dir, mode);
5167 diff -NurpP --minimal linux-3.0/fs/ext4/inode.c linux-3.0-vs2.3.1-pre7/fs/ext4/inode.c
5168 --- linux-3.0/fs/ext4/inode.c 2011-07-22 11:18:05.000000000 +0200
5169 +++ linux-3.0-vs2.3.1-pre7/fs/ext4/inode.c 2011-07-01 11:35:34.000000000 +0200
5171 #include <linux/printk.h>
5172 #include <linux/slab.h>
5173 #include <linux/ratelimit.h>
5174 +#include <linux/vs_tag.h>
5176 #include "ext4_jbd2.h"
5178 @@ -4797,41 +4798,64 @@ void ext4_set_inode_flags(struct inode *
5180 unsigned int flags = EXT4_I(inode)->i_flags;
5182 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
5183 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5184 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5186 + if (flags & EXT4_IMMUTABLE_FL)
5187 + inode->i_flags |= S_IMMUTABLE;
5188 + if (flags & EXT4_IXUNLINK_FL)
5189 + inode->i_flags |= S_IXUNLINK;
5191 if (flags & EXT4_SYNC_FL)
5192 inode->i_flags |= S_SYNC;
5193 if (flags & EXT4_APPEND_FL)
5194 inode->i_flags |= S_APPEND;
5195 - if (flags & EXT4_IMMUTABLE_FL)
5196 - inode->i_flags |= S_IMMUTABLE;
5197 if (flags & EXT4_NOATIME_FL)
5198 inode->i_flags |= S_NOATIME;
5199 if (flags & EXT4_DIRSYNC_FL)
5200 inode->i_flags |= S_DIRSYNC;
5202 + inode->i_vflags &= ~(V_BARRIER | V_COW);
5204 + if (flags & EXT4_BARRIER_FL)
5205 + inode->i_vflags |= V_BARRIER;
5206 + if (flags & EXT4_COW_FL)
5207 + inode->i_vflags |= V_COW;
5210 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
5211 void ext4_get_inode_flags(struct ext4_inode_info *ei)
5213 - unsigned int vfs_fl;
5214 + unsigned int vfs_fl, vfs_vf;
5215 unsigned long old_fl, new_fl;
5218 vfs_fl = ei->vfs_inode.i_flags;
5219 + vfs_vf = ei->vfs_inode.i_vflags;
5220 old_fl = ei->i_flags;
5221 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
5222 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
5224 + EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
5227 + if (vfs_fl & S_IMMUTABLE)
5228 + new_fl |= EXT4_IMMUTABLE_FL;
5229 + if (vfs_fl & S_IXUNLINK)
5230 + new_fl |= EXT4_IXUNLINK_FL;
5232 if (vfs_fl & S_SYNC)
5233 new_fl |= EXT4_SYNC_FL;
5234 if (vfs_fl & S_APPEND)
5235 new_fl |= EXT4_APPEND_FL;
5236 - if (vfs_fl & S_IMMUTABLE)
5237 - new_fl |= EXT4_IMMUTABLE_FL;
5238 if (vfs_fl & S_NOATIME)
5239 new_fl |= EXT4_NOATIME_FL;
5240 if (vfs_fl & S_DIRSYNC)
5241 new_fl |= EXT4_DIRSYNC_FL;
5243 + if (vfs_vf & V_BARRIER)
5244 + new_fl |= EXT4_BARRIER_FL;
5245 + if (vfs_vf & V_COW)
5246 + new_fl |= EXT4_COW_FL;
5247 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
5250 @@ -4867,6 +4891,8 @@ struct inode *ext4_iget(struct super_blo
5251 journal_t *journal = EXT4_SB(sb)->s_journal;
5257 inode = iget_locked(sb, ino);
5259 @@ -4882,12 +4908,16 @@ struct inode *ext4_iget(struct super_blo
5261 raw_inode = ext4_raw_inode(&iloc);
5262 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
5263 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
5264 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
5265 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
5266 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
5267 if (!(test_opt(inode->i_sb, NO_UID32))) {
5268 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
5269 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
5270 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
5271 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
5273 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5274 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5275 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
5276 + le16_to_cpu(raw_inode->i_raw_tag));
5277 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
5279 ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
5280 @@ -5106,6 +5136,8 @@ static int ext4_do_update_inode(handle_t
5281 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
5282 struct ext4_inode_info *ei = EXT4_I(inode);
5283 struct buffer_head *bh = iloc->bh;
5284 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
5285 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
5286 int err = 0, rc, block;
5288 /* For fields not not tracking in the in-memory inode,
5289 @@ -5116,29 +5148,32 @@ static int ext4_do_update_inode(handle_t
5290 ext4_get_inode_flags(ei);
5291 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
5292 if (!(test_opt(inode->i_sb, NO_UID32))) {
5293 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
5294 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
5295 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
5296 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
5298 * Fix up interoperability with old kernels. Otherwise, old inodes get
5299 * re-used with the upper 16 bits of the uid/gid intact
5302 raw_inode->i_uid_high =
5303 - cpu_to_le16(high_16_bits(inode->i_uid));
5304 + cpu_to_le16(high_16_bits(uid));
5305 raw_inode->i_gid_high =
5306 - cpu_to_le16(high_16_bits(inode->i_gid));
5307 + cpu_to_le16(high_16_bits(gid));
5309 raw_inode->i_uid_high = 0;
5310 raw_inode->i_gid_high = 0;
5313 raw_inode->i_uid_low =
5314 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
5315 + cpu_to_le16(fs_high2lowuid(uid));
5316 raw_inode->i_gid_low =
5317 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
5318 + cpu_to_le16(fs_high2lowgid(gid));
5319 raw_inode->i_uid_high = 0;
5320 raw_inode->i_gid_high = 0;
5322 +#ifdef CONFIG_TAGGING_INTERN
5323 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
5325 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
5327 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
5328 @@ -5324,7 +5359,8 @@ int ext4_setattr(struct dentry *dentry,
5329 if (is_quota_modification(inode, attr))
5330 dquot_initialize(inode);
5331 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
5332 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
5333 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
5334 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
5337 /* (user+group)*(old+new) structure, inode write (sb,
5338 @@ -5346,6 +5382,8 @@ int ext4_setattr(struct dentry *dentry,
5339 inode->i_uid = attr->ia_uid;
5340 if (attr->ia_valid & ATTR_GID)
5341 inode->i_gid = attr->ia_gid;
5342 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5343 + inode->i_tag = attr->ia_tag;
5344 error = ext4_mark_inode_dirty(handle, inode);
5345 ext4_journal_stop(handle);
5347 diff -NurpP --minimal linux-3.0/fs/ext4/ioctl.c linux-3.0-vs2.3.1-pre7/fs/ext4/ioctl.c
5348 --- linux-3.0/fs/ext4/ioctl.c 2011-05-22 16:17:52.000000000 +0200
5349 +++ linux-3.0-vs2.3.1-pre7/fs/ext4/ioctl.c 2011-06-10 22:11:24.000000000 +0200
5351 #include <linux/compat.h>
5352 #include <linux/mount.h>
5353 #include <linux/file.h>
5354 +#include <linux/vs_tag.h>
5355 #include <asm/uaccess.h>
5356 #include "ext4_jbd2.h"
5360 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
5362 + handle_t *handle = NULL;
5363 + struct ext4_iloc iloc;
5366 + handle = ext4_journal_start(inode, 1);
5367 + if (IS_ERR(handle))
5368 + return PTR_ERR(handle);
5370 + if (IS_SYNC(inode))
5371 + ext4_handle_sync(handle);
5372 + err = ext4_reserve_inode_write(handle, inode, &iloc);
5376 + inode->i_flags = flags;
5377 + inode->i_vflags = vflags;
5378 + ext4_get_inode_flags(EXT4_I(inode));
5379 + inode->i_ctime = ext4_current_time(inode);
5381 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
5383 + ext4_journal_stop(handle);
5387 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5389 struct inode *inode = filp->f_dentry->d_inode;
5390 @@ -50,6 +79,11 @@ long ext4_ioctl(struct file *filp, unsig
5392 flags = ext4_mask_flags(inode->i_mode, flags);
5394 + if (IS_BARRIER(inode)) {
5395 + vxwprintk_task(1, "messing with the barrier.");
5400 mutex_lock(&inode->i_mutex);
5401 /* Is it quota file? Do not allow user to mess with it */
5402 @@ -67,7 +101,9 @@ long ext4_ioctl(struct file *filp, unsig
5404 * This test looks nicer. Thanks to Pauline Middelink
5406 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
5407 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
5408 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
5409 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
5410 if (!capable(CAP_LINUX_IMMUTABLE))
5413 diff -NurpP --minimal linux-3.0/fs/ext4/namei.c linux-3.0-vs2.3.1-pre7/fs/ext4/namei.c
5414 --- linux-3.0/fs/ext4/namei.c 2011-07-22 11:18:05.000000000 +0200
5415 +++ linux-3.0-vs2.3.1-pre7/fs/ext4/namei.c 2011-06-10 22:11:24.000000000 +0200
5417 #include <linux/quotaops.h>
5418 #include <linux/buffer_head.h>
5419 #include <linux/bio.h>
5420 +#include <linux/vs_tag.h>
5422 #include "ext4_jbd2.h"
5424 @@ -924,6 +925,7 @@ restart:
5426 ll_rw_block(READ_META, 1, &bh);
5428 + dx_propagate_tag(nd, inode);
5430 if ((bh = bh_use[ra_ptr++]) == NULL)
5432 @@ -2596,6 +2598,7 @@ const struct inode_operations ext4_dir_i
5434 .check_acl = ext4_check_acl,
5435 .fiemap = ext4_fiemap,
5436 + .sync_flags = ext4_sync_flags,
5439 const struct inode_operations ext4_special_inode_operations = {
5440 diff -NurpP --minimal linux-3.0/fs/ext4/super.c linux-3.0-vs2.3.1-pre7/fs/ext4/super.c
5441 --- linux-3.0/fs/ext4/super.c 2011-07-22 11:18:05.000000000 +0200
5442 +++ linux-3.0-vs2.3.1-pre7/fs/ext4/super.c 2011-07-01 11:35:34.000000000 +0200
5443 @@ -1294,6 +1294,7 @@ enum {
5444 Opt_dioread_nolock, Opt_dioread_lock,
5445 Opt_discard, Opt_nodiscard,
5446 Opt_init_inode_table, Opt_noinit_inode_table,
5447 + Opt_tag, Opt_notag, Opt_tagid
5450 static const match_table_t tokens = {
5451 @@ -1369,6 +1370,9 @@ static const match_table_t tokens = {
5452 {Opt_init_inode_table, "init_itable=%u"},
5453 {Opt_init_inode_table, "init_itable"},
5454 {Opt_noinit_inode_table, "noinit_itable"},
5456 + {Opt_notag, "notag"},
5457 + {Opt_tagid, "tagid=%u"},
5461 @@ -1537,6 +1541,20 @@ static int parse_options(char *options,
5463 set_opt(sb, NO_UID32);
5465 +#ifndef CONFIG_TAGGING_NONE
5467 + set_opt(sb, TAGGED);
5470 + clear_opt(sb, TAGGED);
5473 +#ifdef CONFIG_PROPAGATE
5476 + set_opt(sb, TAGGED);
5482 @@ -3194,6 +3212,9 @@ static int ext4_fill_super(struct super_
5483 &journal_ioprio, NULL, 0))
5486 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
5487 + sb->s_flags |= MS_TAGGED;
5489 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
5490 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
5492 @@ -4324,6 +4345,14 @@ static int ext4_remount(struct super_blo
5493 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
5494 ext4_abort(sb, "Abort forced by user");
5496 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
5497 + !(sb->s_flags & MS_TAGGED)) {
5498 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
5501 + goto restore_opts;
5504 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
5505 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
5507 diff -NurpP --minimal linux-3.0/fs/fcntl.c linux-3.0-vs2.3.1-pre7/fs/fcntl.c
5508 --- linux-3.0/fs/fcntl.c 2011-05-22 16:17:52.000000000 +0200
5509 +++ linux-3.0-vs2.3.1-pre7/fs/fcntl.c 2011-06-10 22:11:24.000000000 +0200
5511 #include <linux/signal.h>
5512 #include <linux/rcupdate.h>
5513 #include <linux/pid_namespace.h>
5514 +#include <linux/vs_limit.h>
5516 #include <asm/poll.h>
5517 #include <asm/siginfo.h>
5518 @@ -103,6 +104,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
5521 filp_close(tofree, files);
5523 + vx_openfd_inc(newfd); /* fd was unused */
5527 @@ -447,6 +450,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
5528 filp = fget_raw(fd);
5531 + if (!vx_files_avail(1))
5534 if (unlikely(filp->f_mode & FMODE_PATH)) {
5535 if (!check_fcntl_cmd(cmd)) {
5536 diff -NurpP --minimal linux-3.0/fs/file.c linux-3.0-vs2.3.1-pre7/fs/file.c
5537 --- linux-3.0/fs/file.c 2011-05-22 16:17:52.000000000 +0200
5538 +++ linux-3.0-vs2.3.1-pre7/fs/file.c 2011-06-10 22:11:24.000000000 +0200
5540 #include <linux/spinlock.h>
5541 #include <linux/rcupdate.h>
5542 #include <linux/workqueue.h>
5543 +#include <linux/vs_limit.h>
5545 struct fdtable_defer {
5547 @@ -359,6 +360,8 @@ struct files_struct *dup_fd(struct files
5548 struct file *f = *old_fds++;
5551 + /* TODO: sum it first for check and performance */
5552 + vx_openfd_inc(open_files - i);
5555 * The fd may be claimed in the fd bitmap but not yet
5556 @@ -466,6 +469,7 @@ repeat:
5558 FD_CLR(fd, fdt->close_on_exec);
5560 + vx_openfd_inc(fd);
5563 if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
5564 diff -NurpP --minimal linux-3.0/fs/file_table.c linux-3.0-vs2.3.1-pre7/fs/file_table.c
5565 --- linux-3.0/fs/file_table.c 2011-05-22 16:17:52.000000000 +0200
5566 +++ linux-3.0-vs2.3.1-pre7/fs/file_table.c 2011-06-10 22:11:24.000000000 +0200
5568 #include <linux/percpu_counter.h>
5569 #include <linux/percpu.h>
5570 #include <linux/ima.h>
5571 +#include <linux/vs_limit.h>
5572 +#include <linux/vs_context.h>
5574 #include <asm/atomic.h>
5576 @@ -135,6 +137,8 @@ struct file *get_empty_filp(void)
5577 spin_lock_init(&f->f_lock);
5578 eventpoll_init_file(f);
5579 /* f->f_version: 0 */
5580 + f->f_xid = vx_current_xid();
5585 @@ -253,6 +257,8 @@ static void __fput(struct file *file)
5587 fops_put(file->f_op);
5588 put_pid(file->f_owner.pid);
5589 + vx_files_dec(file);
5591 file_sb_list_del(file);
5592 if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
5593 i_readcount_dec(inode);
5594 @@ -383,6 +389,8 @@ void put_filp(struct file *file)
5596 if (atomic_long_dec_and_test(&file->f_count)) {
5597 security_file_free(file);
5598 + vx_files_dec(file);
5600 file_sb_list_del(file);
5603 diff -NurpP --minimal linux-3.0/fs/fs_struct.c linux-3.0-vs2.3.1-pre7/fs/fs_struct.c
5604 --- linux-3.0/fs/fs_struct.c 2011-03-15 18:07:31.000000000 +0100
5605 +++ linux-3.0-vs2.3.1-pre7/fs/fs_struct.c 2011-06-10 22:11:24.000000000 +0200
5607 #include <linux/path.h>
5608 #include <linux/slab.h>
5609 #include <linux/fs_struct.h>
5610 +#include <linux/vserver/global.h>
5611 #include "internal.h"
5613 static inline void path_get_longterm(struct path *path)
5614 @@ -96,6 +97,7 @@ void free_fs_struct(struct fs_struct *fs
5616 path_put_longterm(&fs->root);
5617 path_put_longterm(&fs->pwd);
5618 + atomic_dec(&vs_global_fs);
5619 kmem_cache_free(fs_cachep, fs);
5622 @@ -135,6 +137,7 @@ struct fs_struct *copy_fs_struct(struct
5624 path_get_longterm(&fs->pwd);
5625 spin_unlock(&old->lock);
5626 + atomic_inc(&vs_global_fs);
5630 diff -NurpP --minimal linux-3.0/fs/gfs2/file.c linux-3.0-vs2.3.1-pre7/fs/gfs2/file.c
5631 --- linux-3.0/fs/gfs2/file.c 2011-07-22 11:18:05.000000000 +0200
5632 +++ linux-3.0-vs2.3.1-pre7/fs/gfs2/file.c 2011-06-10 22:11:24.000000000 +0200
5633 @@ -134,6 +134,9 @@ static const u32 fsflags_to_gfs2[32] = {
5634 [7] = GFS2_DIF_NOATIME,
5635 [12] = GFS2_DIF_EXHASH,
5636 [14] = GFS2_DIF_INHERIT_JDATA,
5637 + [27] = GFS2_DIF_IXUNLINK,
5638 + [26] = GFS2_DIF_BARRIER,
5639 + [29] = GFS2_DIF_COW,
5642 static const u32 gfs2_to_fsflags[32] = {
5643 @@ -143,6 +146,9 @@ static const u32 gfs2_to_fsflags[32] = {
5644 [gfs2fl_NoAtime] = FS_NOATIME_FL,
5645 [gfs2fl_ExHash] = FS_INDEX_FL,
5646 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
5647 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
5648 + [gfs2fl_Barrier] = FS_BARRIER_FL,
5649 + [gfs2fl_Cow] = FS_COW_FL,
5652 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
5653 @@ -173,10 +179,16 @@ void gfs2_set_inode_flags(struct inode *
5655 struct gfs2_inode *ip = GFS2_I(inode);
5656 unsigned int flags = inode->i_flags;
5657 + unsigned int vflags = inode->i_vflags;
5659 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5660 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5662 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
5663 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
5664 flags |= S_IMMUTABLE;
5665 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
5666 + flags |= S_IXUNLINK;
5668 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
5670 if (ip->i_diskflags & GFS2_DIF_NOATIME)
5671 @@ -184,6 +196,43 @@ void gfs2_set_inode_flags(struct inode *
5672 if (ip->i_diskflags & GFS2_DIF_SYNC)
5674 inode->i_flags = flags;
5676 + vflags &= ~(V_BARRIER | V_COW);
5678 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
5679 + vflags |= V_BARRIER;
5680 + if (ip->i_diskflags & GFS2_DIF_COW)
5682 + inode->i_vflags = vflags;
5685 +void gfs2_get_inode_flags(struct inode *inode)
5687 + struct gfs2_inode *ip = GFS2_I(inode);
5688 + unsigned int flags = inode->i_flags;
5689 + unsigned int vflags = inode->i_vflags;
5691 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
5692 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
5693 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
5694 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
5696 + if (flags & S_IMMUTABLE)
5697 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
5698 + if (flags & S_IXUNLINK)
5699 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
5701 + if (flags & S_APPEND)
5702 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
5703 + if (flags & S_NOATIME)
5704 + ip->i_diskflags |= GFS2_DIF_NOATIME;
5705 + if (flags & S_SYNC)
5706 + ip->i_diskflags |= GFS2_DIF_SYNC;
5708 + if (vflags & V_BARRIER)
5709 + ip->i_diskflags |= GFS2_DIF_BARRIER;
5710 + if (vflags & V_COW)
5711 + ip->i_diskflags |= GFS2_DIF_COW;
5714 /* Flags that can be set by user space */
5715 @@ -295,6 +344,37 @@ static int gfs2_set_flags(struct file *f
5716 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
5719 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
5721 + struct gfs2_inode *ip = GFS2_I(inode);
5722 + struct gfs2_sbd *sdp = GFS2_SB(inode);
5723 + struct buffer_head *bh;
5724 + struct gfs2_holder gh;
5727 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
5730 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
5733 + error = gfs2_meta_inode_buffer(ip, &bh);
5735 + goto out_trans_end;
5736 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
5737 + inode->i_flags = flags;
5738 + inode->i_vflags = vflags;
5739 + gfs2_get_inode_flags(inode);
5740 + gfs2_dinode_out(ip, bh->b_data);
5742 + gfs2_set_aops(inode);
5744 + gfs2_trans_end(sdp);
5746 + gfs2_glock_dq_uninit(&gh);
5750 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5753 diff -NurpP --minimal linux-3.0/fs/gfs2/inode.h linux-3.0-vs2.3.1-pre7/fs/gfs2/inode.h
5754 --- linux-3.0/fs/gfs2/inode.h 2011-07-22 11:18:05.000000000 +0200
5755 +++ linux-3.0-vs2.3.1-pre7/fs/gfs2/inode.h 2011-06-10 22:11:24.000000000 +0200
5756 @@ -120,6 +120,7 @@ extern const struct file_operations gfs2
5757 extern const struct file_operations gfs2_dir_fops_nolock;
5759 extern void gfs2_set_inode_flags(struct inode *inode);
5760 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
5762 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
5763 extern const struct file_operations gfs2_file_fops;
5764 diff -NurpP --minimal linux-3.0/fs/inode.c linux-3.0-vs2.3.1-pre7/fs/inode.c
5765 --- linux-3.0/fs/inode.c 2011-07-22 11:18:05.000000000 +0200
5766 +++ linux-3.0-vs2.3.1-pre7/fs/inode.c 2011-07-01 11:35:34.000000000 +0200
5768 #include <linux/ima.h>
5769 #include <linux/cred.h>
5770 #include <linux/buffer_head.h> /* for inode_has_buffers */
5771 +#include <linux/vs_tag.h>
5772 #include "internal.h"
5775 @@ -146,6 +147,9 @@ int inode_init_always(struct super_block
5776 struct address_space *const mapping = &inode->i_data;
5780 + /* essential because of inode slab reuse */
5782 inode->i_blkbits = sb->s_blocksize_bits;
5784 atomic_set(&inode->i_count, 1);
5785 @@ -166,6 +170,7 @@ int inode_init_always(struct super_block
5786 inode->i_bdev = NULL;
5787 inode->i_cdev = NULL;
5789 + inode->i_mdev = 0;
5790 inode->dirtied_when = 0;
5792 if (security_inode_alloc(inode))
5793 @@ -404,6 +409,8 @@ void __insert_inode_hash(struct inode *i
5795 EXPORT_SYMBOL(__insert_inode_hash);
5797 +EXPORT_SYMBOL_GPL(__iget);
5800 * remove_inode_hash - remove an inode from the hash
5801 * @inode: inode to unhash
5802 @@ -1643,9 +1650,11 @@ void init_special_inode(struct inode *in
5803 if (S_ISCHR(mode)) {
5804 inode->i_fop = &def_chr_fops;
5805 inode->i_rdev = rdev;
5806 + inode->i_mdev = rdev;
5807 } else if (S_ISBLK(mode)) {
5808 inode->i_fop = &def_blk_fops;
5809 inode->i_rdev = rdev;
5810 + inode->i_mdev = rdev;
5811 } else if (S_ISFIFO(mode))
5812 inode->i_fop = &def_fifo_fops;
5813 else if (S_ISSOCK(mode))
5814 @@ -1674,6 +1683,7 @@ void inode_init_owner(struct inode *inod
5816 inode->i_gid = current_fsgid();
5817 inode->i_mode = mode;
5818 + inode->i_tag = dx_current_fstag(inode->i_sb);
5820 EXPORT_SYMBOL(inode_init_owner);
5822 diff -NurpP --minimal linux-3.0/fs/ioctl.c linux-3.0-vs2.3.1-pre7/fs/ioctl.c
5823 --- linux-3.0/fs/ioctl.c 2011-05-22 16:17:52.000000000 +0200
5824 +++ linux-3.0-vs2.3.1-pre7/fs/ioctl.c 2011-06-10 22:11:24.000000000 +0200
5826 #include <linux/writeback.h>
5827 #include <linux/buffer_head.h>
5828 #include <linux/falloc.h>
5829 +#include <linux/proc_fs.h>
5830 +#include <linux/vserver/inode.h>
5831 +#include <linux/vs_tag.h>
5833 #include <asm/ioctls.h>
5835 diff -NurpP --minimal linux-3.0/fs/ioprio.c linux-3.0-vs2.3.1-pre7/fs/ioprio.c
5836 --- linux-3.0/fs/ioprio.c 2011-01-05 21:50:24.000000000 +0100
5837 +++ linux-3.0-vs2.3.1-pre7/fs/ioprio.c 2011-06-10 22:11:24.000000000 +0200
5839 #include <linux/syscalls.h>
5840 #include <linux/security.h>
5841 #include <linux/pid_namespace.h>
5842 +#include <linux/vs_base.h>
5844 int set_task_ioprio(struct task_struct *task, int ioprio)
5846 @@ -119,6 +120,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
5848 pgrp = find_vpid(who);
5849 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
5850 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5852 ret = set_task_ioprio(p, ioprio);
5855 @@ -208,6 +211,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
5857 pgrp = find_vpid(who);
5858 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
5859 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
5861 tmpio = get_task_ioprio(p);
5864 diff -NurpP --minimal linux-3.0/fs/jfs/file.c linux-3.0-vs2.3.1-pre7/fs/jfs/file.c
5865 --- linux-3.0/fs/jfs/file.c 2011-07-22 11:18:05.000000000 +0200
5866 +++ linux-3.0-vs2.3.1-pre7/fs/jfs/file.c 2011-07-01 11:35:34.000000000 +0200
5867 @@ -102,7 +102,8 @@ int jfs_setattr(struct dentry *dentry, s
5868 if (is_quota_modification(inode, iattr))
5869 dquot_initialize(inode);
5870 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
5871 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
5872 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
5873 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
5874 rc = dquot_transfer(inode, iattr);
5877 @@ -133,6 +134,7 @@ const struct inode_operations jfs_file_i
5878 #ifdef CONFIG_JFS_POSIX_ACL
5879 .check_acl = jfs_check_acl,
5881 + .sync_flags = jfs_sync_flags,
5884 const struct file_operations jfs_file_operations = {
5885 diff -NurpP --minimal linux-3.0/fs/jfs/ioctl.c linux-3.0-vs2.3.1-pre7/fs/jfs/ioctl.c
5886 --- linux-3.0/fs/jfs/ioctl.c 2011-05-22 16:17:52.000000000 +0200
5887 +++ linux-3.0-vs2.3.1-pre7/fs/jfs/ioctl.c 2011-06-10 22:11:24.000000000 +0200
5889 #include <linux/mount.h>
5890 #include <linux/time.h>
5891 #include <linux/sched.h>
5892 +#include <linux/mount.h>
5893 #include <asm/current.h>
5894 #include <asm/uaccess.h>
5896 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
5900 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
5902 + inode->i_flags = flags;
5903 + inode->i_vflags = vflags;
5904 + jfs_get_inode_flags(JFS_IP(inode));
5905 + inode->i_ctime = CURRENT_TIME_SEC;
5906 + mark_inode_dirty(inode);
5910 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5912 struct inode *inode = filp->f_dentry->d_inode;
5913 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
5914 if (!S_ISDIR(inode->i_mode))
5915 flags &= ~JFS_DIRSYNC_FL;
5917 + if (IS_BARRIER(inode)) {
5918 + vxwprintk_task(1, "messing with the barrier.");
5922 /* Is it quota file? Do not allow user to mess with it */
5923 if (IS_NOQUOTA(inode)) {
5925 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
5926 * the relevant capability.
5928 if ((oldflags & JFS_IMMUTABLE_FL) ||
5929 - ((flags ^ oldflags) &
5930 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
5931 + ((flags ^ oldflags) & (JFS_APPEND_FL |
5932 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
5933 if (!capable(CAP_LINUX_IMMUTABLE)) {
5934 mutex_unlock(&inode->i_mutex);
5936 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
5940 - flags = flags & JFS_FL_USER_MODIFIABLE;
5941 + flags &= JFS_FL_USER_MODIFIABLE;
5942 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
5943 jfs_inode->mode2 = flags;
5945 diff -NurpP --minimal linux-3.0/fs/jfs/jfs_dinode.h linux-3.0-vs2.3.1-pre7/fs/jfs/jfs_dinode.h
5946 --- linux-3.0/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
5947 +++ linux-3.0-vs2.3.1-pre7/fs/jfs/jfs_dinode.h 2011-06-10 22:11:24.000000000 +0200
5948 @@ -161,9 +161,13 @@ struct dinode {
5950 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
5951 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
5952 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
5954 -#define JFS_FL_USER_VISIBLE 0x03F80000
5955 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
5956 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
5957 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
5959 +#define JFS_FL_USER_VISIBLE 0x07F80000
5960 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
5961 #define JFS_FL_INHERIT 0x03C80000
5963 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
5964 diff -NurpP --minimal linux-3.0/fs/jfs/jfs_filsys.h linux-3.0-vs2.3.1-pre7/fs/jfs/jfs_filsys.h
5965 --- linux-3.0/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
5966 +++ linux-3.0-vs2.3.1-pre7/fs/jfs/jfs_filsys.h 2011-06-10 22:11:24.000000000 +0200
5968 #define JFS_NAME_MAX 255
5969 #define JFS_PATH_MAX BPSIZE
5971 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
5974 * file system state (superblock state)
5975 diff -NurpP --minimal linux-3.0/fs/jfs/jfs_imap.c linux-3.0-vs2.3.1-pre7/fs/jfs/jfs_imap.c
5976 --- linux-3.0/fs/jfs/jfs_imap.c 2011-07-22 11:18:05.000000000 +0200
5977 +++ linux-3.0-vs2.3.1-pre7/fs/jfs/jfs_imap.c 2011-07-01 11:35:34.000000000 +0200
5979 #include <linux/pagemap.h>
5980 #include <linux/quotaops.h>
5981 #include <linux/slab.h>
5982 +#include <linux/vs_tag.h>
5984 #include "jfs_incore.h"
5985 #include "jfs_inode.h"
5986 @@ -3058,6 +3059,8 @@ static int copy_from_dinode(struct dinod
5988 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
5989 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
5993 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
5994 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
5995 @@ -3078,14 +3081,18 @@ static int copy_from_dinode(struct dinod
5997 ip->i_nlink = le32_to_cpu(dip->di_nlink);
5999 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
6000 + uid = le32_to_cpu(dip->di_uid);
6001 + gid = le32_to_cpu(dip->di_gid);
6002 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
6004 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
6006 ip->i_uid = jfs_ip->saved_uid;
6008 ip->i_uid = sbi->uid;
6011 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
6012 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
6014 ip->i_gid = jfs_ip->saved_gid;
6016 @@ -3150,14 +3157,12 @@ static void copy_to_dinode(struct dinode
6017 dip->di_size = cpu_to_le64(ip->i_size);
6018 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
6019 dip->di_nlink = cpu_to_le32(ip->i_nlink);
6020 - if (sbi->uid == -1)
6021 - dip->di_uid = cpu_to_le32(ip->i_uid);
6023 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
6024 - if (sbi->gid == -1)
6025 - dip->di_gid = cpu_to_le32(ip->i_gid);
6027 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
6029 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
6030 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
6031 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
6032 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
6034 jfs_get_inode_flags(jfs_ip);
6036 * mode2 is only needed for storing the higher order bits.
6037 diff -NurpP --minimal linux-3.0/fs/jfs/jfs_inode.c linux-3.0-vs2.3.1-pre7/fs/jfs/jfs_inode.c
6038 --- linux-3.0/fs/jfs/jfs_inode.c 2010-08-02 16:52:49.000000000 +0200
6039 +++ linux-3.0-vs2.3.1-pre7/fs/jfs/jfs_inode.c 2011-06-10 22:11:24.000000000 +0200
6042 #include <linux/fs.h>
6043 #include <linux/quotaops.h>
6044 +#include <linux/vs_tag.h>
6045 #include "jfs_incore.h"
6046 #include "jfs_inode.h"
6047 #include "jfs_filsys.h"
6048 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
6050 unsigned int flags = JFS_IP(inode)->mode2;
6052 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
6053 - S_NOATIME | S_DIRSYNC | S_SYNC);
6054 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
6055 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
6057 if (flags & JFS_IMMUTABLE_FL)
6058 inode->i_flags |= S_IMMUTABLE;
6059 + if (flags & JFS_IXUNLINK_FL)
6060 + inode->i_flags |= S_IXUNLINK;
6062 + if (flags & JFS_SYNC_FL)
6063 + inode->i_flags |= S_SYNC;
6064 if (flags & JFS_APPEND_FL)
6065 inode->i_flags |= S_APPEND;
6066 if (flags & JFS_NOATIME_FL)
6067 inode->i_flags |= S_NOATIME;
6068 if (flags & JFS_DIRSYNC_FL)
6069 inode->i_flags |= S_DIRSYNC;
6070 - if (flags & JFS_SYNC_FL)
6071 - inode->i_flags |= S_SYNC;
6073 + inode->i_vflags &= ~(V_BARRIER | V_COW);
6075 + if (flags & JFS_BARRIER_FL)
6076 + inode->i_vflags |= V_BARRIER;
6077 + if (flags & JFS_COW_FL)
6078 + inode->i_vflags |= V_COW;
6081 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
6083 unsigned int flags = jfs_ip->vfs_inode.i_flags;
6084 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
6086 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
6087 + JFS_APPEND_FL | JFS_NOATIME_FL |
6088 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
6089 + JFS_BARRIER_FL | JFS_COW_FL);
6091 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
6092 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
6093 if (flags & S_IMMUTABLE)
6094 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
6095 + if (flags & S_IXUNLINK)
6096 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
6098 if (flags & S_APPEND)
6099 jfs_ip->mode2 |= JFS_APPEND_FL;
6100 if (flags & S_NOATIME)
6101 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
6102 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
6104 jfs_ip->mode2 |= JFS_SYNC_FL;
6106 + if (vflags & V_BARRIER)
6107 + jfs_ip->mode2 |= JFS_BARRIER_FL;
6108 + if (vflags & V_COW)
6109 + jfs_ip->mode2 |= JFS_COW_FL;
6113 diff -NurpP --minimal linux-3.0/fs/jfs/jfs_inode.h linux-3.0-vs2.3.1-pre7/fs/jfs/jfs_inode.h
6114 --- linux-3.0/fs/jfs/jfs_inode.h 2011-07-22 11:18:05.000000000 +0200
6115 +++ linux-3.0-vs2.3.1-pre7/fs/jfs/jfs_inode.h 2011-06-10 22:11:24.000000000 +0200
6116 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
6117 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
6118 int fh_len, int fh_type);
6119 extern void jfs_set_inode_flags(struct inode *);
6120 +extern int jfs_sync_flags(struct inode *, int, int);
6121 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
6122 extern int jfs_setattr(struct dentry *, struct iattr *);
6124 diff -NurpP --minimal linux-3.0/fs/jfs/namei.c linux-3.0-vs2.3.1-pre7/fs/jfs/namei.c
6125 --- linux-3.0/fs/jfs/namei.c 2011-05-22 16:17:53.000000000 +0200
6126 +++ linux-3.0-vs2.3.1-pre7/fs/jfs/namei.c 2011-06-10 22:11:24.000000000 +0200
6128 #include <linux/ctype.h>
6129 #include <linux/quotaops.h>
6130 #include <linux/exportfs.h>
6131 +#include <linux/vs_tag.h>
6132 #include "jfs_incore.h"
6133 #include "jfs_superblock.h"
6134 #include "jfs_inode.h"
6135 @@ -1486,6 +1487,7 @@ static struct dentry *jfs_lookup(struct
6136 return ERR_CAST(ip);
6139 + dx_propagate_tag(nd, ip);
6140 return d_splice_alias(ip, dentry);
6143 @@ -1550,6 +1552,7 @@ const struct inode_operations jfs_dir_in
6144 #ifdef CONFIG_JFS_POSIX_ACL
6145 .check_acl = jfs_check_acl,
6147 + .sync_flags = jfs_sync_flags,
6150 const struct file_operations jfs_dir_operations = {
6151 diff -NurpP --minimal linux-3.0/fs/jfs/super.c linux-3.0-vs2.3.1-pre7/fs/jfs/super.c
6152 --- linux-3.0/fs/jfs/super.c 2011-05-22 16:17:53.000000000 +0200
6153 +++ linux-3.0-vs2.3.1-pre7/fs/jfs/super.c 2011-06-10 22:11:24.000000000 +0200
6154 @@ -198,7 +198,8 @@ static void jfs_put_super(struct super_b
6156 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
6157 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
6158 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
6159 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
6160 + Opt_tag, Opt_notag, Opt_tagid
6163 static const match_table_t tokens = {
6164 @@ -208,6 +209,10 @@ static const match_table_t tokens = {
6165 {Opt_resize, "resize=%u"},
6166 {Opt_resize_nosize, "resize"},
6167 {Opt_errors, "errors=%s"},
6169 + {Opt_notag, "notag"},
6170 + {Opt_tagid, "tagid=%u"},
6171 + {Opt_tag, "tagxid"},
6172 {Opt_ignore, "noquota"},
6173 {Opt_ignore, "quota"},
6174 {Opt_usrquota, "usrquota"},
6175 @@ -342,6 +347,20 @@ static int parse_options(char *options,
6179 +#ifndef CONFIG_TAGGING_NONE
6181 + *flag |= JFS_TAGGED;
6184 + *flag &= JFS_TAGGED;
6187 +#ifdef CONFIG_PROPAGATE
6190 + *flag |= JFS_TAGGED;
6194 printk("jfs: Unrecognized mount option \"%s\" "
6195 " or missing value\n", p);
6196 @@ -373,6 +392,12 @@ static int jfs_remount(struct super_bloc
6200 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
6201 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
6207 if (sb->s_flags & MS_RDONLY) {
6209 @@ -455,6 +480,9 @@ static int jfs_fill_super(struct super_b
6210 #ifdef CONFIG_JFS_POSIX_ACL
6211 sb->s_flags |= MS_POSIXACL;
6213 + /* map mount option tagxid */
6214 + if (sbi->flag & JFS_TAGGED)
6215 + sb->s_flags |= MS_TAGGED;
6218 printk(KERN_ERR "resize option for remount only\n");
6219 diff -NurpP --minimal linux-3.0/fs/libfs.c linux-3.0-vs2.3.1-pre7/fs/libfs.c
6220 --- linux-3.0/fs/libfs.c 2011-07-22 11:18:05.000000000 +0200
6221 +++ linux-3.0-vs2.3.1-pre7/fs/libfs.c 2011-07-22 11:20:39.000000000 +0200
6222 @@ -133,7 +133,8 @@ static inline unsigned char dt_type(stru
6223 * both impossible due to the lock on directory.
6226 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
6227 +static inline int do_dcache_readdir_filter(struct file *filp,
6228 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
6230 struct dentry *dentry = filp->f_path.dentry;
6231 struct dentry *cursor = filp->private_data;
6232 @@ -164,6 +165,8 @@ int dcache_readdir(struct file * filp, v
6233 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
6234 struct dentry *next;
6235 next = list_entry(p, struct dentry, d_u.d_child);
6236 + if (filter && !filter(next))
6238 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
6239 if (!simple_positive(next)) {
6240 spin_unlock(&next->d_lock);
6241 @@ -190,6 +193,17 @@ int dcache_readdir(struct file * filp, v
6245 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
6247 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
6250 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
6251 + int (*filter)(struct dentry *))
6253 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
6256 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
6259 @@ -965,6 +979,7 @@ EXPORT_SYMBOL(dcache_dir_close);
6260 EXPORT_SYMBOL(dcache_dir_lseek);
6261 EXPORT_SYMBOL(dcache_dir_open);
6262 EXPORT_SYMBOL(dcache_readdir);
6263 +EXPORT_SYMBOL(dcache_readdir_filter);
6264 EXPORT_SYMBOL(generic_read_dir);
6265 EXPORT_SYMBOL(mount_pseudo);
6266 EXPORT_SYMBOL(simple_write_begin);
6267 diff -NurpP --minimal linux-3.0/fs/locks.c linux-3.0-vs2.3.1-pre7/fs/locks.c
6268 --- linux-3.0/fs/locks.c 2011-07-22 11:18:05.000000000 +0200
6269 +++ linux-3.0-vs2.3.1-pre7/fs/locks.c 2011-07-19 00:51:58.000000000 +0200
6271 #include <linux/time.h>
6272 #include <linux/rcupdate.h>
6273 #include <linux/pid_namespace.h>
6274 +#include <linux/vs_base.h>
6275 +#include <linux/vs_limit.h>
6277 #include <asm/uaccess.h>
6279 @@ -171,13 +173,19 @@ static void locks_init_lock_always(struc
6282 fl->fl_start = fl->fl_end = 0;
6287 /* Allocate an empty lock structure. */
6288 struct file_lock *locks_alloc_lock(void)
6290 - struct file_lock *fl = kmem_cache_alloc(filelock_cache, GFP_KERNEL);
6291 + struct file_lock *fl;
6293 + if (!vx_locks_avail(1))
6296 + fl = kmem_cache_alloc(filelock_cache, GFP_KERNEL);
6298 locks_init_lock_always(fl);
6300 @@ -208,6 +216,7 @@ void locks_free_lock(struct file_lock *f
6301 BUG_ON(!list_empty(&fl->fl_block));
6302 BUG_ON(!list_empty(&fl->fl_link));
6305 locks_release_private(fl);
6306 kmem_cache_free(filelock_cache, fl);
6308 @@ -272,6 +281,7 @@ void locks_copy_lock(struct file_lock *n
6309 new->fl_file = fl->fl_file;
6310 new->fl_ops = fl->fl_ops;
6311 new->fl_lmops = fl->fl_lmops;
6312 + new->fl_xid = fl->fl_xid;
6314 locks_copy_private(new, fl);
6316 @@ -310,6 +320,11 @@ static int flock_make_lock(struct file *
6317 fl->fl_flags = FL_FLOCK;
6319 fl->fl_end = OFFSET_MAX;
6321 + vxd_assert(filp->f_xid == vx_current_xid(),
6322 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6323 + fl->fl_xid = filp->f_xid;
6328 @@ -459,6 +474,7 @@ static int lease_init(struct file *filp,
6330 fl->fl_owner = current->files;
6331 fl->fl_pid = current->tgid;
6332 + fl->fl_xid = vx_current_xid();
6335 fl->fl_flags = FL_LEASE;
6336 @@ -478,6 +494,11 @@ static struct file_lock *lease_alloc(str
6338 return ERR_PTR(error);
6340 + fl->fl_xid = vx_current_xid();
6342 + vxd_assert(filp->f_xid == fl->fl_xid,
6343 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
6345 error = lease_init(filp, type, fl);
6347 locks_free_lock(fl);
6348 @@ -779,6 +800,7 @@ static int flock_lock_file(struct file *
6352 + new_fl->fl_xid = -1;
6354 for_each_lock(inode, before) {
6355 struct file_lock *fl = *before;
6356 @@ -799,6 +821,7 @@ find_conflict:
6358 locks_copy_lock(new_fl, request);
6359 locks_insert_lock(before, new_fl);
6360 + vx_locks_inc(new_fl);
6364 @@ -809,7 +832,8 @@ out:
6368 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
6369 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
6370 + struct file_lock *conflock, xid_t xid)
6372 struct file_lock *fl;
6373 struct file_lock *new_fl = NULL;
6374 @@ -819,6 +843,8 @@ static int __posix_lock_file(struct inod
6375 struct file_lock **before;
6376 int error, added = 0;
6378 + vxd_assert(xid == vx_current_xid(),
6379 + "xid(%d) == current(%d)", xid, vx_current_xid());
6381 * We may need two file_lock structures for this operation,
6382 * so we get them in advance to avoid races.
6383 @@ -829,7 +855,11 @@ static int __posix_lock_file(struct inod
6384 (request->fl_type != F_UNLCK ||
6385 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
6386 new_fl = locks_alloc_lock();
6387 + new_fl->fl_xid = xid;
6388 + vx_locks_inc(new_fl);
6389 new_fl2 = locks_alloc_lock();
6390 + new_fl2->fl_xid = xid;
6391 + vx_locks_inc(new_fl2);
6395 @@ -1028,7 +1058,8 @@ static int __posix_lock_file(struct inod
6396 int posix_lock_file(struct file *filp, struct file_lock *fl,
6397 struct file_lock *conflock)
6399 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
6400 + return __posix_lock_file(filp->f_path.dentry->d_inode,
6401 + fl, conflock, filp->f_xid);
6403 EXPORT_SYMBOL(posix_lock_file);
6405 @@ -1118,7 +1149,7 @@ int locks_mandatory_area(int read_write,
6406 fl.fl_end = offset + count - 1;
6409 - error = __posix_lock_file(inode, &fl, NULL);
6410 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
6411 if (error != FILE_LOCK_DEFERRED)
6413 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
6414 @@ -1431,6 +1462,7 @@ int generic_setlease(struct file *filp,
6417 locks_insert_lock(before, lease);
6418 + vx_locks_inc(lease);
6422 @@ -1815,6 +1847,11 @@ int fcntl_setlk(unsigned int fd, struct
6423 if (file_lock == NULL)
6426 + vxd_assert(filp->f_xid == vx_current_xid(),
6427 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6428 + file_lock->fl_xid = filp->f_xid;
6429 + vx_locks_inc(file_lock);
6432 * This might block, so we do it before checking the inode.
6434 @@ -1933,6 +1970,11 @@ int fcntl_setlk64(unsigned int fd, struc
6435 if (file_lock == NULL)
6438 + vxd_assert(filp->f_xid == vx_current_xid(),
6439 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
6440 + file_lock->fl_xid = filp->f_xid;
6441 + vx_locks_inc(file_lock);
6444 * This might block, so we do it before checking the inode.
6446 @@ -2198,8 +2240,11 @@ static int locks_show(struct seq_file *f
6448 lock_get_status(f, fl, *((loff_t *)f->private), "");
6450 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
6451 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
6452 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
6454 lock_get_status(f, bfl, *((loff_t *)f->private), " ->");
6459 diff -NurpP --minimal linux-3.0/fs/namei.c linux-3.0-vs2.3.1-pre7/fs/namei.c
6460 --- linux-3.0/fs/namei.c 2011-07-22 11:18:05.000000000 +0200
6461 +++ linux-3.0-vs2.3.1-pre7/fs/namei.c 2011-07-23 17:04:13.000000000 +0200
6463 #include <linux/fcntl.h>
6464 #include <linux/device_cgroup.h>
6465 #include <linux/fs_struct.h>
6466 +#include <linux/proc_fs.h>
6467 +#include <linux/vserver/inode.h>
6468 +#include <linux/vs_base.h>
6469 +#include <linux/vs_tag.h>
6470 +#include <linux/vs_cowbl.h>
6471 +#include <linux/vs_device.h>
6472 +#include <linux/vs_context.h>
6473 +#include <linux/pid_namespace.h>
6474 #include <asm/uaccess.h>
6476 #include "internal.h"
6477 @@ -173,6 +181,84 @@ void putname(const char *name)
6478 EXPORT_SYMBOL(putname);
6481 +static inline int dx_barrier(const struct inode *inode)
6483 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
6484 + vxwprintk_task(1, "did hit the barrier.");
6490 +static int __dx_permission(const struct inode *inode, int mask)
6492 + if (dx_barrier(inode))
6495 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
6496 + /* devpts is xid tagged */
6497 + if (S_ISDIR(inode->i_mode) ||
6498 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
6501 + /* just pretend we didn't find anything */
6504 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
6505 + struct proc_dir_entry *de = PDE(inode);
6507 + if (de && !vx_hide_check(0, de->vx_flags))
6510 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
6512 + struct task_struct *tsk;
6514 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
6515 + vx_flags(VXF_STATE_SETUP, 0))
6518 + pid = PROC_I(inode)->pid;
6522 + tsk = pid_task(pid, PIDTYPE_PID);
6523 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
6524 + tsk, (tsk ? vx_task_xid(tsk) : 0));
6525 + if (tsk && vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P))
6529 + /* FIXME: Should we block some entries here? */
6534 + if (dx_notagcheck(inode->i_sb) ||
6535 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
6544 +int dx_permission(const struct inode *inode, int mask)
6546 + int ret = __dx_permission(inode, mask);
6547 + if (unlikely(ret)) {
6548 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
6549 + if (inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
6552 + "denied [0x%x] access to inode %s:%p[#%d,%lu]",
6553 + mask, inode->i_sb->s_id, inode, inode->i_tag,
6560 * This does basic POSIX ACL permission checking
6562 @@ -283,10 +369,14 @@ int inode_permission(struct inode *inode
6564 * Nobody gets write access to an immutable file.
6566 - if (IS_IMMUTABLE(inode))
6567 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
6571 + retval = dx_permission(inode, mask);
6575 if (inode->i_op->permission)
6576 retval = inode->i_op->permission(inode, mask, 0);
6578 @@ -582,6 +672,9 @@ static inline int exec_permission(struct
6580 struct user_namespace *ns = inode_userns(inode);
6582 + if (dx_barrier(inode))
6585 if (inode->i_op->permission) {
6586 ret = inode->i_op->permission(inode, MAY_EXEC, flags);
6588 @@ -1089,7 +1182,8 @@ static void follow_dotdot(struct nameida
6590 if (nd->path.dentry == nd->root.dentry &&
6591 nd->path.mnt == nd->root.mnt) {
6593 + /* for sane '/' avoid follow_mount() */
6596 if (nd->path.dentry != nd->path.mnt->mnt_root) {
6597 /* rare case of legitimate dget_parent()... */
6598 @@ -1172,6 +1266,9 @@ static int do_lookup(struct nameidata *n
6603 + /* FIXME: check dx permission */
6606 path->dentry = dentry;
6607 if (unlikely(!__follow_mount_rcu(nd, path, inode)))
6608 @@ -1220,6 +1317,8 @@ retry:
6612 + /* FIXME: check dx permission */
6615 path->dentry = dentry;
6616 err = follow_managed(path, nd->flags);
6617 @@ -1839,7 +1938,7 @@ static int may_delete(struct inode *dir,
6620 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
6621 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
6622 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
6625 if (!S_ISDIR(victim->d_inode->i_mode))
6626 @@ -1966,6 +2065,15 @@ static int may_open(struct path *path, i
6630 +#ifdef CONFIG_VSERVER_COWBL
6631 + if (IS_COW(inode) &&
6632 + ((flag & O_ACCMODE) != O_RDONLY)) {
6633 + if (IS_COW_LINK(inode))
6635 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
6636 + mark_inode_dirty(inode);
6639 error = inode_permission(inode, acc_mode);
6642 @@ -2859,7 +2967,7 @@ int vfs_link(struct dentry *old_dentry,
6644 * A link to an append-only or immutable file cannot be created.
6646 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
6647 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
6649 if (!dir->i_op->link)
6651 @@ -3245,6 +3353,222 @@ int vfs_follow_link(struct nameidata *nd
6652 return __vfs_follow_link(nd, link);
6656 +#ifdef CONFIG_VSERVER_COWBL
6658 +#include <linux/file.h>
6661 +long do_cow_splice(struct file *in, struct file *out, size_t len)
6665 + return do_splice_direct(in, &ppos, out, len, 0);
6668 +struct dentry *cow_break_link(const char *pathname)
6670 + int ret, mode, pathlen, redo = 0;
6671 + struct nameidata old_nd, dir_nd;
6672 + struct path old_path, new_path;
6673 + struct dentry *dir, *res = NULL;
6674 + struct file *old_file;
6675 + struct file *new_file;
6676 + char *to, *path, pad='\251';
6679 + vxdprintk(VXD_CBIT(misc, 1),
6680 + "cow_break_link(" VS_Q("%s") ")", pathname);
6681 + path = kmalloc(PATH_MAX, GFP_KERNEL);
6686 + /* old_nd will have refs to dentry and mnt */
6687 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
6688 + vxdprintk(VXD_CBIT(misc, 2), "do_path_lookup(old): %d", ret);
6690 + goto out_free_path;
6692 + old_path = old_nd.path;
6693 + mode = old_path.dentry->d_inode->i_mode;
6695 + to = d_path(&old_path, path, PATH_MAX-2);
6696 + pathlen = strlen(to);
6697 + vxdprintk(VXD_CBIT(misc, 2),
6698 + "old path " VS_Q("%s") " [" VS_Q("%.*s") ":%d]", to,
6699 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
6700 + old_path.dentry->d_name.len);
6702 + to[pathlen + 1] = 0;
6704 + to[pathlen] = pad--;
6706 + if (pad <= '\240')
6709 + vxdprintk(VXD_CBIT(misc, 1), "temp copy " VS_Q("%s"), to);
6710 + /* dir_nd will have refs to dentry and mnt */
6711 + ret = do_path_lookup(AT_FDCWD, to,
6712 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
6713 + vxdprintk(VXD_CBIT(misc, 2),
6714 + "do_path_lookup(new): %d", ret);
6718 + /* this puppy downs the inode mutex */
6719 + new_path.dentry = lookup_create(&dir_nd, 0);
6720 + if (!new_path.dentry || IS_ERR(new_path.dentry)) {
6721 + vxdprintk(VXD_CBIT(misc, 2),
6722 + "lookup_create(new): %p", new_path.dentry);
6723 + mutex_unlock(&dir_nd.path.dentry->d_inode->i_mutex);
6724 + path_put(&dir_nd.path);
6727 + vxdprintk(VXD_CBIT(misc, 2),
6728 + "lookup_create(new): %p [" VS_Q("%.*s") ":%d]",
6730 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
6731 + new_path.dentry->d_name.len);
6732 + dir = dir_nd.path.dentry;
6734 + ret = vfs_create(dir_nd.path.dentry->d_inode, new_path.dentry, mode, &dir_nd);
6735 + vxdprintk(VXD_CBIT(misc, 2),
6736 + "vfs_create(new): %d", ret);
6737 + if (ret == -EEXIST) {
6738 + mutex_unlock(&dir->d_inode->i_mutex);
6739 + dput(new_path.dentry);
6740 + path_put(&dir_nd.path);
6744 + goto out_unlock_new;
6746 + /* drop out early, ret passes ENOENT */
6748 + if ((redo = d_unhashed(old_path.dentry)))
6749 + goto out_unlock_new;
6751 + new_path.mnt = dir_nd.path.mnt;
6752 + dget(old_path.dentry);
6753 + mntget(old_path.mnt);
6754 + /* this one cleans up the dentry/mnt in case of failure */
6755 + old_file = dentry_open(old_path.dentry, old_path.mnt,
6756 + O_RDONLY, current_cred());
6757 + vxdprintk(VXD_CBIT(misc, 2),
6758 + "dentry_open(old): %p", old_file);
6759 + if (!old_file || IS_ERR(old_file)) {
6760 + res = IS_ERR(old_file) ? (void *) old_file : res;
6761 + goto out_unlock_new;
6764 + dget(new_path.dentry);
6765 + mntget(new_path.mnt);
6766 + /* this one cleans up the dentry/mnt in case of failure */
6767 + new_file = dentry_open(new_path.dentry, new_path.mnt,
6768 + O_WRONLY, current_cred());
6769 + vxdprintk(VXD_CBIT(misc, 2),
6770 + "dentry_open(new): %p", new_file);
6772 + ret = IS_ERR(new_file) ? PTR_ERR(new_file) : -ENOENT;
6773 + if (!new_file || IS_ERR(new_file))
6774 + goto out_fput_old;
6776 + size = i_size_read(old_file->f_dentry->d_inode);
6777 + ret = do_cow_splice(old_file, new_file, size);
6778 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
6780 + goto out_fput_both;
6781 + } else if (ret < size) {
6783 + goto out_fput_both;
6785 + struct inode *old_inode = old_path.dentry->d_inode;
6786 + struct inode *new_inode = new_path.dentry->d_inode;
6787 + struct iattr attr = {
6788 + .ia_uid = old_inode->i_uid,
6789 + .ia_gid = old_inode->i_gid,
6790 + .ia_valid = ATTR_UID | ATTR_GID
6793 + setattr_copy(new_inode, &attr);
6794 + mark_inode_dirty(new_inode);
6797 + mutex_lock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
6799 + /* drop out late */
6801 + if ((redo = d_unhashed(old_path.dentry)))
6804 + vxdprintk(VXD_CBIT(misc, 2),
6805 + "vfs_rename: [" VS_Q("%*s") ":%d] -> [" VS_Q("%*s") ":%d]",
6806 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
6807 + new_path.dentry->d_name.len,
6808 + old_path.dentry->d_name.len, old_path.dentry->d_name.name,
6809 + old_path.dentry->d_name.len);
6810 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_path.dentry,
6811 + old_nd.path.dentry->d_parent->d_inode, old_path.dentry);
6812 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
6813 + res = new_path.dentry;
6816 + mutex_unlock(&old_path.dentry->d_inode->i_sb->s_vfs_rename_mutex);
6819 + vxdprintk(VXD_CBIT(misc, 3),
6820 + "fput(new_file=%p[#%ld])", new_file,
6821 + atomic_long_read(&new_file->f_count));
6825 + vxdprintk(VXD_CBIT(misc, 3),
6826 + "fput(old_file=%p[#%ld])", old_file,
6827 + atomic_long_read(&old_file->f_count));
6831 + mutex_unlock(&dir->d_inode->i_mutex);
6835 + /* error path cleanup */
6836 + vfs_unlink(dir->d_inode, new_path.dentry);
6837 + dput(new_path.dentry);
6841 + goto out_rel_both;
6842 + /* lookup dentry once again */
6843 + path_put(&old_nd.path);
6844 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
6846 + goto out_rel_both;
6848 + new_path.dentry = old_nd.path.dentry;
6849 + vxdprintk(VXD_CBIT(misc, 2),
6850 + "do_path_lookup(redo): %p [" VS_Q("%.*s") ":%d]",
6852 + new_path.dentry->d_name.len, new_path.dentry->d_name.name,
6853 + new_path.dentry->d_name.len);
6854 + dget(new_path.dentry);
6855 + res = new_path.dentry;
6858 + path_put(&dir_nd.path);
6860 + path_put(&old_nd.path);
6865 + res = ERR_PTR(ret);
6871 /* get the link contents into pagecache */
6872 static char *page_getlink(struct dentry * dentry, struct page **ppage)
6874 diff -NurpP --minimal linux-3.0/fs/namespace.c linux-3.0-vs2.3.1-pre7/fs/namespace.c
6875 --- linux-3.0/fs/namespace.c 2011-07-22 11:18:05.000000000 +0200
6876 +++ linux-3.0-vs2.3.1-pre7/fs/namespace.c 2011-07-23 16:43:31.000000000 +0200
6878 #include <linux/idr.h>
6879 #include <linux/fs_struct.h>
6880 #include <linux/fsnotify.h>
6881 +#include <linux/vs_base.h>
6882 +#include <linux/vs_context.h>
6883 +#include <linux/vs_tag.h>
6884 +#include <linux/vserver/space.h>
6885 +#include <linux/vserver/global.h>
6886 #include <asm/uaccess.h>
6887 #include <asm/unistd.h>
6889 @@ -679,6 +684,10 @@ vfs_kern_mount(struct file_system_type *
6891 return ERR_PTR(-ENODEV);
6893 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
6894 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
6895 + return ERR_PTR(-EPERM);
6897 mnt = alloc_vfsmnt(name);
6899 return ERR_PTR(-ENOMEM);
6900 @@ -724,6 +733,7 @@ static struct vfsmount *clone_mnt(struct
6901 mnt->mnt_root = dget(root);
6902 mnt->mnt_mountpoint = mnt->mnt_root;
6903 mnt->mnt_parent = mnt;
6904 + mnt->mnt_tag = old->mnt_tag;
6906 if (flag & CL_SLAVE) {
6907 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
6908 @@ -852,6 +862,31 @@ static inline void mangle(struct seq_fil
6909 seq_escape(m, s, " \t\n\\");
6912 +static int mnt_is_reachable(struct vfsmount *mnt)
6915 + struct dentry *point;
6918 + if (mnt == mnt->mnt_ns->root)
6921 + br_read_lock(vfsmount_lock);
6922 + root = current->fs->root;
6923 + point = root.dentry;
6925 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
6926 + point = mnt->mnt_mountpoint;
6927 + mnt = mnt->mnt_parent;
6930 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
6932 + br_read_unlock(vfsmount_lock);
6938 * Simple .show_options callback for filesystems which don't want to
6939 * implement more complex mount option showing.
6940 @@ -954,6 +989,8 @@ static int show_sb_opts(struct seq_file
6941 { MS_SYNCHRONOUS, ",sync" },
6942 { MS_DIRSYNC, ",dirsync" },
6943 { MS_MANDLOCK, ",mand" },
6944 + { MS_TAGGED, ",tag" },
6945 + { MS_NOTAGCHECK, ",notagcheck" },
6948 const struct proc_fs_info *fs_infop;
6949 @@ -1000,16 +1037,26 @@ static int show_vfsmnt(struct seq_file *
6951 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
6953 - if (mnt->mnt_sb->s_op->show_devname) {
6954 - err = mnt->mnt_sb->s_op->show_devname(m, mnt);
6957 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6959 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6962 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6963 + mnt == current->fs->root.mnt) {
6964 + seq_puts(m, "/dev/root / ");
6966 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
6967 + if (mnt->mnt_sb->s_op->show_devname) {
6968 + err = mnt->mnt_sb->s_op->show_devname(m, mnt);
6972 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
6975 + seq_path(m, &mnt_path, " \t\n\\");
6979 - seq_path(m, &mnt_path, " \t\n\\");
6981 show_type(m, mnt->mnt_sb);
6982 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
6983 err = show_sb_opts(m, mnt->mnt_sb);
6984 @@ -1039,6 +1086,11 @@ static int show_mountinfo(struct seq_fil
6985 struct path root = p->root;
6988 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6990 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6993 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
6994 MAJOR(sb->s_dev), MINOR(sb->s_dev));
6995 if (sb->s_op->show_path)
6996 @@ -1107,21 +1159,31 @@ static int show_vfsstat(struct seq_file
6997 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
7001 - if (mnt->mnt_sb->s_op->show_devname) {
7002 - err = mnt->mnt_sb->s_op->show_devname(m, mnt);
7003 + if (vx_flags(VXF_HIDE_MOUNT, 0))
7005 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
7008 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
7009 + mnt == current->fs->root.mnt) {
7010 + seq_puts(m, "device /dev/root mounted on / ");
7012 - if (mnt->mnt_devname) {
7013 - seq_puts(m, "device ");
7014 - mangle(m, mnt->mnt_devname);
7016 - seq_puts(m, "no device");
7019 + if (mnt->mnt_sb->s_op->show_devname) {
7020 + err = mnt->mnt_sb->s_op->show_devname(m, mnt);
7022 + if (mnt->mnt_devname) {
7023 + seq_puts(m, "device ");
7024 + mangle(m, mnt->mnt_devname);
7026 + seq_puts(m, "no device");
7030 - seq_puts(m, " mounted on ");
7031 - seq_path(m, &mnt_path, " \t\n\\");
7034 + seq_puts(m, " mounted on ");
7035 + seq_path(m, &mnt_path, " \t\n\\");
7039 /* file system type */
7040 seq_puts(m, "with fstype ");
7041 @@ -1380,7 +1442,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
7045 - if (!capable(CAP_SYS_ADMIN))
7046 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7049 retval = do_umount(path.mnt, flags);
7050 @@ -1406,7 +1468,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
7052 static int mount_is_safe(struct path *path)
7054 - if (capable(CAP_SYS_ADMIN))
7055 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7059 @@ -1716,7 +1778,7 @@ static int do_change_type(struct path *p
7063 - if (!capable(CAP_SYS_ADMIN))
7064 + if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
7067 if (path->dentry != path->mnt->mnt_root)
7068 @@ -1732,6 +1794,7 @@ static int do_change_type(struct path *p
7072 + // mnt->mnt_flags = mnt_flags;
7074 br_write_lock(vfsmount_lock);
7075 for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
7076 @@ -1747,12 +1810,14 @@ static int do_change_type(struct path *p
7077 * do loopback mount.
7079 static int do_loopback(struct path *path, char *old_name,
7081 + tag_t tag, unsigned long flags, int mnt_flags)
7083 LIST_HEAD(umount_list);
7084 struct path old_path;
7085 struct vfsmount *mnt = NULL;
7086 int err = mount_is_safe(path);
7087 + int recurse = flags & MS_REC;
7091 if (!old_name || !*old_name)
7092 @@ -1818,12 +1883,12 @@ static int change_mount_flags(struct vfs
7093 * on it - tough luck.
7095 static int do_remount(struct path *path, int flags, int mnt_flags,
7097 + void *data, xid_t xid)
7100 struct super_block *sb = path->mnt->mnt_sb;
7102 - if (!capable(CAP_SYS_ADMIN))
7103 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
7106 if (!check_mnt(path->mnt))
7107 @@ -1871,7 +1936,7 @@ static int do_move_mount(struct path *pa
7108 struct path old_path, parent_path;
7111 - if (!capable(CAP_SYS_ADMIN))
7112 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7114 if (!old_name || !*old_name)
7116 @@ -2022,7 +2087,7 @@ static int do_new_mount(struct path *pat
7119 /* we need capabilities... */
7120 - if (!capable(CAP_SYS_ADMIN))
7121 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
7124 mnt = do_kern_mount(type, flags, name, data);
7125 @@ -2291,6 +2356,7 @@ long do_mount(char *dev_name, char *dir_
7132 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
7133 @@ -2318,6 +2384,12 @@ long do_mount(char *dev_name, char *dir_
7134 if (!(flags & MS_NOATIME))
7135 mnt_flags |= MNT_RELATIME;
7137 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
7138 + /* FIXME: bind and re-mounts get the tag flag? */
7139 + if (flags & (MS_BIND|MS_REMOUNT))
7140 + flags |= MS_TAGID;
7143 /* Separate the per-mountpoint flags */
7144 if (flags & MS_NOSUID)
7145 mnt_flags |= MNT_NOSUID;
7146 @@ -2334,15 +2406,17 @@ long do_mount(char *dev_name, char *dir_
7147 if (flags & MS_RDONLY)
7148 mnt_flags |= MNT_READONLY;
7150 + if (!capable(CAP_SYS_ADMIN))
7151 + mnt_flags |= MNT_NODEV;
7152 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
7153 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
7156 if (flags & MS_REMOUNT)
7157 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
7160 else if (flags & MS_BIND)
7161 - retval = do_loopback(&path, dev_name, flags & MS_REC);
7162 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
7163 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
7164 retval = do_change_type(&path, flags);
7165 else if (flags & MS_MOVE)
7166 @@ -2442,6 +2516,7 @@ static struct mnt_namespace *dup_mnt_ns(
7167 q = next_mnt(q, new_ns->root);
7169 up_write(&namespace_sem);
7170 + atomic_inc(&vs_global_mnt_ns);
7174 @@ -2581,9 +2656,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
7178 - if (IS_MNT_SHARED(old.mnt) ||
7179 - IS_MNT_SHARED(new.mnt->mnt_parent) ||
7180 - IS_MNT_SHARED(root.mnt->mnt_parent))
7181 + if ((IS_MNT_SHARED(old.mnt) ||
7182 + IS_MNT_SHARED(new.mnt->mnt_parent) ||
7183 + IS_MNT_SHARED(root.mnt->mnt_parent)) &&
7184 + !vx_flags(VXF_STATE_SETUP, 0))
7186 if (!check_mnt(root.mnt) || !check_mnt(new.mnt))
7188 @@ -2715,6 +2791,7 @@ void put_mnt_ns(struct mnt_namespace *ns
7189 br_write_unlock(vfsmount_lock);
7190 up_write(&namespace_sem);
7191 release_mounts(&umount_list);
7192 + atomic_dec(&vs_global_mnt_ns);
7195 EXPORT_SYMBOL(put_mnt_ns);
7196 diff -NurpP --minimal linux-3.0/fs/nfs/client.c linux-3.0-vs2.3.1-pre7/fs/nfs/client.c
7197 --- linux-3.0/fs/nfs/client.c 2011-07-22 11:18:05.000000000 +0200
7198 +++ linux-3.0-vs2.3.1-pre7/fs/nfs/client.c 2011-06-10 22:11:24.000000000 +0200
7199 @@ -780,6 +780,9 @@ static int nfs_init_server_rpcclient(str
7200 if (server->flags & NFS_MOUNT_SOFT)
7201 server->client->cl_softrtry = 1;
7203 + server->client->cl_tag = 0;
7204 + if (server->flags & NFS_MOUNT_TAGGED)
7205 + server->client->cl_tag = 1;
7209 @@ -951,6 +954,10 @@ static void nfs_server_set_fsinfo(struct
7210 server->acdirmin = server->acdirmax = 0;
7213 + /* FIXME: needs fsinfo
7214 + if (server->flags & NFS_MOUNT_TAGGED)
7215 + sb->s_flags |= MS_TAGGED; */
7217 server->maxfilesize = fsinfo->maxfilesize;
7219 server->time_delta = fsinfo->time_delta;
7220 diff -NurpP --minimal linux-3.0/fs/nfs/dir.c linux-3.0-vs2.3.1-pre7/fs/nfs/dir.c
7221 --- linux-3.0/fs/nfs/dir.c 2011-07-22 11:18:05.000000000 +0200
7222 +++ linux-3.0-vs2.3.1-pre7/fs/nfs/dir.c 2011-06-10 22:11:24.000000000 +0200
7224 #include <linux/sched.h>
7225 #include <linux/kmemleak.h>
7226 #include <linux/xattr.h>
7227 +#include <linux/vs_tag.h>
7229 #include "delegation.h"
7231 @@ -1298,6 +1299,7 @@ static struct dentry *nfs_lookup(struct
7233 goto out_unblock_sillyrename;
7235 + dx_propagate_tag(nd, inode);
7237 res = d_materialise_unique(dentry, inode);
7239 diff -NurpP --minimal linux-3.0/fs/nfs/inode.c linux-3.0-vs2.3.1-pre7/fs/nfs/inode.c
7240 --- linux-3.0/fs/nfs/inode.c 2011-07-22 11:18:05.000000000 +0200
7241 +++ linux-3.0-vs2.3.1-pre7/fs/nfs/inode.c 2011-07-01 11:35:34.000000000 +0200
7243 #include <linux/nfs_xdr.h>
7244 #include <linux/slab.h>
7245 #include <linux/compat.h>
7246 +#include <linux/vs_tag.h>
7248 #include <asm/system.h>
7249 #include <asm/uaccess.h>
7250 @@ -273,6 +274,8 @@ nfs_fhget(struct super_block *sb, struct
7251 if (inode->i_state & I_NEW) {
7252 struct nfs_inode *nfsi = NFS_I(inode);
7253 unsigned long now = jiffies;
7257 /* We set i_ino for the few things that still rely on it,
7258 * such as stat(2) */
7259 @@ -321,8 +324,8 @@ nfs_fhget(struct super_block *sb, struct
7260 nfsi->change_attr = 0;
7263 - inode->i_uid = -2;
7264 - inode->i_gid = -2;
7267 inode->i_blocks = 0;
7268 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
7270 @@ -359,13 +362,13 @@ nfs_fhget(struct super_block *sb, struct
7271 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
7272 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
7273 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
7274 - inode->i_uid = fattr->uid;
7276 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
7277 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
7278 | NFS_INO_INVALID_ACCESS
7279 | NFS_INO_INVALID_ACL;
7280 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
7281 - inode->i_gid = fattr->gid;
7283 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
7284 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
7285 | NFS_INO_INVALID_ACCESS
7286 @@ -378,6 +381,11 @@ nfs_fhget(struct super_block *sb, struct
7288 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
7290 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7291 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7292 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
7293 + /* maybe fattr->xid someday */
7295 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
7296 nfsi->attrtimeo_timestamp = now;
7297 nfsi->access_cache = RB_ROOT;
7298 @@ -494,6 +502,8 @@ void nfs_setattr_update_inode(struct ino
7299 inode->i_uid = attr->ia_uid;
7300 if ((attr->ia_valid & ATTR_GID) != 0)
7301 inode->i_gid = attr->ia_gid;
7302 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
7303 + inode->i_tag = attr->ia_tag;
7304 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7305 spin_unlock(&inode->i_lock);
7307 @@ -941,6 +951,9 @@ static int nfs_check_inode_attributes(st
7308 struct nfs_inode *nfsi = NFS_I(inode);
7309 loff_t cur_size, new_isize;
7310 unsigned long invalid = 0;
7316 /* Has the inode gone and changed behind our back? */
7317 @@ -964,13 +977,18 @@ static int nfs_check_inode_attributes(st
7318 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
7321 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7322 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7323 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7325 /* Have any file permissions changed? */
7326 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
7327 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7328 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
7329 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
7330 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7331 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
7332 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
7333 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
7334 + /* maybe check for tag too? */
7336 /* Has the link count changed? */
7337 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
7338 @@ -1205,6 +1223,9 @@ static int nfs_update_inode(struct inode
7339 unsigned long invalid = 0;
7340 unsigned long now = jiffies;
7341 unsigned long save_cache_validity;
7346 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
7347 __func__, inode->i_sb->s_id, inode->i_ino,
7348 @@ -1312,6 +1333,9 @@ static int nfs_update_inode(struct inode
7349 | NFS_INO_REVAL_PAGECACHE
7350 | NFS_INO_REVAL_FORCED);
7352 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
7353 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
7354 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
7356 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
7357 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
7358 @@ -1333,9 +1357,9 @@ static int nfs_update_inode(struct inode
7359 | NFS_INO_REVAL_FORCED);
7361 if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
7362 - if (inode->i_uid != fattr->uid) {
7363 + if (uid != fattr->uid) {
7364 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7365 - inode->i_uid = fattr->uid;
7368 } else if (server->caps & NFS_CAP_OWNER)
7369 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
7370 @@ -1344,9 +1368,9 @@ static int nfs_update_inode(struct inode
7371 | NFS_INO_REVAL_FORCED);
7373 if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
7374 - if (inode->i_gid != fattr->gid) {
7375 + if (gid != fattr->gid) {
7376 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
7377 - inode->i_gid = fattr->gid;
7380 } else if (server->caps & NFS_CAP_OWNER_GROUP)
7381 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
7382 @@ -1354,6 +1378,10 @@ static int nfs_update_inode(struct inode
7383 | NFS_INO_INVALID_ACL
7384 | NFS_INO_REVAL_FORCED);
7386 + inode->i_uid = uid;
7387 + inode->i_gid = gid;
7388 + inode->i_tag = tag;
7390 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
7391 if (inode->i_nlink != fattr->nlink) {
7392 invalid |= NFS_INO_INVALID_ATTR;
7393 diff -NurpP --minimal linux-3.0/fs/nfs/nfs3xdr.c linux-3.0-vs2.3.1-pre7/fs/nfs/nfs3xdr.c
7394 --- linux-3.0/fs/nfs/nfs3xdr.c 2011-03-15 18:07:32.000000000 +0100
7395 +++ linux-3.0-vs2.3.1-pre7/fs/nfs/nfs3xdr.c 2011-06-10 22:11:24.000000000 +0200
7397 #include <linux/nfs3.h>
7398 #include <linux/nfs_fs.h>
7399 #include <linux/nfsacl.h>
7400 +#include <linux/vs_tag.h>
7401 #include "internal.h"
7403 #define NFSDBG_FACILITY NFSDBG_XDR
7404 @@ -562,7 +563,8 @@ static __be32 *xdr_decode_nfstime3(__be3
7408 -static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
7409 +static void encode_sattr3(struct xdr_stream *xdr,
7410 + const struct iattr *attr, int tag)
7414 @@ -594,15 +596,19 @@ static void encode_sattr3(struct xdr_str
7418 - if (attr->ia_valid & ATTR_UID) {
7419 + if (attr->ia_valid & ATTR_UID ||
7420 + (tag && (attr->ia_valid & ATTR_TAG))) {
7422 - *p++ = cpu_to_be32(attr->ia_uid);
7423 + *p++ = cpu_to_be32(TAGINO_UID(tag,
7424 + attr->ia_uid, attr->ia_tag));
7428 - if (attr->ia_valid & ATTR_GID) {
7429 + if (attr->ia_valid & ATTR_GID ||
7430 + (tag && (attr->ia_valid & ATTR_TAG))) {
7432 - *p++ = cpu_to_be32(attr->ia_gid);
7433 + *p++ = cpu_to_be32(TAGINO_GID(tag,
7434 + attr->ia_gid, attr->ia_tag));
7438 @@ -878,7 +884,7 @@ static void nfs3_xdr_enc_setattr3args(st
7439 const struct nfs3_sattrargs *args)
7441 encode_nfs_fh3(xdr, args->fh);
7442 - encode_sattr3(xdr, args->sattr);
7443 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
7444 encode_sattrguard3(xdr, args);
7447 @@ -1028,13 +1034,13 @@ static void nfs3_xdr_enc_write3args(stru
7450 static void encode_createhow3(struct xdr_stream *xdr,
7451 - const struct nfs3_createargs *args)
7452 + const struct nfs3_createargs *args, int tag)
7454 encode_uint32(xdr, args->createmode);
7455 switch (args->createmode) {
7456 case NFS3_CREATE_UNCHECKED:
7457 case NFS3_CREATE_GUARDED:
7458 - encode_sattr3(xdr, args->sattr);
7459 + encode_sattr3(xdr, args->sattr, tag);
7461 case NFS3_CREATE_EXCLUSIVE:
7462 encode_createverf3(xdr, args->verifier);
7463 @@ -1049,7 +1055,7 @@ static void nfs3_xdr_enc_create3args(str
7464 const struct nfs3_createargs *args)
7466 encode_diropargs3(xdr, args->fh, args->name, args->len);
7467 - encode_createhow3(xdr, args);
7468 + encode_createhow3(xdr, args, req->rq_task->tk_client->cl_tag);
7472 @@ -1065,7 +1071,7 @@ static void nfs3_xdr_enc_mkdir3args(stru
7473 const struct nfs3_mkdirargs *args)
7475 encode_diropargs3(xdr, args->fh, args->name, args->len);
7476 - encode_sattr3(xdr, args->sattr);
7477 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
7481 @@ -1082,9 +1088,9 @@ static void nfs3_xdr_enc_mkdir3args(stru
7484 static void encode_symlinkdata3(struct xdr_stream *xdr,
7485 - const struct nfs3_symlinkargs *args)
7486 + const struct nfs3_symlinkargs *args, int tag)
7488 - encode_sattr3(xdr, args->sattr);
7489 + encode_sattr3(xdr, args->sattr, tag);
7490 encode_nfspath3(xdr, args->pages, args->pathlen);
7493 @@ -1093,7 +1099,7 @@ static void nfs3_xdr_enc_symlink3args(st
7494 const struct nfs3_symlinkargs *args)
7496 encode_diropargs3(xdr, args->fromfh, args->fromname, args->fromlen);
7497 - encode_symlinkdata3(xdr, args);
7498 + encode_symlinkdata3(xdr, args, req->rq_task->tk_client->cl_tag);
7502 @@ -1121,24 +1127,24 @@ static void nfs3_xdr_enc_symlink3args(st
7505 static void encode_devicedata3(struct xdr_stream *xdr,
7506 - const struct nfs3_mknodargs *args)
7507 + const struct nfs3_mknodargs *args, int tag)
7509 - encode_sattr3(xdr, args->sattr);
7510 + encode_sattr3(xdr, args->sattr, tag);
7511 encode_specdata3(xdr, args->rdev);
7514 static void encode_mknoddata3(struct xdr_stream *xdr,
7515 - const struct nfs3_mknodargs *args)
7516 + const struct nfs3_mknodargs *args, int tag)
7518 encode_ftype3(xdr, args->type);
7519 switch (args->type) {
7522 - encode_devicedata3(xdr, args);
7523 + encode_devicedata3(xdr, args, tag);
7527 - encode_sattr3(xdr, args->sattr);
7528 + encode_sattr3(xdr, args->sattr, tag);
7532 @@ -1153,7 +1159,7 @@ static void nfs3_xdr_enc_mknod3args(stru
7533 const struct nfs3_mknodargs *args)
7535 encode_diropargs3(xdr, args->fh, args->name, args->len);
7536 - encode_mknoddata3(xdr, args);
7537 + encode_mknoddata3(xdr, args, req->rq_task->tk_client->cl_tag);
7541 diff -NurpP --minimal linux-3.0/fs/nfs/super.c linux-3.0-vs2.3.1-pre7/fs/nfs/super.c
7542 --- linux-3.0/fs/nfs/super.c 2011-07-22 11:18:05.000000000 +0200
7543 +++ linux-3.0-vs2.3.1-pre7/fs/nfs/super.c 2011-06-10 22:11:24.000000000 +0200
7545 #include <linux/nfs_xdr.h>
7546 #include <linux/magic.h>
7547 #include <linux/parser.h>
7548 +#include <linux/vs_tag.h>
7550 #include <asm/system.h>
7551 #include <asm/uaccess.h>
7552 @@ -87,6 +88,7 @@ enum {
7553 Opt_sharecache, Opt_nosharecache,
7554 Opt_resvport, Opt_noresvport,
7555 Opt_fscache, Opt_nofscache,
7556 + Opt_tag, Opt_notag,
7558 /* Mount options that take integer arguments */
7560 @@ -100,6 +102,7 @@ enum {
7566 /* Mount options that take string arguments */
7567 Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost,
7568 @@ -180,6 +183,10 @@ static const match_table_t nfs_mount_opt
7569 { Opt_fscache_uniq, "fsc=%s" },
7570 { Opt_local_lock, "local_lock=%s" },
7572 + { Opt_tag, "tag" },
7573 + { Opt_notag, "notag" },
7574 + { Opt_tagid, "tagid=%u" },
7579 @@ -650,6 +657,7 @@ static void nfs_show_mount_options(struc
7580 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
7581 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
7582 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
7583 + { NFS_MOUNT_TAGGED, ",tag", "" },
7586 const struct proc_nfs_info *nfs_infop;
7587 @@ -1198,6 +1206,14 @@ static int nfs_parse_mount_options(char
7588 kfree(mnt->fscache_uniq);
7589 mnt->fscache_uniq = NULL;
7591 +#ifndef CONFIG_TAGGING_NONE
7593 + mnt->flags |= NFS_MOUNT_TAGGED;
7596 + mnt->flags &= ~NFS_MOUNT_TAGGED;
7601 * options that take numeric values
7602 @@ -1304,6 +1320,12 @@ static int nfs_parse_mount_options(char
7603 goto out_invalid_value;
7604 mnt->minorversion = option;
7606 +#ifdef CONFIG_PROPAGATE
7609 + nfs_data.flags |= NFS_MOUNT_TAGGED;
7614 * options that take text values
7615 diff -NurpP --minimal linux-3.0/fs/nfsd/auth.c linux-3.0-vs2.3.1-pre7/fs/nfsd/auth.c
7616 --- linux-3.0/fs/nfsd/auth.c 2010-02-25 11:52:05.000000000 +0100
7617 +++ linux-3.0-vs2.3.1-pre7/fs/nfsd/auth.c 2011-06-10 22:11:24.000000000 +0200
7619 /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
7621 #include <linux/sched.h>
7622 +#include <linux/vs_tag.h>
7626 @@ -36,6 +37,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
7628 new->fsuid = rqstp->rq_cred.cr_uid;
7629 new->fsgid = rqstp->rq_cred.cr_gid;
7630 + /* FIXME: this desperately needs a tag :)
7631 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
7634 rqgi = rqstp->rq_cred.cr_group_info;
7636 diff -NurpP --minimal linux-3.0/fs/nfsd/nfs3xdr.c linux-3.0-vs2.3.1-pre7/fs/nfsd/nfs3xdr.c
7637 --- linux-3.0/fs/nfsd/nfs3xdr.c 2011-07-22 11:18:05.000000000 +0200
7638 +++ linux-3.0-vs2.3.1-pre7/fs/nfsd/nfs3xdr.c 2011-06-10 22:11:24.000000000 +0200
7642 #include <linux/namei.h>
7643 +#include <linux/vs_tag.h>
7647 @@ -95,6 +96,8 @@ static __be32 *
7648 decode_sattr3(__be32 *p, struct iattr *iap)
7656 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
7659 iap->ia_valid |= ATTR_UID;
7660 - iap->ia_uid = ntohl(*p++);
7661 + uid = ntohl(*p++);
7664 iap->ia_valid |= ATTR_GID;
7665 - iap->ia_gid = ntohl(*p++);
7666 + gid = ntohl(*p++);
7668 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7669 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7670 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7674 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
7675 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
7676 *p++ = htonl((u32) stat->mode);
7677 *p++ = htonl((u32) stat->nlink);
7678 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7679 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7680 + *p++ = htonl((u32) nfsd_ruid(rqstp,
7681 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
7682 + stat->uid, stat->tag)));
7683 + *p++ = htonl((u32) nfsd_rgid(rqstp,
7684 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
7685 + stat->gid, stat->tag)));
7686 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
7687 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
7689 diff -NurpP --minimal linux-3.0/fs/nfsd/nfs4xdr.c linux-3.0-vs2.3.1-pre7/fs/nfsd/nfs4xdr.c
7690 --- linux-3.0/fs/nfsd/nfs4xdr.c 2011-07-22 11:18:05.000000000 +0200
7691 +++ linux-3.0-vs2.3.1-pre7/fs/nfsd/nfs4xdr.c 2011-06-10 22:11:24.000000000 +0200
7693 #include <linux/statfs.h>
7694 #include <linux/utsname.h>
7695 #include <linux/sunrpc/svcauth_gss.h>
7696 +#include <linux/vs_tag.h>
7700 @@ -2090,14 +2091,18 @@ out_acl:
7701 WRITE32(stat.nlink);
7703 if (bmval1 & FATTR4_WORD1_OWNER) {
7704 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
7705 + status = nfsd4_encode_user(rqstp,
7706 + TAGINO_UID(DX_TAG(dentry->d_inode),
7707 + stat.uid, stat.tag), &p, &buflen);
7708 if (status == nfserr_resource)
7713 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
7714 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
7715 + status = nfsd4_encode_group(rqstp,
7716 + TAGINO_GID(DX_TAG(dentry->d_inode),
7717 + stat.gid, stat.tag), &p, &buflen);
7718 if (status == nfserr_resource)
7721 diff -NurpP --minimal linux-3.0/fs/nfsd/nfsxdr.c linux-3.0-vs2.3.1-pre7/fs/nfsd/nfsxdr.c
7722 --- linux-3.0/fs/nfsd/nfsxdr.c 2011-05-22 16:17:53.000000000 +0200
7723 +++ linux-3.0-vs2.3.1-pre7/fs/nfsd/nfsxdr.c 2011-06-10 22:11:24.000000000 +0200
7728 +#include <linux/vs_tag.h>
7730 #define NFSDDBG_FACILITY NFSDDBG_XDR
7732 @@ -88,6 +89,8 @@ static __be32 *
7733 decode_sattr(__be32 *p, struct iattr *iap)
7741 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
7743 if ((tmp = ntohl(*p++)) != (u32)-1) {
7744 iap->ia_valid |= ATTR_UID;
7745 - iap->ia_uid = tmp;
7748 if ((tmp = ntohl(*p++)) != (u32)-1) {
7749 iap->ia_valid |= ATTR_GID;
7750 - iap->ia_gid = tmp;
7753 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
7754 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
7755 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
7756 if ((tmp = ntohl(*p++)) != (u32)-1) {
7757 iap->ia_valid |= ATTR_SIZE;
7759 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
7760 *p++ = htonl(nfs_ftypes[type >> 12]);
7761 *p++ = htonl((u32) stat->mode);
7762 *p++ = htonl((u32) stat->nlink);
7763 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
7764 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
7765 + *p++ = htonl((u32) nfsd_ruid(rqstp,
7766 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
7767 + *p++ = htonl((u32) nfsd_rgid(rqstp,
7768 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
7770 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
7771 *p++ = htonl(NFS_MAXPATHLEN);
7772 diff -NurpP --minimal linux-3.0/fs/ocfs2/dlmglue.c linux-3.0-vs2.3.1-pre7/fs/ocfs2/dlmglue.c
7773 --- linux-3.0/fs/ocfs2/dlmglue.c 2011-05-22 16:17:53.000000000 +0200
7774 +++ linux-3.0-vs2.3.1-pre7/fs/ocfs2/dlmglue.c 2011-06-10 22:11:24.000000000 +0200
7775 @@ -2041,6 +2041,7 @@ static void __ocfs2_stuff_meta_lvb(struc
7776 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
7777 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
7778 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
7779 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
7780 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
7781 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
7782 lvb->lvb_iatime_packed =
7783 @@ -2091,6 +2092,7 @@ static void ocfs2_refresh_inode_from_lvb
7785 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
7786 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
7787 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
7788 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
7789 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
7790 ocfs2_unpack_timespec(&inode->i_atime,
7791 diff -NurpP --minimal linux-3.0/fs/ocfs2/dlmglue.h linux-3.0-vs2.3.1-pre7/fs/ocfs2/dlmglue.h
7792 --- linux-3.0/fs/ocfs2/dlmglue.h 2010-10-21 13:07:50.000000000 +0200
7793 +++ linux-3.0-vs2.3.1-pre7/fs/ocfs2/dlmglue.h 2011-06-10 22:11:24.000000000 +0200
7794 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
7797 __be32 lvb_igeneration;
7798 - __be32 lvb_reserved2;
7800 + __be16 lvb_reserved2;
7803 #define OCFS2_QINFO_LVB_VERSION 1
7804 diff -NurpP --minimal linux-3.0/fs/ocfs2/file.c linux-3.0-vs2.3.1-pre7/fs/ocfs2/file.c
7805 --- linux-3.0/fs/ocfs2/file.c 2011-07-22 11:18:06.000000000 +0200
7806 +++ linux-3.0-vs2.3.1-pre7/fs/ocfs2/file.c 2011-06-10 22:43:33.000000000 +0200
7807 @@ -1111,7 +1111,7 @@ int ocfs2_setattr(struct dentry *dentry,
7808 attr->ia_valid &= ~ATTR_SIZE;
7810 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
7811 - | ATTR_GID | ATTR_UID | ATTR_MODE)
7812 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
7813 if (!(attr->ia_valid & OCFS2_VALID_ATTRS))
7816 diff -NurpP --minimal linux-3.0/fs/ocfs2/inode.c linux-3.0-vs2.3.1-pre7/fs/ocfs2/inode.c
7817 --- linux-3.0/fs/ocfs2/inode.c 2011-05-22 16:17:53.000000000 +0200
7818 +++ linux-3.0-vs2.3.1-pre7/fs/ocfs2/inode.c 2011-06-10 22:11:24.000000000 +0200
7820 #include <linux/highmem.h>
7821 #include <linux/pagemap.h>
7822 #include <linux/quotaops.h>
7823 +#include <linux/vs_tag.h>
7825 #include <asm/byteorder.h>
7827 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
7829 unsigned int flags = OCFS2_I(inode)->ip_attr;
7831 - inode->i_flags &= ~(S_IMMUTABLE |
7832 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
7833 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
7835 if (flags & OCFS2_IMMUTABLE_FL)
7836 inode->i_flags |= S_IMMUTABLE;
7837 + if (flags & OCFS2_IXUNLINK_FL)
7838 + inode->i_flags |= S_IXUNLINK;
7840 if (flags & OCFS2_SYNC_FL)
7841 inode->i_flags |= S_SYNC;
7842 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode
7843 inode->i_flags |= S_NOATIME;
7844 if (flags & OCFS2_DIRSYNC_FL)
7845 inode->i_flags |= S_DIRSYNC;
7847 + inode->i_vflags &= ~(V_BARRIER | V_COW);
7849 + if (flags & OCFS2_BARRIER_FL)
7850 + inode->i_vflags |= V_BARRIER;
7851 + if (flags & OCFS2_COW_FL)
7852 + inode->i_vflags |= V_COW;
7855 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
7856 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
7858 unsigned int flags = oi->vfs_inode.i_flags;
7859 + unsigned int vflags = oi->vfs_inode.i_vflags;
7861 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
7862 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
7863 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
7864 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
7866 + if (flags & S_IMMUTABLE)
7867 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
7868 + if (flags & S_IXUNLINK)
7869 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
7871 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
7872 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
7874 oi->ip_attr |= OCFS2_SYNC_FL;
7875 if (flags & S_APPEND)
7876 oi->ip_attr |= OCFS2_APPEND_FL;
7877 - if (flags & S_IMMUTABLE)
7878 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
7879 if (flags & S_NOATIME)
7880 oi->ip_attr |= OCFS2_NOATIME_FL;
7881 if (flags & S_DIRSYNC)
7882 oi->ip_attr |= OCFS2_DIRSYNC_FL;
7884 + if (vflags & V_BARRIER)
7885 + oi->ip_attr |= OCFS2_BARRIER_FL;
7886 + if (vflags & V_COW)
7887 + oi->ip_attr |= OCFS2_COW_FL;
7890 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
7891 @@ -241,6 +263,8 @@ void ocfs2_populate_inode(struct inode *
7892 struct super_block *sb;
7893 struct ocfs2_super *osb;
7900 @@ -269,8 +293,12 @@ void ocfs2_populate_inode(struct inode *
7901 inode->i_generation = le32_to_cpu(fe->i_generation);
7902 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
7903 inode->i_mode = le16_to_cpu(fe->i_mode);
7904 - inode->i_uid = le32_to_cpu(fe->i_uid);
7905 - inode->i_gid = le32_to_cpu(fe->i_gid);
7906 + uid = le32_to_cpu(fe->i_uid);
7907 + gid = le32_to_cpu(fe->i_gid);
7908 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
7909 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
7910 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
7911 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
7913 /* Fast symlinks will have i_size but no allocated clusters. */
7914 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
7915 diff -NurpP --minimal linux-3.0/fs/ocfs2/inode.h linux-3.0-vs2.3.1-pre7/fs/ocfs2/inode.h
7916 --- linux-3.0/fs/ocfs2/inode.h 2011-01-05 21:50:26.000000000 +0100
7917 +++ linux-3.0-vs2.3.1-pre7/fs/ocfs2/inode.h 2011-06-10 22:11:24.000000000 +0200
7918 @@ -151,6 +151,7 @@ struct buffer_head *ocfs2_bread(struct i
7920 void ocfs2_set_inode_flags(struct inode *inode);
7921 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
7922 +int ocfs2_sync_flags(struct inode *inode, int, int);
7924 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
7926 diff -NurpP --minimal linux-3.0/fs/ocfs2/ioctl.c linux-3.0-vs2.3.1-pre7/fs/ocfs2/ioctl.c
7927 --- linux-3.0/fs/ocfs2/ioctl.c 2011-07-22 11:18:06.000000000 +0200
7928 +++ linux-3.0-vs2.3.1-pre7/fs/ocfs2/ioctl.c 2011-06-10 22:11:24.000000000 +0200
7929 @@ -78,7 +78,41 @@ static int ocfs2_get_inode_attr(struct i
7933 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
7934 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
7936 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
7937 + struct buffer_head *bh = NULL;
7938 + handle_t *handle = NULL;
7941 + status = ocfs2_inode_lock(inode, &bh, 1);
7943 + mlog_errno(status);
7946 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
7947 + if (IS_ERR(handle)) {
7948 + status = PTR_ERR(handle);
7949 + mlog_errno(status);
7953 + inode->i_flags = flags;
7954 + inode->i_vflags = vflags;
7955 + ocfs2_get_inode_flags(OCFS2_I(inode));
7957 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
7959 + mlog_errno(status);
7961 + ocfs2_commit_trans(osb, handle);
7963 + ocfs2_inode_unlock(inode, 1);
7968 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
7971 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
7972 @@ -103,6 +137,11 @@ static int ocfs2_set_inode_attr(struct i
7973 if (!S_ISDIR(inode->i_mode))
7974 flags &= ~OCFS2_DIRSYNC_FL;
7976 + if (IS_BARRIER(inode)) {
7977 + vxwprintk_task(1, "messing with the barrier.");
7981 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
7982 if (IS_ERR(handle)) {
7983 status = PTR_ERR(handle);
7984 @@ -880,6 +919,7 @@ bail:
7989 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7991 struct inode *inode = filp->f_path.dentry->d_inode;
7992 diff -NurpP --minimal linux-3.0/fs/ocfs2/namei.c linux-3.0-vs2.3.1-pre7/fs/ocfs2/namei.c
7993 --- linux-3.0/fs/ocfs2/namei.c 2011-05-22 16:17:53.000000000 +0200
7994 +++ linux-3.0-vs2.3.1-pre7/fs/ocfs2/namei.c 2011-06-10 22:11:24.000000000 +0200
7996 #include <linux/slab.h>
7997 #include <linux/highmem.h>
7998 #include <linux/quotaops.h>
7999 +#include <linux/vs_tag.h>
8001 #include <cluster/masklog.h>
8003 @@ -477,6 +478,7 @@ static int __ocfs2_mknod_locked(struct i
8004 struct ocfs2_dinode *fe = NULL;
8005 struct ocfs2_extent_list *fel;
8011 @@ -514,8 +516,11 @@ static int __ocfs2_mknod_locked(struct i
8012 fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
8013 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
8014 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
8015 - fe->i_uid = cpu_to_le32(inode->i_uid);
8016 - fe->i_gid = cpu_to_le32(inode->i_gid);
8018 + tag = dx_current_fstag(osb->sb);
8019 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
8020 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
8021 + inode->i_tag = tag;
8022 fe->i_mode = cpu_to_le16(inode->i_mode);
8023 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
8024 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
8025 diff -NurpP --minimal linux-3.0/fs/ocfs2/ocfs2.h linux-3.0-vs2.3.1-pre7/fs/ocfs2/ocfs2.h
8026 --- linux-3.0/fs/ocfs2/ocfs2.h 2011-05-22 16:17:53.000000000 +0200
8027 +++ linux-3.0-vs2.3.1-pre7/fs/ocfs2/ocfs2.h 2011-06-10 22:11:24.000000000 +0200
8028 @@ -272,6 +272,7 @@ enum ocfs2_mount_options
8030 OCFS2_MOUNT_HB_NONE = 1 << 13, /* No heartbeat */
8031 OCFS2_MOUNT_HB_GLOBAL = 1 << 14, /* Global heartbeat */
8032 + OCFS2_MOUNT_TAGGED = 1 << 15, /* use tagging */
8035 #define OCFS2_OSB_SOFT_RO 0x0001
8036 diff -NurpP --minimal linux-3.0/fs/ocfs2/ocfs2_fs.h linux-3.0-vs2.3.1-pre7/fs/ocfs2/ocfs2_fs.h
8037 --- linux-3.0/fs/ocfs2/ocfs2_fs.h 2011-05-22 16:17:53.000000000 +0200
8038 +++ linux-3.0-vs2.3.1-pre7/fs/ocfs2/ocfs2_fs.h 2011-06-10 22:11:24.000000000 +0200
8039 @@ -266,6 +266,11 @@
8040 #define OCFS2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8041 #define OCFS2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8043 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8045 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8046 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
8048 #define OCFS2_FL_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8049 #define OCFS2_FL_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8051 diff -NurpP --minimal linux-3.0/fs/ocfs2/super.c linux-3.0-vs2.3.1-pre7/fs/ocfs2/super.c
8052 --- linux-3.0/fs/ocfs2/super.c 2011-07-22 11:18:06.000000000 +0200
8053 +++ linux-3.0-vs2.3.1-pre7/fs/ocfs2/super.c 2011-06-15 02:40:14.000000000 +0200
8054 @@ -184,6 +184,7 @@ enum {
8058 + Opt_tag, Opt_notag, Opt_tagid,
8062 @@ -215,6 +216,9 @@ static const match_table_t tokens = {
8063 {Opt_coherency_full, "coherency=full"},
8064 {Opt_resv_level, "resv_level=%u"},
8065 {Opt_dir_resv_level, "dir_resv_level=%u"},
8067 + {Opt_notag, "notag"},
8068 + {Opt_tagid, "tagid=%u"},
8072 @@ -662,6 +666,13 @@ static int ocfs2_remount(struct super_bl
8076 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
8077 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
8079 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
8083 /* We're going to/from readonly mode. */
8084 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
8085 /* Disable quota accounting before remounting RO */
8086 @@ -1177,6 +1188,9 @@ static int ocfs2_fill_super(struct super
8088 ocfs2_complete_mount_recovery(osb);
8090 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
8091 + sb->s_flags |= MS_TAGGED;
8093 if (ocfs2_mount_local(osb))
8094 snprintf(nodestr, sizeof(nodestr), "local");
8096 @@ -1506,6 +1520,20 @@ static int ocfs2_parse_options(struct su
8097 option < OCFS2_MAX_RESV_LEVEL)
8098 mopt->dir_resv_level = option;
8100 +#ifndef CONFIG_TAGGING_NONE
8102 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
8105 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
8108 +#ifdef CONFIG_PROPAGATE
8111 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
8116 "Unrecognized mount option \"%s\" "
8117 diff -NurpP --minimal linux-3.0/fs/open.c linux-3.0-vs2.3.1-pre7/fs/open.c
8118 --- linux-3.0/fs/open.c 2011-05-22 16:17:53.000000000 +0200
8119 +++ linux-3.0-vs2.3.1-pre7/fs/open.c 2011-06-10 22:11:24.000000000 +0200
8121 #include <linux/fs_struct.h>
8122 #include <linux/ima.h>
8123 #include <linux/dnotify.h>
8124 +#include <linux/vs_base.h>
8125 +#include <linux/vs_limit.h>
8126 +#include <linux/vs_tag.h>
8127 +#include <linux/vs_cowbl.h>
8128 +#include <linux/vserver/dlimit.h>
8130 #include "internal.h"
8132 @@ -494,6 +499,12 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
8133 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
8137 +#ifdef CONFIG_VSERVER_COWBL
8138 + error = cow_check_and_break(&path);
8140 + goto dput_and_out;
8142 inode = path.dentry->d_inode;
8144 error = mnt_want_write(path.mnt);
8145 @@ -531,11 +542,11 @@ static int chown_common(struct path *pat
8146 newattrs.ia_valid = ATTR_CTIME;
8147 if (user != (uid_t) -1) {
8148 newattrs.ia_valid |= ATTR_UID;
8149 - newattrs.ia_uid = user;
8150 + newattrs.ia_uid = dx_map_uid(user);
8152 if (group != (gid_t) -1) {
8153 newattrs.ia_valid |= ATTR_GID;
8154 - newattrs.ia_gid = group;
8155 + newattrs.ia_gid = dx_map_gid(group);
8157 if (!S_ISDIR(inode->i_mode))
8158 newattrs.ia_valid |=
8159 @@ -560,6 +571,10 @@ SYSCALL_DEFINE3(chown, const char __user
8160 error = mnt_want_write(path.mnt);
8163 +#ifdef CONFIG_VSERVER_COWBL
8164 + error = cow_check_and_break(&path);
8167 error = chown_common(&path, user, group);
8168 mnt_drop_write(path.mnt);
8170 @@ -587,6 +602,10 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
8171 error = mnt_want_write(path.mnt);
8174 +#ifdef CONFIG_VSERVER_COWBL
8175 + error = cow_check_and_break(&path);
8178 error = chown_common(&path, user, group);
8179 mnt_drop_write(path.mnt);
8181 @@ -606,6 +625,10 @@ SYSCALL_DEFINE3(lchown, const char __use
8182 error = mnt_want_write(path.mnt);
8185 +#ifdef CONFIG_VSERVER_COWBL
8186 + error = cow_check_and_break(&path);
8189 error = chown_common(&path, user, group);
8190 mnt_drop_write(path.mnt);
8192 @@ -857,6 +880,7 @@ static void __put_unused_fd(struct files
8193 __FD_CLR(fd, fdt->open_fds);
8194 if (fd < files->next_fd)
8195 files->next_fd = fd;
8196 + vx_openfd_dec(fd);
8199 void put_unused_fd(unsigned int fd)
8200 diff -NurpP --minimal linux-3.0/fs/proc/array.c linux-3.0-vs2.3.1-pre7/fs/proc/array.c
8201 --- linux-3.0/fs/proc/array.c 2011-07-22 11:18:06.000000000 +0200
8202 +++ linux-3.0-vs2.3.1-pre7/fs/proc/array.c 2011-06-10 22:11:24.000000000 +0200
8204 #include <linux/pid_namespace.h>
8205 #include <linux/ptrace.h>
8206 #include <linux/tracehook.h>
8207 +#include <linux/vs_context.h>
8208 +#include <linux/vs_network.h>
8210 #include <asm/pgtable.h>
8211 #include <asm/processor.h>
8212 @@ -170,6 +172,9 @@ static inline void task_state(struct seq
8214 ppid = pid_alive(p) ?
8215 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
8216 + if (unlikely(vx_current_initpid(p->pid)))
8221 struct task_struct *tracer = tracehook_tracer_task(p);
8222 @@ -287,7 +292,7 @@ static inline void task_sig(struct seq_f
8225 static void render_cap_t(struct seq_file *m, const char *header,
8227 + struct vx_info *vxi, kernel_cap_t *a)
8231 @@ -312,10 +317,11 @@ static inline void task_cap(struct seq_f
8232 cap_bset = cred->cap_bset;
8235 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
8236 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
8237 - render_cap_t(m, "CapEff:\t", &cap_effective);
8238 - render_cap_t(m, "CapBnd:\t", &cap_bset);
8239 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
8240 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
8241 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
8242 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
8243 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
8246 static inline void task_context_switch_counts(struct seq_file *m,
8247 @@ -337,6 +343,42 @@ static void task_cpus_allowed(struct seq
8251 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
8252 + struct pid *pid, struct task_struct *task)
8254 + seq_printf(m, "Proxy:\t%p(%c)\n"
8262 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
8263 + atomic_read(&task->nsproxy->count),
8264 + task->nsproxy->uts_ns,
8265 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
8266 + task->nsproxy->ipc_ns,
8267 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
8268 + task->nsproxy->mnt_ns,
8269 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
8270 + task->nsproxy->pid_ns,
8271 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
8272 + task->nsproxy->net_ns,
8273 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
8277 +void task_vs_id(struct seq_file *m, struct task_struct *task)
8279 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
8282 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
8283 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
8287 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
8288 struct pid *pid, struct task_struct *task)
8290 @@ -353,6 +395,7 @@ int proc_pid_status(struct seq_file *m,
8292 task_cpus_allowed(m, task);
8293 cpuset_task_status_allowed(m, task);
8294 + task_vs_id(m, task);
8295 task_context_switch_counts(m, task);
8298 @@ -462,6 +505,17 @@ static int do_task_stat(struct seq_file
8299 /* convert nsec -> ticks */
8300 start_time = nsec_to_clock_t(start_time);
8302 + /* fixup start time for virt uptime */
8303 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
8304 + unsigned long long bias =
8305 + current->vx_info->cvirt.bias_clock;
8307 + if (start_time > bias)
8308 + start_time -= bias;
8313 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
8314 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
8315 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
8316 diff -NurpP --minimal linux-3.0/fs/proc/base.c linux-3.0-vs2.3.1-pre7/fs/proc/base.c
8317 --- linux-3.0/fs/proc/base.c 2011-07-22 11:18:06.000000000 +0200
8318 +++ linux-3.0-vs2.3.1-pre7/fs/proc/base.c 2011-07-19 00:44:39.000000000 +0200
8320 #include <linux/pid_namespace.h>
8321 #include <linux/fs_struct.h>
8322 #include <linux/slab.h>
8323 +#include <linux/vs_context.h>
8324 +#include <linux/vs_network.h>
8325 #ifdef CONFIG_HARDWALL
8326 #include <asm/hardwall.h>
8328 @@ -1102,11 +1104,16 @@ static ssize_t oom_adjust_write(struct f
8332 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
8333 + if (oom_adjust < task->signal->oom_adj &&
8334 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
8339 + /* prevent guest processes from circumventing the oom killer */
8340 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
8341 + oom_adjust = OOM_ADJUST_MIN;
8343 if (oom_adjust != task->signal->oom_adj) {
8344 if (oom_adjust == OOM_DISABLE)
8345 atomic_inc(&task->mm->oom_disable_count);
8346 @@ -1275,7 +1282,7 @@ static ssize_t proc_loginuid_write(struc
8350 - if (!capable(CAP_AUDIT_CONTROL))
8351 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
8355 @@ -1722,6 +1729,8 @@ struct inode *proc_pid_make_inode(struct
8356 inode->i_gid = cred->egid;
8359 + /* procfs is xid tagged */
8360 + inode->i_tag = (tag_t)vx_task_xid(task);
8361 security_task_to_inode(task, inode);
8364 @@ -1758,6 +1767,8 @@ int pid_getattr(struct vfsmount *mnt, st
8368 +static unsigned name_to_int(struct dentry *dentry);
8371 * Exceptional case: normally we are not allowed to unhash a busy
8372 * directory. In this case, however, we can do it - no aliasing problems
8373 @@ -1786,6 +1797,12 @@ int pid_revalidate(struct dentry *dentry
8374 task = get_proc_task(inode);
8377 + unsigned pid = name_to_int(dentry);
8379 + if (pid != ~0U && pid != vx_map_pid(task->pid)) {
8380 + put_task_struct(task);
8383 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
8384 task_dumpable(task)) {
8386 @@ -1802,6 +1819,7 @@ int pid_revalidate(struct dentry *dentry
8387 put_task_struct(task);
8394 @@ -2283,6 +2301,13 @@ static struct dentry *proc_pident_lookup
8398 + /* TODO: maybe we can come up with a generic approach? */
8399 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
8400 + (dentry->d_name.len == 5) &&
8401 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
8402 + !memcmp(dentry->d_name.name, "ninfo", 5)))
8406 * Yes, it does not scale. And it should not. Don't add
8407 * new entries into /proc/<tgid>/ without very good reasons.
8408 @@ -2668,7 +2693,7 @@ out_iput:
8409 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
8411 struct dentry *error;
8412 - struct task_struct *task = get_proc_task(dir);
8413 + struct task_struct *task = get_proc_task_real(dir);
8414 const struct pid_entry *p, *last;
8416 error = ERR_PTR(-ENOENT);
8417 @@ -2765,6 +2790,9 @@ static int proc_pid_personality(struct s
8418 static const struct file_operations proc_task_operations;
8419 static const struct inode_operations proc_task_inode_operations;
8421 +extern int proc_pid_vx_info(struct task_struct *, char *);
8422 +extern int proc_pid_nx_info(struct task_struct *, char *);
8424 static const struct pid_entry tgid_base_stuff[] = {
8425 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
8426 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
8427 @@ -2828,6 +2856,8 @@ static const struct pid_entry tgid_base_
8428 #ifdef CONFIG_CGROUPS
8429 REG("cgroup", S_IRUGO, proc_cgroup_operations),
8431 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
8432 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
8433 INF("oom_score", S_IRUGO, proc_oom_score),
8434 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
8435 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
8436 @@ -2847,6 +2877,7 @@ static const struct pid_entry tgid_base_
8437 #ifdef CONFIG_HARDWALL
8438 INF("hardwall", S_IRUGO, proc_pid_hardwall),
8440 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
8443 static int proc_tgid_base_readdir(struct file * filp,
8444 @@ -3039,7 +3070,7 @@ retry:
8446 pid = find_ge_pid(iter.tgid, ns);
8448 - iter.tgid = pid_nr_ns(pid, ns);
8449 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
8450 iter.task = pid_task(pid, PIDTYPE_PID);
8451 /* What we to know is if the pid we have find is the
8452 * pid of a thread_group_leader. Testing for task
8453 @@ -3069,7 +3100,7 @@ static int proc_pid_fill_cache(struct fi
8454 struct tgid_iter iter)
8456 char name[PROC_NUMBUF];
8457 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
8458 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
8459 return proc_fill_cache(filp, dirent, filldir, name, len,
8460 proc_pid_instantiate, iter.task, NULL);
8462 @@ -3086,7 +3117,7 @@ int proc_pid_readdir(struct file * filp,
8464 nr = filp->f_pos - FIRST_PROCESS_ENTRY;
8466 - reaper = get_proc_task(filp->f_path.dentry->d_inode);
8467 + reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
8471 @@ -3103,6 +3134,8 @@ int proc_pid_readdir(struct file * filp,
8473 iter.tgid += 1, iter = next_tgid(ns, iter)) {
8474 filp->f_pos = iter.tgid + TGID_OFFSET;
8475 + if (!vx_proc_task_visible(iter.task))
8477 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
8478 put_task_struct(iter.task);
8480 @@ -3256,6 +3289,8 @@ static struct dentry *proc_task_lookup(s
8481 tid = name_to_int(dentry);
8484 + if (vx_current_initpid(tid))
8487 ns = dentry->d_sb->s_fs_info;
8489 diff -NurpP --minimal linux-3.0/fs/proc/generic.c linux-3.0-vs2.3.1-pre7/fs/proc/generic.c
8490 --- linux-3.0/fs/proc/generic.c 2011-07-22 11:18:06.000000000 +0200
8491 +++ linux-3.0-vs2.3.1-pre7/fs/proc/generic.c 2011-06-10 22:11:24.000000000 +0200
8493 #include <linux/bitops.h>
8494 #include <linux/spinlock.h>
8495 #include <linux/completion.h>
8496 +#include <linux/vserver/inode.h>
8497 #include <asm/uaccess.h>
8499 #include "internal.h"
8500 @@ -424,11 +425,15 @@ struct dentry *proc_lookup_de(struct pro
8501 for (de = de->subdir; de ; de = de->next) {
8502 if (de->namelen != dentry->d_name.len)
8504 + if (!vx_hide_check(0, de->vx_flags))
8506 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
8508 spin_unlock(&proc_subdir_lock);
8510 inode = proc_get_inode(dir->i_sb, de);
8511 + /* generic proc entries belong to the host */
8516 @@ -506,6 +511,8 @@ int proc_readdir_de(struct proc_dir_entr
8518 /* filldir passes info to user space */
8520 + if (!vx_hide_check(0, de->vx_flags))
8522 spin_unlock(&proc_subdir_lock);
8523 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
8524 de->low_ino, de->mode >> 12) < 0) {
8525 @@ -513,6 +520,7 @@ int proc_readdir_de(struct proc_dir_entr
8528 spin_lock(&proc_subdir_lock);
8533 @@ -627,6 +635,7 @@ static struct proc_dir_entry *__proc_cre
8535 atomic_set(&ent->count, 1);
8537 + ent->vx_flags = IATTR_PROC_DEFAULT;
8538 spin_lock_init(&ent->pde_unload_lock);
8539 ent->pde_unload_completion = NULL;
8540 INIT_LIST_HEAD(&ent->pde_openers);
8541 @@ -650,7 +659,8 @@ struct proc_dir_entry *proc_symlink(cons
8547 + ent->vx_flags = IATTR_PROC_SYMLINK;
8551 diff -NurpP --minimal linux-3.0/fs/proc/inode.c linux-3.0-vs2.3.1-pre7/fs/proc/inode.c
8552 --- linux-3.0/fs/proc/inode.c 2011-07-22 11:18:06.000000000 +0200
8553 +++ linux-3.0-vs2.3.1-pre7/fs/proc/inode.c 2011-06-10 22:11:24.000000000 +0200
8554 @@ -442,6 +442,8 @@ struct inode *proc_get_inode(struct supe
8555 inode->i_uid = de->uid;
8556 inode->i_gid = de->gid;
8559 + PROC_I(inode)->vx_flags = de->vx_flags;
8561 inode->i_size = de->size;
8563 diff -NurpP --minimal linux-3.0/fs/proc/internal.h linux-3.0-vs2.3.1-pre7/fs/proc/internal.h
8564 --- linux-3.0/fs/proc/internal.h 2011-07-22 11:18:06.000000000 +0200
8565 +++ linux-3.0-vs2.3.1-pre7/fs/proc/internal.h 2011-06-10 22:11:24.000000000 +0200
8569 #include <linux/proc_fs.h>
8570 +#include <linux/vs_pid.h>
8572 extern struct proc_dir_entry proc_root;
8573 #ifdef CONFIG_PROC_SYSCTL
8574 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
8575 struct pid *pid, struct task_struct *task);
8576 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
8577 struct pid *pid, struct task_struct *task);
8578 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
8579 + struct pid *pid, struct task_struct *task);
8581 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
8583 extern const struct file_operations proc_maps_operations;
8584 @@ -76,11 +80,16 @@ static inline struct pid *proc_pid(struc
8585 return PROC_I(inode)->pid;
8588 -static inline struct task_struct *get_proc_task(struct inode *inode)
8589 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
8591 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
8594 +static inline struct task_struct *get_proc_task(struct inode *inode)
8596 + return vx_get_proc_task(inode, proc_pid(inode));
8599 static inline int proc_fd(struct inode *inode)
8601 return PROC_I(inode)->fd;
8602 diff -NurpP --minimal linux-3.0/fs/proc/loadavg.c linux-3.0-vs2.3.1-pre7/fs/proc/loadavg.c
8603 --- linux-3.0/fs/proc/loadavg.c 2009-09-10 15:26:23.000000000 +0200
8604 +++ linux-3.0-vs2.3.1-pre7/fs/proc/loadavg.c 2011-06-10 22:11:24.000000000 +0200
8607 static int loadavg_proc_show(struct seq_file *m, void *v)
8609 + unsigned long running;
8610 + unsigned int threads;
8611 unsigned long avnrun[3];
8613 get_avenrun(avnrun, FIXED_1/200, 0);
8615 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
8616 + struct vx_info *vxi = current_vx_info();
8618 + running = atomic_read(&vxi->cvirt.nr_running);
8619 + threads = atomic_read(&vxi->cvirt.nr_threads);
8621 + running = nr_running();
8622 + threads = nr_threads;
8625 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
8626 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
8627 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
8628 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
8629 - nr_running(), nr_threads,
8631 task_active_pid_ns(current)->last_pid);
8634 diff -NurpP --minimal linux-3.0/fs/proc/meminfo.c linux-3.0-vs2.3.1-pre7/fs/proc/meminfo.c
8635 --- linux-3.0/fs/proc/meminfo.c 2011-03-15 18:07:33.000000000 +0100
8636 +++ linux-3.0-vs2.3.1-pre7/fs/proc/meminfo.c 2011-06-10 22:11:24.000000000 +0200
8637 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
8638 allowed = ((totalram_pages - hugetlb_total_pages())
8639 * sysctl_overcommit_ratio / 100) + total_swap_pages;
8641 - cached = global_page_state(NR_FILE_PAGES) -
8642 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
8643 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
8644 total_swapcache_pages - i.bufferram;
8647 diff -NurpP --minimal linux-3.0/fs/proc/root.c linux-3.0-vs2.3.1-pre7/fs/proc/root.c
8648 --- linux-3.0/fs/proc/root.c 2011-07-22 11:18:06.000000000 +0200
8649 +++ linux-3.0-vs2.3.1-pre7/fs/proc/root.c 2011-06-22 12:39:15.000000000 +0200
8651 #include <linux/bitops.h>
8652 #include <linux/mount.h>
8653 #include <linux/pid_namespace.h>
8654 +#include <linux/vserver/inode.h>
8656 #include "internal.h"
8658 +struct proc_dir_entry *proc_virtual;
8660 +extern void proc_vx_init(void);
8662 static int proc_test_super(struct super_block *sb, void *data)
8664 return sb->s_fs_info == data;
8665 @@ -125,6 +130,7 @@ void __init proc_root_init(void)
8667 proc_mkdir("bus", NULL);
8672 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
8673 @@ -193,6 +199,7 @@ struct proc_dir_entry proc_root = {
8674 .proc_iops = &proc_root_inode_operations,
8675 .proc_fops = &proc_root_operations,
8676 .parent = &proc_root,
8677 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
8680 int pid_ns_prepare_proc(struct pid_namespace *ns)
8681 diff -NurpP --minimal linux-3.0/fs/proc/uptime.c linux-3.0-vs2.3.1-pre7/fs/proc/uptime.c
8682 --- linux-3.0/fs/proc/uptime.c 2009-12-03 20:02:53.000000000 +0100
8683 +++ linux-3.0-vs2.3.1-pre7/fs/proc/uptime.c 2011-06-10 22:11:24.000000000 +0200
8685 #include <linux/sched.h>
8686 #include <linux/seq_file.h>
8687 #include <linux/time.h>
8688 -#include <linux/kernel_stat.h>
8689 +#include <linux/vserver/cvirt.h>
8690 #include <asm/cputime.h>
8692 static int uptime_proc_show(struct seq_file *m, void *v)
8694 struct timespec uptime;
8695 struct timespec idle;
8697 - cputime_t idletime = cputime_zero;
8699 - for_each_possible_cpu(i)
8700 - idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
8701 + cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
8703 do_posix_clock_monotonic_gettime(&uptime);
8704 monotonic_to_bootbased(&uptime);
8705 cputime_to_timespec(idletime, &idle);
8707 + if (vx_flags(VXF_VIRT_UPTIME, 0))
8708 + vx_vsi_uptime(&uptime, &idle);
8710 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
8711 (unsigned long) uptime.tv_sec,
8712 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
8713 diff -NurpP --minimal linux-3.0/fs/quota/dquot.c linux-3.0-vs2.3.1-pre7/fs/quota/dquot.c
8714 --- linux-3.0/fs/quota/dquot.c 2011-07-22 11:18:06.000000000 +0200
8715 +++ linux-3.0-vs2.3.1-pre7/fs/quota/dquot.c 2011-06-10 22:11:24.000000000 +0200
8716 @@ -1548,6 +1548,9 @@ int __dquot_alloc_space(struct inode *in
8717 int reserve = flags & DQUOT_SPACE_RESERVE;
8718 int nofail = flags & DQUOT_SPACE_NOFAIL;
8720 + if ((ret = dl_alloc_space(inode, number)))
8724 * First test before acquiring mutex - solves deadlocks when we
8725 * re-enter the quota code and are already holding the mutex
8726 @@ -1602,6 +1605,9 @@ int dquot_alloc_inode(const struct inode
8728 char warntype[MAXQUOTAS];
8730 + if ((ret = dl_alloc_inode(inode)))
8733 /* First test before acquiring mutex - solves deadlocks when we
8734 * re-enter the quota code and are already holding the mutex */
8735 if (!dquot_active(inode))
8736 @@ -1672,6 +1678,8 @@ void __dquot_free_space(struct inode *in
8737 char warntype[MAXQUOTAS];
8738 int reserve = flags & DQUOT_SPACE_RESERVE;
8740 + dl_free_space(inode, number);
8742 /* First test before acquiring mutex - solves deadlocks when we
8743 * re-enter the quota code and are already holding the mutex */
8744 if (!dquot_active(inode)) {
8745 @@ -1710,6 +1718,8 @@ void dquot_free_inode(const struct inode
8747 char warntype[MAXQUOTAS];
8749 + dl_free_inode(inode);
8751 /* First test before acquiring mutex - solves deadlocks when we
8752 * re-enter the quota code and are already holding the mutex */
8753 if (!dquot_active(inode))
8754 diff -NurpP --minimal linux-3.0/fs/quota/quota.c linux-3.0-vs2.3.1-pre7/fs/quota/quota.c
8755 --- linux-3.0/fs/quota/quota.c 2011-03-15 18:07:34.000000000 +0100
8756 +++ linux-3.0-vs2.3.1-pre7/fs/quota/quota.c 2011-06-13 18:19:47.000000000 +0200
8758 #include <linux/fs.h>
8759 #include <linux/namei.h>
8760 #include <linux/slab.h>
8761 +#include <linux/vs_context.h>
8762 #include <asm/current.h>
8763 #include <asm/uaccess.h>
8764 #include <linux/kernel.h>
8765 @@ -38,7 +39,7 @@ static int check_quotactl_permission(str
8769 - if (!capable(CAP_SYS_ADMIN))
8770 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
8774 @@ -293,6 +294,46 @@ static int do_quotactl(struct super_bloc
8778 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
8780 +#include <linux/vroot.h>
8781 +#include <linux/major.h>
8782 +#include <linux/module.h>
8783 +#include <linux/kallsyms.h>
8784 +#include <linux/vserver/debug.h>
8786 +static vroot_grb_func *vroot_get_real_bdev = NULL;
8788 +static DEFINE_SPINLOCK(vroot_grb_lock);
8790 +int register_vroot_grb(vroot_grb_func *func) {
8793 + spin_lock(&vroot_grb_lock);
8794 + if (!vroot_get_real_bdev) {
8795 + vroot_get_real_bdev = func;
8798 + spin_unlock(&vroot_grb_lock);
8801 +EXPORT_SYMBOL(register_vroot_grb);
8803 +int unregister_vroot_grb(vroot_grb_func *func) {
8804 + int ret = -EINVAL;
8806 + spin_lock(&vroot_grb_lock);
8807 + if (vroot_get_real_bdev) {
8808 + vroot_get_real_bdev = NULL;
8811 + spin_unlock(&vroot_grb_lock);
8814 +EXPORT_SYMBOL(unregister_vroot_grb);
8819 * look up a superblock on which quota ops will be performed
8820 * - use the name of a block device to find the superblock thereon
8821 @@ -310,6 +351,22 @@ static struct super_block *quotactl_bloc
8824 return ERR_CAST(bdev);
8825 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
8826 + if (bdev && bdev->bd_inode &&
8827 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
8828 + struct block_device *bdnew = (void *)-EINVAL;
8830 + if (vroot_get_real_bdev)
8831 + bdnew = vroot_get_real_bdev(bdev);
8833 + vxdprintk(VXD_CBIT(misc, 0),
8834 + "vroot_get_real_bdev not set");
8836 + if (IS_ERR(bdnew))
8837 + return ERR_PTR(PTR_ERR(bdnew));
8841 sb = get_super(bdev);
8844 diff -NurpP --minimal linux-3.0/fs/reiserfs/file.c linux-3.0-vs2.3.1-pre7/fs/reiserfs/file.c
8845 --- linux-3.0/fs/reiserfs/file.c 2011-01-05 21:50:26.000000000 +0100
8846 +++ linux-3.0-vs2.3.1-pre7/fs/reiserfs/file.c 2011-06-10 22:11:24.000000000 +0200
8847 @@ -312,4 +312,5 @@ const struct inode_operations reiserfs_f
8848 .listxattr = reiserfs_listxattr,
8849 .removexattr = reiserfs_removexattr,
8850 .permission = reiserfs_permission,
8851 + .sync_flags = reiserfs_sync_flags,
8853 diff -NurpP --minimal linux-3.0/fs/reiserfs/inode.c linux-3.0-vs2.3.1-pre7/fs/reiserfs/inode.c
8854 --- linux-3.0/fs/reiserfs/inode.c 2011-05-22 16:17:53.000000000 +0200
8855 +++ linux-3.0-vs2.3.1-pre7/fs/reiserfs/inode.c 2011-06-10 22:11:24.000000000 +0200
8857 #include <linux/writeback.h>
8858 #include <linux/quotaops.h>
8859 #include <linux/swap.h>
8860 +#include <linux/vs_tag.h>
8862 int reiserfs_commit_write(struct file *f, struct page *page,
8863 unsigned from, unsigned to);
8864 @@ -1131,6 +1132,8 @@ static void init_inode(struct inode *ino
8865 struct buffer_head *bh;
8866 struct item_head *ih;
8870 //int version = ITEM_VERSION_1;
8872 bh = PATH_PLAST_BUFFER(path);
8873 @@ -1151,12 +1154,13 @@ static void init_inode(struct inode *ino
8874 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
8875 unsigned long blocks;
8877 + uid = sd_v1_uid(sd);
8878 + gid = sd_v1_gid(sd);
8880 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
8881 set_inode_sd_version(inode, STAT_DATA_V1);
8882 inode->i_mode = sd_v1_mode(sd);
8883 inode->i_nlink = sd_v1_nlink(sd);
8884 - inode->i_uid = sd_v1_uid(sd);
8885 - inode->i_gid = sd_v1_gid(sd);
8886 inode->i_size = sd_v1_size(sd);
8887 inode->i_atime.tv_sec = sd_v1_atime(sd);
8888 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
8889 @@ -1198,11 +1202,12 @@ static void init_inode(struct inode *ino
8890 // (directories and symlinks)
8891 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
8893 + uid = sd_v2_uid(sd);
8894 + gid = sd_v2_gid(sd);
8896 inode->i_mode = sd_v2_mode(sd);
8897 inode->i_nlink = sd_v2_nlink(sd);
8898 - inode->i_uid = sd_v2_uid(sd);
8899 inode->i_size = sd_v2_size(sd);
8900 - inode->i_gid = sd_v2_gid(sd);
8901 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
8902 inode->i_atime.tv_sec = sd_v2_atime(sd);
8903 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
8904 @@ -1232,6 +1237,10 @@ static void init_inode(struct inode *ino
8905 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
8908 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
8909 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
8910 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
8913 if (S_ISREG(inode->i_mode)) {
8914 inode->i_op = &reiserfs_file_inode_operations;
8915 @@ -1254,13 +1263,15 @@ static void init_inode(struct inode *ino
8916 static void inode2sd(void *sd, struct inode *inode, loff_t size)
8918 struct stat_data *sd_v2 = (struct stat_data *)sd;
8919 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
8920 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
8923 + set_sd_v2_uid(sd_v2, uid);
8924 + set_sd_v2_gid(sd_v2, gid);
8925 set_sd_v2_mode(sd_v2, inode->i_mode);
8926 set_sd_v2_nlink(sd_v2, inode->i_nlink);
8927 - set_sd_v2_uid(sd_v2, inode->i_uid);
8928 set_sd_v2_size(sd_v2, size);
8929 - set_sd_v2_gid(sd_v2, inode->i_gid);
8930 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
8931 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
8932 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
8933 @@ -2863,14 +2874,19 @@ int reiserfs_commit_write(struct file *f
8934 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
8936 if (reiserfs_attrs(inode->i_sb)) {
8937 - if (sd_attrs & REISERFS_SYNC_FL)
8938 - inode->i_flags |= S_SYNC;
8940 - inode->i_flags &= ~S_SYNC;
8941 if (sd_attrs & REISERFS_IMMUTABLE_FL)
8942 inode->i_flags |= S_IMMUTABLE;
8944 inode->i_flags &= ~S_IMMUTABLE;
8945 + if (sd_attrs & REISERFS_IXUNLINK_FL)
8946 + inode->i_flags |= S_IXUNLINK;
8948 + inode->i_flags &= ~S_IXUNLINK;
8950 + if (sd_attrs & REISERFS_SYNC_FL)
8951 + inode->i_flags |= S_SYNC;
8953 + inode->i_flags &= ~S_SYNC;
8954 if (sd_attrs & REISERFS_APPEND_FL)
8955 inode->i_flags |= S_APPEND;
8957 @@ -2883,6 +2899,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
8958 REISERFS_I(inode)->i_flags |= i_nopack_mask;
8960 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
8962 + if (sd_attrs & REISERFS_BARRIER_FL)
8963 + inode->i_vflags |= V_BARRIER;
8965 + inode->i_vflags &= ~V_BARRIER;
8966 + if (sd_attrs & REISERFS_COW_FL)
8967 + inode->i_vflags |= V_COW;
8969 + inode->i_vflags &= ~V_COW;
8973 @@ -2893,6 +2918,11 @@ void i_attrs_to_sd_attrs(struct inode *i
8974 *sd_attrs |= REISERFS_IMMUTABLE_FL;
8976 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
8977 + if (inode->i_flags & S_IXUNLINK)
8978 + *sd_attrs |= REISERFS_IXUNLINK_FL;
8980 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
8982 if (inode->i_flags & S_SYNC)
8983 *sd_attrs |= REISERFS_SYNC_FL;
8985 @@ -2905,6 +2935,15 @@ void i_attrs_to_sd_attrs(struct inode *i
8986 *sd_attrs |= REISERFS_NOTAIL_FL;
8988 *sd_attrs &= ~REISERFS_NOTAIL_FL;
8990 + if (inode->i_vflags & V_BARRIER)
8991 + *sd_attrs |= REISERFS_BARRIER_FL;
8993 + *sd_attrs &= ~REISERFS_BARRIER_FL;
8994 + if (inode->i_vflags & V_COW)
8995 + *sd_attrs |= REISERFS_COW_FL;
8997 + *sd_attrs &= ~REISERFS_COW_FL;
9001 @@ -3148,7 +3187,8 @@ int reiserfs_setattr(struct dentry *dent
9004 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
9005 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
9006 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
9007 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
9008 struct reiserfs_transaction_handle th;
9011 @@ -3177,6 +3217,9 @@ int reiserfs_setattr(struct dentry *dent
9012 inode->i_uid = attr->ia_uid;
9013 if (attr->ia_valid & ATTR_GID)
9014 inode->i_gid = attr->ia_gid;
9015 + if ((attr->ia_valid & ATTR_TAG) &&
9017 + inode->i_tag = attr->ia_tag;
9018 mark_inode_dirty(inode);
9019 error = journal_end(&th, inode->i_sb, jbegin_count);
9021 diff -NurpP --minimal linux-3.0/fs/reiserfs/ioctl.c linux-3.0-vs2.3.1-pre7/fs/reiserfs/ioctl.c
9022 --- linux-3.0/fs/reiserfs/ioctl.c 2011-05-22 16:17:53.000000000 +0200
9023 +++ linux-3.0-vs2.3.1-pre7/fs/reiserfs/ioctl.c 2011-06-10 22:11:24.000000000 +0200
9025 #include <linux/pagemap.h>
9026 #include <linux/compat.h>
9029 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
9031 + __u16 sd_attrs = 0;
9033 + inode->i_flags = flags;
9034 + inode->i_vflags = vflags;
9036 + i_attrs_to_sd_attrs(inode, &sd_attrs);
9037 + REISERFS_I(inode)->i_attrs = sd_attrs;
9038 + inode->i_ctime = CURRENT_TIME_SEC;
9039 + mark_inode_dirty(inode);
9044 * reiserfs_ioctl - handler for ioctl for inode
9045 * supported commands:
9047 long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
9049 struct inode *inode = filp->f_path.dentry->d_inode;
9050 - unsigned int flags;
9051 + unsigned int flags, oldflags;
9054 reiserfs_write_lock(inode->i_sb);
9055 @@ -47,6 +62,7 @@ long reiserfs_ioctl(struct file *filp, u
9057 flags = REISERFS_I(inode)->i_attrs;
9058 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
9059 + flags &= REISERFS_FL_USER_VISIBLE;
9060 err = put_user(flags, (int __user *)arg);
9062 case REISERFS_IOC_SETFLAGS:{
9063 @@ -67,6 +83,10 @@ long reiserfs_ioctl(struct file *filp, u
9067 + if (IS_BARRIER(inode)) {
9068 + vxwprintk_task(1, "messing with the barrier.");
9072 * Is it quota file? Do not allow user to mess with it
9074 @@ -91,6 +111,10 @@ long reiserfs_ioctl(struct file *filp, u
9079 + oldflags = REISERFS_I(inode)->i_attrs;
9080 + flags &= REISERFS_FL_USER_MODIFIABLE;
9081 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
9082 sd_attrs_to_i_attrs(flags, inode);
9083 REISERFS_I(inode)->i_attrs = flags;
9084 inode->i_ctime = CURRENT_TIME_SEC;
9085 diff -NurpP --minimal linux-3.0/fs/reiserfs/namei.c linux-3.0-vs2.3.1-pre7/fs/reiserfs/namei.c
9086 --- linux-3.0/fs/reiserfs/namei.c 2011-05-22 16:17:53.000000000 +0200
9087 +++ linux-3.0-vs2.3.1-pre7/fs/reiserfs/namei.c 2011-06-10 22:11:24.000000000 +0200
9089 #include <linux/reiserfs_acl.h>
9090 #include <linux/reiserfs_xattr.h>
9091 #include <linux/quotaops.h>
9092 +#include <linux/vs_tag.h>
9094 #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; }
9095 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
9096 @@ -362,6 +363,7 @@ static struct dentry *reiserfs_lookup(st
9097 if (retval == IO_ERROR) {
9098 return ERR_PTR(-EIO);
9100 + dx_propagate_tag(nd, inode);
9102 return d_splice_alias(inode, dentry);
9104 @@ -1529,6 +1531,7 @@ const struct inode_operations reiserfs_d
9105 .listxattr = reiserfs_listxattr,
9106 .removexattr = reiserfs_removexattr,
9107 .permission = reiserfs_permission,
9108 + .sync_flags = reiserfs_sync_flags,
9112 diff -NurpP --minimal linux-3.0/fs/reiserfs/super.c linux-3.0-vs2.3.1-pre7/fs/reiserfs/super.c
9113 --- linux-3.0/fs/reiserfs/super.c 2011-07-22 11:18:06.000000000 +0200
9114 +++ linux-3.0-vs2.3.1-pre7/fs/reiserfs/super.c 2011-06-10 22:11:24.000000000 +0200
9115 @@ -899,6 +899,14 @@ static int reiserfs_parse_options(struct
9116 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
9117 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
9119 +#ifndef CONFIG_TAGGING_NONE
9120 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
9121 + {"tag",.setmask = 1 << REISERFS_TAGGED},
9122 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
9124 +#ifdef CONFIG_PROPAGATE
9125 + {"tag",.arg_required = 'T',.values = NULL},
9127 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
9128 {"acl",.setmask = 1 << REISERFS_POSIXACL},
9129 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
9130 @@ -1208,6 +1216,14 @@ static int reiserfs_remount(struct super
9131 handle_quota_files(s, qf_names, &qfmt);
9134 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
9135 + !(s->s_flags & MS_TAGGED)) {
9136 + reiserfs_warning(s, "super-vs01",
9137 + "reiserfs: tagging not permitted on remount.");
9144 /* Add options that are safe here */
9145 @@ -1690,6 +1706,10 @@ static int reiserfs_fill_super(struct su
9149 + /* map mount option tagxid */
9150 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
9151 + s->s_flags |= MS_TAGGED;
9153 rs = SB_DISK_SUPER_BLOCK(s);
9154 /* Let's do basic sanity check to verify that underlying device is not
9155 smaller than the filesystem. If the check fails then abort and scream,
9156 diff -NurpP --minimal linux-3.0/fs/reiserfs/xattr.c linux-3.0-vs2.3.1-pre7/fs/reiserfs/xattr.c
9157 --- linux-3.0/fs/reiserfs/xattr.c 2011-07-22 11:18:06.000000000 +0200
9158 +++ linux-3.0-vs2.3.1-pre7/fs/reiserfs/xattr.c 2011-06-22 12:39:15.000000000 +0200
9160 #include <linux/errno.h>
9161 #include <linux/gfp.h>
9162 #include <linux/fs.h>
9163 +#include <linux/mount.h>
9164 #include <linux/file.h>
9165 #include <linux/pagemap.h>
9166 #include <linux/xattr.h>
9167 diff -NurpP --minimal linux-3.0/fs/stat.c linux-3.0-vs2.3.1-pre7/fs/stat.c
9168 --- linux-3.0/fs/stat.c 2011-05-22 16:17:54.000000000 +0200
9169 +++ linux-3.0-vs2.3.1-pre7/fs/stat.c 2011-06-10 22:11:24.000000000 +0200
9170 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
9171 stat->nlink = inode->i_nlink;
9172 stat->uid = inode->i_uid;
9173 stat->gid = inode->i_gid;
9174 + stat->tag = inode->i_tag;
9175 stat->rdev = inode->i_rdev;
9176 stat->atime = inode->i_atime;
9177 stat->mtime = inode->i_mtime;
9178 diff -NurpP --minimal linux-3.0/fs/statfs.c linux-3.0-vs2.3.1-pre7/fs/statfs.c
9179 --- linux-3.0/fs/statfs.c 2011-05-22 16:17:54.000000000 +0200
9180 +++ linux-3.0-vs2.3.1-pre7/fs/statfs.c 2011-06-10 22:11:24.000000000 +0200
9182 #include <linux/statfs.h>
9183 #include <linux/security.h>
9184 #include <linux/uaccess.h>
9185 +#include <linux/vs_base.h>
9186 +#include <linux/vs_dlimit.h>
9188 static int flags_by_mnt(int mnt_flags)
9190 @@ -59,6 +61,8 @@ int statfs_by_dentry(struct dentry *dent
9191 retval = dentry->d_sb->s_op->statfs(dentry, buf);
9192 if (retval == 0 && buf->f_frsize == 0)
9193 buf->f_frsize = buf->f_bsize;
9194 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
9195 + vx_vsi_statfs(dentry->d_sb, buf);
9199 diff -NurpP --minimal linux-3.0/fs/super.c linux-3.0-vs2.3.1-pre7/fs/super.c
9200 --- linux-3.0/fs/super.c 2011-07-22 11:18:06.000000000 +0200
9201 +++ linux-3.0-vs2.3.1-pre7/fs/super.c 2011-07-23 16:49:09.000000000 +0200
9203 #include <linux/backing-dev.h>
9204 #include <linux/rculist_bl.h>
9205 #include <linux/cleancache.h>
9206 +#include <linux/devpts_fs.h>
9207 +#include <linux/proc_fs.h>
9208 +#include <linux/vs_context.h>
9209 #include "internal.h"
9212 @@ -943,6 +946,13 @@ mount_fs(struct file_system_type *type,
9213 WARN_ON(sb->s_bdi == &default_backing_dev_info);
9214 sb->s_flags |= MS_BORN;
9217 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) &&
9219 + (sb->s_magic != PROC_SUPER_MAGIC) &&
9220 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
9223 error = security_sb_kern_mount(sb, flags, secdata);
9226 diff -NurpP --minimal linux-3.0/fs/sysfs/mount.c linux-3.0-vs2.3.1-pre7/fs/sysfs/mount.c
9227 --- linux-3.0/fs/sysfs/mount.c 2011-07-22 11:18:06.000000000 +0200
9228 +++ linux-3.0-vs2.3.1-pre7/fs/sysfs/mount.c 2011-06-22 12:39:15.000000000 +0200
9229 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
9231 sb->s_blocksize = PAGE_CACHE_SIZE;
9232 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
9233 - sb->s_magic = SYSFS_MAGIC;
9234 + sb->s_magic = SYSFS_SUPER_MAGIC;
9235 sb->s_op = &sysfs_ops;
9236 sb->s_time_gran = 1;
9238 diff -NurpP --minimal linux-3.0/fs/utimes.c linux-3.0-vs2.3.1-pre7/fs/utimes.c
9239 --- linux-3.0/fs/utimes.c 2011-05-22 16:17:54.000000000 +0200
9240 +++ linux-3.0-vs2.3.1-pre7/fs/utimes.c 2011-06-10 22:11:24.000000000 +0200
9242 #include <linux/stat.h>
9243 #include <linux/utime.h>
9244 #include <linux/syscalls.h>
9245 +#include <linux/mount.h>
9246 +#include <linux/vs_cowbl.h>
9247 #include <asm/uaccess.h>
9248 #include <asm/unistd.h>
9250 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
9253 struct iattr newattrs;
9254 - struct inode *inode = path->dentry->d_inode;
9255 + struct inode *inode;
9257 error = mnt_want_write(path->mnt);
9261 + error = cow_check_and_break(path);
9263 + goto mnt_drop_write_and_out;
9265 + inode = path->dentry->d_inode;
9267 if (times && times[0].tv_nsec == UTIME_NOW &&
9268 times[1].tv_nsec == UTIME_NOW)
9270 diff -NurpP --minimal linux-3.0/fs/xattr.c linux-3.0-vs2.3.1-pre7/fs/xattr.c
9271 --- linux-3.0/fs/xattr.c 2011-07-22 11:18:09.000000000 +0200
9272 +++ linux-3.0-vs2.3.1-pre7/fs/xattr.c 2011-06-10 23:10:19.000000000 +0200
9274 #include <linux/module.h>
9275 #include <linux/fsnotify.h>
9276 #include <linux/audit.h>
9277 +#include <linux/mount.h>
9278 #include <asm/uaccess.h>
9281 @@ -49,7 +50,7 @@ xattr_permission(struct inode *inode, co
9282 * The trusted.* namespace can only be accessed by privileged users.
9284 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) {
9285 - if (!capable(CAP_SYS_ADMIN))
9286 + if (!vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED))
9287 return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
9290 diff -NurpP --minimal linux-3.0/fs/xfs/linux-2.6/xfs_ioctl.c linux-3.0-vs2.3.1-pre7/fs/xfs/linux-2.6/xfs_ioctl.c
9291 --- linux-3.0/fs/xfs/linux-2.6/xfs_ioctl.c 2011-05-22 16:17:54.000000000 +0200
9292 +++ linux-3.0-vs2.3.1-pre7/fs/xfs/linux-2.6/xfs_ioctl.c 2011-06-10 22:11:24.000000000 +0200
9294 #include "xfs_bmap_btree.h"
9295 #include "xfs_dinode.h"
9296 #include "xfs_inode.h"
9297 -#include "xfs_ioctl.h"
9298 +// #include "xfs_ioctl.h"
9299 #include "xfs_rtalloc.h"
9300 #include "xfs_itable.h"
9301 #include "xfs_error.h"
9302 @@ -748,6 +748,10 @@ xfs_merge_ioc_xflags(
9303 xflags |= XFS_XFLAG_IMMUTABLE;
9305 xflags &= ~XFS_XFLAG_IMMUTABLE;
9306 + if (flags & FS_IXUNLINK_FL)
9307 + xflags |= XFS_XFLAG_IXUNLINK;
9309 + xflags &= ~XFS_XFLAG_IXUNLINK;
9310 if (flags & FS_APPEND_FL)
9311 xflags |= XFS_XFLAG_APPEND;
9313 @@ -776,6 +780,8 @@ xfs_di2lxflags(
9315 if (di_flags & XFS_DIFLAG_IMMUTABLE)
9316 flags |= FS_IMMUTABLE_FL;
9317 + if (di_flags & XFS_DIFLAG_IXUNLINK)
9318 + flags |= FS_IXUNLINK_FL;
9319 if (di_flags & XFS_DIFLAG_APPEND)
9320 flags |= FS_APPEND_FL;
9321 if (di_flags & XFS_DIFLAG_SYNC)
9322 @@ -836,6 +842,8 @@ xfs_set_diflags(
9323 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
9324 if (xflags & XFS_XFLAG_IMMUTABLE)
9325 di_flags |= XFS_DIFLAG_IMMUTABLE;
9326 + if (xflags & XFS_XFLAG_IXUNLINK)
9327 + di_flags |= XFS_DIFLAG_IXUNLINK;
9328 if (xflags & XFS_XFLAG_APPEND)
9329 di_flags |= XFS_DIFLAG_APPEND;
9330 if (xflags & XFS_XFLAG_SYNC)
9331 @@ -878,6 +886,10 @@ xfs_diflags_to_linux(
9332 inode->i_flags |= S_IMMUTABLE;
9334 inode->i_flags &= ~S_IMMUTABLE;
9335 + if (xflags & XFS_XFLAG_IXUNLINK)
9336 + inode->i_flags |= S_IXUNLINK;
9338 + inode->i_flags &= ~S_IXUNLINK;
9339 if (xflags & XFS_XFLAG_APPEND)
9340 inode->i_flags |= S_APPEND;
9342 @@ -1370,10 +1382,18 @@ xfs_file_ioctl(
9343 case XFS_IOC_FSGETXATTRA:
9344 return xfs_ioc_fsgetxattr(ip, 1, arg);
9345 case XFS_IOC_FSSETXATTR:
9346 + if (IS_BARRIER(inode)) {
9347 + vxwprintk_task(1, "messing with the barrier.");
9348 + return -XFS_ERROR(EACCES);
9350 return xfs_ioc_fssetxattr(ip, filp, arg);
9351 case XFS_IOC_GETXFLAGS:
9352 return xfs_ioc_getxflags(ip, arg);
9353 case XFS_IOC_SETXFLAGS:
9354 + if (IS_BARRIER(inode)) {
9355 + vxwprintk_task(1, "messing with the barrier.");
9356 + return -XFS_ERROR(EACCES);
9358 return xfs_ioc_setxflags(ip, filp, arg);
9360 case XFS_IOC_FSSETDM: {
9361 diff -NurpP --minimal linux-3.0/fs/xfs/linux-2.6/xfs_ioctl.h linux-3.0-vs2.3.1-pre7/fs/xfs/linux-2.6/xfs_ioctl.h
9362 --- linux-3.0/fs/xfs/linux-2.6/xfs_ioctl.h 2010-07-07 18:31:54.000000000 +0200
9363 +++ linux-3.0-vs2.3.1-pre7/fs/xfs/linux-2.6/xfs_ioctl.h 2011-06-10 22:11:24.000000000 +0200
9364 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
9365 void __user *uhandle,
9370 + struct inode *inode,
9377 diff -NurpP --minimal linux-3.0/fs/xfs/linux-2.6/xfs_iops.c linux-3.0-vs2.3.1-pre7/fs/xfs/linux-2.6/xfs_iops.c
9378 --- linux-3.0/fs/xfs/linux-2.6/xfs_iops.c 2011-07-22 11:18:09.000000000 +0200
9379 +++ linux-3.0-vs2.3.1-pre7/fs/xfs/linux-2.6/xfs_iops.c 2011-06-22 12:39:15.000000000 +0200
9381 #include "xfs_bmap_btree.h"
9382 #include "xfs_dinode.h"
9383 #include "xfs_inode.h"
9384 +#include "xfs_ioctl.h"
9385 #include "xfs_bmap.h"
9386 #include "xfs_rtalloc.h"
9387 #include "xfs_error.h"
9389 #include <linux/security.h>
9390 #include <linux/fiemap.h>
9391 #include <linux/slab.h>
9392 +#include <linux/vs_tag.h>
9395 * Bring the timestamps in the XFS inode uptodate.
9396 @@ -464,6 +466,7 @@ xfs_vn_getattr(
9397 stat->nlink = ip->i_d.di_nlink;
9398 stat->uid = ip->i_d.di_uid;
9399 stat->gid = ip->i_d.di_gid;
9400 + stat->tag = ip->i_d.di_tag;
9401 stat->ino = ip->i_ino;
9402 stat->atime = inode->i_atime;
9403 stat->mtime = inode->i_mtime;
9404 @@ -599,6 +602,7 @@ static const struct inode_operations xfs
9405 .removexattr = generic_removexattr,
9406 .listxattr = xfs_vn_listxattr,
9407 .fiemap = xfs_vn_fiemap,
9408 + .sync_flags = xfs_sync_flags,
9411 static const struct inode_operations xfs_dir_inode_operations = {
9412 @@ -624,6 +628,7 @@ static const struct inode_operations xfs
9413 .getxattr = generic_getxattr,
9414 .removexattr = generic_removexattr,
9415 .listxattr = xfs_vn_listxattr,
9416 + .sync_flags = xfs_sync_flags,
9419 static const struct inode_operations xfs_dir_ci_inode_operations = {
9420 @@ -673,6 +678,10 @@ xfs_diflags_to_iflags(
9421 inode->i_flags |= S_IMMUTABLE;
9423 inode->i_flags &= ~S_IMMUTABLE;
9424 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
9425 + inode->i_flags |= S_IXUNLINK;
9427 + inode->i_flags &= ~S_IXUNLINK;
9428 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
9429 inode->i_flags |= S_APPEND;
9431 @@ -685,6 +694,15 @@ xfs_diflags_to_iflags(
9432 inode->i_flags |= S_NOATIME;
9434 inode->i_flags &= ~S_NOATIME;
9436 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
9437 + inode->i_vflags |= V_BARRIER;
9439 + inode->i_vflags &= ~V_BARRIER;
9440 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
9441 + inode->i_vflags |= V_COW;
9443 + inode->i_vflags &= ~V_COW;
9447 @@ -716,6 +734,7 @@ xfs_setup_inode(
9448 inode->i_nlink = ip->i_d.di_nlink;
9449 inode->i_uid = ip->i_d.di_uid;
9450 inode->i_gid = ip->i_d.di_gid;
9451 + inode->i_tag = ip->i_d.di_tag;
9453 switch (inode->i_mode & S_IFMT) {
9455 diff -NurpP --minimal linux-3.0/fs/xfs/linux-2.6/xfs_linux.h linux-3.0-vs2.3.1-pre7/fs/xfs/linux-2.6/xfs_linux.h
9456 --- linux-3.0/fs/xfs/linux-2.6/xfs_linux.h 2011-07-22 11:18:09.000000000 +0200
9457 +++ linux-3.0-vs2.3.1-pre7/fs/xfs/linux-2.6/xfs_linux.h 2011-06-10 22:11:24.000000000 +0200
9460 #define current_cpu() (raw_smp_processor_id())
9461 #define current_pid() (current->pid)
9462 +#define current_fstag(vp) (dx_current_fstag((vp)->i_sb))
9463 #define current_test_flags(f) (current->flags & (f))
9464 #define current_set_flags_nested(sp, f) \
9465 (*(sp) = current->flags, current->flags |= (f))
9466 diff -NurpP --minimal linux-3.0/fs/xfs/linux-2.6/xfs_super.c linux-3.0-vs2.3.1-pre7/fs/xfs/linux-2.6/xfs_super.c
9467 --- linux-3.0/fs/xfs/linux-2.6/xfs_super.c 2011-07-22 11:18:09.000000000 +0200
9468 +++ linux-3.0-vs2.3.1-pre7/fs/xfs/linux-2.6/xfs_super.c 2011-06-22 12:39:15.000000000 +0200
9469 @@ -114,6 +114,9 @@ mempool_t *xfs_ioend_pool;
9470 #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed logging disabled */
9471 #define MNTOPT_DISCARD "discard" /* Discard unused blocks */
9472 #define MNTOPT_NODISCARD "nodiscard" /* Do not discard unused blocks */
9473 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
9474 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
9475 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
9478 * Table driven mount option parser.
9479 @@ -122,10 +125,14 @@ mempool_t *xfs_ioend_pool;
9480 * in the future, too.
9483 + Opt_tag, Opt_notag,
9484 Opt_barrier, Opt_nobarrier, Opt_err
9487 static const match_table_t tokens = {
9488 + {Opt_tag, "tagxid"},
9490 + {Opt_notag, "notag"},
9491 {Opt_barrier, "barrier"},
9492 {Opt_nobarrier, "nobarrier"},
9494 @@ -373,6 +380,19 @@ xfs_parseargs(
9495 } else if (!strcmp(this_char, "irixsgid")) {
9497 "irixsgid is now a sysctl(2) variable, option is deprecated.");
9498 +#ifndef CONFIG_TAGGING_NONE
9499 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
9500 + mp->m_flags |= XFS_MOUNT_TAGGED;
9501 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
9502 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
9503 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
9504 + mp->m_flags |= XFS_MOUNT_TAGGED;
9506 +#ifdef CONFIG_PROPAGATE
9507 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
9509 + mp->m_flags |= XFS_MOUNT_TAGGED;
9512 xfs_warn(mp, "unknown mount option [%s].", this_char);
9514 @@ -1182,6 +1202,16 @@ xfs_fs_remount(
9516 mp->m_flags &= ~XFS_MOUNT_BARRIER;
9519 + if (!(sb->s_flags & MS_TAGGED)) {
9521 + "XFS: %s: tagging not permitted on remount.\n",
9530 * Logically we would return an error here to prevent
9531 @@ -1397,6 +1427,9 @@ xfs_fs_fill_super(
9535 + if (mp->m_flags & XFS_MOUNT_TAGGED)
9536 + sb->s_flags |= MS_TAGGED;
9539 * we must configure the block size in the superblock before we run the
9540 * full mount process as the mount process can lookup and cache inodes.
9541 diff -NurpP --minimal linux-3.0/fs/xfs/xfs_dinode.h linux-3.0-vs2.3.1-pre7/fs/xfs/xfs_dinode.h
9542 --- linux-3.0/fs/xfs/xfs_dinode.h 2011-01-05 21:50:28.000000000 +0100
9543 +++ linux-3.0-vs2.3.1-pre7/fs/xfs/xfs_dinode.h 2011-06-10 22:11:24.000000000 +0200
9544 @@ -51,7 +51,9 @@ typedef struct xfs_dinode {
9545 __be32 di_nlink; /* number of links to file */
9546 __be16 di_projid_lo; /* lower part of owner's project id */
9547 __be16 di_projid_hi; /* higher part owner's project id */
9548 - __u8 di_pad[6]; /* unused, zeroed space */
9549 + __u8 di_pad[2]; /* unused, zeroed space */
9550 + __be16 di_tag; /* context tagging */
9551 + __be16 di_vflags; /* vserver specific flags */
9552 __be16 di_flushiter; /* incremented on flush */
9553 xfs_timestamp_t di_atime; /* time last accessed */
9554 xfs_timestamp_t di_mtime; /* time last modified */
9555 @@ -184,6 +186,8 @@ static inline void xfs_dinode_put_rdev(s
9556 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
9557 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
9558 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
9559 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
9561 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
9562 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
9563 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
9564 @@ -199,6 +203,7 @@ static inline void xfs_dinode_put_rdev(s
9565 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
9566 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
9567 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
9568 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
9570 #ifdef CONFIG_XFS_RT
9571 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
9572 @@ -211,6 +216,10 @@ static inline void xfs_dinode_put_rdev(s
9573 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
9574 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
9575 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
9576 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
9577 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
9578 + XFS_DIFLAG_IXUNLINK)
9580 +#define XFS_DIVFLAG_BARRIER 0x01
9581 +#define XFS_DIVFLAG_COW 0x02
9583 #endif /* __XFS_DINODE_H__ */
9584 diff -NurpP --minimal linux-3.0/fs/xfs/xfs_fs.h linux-3.0-vs2.3.1-pre7/fs/xfs/xfs_fs.h
9585 --- linux-3.0/fs/xfs/xfs_fs.h 2011-01-05 21:50:28.000000000 +0100
9586 +++ linux-3.0-vs2.3.1-pre7/fs/xfs/xfs_fs.h 2011-06-10 22:11:24.000000000 +0200
9587 @@ -67,6 +67,9 @@ struct fsxattr {
9588 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
9589 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
9590 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
9591 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
9592 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
9593 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
9594 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
9597 @@ -297,7 +300,8 @@ typedef struct xfs_bstat {
9598 #define bs_projid bs_projid_lo /* (previously just bs_projid) */
9599 __u16 bs_forkoff; /* inode fork offset in bytes */
9600 __u16 bs_projid_hi; /* higher part of project id */
9601 - unsigned char bs_pad[10]; /* pad space, unused */
9602 + unsigned char bs_pad[8]; /* pad space, unused */
9603 + __u16 bs_tag; /* context tagging */
9604 __u32 bs_dmevmask; /* DMIG event mask */
9605 __u16 bs_dmstate; /* DMIG state info */
9606 __u16 bs_aextents; /* attribute number of extents */
9607 diff -NurpP --minimal linux-3.0/fs/xfs/xfs_ialloc.c linux-3.0-vs2.3.1-pre7/fs/xfs/xfs_ialloc.c
9608 --- linux-3.0/fs/xfs/xfs_ialloc.c 2011-05-22 16:17:54.000000000 +0200
9609 +++ linux-3.0-vs2.3.1-pre7/fs/xfs/xfs_ialloc.c 2011-06-10 22:11:24.000000000 +0200
9611 #include "xfs_error.h"
9612 #include "xfs_bmap.h"
9616 * Allocation group level functions.
9618 diff -NurpP --minimal linux-3.0/fs/xfs/xfs_inode.c linux-3.0-vs2.3.1-pre7/fs/xfs/xfs_inode.c
9619 --- linux-3.0/fs/xfs/xfs_inode.c 2011-07-22 11:18:10.000000000 +0200
9620 +++ linux-3.0-vs2.3.1-pre7/fs/xfs/xfs_inode.c 2011-06-10 22:11:24.000000000 +0200
9621 @@ -243,6 +243,7 @@ xfs_inotobp(
9625 +#include <linux/vs_tag.h>
9628 * This routine is called to map an inode to the buffer containing
9629 @@ -641,15 +642,25 @@ xfs_iformat_btree(
9631 xfs_dinode_from_disk(
9633 - xfs_dinode_t *from)
9634 + xfs_dinode_t *from,
9637 + uint32_t uid, gid, tag;
9639 to->di_magic = be16_to_cpu(from->di_magic);
9640 to->di_mode = be16_to_cpu(from->di_mode);
9641 to->di_version = from ->di_version;
9642 to->di_format = from->di_format;
9643 to->di_onlink = be16_to_cpu(from->di_onlink);
9644 - to->di_uid = be32_to_cpu(from->di_uid);
9645 - to->di_gid = be32_to_cpu(from->di_gid);
9647 + uid = be32_to_cpu(from->di_uid);
9648 + gid = be32_to_cpu(from->di_gid);
9649 + tag = be16_to_cpu(from->di_tag);
9651 + to->di_uid = INOTAG_UID(tagged, uid, gid);
9652 + to->di_gid = INOTAG_GID(tagged, uid, gid);
9653 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
9655 to->di_nlink = be32_to_cpu(from->di_nlink);
9656 to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
9657 to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
9658 @@ -671,21 +682,26 @@ xfs_dinode_from_disk(
9659 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
9660 to->di_dmstate = be16_to_cpu(from->di_dmstate);
9661 to->di_flags = be16_to_cpu(from->di_flags);
9662 + to->di_vflags = be16_to_cpu(from->di_vflags);
9663 to->di_gen = be32_to_cpu(from->di_gen);
9669 - xfs_icdinode_t *from)
9670 + xfs_icdinode_t *from,
9673 to->di_magic = cpu_to_be16(from->di_magic);
9674 to->di_mode = cpu_to_be16(from->di_mode);
9675 to->di_version = from ->di_version;
9676 to->di_format = from->di_format;
9677 to->di_onlink = cpu_to_be16(from->di_onlink);
9678 - to->di_uid = cpu_to_be32(from->di_uid);
9679 - to->di_gid = cpu_to_be32(from->di_gid);
9681 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
9682 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
9683 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
9685 to->di_nlink = cpu_to_be32(from->di_nlink);
9686 to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
9687 to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
9688 @@ -707,12 +723,14 @@ xfs_dinode_to_disk(
9689 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
9690 to->di_dmstate = cpu_to_be16(from->di_dmstate);
9691 to->di_flags = cpu_to_be16(from->di_flags);
9692 + to->di_vflags = cpu_to_be16(from->di_vflags);
9693 to->di_gen = cpu_to_be32(from->di_gen);
9698 - __uint16_t di_flags)
9699 + __uint16_t di_flags,
9700 + __uint16_t di_vflags)
9704 @@ -723,6 +741,8 @@ _xfs_dic2xflags(
9705 flags |= XFS_XFLAG_PREALLOC;
9706 if (di_flags & XFS_DIFLAG_IMMUTABLE)
9707 flags |= XFS_XFLAG_IMMUTABLE;
9708 + if (di_flags & XFS_DIFLAG_IXUNLINK)
9709 + flags |= XFS_XFLAG_IXUNLINK;
9710 if (di_flags & XFS_DIFLAG_APPEND)
9711 flags |= XFS_XFLAG_APPEND;
9712 if (di_flags & XFS_DIFLAG_SYNC)
9713 @@ -747,6 +767,10 @@ _xfs_dic2xflags(
9714 flags |= XFS_XFLAG_FILESTREAM;
9717 + if (di_vflags & XFS_DIVFLAG_BARRIER)
9718 + flags |= FS_BARRIER_FL;
9719 + if (di_vflags & XFS_DIVFLAG_COW)
9720 + flags |= FS_COW_FL;
9724 @@ -756,7 +780,7 @@ xfs_ip2xflags(
9726 xfs_icdinode_t *dic = &ip->i_d;
9728 - return _xfs_dic2xflags(dic->di_flags) |
9729 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
9730 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
9733 @@ -764,7 +788,8 @@ uint
9737 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
9738 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
9739 + be16_to_cpu(dip->di_vflags)) |
9740 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
9743 @@ -797,7 +822,6 @@ xfs_iread(
9746 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
9749 * If we got something that isn't an inode it means someone
9750 * (nfs or dmi) has a stale handle.
9751 @@ -820,7 +844,8 @@ xfs_iread(
9752 * Otherwise, just get the truly permanent information.
9755 - xfs_dinode_from_disk(&ip->i_d, dip);
9756 + xfs_dinode_from_disk(&ip->i_d, dip,
9757 + mp->m_flags & XFS_MOUNT_TAGGED);
9758 error = xfs_iformat(ip, dip);
9761 @@ -1015,6 +1040,7 @@ xfs_ialloc(
9762 ASSERT(ip->i_d.di_nlink == nlink);
9763 ip->i_d.di_uid = current_fsuid();
9764 ip->i_d.di_gid = current_fsgid();
9765 + ip->i_d.di_tag = current_fstag(&ip->i_vnode);
9766 xfs_set_projid(ip, prid);
9767 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
9769 @@ -1075,6 +1101,7 @@ xfs_ialloc(
9770 ip->i_d.di_dmevmask = 0;
9771 ip->i_d.di_dmstate = 0;
9772 ip->i_d.di_flags = 0;
9773 + ip->i_d.di_vflags = 0;
9774 flags = XFS_ILOG_CORE;
9775 switch (mode & S_IFMT) {
9777 @@ -2108,6 +2135,7 @@ xfs_ifree(
9779 ip->i_d.di_mode = 0; /* mark incore inode as free */
9780 ip->i_d.di_flags = 0;
9781 + ip->i_d.di_vflags = 0;
9782 ip->i_d.di_dmevmask = 0;
9783 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
9784 ip->i_df.if_ext_max =
9785 @@ -2987,7 +3015,8 @@ xfs_iflush_int(
9786 * because if the inode is dirty at all the core must
9789 - xfs_dinode_to_disk(dip, &ip->i_d);
9790 + xfs_dinode_to_disk(dip, &ip->i_d,
9791 + mp->m_flags & XFS_MOUNT_TAGGED);
9793 /* Wrap, we never let the log put out DI_MAX_FLUSH */
9794 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
9795 diff -NurpP --minimal linux-3.0/fs/xfs/xfs_inode.h linux-3.0-vs2.3.1-pre7/fs/xfs/xfs_inode.h
9796 --- linux-3.0/fs/xfs/xfs_inode.h 2011-07-22 11:18:10.000000000 +0200
9797 +++ linux-3.0-vs2.3.1-pre7/fs/xfs/xfs_inode.h 2011-07-01 11:35:35.000000000 +0200
9798 @@ -135,7 +135,9 @@ typedef struct xfs_icdinode {
9799 __uint32_t di_nlink; /* number of links to file */
9800 __uint16_t di_projid_lo; /* lower part of owner's project id */
9801 __uint16_t di_projid_hi; /* higher part of owner's project id */
9802 - __uint8_t di_pad[6]; /* unused, zeroed space */
9803 + __uint8_t di_pad[2]; /* unused, zeroed space */
9804 + __uint16_t di_tag; /* context tagging */
9805 + __uint16_t di_vflags; /* vserver specific flags */
9806 __uint16_t di_flushiter; /* incremented on flush */
9807 xfs_ictimestamp_t di_atime; /* time last accessed */
9808 xfs_ictimestamp_t di_mtime; /* time last modified */
9809 @@ -546,7 +548,7 @@ int xfs_itobp(struct xfs_mount *, struc
9810 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
9811 struct xfs_inode *, uint);
9812 void xfs_dinode_to_disk(struct xfs_dinode *,
9813 - struct xfs_icdinode *);
9814 + struct xfs_icdinode *, int);
9815 void xfs_idestroy_fork(struct xfs_inode *, int);
9816 void xfs_idata_realloc(struct xfs_inode *, int, int);
9817 void xfs_iroot_realloc(struct xfs_inode *, int, int);
9818 diff -NurpP --minimal linux-3.0/fs/xfs/xfs_itable.c linux-3.0-vs2.3.1-pre7/fs/xfs/xfs_itable.c
9819 --- linux-3.0/fs/xfs/xfs_itable.c 2011-05-22 16:17:54.000000000 +0200
9820 +++ linux-3.0-vs2.3.1-pre7/fs/xfs/xfs_itable.c 2011-06-10 22:11:24.000000000 +0200
9821 @@ -98,6 +98,7 @@ xfs_bulkstat_one_int(
9822 buf->bs_mode = dic->di_mode;
9823 buf->bs_uid = dic->di_uid;
9824 buf->bs_gid = dic->di_gid;
9825 + buf->bs_tag = dic->di_tag;
9826 buf->bs_size = dic->di_size;
9829 diff -NurpP --minimal linux-3.0/fs/xfs/xfs_log_recover.c linux-3.0-vs2.3.1-pre7/fs/xfs/xfs_log_recover.c
9830 --- linux-3.0/fs/xfs/xfs_log_recover.c 2011-07-22 11:18:10.000000000 +0200
9831 +++ linux-3.0-vs2.3.1-pre7/fs/xfs/xfs_log_recover.c 2011-06-10 22:11:24.000000000 +0200
9832 @@ -2343,7 +2343,8 @@ xlog_recover_inode_pass2(
9835 /* The core is in in-core format */
9836 - xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr);
9837 + xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr,
9838 + mp->m_flags & XFS_MOUNT_TAGGED);
9840 /* the rest is in on-disk format */
9841 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
9842 diff -NurpP --minimal linux-3.0/fs/xfs/xfs_mount.h linux-3.0-vs2.3.1-pre7/fs/xfs/xfs_mount.h
9843 --- linux-3.0/fs/xfs/xfs_mount.h 2011-07-22 11:18:10.000000000 +0200
9844 +++ linux-3.0-vs2.3.1-pre7/fs/xfs/xfs_mount.h 2011-06-10 22:11:24.000000000 +0200
9845 @@ -249,6 +249,7 @@ typedef struct xfs_mount {
9847 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
9849 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
9852 * Default minimum read and write sizes.
9853 diff -NurpP --minimal linux-3.0/fs/xfs/xfs_vnodeops.c linux-3.0-vs2.3.1-pre7/fs/xfs/xfs_vnodeops.c
9854 --- linux-3.0/fs/xfs/xfs_vnodeops.c 2011-07-22 11:18:10.000000000 +0200
9855 +++ linux-3.0-vs2.3.1-pre7/fs/xfs/xfs_vnodeops.c 2011-07-01 11:35:35.000000000 +0200
9857 #include "xfs_vnodeops.h"
9858 #include "xfs_trace.h"
9862 +xfs_get_inode_flags(
9865 + struct inode *inode = VFS_I(ip);
9866 + unsigned int flags = inode->i_flags;
9867 + unsigned int vflags = inode->i_vflags;
9869 + if (flags & S_IMMUTABLE)
9870 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
9872 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
9873 + if (flags & S_IXUNLINK)
9874 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
9876 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
9878 + if (vflags & V_BARRIER)
9879 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
9881 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
9882 + if (vflags & V_COW)
9883 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
9885 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
9890 + struct inode *inode,
9894 + struct xfs_inode *ip = XFS_I(inode);
9895 + struct xfs_mount *mp = ip->i_mount;
9896 + struct xfs_trans *tp;
9897 + unsigned int lock_flags = 0;
9900 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
9901 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
9905 + xfs_ilock(ip, XFS_ILOCK_EXCL);
9907 + xfs_trans_ijoin(tp, ip);
9909 + inode->i_flags = flags;
9910 + inode->i_vflags = vflags;
9911 + xfs_get_inode_flags(ip);
9913 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
9914 + xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
9916 + XFS_STATS_INC(xs_ig_attrchg);
9918 + if (mp->m_flags & XFS_MOUNT_WSYNC)
9919 + xfs_trans_set_sync(tp);
9920 + code = xfs_trans_commit(tp, 0);
9921 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
9925 + xfs_trans_cancel(tp, 0);
9927 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
9934 struct xfs_inode *ip,
9935 @@ -65,6 +137,7 @@ xfs_setattr(
9936 uint commit_flags=0;
9937 uid_t uid=0, iuid=0;
9938 gid_t gid=0, igid=0;
9939 + tag_t tag=0, itag=0;
9940 struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2;
9941 int need_iolock = 1;
9943 @@ -147,7 +220,7 @@ xfs_setattr(
9945 * Change file ownership. Must be the owner or privileged.
9947 - if (mask & (ATTR_UID|ATTR_GID)) {
9948 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
9950 * These IDs could have changed since we last looked at them.
9951 * But, we're assured that if the ownership did change
9952 @@ -156,8 +229,10 @@ xfs_setattr(
9954 iuid = ip->i_d.di_uid;
9955 igid = ip->i_d.di_gid;
9956 + itag = ip->i_d.di_tag;
9957 gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
9958 uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
9959 + tag = (mask & ATTR_TAG) ? iattr->ia_tag : itag;
9962 * Do a quota reservation only if uid/gid is actually
9963 @@ -165,7 +240,8 @@ xfs_setattr(
9965 if (XFS_IS_QUOTA_RUNNING(mp) &&
9966 ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) ||
9967 - (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {
9968 + (XFS_IS_GQUOTA_ON(mp) && igid != gid) ||
9969 + (XFS_IS_GQUOTA_ON(mp) && itag != tag))) {
9971 code = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp,
9972 capable(CAP_FOWNER) ?
9973 @@ -329,7 +405,7 @@ xfs_setattr(
9975 * Change file ownership. Must be the owner or privileged.
9977 - if (mask & (ATTR_UID|ATTR_GID)) {
9978 + if (mask & (ATTR_UID|ATTR_GID|ATTR_TAG)) {
9980 * CAP_FSETID overrides the following restrictions:
9982 @@ -345,6 +421,10 @@ xfs_setattr(
9983 * Change the ownerships and register quota modifications
9984 * in the transaction.
9986 + if (itag != tag) {
9987 + ip->i_d.di_tag = tag;
9988 + inode->i_tag = tag;
9991 if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {
9992 ASSERT(mask & ATTR_UID);
9993 diff -NurpP --minimal linux-3.0/fs/xfs/xfs_vnodeops.h linux-3.0-vs2.3.1-pre7/fs/xfs/xfs_vnodeops.h
9994 --- linux-3.0/fs/xfs/xfs_vnodeops.h 2011-05-22 16:17:54.000000000 +0200
9995 +++ linux-3.0-vs2.3.1-pre7/fs/xfs/xfs_vnodeops.h 2011-06-10 22:11:24.000000000 +0200
9996 @@ -13,6 +13,7 @@ struct xfs_inode;
10000 +int xfs_sync_xflags(struct xfs_inode *ip);
10001 int xfs_setattr(struct xfs_inode *ip, struct iattr *vap, int flags);
10002 #define XFS_ATTR_DMI 0x01 /* invocation from a DMI function */
10003 #define XFS_ATTR_NONBLOCK 0x02 /* return EAGAIN if operation would block */
10004 diff -NurpP --minimal linux-3.0/include/asm-generic/tlb.h linux-3.0-vs2.3.1-pre7/include/asm-generic/tlb.h
10005 --- linux-3.0/include/asm-generic/tlb.h 2011-07-22 11:18:10.000000000 +0200
10006 +++ linux-3.0-vs2.3.1-pre7/include/asm-generic/tlb.h 2011-06-10 22:11:24.000000000 +0200
10008 #define _ASM_GENERIC__TLB_H
10010 #include <linux/swap.h>
10011 +#include <linux/vs_memory.h>
10012 #include <asm/pgalloc.h>
10013 #include <asm/tlbflush.h>
10015 diff -NurpP --minimal linux-3.0/include/linux/Kbuild linux-3.0-vs2.3.1-pre7/include/linux/Kbuild
10016 --- linux-3.0/include/linux/Kbuild 2011-07-22 11:18:10.000000000 +0200
10017 +++ linux-3.0-vs2.3.1-pre7/include/linux/Kbuild 2011-06-10 22:11:24.000000000 +0200
10018 @@ -17,6 +17,7 @@ header-y += netfilter_bridge/
10019 header-y += netfilter_ipv4/
10020 header-y += netfilter_ipv6/
10022 +header-y += vserver/
10025 objhdr-y += version.h
10026 diff -NurpP --minimal linux-3.0/include/linux/capability.h linux-3.0-vs2.3.1-pre7/include/linux/capability.h
10027 --- linux-3.0/include/linux/capability.h 2011-07-22 11:18:10.000000000 +0200
10028 +++ linux-3.0-vs2.3.1-pre7/include/linux/capability.h 2011-06-10 22:11:24.000000000 +0200
10029 @@ -279,6 +279,7 @@ struct cpu_vfs_cap_data {
10030 arbitrary SCSI commands */
10031 /* Allow setting encryption key on loopback filesystem */
10032 /* Allow setting zone reclaim policy */
10033 +/* Allow the selection of a security context */
10035 #define CAP_SYS_ADMIN 21
10037 @@ -362,7 +363,12 @@ struct cpu_vfs_cap_data {
10039 #define CAP_LAST_CAP CAP_WAKE_ALARM
10041 -#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
10042 +/* Allow context manipulations */
10043 +/* Allow changing context info on files */
10045 +#define CAP_CONTEXT 63
10047 +#define cap_valid(x) ((x) >= 0 && ((x) <= CAP_LAST_CAP || (x) == CAP_CONTEXT))
10050 * Bit location of each capability (used by user-space library and kernel)
10051 diff -NurpP --minimal linux-3.0/include/linux/cred.h linux-3.0-vs2.3.1-pre7/include/linux/cred.h
10052 --- linux-3.0/include/linux/cred.h 2011-07-22 11:18:10.000000000 +0200
10053 +++ linux-3.0-vs2.3.1-pre7/include/linux/cred.h 2011-06-10 22:11:24.000000000 +0200
10054 @@ -156,6 +156,7 @@ extern void exit_creds(struct task_struc
10055 extern int copy_creds(struct task_struct *, unsigned long);
10056 extern const struct cred *get_task_cred(struct task_struct *);
10057 extern struct cred *cred_alloc_blank(void);
10058 +extern struct cred *__prepare_creds(const struct cred *);
10059 extern struct cred *prepare_creds(void);
10060 extern struct cred *prepare_exec_creds(void);
10061 extern int commit_creds(struct cred *);
10062 @@ -209,6 +210,31 @@ static inline void validate_process_cred
10066 +static inline void set_cred_subscribers(struct cred *cred, int n)
10068 +#ifdef CONFIG_DEBUG_CREDENTIALS
10069 + atomic_set(&cred->subscribers, n);
10073 +static inline int read_cred_subscribers(const struct cred *cred)
10075 +#ifdef CONFIG_DEBUG_CREDENTIALS
10076 + return atomic_read(&cred->subscribers);
10082 +static inline void alter_cred_subscribers(const struct cred *_cred, int n)
10084 +#ifdef CONFIG_DEBUG_CREDENTIALS
10085 + struct cred *cred = (struct cred *) _cred;
10087 + atomic_add(n, &cred->subscribers);
10092 * get_new_cred - Get a reference on a new set of credentials
10093 * @cred: The new credentials to reference
10094 diff -NurpP --minimal linux-3.0/include/linux/devpts_fs.h linux-3.0-vs2.3.1-pre7/include/linux/devpts_fs.h
10095 --- linux-3.0/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
10096 +++ linux-3.0-vs2.3.1-pre7/include/linux/devpts_fs.h 2011-06-10 22:11:24.000000000 +0200
10097 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
10102 #endif /* _LINUX_DEVPTS_FS_H */
10103 diff -NurpP --minimal linux-3.0/include/linux/ext2_fs.h linux-3.0-vs2.3.1-pre7/include/linux/ext2_fs.h
10104 --- linux-3.0/include/linux/ext2_fs.h 2010-02-25 11:52:07.000000000 +0100
10105 +++ linux-3.0-vs2.3.1-pre7/include/linux/ext2_fs.h 2011-06-10 22:11:24.000000000 +0200
10106 @@ -189,8 +189,12 @@ struct ext2_group_desc
10107 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
10108 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
10109 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
10110 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
10111 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
10113 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
10114 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
10116 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
10117 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
10119 @@ -274,7 +278,8 @@ struct ext2_inode {
10121 __le16 l_i_uid_high; /* these 2 fields */
10122 __le16 l_i_gid_high; /* were reserved2[0] */
10123 - __u32 l_i_reserved2;
10124 + __le16 l_i_tag; /* Context Tag */
10125 + __u16 l_i_reserved2;
10128 __u8 h_i_frag; /* Fragment number */
10129 @@ -303,6 +308,7 @@ struct ext2_inode {
10130 #define i_gid_low i_gid
10131 #define i_uid_high osd2.linux2.l_i_uid_high
10132 #define i_gid_high osd2.linux2.l_i_gid_high
10133 +#define i_raw_tag osd2.linux2.l_i_tag
10134 #define i_reserved2 osd2.linux2.l_i_reserved2
10137 @@ -347,6 +353,7 @@ struct ext2_inode {
10138 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
10139 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
10140 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
10141 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
10144 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
10145 diff -NurpP --minimal linux-3.0/include/linux/ext3_fs.h linux-3.0-vs2.3.1-pre7/include/linux/ext3_fs.h
10146 --- linux-3.0/include/linux/ext3_fs.h 2011-07-22 11:18:10.000000000 +0200
10147 +++ linux-3.0-vs2.3.1-pre7/include/linux/ext3_fs.h 2011-06-10 22:11:24.000000000 +0200
10148 @@ -173,10 +173,14 @@ struct ext3_group_desc
10149 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
10150 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
10151 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
10152 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
10153 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
10155 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
10156 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
10157 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
10158 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
10160 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
10161 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
10163 /* Flags that should be inherited by new inodes from their parent. */
10164 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
10165 @@ -312,7 +316,8 @@ struct ext3_inode {
10167 __le16 l_i_uid_high; /* these 2 fields */
10168 __le16 l_i_gid_high; /* were reserved2[0] */
10169 - __u32 l_i_reserved2;
10170 + __le16 l_i_tag; /* Context Tag */
10171 + __u16 l_i_reserved2;
10174 __u8 h_i_frag; /* Fragment number */
10175 @@ -343,6 +348,7 @@ struct ext3_inode {
10176 #define i_gid_low i_gid
10177 #define i_uid_high osd2.linux2.l_i_uid_high
10178 #define i_gid_high osd2.linux2.l_i_gid_high
10179 +#define i_raw_tag osd2.linux2.l_i_tag
10180 #define i_reserved2 osd2.linux2.l_i_reserved2
10182 #elif defined(__GNU__)
10183 @@ -405,6 +411,7 @@ struct ext3_inode {
10184 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
10185 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
10186 * error in ordered mode */
10187 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
10189 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
10190 #ifndef _LINUX_EXT2_FS_H
10191 @@ -919,6 +926,7 @@ extern void ext3_get_inode_flags(struct
10192 extern void ext3_set_aops(struct inode *inode);
10193 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
10194 u64 start, u64 len);
10195 +extern int ext3_sync_flags(struct inode *, int, int);
10198 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
10199 diff -NurpP --minimal linux-3.0/include/linux/fs.h linux-3.0-vs2.3.1-pre7/include/linux/fs.h
10200 --- linux-3.0/include/linux/fs.h 2011-07-22 11:18:10.000000000 +0200
10201 +++ linux-3.0-vs2.3.1-pre7/include/linux/fs.h 2011-07-01 11:35:35.000000000 +0200
10202 @@ -208,6 +208,9 @@ struct inodes_stat_t {
10203 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
10204 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
10205 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
10206 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
10207 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
10208 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
10209 #define MS_NOSEC (1<<28)
10210 #define MS_BORN (1<<29)
10211 #define MS_ACTIVE (1<<30)
10212 @@ -239,6 +242,14 @@ struct inodes_stat_t {
10213 #define S_IMA 1024 /* Inode has an associated IMA struct */
10214 #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
10215 #define S_NOSEC 4096 /* no suid or xattr security attributes */
10216 +#define S_IXUNLINK 8192 /* Immutable Invert on unlink */
10218 +/* Linux-VServer related Inode flags */
10222 +#define V_BARRIER 4 /* Barrier for chroot() */
10223 +#define V_COW 8 /* Copy on Write */
10226 * Note that nosuid etc flags are inode-specific: setting some file-system
10227 @@ -261,12 +272,15 @@ struct inodes_stat_t {
10228 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
10229 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
10230 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
10231 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
10232 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
10233 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
10234 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
10235 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
10237 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
10238 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
10239 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
10240 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
10241 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
10242 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
10244 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
10245 @@ -277,6 +291,16 @@ struct inodes_stat_t {
10246 #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
10247 #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
10249 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
10251 +#ifdef CONFIG_VSERVER_COWBL
10252 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
10253 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
10255 +# define IS_COW(inode) (0)
10256 +# define IS_COW_LINK(inode) (0)
10259 /* the read-only stuff doesn't really belong here, but any other place is
10260 probably as bad and I don't want to create yet another include file. */
10262 @@ -362,11 +386,14 @@ struct inodes_stat_t {
10263 #define FS_EXTENT_FL 0x00080000 /* Extents */
10264 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
10265 #define FS_NOCOW_FL 0x00800000 /* Do not cow file */
10266 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
10267 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
10269 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
10270 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
10272 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
10273 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
10275 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
10276 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
10278 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
10279 #define SYNC_FILE_RANGE_WRITE 2
10280 @@ -447,6 +474,7 @@ typedef void (dio_iodone_t)(struct kiocb
10281 #define ATTR_KILL_PRIV (1 << 14)
10282 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
10283 #define ATTR_TIMES_SET (1 << 16)
10284 +#define ATTR_TAG (1 << 17)
10287 * This is the Inode Attributes structure, used for notify_change(). It
10288 @@ -462,6 +490,7 @@ struct iattr {
10294 struct timespec ia_atime;
10295 struct timespec ia_mtime;
10296 @@ -475,6 +504,9 @@ struct iattr {
10297 struct file *ia_file;
10300 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
10301 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
10304 * Includes for diskquotas.
10306 @@ -740,11 +772,13 @@ struct inode {
10311 const struct inode_operations *i_op;
10312 struct super_block *i_sb;
10314 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
10315 - unsigned int i_flags;
10316 + unsigned short i_flags;
10317 + unsigned short i_vflags;
10318 unsigned long i_state;
10319 #ifdef CONFIG_SECURITY
10321 @@ -766,6 +800,7 @@ struct inode {
10323 unsigned int i_nlink;
10326 unsigned int i_blkbits;
10329 @@ -890,12 +925,12 @@ static inline void i_size_write(struct i
10331 static inline unsigned iminor(const struct inode *inode)
10333 - return MINOR(inode->i_rdev);
10334 + return MINOR(inode->i_mdev);
10337 static inline unsigned imajor(const struct inode *inode)
10339 - return MAJOR(inode->i_rdev);
10340 + return MAJOR(inode->i_mdev);
10343 extern struct block_device *I_BDEV(struct inode *inode);
10344 @@ -957,6 +992,7 @@ struct file {
10346 struct fown_struct f_owner;
10347 const struct cred *f_cred;
10349 struct file_ra_state f_ra;
10352 @@ -1101,6 +1137,7 @@ struct file_lock {
10353 struct file *fl_file;
10358 struct fasync_struct * fl_fasync; /* for lease break notifications */
10359 unsigned long fl_break_time; /* for nonblocking lease breaks */
10360 @@ -1600,6 +1637,7 @@ struct inode_operations {
10361 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
10362 ssize_t (*listxattr) (struct dentry *, char *, size_t);
10363 int (*removexattr) (struct dentry *, const char *);
10364 + int (*sync_flags) (struct inode *, int, int);
10365 void (*truncate_range)(struct inode *, loff_t, loff_t);
10366 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
10368 @@ -1618,6 +1656,7 @@ extern ssize_t vfs_readv(struct file *,
10369 unsigned long, loff_t *);
10370 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
10371 unsigned long, loff_t *);
10372 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
10374 struct super_operations {
10375 struct inode *(*alloc_inode)(struct super_block *sb);
10376 @@ -2437,6 +2476,7 @@ extern int dcache_dir_open(struct inode
10377 extern int dcache_dir_close(struct inode *, struct file *);
10378 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
10379 extern int dcache_readdir(struct file *, void *, filldir_t);
10380 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
10381 extern int simple_setattr(struct dentry *, struct iattr *);
10382 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
10383 extern int simple_statfs(struct dentry *, struct kstatfs *);
10384 diff -NurpP --minimal linux-3.0/include/linux/gfs2_ondisk.h linux-3.0-vs2.3.1-pre7/include/linux/gfs2_ondisk.h
10385 --- linux-3.0/include/linux/gfs2_ondisk.h 2010-07-07 18:31:55.000000000 +0200
10386 +++ linux-3.0-vs2.3.1-pre7/include/linux/gfs2_ondisk.h 2011-06-10 22:11:24.000000000 +0200
10387 @@ -211,6 +211,9 @@ enum {
10388 gfs2fl_NoAtime = 7,
10391 + gfs2fl_IXUnlink = 16,
10392 + gfs2fl_Barrier = 17,
10394 gfs2fl_TruncInProg = 29,
10395 gfs2fl_InheritDirectio = 30,
10396 gfs2fl_InheritJdata = 31,
10397 @@ -227,6 +230,9 @@ enum {
10398 #define GFS2_DIF_NOATIME 0x00000080
10399 #define GFS2_DIF_SYNC 0x00000100
10400 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
10401 +#define GFS2_DIF_IXUNLINK 0x00010000
10402 +#define GFS2_DIF_BARRIER 0x00020000
10403 +#define GFS2_DIF_COW 0x00040000
10404 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
10405 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000
10406 #define GFS2_DIF_INHERIT_JDATA 0x80000000
10407 diff -NurpP --minimal linux-3.0/include/linux/if_tun.h linux-3.0-vs2.3.1-pre7/include/linux/if_tun.h
10408 --- linux-3.0/include/linux/if_tun.h 2010-08-02 16:52:54.000000000 +0200
10409 +++ linux-3.0-vs2.3.1-pre7/include/linux/if_tun.h 2011-06-10 22:11:24.000000000 +0200
10411 #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
10412 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
10413 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
10414 +#define TUNSETNID _IOW('T', 217, int)
10416 /* TUNSETIFF ifr flags */
10417 #define IFF_TUN 0x0001
10418 diff -NurpP --minimal linux-3.0/include/linux/init_task.h linux-3.0-vs2.3.1-pre7/include/linux/init_task.h
10419 --- linux-3.0/include/linux/init_task.h 2011-07-22 11:18:10.000000000 +0200
10420 +++ linux-3.0-vs2.3.1-pre7/include/linux/init_task.h 2011-06-10 22:11:24.000000000 +0200
10421 @@ -193,6 +193,10 @@ extern struct cred init_cred;
10422 INIT_FTRACE_GRAPH \
10423 INIT_TRACE_RECURSION \
10424 INIT_TASK_RCU_PREEMPT(tsk) \
10426 + .vx_info = NULL, \
10428 + .nx_info = NULL, \
10432 diff -NurpP --minimal linux-3.0/include/linux/ipc.h linux-3.0-vs2.3.1-pre7/include/linux/ipc.h
10433 --- linux-3.0/include/linux/ipc.h 2009-12-03 20:02:55.000000000 +0100
10434 +++ linux-3.0-vs2.3.1-pre7/include/linux/ipc.h 2011-06-10 22:11:24.000000000 +0200
10435 @@ -91,6 +91,7 @@ struct kern_ipc_perm
10443 diff -NurpP --minimal linux-3.0/include/linux/ipc_namespace.h linux-3.0-vs2.3.1-pre7/include/linux/ipc_namespace.h
10444 --- linux-3.0/include/linux/ipc_namespace.h 2011-05-22 16:17:55.000000000 +0200
10445 +++ linux-3.0-vs2.3.1-pre7/include/linux/ipc_namespace.h 2011-06-13 14:09:44.000000000 +0200
10446 @@ -94,7 +94,8 @@ static inline int mq_init_ns(struct ipc_
10448 #if defined(CONFIG_IPC_NS)
10449 extern struct ipc_namespace *copy_ipcs(unsigned long flags,
10450 - struct task_struct *tsk);
10451 + struct ipc_namespace *old_ns,
10452 + struct user_namespace *user_ns);
10453 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
10456 @@ -105,12 +106,13 @@ static inline struct ipc_namespace *get_
10457 extern void put_ipc_ns(struct ipc_namespace *ns);
10459 static inline struct ipc_namespace *copy_ipcs(unsigned long flags,
10460 - struct task_struct *tsk)
10461 + struct ipc_namespace *old_ns,
10462 + struct user_namespace *user_ns)
10464 if (flags & CLONE_NEWIPC)
10465 return ERR_PTR(-EINVAL);
10467 - return tsk->nsproxy->ipc_ns;
10471 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
10472 diff -NurpP --minimal linux-3.0/include/linux/loop.h linux-3.0-vs2.3.1-pre7/include/linux/loop.h
10473 --- linux-3.0/include/linux/loop.h 2009-09-10 15:26:25.000000000 +0200
10474 +++ linux-3.0-vs2.3.1-pre7/include/linux/loop.h 2011-06-10 22:11:24.000000000 +0200
10475 @@ -45,6 +45,7 @@ struct loop_device {
10476 struct loop_func_table *lo_encryption;
10478 uid_t lo_key_owner; /* Who set the key */
10480 int (*ioctl)(struct loop_device *, int cmd,
10481 unsigned long arg);
10483 diff -NurpP --minimal linux-3.0/include/linux/magic.h linux-3.0-vs2.3.1-pre7/include/linux/magic.h
10484 --- linux-3.0/include/linux/magic.h 2011-05-22 16:17:55.000000000 +0200
10485 +++ linux-3.0-vs2.3.1-pre7/include/linux/magic.h 2011-06-10 22:11:24.000000000 +0200
10488 #define ADFS_SUPER_MAGIC 0xadf5
10489 #define AFFS_SUPER_MAGIC 0xadff
10490 -#define AFS_SUPER_MAGIC 0x5346414F
10491 +#define AFS_SUPER_MAGIC 0x5346414F
10492 #define AUTOFS_SUPER_MAGIC 0x0187
10493 #define CODA_SUPER_MAGIC 0x73757245
10494 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
10496 #define NFS_SUPER_MAGIC 0x6969
10497 #define OPENPROM_SUPER_MAGIC 0x9fa1
10498 #define PROC_SUPER_MAGIC 0x9fa0
10499 +#define DEVPTS_SUPER_MAGIC 0x1cd1
10500 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
10502 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
10503 diff -NurpP --minimal linux-3.0/include/linux/major.h linux-3.0-vs2.3.1-pre7/include/linux/major.h
10504 --- linux-3.0/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
10505 +++ linux-3.0-vs2.3.1-pre7/include/linux/major.h 2011-06-10 22:11:24.000000000 +0200
10507 #define HD_MAJOR IDE0_MAJOR
10508 #define PTY_SLAVE_MAJOR 3
10509 #define TTY_MAJOR 4
10510 +#define VROOT_MAJOR 4
10511 #define TTYAUX_MAJOR 5
10513 #define VCS_MAJOR 7
10514 diff -NurpP --minimal linux-3.0/include/linux/memcontrol.h linux-3.0-vs2.3.1-pre7/include/linux/memcontrol.h
10515 --- linux-3.0/include/linux/memcontrol.h 2011-07-22 11:18:10.000000000 +0200
10516 +++ linux-3.0-vs2.3.1-pre7/include/linux/memcontrol.h 2011-06-22 12:39:15.000000000 +0200
10517 @@ -86,6 +86,13 @@ extern struct mem_cgroup *try_get_mem_cg
10518 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
10519 extern struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm);
10521 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
10522 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
10524 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
10525 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
10526 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
10529 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
10531 diff -NurpP --minimal linux-3.0/include/linux/mm_types.h linux-3.0-vs2.3.1-pre7/include/linux/mm_types.h
10532 --- linux-3.0/include/linux/mm_types.h 2011-07-22 11:18:11.000000000 +0200
10533 +++ linux-3.0-vs2.3.1-pre7/include/linux/mm_types.h 2011-06-10 22:11:24.000000000 +0200
10534 @@ -268,6 +268,7 @@ struct mm_struct {
10536 /* Architecture-specific MM context */
10537 mm_context_t context;
10538 + struct vx_info *mm_vx_info;
10540 /* Swap token stuff */
10542 diff -NurpP --minimal linux-3.0/include/linux/mmzone.h linux-3.0-vs2.3.1-pre7/include/linux/mmzone.h
10543 --- linux-3.0/include/linux/mmzone.h 2011-07-22 11:18:11.000000000 +0200
10544 +++ linux-3.0-vs2.3.1-pre7/include/linux/mmzone.h 2011-07-01 11:35:35.000000000 +0200
10545 @@ -654,6 +654,13 @@ typedef struct pglist_data {
10546 __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
10549 +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
10551 +#define node_end_pfn(nid) ({\
10552 + pg_data_t *__pgdat = NODE_DATA(nid);\
10553 + __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
10556 #include <linux/memory_hotplug.h>
10558 extern struct mutex zonelists_mutex;
10559 diff -NurpP --minimal linux-3.0/include/linux/mount.h linux-3.0-vs2.3.1-pre7/include/linux/mount.h
10560 --- linux-3.0/include/linux/mount.h 2011-03-15 18:07:39.000000000 +0100
10561 +++ linux-3.0-vs2.3.1-pre7/include/linux/mount.h 2011-06-10 22:11:24.000000000 +0200
10562 @@ -52,6 +52,9 @@ struct mnt_pcp {
10566 +#define MNT_TAGID 0x10000
10567 +#define MNT_NOTAG 0x20000
10570 struct list_head mnt_hash;
10571 struct vfsmount *mnt_parent; /* fs we are mounted on */
10572 @@ -86,6 +89,7 @@ struct vfsmount {
10573 int mnt_expiry_mark; /* true if marked for expiry */
10576 + tag_t mnt_tag; /* tagging used for vfsmount */
10579 struct file; /* forward dec */
10580 diff -NurpP --minimal linux-3.0/include/linux/net.h linux-3.0-vs2.3.1-pre7/include/linux/net.h
10581 --- linux-3.0/include/linux/net.h 2011-07-22 11:18:11.000000000 +0200
10582 +++ linux-3.0-vs2.3.1-pre7/include/linux/net.h 2011-06-10 22:11:24.000000000 +0200
10583 @@ -72,6 +72,7 @@ struct net;
10584 #define SOCK_NOSPACE 2
10585 #define SOCK_PASSCRED 3
10586 #define SOCK_PASSSEC 4
10587 +#define SOCK_USER_SOCKET 5
10589 #ifndef ARCH_HAS_SOCKET_TYPES
10591 diff -NurpP --minimal linux-3.0/include/linux/nfs_mount.h linux-3.0-vs2.3.1-pre7/include/linux/nfs_mount.h
10592 --- linux-3.0/include/linux/nfs_mount.h 2011-01-05 21:50:31.000000000 +0100
10593 +++ linux-3.0-vs2.3.1-pre7/include/linux/nfs_mount.h 2011-06-10 22:11:24.000000000 +0200
10594 @@ -63,7 +63,8 @@ struct nfs_mount_data {
10595 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
10596 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
10597 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
10598 -#define NFS_MOUNT_FLAGMASK 0xFFFF
10599 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
10600 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
10602 /* The following are for internal use only */
10603 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
10604 diff -NurpP --minimal linux-3.0/include/linux/nsproxy.h linux-3.0-vs2.3.1-pre7/include/linux/nsproxy.h
10605 --- linux-3.0/include/linux/nsproxy.h 2011-07-22 11:18:11.000000000 +0200
10606 +++ linux-3.0-vs2.3.1-pre7/include/linux/nsproxy.h 2011-06-10 22:11:24.000000000 +0200
10609 #include <linux/spinlock.h>
10610 #include <linux/sched.h>
10611 +#include <linux/vserver/debug.h>
10613 struct mnt_namespace;
10614 struct uts_namespace;
10615 @@ -63,22 +64,33 @@ static inline struct nsproxy *task_nspro
10618 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
10619 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
10620 void exit_task_namespaces(struct task_struct *tsk);
10621 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
10622 void free_nsproxy(struct nsproxy *ns);
10623 int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **,
10624 struct fs_struct *);
10626 -static inline void put_nsproxy(struct nsproxy *ns)
10627 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
10629 +static inline void __get_nsproxy(struct nsproxy *ns,
10630 + const char *_file, int _line)
10632 - if (atomic_dec_and_test(&ns->count)) {
10633 - free_nsproxy(ns);
10635 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
10636 + ns, atomic_read(&ns->count), _file, _line);
10637 + atomic_inc(&ns->count);
10640 -static inline void get_nsproxy(struct nsproxy *ns)
10641 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
10643 +static inline void __put_nsproxy(struct nsproxy *ns,
10644 + const char *_file, int _line)
10646 - atomic_inc(&ns->count);
10647 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
10648 + ns, atomic_read(&ns->count), _file, _line);
10649 + if (atomic_dec_and_test(&ns->count)) {
10650 + free_nsproxy(ns);
10655 diff -NurpP --minimal linux-3.0/include/linux/pid.h linux-3.0-vs2.3.1-pre7/include/linux/pid.h
10656 --- linux-3.0/include/linux/pid.h 2011-07-22 11:18:11.000000000 +0200
10657 +++ linux-3.0-vs2.3.1-pre7/include/linux/pid.h 2011-06-10 22:11:24.000000000 +0200
10658 @@ -8,7 +8,8 @@ enum pid_type
10668 @@ -171,6 +172,7 @@ static inline pid_t pid_nr(struct pid *p
10671 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
10672 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
10673 pid_t pid_vnr(struct pid *pid);
10675 #define do_each_pid_task(pid, type, task) \
10676 diff -NurpP --minimal linux-3.0/include/linux/proc_fs.h linux-3.0-vs2.3.1-pre7/include/linux/proc_fs.h
10677 --- linux-3.0/include/linux/proc_fs.h 2011-07-22 11:18:11.000000000 +0200
10678 +++ linux-3.0-vs2.3.1-pre7/include/linux/proc_fs.h 2011-06-10 22:11:24.000000000 +0200
10679 @@ -56,6 +56,7 @@ struct proc_dir_entry {
10685 const struct inode_operations *proc_iops;
10687 @@ -252,12 +253,18 @@ extern const struct proc_ns_operations n
10688 extern const struct proc_ns_operations utsns_operations;
10689 extern const struct proc_ns_operations ipcns_operations;
10695 int (*proc_get_link)(struct inode *, struct path *);
10696 int (*proc_read)(struct task_struct *task, char *page);
10697 int (*proc_show)(struct seq_file *m,
10698 struct pid_namespace *ns, struct pid *pid,
10699 struct task_struct *task);
10700 + int (*proc_vs_read)(char *page);
10701 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
10702 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
10705 struct ctl_table_header;
10706 @@ -265,6 +272,7 @@ struct ctl_table;
10708 struct proc_inode {
10713 struct proc_dir_entry *pde;
10714 diff -NurpP --minimal linux-3.0/include/linux/quotaops.h linux-3.0-vs2.3.1-pre7/include/linux/quotaops.h
10715 --- linux-3.0/include/linux/quotaops.h 2011-05-22 16:17:57.000000000 +0200
10716 +++ linux-3.0-vs2.3.1-pre7/include/linux/quotaops.h 2011-06-10 22:11:24.000000000 +0200
10718 #define _LINUX_QUOTAOPS_
10720 #include <linux/fs.h>
10721 +#include <linux/vs_dlimit.h>
10723 #define DQUOT_SPACE_WARN 0x1
10724 #define DQUOT_SPACE_RESERVE 0x2
10725 @@ -204,11 +205,12 @@ static inline void dquot_drop(struct ino
10727 static inline int dquot_alloc_inode(const struct inode *inode)
10730 + return dl_alloc_inode(inode);
10733 static inline void dquot_free_inode(const struct inode *inode)
10735 + dl_free_inode(inode);
10738 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
10739 @@ -219,6 +221,10 @@ static inline int dquot_transfer(struct
10740 static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
10745 + if ((ret = dl_alloc_space(inode, number)))
10747 if (!(flags & DQUOT_SPACE_RESERVE))
10748 inode_add_bytes(inode, number);
10750 @@ -229,6 +235,7 @@ static inline void __dquot_free_space(st
10752 if (!(flags & DQUOT_SPACE_RESERVE))
10753 inode_sub_bytes(inode, number);
10754 + dl_free_space(inode, number);
10757 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
10758 diff -NurpP --minimal linux-3.0/include/linux/reboot.h linux-3.0-vs2.3.1-pre7/include/linux/reboot.h
10759 --- linux-3.0/include/linux/reboot.h 2010-07-07 18:31:56.000000000 +0200
10760 +++ linux-3.0-vs2.3.1-pre7/include/linux/reboot.h 2011-06-10 22:11:24.000000000 +0200
10762 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
10763 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
10764 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
10765 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
10769 diff -NurpP --minimal linux-3.0/include/linux/reiserfs_fs.h linux-3.0-vs2.3.1-pre7/include/linux/reiserfs_fs.h
10770 --- linux-3.0/include/linux/reiserfs_fs.h 2011-05-22 16:17:58.000000000 +0200
10771 +++ linux-3.0-vs2.3.1-pre7/include/linux/reiserfs_fs.h 2011-06-10 22:11:24.000000000 +0200
10772 @@ -976,6 +976,11 @@ struct stat_data_v1 {
10773 #define REISERFS_COMPR_FL FS_COMPR_FL
10774 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
10776 +/* unfortunately reiserfs sdattr is only 16 bit */
10777 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
10778 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
10779 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
10781 /* persistent flags that file inherits from the parent directory */
10782 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
10783 REISERFS_SYNC_FL | \
10784 @@ -985,6 +990,9 @@ struct stat_data_v1 {
10785 REISERFS_COMPR_FL | \
10786 REISERFS_NOTAIL_FL )
10788 +#define REISERFS_FL_USER_VISIBLE 0x80FF
10789 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
10791 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
10794 @@ -2073,6 +2081,7 @@ static inline void reiserfs_update_sd(st
10795 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
10796 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
10797 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
10798 +int reiserfs_sync_flags(struct inode *inode, int, int);
10800 int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len);
10802 diff -NurpP --minimal linux-3.0/include/linux/reiserfs_fs_sb.h linux-3.0-vs2.3.1-pre7/include/linux/reiserfs_fs_sb.h
10803 --- linux-3.0/include/linux/reiserfs_fs_sb.h 2010-02-25 11:52:07.000000000 +0100
10804 +++ linux-3.0-vs2.3.1-pre7/include/linux/reiserfs_fs_sb.h 2011-06-10 22:11:24.000000000 +0200
10805 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
10806 REISERFS_EXPOSE_PRIVROOT,
10807 REISERFS_BARRIER_NONE,
10808 REISERFS_BARRIER_FLUSH,
10811 /* Actions on error */
10812 REISERFS_ERROR_PANIC,
10813 diff -NurpP --minimal linux-3.0/include/linux/sched.h linux-3.0-vs2.3.1-pre7/include/linux/sched.h
10814 --- linux-3.0/include/linux/sched.h 2011-07-22 11:18:11.000000000 +0200
10815 +++ linux-3.0-vs2.3.1-pre7/include/linux/sched.h 2011-07-22 11:20:39.000000000 +0200
10816 @@ -1406,6 +1406,14 @@ struct task_struct {
10820 +/* vserver context data */
10821 + struct vx_info *vx_info;
10822 + struct nx_info *nx_info;
10828 /* Thread group tracking */
10829 u32 parent_exec_id;
10831 @@ -1649,6 +1657,11 @@ struct pid_namespace;
10832 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
10833 struct pid_namespace *ns);
10835 +#include <linux/vserver/base.h>
10836 +#include <linux/vserver/context.h>
10837 +#include <linux/vserver/debug.h>
10838 +#include <linux/vserver/pid.h>
10840 static inline pid_t task_pid_nr(struct task_struct *tsk)
10843 @@ -1662,7 +1675,8 @@ static inline pid_t task_pid_nr_ns(struc
10845 static inline pid_t task_pid_vnr(struct task_struct *tsk)
10847 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
10848 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
10849 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
10853 @@ -1675,7 +1689,7 @@ pid_t task_tgid_nr_ns(struct task_struct
10855 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
10857 - return pid_vnr(task_tgid(tsk));
10858 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
10862 diff -NurpP --minimal linux-3.0/include/linux/shmem_fs.h linux-3.0-vs2.3.1-pre7/include/linux/shmem_fs.h
10863 --- linux-3.0/include/linux/shmem_fs.h 2011-07-22 11:18:11.000000000 +0200
10864 +++ linux-3.0-vs2.3.1-pre7/include/linux/shmem_fs.h 2011-07-01 11:35:35.000000000 +0200
10867 #define SHMEM_SYMLINK_INLINE_LEN (SHMEM_NR_DIRECT * sizeof(swp_entry_t))
10869 +#define TMPFS_SUPER_MAGIC 0x01021994
10872 struct shmem_inode_info {
10874 unsigned long flags;
10875 diff -NurpP --minimal linux-3.0/include/linux/stat.h linux-3.0-vs2.3.1-pre7/include/linux/stat.h
10876 --- linux-3.0/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
10877 +++ linux-3.0-vs2.3.1-pre7/include/linux/stat.h 2011-06-10 22:11:24.000000000 +0200
10878 @@ -66,6 +66,7 @@ struct kstat {
10879 unsigned int nlink;
10885 struct timespec atime;
10886 diff -NurpP --minimal linux-3.0/include/linux/sunrpc/auth.h linux-3.0-vs2.3.1-pre7/include/linux/sunrpc/auth.h
10887 --- linux-3.0/include/linux/sunrpc/auth.h 2011-03-15 18:07:39.000000000 +0100
10888 +++ linux-3.0-vs2.3.1-pre7/include/linux/sunrpc/auth.h 2011-06-10 22:11:24.000000000 +0200
10894 struct group_info *group_info;
10895 unsigned char machine_cred : 1;
10897 diff -NurpP --minimal linux-3.0/include/linux/sunrpc/clnt.h linux-3.0-vs2.3.1-pre7/include/linux/sunrpc/clnt.h
10898 --- linux-3.0/include/linux/sunrpc/clnt.h 2011-05-22 16:17:58.000000000 +0200
10899 +++ linux-3.0-vs2.3.1-pre7/include/linux/sunrpc/clnt.h 2011-06-10 22:11:24.000000000 +0200
10900 @@ -49,7 +49,8 @@ struct rpc_clnt {
10901 unsigned int cl_softrtry : 1,/* soft timeouts */
10902 cl_discrtry : 1,/* disconnect before retry */
10903 cl_autobind : 1,/* use getport() */
10904 - cl_chatty : 1;/* be verbose */
10905 + cl_chatty : 1,/* be verbose */
10906 + cl_tag : 1;/* context tagging */
10908 struct rpc_rtt * cl_rtt; /* RTO estimator data */
10909 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
10910 diff -NurpP --minimal linux-3.0/include/linux/syscalls.h linux-3.0-vs2.3.1-pre7/include/linux/syscalls.h
10911 --- linux-3.0/include/linux/syscalls.h 2011-07-22 11:18:11.000000000 +0200
10912 +++ linux-3.0-vs2.3.1-pre7/include/linux/syscalls.h 2011-06-10 22:11:24.000000000 +0200
10913 @@ -483,6 +483,8 @@ asmlinkage long sys_symlink(const char _
10914 asmlinkage long sys_unlink(const char __user *pathname);
10915 asmlinkage long sys_rename(const char __user *oldname,
10916 const char __user *newname);
10917 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
10919 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
10920 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
10922 diff -NurpP --minimal linux-3.0/include/linux/sysctl.h linux-3.0-vs2.3.1-pre7/include/linux/sysctl.h
10923 --- linux-3.0/include/linux/sysctl.h 2011-03-15 18:07:40.000000000 +0100
10924 +++ linux-3.0-vs2.3.1-pre7/include/linux/sysctl.h 2011-06-10 22:11:24.000000000 +0200
10925 @@ -60,6 +60,7 @@ enum
10926 CTL_ABI=9, /* Binary emulation */
10927 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
10928 CTL_ARLAN=254, /* arlan wireless driver */
10929 + CTL_VSERVER=4242, /* Linux-VServer debug */
10930 CTL_S390DBF=5677, /* s390 debug */
10931 CTL_SUNRPC=7249, /* sunrpc debug */
10932 CTL_PM=9899, /* frv power management */
10933 @@ -94,6 +95,7 @@ enum
10935 KERN_PANIC=15, /* int: panic timeout */
10936 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
10937 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
10939 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
10940 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
10941 diff -NurpP --minimal linux-3.0/include/linux/sysfs.h linux-3.0-vs2.3.1-pre7/include/linux/sysfs.h
10942 --- linux-3.0/include/linux/sysfs.h 2011-07-22 11:18:11.000000000 +0200
10943 +++ linux-3.0-vs2.3.1-pre7/include/linux/sysfs.h 2011-06-22 12:39:15.000000000 +0200
10945 #include <linux/kobject_ns.h>
10946 #include <asm/atomic.h>
10948 +#define SYSFS_SUPER_MAGIC 0x62656572
10953 diff -NurpP --minimal linux-3.0/include/linux/time.h linux-3.0-vs2.3.1-pre7/include/linux/time.h
10954 --- linux-3.0/include/linux/time.h 2011-07-22 11:18:11.000000000 +0200
10955 +++ linux-3.0-vs2.3.1-pre7/include/linux/time.h 2011-06-10 22:11:24.000000000 +0200
10956 @@ -256,6 +256,9 @@ static __always_inline void timespec_add
10957 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
10961 +#include <linux/vs_time.h>
10963 #endif /* __KERNEL__ */
10965 #define NFDBITS __NFDBITS
10966 diff -NurpP --minimal linux-3.0/include/linux/types.h linux-3.0-vs2.3.1-pre7/include/linux/types.h
10967 --- linux-3.0/include/linux/types.h 2011-05-22 16:17:58.000000000 +0200
10968 +++ linux-3.0-vs2.3.1-pre7/include/linux/types.h 2011-06-10 22:11:24.000000000 +0200
10969 @@ -40,6 +40,9 @@ typedef __kernel_uid32_t uid_t;
10970 typedef __kernel_gid32_t gid_t;
10971 typedef __kernel_uid16_t uid16_t;
10972 typedef __kernel_gid16_t gid16_t;
10973 +typedef unsigned int xid_t;
10974 +typedef unsigned int nid_t;
10975 +typedef unsigned int tag_t;
10977 typedef unsigned long uintptr_t;
10979 diff -NurpP --minimal linux-3.0/include/linux/utsname.h linux-3.0-vs2.3.1-pre7/include/linux/utsname.h
10980 --- linux-3.0/include/linux/utsname.h 2011-05-22 16:17:58.000000000 +0200
10981 +++ linux-3.0-vs2.3.1-pre7/include/linux/utsname.h 2011-06-13 14:36:48.000000000 +0200
10982 @@ -54,7 +54,8 @@ static inline void get_uts_ns(struct uts
10985 extern struct uts_namespace *copy_utsname(unsigned long flags,
10986 - struct task_struct *tsk);
10987 + struct uts_namespace *old_ns,
10988 + struct user_namespace *user_ns);
10989 extern void free_uts_ns(struct kref *kref);
10991 static inline void put_uts_ns(struct uts_namespace *ns)
10992 @@ -71,12 +72,13 @@ static inline void put_uts_ns(struct uts
10995 static inline struct uts_namespace *copy_utsname(unsigned long flags,
10996 - struct task_struct *tsk)
10997 + struct uts_namespace *old_ns,
10998 + struct user_namespace *user_ns)
11000 if (flags & CLONE_NEWUTS)
11001 return ERR_PTR(-EINVAL);
11003 - return tsk->nsproxy->uts_ns;
11008 diff -NurpP --minimal linux-3.0/include/linux/vroot.h linux-3.0-vs2.3.1-pre7/include/linux/vroot.h
11009 --- linux-3.0/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
11010 +++ linux-3.0-vs2.3.1-pre7/include/linux/vroot.h 2011-06-10 22:11:24.000000000 +0200
11014 + * include/linux/vroot.h
11016 + * written by Herbert Pötzl, 9/11/2002
11017 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
11019 + * Copyright (C) 2002-2007 by Herbert Pötzl.
11020 + * Redistribution of this file is permitted under the
11021 + * GNU General Public License.
11024 +#ifndef _LINUX_VROOT_H
11025 +#define _LINUX_VROOT_H
11030 +/* Possible states of device */
11036 +struct vroot_device {
11040 + struct semaphore vr_ctl_mutex;
11041 + struct block_device *vr_device;
11046 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
11048 +extern int register_vroot_grb(vroot_grb_func *);
11049 +extern int unregister_vroot_grb(vroot_grb_func *);
11051 +#endif /* __KERNEL__ */
11053 +#define MAX_VROOT_DEFAULT 8
11056 + * IOCTL commands --- we will commandeer 0x56 ('V')
11059 +#define VROOT_SET_DEV 0x5600
11060 +#define VROOT_CLR_DEV 0x5601
11062 +#endif /* _LINUX_VROOT_H */
11063 diff -NurpP --minimal linux-3.0/include/linux/vs_base.h linux-3.0-vs2.3.1-pre7/include/linux/vs_base.h
11064 --- linux-3.0/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
11065 +++ linux-3.0-vs2.3.1-pre7/include/linux/vs_base.h 2011-06-10 22:11:24.000000000 +0200
11067 +#ifndef _VS_BASE_H
11068 +#define _VS_BASE_H
11070 +#include "vserver/base.h"
11071 +#include "vserver/check.h"
11072 +#include "vserver/debug.h"
11075 +#warning duplicate inclusion
11077 diff -NurpP --minimal linux-3.0/include/linux/vs_context.h linux-3.0-vs2.3.1-pre7/include/linux/vs_context.h
11078 --- linux-3.0/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
11079 +++ linux-3.0-vs2.3.1-pre7/include/linux/vs_context.h 2011-06-10 22:11:24.000000000 +0200
11081 +#ifndef _VS_CONTEXT_H
11082 +#define _VS_CONTEXT_H
11084 +#include "vserver/base.h"
11085 +#include "vserver/check.h"
11086 +#include "vserver/context.h"
11087 +#include "vserver/history.h"
11088 +#include "vserver/debug.h"
11090 +#include <linux/sched.h>
11093 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
11095 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
11096 + const char *_file, int _line, void *_here)
11101 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
11102 + vxi, vxi ? vxi->vx_id : 0,
11103 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11105 + __vxh_get_vx_info(vxi, _here);
11107 + atomic_inc(&vxi->vx_usecnt);
11112 +extern void free_vx_info(struct vx_info *);
11114 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
11116 +static inline void __put_vx_info(struct vx_info *vxi,
11117 + const char *_file, int _line, void *_here)
11122 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
11123 + vxi, vxi ? vxi->vx_id : 0,
11124 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11126 + __vxh_put_vx_info(vxi, _here);
11128 + if (atomic_dec_and_test(&vxi->vx_usecnt))
11129 + free_vx_info(vxi);
11133 +#define init_vx_info(p, i) \
11134 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
11136 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
11137 + const char *_file, int _line, void *_here)
11140 + vxlprintk(VXD_CBIT(xid, 3),
11141 + "init_vx_info(%p[#%d.%d])",
11142 + vxi, vxi ? vxi->vx_id : 0,
11143 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11145 + __vxh_init_vx_info(vxi, vxp, _here);
11147 + atomic_inc(&vxi->vx_usecnt);
11153 +#define set_vx_info(p, i) \
11154 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
11156 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
11157 + const char *_file, int _line, void *_here)
11159 + struct vx_info *vxo;
11164 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
11165 + vxi, vxi ? vxi->vx_id : 0,
11166 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11168 + __vxh_set_vx_info(vxi, vxp, _here);
11170 + atomic_inc(&vxi->vx_usecnt);
11171 + vxo = xchg(vxp, vxi);
11176 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
11178 +static inline void __clr_vx_info(struct vx_info **vxp,
11179 + const char *_file, int _line, void *_here)
11181 + struct vx_info *vxo;
11183 + vxo = xchg(vxp, NULL);
11187 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
11188 + vxo, vxo ? vxo->vx_id : 0,
11189 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
11191 + __vxh_clr_vx_info(vxo, vxp, _here);
11193 + if (atomic_dec_and_test(&vxo->vx_usecnt))
11194 + free_vx_info(vxo);
11198 +#define claim_vx_info(v, p) \
11199 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
11201 +static inline void __claim_vx_info(struct vx_info *vxi,
11202 + struct task_struct *task,
11203 + const char *_file, int _line, void *_here)
11205 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
11206 + vxi, vxi ? vxi->vx_id : 0,
11207 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11208 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
11209 + task, _file, _line);
11210 + __vxh_claim_vx_info(vxi, task, _here);
11212 + atomic_inc(&vxi->vx_tasks);
11216 +extern void unhash_vx_info(struct vx_info *);
11218 +#define release_vx_info(v, p) \
11219 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
11221 +static inline void __release_vx_info(struct vx_info *vxi,
11222 + struct task_struct *task,
11223 + const char *_file, int _line, void *_here)
11225 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
11226 + vxi, vxi ? vxi->vx_id : 0,
11227 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
11228 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
11229 + task, _file, _line);
11230 + __vxh_release_vx_info(vxi, task, _here);
11234 + if (atomic_dec_and_test(&vxi->vx_tasks))
11235 + unhash_vx_info(vxi);
11239 +#define task_get_vx_info(p) \
11240 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
11242 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
11243 + const char *_file, int _line, void *_here)
11245 + struct vx_info *vxi;
11248 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
11249 + p, _file, _line);
11250 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
11256 +static inline void __wakeup_vx_info(struct vx_info *vxi)
11258 + if (waitqueue_active(&vxi->vx_wait))
11259 + wake_up_interruptible(&vxi->vx_wait);
11263 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
11265 +static inline void __enter_vx_info(struct vx_info *vxi,
11266 + struct vx_info_save *vxis, const char *_file, int _line)
11268 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
11269 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
11270 + current->xid, current->vx_info, _file, _line);
11271 + vxis->vxi = xchg(¤t->vx_info, vxi);
11272 + vxis->xid = current->xid;
11273 + current->xid = vxi ? vxi->vx_id : 0;
11276 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
11278 +static inline void __leave_vx_info(struct vx_info_save *vxis,
11279 + const char *_file, int _line)
11281 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
11282 + vxis, vxis->xid, vxis->vxi, current,
11283 + current->xid, current->vx_info, _file, _line);
11284 + (void)xchg(¤t->vx_info, vxis->vxi);
11285 + current->xid = vxis->xid;
11289 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
11291 + vxis->vxi = xchg(¤t->vx_info, NULL);
11292 + vxis->xid = xchg(¤t->xid, (xid_t)0);
11295 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
11297 + (void)xchg(¤t->xid, vxis->xid);
11298 + (void)xchg(¤t->vx_info, vxis->vxi);
11301 +#define task_is_init(p) \
11302 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
11304 +static inline int __task_is_init(struct task_struct *p,
11305 + const char *_file, int _line, void *_here)
11307 + int is_init = is_global_init(p);
11311 + is_init = p->vx_info->vx_initpid == p->pid;
11316 +extern void exit_vx_info(struct task_struct *, int);
11317 +extern void exit_vx_info_early(struct task_struct *, int);
11321 +#warning duplicate inclusion
11323 diff -NurpP --minimal linux-3.0/include/linux/vs_cowbl.h linux-3.0-vs2.3.1-pre7/include/linux/vs_cowbl.h
11324 --- linux-3.0/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
11325 +++ linux-3.0-vs2.3.1-pre7/include/linux/vs_cowbl.h 2011-06-10 22:11:24.000000000 +0200
11327 +#ifndef _VS_COWBL_H
11328 +#define _VS_COWBL_H
11330 +#include <linux/fs.h>
11331 +#include <linux/dcache.h>
11332 +#include <linux/namei.h>
11333 +#include <linux/slab.h>
11335 +extern struct dentry *cow_break_link(const char *pathname);
11337 +static inline int cow_check_and_break(struct path *path)
11339 + struct inode *inode = path->dentry->d_inode;
11342 + /* do we need this check? */
11343 + if (IS_RDONLY(inode))
11346 + if (IS_COW(inode)) {
11347 + if (IS_COW_LINK(inode)) {
11348 + struct dentry *new_dentry, *old_dentry = path->dentry;
11351 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
11355 + pp = d_path(path, buf, PATH_MAX);
11356 + new_dentry = cow_break_link(pp);
11358 + if (!IS_ERR(new_dentry)) {
11359 + path->dentry = new_dentry;
11360 + dput(old_dentry);
11362 + error = PTR_ERR(new_dentry);
11364 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
11365 + inode->i_ctime = CURRENT_TIME;
11366 + mark_inode_dirty(inode);
11373 +#warning duplicate inclusion
11375 diff -NurpP --minimal linux-3.0/include/linux/vs_cvirt.h linux-3.0-vs2.3.1-pre7/include/linux/vs_cvirt.h
11376 --- linux-3.0/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
11377 +++ linux-3.0-vs2.3.1-pre7/include/linux/vs_cvirt.h 2011-06-10 22:11:24.000000000 +0200
11379 +#ifndef _VS_CVIRT_H
11380 +#define _VS_CVIRT_H
11382 +#include "vserver/cvirt.h"
11383 +#include "vserver/context.h"
11384 +#include "vserver/base.h"
11385 +#include "vserver/check.h"
11386 +#include "vserver/debug.h"
11389 +static inline void vx_activate_task(struct task_struct *p)
11391 + struct vx_info *vxi;
11393 + if ((vxi = p->vx_info)) {
11394 + vx_update_load(vxi);
11395 + atomic_inc(&vxi->cvirt.nr_running);
11399 +static inline void vx_deactivate_task(struct task_struct *p)
11401 + struct vx_info *vxi;
11403 + if ((vxi = p->vx_info)) {
11404 + vx_update_load(vxi);
11405 + atomic_dec(&vxi->cvirt.nr_running);
11409 +static inline void vx_uninterruptible_inc(struct task_struct *p)
11411 + struct vx_info *vxi;
11413 + if ((vxi = p->vx_info))
11414 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
11417 +static inline void vx_uninterruptible_dec(struct task_struct *p)
11419 + struct vx_info *vxi;
11421 + if ((vxi = p->vx_info))
11422 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
11427 +#warning duplicate inclusion
11429 diff -NurpP --minimal linux-3.0/include/linux/vs_device.h linux-3.0-vs2.3.1-pre7/include/linux/vs_device.h
11430 --- linux-3.0/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
11431 +++ linux-3.0-vs2.3.1-pre7/include/linux/vs_device.h 2011-06-10 22:11:24.000000000 +0200
11433 +#ifndef _VS_DEVICE_H
11434 +#define _VS_DEVICE_H
11436 +#include "vserver/base.h"
11437 +#include "vserver/device.h"
11438 +#include "vserver/debug.h"
11441 +#ifdef CONFIG_VSERVER_DEVICE
11443 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
11445 +#define vs_device_perm(v, d, m, p) \
11446 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
11451 +int vs_map_device(struct vx_info *vxi,
11452 + dev_t device, dev_t *target, umode_t mode)
11455 + *target = device;
11459 +#define vs_device_perm(v, d, m, p) ((p) == (p))
11464 +#define vs_map_chrdev(d, t, p) \
11465 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
11466 +#define vs_map_blkdev(d, t, p) \
11467 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
11469 +#define vs_chrdev_perm(d, p) \
11470 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
11471 +#define vs_blkdev_perm(d, p) \
11472 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
11476 +#warning duplicate inclusion
11478 diff -NurpP --minimal linux-3.0/include/linux/vs_dlimit.h linux-3.0-vs2.3.1-pre7/include/linux/vs_dlimit.h
11479 --- linux-3.0/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
11480 +++ linux-3.0-vs2.3.1-pre7/include/linux/vs_dlimit.h 2011-06-10 22:11:24.000000000 +0200
11482 +#ifndef _VS_DLIMIT_H
11483 +#define _VS_DLIMIT_H
11485 +#include <linux/fs.h>
11487 +#include "vserver/dlimit.h"
11488 +#include "vserver/base.h"
11489 +#include "vserver/debug.h"
11492 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
11494 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
11495 + const char *_file, int _line)
11499 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
11500 + dli, dli ? dli->dl_tag : 0,
11501 + dli ? atomic_read(&dli->dl_usecnt) : 0,
11503 + atomic_inc(&dli->dl_usecnt);
11508 +#define free_dl_info(i) \
11509 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
11511 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
11513 +static inline void __put_dl_info(struct dl_info *dli,
11514 + const char *_file, int _line)
11518 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
11519 + dli, dli ? dli->dl_tag : 0,
11520 + dli ? atomic_read(&dli->dl_usecnt) : 0,
11522 + if (atomic_dec_and_test(&dli->dl_usecnt))
11523 + free_dl_info(dli);
11527 +#define __dlimit_char(d) ((d) ? '*' : ' ')
11529 +static inline int __dl_alloc_space(struct super_block *sb,
11530 + tag_t tag, dlsize_t nr, const char *file, int line)
11532 + struct dl_info *dli = NULL;
11537 + dli = locate_dl_info(sb, tag);
11541 + spin_lock(&dli->dl_lock);
11542 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
11544 + dli->dl_space_used += nr;
11545 + spin_unlock(&dli->dl_lock);
11546 + put_dl_info(dli);
11548 + vxlprintk(VXD_CBIT(dlim, 1),
11549 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
11550 + sb, tag, __dlimit_char(dli), (long long)nr,
11551 + ret, file, line);
11552 + return ret ? -ENOSPC : 0;
11555 +static inline void __dl_free_space(struct super_block *sb,
11556 + tag_t tag, dlsize_t nr, const char *_file, int _line)
11558 + struct dl_info *dli = NULL;
11562 + dli = locate_dl_info(sb, tag);
11566 + spin_lock(&dli->dl_lock);
11567 + if (dli->dl_space_used > nr)
11568 + dli->dl_space_used -= nr;
11570 + dli->dl_space_used = 0;
11571 + spin_unlock(&dli->dl_lock);
11572 + put_dl_info(dli);
11574 + vxlprintk(VXD_CBIT(dlim, 1),
11575 + "FREE (%p,#%d)%c %lld bytes",
11576 + sb, tag, __dlimit_char(dli), (long long)nr,
11580 +static inline int __dl_alloc_inode(struct super_block *sb,
11581 + tag_t tag, const char *_file, int _line)
11583 + struct dl_info *dli;
11586 + dli = locate_dl_info(sb, tag);
11590 + spin_lock(&dli->dl_lock);
11591 + dli->dl_inodes_used++;
11592 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
11593 + spin_unlock(&dli->dl_lock);
11594 + put_dl_info(dli);
11596 + vxlprintk(VXD_CBIT(dlim, 0),
11597 + "ALLOC (%p,#%d)%c inode (%d)",
11598 + sb, tag, __dlimit_char(dli), ret, _file, _line);
11599 + return ret ? -ENOSPC : 0;
11602 +static inline void __dl_free_inode(struct super_block *sb,
11603 + tag_t tag, const char *_file, int _line)
11605 + struct dl_info *dli;
11607 + dli = locate_dl_info(sb, tag);
11611 + spin_lock(&dli->dl_lock);
11612 + if (dli->dl_inodes_used > 1)
11613 + dli->dl_inodes_used--;
11615 + dli->dl_inodes_used = 0;
11616 + spin_unlock(&dli->dl_lock);
11617 + put_dl_info(dli);
11619 + vxlprintk(VXD_CBIT(dlim, 0),
11620 + "FREE (%p,#%d)%c inode",
11621 + sb, tag, __dlimit_char(dli), _file, _line);
11624 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
11625 + unsigned long long *free_blocks, unsigned long long *root_blocks,
11626 + const char *_file, int _line)
11628 + struct dl_info *dli;
11629 + uint64_t broot, bfree;
11631 + dli = locate_dl_info(sb, tag);
11635 + spin_lock(&dli->dl_lock);
11636 + broot = (dli->dl_space_total -
11637 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
11638 + >> sb->s_blocksize_bits;
11639 + bfree = (dli->dl_space_total - dli->dl_space_used)
11640 + >> sb->s_blocksize_bits;
11641 + spin_unlock(&dli->dl_lock);
11643 + vxlprintk(VXD_CBIT(dlim, 2),
11644 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
11645 + (long long)bfree, (long long)broot,
11646 + *free_blocks, *root_blocks, dli->dl_nrlmult,
11648 + if (free_blocks) {
11649 + if (*free_blocks > bfree)
11650 + *free_blocks = bfree;
11652 + if (root_blocks) {
11653 + if (*root_blocks > broot)
11654 + *root_blocks = broot;
11656 + put_dl_info(dli);
11659 +#define dl_prealloc_space(in, bytes) \
11660 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11661 + __FILE__, __LINE__ )
11663 +#define dl_alloc_space(in, bytes) \
11664 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11665 + __FILE__, __LINE__ )
11667 +#define dl_reserve_space(in, bytes) \
11668 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11669 + __FILE__, __LINE__ )
11671 +#define dl_claim_space(in, bytes) (0)
11673 +#define dl_release_space(in, bytes) \
11674 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11675 + __FILE__, __LINE__ )
11677 +#define dl_free_space(in, bytes) \
11678 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
11679 + __FILE__, __LINE__ )
11683 +#define dl_alloc_inode(in) \
11684 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
11686 +#define dl_free_inode(in) \
11687 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
11690 +#define dl_adjust_block(sb, tag, fb, rb) \
11691 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
11695 +#warning duplicate inclusion
11697 diff -NurpP --minimal linux-3.0/include/linux/vs_inet.h linux-3.0-vs2.3.1-pre7/include/linux/vs_inet.h
11698 --- linux-3.0/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
11699 +++ linux-3.0-vs2.3.1-pre7/include/linux/vs_inet.h 2011-06-10 22:11:24.000000000 +0200
11701 +#ifndef _VS_INET_H
11702 +#define _VS_INET_H
11704 +#include "vserver/base.h"
11705 +#include "vserver/network.h"
11706 +#include "vserver/debug.h"
11708 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
11710 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
11711 + NIPQUAD((a)->mask), (a)->type
11712 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
11714 +#define NIPQUAD(addr) \
11715 + ((unsigned char *)&addr)[0], \
11716 + ((unsigned char *)&addr)[1], \
11717 + ((unsigned char *)&addr)[2], \
11718 + ((unsigned char *)&addr)[3]
11720 +#define NIPQUAD_FMT "%u.%u.%u.%u"
11724 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
11726 + __be32 ip = nxa->ip[0].s_addr;
11727 + __be32 mask = nxa->mask.s_addr;
11728 + __be32 bcast = ip | ~mask;
11731 + switch (nxa->type & tmask) {
11732 + case NXA_TYPE_MASK:
11733 + ret = (ip == (addr & mask));
11735 + case NXA_TYPE_ADDR:
11739 + /* fall through to broadcast */
11740 + case NXA_MOD_BCAST:
11741 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
11743 + case NXA_TYPE_RANGE:
11744 + ret = ((nxa->ip[0].s_addr <= addr) &&
11745 + (nxa->ip[1].s_addr > addr));
11747 + case NXA_TYPE_ANY:
11752 + vxdprintk(VXD_CBIT(net, 0),
11753 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
11754 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
11759 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
11761 + struct nx_addr_v4 *nxa;
11768 + /* allow 127.0.0.1 when remapping lback */
11769 + if ((tmask & NXA_LOOPBACK) &&
11770 + (addr == IPI_LOOPBACK) &&
11771 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
11774 + /* check for lback address */
11775 + if ((tmask & NXA_MOD_LBACK) &&
11776 + (nxi->v4_lback.s_addr == addr))
11779 + /* check for broadcast address */
11780 + if ((tmask & NXA_MOD_BCAST) &&
11781 + (nxi->v4_bcast.s_addr == addr))
11784 + /* check for v4 addresses */
11785 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
11786 + if (v4_addr_match(nxa, addr, tmask))
11790 + vxdprintk(VXD_CBIT(net, 0),
11791 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
11792 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
11797 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
11799 + /* FIXME: needs full range checks */
11800 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
11804 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
11806 + struct nx_addr_v4 *ptr;
11808 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
11809 + if (v4_nx_addr_match(ptr, nxa, mask))
11814 +#include <net/inet_sock.h>
11817 + * Check if a given address matches for a socket
11819 + * nxi: the socket's nx_info if any
11820 + * addr: to be verified address
11823 +int v4_sock_addr_match (
11824 + struct nx_info *nxi,
11825 + struct inet_sock *inet,
11828 + __be32 saddr = inet->inet_rcv_saddr;
11829 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
11831 + if (addr && (saddr == addr || bcast == addr))
11834 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
11839 +/* inet related checks and helpers */
11843 +struct net_device;
11846 +#ifdef CONFIG_INET
11848 +#include <linux/netdevice.h>
11849 +#include <linux/inetdevice.h>
11850 +#include <net/inet_sock.h>
11851 +#include <net/inet_timewait_sock.h>
11854 +int dev_in_nx_info(struct net_device *, struct nx_info *);
11855 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
11856 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
11860 + * check if address is covered by socket
11862 + * sk: the socket to check against
11863 + * addr: the address in question (must be != 0)
11867 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
11869 + struct nx_info *nxi = sk->sk_nx_info;
11870 + __be32 saddr = sk_rcv_saddr(sk);
11872 + vxdprintk(VXD_CBIT(net, 5),
11873 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
11874 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
11875 + (sk->sk_socket?sk->sk_socket->flags:0));
11877 + if (saddr) { /* direct address match */
11878 + return v4_addr_match(nxa, saddr, -1);
11879 + } else if (nxi) { /* match against nx_info */
11880 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
11881 + } else { /* unrestricted any socket */
11889 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
11891 + vxdprintk(VXD_CBIT(net, 1),
11892 + "nx_dev_visible(%p[#%u],%p " VS_Q("%s") ") %d",
11893 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
11894 + nxi ? dev_in_nx_info(dev, nxi) : 0);
11896 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
11898 + if (dev_in_nx_info(dev, nxi))
11905 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
11911 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
11915 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
11917 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
11918 + nxi, nxi ? nxi->nx_id : 0, ifa,
11919 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
11921 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
11923 + if (v4_ifa_in_nx_info(ifa, nxi))
11929 +struct nx_v4_sock_addr {
11930 + __be32 saddr; /* Address used for validation */
11931 + __be32 baddr; /* Address used for socket bind */
11935 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
11936 + struct nx_v4_sock_addr *nsa)
11938 + struct sock *sk = &inet->sk;
11939 + struct nx_info *nxi = sk->sk_nx_info;
11940 + __be32 saddr = addr->sin_addr.s_addr;
11941 + __be32 baddr = saddr;
11943 + vxdprintk(VXD_CBIT(net, 3),
11944 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
11945 + sk, sk->sk_nx_info, sk->sk_socket,
11946 + (sk->sk_socket ? sk->sk_socket->flags : 0),
11950 + if (saddr == INADDR_ANY) {
11951 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
11952 + baddr = nxi->v4.ip[0].s_addr;
11953 + } else if (saddr == IPI_LOOPBACK) {
11954 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
11955 + baddr = nxi->v4_lback.s_addr;
11956 + } else { /* normal address bind */
11957 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
11958 + return -EADDRNOTAVAIL;
11962 + vxdprintk(VXD_CBIT(net, 3),
11963 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
11964 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
11966 + nsa->saddr = saddr;
11967 + nsa->baddr = baddr;
11972 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
11974 + inet->inet_saddr = nsa->baddr;
11975 + inet->inet_rcv_saddr = nsa->baddr;
11980 + * helper to simplify inet_lookup_listener
11982 + * nxi: the socket's nx_info if any
11983 + * addr: to be verified address
11984 + * saddr: socket address
11986 +static inline int v4_inet_addr_match (
11987 + struct nx_info *nxi,
11991 + if (addr && (saddr == addr))
11994 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
11998 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
12000 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
12001 + (addr == nxi->v4_lback.s_addr))
12002 + return IPI_LOOPBACK;
12007 +int nx_info_has_v4(struct nx_info *nxi)
12011 + if (NX_IPV4(nxi))
12013 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
12018 +#else /* CONFIG_INET */
12021 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
12027 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
12033 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
12039 +int nx_info_has_v4(struct nx_info *nxi)
12044 +#endif /* CONFIG_INET */
12046 +#define current_nx_info_has_v4() \
12047 + nx_info_has_v4(current_nx_info())
12050 +// #warning duplicate inclusion
12052 diff -NurpP --minimal linux-3.0/include/linux/vs_inet6.h linux-3.0-vs2.3.1-pre7/include/linux/vs_inet6.h
12053 --- linux-3.0/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
12054 +++ linux-3.0-vs2.3.1-pre7/include/linux/vs_inet6.h 2011-06-10 22:11:24.000000000 +0200
12056 +#ifndef _VS_INET6_H
12057 +#define _VS_INET6_H
12059 +#include "vserver/base.h"
12060 +#include "vserver/network.h"
12061 +#include "vserver/debug.h"
12063 +#include <net/ipv6.h>
12065 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
12066 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
12069 +#ifdef CONFIG_IPV6
12072 +int v6_addr_match(struct nx_addr_v6 *nxa,
12073 + const struct in6_addr *addr, uint16_t mask)
12077 + switch (nxa->type & mask) {
12078 + case NXA_TYPE_MASK:
12079 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
12081 + case NXA_TYPE_ADDR:
12082 + ret = ipv6_addr_equal(&nxa->ip, addr);
12084 + case NXA_TYPE_ANY:
12088 + vxdprintk(VXD_CBIT(net, 0),
12089 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
12090 + nxa, NXAV6(nxa), addr, mask, ret);
12095 +int v6_addr_in_nx_info(struct nx_info *nxi,
12096 + const struct in6_addr *addr, uint16_t mask)
12098 + struct nx_addr_v6 *nxa;
12103 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
12104 + if (v6_addr_match(nxa, addr, mask))
12108 + vxdprintk(VXD_CBIT(net, 0),
12109 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
12110 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
12115 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
12117 + /* FIXME: needs full range checks */
12118 + return v6_addr_match(nxa, &addr->ip, mask);
12122 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
12124 + struct nx_addr_v6 *ptr;
12126 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
12127 + if (v6_nx_addr_match(ptr, nxa, mask))
12134 + * Check if a given address matches for a socket
12136 + * nxi: the socket's nx_info if any
12137 + * addr: to be verified address
12140 +int v6_sock_addr_match (
12141 + struct nx_info *nxi,
12142 + struct inet_sock *inet,
12143 + struct in6_addr *addr)
12145 + struct sock *sk = &inet->sk;
12146 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
12148 + if (!ipv6_addr_any(addr) &&
12149 + ipv6_addr_equal(saddr, addr))
12151 + if (ipv6_addr_any(saddr))
12152 + return v6_addr_in_nx_info(nxi, addr, -1);
12157 + * check if address is covered by socket
12159 + * sk: the socket to check against
12160 + * addr: the address in question (must be != 0)
12164 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
12166 + struct nx_info *nxi = sk->sk_nx_info;
12167 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
12169 + vxdprintk(VXD_CBIT(net, 5),
12170 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
12171 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
12172 + (sk->sk_socket?sk->sk_socket->flags:0));
12174 + if (!ipv6_addr_any(saddr)) { /* direct address match */
12175 + return v6_addr_match(nxa, saddr, -1);
12176 + } else if (nxi) { /* match against nx_info */
12177 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
12178 + } else { /* unrestricted any socket */
12184 +/* inet related checks and helpers */
12188 +struct net_device;
12192 +#include <linux/netdevice.h>
12193 +#include <linux/inetdevice.h>
12194 +#include <net/inet_timewait_sock.h>
12197 +int dev_in_nx_info(struct net_device *, struct nx_info *);
12198 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
12199 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
12204 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
12210 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
12214 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
12216 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
12217 + nxi, nxi ? nxi->nx_id : 0, ifa,
12218 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
12220 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
12222 + if (v6_ifa_in_nx_info(ifa, nxi))
12228 +struct nx_v6_sock_addr {
12229 + struct in6_addr saddr; /* Address used for validation */
12230 + struct in6_addr baddr; /* Address used for socket bind */
12234 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
12235 + struct nx_v6_sock_addr *nsa)
12237 + // struct sock *sk = &inet->sk;
12238 + // struct nx_info *nxi = sk->sk_nx_info;
12239 + struct in6_addr saddr = addr->sin6_addr;
12240 + struct in6_addr baddr = saddr;
12242 + nsa->saddr = saddr;
12243 + nsa->baddr = baddr;
12248 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
12250 + // struct sock *sk = &inet->sk;
12251 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
12253 + // *saddr = nsa->baddr;
12254 + // inet->inet_saddr = nsa->baddr;
12258 +int nx_info_has_v6(struct nx_info *nxi)
12262 + if (NX_IPV6(nxi))
12267 +#else /* CONFIG_IPV6 */
12270 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
12277 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
12283 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
12289 +int nx_info_has_v6(struct nx_info *nxi)
12294 +#endif /* CONFIG_IPV6 */
12296 +#define current_nx_info_has_v6() \
12297 + nx_info_has_v6(current_nx_info())
12300 +#warning duplicate inclusion
12302 diff -NurpP --minimal linux-3.0/include/linux/vs_limit.h linux-3.0-vs2.3.1-pre7/include/linux/vs_limit.h
12303 --- linux-3.0/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
12304 +++ linux-3.0-vs2.3.1-pre7/include/linux/vs_limit.h 2011-06-10 22:11:24.000000000 +0200
12306 +#ifndef _VS_LIMIT_H
12307 +#define _VS_LIMIT_H
12309 +#include "vserver/limit.h"
12310 +#include "vserver/base.h"
12311 +#include "vserver/context.h"
12312 +#include "vserver/debug.h"
12313 +#include "vserver/context.h"
12314 +#include "vserver/limit_int.h"
12317 +#define vx_acc_cres(v, d, p, r) \
12318 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
12320 +#define vx_acc_cres_cond(x, d, p, r) \
12321 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
12322 + r, d, p, __FILE__, __LINE__)
12325 +#define vx_add_cres(v, a, p, r) \
12326 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
12327 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
12329 +#define vx_add_cres_cond(x, a, p, r) \
12330 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
12331 + r, a, p, __FILE__, __LINE__)
12332 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
12335 +/* process and file limits */
12337 +#define vx_nproc_inc(p) \
12338 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
12340 +#define vx_nproc_dec(p) \
12341 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
12343 +#define vx_files_inc(f) \
12344 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
12346 +#define vx_files_dec(f) \
12347 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
12349 +#define vx_locks_inc(l) \
12350 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
12352 +#define vx_locks_dec(l) \
12353 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
12355 +#define vx_openfd_inc(f) \
12356 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
12358 +#define vx_openfd_dec(f) \
12359 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
12362 +#define vx_cres_avail(v, n, r) \
12363 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
12366 +#define vx_nproc_avail(n) \
12367 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
12369 +#define vx_files_avail(n) \
12370 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
12372 +#define vx_locks_avail(n) \
12373 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
12375 +#define vx_openfd_avail(n) \
12376 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
12379 +/* dentry limits */
12381 +#define vx_dentry_inc(d) do { \
12382 + if ((d)->d_count == 1) \
12383 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
12386 +#define vx_dentry_dec(d) do { \
12387 + if ((d)->d_count == 0) \
12388 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
12391 +#define vx_dentry_avail(n) \
12392 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
12395 +/* socket limits */
12397 +#define vx_sock_inc(s) \
12398 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
12400 +#define vx_sock_dec(s) \
12401 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
12403 +#define vx_sock_avail(n) \
12404 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
12407 +/* ipc resource limits */
12409 +#define vx_ipcmsg_add(v, u, a) \
12410 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
12412 +#define vx_ipcmsg_sub(v, u, a) \
12413 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
12415 +#define vx_ipcmsg_avail(v, a) \
12416 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
12419 +#define vx_ipcshm_add(v, k, a) \
12420 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
12422 +#define vx_ipcshm_sub(v, k, a) \
12423 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
12425 +#define vx_ipcshm_avail(v, a) \
12426 + vx_cres_avail(v, a, VLIMIT_SHMEM)
12429 +#define vx_semary_inc(a) \
12430 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
12432 +#define vx_semary_dec(a) \
12433 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
12436 +#define vx_nsems_add(a,n) \
12437 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
12439 +#define vx_nsems_sub(a,n) \
12440 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
12444 +#warning duplicate inclusion
12446 diff -NurpP --minimal linux-3.0/include/linux/vs_memory.h linux-3.0-vs2.3.1-pre7/include/linux/vs_memory.h
12447 --- linux-3.0/include/linux/vs_memory.h 1970-01-01 01:00:00.000000000 +0100
12448 +++ linux-3.0-vs2.3.1-pre7/include/linux/vs_memory.h 2011-06-10 22:11:24.000000000 +0200
12450 +#ifndef _VS_MEMORY_H
12451 +#define _VS_MEMORY_H
12453 +#include "vserver/limit.h"
12454 +#include "vserver/base.h"
12455 +#include "vserver/context.h"
12456 +#include "vserver/debug.h"
12457 +#include "vserver/context.h"
12458 +#include "vserver/limit_int.h"
12461 + VXPT_UNKNOWN = 0,
12470 +#define vx_page_fault(mm, vma, type, ret)
12474 +void __vx_page_fault(struct mm_struct *mm,
12475 + struct vm_area_struct *vma, int type, int ret)
12477 + struct vx_info *vxi = mm->mm_vx_info;
12480 + static char *page_type[6] =
12481 + { "UNKNOWN", "ANON", "NONE", "FILE", "SWAP", "WRITE" };
12482 + static char *page_what[4] =
12483 + { "FAULT_OOM", "FAULT_SIGBUS", "FAULT_MINOR", "FAULT_MAJOR" };
12489 + what = (ret & 0x3);
12491 +/* printk("[%d] page[%d][%d] %2x %s %s\n", vxi->vx_id,
12492 + type, what, ret, page_type[type], page_what[what]);
12494 + if (ret & VM_FAULT_WRITE)
12496 + atomic_inc(&vxi->cacct.page[type][what]);
12499 +#define vx_page_fault(mm, vma, type, ret) __vx_page_fault(mm, vma, type, ret)
12503 +extern unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm);
12506 +#warning duplicate inclusion
12508 diff -NurpP --minimal linux-3.0/include/linux/vs_network.h linux-3.0-vs2.3.1-pre7/include/linux/vs_network.h
12509 --- linux-3.0/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
12510 +++ linux-3.0-vs2.3.1-pre7/include/linux/vs_network.h 2011-06-10 22:11:24.000000000 +0200
12512 +#ifndef _NX_VS_NETWORK_H
12513 +#define _NX_VS_NETWORK_H
12515 +#include "vserver/context.h"
12516 +#include "vserver/network.h"
12517 +#include "vserver/base.h"
12518 +#include "vserver/check.h"
12519 +#include "vserver/debug.h"
12521 +#include <linux/sched.h>
12524 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
12526 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
12527 + const char *_file, int _line)
12532 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
12533 + nxi, nxi ? nxi->nx_id : 0,
12534 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
12537 + atomic_inc(&nxi->nx_usecnt);
12542 +extern void free_nx_info(struct nx_info *);
12544 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
12546 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
12551 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
12552 + nxi, nxi ? nxi->nx_id : 0,
12553 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
12556 + if (atomic_dec_and_test(&nxi->nx_usecnt))
12557 + free_nx_info(nxi);
12561 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
12563 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
12564 + const char *_file, int _line)
12567 + vxlprintk(VXD_CBIT(nid, 3),
12568 + "init_nx_info(%p[#%d.%d])",
12569 + nxi, nxi ? nxi->nx_id : 0,
12570 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
12573 + atomic_inc(&nxi->nx_usecnt);
12579 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
12581 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
12582 + const char *_file, int _line)
12584 + struct nx_info *nxo;
12589 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
12590 + nxi, nxi ? nxi->nx_id : 0,
12591 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
12594 + atomic_inc(&nxi->nx_usecnt);
12595 + nxo = xchg(nxp, nxi);
12599 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
12601 +static inline void __clr_nx_info(struct nx_info **nxp,
12602 + const char *_file, int _line)
12604 + struct nx_info *nxo;
12606 + nxo = xchg(nxp, NULL);
12610 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
12611 + nxo, nxo ? nxo->nx_id : 0,
12612 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
12615 + if (atomic_dec_and_test(&nxo->nx_usecnt))
12616 + free_nx_info(nxo);
12620 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
12622 +static inline void __claim_nx_info(struct nx_info *nxi,
12623 + struct task_struct *task, const char *_file, int _line)
12625 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
12626 + nxi, nxi ? nxi->nx_id : 0,
12627 + nxi?atomic_read(&nxi->nx_usecnt):0,
12628 + nxi?atomic_read(&nxi->nx_tasks):0,
12629 + task, _file, _line);
12631 + atomic_inc(&nxi->nx_tasks);
12635 +extern void unhash_nx_info(struct nx_info *);
12637 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
12639 +static inline void __release_nx_info(struct nx_info *nxi,
12640 + struct task_struct *task, const char *_file, int _line)
12642 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
12643 + nxi, nxi ? nxi->nx_id : 0,
12644 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
12645 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
12646 + task, _file, _line);
12650 + if (atomic_dec_and_test(&nxi->nx_tasks))
12651 + unhash_nx_info(nxi);
12655 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
12657 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
12658 + const char *_file, int _line)
12660 + struct nx_info *nxi;
12663 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
12664 + p, _file, _line);
12665 + nxi = __get_nx_info(p->nx_info, _file, _line);
12671 +static inline void exit_nx_info(struct task_struct *p)
12674 + release_nx_info(p->nx_info, p);
12679 +#warning duplicate inclusion
12681 diff -NurpP --minimal linux-3.0/include/linux/vs_pid.h linux-3.0-vs2.3.1-pre7/include/linux/vs_pid.h
12682 --- linux-3.0/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
12683 +++ linux-3.0-vs2.3.1-pre7/include/linux/vs_pid.h 2011-06-10 22:11:24.000000000 +0200
12688 +#include "vserver/base.h"
12689 +#include "vserver/check.h"
12690 +#include "vserver/context.h"
12691 +#include "vserver/debug.h"
12692 +#include "vserver/pid.h"
12693 +#include <linux/pid_namespace.h>
12696 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
12699 +int vx_proc_task_visible(struct task_struct *task)
12701 + if ((task->pid == 1) &&
12702 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
12703 + /* show a blend through init */
12705 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
12712 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
12716 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
12718 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
12720 + if (task && !vx_proc_task_visible(task)) {
12721 + vxdprintk(VXD_CBIT(misc, 6),
12722 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
12723 + task, task->xid, task->pid,
12724 + current, current->xid, current->pid);
12725 + put_task_struct(task);
12733 +#warning duplicate inclusion
12735 diff -NurpP --minimal linux-3.0/include/linux/vs_sched.h linux-3.0-vs2.3.1-pre7/include/linux/vs_sched.h
12736 --- linux-3.0/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
12737 +++ linux-3.0-vs2.3.1-pre7/include/linux/vs_sched.h 2011-06-10 22:11:24.000000000 +0200
12739 +#ifndef _VS_SCHED_H
12740 +#define _VS_SCHED_H
12742 +#include "vserver/base.h"
12743 +#include "vserver/context.h"
12744 +#include "vserver/sched.h"
12747 +#define MAX_PRIO_BIAS 20
12748 +#define MIN_PRIO_BIAS -20
12751 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
12753 + struct vx_info *vxi = p->vx_info;
12756 + prio += vx_cpu(vxi, sched_pc).prio_bias;
12760 +static inline void vx_account_user(struct vx_info *vxi,
12761 + cputime_t cputime, int nice)
12765 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
12768 +static inline void vx_account_system(struct vx_info *vxi,
12769 + cputime_t cputime, int idle)
12773 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
12777 +#warning duplicate inclusion
12779 diff -NurpP --minimal linux-3.0/include/linux/vs_socket.h linux-3.0-vs2.3.1-pre7/include/linux/vs_socket.h
12780 --- linux-3.0/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
12781 +++ linux-3.0-vs2.3.1-pre7/include/linux/vs_socket.h 2011-06-10 22:11:24.000000000 +0200
12783 +#ifndef _VS_SOCKET_H
12784 +#define _VS_SOCKET_H
12786 +#include "vserver/debug.h"
12787 +#include "vserver/base.h"
12788 +#include "vserver/cacct.h"
12789 +#include "vserver/context.h"
12790 +#include "vserver/tag.h"
12793 +/* socket accounting */
12795 +#include <linux/socket.h>
12797 +static inline int vx_sock_type(int family)
12799 + switch (family) {
12801 + return VXA_SOCK_UNSPEC;
12803 + return VXA_SOCK_UNIX;
12805 + return VXA_SOCK_INET;
12807 + return VXA_SOCK_INET6;
12809 + return VXA_SOCK_PACKET;
12811 + return VXA_SOCK_OTHER;
12815 +#define vx_acc_sock(v, f, p, s) \
12816 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
12818 +static inline void __vx_acc_sock(struct vx_info *vxi,
12819 + int family, int pos, int size, char *file, int line)
12822 + int type = vx_sock_type(family);
12824 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
12825 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
12829 +#define vx_sock_recv(sk, s) \
12830 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
12831 +#define vx_sock_send(sk, s) \
12832 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
12833 +#define vx_sock_fail(sk, s) \
12834 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
12837 +#define sock_vx_init(s) do { \
12838 + (s)->sk_xid = 0; \
12839 + (s)->sk_vx_info = NULL; \
12842 +#define sock_nx_init(s) do { \
12843 + (s)->sk_nid = 0; \
12844 + (s)->sk_nx_info = NULL; \
12848 +#warning duplicate inclusion
12850 diff -NurpP --minimal linux-3.0/include/linux/vs_tag.h linux-3.0-vs2.3.1-pre7/include/linux/vs_tag.h
12851 --- linux-3.0/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
12852 +++ linux-3.0-vs2.3.1-pre7/include/linux/vs_tag.h 2011-06-10 22:11:24.000000000 +0200
12857 +#include <linux/vserver/tag.h>
12859 +/* check conditions */
12861 +#define DX_ADMIN 0x0001
12862 +#define DX_WATCH 0x0002
12863 +#define DX_HOSTID 0x0008
12865 +#define DX_IDENT 0x0010
12867 +#define DX_ARG_MASK 0x0010
12870 +#define dx_task_tag(t) ((t)->tag)
12872 +#define dx_current_tag() dx_task_tag(current)
12874 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
12876 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
12880 + * check current context for ADMIN/WATCH and
12881 + * optionally against supplied argument
12883 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
12885 + if (mode & DX_ARG_MASK) {
12886 + if ((mode & DX_IDENT) && (id == cid))
12889 + return (((mode & DX_ADMIN) && (cid == 0)) ||
12890 + ((mode & DX_WATCH) && (cid == 1)) ||
12891 + ((mode & DX_HOSTID) && (id == 0)));
12895 +int dx_permission(const struct inode *inode, int mask);
12899 +#warning duplicate inclusion
12901 diff -NurpP --minimal linux-3.0/include/linux/vs_time.h linux-3.0-vs2.3.1-pre7/include/linux/vs_time.h
12902 --- linux-3.0/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
12903 +++ linux-3.0-vs2.3.1-pre7/include/linux/vs_time.h 2011-06-13 14:57:45.000000000 +0200
12905 +#ifndef _VS_TIME_H
12906 +#define _VS_TIME_H
12909 +/* time faking stuff */
12911 +#ifdef CONFIG_VSERVER_VTIME
12913 +extern void vx_adjust_timespec(struct timespec *ts);
12914 +extern int vx_settimeofday(const struct timespec *ts);
12917 +#define vx_adjust_timespec(t) do { } while (0)
12918 +#define vx_settimeofday(t) do_settimeofday(t)
12922 +#warning duplicate inclusion
12924 diff -NurpP --minimal linux-3.0/include/linux/vserver/Kbuild linux-3.0-vs2.3.1-pre7/include/linux/vserver/Kbuild
12925 --- linux-3.0/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
12926 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/Kbuild 2011-06-10 22:11:24.000000000 +0200
12929 +unifdef-y += context_cmd.h network_cmd.h space_cmd.h \
12930 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
12931 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
12932 + debug_cmd.h device_cmd.h
12934 +unifdef-y += switch.h network.h monitor.h inode.h device.h
12936 diff -NurpP --minimal linux-3.0/include/linux/vserver/base.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/base.h
12937 --- linux-3.0/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
12938 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/base.h 2011-06-13 14:09:44.000000000 +0200
12940 +#ifndef _VX_BASE_H
12941 +#define _VX_BASE_H
12944 +/* context state changes */
12956 +#define vx_task_xid(t) ((t)->xid)
12958 +#define vx_current_xid() vx_task_xid(current)
12960 +#define current_vx_info() (current->vx_info)
12963 +#define nx_task_nid(t) ((t)->nid)
12965 +#define nx_current_nid() nx_task_nid(current)
12967 +#define current_nx_info() (current->nx_info)
12970 +/* generic flag merging */
12972 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
12974 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
12976 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
12978 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
12981 +/* context flags */
12983 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
12985 +#define vx_current_flags() __vx_flags(current_vx_info())
12987 +#define vx_info_flags(v, m, f) \
12988 + vs_check_flags(__vx_flags(v), m, f)
12990 +#define task_vx_flags(t, m, f) \
12991 + ((t) && vx_info_flags((t)->vx_info, m, f))
12993 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
12996 +/* context caps */
12998 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
13000 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
13002 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
13004 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
13008 +/* network flags */
13010 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
13012 +#define nx_current_flags() __nx_flags(current_nx_info())
13014 +#define nx_info_flags(n, m, f) \
13015 + vs_check_flags(__nx_flags(n), m, f)
13017 +#define task_nx_flags(t, m, f) \
13018 + ((t) && nx_info_flags((t)->nx_info, m, f))
13020 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
13023 +/* network caps */
13025 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
13027 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
13029 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
13031 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
13034 +/* context mask capabilities */
13036 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
13038 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
13040 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
13043 +/* context bcap mask */
13045 +#define __vx_bcaps(v) ((v)->vx_bcaps)
13047 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
13050 +/* mask given bcaps */
13052 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
13054 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
13057 +/* masked cap_bset */
13059 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
13061 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
13064 +#define vx_info_mbcap(v, b) \
13065 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
13066 + vx_info_bcaps(v, b) : (b))
13068 +#define task_vx_mbcap(t, b) \
13069 + vx_info_mbcap((t)->vx_info, (t)->b)
13071 +#define vx_mbcap(b) task_vx_mbcap(current, b)
13074 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
13076 +#define vx_capable(b, c) (capable(b) || \
13077 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
13079 +#define vx_ns_capable(n, b, c) (ns_capable(n, b) || \
13080 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
13082 +#define nx_capable(b, c) (capable(b) || \
13083 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
13085 +#define vx_task_initpid(t, n) \
13086 + ((t)->vx_info && \
13087 + ((t)->vx_info->vx_initpid == (n)))
13089 +#define vx_current_initpid(n) vx_task_initpid(current, n)
13092 +/* context unshare mask */
13094 +#define __vx_umask(v) ((v)->vx_umask)
13096 +#define vx_current_umask() __vx_umask(current_vx_info())
13098 +#define vx_can_unshare(b, f) (capable(b) || \
13099 + (cap_raised(current_cap(), b) && \
13100 + !((f) & ~vx_current_umask())))
13103 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
13105 +#define vx_info_state(v, m) (__vx_state(v) & (m))
13108 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
13110 +#define nx_info_state(n, m) (__nx_state(n) & (m))
13113 diff -NurpP --minimal linux-3.0/include/linux/vserver/cacct.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/cacct.h
13114 --- linux-3.0/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
13115 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/cacct.h 2011-06-10 22:11:24.000000000 +0200
13117 +#ifndef _VX_CACCT_H
13118 +#define _VX_CACCT_H
13121 +enum sock_acc_field {
13122 + VXA_SOCK_UNSPEC = 0,
13128 + VXA_SOCK_SIZE /* array size */
13131 +#endif /* _VX_CACCT_H */
13132 diff -NurpP --minimal linux-3.0/include/linux/vserver/cacct_cmd.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/cacct_cmd.h
13133 --- linux-3.0/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
13134 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/cacct_cmd.h 2011-06-10 22:11:24.000000000 +0200
13136 +#ifndef _VX_CACCT_CMD_H
13137 +#define _VX_CACCT_CMD_H
13140 +/* virtual host info name commands */
13142 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
13144 +struct vcmd_sock_stat_v0 {
13146 + uint32_t count[3];
13147 + uint64_t total[3];
13153 +#include <linux/compiler.h>
13155 +extern int vc_sock_stat(struct vx_info *, void __user *);
13157 +#endif /* __KERNEL__ */
13158 +#endif /* _VX_CACCT_CMD_H */
13159 diff -NurpP --minimal linux-3.0/include/linux/vserver/cacct_def.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/cacct_def.h
13160 --- linux-3.0/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
13161 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/cacct_def.h 2011-06-10 22:11:24.000000000 +0200
13163 +#ifndef _VX_CACCT_DEF_H
13164 +#define _VX_CACCT_DEF_H
13166 +#include <asm/atomic.h>
13167 +#include <linux/vserver/cacct.h>
13170 +struct _vx_sock_acc {
13171 + atomic_long_t count;
13172 + atomic_long_t total;
13175 +/* context sub struct */
13177 +struct _vx_cacct {
13178 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
13179 + atomic_t slab[8];
13180 + atomic_t page[6][8];
13183 +#ifdef CONFIG_VSERVER_DEBUG
13185 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
13189 + printk("\t_vx_cacct:");
13190 + for (i = 0; i < 6; i++) {
13191 + struct _vx_sock_acc *ptr = cacct->sock[i];
13193 + printk("\t [%d] =", i);
13194 + for (j = 0; j < 3; j++) {
13195 + printk(" [%d] = %8lu, %8lu", j,
13196 + atomic_long_read(&ptr[j].count),
13197 + atomic_long_read(&ptr[j].total));
13205 +#endif /* _VX_CACCT_DEF_H */
13206 diff -NurpP --minimal linux-3.0/include/linux/vserver/cacct_int.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/cacct_int.h
13207 --- linux-3.0/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
13208 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/cacct_int.h 2011-06-10 22:11:24.000000000 +0200
13210 +#ifndef _VX_CACCT_INT_H
13211 +#define _VX_CACCT_INT_H
13217 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
13219 + return atomic_long_read(&cacct->sock[type][pos].count);
13224 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
13226 + return atomic_long_read(&cacct->sock[type][pos].total);
13229 +#endif /* __KERNEL__ */
13230 +#endif /* _VX_CACCT_INT_H */
13231 diff -NurpP --minimal linux-3.0/include/linux/vserver/check.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/check.h
13232 --- linux-3.0/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
13233 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/check.h 2011-06-10 22:11:24.000000000 +0200
13235 +#ifndef _VS_CHECK_H
13236 +#define _VS_CHECK_H
13239 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
13241 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
13242 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
13244 +#define MIN_D_CONTEXT 65536
13247 +/* check conditions */
13249 +#define VS_ADMIN 0x0001
13250 +#define VS_WATCH 0x0002
13251 +#define VS_HIDE 0x0004
13252 +#define VS_HOSTID 0x0008
13254 +#define VS_IDENT 0x0010
13255 +#define VS_EQUIV 0x0020
13256 +#define VS_PARENT 0x0040
13257 +#define VS_CHILD 0x0080
13259 +#define VS_ARG_MASK 0x00F0
13261 +#define VS_DYNAMIC 0x0100
13262 +#define VS_STATIC 0x0200
13264 +#define VS_ATR_MASK 0x0F00
13266 +#ifdef CONFIG_VSERVER_PRIVACY
13267 +#define VS_ADMIN_P (0)
13268 +#define VS_WATCH_P (0)
13270 +#define VS_ADMIN_P VS_ADMIN
13271 +#define VS_WATCH_P VS_WATCH
13274 +#define VS_HARDIRQ 0x1000
13275 +#define VS_SOFTIRQ 0x2000
13276 +#define VS_IRQ 0x4000
13278 +#define VS_IRQ_MASK 0xF000
13280 +#include <linux/hardirq.h>
13283 + * check current context for ADMIN/WATCH and
13284 + * optionally against supplied argument
13286 +static inline int __vs_check(int cid, int id, unsigned int mode)
13288 + if (mode & VS_ARG_MASK) {
13289 + if ((mode & VS_IDENT) && (id == cid))
13292 + if (mode & VS_ATR_MASK) {
13293 + if ((mode & VS_DYNAMIC) &&
13294 + (id >= MIN_D_CONTEXT) &&
13295 + (id <= MAX_S_CONTEXT))
13297 + if ((mode & VS_STATIC) &&
13298 + (id > 1) && (id < MIN_D_CONTEXT))
13301 + if (mode & VS_IRQ_MASK) {
13302 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
13304 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
13306 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
13309 + return (((mode & VS_ADMIN) && (cid == 0)) ||
13310 + ((mode & VS_WATCH) && (cid == 1)) ||
13311 + ((mode & VS_HOSTID) && (id == 0)));
13314 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
13316 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
13319 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
13321 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
13324 diff -NurpP --minimal linux-3.0/include/linux/vserver/context.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/context.h
13325 --- linux-3.0/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
13326 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/context.h 2011-06-10 22:11:24.000000000 +0200
13328 +#ifndef _VX_CONTEXT_H
13329 +#define _VX_CONTEXT_H
13331 +#include <linux/types.h>
13332 +#include <linux/capability.h>
13335 +/* context flags */
13337 +#define VXF_INFO_SCHED 0x00000002
13338 +#define VXF_INFO_NPROC 0x00000004
13339 +#define VXF_INFO_PRIVATE 0x00000008
13341 +#define VXF_INFO_INIT 0x00000010
13342 +#define VXF_INFO_HIDE 0x00000020
13343 +#define VXF_INFO_ULIMIT 0x00000040
13344 +#define VXF_INFO_NSPACE 0x00000080
13346 +#define VXF_SCHED_HARD 0x00000100
13347 +#define VXF_SCHED_PRIO 0x00000200
13348 +#define VXF_SCHED_PAUSE 0x00000400
13350 +#define VXF_VIRT_MEM 0x00010000
13351 +#define VXF_VIRT_UPTIME 0x00020000
13352 +#define VXF_VIRT_CPU 0x00040000
13353 +#define VXF_VIRT_LOAD 0x00080000
13354 +#define VXF_VIRT_TIME 0x00100000
13356 +#define VXF_HIDE_MOUNT 0x01000000
13357 +/* was VXF_HIDE_NETIF 0x02000000 */
13358 +#define VXF_HIDE_VINFO 0x04000000
13360 +#define VXF_STATE_SETUP (1ULL << 32)
13361 +#define VXF_STATE_INIT (1ULL << 33)
13362 +#define VXF_STATE_ADMIN (1ULL << 34)
13364 +#define VXF_SC_HELPER (1ULL << 36)
13365 +#define VXF_REBOOT_KILL (1ULL << 37)
13366 +#define VXF_PERSISTENT (1ULL << 38)
13368 +#define VXF_FORK_RSS (1ULL << 48)
13369 +#define VXF_PROLIFIC (1ULL << 49)
13371 +#define VXF_IGNEG_NICE (1ULL << 52)
13373 +#define VXF_ONE_TIME (0x0007ULL << 32)
13375 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
13378 +/* context migration */
13380 +#define VXM_SET_INIT 0x00000001
13381 +#define VXM_SET_REAPER 0x00000002
13383 +/* context caps */
13385 +#define VXC_CAP_MASK 0x00000000
13387 +#define VXC_SET_UTSNAME 0x00000001
13388 +#define VXC_SET_RLIMIT 0x00000002
13389 +#define VXC_FS_SECURITY 0x00000004
13390 +#define VXC_FS_TRUSTED 0x00000008
13391 +#define VXC_TIOCSTI 0x00000010
13393 +/* was VXC_RAW_ICMP 0x00000100 */
13394 +#define VXC_SYSLOG 0x00001000
13395 +#define VXC_OOM_ADJUST 0x00002000
13396 +#define VXC_AUDIT_CONTROL 0x00004000
13398 +#define VXC_SECURE_MOUNT 0x00010000
13399 +#define VXC_SECURE_REMOUNT 0x00020000
13400 +#define VXC_BINARY_MOUNT 0x00040000
13402 +#define VXC_QUOTA_CTL 0x00100000
13403 +#define VXC_ADMIN_MAPPER 0x00200000
13404 +#define VXC_ADMIN_CLOOP 0x00400000
13406 +#define VXC_KTHREAD 0x01000000
13407 +#define VXC_NAMESPACE 0x02000000
13412 +#include <linux/list.h>
13413 +#include <linux/spinlock.h>
13414 +#include <linux/rcupdate.h>
13416 +#include "limit_def.h"
13417 +#include "sched_def.h"
13418 +#include "cvirt_def.h"
13419 +#include "cacct_def.h"
13420 +#include "device_def.h"
13422 +#define VX_SPACES 2
13424 +struct _vx_info_pc {
13425 + struct _vx_sched_pc sched_pc;
13426 + struct _vx_cvirt_pc cvirt_pc;
13429 +struct _vx_space {
13430 + unsigned long vx_nsmask; /* assignment mask */
13431 + struct nsproxy *vx_nsproxy; /* private namespaces */
13432 + struct fs_struct *vx_fs; /* private namespace fs */
13433 + const struct cred *vx_cred; /* task credentials */
13437 + struct hlist_node vx_hlist; /* linked list of contexts */
13438 + xid_t vx_id; /* context id */
13439 + atomic_t vx_usecnt; /* usage count */
13440 + atomic_t vx_tasks; /* tasks count */
13441 + struct vx_info *vx_parent; /* parent context */
13442 + int vx_state; /* context state */
13444 + struct _vx_space space[VX_SPACES]; /* namespace store */
13446 + uint64_t vx_flags; /* context flags */
13447 + uint64_t vx_ccaps; /* context caps (vserver) */
13448 + uint64_t vx_umask; /* unshare mask (guest) */
13449 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
13451 + struct task_struct *vx_reaper; /* guest reaper process */
13452 + pid_t vx_initpid; /* PID of guest init */
13453 + int64_t vx_badness_bias; /* OOM points bias */
13455 + struct _vx_limit limit; /* vserver limits */
13456 + struct _vx_sched sched; /* vserver scheduler */
13457 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
13458 + struct _vx_cacct cacct; /* context accounting */
13460 + struct _vx_device dmap; /* default device map targets */
13462 +#ifndef CONFIG_SMP
13463 + struct _vx_info_pc info_pc; /* per cpu data */
13465 + struct _vx_info_pc *ptr_pc; /* per cpu array */
13468 + wait_queue_head_t vx_wait; /* context exit waitqueue */
13469 + int reboot_cmd; /* last sys_reboot() cmd */
13470 + int exit_code; /* last process exit code */
13472 + char vx_name[65]; /* vserver name */
13475 +#ifndef CONFIG_SMP
13476 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
13477 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
13479 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
13480 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
13483 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
13486 +struct vx_info_save {
13487 + struct vx_info *vxi;
13492 +/* status flags */
13494 +#define VXS_HASHED 0x0001
13495 +#define VXS_PAUSED 0x0010
13496 +#define VXS_SHUTDOWN 0x0100
13497 +#define VXS_HELPER 0x1000
13498 +#define VXS_RELEASED 0x8000
13501 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
13502 +extern void release_vx_info(struct vx_info *, struct task_struct *);
13504 +extern struct vx_info *lookup_vx_info(int);
13505 +extern struct vx_info *lookup_or_create_vx_info(int);
13507 +extern int get_xid_list(int, unsigned int *, int);
13508 +extern int xid_is_hashed(xid_t);
13510 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
13512 +extern long vs_state_change(struct vx_info *, unsigned int);
13515 +#endif /* __KERNEL__ */
13516 +#endif /* _VX_CONTEXT_H */
13517 diff -NurpP --minimal linux-3.0/include/linux/vserver/context_cmd.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/context_cmd.h
13518 --- linux-3.0/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
13519 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/context_cmd.h 2011-06-10 22:11:24.000000000 +0200
13521 +#ifndef _VX_CONTEXT_CMD_H
13522 +#define _VX_CONTEXT_CMD_H
13525 +/* vinfo commands */
13527 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
13530 +extern int vc_task_xid(uint32_t);
13532 +#endif /* __KERNEL__ */
13534 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
13536 +struct vcmd_vx_info_v0 {
13538 + uint32_t initpid;
13539 + /* more to come */
13543 +extern int vc_vx_info(struct vx_info *, void __user *);
13545 +#endif /* __KERNEL__ */
13547 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
13549 +struct vcmd_ctx_stat_v0 {
13552 + /* more to come */
13556 +extern int vc_ctx_stat(struct vx_info *, void __user *);
13558 +#endif /* __KERNEL__ */
13560 +/* context commands */
13562 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
13563 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
13565 +struct vcmd_ctx_create {
13566 + uint64_t flagword;
13569 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
13570 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
13572 +struct vcmd_ctx_migrate {
13573 + uint64_t flagword;
13577 +extern int vc_ctx_create(uint32_t, void __user *);
13578 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
13580 +#endif /* __KERNEL__ */
13583 +/* flag commands */
13585 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
13586 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
13588 +struct vcmd_ctx_flags_v0 {
13589 + uint64_t flagword;
13594 +extern int vc_get_cflags(struct vx_info *, void __user *);
13595 +extern int vc_set_cflags(struct vx_info *, void __user *);
13597 +#endif /* __KERNEL__ */
13600 +/* context caps commands */
13602 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
13603 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
13605 +struct vcmd_ctx_caps_v1 {
13611 +extern int vc_get_ccaps(struct vx_info *, void __user *);
13612 +extern int vc_set_ccaps(struct vx_info *, void __user *);
13614 +#endif /* __KERNEL__ */
13617 +/* bcaps commands */
13619 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
13620 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
13622 +struct vcmd_bcaps {
13628 +extern int vc_get_bcaps(struct vx_info *, void __user *);
13629 +extern int vc_set_bcaps(struct vx_info *, void __user *);
13631 +#endif /* __KERNEL__ */
13634 +/* umask commands */
13636 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
13637 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
13639 +struct vcmd_umask {
13645 +extern int vc_get_umask(struct vx_info *, void __user *);
13646 +extern int vc_set_umask(struct vx_info *, void __user *);
13648 +#endif /* __KERNEL__ */
13653 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
13654 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
13656 +struct vcmd_badness_v0 {
13661 +extern int vc_get_badness(struct vx_info *, void __user *);
13662 +extern int vc_set_badness(struct vx_info *, void __user *);
13664 +#endif /* __KERNEL__ */
13665 +#endif /* _VX_CONTEXT_CMD_H */
13666 diff -NurpP --minimal linux-3.0/include/linux/vserver/cvirt.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/cvirt.h
13667 --- linux-3.0/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
13668 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/cvirt.h 2011-06-10 22:11:24.000000000 +0200
13670 +#ifndef _VX_CVIRT_H
13671 +#define _VX_CVIRT_H
13678 +void vx_vsi_uptime(struct timespec *, struct timespec *);
13683 +void vx_update_load(struct vx_info *);
13686 +int vx_do_syslog(int, char __user *, int);
13688 +#endif /* __KERNEL__ */
13689 +#endif /* _VX_CVIRT_H */
13690 diff -NurpP --minimal linux-3.0/include/linux/vserver/cvirt_cmd.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/cvirt_cmd.h
13691 --- linux-3.0/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
13692 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/cvirt_cmd.h 2011-06-10 22:11:24.000000000 +0200
13694 +#ifndef _VX_CVIRT_CMD_H
13695 +#define _VX_CVIRT_CMD_H
13698 +/* virtual host info name commands */
13700 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
13701 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
13703 +struct vcmd_vhi_name_v0 {
13709 +enum vhi_name_field {
13710 + VHIN_CONTEXT = 0,
13722 +#include <linux/compiler.h>
13724 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
13725 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
13727 +#endif /* __KERNEL__ */
13729 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
13731 +struct vcmd_virt_stat_v0 {
13734 + uint32_t nr_threads;
13735 + uint32_t nr_running;
13736 + uint32_t nr_uninterruptible;
13737 + uint32_t nr_onhold;
13738 + uint32_t nr_forks;
13739 + uint32_t load[3];
13743 +extern int vc_virt_stat(struct vx_info *, void __user *);
13745 +#endif /* __KERNEL__ */
13746 +#endif /* _VX_CVIRT_CMD_H */
13747 diff -NurpP --minimal linux-3.0/include/linux/vserver/cvirt_def.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/cvirt_def.h
13748 --- linux-3.0/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
13749 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/cvirt_def.h 2011-06-10 22:11:24.000000000 +0200
13751 +#ifndef _VX_CVIRT_DEF_H
13752 +#define _VX_CVIRT_DEF_H
13754 +#include <linux/jiffies.h>
13755 +#include <linux/spinlock.h>
13756 +#include <linux/wait.h>
13757 +#include <linux/time.h>
13758 +#include <asm/atomic.h>
13761 +struct _vx_usage_stat {
13765 + uint64_t softirq;
13771 +struct _vx_syslog {
13772 + wait_queue_head_t log_wait;
13773 + spinlock_t logbuf_lock; /* lock for the log buffer */
13775 + unsigned long log_start; /* next char to be read by syslog() */
13776 + unsigned long con_start; /* next char to be sent to consoles */
13777 + unsigned long log_end; /* most-recently-written-char + 1 */
13778 + unsigned long logged_chars; /* #chars since last read+clear operation */
13780 + char log_buf[1024];
13784 +/* context sub struct */
13786 +struct _vx_cvirt {
13787 + atomic_t nr_threads; /* number of current threads */
13788 + atomic_t nr_running; /* number of running threads */
13789 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
13791 + atomic_t nr_onhold; /* processes on hold */
13792 + uint32_t onhold_last; /* jiffies when put on hold */
13794 + struct timespec bias_ts; /* time offset to the host */
13795 + struct timespec bias_idle;
13796 + struct timespec bias_uptime; /* context creation point */
13797 + uint64_t bias_clock; /* offset in clock_t */
13799 + spinlock_t load_lock; /* lock for the load averages */
13800 + atomic_t load_updates; /* nr of load updates done so far */
13801 + uint32_t load_last; /* last time load was calculated */
13802 + uint32_t load[3]; /* load averages 1,5,15 */
13804 + atomic_t total_forks; /* number of forks so far */
13806 + struct _vx_syslog syslog;
13809 +struct _vx_cvirt_pc {
13810 + struct _vx_usage_stat cpustat;
13814 +#ifdef CONFIG_VSERVER_DEBUG
13816 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
13818 + printk("\t_vx_cvirt:\n");
13819 + printk("\t threads: %4d, %4d, %4d, %4d\n",
13820 + atomic_read(&cvirt->nr_threads),
13821 + atomic_read(&cvirt->nr_running),
13822 + atomic_read(&cvirt->nr_uninterruptible),
13823 + atomic_read(&cvirt->nr_onhold));
13824 + /* add rest here */
13825 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
13830 +#endif /* _VX_CVIRT_DEF_H */
13831 diff -NurpP --minimal linux-3.0/include/linux/vserver/debug.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/debug.h
13832 --- linux-3.0/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
13833 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/debug.h 2011-06-10 22:11:24.000000000 +0200
13835 +#ifndef _VX_DEBUG_H
13836 +#define _VX_DEBUG_H
13839 +#define VXD_CBIT(n, m) (vx_debug_ ## n & (1 << (m)))
13840 +#define VXD_CMIN(n, m) (vx_debug_ ## n > (m))
13841 +#define VXD_MASK(n, m) (vx_debug_ ## n & (m))
13843 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
13844 + imajor((d)->bd_inode), iminor((d)->bd_inode)
13845 +#define VXF_DEV "%p[%lu,%d:%d]"
13847 +#if defined(CONFIG_QUOTES_UTF8)
13848 +#define VS_Q_LQM "\xc2\xbb"
13849 +#define VS_Q_RQM "\xc2\xab"
13850 +#elif defined(CONFIG_QUOTES_ASCII)
13851 +#define VS_Q_LQM "\x27"
13852 +#define VS_Q_RQM "\x27"
13854 +#define VS_Q_LQM "\xbb"
13855 +#define VS_Q_RQM "\xab"
13858 +#define VS_Q(f) VS_Q_LQM f VS_Q_RQM
13861 +#define vxd_path(p) \
13862 + ({ static char _buffer[PATH_MAX]; \
13863 + d_path(p, _buffer, sizeof(_buffer)); })
13865 +#define vxd_cond_path(n) \
13866 + ((n) ? vxd_path(&(n)->path) : "<null>" )
13869 +#ifdef CONFIG_VSERVER_DEBUG
13871 +extern unsigned int vx_debug_switch;
13872 +extern unsigned int vx_debug_xid;
13873 +extern unsigned int vx_debug_nid;
13874 +extern unsigned int vx_debug_tag;
13875 +extern unsigned int vx_debug_net;
13876 +extern unsigned int vx_debug_limit;
13877 +extern unsigned int vx_debug_cres;
13878 +extern unsigned int vx_debug_dlim;
13879 +extern unsigned int vx_debug_quota;
13880 +extern unsigned int vx_debug_cvirt;
13881 +extern unsigned int vx_debug_space;
13882 +extern unsigned int vx_debug_misc;
13885 +#define VX_LOGLEVEL "vxD: "
13886 +#define VX_PROC_FMT "%p: "
13887 +#define VX_PROCESS current
13889 +#define vxdprintk(c, f, x...) \
13892 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
13893 + VX_PROCESS , ##x); \
13896 +#define vxlprintk(c, f, x...) \
13899 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
13902 +#define vxfprintk(c, f, x...) \
13905 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
13911 +void dump_vx_info(struct vx_info *, int);
13912 +void dump_vx_info_inactive(int);
13914 +#else /* CONFIG_VSERVER_DEBUG */
13916 +#define vx_debug_switch 0
13917 +#define vx_debug_xid 0
13918 +#define vx_debug_nid 0
13919 +#define vx_debug_tag 0
13920 +#define vx_debug_net 0
13921 +#define vx_debug_limit 0
13922 +#define vx_debug_cres 0
13923 +#define vx_debug_dlim 0
13924 +#define vx_debug_cvirt 0
13926 +#define vxdprintk(x...) do { } while (0)
13927 +#define vxlprintk(x...) do { } while (0)
13928 +#define vxfprintk(x...) do { } while (0)
13930 +#endif /* CONFIG_VSERVER_DEBUG */
13933 +#ifdef CONFIG_VSERVER_WARN
13935 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
13936 +#define VX_WARN_TASK "[" VS_Q("%s") ",%u:#%u|%u|%u] "
13937 +#define VX_WARN_XID "[xid #%u] "
13938 +#define VX_WARN_NID "[nid #%u] "
13939 +#define VX_WARN_TAG "[tag #%u] "
13941 +#define vxwprintk(c, f, x...) \
13944 + printk(VX_WARNLEVEL f "\n", ##x); \
13947 +#else /* CONFIG_VSERVER_WARN */
13949 +#define vxwprintk(x...) do { } while (0)
13951 +#endif /* CONFIG_VSERVER_WARN */
13953 +#define vxwprintk_task(c, f, x...) \
13954 + vxwprintk(c, VX_WARN_TASK f, \
13955 + current->comm, current->pid, \
13956 + current->xid, current->nid, current->tag, ##x)
13957 +#define vxwprintk_xid(c, f, x...) \
13958 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
13959 +#define vxwprintk_nid(c, f, x...) \
13960 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
13961 +#define vxwprintk_tag(c, f, x...) \
13962 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
13964 +#ifdef CONFIG_VSERVER_DEBUG
13965 +#define vxd_assert_lock(l) assert_spin_locked(l)
13966 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
13967 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
13969 +#define vxd_assert_lock(l) do { } while (0)
13970 +#define vxd_assert(c, f, x...) do { } while (0)
13974 +#endif /* _VX_DEBUG_H */
13975 diff -NurpP --minimal linux-3.0/include/linux/vserver/debug_cmd.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/debug_cmd.h
13976 --- linux-3.0/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
13977 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/debug_cmd.h 2011-06-10 22:11:24.000000000 +0200
13979 +#ifndef _VX_DEBUG_CMD_H
13980 +#define _VX_DEBUG_CMD_H
13983 +/* debug commands */
13985 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
13987 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
13988 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
13990 +struct vcmd_read_history_v0 {
13993 + char __user *data;
13996 +struct vcmd_read_monitor_v0 {
13999 + char __user *data;
14005 +#ifdef CONFIG_COMPAT
14007 +#include <asm/compat.h>
14009 +struct vcmd_read_history_v0_x32 {
14012 + compat_uptr_t data_ptr;
14015 +struct vcmd_read_monitor_v0_x32 {
14018 + compat_uptr_t data_ptr;
14021 +#endif /* CONFIG_COMPAT */
14023 +extern int vc_dump_history(uint32_t);
14025 +extern int vc_read_history(uint32_t, void __user *);
14026 +extern int vc_read_monitor(uint32_t, void __user *);
14028 +#ifdef CONFIG_COMPAT
14030 +extern int vc_read_history_x32(uint32_t, void __user *);
14031 +extern int vc_read_monitor_x32(uint32_t, void __user *);
14033 +#endif /* CONFIG_COMPAT */
14035 +#endif /* __KERNEL__ */
14036 +#endif /* _VX_DEBUG_CMD_H */
14037 diff -NurpP --minimal linux-3.0/include/linux/vserver/device.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/device.h
14038 --- linux-3.0/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
14039 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/device.h 2011-06-10 22:11:24.000000000 +0200
14041 +#ifndef _VX_DEVICE_H
14042 +#define _VX_DEVICE_H
14045 +#define DATTR_CREATE 0x00000001
14046 +#define DATTR_OPEN 0x00000002
14048 +#define DATTR_REMAP 0x00000010
14050 +#define DATTR_MASK 0x00000013
14053 +#else /* _VX_DEVICE_H */
14054 +#warning duplicate inclusion
14055 +#endif /* _VX_DEVICE_H */
14056 diff -NurpP --minimal linux-3.0/include/linux/vserver/device_cmd.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/device_cmd.h
14057 --- linux-3.0/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
14058 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/device_cmd.h 2011-06-10 22:11:24.000000000 +0200
14060 +#ifndef _VX_DEVICE_CMD_H
14061 +#define _VX_DEVICE_CMD_H
14064 +/* device vserver commands */
14066 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
14067 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
14069 +struct vcmd_set_mapping_v0 {
14070 + const char __user *device;
14071 + const char __user *target;
14078 +#ifdef CONFIG_COMPAT
14080 +#include <asm/compat.h>
14082 +struct vcmd_set_mapping_v0_x32 {
14083 + compat_uptr_t device_ptr;
14084 + compat_uptr_t target_ptr;
14088 +#endif /* CONFIG_COMPAT */
14090 +#include <linux/compiler.h>
14092 +extern int vc_set_mapping(struct vx_info *, void __user *);
14093 +extern int vc_unset_mapping(struct vx_info *, void __user *);
14095 +#ifdef CONFIG_COMPAT
14097 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
14098 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
14100 +#endif /* CONFIG_COMPAT */
14102 +#endif /* __KERNEL__ */
14103 +#endif /* _VX_DEVICE_CMD_H */
14104 diff -NurpP --minimal linux-3.0/include/linux/vserver/device_def.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/device_def.h
14105 --- linux-3.0/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
14106 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/device_def.h 2011-06-10 22:11:24.000000000 +0200
14108 +#ifndef _VX_DEVICE_DEF_H
14109 +#define _VX_DEVICE_DEF_H
14111 +#include <linux/types.h>
14113 +struct vx_dmap_target {
14118 +struct _vx_device {
14119 +#ifdef CONFIG_VSERVER_DEVICE
14120 + struct vx_dmap_target targets[2];
14124 +#endif /* _VX_DEVICE_DEF_H */
14125 diff -NurpP --minimal linux-3.0/include/linux/vserver/dlimit.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/dlimit.h
14126 --- linux-3.0/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
14127 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/dlimit.h 2011-06-10 22:11:24.000000000 +0200
14129 +#ifndef _VX_DLIMIT_H
14130 +#define _VX_DLIMIT_H
14132 +#include "switch.h"
14137 +/* keep in sync with CDLIM_INFINITY */
14139 +#define DLIM_INFINITY (~0ULL)
14141 +#include <linux/spinlock.h>
14142 +#include <linux/rcupdate.h>
14144 +struct super_block;
14147 + struct hlist_node dl_hlist; /* linked list of contexts */
14148 + struct rcu_head dl_rcu; /* the rcu head */
14149 + tag_t dl_tag; /* context tag */
14150 + atomic_t dl_usecnt; /* usage count */
14151 + atomic_t dl_refcnt; /* reference count */
14153 + struct super_block *dl_sb; /* associated superblock */
14155 + spinlock_t dl_lock; /* protect the values */
14157 + unsigned long long dl_space_used; /* used space in bytes */
14158 + unsigned long long dl_space_total; /* maximum space in bytes */
14159 + unsigned long dl_inodes_used; /* used inodes */
14160 + unsigned long dl_inodes_total; /* maximum inodes */
14162 + unsigned int dl_nrlmult; /* non root limit mult */
14167 +extern void rcu_free_dl_info(struct rcu_head *);
14168 +extern void unhash_dl_info(struct dl_info *);
14170 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
14175 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
14177 +typedef uint64_t dlsize_t;
14179 +#endif /* __KERNEL__ */
14180 +#else /* _VX_DLIMIT_H */
14181 +#warning duplicate inclusion
14182 +#endif /* _VX_DLIMIT_H */
14183 diff -NurpP --minimal linux-3.0/include/linux/vserver/dlimit_cmd.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/dlimit_cmd.h
14184 --- linux-3.0/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
14185 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/dlimit_cmd.h 2011-06-10 22:11:24.000000000 +0200
14187 +#ifndef _VX_DLIMIT_CMD_H
14188 +#define _VX_DLIMIT_CMD_H
14191 +/* dlimit vserver commands */
14193 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
14194 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
14196 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
14197 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
14199 +struct vcmd_ctx_dlimit_base_v0 {
14200 + const char __user *name;
14204 +struct vcmd_ctx_dlimit_v0 {
14205 + const char __user *name;
14206 + uint32_t space_used; /* used space in kbytes */
14207 + uint32_t space_total; /* maximum space in kbytes */
14208 + uint32_t inodes_used; /* used inodes */
14209 + uint32_t inodes_total; /* maximum inodes */
14210 + uint32_t reserved; /* reserved for root in % */
14214 +#define CDLIM_UNSET ((uint32_t)0UL)
14215 +#define CDLIM_INFINITY ((uint32_t)~0UL)
14216 +#define CDLIM_KEEP ((uint32_t)~1UL)
14218 +#define DLIME_UNIT 0
14219 +#define DLIME_KILO 1
14220 +#define DLIME_MEGA 2
14221 +#define DLIME_GIGA 3
14223 +#define DLIMF_SHIFT 0x10
14225 +#define DLIMS_USED 0
14226 +#define DLIMS_TOTAL 2
14229 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
14231 + int exp = (flags & DLIMF_SHIFT) ?
14232 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
14233 + return ((uint64_t)val) << (10 * exp);
14237 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
14241 + if (*flags & DLIMF_SHIFT) {
14242 + while (val > (1LL << 32) && (exp < 3)) {
14246 + *flags &= ~(DLIME_GIGA << shift);
14247 + *flags |= exp << shift;
14255 +#ifdef CONFIG_COMPAT
14257 +#include <asm/compat.h>
14259 +struct vcmd_ctx_dlimit_base_v0_x32 {
14260 + compat_uptr_t name_ptr;
14264 +struct vcmd_ctx_dlimit_v0_x32 {
14265 + compat_uptr_t name_ptr;
14266 + uint32_t space_used; /* used space in kbytes */
14267 + uint32_t space_total; /* maximum space in kbytes */
14268 + uint32_t inodes_used; /* used inodes */
14269 + uint32_t inodes_total; /* maximum inodes */
14270 + uint32_t reserved; /* reserved for root in % */
14274 +#endif /* CONFIG_COMPAT */
14276 +#include <linux/compiler.h>
14278 +extern int vc_add_dlimit(uint32_t, void __user *);
14279 +extern int vc_rem_dlimit(uint32_t, void __user *);
14281 +extern int vc_set_dlimit(uint32_t, void __user *);
14282 +extern int vc_get_dlimit(uint32_t, void __user *);
14284 +#ifdef CONFIG_COMPAT
14286 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
14287 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
14289 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
14290 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
14292 +#endif /* CONFIG_COMPAT */
14294 +#endif /* __KERNEL__ */
14295 +#endif /* _VX_DLIMIT_CMD_H */
14296 diff -NurpP --minimal linux-3.0/include/linux/vserver/global.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/global.h
14297 --- linux-3.0/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
14298 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/global.h 2011-06-10 22:11:24.000000000 +0200
14300 +#ifndef _VX_GLOBAL_H
14301 +#define _VX_GLOBAL_H
14304 +extern atomic_t vx_global_ctotal;
14305 +extern atomic_t vx_global_cactive;
14307 +extern atomic_t nx_global_ctotal;
14308 +extern atomic_t nx_global_cactive;
14310 +extern atomic_t vs_global_nsproxy;
14311 +extern atomic_t vs_global_fs;
14312 +extern atomic_t vs_global_mnt_ns;
14313 +extern atomic_t vs_global_uts_ns;
14314 +extern atomic_t vs_global_user_ns;
14315 +extern atomic_t vs_global_pid_ns;
14318 +#endif /* _VX_GLOBAL_H */
14319 diff -NurpP --minimal linux-3.0/include/linux/vserver/history.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/history.h
14320 --- linux-3.0/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
14321 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/history.h 2011-06-10 22:11:24.000000000 +0200
14323 +#ifndef _VX_HISTORY_H
14324 +#define _VX_HISTORY_H
14329 + VXH_THROW_OOPS = 1,
14333 + VXH_INIT_VX_INFO,
14336 + VXH_CLAIM_VX_INFO,
14337 + VXH_RELEASE_VX_INFO,
14338 + VXH_ALLOC_VX_INFO,
14339 + VXH_DEALLOC_VX_INFO,
14340 + VXH_HASH_VX_INFO,
14341 + VXH_UNHASH_VX_INFO,
14343 + VXH_LOOKUP_VX_INFO,
14344 + VXH_CREATE_VX_INFO,
14347 +struct _vxhe_vxi {
14348 + struct vx_info *ptr;
14354 +struct _vxhe_set_clr {
14358 +struct _vxhe_loc_lookup {
14362 +struct _vx_hist_entry {
14364 + unsigned short seq;
14365 + unsigned short type;
14366 + struct _vxhe_vxi vxi;
14368 + struct _vxhe_set_clr sc;
14369 + struct _vxhe_loc_lookup ll;
14373 +#ifdef CONFIG_VSERVER_HISTORY
14375 +extern unsigned volatile int vxh_active;
14377 +struct _vx_hist_entry *vxh_advance(void *loc);
14381 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
14383 + entry->vxi.ptr = vxi;
14385 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
14386 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
14387 + entry->vxi.xid = vxi->vx_id;
14392 +#define __HERE__ current_text_addr()
14394 +#define __VXH_BODY(__type, __data, __here) \
14395 + struct _vx_hist_entry *entry; \
14397 + preempt_disable(); \
14398 + entry = vxh_advance(__here); \
14400 + entry->type = __type; \
14401 + preempt_enable();
14404 + /* pass vxi only */
14406 +#define __VXH_SMPL \
14407 + __vxh_copy_vxi(entry, vxi)
14410 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
14412 + __VXH_BODY(__type, __VXH_SMPL, __here)
14415 + /* pass vxi and data (void *) */
14417 +#define __VXH_DATA \
14418 + __vxh_copy_vxi(entry, vxi); \
14419 + entry->sc.data = data
14422 +void __vxh_data(struct vx_info *vxi, void *data,
14423 + int __type, void *__here)
14425 + __VXH_BODY(__type, __VXH_DATA, __here)
14428 + /* pass vxi and arg (long) */
14430 +#define __VXH_LONG \
14431 + __vxh_copy_vxi(entry, vxi); \
14432 + entry->ll.arg = arg
14435 +void __vxh_long(struct vx_info *vxi, long arg,
14436 + int __type, void *__here)
14438 + __VXH_BODY(__type, __VXH_LONG, __here)
14443 +void __vxh_throw_oops(void *__here)
14445 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
14446 + /* prevent further acquisition */
14451 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
14453 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
14454 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
14456 +#define __vxh_init_vx_info(v, d, h) \
14457 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
14458 +#define __vxh_set_vx_info(v, d, h) \
14459 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
14460 +#define __vxh_clr_vx_info(v, d, h) \
14461 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
14463 +#define __vxh_claim_vx_info(v, d, h) \
14464 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
14465 +#define __vxh_release_vx_info(v, d, h) \
14466 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
14468 +#define vxh_alloc_vx_info(v) \
14469 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
14470 +#define vxh_dealloc_vx_info(v) \
14471 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
14473 +#define vxh_hash_vx_info(v) \
14474 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
14475 +#define vxh_unhash_vx_info(v) \
14476 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
14478 +#define vxh_loc_vx_info(v, l) \
14479 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
14480 +#define vxh_lookup_vx_info(v, l) \
14481 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
14482 +#define vxh_create_vx_info(v, l) \
14483 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
14485 +extern void vxh_dump_history(void);
14488 +#else /* CONFIG_VSERVER_HISTORY */
14490 +#define __HERE__ 0
14492 +#define vxh_throw_oops() do { } while (0)
14494 +#define __vxh_get_vx_info(v, h) do { } while (0)
14495 +#define __vxh_put_vx_info(v, h) do { } while (0)
14497 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
14498 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
14499 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
14501 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
14502 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
14504 +#define vxh_alloc_vx_info(v) do { } while (0)
14505 +#define vxh_dealloc_vx_info(v) do { } while (0)
14507 +#define vxh_hash_vx_info(v) do { } while (0)
14508 +#define vxh_unhash_vx_info(v) do { } while (0)
14510 +#define vxh_loc_vx_info(v, l) do { } while (0)
14511 +#define vxh_lookup_vx_info(v, l) do { } while (0)
14512 +#define vxh_create_vx_info(v, l) do { } while (0)
14514 +#define vxh_dump_history() do { } while (0)
14517 +#endif /* CONFIG_VSERVER_HISTORY */
14519 +#endif /* _VX_HISTORY_H */
14520 diff -NurpP --minimal linux-3.0/include/linux/vserver/inode.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/inode.h
14521 --- linux-3.0/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
14522 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/inode.h 2011-06-10 22:11:24.000000000 +0200
14524 +#ifndef _VX_INODE_H
14525 +#define _VX_INODE_H
14528 +#define IATTR_TAG 0x01000000
14530 +#define IATTR_ADMIN 0x00000001
14531 +#define IATTR_WATCH 0x00000002
14532 +#define IATTR_HIDE 0x00000004
14533 +#define IATTR_FLAGS 0x00000007
14535 +#define IATTR_BARRIER 0x00010000
14536 +#define IATTR_IXUNLINK 0x00020000
14537 +#define IATTR_IMMUTABLE 0x00040000
14538 +#define IATTR_COW 0x00080000
14543 +#ifdef CONFIG_VSERVER_PROC_SECURE
14544 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
14545 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
14547 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
14548 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
14551 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
14553 +#endif /* __KERNEL__ */
14555 +/* inode ioctls */
14557 +#define FIOC_GETXFLG _IOR('x', 5, long)
14558 +#define FIOC_SETXFLG _IOW('x', 6, long)
14560 +#else /* _VX_INODE_H */
14561 +#warning duplicate inclusion
14562 +#endif /* _VX_INODE_H */
14563 diff -NurpP --minimal linux-3.0/include/linux/vserver/inode_cmd.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/inode_cmd.h
14564 --- linux-3.0/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
14565 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/inode_cmd.h 2011-06-10 22:11:24.000000000 +0200
14567 +#ifndef _VX_INODE_CMD_H
14568 +#define _VX_INODE_CMD_H
14571 +/* inode vserver commands */
14573 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
14574 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
14576 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
14577 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
14579 +struct vcmd_ctx_iattr_v1 {
14580 + const char __user *name;
14586 +struct vcmd_ctx_fiattr_v0 {
14596 +#ifdef CONFIG_COMPAT
14598 +#include <asm/compat.h>
14600 +struct vcmd_ctx_iattr_v1_x32 {
14601 + compat_uptr_t name_ptr;
14607 +#endif /* CONFIG_COMPAT */
14609 +#include <linux/compiler.h>
14611 +extern int vc_get_iattr(void __user *);
14612 +extern int vc_set_iattr(void __user *);
14614 +extern int vc_fget_iattr(uint32_t, void __user *);
14615 +extern int vc_fset_iattr(uint32_t, void __user *);
14617 +#ifdef CONFIG_COMPAT
14619 +extern int vc_get_iattr_x32(void __user *);
14620 +extern int vc_set_iattr_x32(void __user *);
14622 +#endif /* CONFIG_COMPAT */
14624 +#endif /* __KERNEL__ */
14625 +#endif /* _VX_INODE_CMD_H */
14626 diff -NurpP --minimal linux-3.0/include/linux/vserver/limit.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/limit.h
14627 --- linux-3.0/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
14628 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/limit.h 2011-06-10 22:11:24.000000000 +0200
14630 +#ifndef _VX_LIMIT_H
14631 +#define _VX_LIMIT_H
14633 +#define VLIMIT_NSOCK 16
14634 +#define VLIMIT_OPENFD 17
14635 +#define VLIMIT_ANON 18
14636 +#define VLIMIT_SHMEM 19
14637 +#define VLIMIT_SEMARY 20
14638 +#define VLIMIT_NSEMS 21
14639 +#define VLIMIT_DENTRY 22
14640 +#define VLIMIT_MAPPED 23
14645 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
14647 +/* keep in sync with CRLIM_INFINITY */
14649 +#define VLIM_INFINITY (~0ULL)
14651 +#include <asm/atomic.h>
14652 +#include <asm/resource.h>
14654 +#ifndef RLIM_INFINITY
14655 +#warning RLIM_INFINITY is undefined
14658 +#define __rlim_val(l, r, v) ((l)->res[r].v)
14660 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
14661 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
14663 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
14664 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
14665 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
14667 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
14668 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
14670 +typedef atomic_long_t rlim_atomic_t;
14671 +typedef unsigned long rlim_t;
14673 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
14674 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
14675 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
14676 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
14677 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
14678 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
14681 +#if (RLIM_INFINITY == VLIM_INFINITY)
14682 +#define VX_VLIM(r) ((long long)(long)(r))
14683 +#define VX_RLIM(v) ((rlim_t)(v))
14685 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
14686 + ? VLIM_INFINITY : (long long)(r))
14687 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
14688 + ? RLIM_INFINITY : (rlim_t)(v))
14693 +void vx_vsi_meminfo(struct sysinfo *);
14694 +void vx_vsi_swapinfo(struct sysinfo *);
14695 +long vx_vsi_cached(struct sysinfo *);
14697 +#define NUM_LIMITS 24
14699 +#endif /* __KERNEL__ */
14700 +#endif /* _VX_LIMIT_H */
14701 diff -NurpP --minimal linux-3.0/include/linux/vserver/limit_cmd.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/limit_cmd.h
14702 --- linux-3.0/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
14703 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/limit_cmd.h 2011-06-10 22:11:24.000000000 +0200
14705 +#ifndef _VX_LIMIT_CMD_H
14706 +#define _VX_LIMIT_CMD_H
14709 +/* rlimit vserver commands */
14711 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
14712 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
14713 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
14714 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
14715 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
14717 +struct vcmd_ctx_rlimit_v0 {
14719 + uint64_t minimum;
14720 + uint64_t softlimit;
14721 + uint64_t maximum;
14724 +struct vcmd_ctx_rlimit_mask_v0 {
14725 + uint32_t minimum;
14726 + uint32_t softlimit;
14727 + uint32_t maximum;
14730 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
14732 +struct vcmd_rlimit_stat_v0 {
14736 + uint64_t minimum;
14737 + uint64_t maximum;
14740 +#define CRLIM_UNSET (0ULL)
14741 +#define CRLIM_INFINITY (~0ULL)
14742 +#define CRLIM_KEEP (~1ULL)
14746 +#ifdef CONFIG_IA32_EMULATION
14748 +struct vcmd_ctx_rlimit_v0_x32 {
14750 + uint64_t minimum;
14751 + uint64_t softlimit;
14752 + uint64_t maximum;
14753 +} __attribute__ ((packed));
14755 +#endif /* CONFIG_IA32_EMULATION */
14757 +#include <linux/compiler.h>
14759 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
14760 +extern int vc_get_rlimit(struct vx_info *, void __user *);
14761 +extern int vc_set_rlimit(struct vx_info *, void __user *);
14762 +extern int vc_reset_hits(struct vx_info *, void __user *);
14763 +extern int vc_reset_minmax(struct vx_info *, void __user *);
14765 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
14767 +#ifdef CONFIG_IA32_EMULATION
14769 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
14770 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
14772 +#endif /* CONFIG_IA32_EMULATION */
14774 +#endif /* __KERNEL__ */
14775 +#endif /* _VX_LIMIT_CMD_H */
14776 diff -NurpP --minimal linux-3.0/include/linux/vserver/limit_def.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/limit_def.h
14777 --- linux-3.0/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
14778 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/limit_def.h 2011-06-10 22:11:24.000000000 +0200
14780 +#ifndef _VX_LIMIT_DEF_H
14781 +#define _VX_LIMIT_DEF_H
14783 +#include <asm/atomic.h>
14784 +#include <asm/resource.h>
14786 +#include "limit.h"
14789 +struct _vx_res_limit {
14790 + rlim_t soft; /* Context soft limit */
14791 + rlim_t hard; /* Context hard limit */
14793 + rlim_atomic_t rcur; /* Current value */
14794 + rlim_t rmin; /* Context minimum */
14795 + rlim_t rmax; /* Context maximum */
14797 + atomic_t lhit; /* Limit hits */
14800 +/* context sub struct */
14802 +struct _vx_limit {
14803 + struct _vx_res_limit res[NUM_LIMITS];
14806 +#ifdef CONFIG_VSERVER_DEBUG
14808 +static inline void __dump_vx_limit(struct _vx_limit *limit)
14812 + printk("\t_vx_limit:");
14813 + for (i = 0; i < NUM_LIMITS; i++) {
14814 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
14815 + i, (unsigned long)__rlim_get(limit, i),
14816 + (unsigned long)__rlim_rmin(limit, i),
14817 + (unsigned long)__rlim_rmax(limit, i),
14818 + (long)__rlim_soft(limit, i),
14819 + (long)__rlim_hard(limit, i),
14820 + atomic_read(&__rlim_lhit(limit, i)));
14826 +#endif /* _VX_LIMIT_DEF_H */
14827 diff -NurpP --minimal linux-3.0/include/linux/vserver/limit_int.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/limit_int.h
14828 --- linux-3.0/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
14829 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/limit_int.h 2011-06-10 22:11:24.000000000 +0200
14831 +#ifndef _VX_LIMIT_INT_H
14832 +#define _VX_LIMIT_INT_H
14834 +#include "context.h"
14838 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
14839 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
14841 +extern const char *vlimit_name[NUM_LIMITS];
14843 +static inline void __vx_acc_cres(struct vx_info *vxi,
14844 + int res, int dir, void *_data, char *_file, int _line)
14846 + if (VXD_RCRES_COND(res))
14847 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
14848 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
14849 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
14850 + (dir > 0) ? "++" : "--", _data, _file, _line);
14855 + __rlim_inc(&vxi->limit, res);
14857 + __rlim_dec(&vxi->limit, res);
14860 +static inline void __vx_add_cres(struct vx_info *vxi,
14861 + int res, int amount, void *_data, char *_file, int _line)
14863 + if (VXD_RCRES_COND(res))
14864 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
14865 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
14866 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
14867 + amount, _data, _file, _line);
14872 + __rlim_add(&vxi->limit, res, amount);
14876 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
14878 + int cond = (value > __rlim_rmax(limit, res));
14881 + __rlim_rmax(limit, res) = value;
14886 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
14888 + int cond = (value < __rlim_rmin(limit, res));
14891 + __rlim_rmin(limit, res) = value;
14896 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
14898 + if (!__vx_cres_adjust_max(limit, res, value))
14899 + __vx_cres_adjust_min(limit, res, value);
14904 + +1 ... no limit hit
14905 + -1 ... over soft limit
14906 + 0 ... over hard limit */
14908 +static inline int __vx_cres_avail(struct vx_info *vxi,
14909 + int res, int num, char *_file, int _line)
14911 + struct _vx_limit *limit;
14914 + if (VXD_RLIMIT_COND(res))
14915 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
14916 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
14917 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
14918 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
14919 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
14920 + num, _file, _line);
14924 + limit = &vxi->limit;
14925 + value = __rlim_get(limit, res);
14927 + if (!__vx_cres_adjust_max(limit, res, value))
14928 + __vx_cres_adjust_min(limit, res, value);
14933 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
14935 + if (value + num <= __rlim_soft(limit, res))
14938 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
14940 + if (value + num <= __rlim_hard(limit, res))
14943 + __rlim_hit(limit, res);
14948 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
14951 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
14953 + rlim_t value, sum = 0;
14956 + while ((res = *array++)) {
14957 + value = __rlim_get(limit, res);
14958 + __vx_cres_fixup(limit, res, value);
14965 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
14967 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
14968 + int res = *array;
14970 + if (value == __rlim_get(limit, res))
14973 + __rlim_set(limit, res, value);
14974 + /* now adjust min/max */
14975 + if (!__vx_cres_adjust_max(limit, res, value))
14976 + __vx_cres_adjust_min(limit, res, value);
14981 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
14982 + const int *array, int num, char *_file, int _line)
14984 + struct _vx_limit *limit;
14985 + rlim_t value = 0;
14993 + limit = &vxi->limit;
14995 + value = __vx_cres_array_sum(limit, array + 1);
14997 + __rlim_set(limit, res, value);
14998 + __vx_cres_fixup(limit, res, value);
15000 + return __vx_cres_avail(vxi, res, num, _file, _line);
15004 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
15009 + /* complex resources first */
15010 + if ((id < 0) || (id == RLIMIT_RSS))
15011 + __vx_cres_array_fixup(limit, VLA_RSS);
15013 + for (res = 0; res < NUM_LIMITS; res++) {
15014 + if ((id > 0) && (res != id))
15017 + value = __rlim_get(limit, res);
15018 + __vx_cres_fixup(limit, res, value);
15020 + /* not supposed to happen, maybe warn? */
15021 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
15022 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
15027 +#endif /* __KERNEL__ */
15028 +#endif /* _VX_LIMIT_INT_H */
15029 diff -NurpP --minimal linux-3.0/include/linux/vserver/monitor.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/monitor.h
15030 --- linux-3.0/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
15031 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/monitor.h 2011-06-10 22:11:24.000000000 +0200
15033 +#ifndef _VX_MONITOR_H
15034 +#define _VX_MONITOR_H
15036 +#include <linux/types.h>
15043 + VXM_UPDATE = 0x20,
15047 + VXM_RQINFO_1 = 0x24,
15050 + VXM_ACTIVATE = 0x40,
15057 + VXM_MIGRATE = 0x48,
15060 + /* all other bits are flags */
15061 + VXM_SCHED = 0x80,
15064 +struct _vxm_update_1 {
15065 + uint32_t tokens_max;
15066 + uint32_t fill_rate;
15067 + uint32_t interval;
15070 +struct _vxm_update_2 {
15071 + uint32_t tokens_min;
15072 + uint32_t fill_rate;
15073 + uint32_t interval;
15076 +struct _vxm_rqinfo_1 {
15077 + uint16_t running;
15081 + uint32_t idle_tokens;
15084 +struct _vxm_rqinfo_2 {
15085 + uint32_t norm_time;
15086 + uint32_t idle_time;
15087 + uint32_t idle_skip;
15090 +struct _vxm_sched {
15092 + uint32_t norm_time;
15093 + uint32_t idle_time;
15096 +struct _vxm_task {
15101 +struct _vxm_event {
15110 + struct _vxm_task tsk;
15114 +struct _vx_mon_entry {
15118 + struct _vxm_event ev;
15119 + struct _vxm_sched sd;
15120 + struct _vxm_update_1 u1;
15121 + struct _vxm_update_2 u2;
15122 + struct _vxm_rqinfo_1 q1;
15123 + struct _vxm_rqinfo_2 q2;
15128 +#endif /* _VX_MONITOR_H */
15129 diff -NurpP --minimal linux-3.0/include/linux/vserver/network.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/network.h
15130 --- linux-3.0/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
15131 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/network.h 2011-06-10 22:11:24.000000000 +0200
15133 +#ifndef _VX_NETWORK_H
15134 +#define _VX_NETWORK_H
15136 +#include <linux/types.h>
15139 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
15142 +/* network flags */
15144 +#define NXF_INFO_PRIVATE 0x00000008
15146 +#define NXF_SINGLE_IP 0x00000100
15147 +#define NXF_LBACK_REMAP 0x00000200
15148 +#define NXF_LBACK_ALLOW 0x00000400
15150 +#define NXF_HIDE_NETIF 0x02000000
15151 +#define NXF_HIDE_LBACK 0x04000000
15153 +#define NXF_STATE_SETUP (1ULL << 32)
15154 +#define NXF_STATE_ADMIN (1ULL << 34)
15156 +#define NXF_SC_HELPER (1ULL << 36)
15157 +#define NXF_PERSISTENT (1ULL << 38)
15159 +#define NXF_ONE_TIME (0x0005ULL << 32)
15162 +#define NXF_INIT_SET (__nxf_init_set())
15164 +static inline uint64_t __nxf_init_set(void) {
15165 + return NXF_STATE_ADMIN
15166 +#ifdef CONFIG_VSERVER_AUTO_LBACK
15167 + | NXF_LBACK_REMAP
15170 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
15173 + | NXF_HIDE_NETIF;
15177 +/* network caps */
15179 +#define NXC_TUN_CREATE 0x00000001
15181 +#define NXC_RAW_ICMP 0x00000100
15184 +/* address types */
15186 +#define NXA_TYPE_IPV4 0x0001
15187 +#define NXA_TYPE_IPV6 0x0002
15189 +#define NXA_TYPE_NONE 0x0000
15190 +#define NXA_TYPE_ANY 0x00FF
15192 +#define NXA_TYPE_ADDR 0x0010
15193 +#define NXA_TYPE_MASK 0x0020
15194 +#define NXA_TYPE_RANGE 0x0040
15196 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
15198 +#define NXA_MOD_BCAST 0x0100
15199 +#define NXA_MOD_LBACK 0x0200
15201 +#define NXA_LOOPBACK 0x1000
15203 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
15204 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
15208 +#include <linux/list.h>
15209 +#include <linux/spinlock.h>
15210 +#include <linux/rcupdate.h>
15211 +#include <linux/in.h>
15212 +#include <linux/in6.h>
15213 +#include <asm/atomic.h>
15215 +struct nx_addr_v4 {
15216 + struct nx_addr_v4 *next;
15217 + struct in_addr ip[2];
15218 + struct in_addr mask;
15223 +struct nx_addr_v6 {
15224 + struct nx_addr_v6 *next;
15225 + struct in6_addr ip;
15226 + struct in6_addr mask;
15233 + struct hlist_node nx_hlist; /* linked list of nxinfos */
15234 + nid_t nx_id; /* vnet id */
15235 + atomic_t nx_usecnt; /* usage count */
15236 + atomic_t nx_tasks; /* tasks count */
15237 + int nx_state; /* context state */
15239 + uint64_t nx_flags; /* network flag word */
15240 + uint64_t nx_ncaps; /* network capabilities */
15242 + struct in_addr v4_lback; /* Loopback address */
15243 + struct in_addr v4_bcast; /* Broadcast address */
15244 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
15245 +#ifdef CONFIG_IPV6
15246 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
15248 + char nx_name[65]; /* network context name */
15252 +/* status flags */
15254 +#define NXS_HASHED 0x0001
15255 +#define NXS_SHUTDOWN 0x0100
15256 +#define NXS_RELEASED 0x8000
15258 +extern struct nx_info *lookup_nx_info(int);
15260 +extern int get_nid_list(int, unsigned int *, int);
15261 +extern int nid_is_hashed(nid_t);
15263 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
15265 +extern long vs_net_change(struct nx_info *, unsigned int);
15270 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
15271 +#ifdef CONFIG_IPV6
15272 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
15274 +#define NX_IPV6(n) (0)
15277 +#endif /* __KERNEL__ */
15278 +#endif /* _VX_NETWORK_H */
15279 diff -NurpP --minimal linux-3.0/include/linux/vserver/network_cmd.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/network_cmd.h
15280 --- linux-3.0/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
15281 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/network_cmd.h 2011-06-10 22:11:24.000000000 +0200
15283 +#ifndef _VX_NETWORK_CMD_H
15284 +#define _VX_NETWORK_CMD_H
15287 +/* vinfo commands */
15289 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
15292 +extern int vc_task_nid(uint32_t);
15294 +#endif /* __KERNEL__ */
15296 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
15298 +struct vcmd_nx_info_v0 {
15300 + /* more to come */
15304 +extern int vc_nx_info(struct nx_info *, void __user *);
15306 +#endif /* __KERNEL__ */
15308 +#include <linux/in.h>
15309 +#include <linux/in6.h>
15311 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
15312 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
15314 +struct vcmd_net_create {
15315 + uint64_t flagword;
15318 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
15320 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
15321 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
15323 +struct vcmd_net_addr_v0 {
15326 + struct in_addr ip[4];
15327 + struct in_addr mask[4];
15330 +#define VCMD_net_add_ipv4_v1 VC_CMD(NETALT, 1, 1)
15331 +#define VCMD_net_rem_ipv4_v1 VC_CMD(NETALT, 2, 1)
15333 +struct vcmd_net_addr_ipv4_v1 {
15336 + struct in_addr ip;
15337 + struct in_addr mask;
15340 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 2)
15341 +#define VCMD_net_rem_ipv4 VC_CMD(NETALT, 2, 2)
15343 +struct vcmd_net_addr_ipv4_v2 {
15346 + struct in_addr ip;
15347 + struct in_addr ip2;
15348 + struct in_addr mask;
15351 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
15352 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
15354 +struct vcmd_net_addr_ipv6_v1 {
15358 + struct in6_addr ip;
15359 + struct in6_addr mask;
15362 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
15363 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
15365 +struct vcmd_match_ipv4_v0 {
15370 + struct in_addr ip;
15371 + struct in_addr ip2;
15372 + struct in_addr mask;
15375 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
15376 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
15378 +struct vcmd_match_ipv6_v0 {
15383 + struct in6_addr ip;
15384 + struct in6_addr ip2;
15385 + struct in6_addr mask;
15390 +extern int vc_net_create(uint32_t, void __user *);
15391 +extern int vc_net_migrate(struct nx_info *, void __user *);
15393 +extern int vc_net_add(struct nx_info *, void __user *);
15394 +extern int vc_net_remove(struct nx_info *, void __user *);
15396 +extern int vc_net_add_ipv4_v1(struct nx_info *, void __user *);
15397 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
15399 +extern int vc_net_rem_ipv4_v1(struct nx_info *, void __user *);
15400 +extern int vc_net_rem_ipv4(struct nx_info *, void __user *);
15402 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
15403 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
15405 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
15406 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
15408 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
15409 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
15411 +#endif /* __KERNEL__ */
15414 +/* flag commands */
15416 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
15417 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
15419 +struct vcmd_net_flags_v0 {
15420 + uint64_t flagword;
15425 +extern int vc_get_nflags(struct nx_info *, void __user *);
15426 +extern int vc_set_nflags(struct nx_info *, void __user *);
15428 +#endif /* __KERNEL__ */
15431 +/* network caps commands */
15433 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
15434 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
15436 +struct vcmd_net_caps_v0 {
15442 +extern int vc_get_ncaps(struct nx_info *, void __user *);
15443 +extern int vc_set_ncaps(struct nx_info *, void __user *);
15445 +#endif /* __KERNEL__ */
15446 +#endif /* _VX_CONTEXT_CMD_H */
15447 diff -NurpP --minimal linux-3.0/include/linux/vserver/percpu.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/percpu.h
15448 --- linux-3.0/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
15449 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/percpu.h 2011-06-10 22:11:24.000000000 +0200
15451 +#ifndef _VX_PERCPU_H
15452 +#define _VX_PERCPU_H
15454 +#include "cvirt_def.h"
15455 +#include "sched_def.h"
15457 +struct _vx_percpu {
15458 + struct _vx_cvirt_pc cvirt;
15459 + struct _vx_sched_pc sched;
15462 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
15464 +#endif /* _VX_PERCPU_H */
15465 diff -NurpP --minimal linux-3.0/include/linux/vserver/pid.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/pid.h
15466 --- linux-3.0/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
15467 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/pid.h 2011-06-10 22:11:24.000000000 +0200
15469 +#ifndef _VSERVER_PID_H
15470 +#define _VSERVER_PID_H
15472 +/* pid faking stuff */
15474 +#define vx_info_map_pid(v, p) \
15475 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
15476 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
15477 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
15478 +#define vx_map_tgid(p) vx_map_pid(p)
15480 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
15481 + const char *func, const char *file, int line)
15483 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
15484 + vxfprintk(VXD_CBIT(cvirt, 2),
15485 + "vx_map_tgid: %p/%llx: %d -> %d",
15486 + vxi, (long long)vxi->vx_flags, pid,
15487 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
15488 + func, file, line);
15491 + if (pid == vxi->vx_initpid)
15497 +#define vx_info_rmap_pid(v, p) \
15498 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
15499 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
15500 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
15502 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
15503 + const char *func, const char *file, int line)
15505 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
15506 + vxfprintk(VXD_CBIT(cvirt, 2),
15507 + "vx_rmap_tgid: %p/%llx: %d -> %d",
15508 + vxi, (long long)vxi->vx_flags, pid,
15509 + (pid == 1) ? vxi->vx_initpid : pid,
15510 + func, file, line);
15511 + if ((pid == 1) && vxi->vx_initpid)
15512 + return vxi->vx_initpid;
15513 + if (pid == vxi->vx_initpid)
15520 diff -NurpP --minimal linux-3.0/include/linux/vserver/sched.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/sched.h
15521 --- linux-3.0/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
15522 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/sched.h 2011-06-10 22:11:24.000000000 +0200
15524 +#ifndef _VX_SCHED_H
15525 +#define _VX_SCHED_H
15532 +void vx_vsi_uptime(struct timespec *, struct timespec *);
15537 +void vx_update_load(struct vx_info *);
15540 +void vx_update_sched_param(struct _vx_sched *sched,
15541 + struct _vx_sched_pc *sched_pc);
15543 +#endif /* __KERNEL__ */
15544 +#else /* _VX_SCHED_H */
15545 +#warning duplicate inclusion
15546 +#endif /* _VX_SCHED_H */
15547 diff -NurpP --minimal linux-3.0/include/linux/vserver/sched_cmd.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/sched_cmd.h
15548 --- linux-3.0/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
15549 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/sched_cmd.h 2011-06-10 22:11:24.000000000 +0200
15551 +#ifndef _VX_SCHED_CMD_H
15552 +#define _VX_SCHED_CMD_H
15555 +struct vcmd_prio_bias {
15557 + int32_t prio_bias;
15560 +#define VCMD_set_prio_bias VC_CMD(SCHED, 4, 0)
15561 +#define VCMD_get_prio_bias VC_CMD(SCHED, 5, 0)
15565 +#include <linux/compiler.h>
15567 +extern int vc_set_prio_bias(struct vx_info *, void __user *);
15568 +extern int vc_get_prio_bias(struct vx_info *, void __user *);
15570 +#endif /* __KERNEL__ */
15571 +#endif /* _VX_SCHED_CMD_H */
15572 diff -NurpP --minimal linux-3.0/include/linux/vserver/sched_def.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/sched_def.h
15573 --- linux-3.0/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
15574 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/sched_def.h 2011-06-10 22:11:24.000000000 +0200
15576 +#ifndef _VX_SCHED_DEF_H
15577 +#define _VX_SCHED_DEF_H
15579 +#include <linux/spinlock.h>
15580 +#include <linux/jiffies.h>
15581 +#include <linux/cpumask.h>
15582 +#include <asm/atomic.h>
15583 +#include <asm/param.h>
15586 +/* context sub struct */
15588 +struct _vx_sched {
15589 + int prio_bias; /* bias offset for priority */
15591 + cpumask_t update; /* CPUs which should update */
15594 +struct _vx_sched_pc {
15595 + int prio_bias; /* bias offset for priority */
15597 + uint64_t user_ticks; /* token tick events */
15598 + uint64_t sys_ticks; /* token tick events */
15599 + uint64_t hold_ticks; /* token ticks paused */
15603 +#ifdef CONFIG_VSERVER_DEBUG
15605 +static inline void __dump_vx_sched(struct _vx_sched *sched)
15607 + printk("\t_vx_sched:\n");
15608 + printk("\t priority = %4d\n", sched->prio_bias);
15613 +#endif /* _VX_SCHED_DEF_H */
15614 diff -NurpP --minimal linux-3.0/include/linux/vserver/signal.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/signal.h
15615 --- linux-3.0/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
15616 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/signal.h 2011-06-10 22:11:24.000000000 +0200
15618 +#ifndef _VX_SIGNAL_H
15619 +#define _VX_SIGNAL_H
15626 +int vx_info_kill(struct vx_info *, int, int);
15628 +#endif /* __KERNEL__ */
15629 +#else /* _VX_SIGNAL_H */
15630 +#warning duplicate inclusion
15631 +#endif /* _VX_SIGNAL_H */
15632 diff -NurpP --minimal linux-3.0/include/linux/vserver/signal_cmd.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/signal_cmd.h
15633 --- linux-3.0/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
15634 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/signal_cmd.h 2011-06-10 22:11:24.000000000 +0200
15636 +#ifndef _VX_SIGNAL_CMD_H
15637 +#define _VX_SIGNAL_CMD_H
15640 +/* signalling vserver commands */
15642 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
15643 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
15645 +struct vcmd_ctx_kill_v0 {
15650 +struct vcmd_wait_exit_v0 {
15651 + int32_t reboot_cmd;
15652 + int32_t exit_code;
15657 +extern int vc_ctx_kill(struct vx_info *, void __user *);
15658 +extern int vc_wait_exit(struct vx_info *, void __user *);
15660 +#endif /* __KERNEL__ */
15662 +/* process alteration commands */
15664 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
15665 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
15667 +struct vcmd_pflags_v0 {
15668 + uint32_t flagword;
15674 +extern int vc_get_pflags(uint32_t pid, void __user *);
15675 +extern int vc_set_pflags(uint32_t pid, void __user *);
15677 +#endif /* __KERNEL__ */
15678 +#endif /* _VX_SIGNAL_CMD_H */
15679 diff -NurpP --minimal linux-3.0/include/linux/vserver/space.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/space.h
15680 --- linux-3.0/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
15681 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/space.h 2011-06-10 22:11:24.000000000 +0200
15683 +#ifndef _VX_SPACE_H
15684 +#define _VX_SPACE_H
15686 +#include <linux/types.h>
15690 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
15692 +#else /* _VX_SPACE_H */
15693 +#warning duplicate inclusion
15694 +#endif /* _VX_SPACE_H */
15695 diff -NurpP --minimal linux-3.0/include/linux/vserver/space_cmd.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/space_cmd.h
15696 --- linux-3.0/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
15697 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/space_cmd.h 2011-06-10 22:11:24.000000000 +0200
15699 +#ifndef _VX_SPACE_CMD_H
15700 +#define _VX_SPACE_CMD_H
15703 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
15704 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
15705 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
15707 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
15708 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
15709 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
15711 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
15713 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
15714 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
15717 +struct vcmd_space_mask_v1 {
15721 +struct vcmd_space_mask_v2 {
15729 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
15730 +extern int vc_set_space_v1(struct vx_info *, void __user *);
15731 +extern int vc_enter_space(struct vx_info *, void __user *);
15732 +extern int vc_set_space(struct vx_info *, void __user *);
15733 +extern int vc_get_space_mask(void __user *, int);
15735 +#endif /* __KERNEL__ */
15736 +#endif /* _VX_SPACE_CMD_H */
15737 diff -NurpP --minimal linux-3.0/include/linux/vserver/switch.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/switch.h
15738 --- linux-3.0/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
15739 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/switch.h 2011-06-10 22:11:24.000000000 +0200
15741 +#ifndef _VX_SWITCH_H
15742 +#define _VX_SWITCH_H
15744 +#include <linux/types.h>
15747 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
15748 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
15749 +#define VC_VERSION(c) ((c) & 0xFFF)
15751 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
15752 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
15756 + Syscall Matrix V2.8
15758 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
15759 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
15760 + |INFO |SETUP | |MOVE | | | | | |
15761 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15762 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
15763 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
15764 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15765 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
15766 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
15767 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15768 + MEMORY | | | | |MEMCTRL| | |SWAP | |
15769 + | 16| 17| 18| 19| 20| 21| | 22| 23|
15770 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15771 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
15772 + | 24| 25| 26| 27| 28| 29| | 30| 31|
15773 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15774 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
15775 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
15776 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15777 + OTHER |VSTAT | | | | | | |VINFO | |
15778 + | 40| 41| 42| 43| 44| 45| | 46| 47|
15779 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
15780 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
15781 + | 48| 49| 50| 51| 52| 53| | 54| 55|
15782 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15783 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
15784 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
15785 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
15789 +#define VC_CAT_VERSION 0
15791 +#define VC_CAT_VSETUP 1
15792 +#define VC_CAT_VHOST 2
15794 +#define VC_CAT_DEVICE 6
15796 +#define VC_CAT_VPROC 9
15797 +#define VC_CAT_PROCALT 10
15798 +#define VC_CAT_PROCMIG 11
15799 +#define VC_CAT_PROCTRL 12
15801 +#define VC_CAT_SCHED 14
15802 +#define VC_CAT_MEMCTRL 20
15804 +#define VC_CAT_VNET 25
15805 +#define VC_CAT_NETALT 26
15806 +#define VC_CAT_NETMIG 27
15807 +#define VC_CAT_NETCTRL 28
15809 +#define VC_CAT_TAGMIG 35
15810 +#define VC_CAT_DLIMIT 36
15811 +#define VC_CAT_INODE 38
15813 +#define VC_CAT_VSTAT 40
15814 +#define VC_CAT_VINFO 46
15815 +#define VC_CAT_EVENT 48
15817 +#define VC_CAT_FLAGS 52
15818 +#define VC_CAT_VSPACE 54
15819 +#define VC_CAT_DEBUG 56
15820 +#define VC_CAT_RLIMIT 60
15822 +#define VC_CAT_SYSTEST 61
15823 +#define VC_CAT_COMPAT 63
15825 +/* query version */
15827 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
15828 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
15833 +#include <linux/errno.h>
15835 +#endif /* __KERNEL__ */
15837 +#endif /* _VX_SWITCH_H */
15839 diff -NurpP --minimal linux-3.0/include/linux/vserver/tag.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/tag.h
15840 --- linux-3.0/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
15841 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/tag.h 2011-06-10 22:11:24.000000000 +0200
15846 +#include <linux/types.h>
15849 +#define DX_TAG(in) (IS_TAGGED(in))
15852 +#ifdef CONFIG_TAG_NFSD
15853 +#define DX_TAG_NFSD 1
15855 +#define DX_TAG_NFSD 0
15859 +#ifdef CONFIG_TAGGING_NONE
15861 +#define MAX_UID 0xFFFFFFFF
15862 +#define MAX_GID 0xFFFFFFFF
15864 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
15866 +#define TAGINO_UID(cond, uid, tag) (uid)
15867 +#define TAGINO_GID(cond, gid, tag) (gid)
15872 +#ifdef CONFIG_TAGGING_GID16
15874 +#define MAX_UID 0xFFFFFFFF
15875 +#define MAX_GID 0x0000FFFF
15877 +#define INOTAG_TAG(cond, uid, gid, tag) \
15878 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
15880 +#define TAGINO_UID(cond, uid, tag) (uid)
15881 +#define TAGINO_GID(cond, gid, tag) \
15882 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
15887 +#ifdef CONFIG_TAGGING_ID24
15889 +#define MAX_UID 0x00FFFFFF
15890 +#define MAX_GID 0x00FFFFFF
15892 +#define INOTAG_TAG(cond, uid, gid, tag) \
15893 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
15895 +#define TAGINO_UID(cond, uid, tag) \
15896 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
15897 +#define TAGINO_GID(cond, gid, tag) \
15898 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
15903 +#ifdef CONFIG_TAGGING_UID16
15905 +#define MAX_UID 0x0000FFFF
15906 +#define MAX_GID 0xFFFFFFFF
15908 +#define INOTAG_TAG(cond, uid, gid, tag) \
15909 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
15911 +#define TAGINO_UID(cond, uid, tag) \
15912 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
15913 +#define TAGINO_GID(cond, gid, tag) (gid)
15918 +#ifdef CONFIG_TAGGING_INTERN
15920 +#define MAX_UID 0xFFFFFFFF
15921 +#define MAX_GID 0xFFFFFFFF
15923 +#define INOTAG_TAG(cond, uid, gid, tag) \
15924 + ((cond) ? (tag) : 0)
15926 +#define TAGINO_UID(cond, uid, tag) (uid)
15927 +#define TAGINO_GID(cond, gid, tag) (gid)
15932 +#ifndef CONFIG_TAGGING_NONE
15933 +#define dx_current_fstag(sb) \
15934 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
15936 +#define dx_current_fstag(sb) (0)
15939 +#ifndef CONFIG_TAGGING_INTERN
15940 +#define TAGINO_TAG(cond, tag) (0)
15942 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
15945 +#define INOTAG_UID(cond, uid, gid) \
15946 + ((cond) ? ((uid) & MAX_UID) : (uid))
15947 +#define INOTAG_GID(cond, uid, gid) \
15948 + ((cond) ? ((gid) & MAX_GID) : (gid))
15951 +static inline uid_t dx_map_uid(uid_t uid)
15953 + if ((uid > MAX_UID) && (uid != -1))
15955 + return (uid & MAX_UID);
15958 +static inline gid_t dx_map_gid(gid_t gid)
15960 + if ((gid > MAX_GID) && (gid != -1))
15962 + return (gid & MAX_GID);
15970 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
15972 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
15973 + unsigned long *flags);
15975 +#ifdef CONFIG_PROPAGATE
15977 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
15979 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
15982 +#define dx_propagate_tag(n, i) do { } while (0)
15985 +#endif /* _DX_TAG_H */
15986 diff -NurpP --minimal linux-3.0/include/linux/vserver/tag_cmd.h linux-3.0-vs2.3.1-pre7/include/linux/vserver/tag_cmd.h
15987 --- linux-3.0/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
15988 +++ linux-3.0-vs2.3.1-pre7/include/linux/vserver/tag_cmd.h 2011-06-10 22:11:24.000000000 +0200
15990 +#ifndef _VX_TAG_CMD_H
15991 +#define _VX_TAG_CMD_H
15994 +/* vinfo commands */
15996 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
15999 +extern int vc_task_tag(uint32_t);
16001 +#endif /* __KERNEL__ */
16003 +/* context commands */
16005 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
16008 +extern int vc_tag_migrate(uint32_t);
16010 +#endif /* __KERNEL__ */
16011 +#endif /* _VX_TAG_CMD_H */
16012 diff -NurpP --minimal linux-3.0/include/net/addrconf.h linux-3.0-vs2.3.1-pre7/include/net/addrconf.h
16013 --- linux-3.0/include/net/addrconf.h 2011-07-22 11:18:11.000000000 +0200
16014 +++ linux-3.0-vs2.3.1-pre7/include/net/addrconf.h 2011-06-10 22:11:24.000000000 +0200
16015 @@ -80,7 +80,8 @@ extern int ipv6_dev_get_saddr(struct n
16016 struct net_device *dev,
16017 const struct in6_addr *daddr,
16018 unsigned int srcprefs,
16019 - struct in6_addr *saddr);
16020 + struct in6_addr *saddr,
16021 + struct nx_info *nxi);
16022 extern int ipv6_get_lladdr(struct net_device *dev,
16023 struct in6_addr *addr,
16024 unsigned char banned_flags);
16025 diff -NurpP --minimal linux-3.0/include/net/af_unix.h linux-3.0-vs2.3.1-pre7/include/net/af_unix.h
16026 --- linux-3.0/include/net/af_unix.h 2011-07-22 11:18:11.000000000 +0200
16027 +++ linux-3.0-vs2.3.1-pre7/include/net/af_unix.h 2011-06-10 22:11:24.000000000 +0200
16029 #include <linux/socket.h>
16030 #include <linux/un.h>
16031 #include <linux/mutex.h>
16032 +#include <linux/vs_base.h>
16033 #include <net/sock.h>
16035 extern void unix_inflight(struct file *fp);
16036 diff -NurpP --minimal linux-3.0/include/net/inet_timewait_sock.h linux-3.0-vs2.3.1-pre7/include/net/inet_timewait_sock.h
16037 --- linux-3.0/include/net/inet_timewait_sock.h 2011-03-15 18:07:40.000000000 +0100
16038 +++ linux-3.0-vs2.3.1-pre7/include/net/inet_timewait_sock.h 2011-06-10 22:11:24.000000000 +0200
16039 @@ -113,6 +113,10 @@ struct inet_timewait_sock {
16040 #define tw_net __tw_common.skc_net
16041 #define tw_daddr __tw_common.skc_daddr
16042 #define tw_rcv_saddr __tw_common.skc_rcv_saddr
16043 +#define tw_xid __tw_common.skc_xid
16044 +#define tw_vx_info __tw_common.skc_vx_info
16045 +#define tw_nid __tw_common.skc_nid
16046 +#define tw_nx_info __tw_common.skc_nx_info
16048 volatile unsigned char tw_substate;
16049 unsigned char tw_rcv_wscale;
16050 diff -NurpP --minimal linux-3.0/include/net/ip6_route.h linux-3.0-vs2.3.1-pre7/include/net/ip6_route.h
16051 --- linux-3.0/include/net/ip6_route.h 2011-07-22 11:18:11.000000000 +0200
16052 +++ linux-3.0-vs2.3.1-pre7/include/net/ip6_route.h 2011-06-16 14:16:51.000000000 +0200
16053 @@ -86,7 +86,8 @@ extern int ip6_route_get_saddr(struct
16054 struct rt6_info *rt,
16055 const struct in6_addr *daddr,
16056 unsigned int prefs,
16057 - struct in6_addr *saddr);
16058 + struct in6_addr *saddr,
16059 + struct nx_info *nxi);
16061 extern struct rt6_info *rt6_lookup(struct net *net,
16062 const struct in6_addr *daddr,
16063 diff -NurpP --minimal linux-3.0/include/net/route.h linux-3.0-vs2.3.1-pre7/include/net/route.h
16064 --- linux-3.0/include/net/route.h 2011-07-22 11:18:11.000000000 +0200
16065 +++ linux-3.0-vs2.3.1-pre7/include/net/route.h 2011-06-13 18:20:44.000000000 +0200
16066 @@ -202,6 +202,9 @@ static inline void ip_rt_put(struct rtab
16067 dst_release(&rt->dst);
16070 +#include <linux/vs_base.h>
16071 +#include <linux/vs_inet.h>
16073 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
16075 extern const __u8 ip_tos2prio[16];
16076 @@ -253,6 +256,9 @@ static inline void ip_route_connect_init
16077 protocol, flow_flags, dst, src, dport, sport);
16080 +extern struct rtable *ip_v4_find_src(struct net *net, struct nx_info *,
16081 + struct flowi4 *);
16083 static inline struct rtable *ip_route_connect(struct flowi4 *fl4,
16084 __be32 dst, __be32 src, u32 tos,
16085 int oif, u8 protocol,
16086 @@ -261,11 +267,24 @@ static inline struct rtable *ip_route_co
16088 struct net *net = sock_net(sk);
16090 + struct nx_info *nx_info = current_nx_info();
16092 ip_route_connect_init(fl4, dst, src, tos, oif, protocol,
16093 sport, dport, sk, can_sleep);
16095 - if (!dst || !src) {
16097 + nx_info = sk->sk_nx_info;
16099 + vxdprintk(VXD_CBIT(net, 4),
16100 + "ip_route_connect(%p) %p,%p;%lx",
16101 + sk, nx_info, sk->sk_socket,
16102 + (sk->sk_socket?sk->sk_socket->flags:0));
16104 + rt = ip_v4_find_src(net, nx_info, fl4);
16108 + if (!fl4->daddr || !fl4->saddr) {
16109 rt = __ip_route_output_key(net, fl4);
16112 diff -NurpP --minimal linux-3.0/include/net/sock.h linux-3.0-vs2.3.1-pre7/include/net/sock.h
16113 --- linux-3.0/include/net/sock.h 2011-07-22 11:18:12.000000000 +0200
16114 +++ linux-3.0-vs2.3.1-pre7/include/net/sock.h 2011-07-01 11:35:35.000000000 +0200
16115 @@ -149,6 +149,10 @@ struct sock_common {
16116 #ifdef CONFIG_NET_NS
16117 struct net *skc_net;
16120 + struct vx_info *skc_vx_info;
16122 + struct nx_info *skc_nx_info;
16124 * fields between dontcopy_begin/dontcopy_end
16125 * are not copied in sock_copy()
16126 @@ -256,6 +260,10 @@ struct sock {
16127 #define sk_bind_node __sk_common.skc_bind_node
16128 #define sk_prot __sk_common.skc_prot
16129 #define sk_net __sk_common.skc_net
16130 +#define sk_xid __sk_common.skc_xid
16131 +#define sk_vx_info __sk_common.skc_vx_info
16132 +#define sk_nid __sk_common.skc_nid
16133 +#define sk_nx_info __sk_common.skc_nx_info
16134 socket_lock_t sk_lock;
16135 struct sk_buff_head sk_receive_queue;
16137 diff -NurpP --minimal linux-3.0/init/Kconfig linux-3.0-vs2.3.1-pre7/init/Kconfig
16138 --- linux-3.0/init/Kconfig 2011-07-22 11:18:12.000000000 +0200
16139 +++ linux-3.0-vs2.3.1-pre7/init/Kconfig 2011-07-20 02:16:43.000000000 +0200
16140 @@ -574,6 +574,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
16142 boolean "Control Group support"
16146 This option adds support for grouping sets of processes together, for
16147 use with process control subsystems such as Cpusets, CFS, memory
16148 @@ -790,7 +791,7 @@ config IPC_NS
16150 bool "User namespace (EXPERIMENTAL)"
16151 depends on EXPERIMENTAL
16155 This allows containers, i.e. vservers, to use user namespaces
16156 to provide different user info for different servers.
16157 diff -NurpP --minimal linux-3.0/init/main.c linux-3.0-vs2.3.1-pre7/init/main.c
16158 --- linux-3.0/init/main.c 2011-07-22 11:18:12.000000000 +0200
16159 +++ linux-3.0-vs2.3.1-pre7/init/main.c 2011-06-22 12:39:15.000000000 +0200
16161 #include <linux/shmem_fs.h>
16162 #include <linux/slab.h>
16163 #include <linux/perf_event.h>
16164 +#include <linux/vserver/percpu.h>
16166 #include <asm/io.h>
16167 #include <asm/bugs.h>
16168 diff -NurpP --minimal linux-3.0/ipc/mqueue.c linux-3.0-vs2.3.1-pre7/ipc/mqueue.c
16169 --- linux-3.0/ipc/mqueue.c 2011-03-15 18:07:41.000000000 +0100
16170 +++ linux-3.0-vs2.3.1-pre7/ipc/mqueue.c 2011-06-10 22:11:24.000000000 +0200
16172 #include <linux/pid.h>
16173 #include <linux/ipc_namespace.h>
16174 #include <linux/slab.h>
16175 +#include <linux/vs_context.h>
16176 +#include <linux/vs_limit.h>
16178 #include <net/sock.h>
16180 @@ -66,6 +68,7 @@ struct mqueue_inode_info {
16181 struct sigevent notify;
16182 struct pid* notify_owner;
16183 struct user_struct *user; /* user who created, for accounting */
16184 + struct vx_info *vxi;
16185 struct sock *notify_sock;
16186 struct sk_buff *notify_cookie;
16188 @@ -126,6 +129,7 @@ static struct inode *mqueue_get_inode(st
16189 if (S_ISREG(mode)) {
16190 struct mqueue_inode_info *info;
16191 struct task_struct *p = current;
16192 + struct vx_info *vxi = p->vx_info;
16193 unsigned long mq_bytes, mq_msg_tblsz;
16195 inode->i_fop = &mqueue_file_operations;
16196 @@ -139,6 +143,7 @@ static struct inode *mqueue_get_inode(st
16197 info->notify_owner = NULL;
16199 info->user = NULL; /* set when all is ok */
16200 + info->vxi = NULL;
16201 memset(&info->attr, 0, sizeof(info->attr));
16202 info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
16203 info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
16204 @@ -157,16 +162,19 @@ static struct inode *mqueue_get_inode(st
16205 spin_lock(&mq_lock);
16206 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
16207 u->mq_bytes + mq_bytes >
16208 - task_rlimit(p, RLIMIT_MSGQUEUE)) {
16209 + task_rlimit(p, RLIMIT_MSGQUEUE) ||
16210 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
16211 spin_unlock(&mq_lock);
16212 /* mqueue_evict_inode() releases info->messages */
16215 u->mq_bytes += mq_bytes;
16216 + vx_ipcmsg_add(vxi, u, mq_bytes);
16217 spin_unlock(&mq_lock);
16220 info->user = get_uid(u);
16221 + info->vxi = get_vx_info(vxi);
16222 } else if (S_ISDIR(mode)) {
16224 /* Some things misbehave if size == 0 on a directory */
16225 @@ -275,8 +283,11 @@ static void mqueue_evict_inode(struct in
16226 + info->attr.mq_msgsize);
16229 + struct vx_info *vxi = info->vxi;
16231 spin_lock(&mq_lock);
16232 user->mq_bytes -= mq_bytes;
16233 + vx_ipcmsg_sub(vxi, user, mq_bytes);
16235 * get_ns_from_inode() ensures that the
16236 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
16237 @@ -286,6 +297,7 @@ static void mqueue_evict_inode(struct in
16239 ipc_ns->mq_queues_count--;
16240 spin_unlock(&mq_lock);
16241 + put_vx_info(vxi);
16245 diff -NurpP --minimal linux-3.0/ipc/msg.c linux-3.0-vs2.3.1-pre7/ipc/msg.c
16246 --- linux-3.0/ipc/msg.c 2011-05-22 16:17:59.000000000 +0200
16247 +++ linux-3.0-vs2.3.1-pre7/ipc/msg.c 2011-06-10 22:11:24.000000000 +0200
16249 #include <linux/rwsem.h>
16250 #include <linux/nsproxy.h>
16251 #include <linux/ipc_namespace.h>
16252 +#include <linux/vs_base.h>
16254 #include <asm/current.h>
16255 #include <asm/uaccess.h>
16256 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
16258 msq->q_perm.mode = msgflg & S_IRWXUGO;
16259 msq->q_perm.key = key;
16260 + msq->q_perm.xid = vx_current_xid();
16262 msq->q_perm.security = NULL;
16263 retval = security_msg_queue_alloc(msq);
16264 diff -NurpP --minimal linux-3.0/ipc/namespace.c linux-3.0-vs2.3.1-pre7/ipc/namespace.c
16265 --- linux-3.0/ipc/namespace.c 2011-07-22 11:18:12.000000000 +0200
16266 +++ linux-3.0-vs2.3.1-pre7/ipc/namespace.c 2011-06-13 14:09:44.000000000 +0200
16267 @@ -13,11 +13,12 @@
16268 #include <linux/mount.h>
16269 #include <linux/user_namespace.h>
16270 #include <linux/proc_fs.h>
16271 +#include <linux/vs_base.h>
16272 +#include <linux/vserver/global.h>
16276 -static struct ipc_namespace *create_ipc_ns(struct task_struct *tsk,
16277 - struct ipc_namespace *old_ns)
16278 +static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns)
16280 struct ipc_namespace *ns;
16282 @@ -46,19 +47,18 @@ static struct ipc_namespace *create_ipc_
16283 ipcns_notify(IPCNS_CREATED);
16284 register_ipcns_notifier(ns);
16286 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
16287 + ns->user_ns = get_user_ns(user_ns);
16292 struct ipc_namespace *copy_ipcs(unsigned long flags,
16293 - struct task_struct *tsk)
16294 + struct ipc_namespace *old_ns,
16295 + struct user_namespace *user_ns)
16297 - struct ipc_namespace *ns = tsk->nsproxy->ipc_ns;
16299 if (!(flags & CLONE_NEWIPC))
16300 - return get_ipc_ns(ns);
16301 - return create_ipc_ns(tsk, ns);
16302 + return get_ipc_ns(old_ns);
16303 + return create_ipc_ns(user_ns);
16307 diff -NurpP --minimal linux-3.0/ipc/sem.c linux-3.0-vs2.3.1-pre7/ipc/sem.c
16308 --- linux-3.0/ipc/sem.c 2011-05-22 16:17:59.000000000 +0200
16309 +++ linux-3.0-vs2.3.1-pre7/ipc/sem.c 2011-06-10 22:11:24.000000000 +0200
16311 #include <linux/rwsem.h>
16312 #include <linux/nsproxy.h>
16313 #include <linux/ipc_namespace.h>
16314 +#include <linux/vs_base.h>
16315 +#include <linux/vs_limit.h>
16317 #include <asm/uaccess.h>
16319 @@ -260,6 +262,7 @@ static int newary(struct ipc_namespace *
16321 sma->sem_perm.mode = (semflg & S_IRWXUGO);
16322 sma->sem_perm.key = key;
16323 + sma->sem_perm.xid = vx_current_xid();
16325 sma->sem_perm.security = NULL;
16326 retval = security_sem_alloc(sma);
16327 @@ -275,6 +278,9 @@ static int newary(struct ipc_namespace *
16330 ns->used_sems += nsems;
16331 + /* FIXME: obsoleted? */
16332 + vx_semary_inc(sma);
16333 + vx_nsems_add(sma, nsems);
16335 sma->sem_base = (struct sem *) &sma[1];
16337 @@ -730,6 +736,9 @@ static void freeary(struct ipc_namespace
16339 wake_up_sem_queue_do(&tasks);
16340 ns->used_sems -= sma->sem_nsems;
16341 + /* FIXME: obsoleted? */
16342 + vx_nsems_sub(sma, sma->sem_nsems);
16343 + vx_semary_dec(sma);
16344 security_sem_free(sma);
16345 ipc_rcu_putref(sma);
16347 diff -NurpP --minimal linux-3.0/ipc/shm.c linux-3.0-vs2.3.1-pre7/ipc/shm.c
16348 --- linux-3.0/ipc/shm.c 2011-07-22 11:18:12.000000000 +0200
16349 +++ linux-3.0-vs2.3.1-pre7/ipc/shm.c 2011-06-10 22:11:24.000000000 +0200
16351 #include <linux/nsproxy.h>
16352 #include <linux/mount.h>
16353 #include <linux/ipc_namespace.h>
16354 +#include <linux/vs_context.h>
16355 +#include <linux/vs_limit.h>
16357 #include <asm/uaccess.h>
16359 @@ -173,7 +175,12 @@ static void shm_open(struct vm_area_stru
16361 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
16363 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
16364 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
16365 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
16367 + vx_ipcshm_sub(vxi, shp, numpages);
16368 + ns->shm_tot -= numpages;
16372 if (!is_file_hugepages(shp->shm_file))
16373 @@ -183,6 +190,7 @@ static void shm_destroy(struct ipc_names
16375 fput (shp->shm_file);
16376 security_shm_free(shp);
16377 + put_vx_info(vxi);
16378 ipc_rcu_putref(shp);
16381 @@ -355,11 +363,15 @@ static int newseg(struct ipc_namespace *
16382 if (ns->shm_tot + numpages > ns->shm_ctlall)
16385 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
16388 shp = ipc_rcu_alloc(sizeof(*shp));
16392 shp->shm_perm.key = key;
16393 + shp->shm_perm.xid = vx_current_xid();
16394 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
16395 shp->mlock_user = NULL;
16397 @@ -413,6 +425,7 @@ static int newseg(struct ipc_namespace *
16398 ns->shm_tot += numpages;
16399 error = shp->shm_perm.id;
16401 + vx_ipcshm_add(current_vx_info(), key, numpages);
16405 diff -NurpP --minimal linux-3.0/kernel/Makefile linux-3.0-vs2.3.1-pre7/kernel/Makefile
16406 --- linux-3.0/kernel/Makefile 2011-07-22 11:18:12.000000000 +0200
16407 +++ linux-3.0-vs2.3.1-pre7/kernel/Makefile 2011-06-10 22:11:24.000000000 +0200
16408 @@ -24,6 +24,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
16409 CFLAGS_REMOVE_irq_work.o = -pg
16413 obj-$(CONFIG_FREEZER) += freezer.o
16414 obj-$(CONFIG_PROFILING) += profile.o
16415 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
16416 diff -NurpP --minimal linux-3.0/kernel/capability.c linux-3.0-vs2.3.1-pre7/kernel/capability.c
16417 --- linux-3.0/kernel/capability.c 2011-07-22 11:18:12.000000000 +0200
16418 +++ linux-3.0-vs2.3.1-pre7/kernel/capability.c 2011-07-19 19:27:53.000000000 +0200
16420 #include <linux/syscalls.h>
16421 #include <linux/pid_namespace.h>
16422 #include <linux/user_namespace.h>
16423 +#include <linux/vs_context.h>
16424 #include <asm/uaccess.h>
16427 @@ -116,6 +117,7 @@ static int cap_validate_magic(cap_user_h
16433 * The only thing that can change the capabilities of the current
16434 * process is the current process. As such, we can't be in this code
16435 @@ -340,6 +342,8 @@ bool has_capability_noaudit(struct task_
16439 +#include <linux/vserver/base.h>
16442 * capable - Determine if the current task has a superior capability in effect
16443 * @cap: The capability to be tested for
16444 @@ -374,6 +378,9 @@ bool ns_capable(struct user_namespace *n
16448 + if (vs_check_bit(VXC_CAP_MASK, cap) && !vx_mcaps(1L << cap))
16451 if (security_capable(ns, current_cred(), cap) == 0) {
16452 current->flags |= PF_SUPERPRIV;
16454 diff -NurpP --minimal linux-3.0/kernel/compat.c linux-3.0-vs2.3.1-pre7/kernel/compat.c
16455 --- linux-3.0/kernel/compat.c 2011-07-22 11:18:12.000000000 +0200
16456 +++ linux-3.0-vs2.3.1-pre7/kernel/compat.c 2011-06-10 22:11:24.000000000 +0200
16457 @@ -970,7 +970,7 @@ asmlinkage long compat_sys_stime(compat_
16461 - do_settimeofday(&tv);
16462 + vx_settimeofday(&tv);
16466 diff -NurpP --minimal linux-3.0/kernel/cred.c linux-3.0-vs2.3.1-pre7/kernel/cred.c
16467 --- linux-3.0/kernel/cred.c 2011-07-22 11:18:12.000000000 +0200
16468 +++ linux-3.0-vs2.3.1-pre7/kernel/cred.c 2011-06-10 22:11:24.000000000 +0200
16469 @@ -61,31 +61,6 @@ struct cred init_cred = {
16473 -static inline void set_cred_subscribers(struct cred *cred, int n)
16475 -#ifdef CONFIG_DEBUG_CREDENTIALS
16476 - atomic_set(&cred->subscribers, n);
16480 -static inline int read_cred_subscribers(const struct cred *cred)
16482 -#ifdef CONFIG_DEBUG_CREDENTIALS
16483 - return atomic_read(&cred->subscribers);
16489 -static inline void alter_cred_subscribers(const struct cred *_cred, int n)
16491 -#ifdef CONFIG_DEBUG_CREDENTIALS
16492 - struct cred *cred = (struct cred *) _cred;
16494 - atomic_add(n, &cred->subscribers);
16499 * Dispose of the shared task group credentials
16501 @@ -281,21 +256,16 @@ error:
16503 * Call commit_creds() or abort_creds() to clean up.
16505 -struct cred *prepare_creds(void)
16506 +struct cred *__prepare_creds(const struct cred *old)
16508 - struct task_struct *task = current;
16509 - const struct cred *old;
16512 - validate_process_creds();
16514 new = kmem_cache_alloc(cred_jar, GFP_KERNEL);
16518 kdebug("prepare_creds() alloc %p", new);
16520 - old = task->cred;
16521 memcpy(new, old, sizeof(struct cred));
16523 atomic_set(&new->usage, 1);
16524 @@ -322,6 +292,13 @@ error:
16529 +struct cred *prepare_creds(void)
16531 + validate_process_creds();
16533 + return __prepare_creds(current->cred);
16535 EXPORT_SYMBOL(prepare_creds);
16538 diff -NurpP --minimal linux-3.0/kernel/exit.c linux-3.0-vs2.3.1-pre7/kernel/exit.c
16539 --- linux-3.0/kernel/exit.c 2011-07-22 11:18:12.000000000 +0200
16540 +++ linux-3.0-vs2.3.1-pre7/kernel/exit.c 2011-06-22 12:39:15.000000000 +0200
16542 #include <linux/fs_struct.h>
16543 #include <linux/init_task.h>
16544 #include <linux/perf_event.h>
16545 +#include <linux/vs_limit.h>
16546 +#include <linux/vs_context.h>
16547 +#include <linux/vs_network.h>
16548 +#include <linux/vs_pid.h>
16549 #include <trace/events/sched.h>
16550 #include <linux/hw_breakpoint.h>
16551 #include <linux/oom.h>
16552 @@ -494,9 +498,11 @@ static void close_files(struct files_str
16553 filp_close(file, files);
16556 + vx_openfd_dec(i);
16564 @@ -1047,11 +1053,16 @@ NORET_TYPE void do_exit(long code)
16566 validate_creds_for_do_exit(tsk);
16568 + /* needs to stay after exit_notify() */
16569 + exit_vx_info(tsk, code);
16570 + exit_nx_info(tsk);
16574 /* causes final put_task_struct in finish_task_switch(). */
16575 tsk->state = TASK_DEAD;
16577 + printk("bad task: %p [%lx]\n", current, current->state);
16579 /* Avoid "noreturn function does return". */
16581 diff -NurpP --minimal linux-3.0/kernel/fork.c linux-3.0-vs2.3.1-pre7/kernel/fork.c
16582 --- linux-3.0/kernel/fork.c 2011-07-22 11:18:12.000000000 +0200
16583 +++ linux-3.0-vs2.3.1-pre7/kernel/fork.c 2011-06-10 22:21:02.000000000 +0200
16585 #include <linux/user-return-notifier.h>
16586 #include <linux/oom.h>
16587 #include <linux/khugepaged.h>
16588 +#include <linux/vs_context.h>
16589 +#include <linux/vs_network.h>
16590 +#include <linux/vs_limit.h>
16591 +#include <linux/vs_memory.h>
16593 #include <asm/pgtable.h>
16594 #include <asm/pgalloc.h>
16595 @@ -167,6 +171,8 @@ void free_task(struct task_struct *tsk)
16596 account_kernel_stack(tsk->stack, -1);
16597 free_thread_info(tsk->stack);
16598 rt_mutex_debug_task_free(tsk);
16599 + clr_vx_info(&tsk->vx_info);
16600 + clr_nx_info(&tsk->nx_info);
16601 ftrace_graph_exit_task(tsk);
16602 free_task_struct(tsk);
16604 @@ -505,6 +511,7 @@ static struct mm_struct * mm_init(struct
16605 if (likely(!mm_alloc_pgd(mm))) {
16607 mmu_notifier_mm_init(mm);
16608 + set_vx_info(&mm->mm_vx_info, p->vx_info);
16612 @@ -542,6 +549,7 @@ void __mmdrop(struct mm_struct *mm)
16613 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
16614 VM_BUG_ON(mm->pmd_huge_pte);
16616 + clr_vx_info(&mm->mm_vx_info);
16619 EXPORT_SYMBOL_GPL(__mmdrop);
16620 @@ -729,6 +737,7 @@ struct mm_struct *dup_mm(struct task_str
16623 memcpy(mm, oldmm, sizeof(*mm));
16624 + mm->mm_vx_info = NULL;
16625 mm_init_cpumask(mm);
16627 /* Initializing for Swap token stuff */
16628 @@ -772,6 +781,7 @@ fail_nocontext:
16629 * If init_new_context() failed, we cannot use mmput() to free the mm
16630 * because it calls destroy_context()
16632 + clr_vx_info(&mm->mm_vx_info);
16636 @@ -1057,6 +1067,8 @@ static struct task_struct *copy_process(
16638 struct task_struct *p;
16639 int cgroup_callbacks_done = 0;
16640 + struct vx_info *vxi;
16641 + struct nx_info *nxi;
16643 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
16644 return ERR_PTR(-EINVAL);
16645 @@ -1103,7 +1115,12 @@ static struct task_struct *copy_process(
16646 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
16647 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
16649 + init_vx_info(&p->vx_info, current_vx_info());
16650 + init_nx_info(&p->nx_info, current_nx_info());
16653 + if (!vx_nproc_avail(1))
16654 + goto bad_fork_free;
16655 if (atomic_read(&p->real_cred->user->processes) >=
16656 task_rlimit(p, RLIMIT_NPROC)) {
16657 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
16658 @@ -1360,6 +1377,18 @@ static struct task_struct *copy_process(
16661 spin_unlock(¤t->sighand->siglock);
16663 + /* p is copy of current */
16664 + vxi = p->vx_info;
16666 + claim_vx_info(vxi, p);
16667 + atomic_inc(&vxi->cvirt.nr_threads);
16668 + atomic_inc(&vxi->cvirt.total_forks);
16671 + nxi = p->nx_info;
16673 + claim_nx_info(nxi, p);
16674 write_unlock_irq(&tasklist_lock);
16675 proc_fork_connector(p);
16676 cgroup_post_fork(p);
16677 diff -NurpP --minimal linux-3.0/kernel/kthread.c linux-3.0-vs2.3.1-pre7/kernel/kthread.c
16678 --- linux-3.0/kernel/kthread.c 2011-07-22 11:18:12.000000000 +0200
16679 +++ linux-3.0-vs2.3.1-pre7/kernel/kthread.c 2011-06-10 22:11:24.000000000 +0200
16681 #include <linux/mutex.h>
16682 #include <linux/slab.h>
16683 #include <linux/freezer.h>
16684 +#include <linux/vs_pid.h>
16685 #include <trace/events/sched.h>
16687 static DEFINE_SPINLOCK(kthread_create_lock);
16688 diff -NurpP --minimal linux-3.0/kernel/nsproxy.c linux-3.0-vs2.3.1-pre7/kernel/nsproxy.c
16689 --- linux-3.0/kernel/nsproxy.c 2011-07-22 11:18:12.000000000 +0200
16690 +++ linux-3.0-vs2.3.1-pre7/kernel/nsproxy.c 2011-06-13 14:09:44.000000000 +0200
16692 #include <linux/mnt_namespace.h>
16693 #include <linux/utsname.h>
16694 #include <linux/pid_namespace.h>
16695 +#include <linux/vserver/global.h>
16696 +#include <linux/vserver/debug.h>
16697 #include <net/net_namespace.h>
16698 #include <linux/ipc_namespace.h>
16699 #include <linux/proc_fs.h>
16700 @@ -46,8 +48,11 @@ static inline struct nsproxy *create_nsp
16701 struct nsproxy *nsproxy;
16703 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
16706 atomic_set(&nsproxy->count, 1);
16707 + atomic_inc(&vs_global_nsproxy);
16709 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
16713 @@ -56,8 +61,11 @@ static inline struct nsproxy *create_nsp
16714 * Return the newly created nsproxy. Do not attach this to the task,
16715 * leave it to the caller to do proper locking and attach it to task.
16717 -static struct nsproxy *create_new_namespaces(unsigned long flags,
16718 - struct task_struct *tsk, struct fs_struct *new_fs)
16719 +static struct nsproxy *unshare_namespaces(unsigned long flags,
16720 + struct nsproxy *orig,
16721 + struct fs_struct *new_fs,
16722 + struct user_namespace *new_user,
16723 + struct pid_namespace *new_pid)
16725 struct nsproxy *new_nsp;
16727 @@ -66,31 +74,31 @@ static struct nsproxy *create_new_namesp
16729 return ERR_PTR(-ENOMEM);
16731 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
16732 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
16733 if (IS_ERR(new_nsp->mnt_ns)) {
16734 err = PTR_ERR(new_nsp->mnt_ns);
16738 - new_nsp->uts_ns = copy_utsname(flags, tsk);
16739 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns, new_user);
16740 if (IS_ERR(new_nsp->uts_ns)) {
16741 err = PTR_ERR(new_nsp->uts_ns);
16745 - new_nsp->ipc_ns = copy_ipcs(flags, tsk);
16746 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns, new_user);
16747 if (IS_ERR(new_nsp->ipc_ns)) {
16748 err = PTR_ERR(new_nsp->ipc_ns);
16752 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
16753 + new_nsp->pid_ns = copy_pid_ns(flags, new_pid);
16754 if (IS_ERR(new_nsp->pid_ns)) {
16755 err = PTR_ERR(new_nsp->pid_ns);
16759 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
16760 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
16761 if (IS_ERR(new_nsp->net_ns)) {
16762 err = PTR_ERR(new_nsp->net_ns);
16764 @@ -115,6 +123,40 @@ out_ns:
16765 return ERR_PTR(err);
16768 +static struct nsproxy *create_new_namespaces(unsigned long flags,
16769 + struct task_struct *tsk, struct fs_struct *new_fs)
16771 + return unshare_namespaces(flags, tsk->nsproxy,
16772 + new_fs, task_cred_xxx(tsk, user)->user_ns,
16773 + task_active_pid_ns(tsk));
16777 + * copies the nsproxy, setting refcount to 1, and grabbing a
16778 + * reference to all contained namespaces.
16780 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
16782 + struct nsproxy *ns = create_nsproxy();
16785 + memcpy(ns, orig, sizeof(struct nsproxy));
16786 + atomic_set(&ns->count, 1);
16789 + get_mnt_ns(ns->mnt_ns);
16791 + get_uts_ns(ns->uts_ns);
16793 + get_ipc_ns(ns->ipc_ns);
16795 + get_pid_ns(ns->pid_ns);
16797 + get_net(ns->net_ns);
16803 * called from clone. This now handles copy for nsproxy and all
16804 * namespaces therein.
16805 @@ -122,9 +164,12 @@ out_ns:
16806 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
16808 struct nsproxy *old_ns = tsk->nsproxy;
16809 - struct nsproxy *new_ns;
16810 + struct nsproxy *new_ns = NULL;
16813 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
16814 + flags, tsk, old_ns);
16819 @@ -134,7 +179,7 @@ int copy_namespaces(unsigned long flags,
16820 CLONE_NEWPID | CLONE_NEWNET)))
16823 - if (!capable(CAP_SYS_ADMIN)) {
16824 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
16828 @@ -161,6 +206,9 @@ int copy_namespaces(unsigned long flags,
16831 put_nsproxy(old_ns);
16832 + vxdprintk(VXD_CBIT(space, 3),
16833 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
16834 + flags, tsk, old_ns, err, new_ns);
16838 @@ -174,7 +222,9 @@ void free_nsproxy(struct nsproxy *ns)
16839 put_ipc_ns(ns->ipc_ns);
16841 put_pid_ns(ns->pid_ns);
16842 - put_net(ns->net_ns);
16844 + put_net(ns->net_ns);
16845 + atomic_dec(&vs_global_nsproxy);
16846 kmem_cache_free(nsproxy_cachep, ns);
16849 @@ -187,11 +237,15 @@ int unshare_nsproxy_namespaces(unsigned
16853 + vxdprintk(VXD_CBIT(space, 4),
16854 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
16855 + unshare_flags, current->nsproxy);
16857 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
16861 - if (!capable(CAP_SYS_ADMIN))
16862 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
16865 *new_nsp = create_new_namespaces(unshare_flags, current,
16866 diff -NurpP --minimal linux-3.0/kernel/pid.c linux-3.0-vs2.3.1-pre7/kernel/pid.c
16867 --- linux-3.0/kernel/pid.c 2011-05-22 16:17:59.000000000 +0200
16868 +++ linux-3.0-vs2.3.1-pre7/kernel/pid.c 2011-06-10 22:11:24.000000000 +0200
16870 #include <linux/pid_namespace.h>
16871 #include <linux/init_task.h>
16872 #include <linux/syscalls.h>
16873 +#include <linux/vs_pid.h>
16875 #define pid_hashfn(nr, ns) \
16876 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
16877 @@ -342,7 +343,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
16879 struct pid *find_vpid(int nr)
16881 - return find_pid_ns(nr, current->nsproxy->pid_ns);
16882 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
16884 EXPORT_SYMBOL_GPL(find_vpid);
16886 @@ -402,6 +403,9 @@ void transfer_pid(struct task_struct *ol
16887 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
16889 struct task_struct *result = NULL;
16891 + if (type == PIDTYPE_REALPID)
16892 + type = PIDTYPE_PID;
16894 struct hlist_node *first;
16895 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]),
16896 @@ -420,7 +424,7 @@ EXPORT_SYMBOL(pid_task);
16897 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
16899 rcu_lockdep_assert(rcu_read_lock_held());
16900 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
16901 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
16904 struct task_struct *find_task_by_vpid(pid_t vnr)
16905 @@ -464,7 +468,7 @@ struct pid *find_get_pid(pid_t nr)
16907 EXPORT_SYMBOL_GPL(find_get_pid);
16909 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
16910 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
16914 @@ -477,6 +481,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
16918 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
16920 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
16923 pid_t pid_vnr(struct pid *pid)
16925 return pid_nr_ns(pid, current->nsproxy->pid_ns);
16926 diff -NurpP --minimal linux-3.0/kernel/pid_namespace.c linux-3.0-vs2.3.1-pre7/kernel/pid_namespace.c
16927 --- linux-3.0/kernel/pid_namespace.c 2011-05-22 16:17:59.000000000 +0200
16928 +++ linux-3.0-vs2.3.1-pre7/kernel/pid_namespace.c 2011-06-10 22:17:45.000000000 +0200
16930 #include <linux/acct.h>
16931 #include <linux/slab.h>
16932 #include <linux/proc_fs.h>
16933 +#include <linux/vserver/global.h>
16935 #define BITS_PER_PAGE (PAGE_SIZE*8)
16937 @@ -88,6 +89,7 @@ static struct pid_namespace *create_pid_
16940 kref_init(&ns->kref);
16941 + atomic_inc(&vs_global_pid_ns);
16943 ns->parent = get_pid_ns(parent_pid_ns);
16945 @@ -119,6 +121,7 @@ static void destroy_pid_namespace(struct
16947 for (i = 0; i < PIDMAP_ENTRIES; i++)
16948 kfree(ns->pidmap[i].page);
16949 + atomic_dec(&vs_global_pid_ns);
16950 kmem_cache_free(pid_ns_cachep, ns);
16953 diff -NurpP --minimal linux-3.0/kernel/posix-timers.c linux-3.0-vs2.3.1-pre7/kernel/posix-timers.c
16954 --- linux-3.0/kernel/posix-timers.c 2011-07-22 11:18:12.000000000 +0200
16955 +++ linux-3.0-vs2.3.1-pre7/kernel/posix-timers.c 2011-06-10 22:11:24.000000000 +0200
16957 #include <linux/wait.h>
16958 #include <linux/workqueue.h>
16959 #include <linux/module.h>
16960 +#include <linux/vs_context.h>
16963 * Management arrays for POSIX timers. Timers are kept in slab memory
16964 @@ -340,6 +341,7 @@ int posix_timer_event(struct k_itimer *t
16966 struct task_struct *task;
16967 int shared, ret = -1;
16970 * FIXME: if ->sigq is queued we can race with
16971 * dequeue_signal()->do_schedule_next_timer().
16972 @@ -356,10 +358,18 @@ int posix_timer_event(struct k_itimer *t
16974 task = pid_task(timr->it_pid, PIDTYPE_PID);
16976 + struct vx_info_save vxis;
16977 + struct vx_info *vxi;
16979 + vxi = get_vx_info(task->vx_info);
16980 + enter_vx_info(vxi, &vxis);
16981 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
16982 ret = send_sigqueue(timr->sigq, task, shared);
16983 + leave_vx_info(&vxis);
16984 + put_vx_info(vxi);
16988 /* If we failed to send the signal the timer stops. */
16991 diff -NurpP --minimal linux-3.0/kernel/printk.c linux-3.0-vs2.3.1-pre7/kernel/printk.c
16992 --- linux-3.0/kernel/printk.c 2011-07-22 11:18:12.000000000 +0200
16993 +++ linux-3.0-vs2.3.1-pre7/kernel/printk.c 2011-06-10 22:11:24.000000000 +0200
16995 #include <linux/cpu.h>
16996 #include <linux/notifier.h>
16997 #include <linux/rculist.h>
16998 +#include <linux/vs_cvirt.h>
17000 #include <asm/uaccess.h>
17002 @@ -314,7 +315,7 @@ static int check_syslog_permissions(int
17005 if (syslog_action_restricted(type)) {
17006 - if (capable(CAP_SYSLOG))
17007 + if (vx_capable(CAP_SYSLOG, VXC_SYSLOG))
17009 /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */
17010 if (capable(CAP_SYS_ADMIN)) {
17011 @@ -342,12 +343,9 @@ int do_syslog(int type, char __user *buf
17016 - case SYSLOG_ACTION_CLOSE: /* Close log */
17018 - case SYSLOG_ACTION_OPEN: /* Open log */
17020 - case SYSLOG_ACTION_READ: /* Read from log */
17021 + if ((type == SYSLOG_ACTION_READ) ||
17022 + (type == SYSLOG_ACTION_READ_ALL) ||
17023 + (type == SYSLOG_ACTION_READ_CLEAR)) {
17025 if (!buf || len < 0)
17027 @@ -358,6 +356,16 @@ int do_syslog(int type, char __user *buf
17032 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
17033 + return vx_do_syslog(type, buf, len);
17036 + case SYSLOG_ACTION_CLOSE: /* Close log */
17038 + case SYSLOG_ACTION_OPEN: /* Open log */
17040 + case SYSLOG_ACTION_READ: /* Read from log */
17041 error = wait_event_interruptible(log_wait,
17042 (log_start - log_end));
17044 @@ -384,16 +392,6 @@ int do_syslog(int type, char __user *buf
17046 /* Read last kernel messages */
17047 case SYSLOG_ACTION_READ_ALL:
17049 - if (!buf || len < 0)
17054 - if (!access_ok(VERIFY_WRITE, buf, len)) {
17059 if (count > log_buf_len)
17060 count = log_buf_len;
17061 diff -NurpP --minimal linux-3.0/kernel/ptrace.c linux-3.0-vs2.3.1-pre7/kernel/ptrace.c
17062 --- linux-3.0/kernel/ptrace.c 2011-07-22 11:18:12.000000000 +0200
17063 +++ linux-3.0-vs2.3.1-pre7/kernel/ptrace.c 2011-06-10 22:11:24.000000000 +0200
17065 #include <linux/syscalls.h>
17066 #include <linux/uaccess.h>
17067 #include <linux/regset.h>
17068 +#include <linux/vs_context.h>
17069 #include <linux/hw_breakpoint.h>
17072 @@ -169,6 +170,11 @@ ok:
17073 dumpable = get_dumpable(task->mm);
17074 if (!dumpable && !task_ns_capable(task, CAP_SYS_PTRACE))
17076 + if (!vx_check(task->xid, VS_ADMIN_P|VS_WATCH_P|VS_IDENT))
17078 + if (!vx_check(task->xid, VS_IDENT) &&
17079 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
17082 return security_ptrace_access_check(task, mode);
17084 diff -NurpP --minimal linux-3.0/kernel/sched.c linux-3.0-vs2.3.1-pre7/kernel/sched.c
17085 --- linux-3.0/kernel/sched.c 2011-07-22 11:18:12.000000000 +0200
17086 +++ linux-3.0-vs2.3.1-pre7/kernel/sched.c 2011-07-22 11:20:39.000000000 +0200
17088 #include <linux/ctype.h>
17089 #include <linux/ftrace.h>
17090 #include <linux/slab.h>
17091 +#include <linux/vs_sched.h>
17092 +#include <linux/vs_cvirt.h>
17094 #include <asm/tlb.h>
17095 #include <asm/irq_regs.h>
17096 @@ -3461,9 +3463,17 @@ static void calc_global_nohz(unsigned lo
17098 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
17100 - loads[0] = (avenrun[0] + offset) << shift;
17101 - loads[1] = (avenrun[1] + offset) << shift;
17102 - loads[2] = (avenrun[2] + offset) << shift;
17103 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
17104 + struct vx_info *vxi = current_vx_info();
17106 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
17107 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
17108 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
17110 + loads[0] = (avenrun[0] + offset) << shift;
17111 + loads[1] = (avenrun[1] + offset) << shift;
17112 + loads[2] = (avenrun[2] + offset) << shift;
17117 @@ -3746,16 +3756,19 @@ void account_user_time(struct task_struc
17118 cputime_t cputime_scaled)
17120 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
17121 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
17123 + int nice = (TASK_NICE(p) > 0);
17125 /* Add user time to process. */
17126 p->utime = cputime_add(p->utime, cputime);
17127 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
17128 + vx_account_user(vxi, cputime, nice);
17129 account_group_user_time(p, cputime);
17131 /* Add user time to cpustat. */
17132 tmp = cputime_to_cputime64(cputime);
17133 - if (TASK_NICE(p) > 0)
17135 cpustat->nice = cputime64_add(cpustat->nice, tmp);
17137 cpustat->user = cputime64_add(cpustat->user, tmp);
17138 @@ -3807,10 +3820,12 @@ void __account_system_time(struct task_s
17139 cputime_t cputime_scaled, cputime64_t *target_cputime64)
17141 cputime64_t tmp = cputime_to_cputime64(cputime);
17142 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
17144 /* Add system time to process. */
17145 p->stime = cputime_add(p->stime, cputime);
17146 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
17147 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
17148 account_group_system_time(p, cputime);
17150 /* Add system time to cpustat. */
17151 @@ -4968,7 +4983,7 @@ SYSCALL_DEFINE1(nice, int, increment)
17154 if (increment < 0 && !can_nice(current, nice))
17156 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
17158 retval = security_task_setnice(current, nice);
17160 diff -NurpP --minimal linux-3.0/kernel/sched_fair.c linux-3.0-vs2.3.1-pre7/kernel/sched_fair.c
17161 --- linux-3.0/kernel/sched_fair.c 2011-07-22 11:18:12.000000000 +0200
17162 +++ linux-3.0-vs2.3.1-pre7/kernel/sched_fair.c 2011-07-22 11:20:39.000000000 +0200
17163 @@ -998,6 +998,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
17164 __enqueue_entity(cfs_rq, se);
17167 + if (entity_is_task(se))
17168 + vx_activate_task(task_of(se));
17169 if (cfs_rq->nr_running == 1)
17170 list_add_leaf_cfs_rq(cfs_rq);
17172 @@ -1074,6 +1076,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
17173 if (se != cfs_rq->curr)
17174 __dequeue_entity(cfs_rq, se);
17176 + if (entity_is_task(se))
17177 + vx_deactivate_task(task_of(se));
17178 update_cfs_load(cfs_rq, 0);
17179 account_entity_dequeue(cfs_rq, se);
17181 diff -NurpP --minimal linux-3.0/kernel/signal.c linux-3.0-vs2.3.1-pre7/kernel/signal.c
17182 --- linux-3.0/kernel/signal.c 2011-07-22 11:18:12.000000000 +0200
17183 +++ linux-3.0-vs2.3.1-pre7/kernel/signal.c 2011-07-22 11:20:39.000000000 +0200
17185 #include <linux/freezer.h>
17186 #include <linux/pid_namespace.h>
17187 #include <linux/nsproxy.h>
17188 +#include <linux/vs_context.h>
17189 +#include <linux/vs_pid.h>
17190 #define CREATE_TRACE_POINTS
17191 #include <trace/events/signal.h>
17193 @@ -744,9 +746,18 @@ static int check_kill_permission(int sig
17197 + vxdprintk(VXD_CBIT(misc, 7),
17198 + "check_kill_permission(%d,%p,%p[#%u,%u])",
17199 + sig, info, t, vx_task_xid(t), t->pid);
17201 if (!valid_signal(sig))
17204 +/* FIXME: needed? if so, why?
17205 + if ((info != SEND_SIG_NOINFO) &&
17206 + (is_si_special(info) || !si_fromuser(info)))
17209 if (!si_fromuser(info))
17212 @@ -770,6 +781,20 @@ static int check_kill_permission(int sig
17217 + if (t->pid == 1 && current->xid)
17221 + /* FIXME: we shouldn't return ESRCH ever, to avoid
17222 + loops, maybe ENOENT or EACCES? */
17223 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
17224 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
17225 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
17226 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
17230 return security_task_kill(t, info, sig, 0);
17233 @@ -1246,7 +1271,7 @@ int kill_pid_info(int sig, struct siginf
17236 p = pid_task(pid, PIDTYPE_PID);
17238 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
17239 error = group_send_sig_info(sig, info, p);
17240 if (unlikely(error == -ESRCH))
17242 @@ -1285,7 +1310,7 @@ int kill_pid_info_as_uid(int sig, struct
17245 p = pid_task(pid, PIDTYPE_PID);
17247 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
17251 @@ -1340,8 +1365,10 @@ static int kill_something_info(int sig,
17252 struct task_struct * p;
17254 for_each_process(p) {
17255 - if (task_pid_vnr(p) > 1 &&
17256 - !same_thread_group(p, current)) {
17257 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
17258 + task_pid_vnr(p) > 1 &&
17259 + !same_thread_group(p, current) &&
17260 + !vx_current_initpid(p->pid)) {
17261 int err = group_send_sig_info(sig, info, p);
17264 @@ -2140,6 +2167,11 @@ relock:
17265 !sig_kernel_only(signr))
17268 + /* virtual init is protected against user signals */
17269 + if ((info->si_code == SI_USER) &&
17270 + vx_current_initpid(current->pid))
17273 if (sig_kernel_stop(signr)) {
17275 * The default action is to stop all threads in
17276 diff -NurpP --minimal linux-3.0/kernel/softirq.c linux-3.0-vs2.3.1-pre7/kernel/softirq.c
17277 --- linux-3.0/kernel/softirq.c 2011-07-22 11:18:12.000000000 +0200
17278 +++ linux-3.0-vs2.3.1-pre7/kernel/softirq.c 2011-07-22 11:20:39.000000000 +0200
17280 #include <linux/ftrace.h>
17281 #include <linux/smp.h>
17282 #include <linux/tick.h>
17283 +#include <linux/vs_context.h>
17285 #define CREATE_TRACE_POINTS
17286 #include <trace/events/irq.h>
17287 diff -NurpP --minimal linux-3.0/kernel/sys.c linux-3.0-vs2.3.1-pre7/kernel/sys.c
17288 --- linux-3.0/kernel/sys.c 2011-07-22 11:18:12.000000000 +0200
17289 +++ linux-3.0-vs2.3.1-pre7/kernel/sys.c 2011-07-23 15:55:50.000000000 +0200
17291 #include <linux/syscalls.h>
17292 #include <linux/kprobes.h>
17293 #include <linux/user_namespace.h>
17294 +#include <linux/vs_pid.h>
17296 #include <linux/kmsg_dump.h>
17298 @@ -151,7 +152,10 @@ static int set_one_prio(struct task_stru
17301 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
17303 + if (vx_flags(VXF_IGNEG_NICE, 0))
17309 no_nice = security_task_setnice(p, niceval);
17310 @@ -201,6 +205,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
17312 pgrp = task_pgrp(current);
17313 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17314 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17316 error = set_one_prio(p, niceval, error);
17317 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
17319 @@ -264,6 +270,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
17321 pgrp = task_pgrp(current);
17322 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
17323 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
17325 niceval = 20 - task_nice(p);
17326 if (niceval > retval)
17328 @@ -383,6 +391,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
17330 static DEFINE_MUTEX(reboot_mutex);
17332 +long vs_reboot(unsigned int, void __user *);
17335 * Reboot system call: for obvious reasons only root may call it,
17336 * and even root needs to set up some magic numbers in the registers
17337 @@ -415,6 +425,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
17338 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
17339 cmd = LINUX_REBOOT_CMD_HALT;
17341 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
17342 + return vs_reboot(cmd, arg);
17344 mutex_lock(&reboot_mutex);
17346 case LINUX_REBOOT_CMD_RESTART:
17347 @@ -1197,7 +1210,8 @@ SYSCALL_DEFINE2(sethostname, char __user
17349 char tmp[__NEW_UTS_LEN];
17351 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
17352 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
17353 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17356 if (len < 0 || len > __NEW_UTS_LEN)
17357 @@ -1247,7 +1261,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
17359 char tmp[__NEW_UTS_LEN];
17361 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
17362 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
17363 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
17365 if (len < 0 || len > __NEW_UTS_LEN)
17367 @@ -1365,7 +1380,7 @@ int do_prlimit(struct task_struct *tsk,
17368 /* Keep the capable check against init_user_ns until
17369 cgroups can contain all limits */
17370 if (new_rlim->rlim_max > rlim->rlim_max &&
17371 - !capable(CAP_SYS_RESOURCE))
17372 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
17375 retval = security_task_setrlimit(tsk->group_leader,
17376 @@ -1419,7 +1434,8 @@ static int check_prlimit_permission(stru
17377 cred->gid == tcred->sgid &&
17378 cred->gid == tcred->gid))
17380 - if (ns_capable(tcred->user->user_ns, CAP_SYS_RESOURCE))
17381 + if (vx_ns_capable(tcred->user->user_ns,
17382 + CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
17386 diff -NurpP --minimal linux-3.0/kernel/sysctl.c linux-3.0-vs2.3.1-pre7/kernel/sysctl.c
17387 --- linux-3.0/kernel/sysctl.c 2011-07-22 11:18:12.000000000 +0200
17388 +++ linux-3.0-vs2.3.1-pre7/kernel/sysctl.c 2011-06-15 02:40:14.000000000 +0200
17390 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
17391 #include <linux/lockdep.h>
17393 +extern char vshelper_path[];
17394 #ifdef CONFIG_CHR_DEV_SG
17395 #include <scsi/sg.h>
17397 @@ -568,6 +569,13 @@ static struct ctl_table kern_table[] = {
17398 .proc_handler = proc_dostring,
17402 + .procname = "vshelper",
17403 + .data = &vshelper_path,
17406 + .proc_handler = &proc_dostring,
17408 #ifdef CONFIG_CHR_DEV_SG
17410 .procname = "sg-big-buff",
17411 diff -NurpP --minimal linux-3.0/kernel/sysctl_binary.c linux-3.0-vs2.3.1-pre7/kernel/sysctl_binary.c
17412 --- linux-3.0/kernel/sysctl_binary.c 2011-05-22 16:17:59.000000000 +0200
17413 +++ linux-3.0-vs2.3.1-pre7/kernel/sysctl_binary.c 2011-06-10 22:11:24.000000000 +0200
17414 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
17416 { CTL_INT, KERN_PANIC, "panic" },
17417 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
17418 + { CTL_STR, KERN_VSHELPER, "vshelper" },
17420 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
17421 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
17422 diff -NurpP --minimal linux-3.0/kernel/time/timekeeping.c linux-3.0-vs2.3.1-pre7/kernel/time/timekeeping.c
17423 --- linux-3.0/kernel/time/timekeeping.c 2011-07-22 11:18:12.000000000 +0200
17424 +++ linux-3.0-vs2.3.1-pre7/kernel/time/timekeeping.c 2011-06-10 22:11:24.000000000 +0200
17425 @@ -233,6 +233,7 @@ void getnstimeofday(struct timespec *ts)
17426 } while (read_seqretry(&xtime_lock, seq));
17428 timespec_add_ns(ts, nsecs);
17429 + vx_adjust_timespec(ts);
17432 EXPORT_SYMBOL(getnstimeofday);
17433 diff -NurpP --minimal linux-3.0/kernel/time.c linux-3.0-vs2.3.1-pre7/kernel/time.c
17434 --- linux-3.0/kernel/time.c 2011-05-22 16:17:59.000000000 +0200
17435 +++ linux-3.0-vs2.3.1-pre7/kernel/time.c 2011-06-10 22:11:24.000000000 +0200
17436 @@ -92,7 +92,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
17440 - do_settimeofday(&tv);
17441 + vx_settimeofday(&tv);
17445 @@ -177,7 +177,7 @@ int do_sys_settimeofday(const struct tim
17446 /* SMP safe, again the code in arch/foo/time.c should
17447 * globally block out interrupts when it runs.
17449 - return do_settimeofday(tv);
17450 + return vx_settimeofday(tv);
17454 diff -NurpP --minimal linux-3.0/kernel/timer.c linux-3.0-vs2.3.1-pre7/kernel/timer.c
17455 --- linux-3.0/kernel/timer.c 2011-07-22 11:18:12.000000000 +0200
17456 +++ linux-3.0-vs2.3.1-pre7/kernel/timer.c 2011-06-15 02:40:14.000000000 +0200
17458 #include <linux/irq_work.h>
17459 #include <linux/sched.h>
17460 #include <linux/slab.h>
17461 +#include <linux/vs_base.h>
17462 +#include <linux/vs_cvirt.h>
17463 +#include <linux/vs_pid.h>
17464 +#include <linux/vserver/sched.h>
17466 #include <asm/uaccess.h>
17467 #include <asm/unistd.h>
17468 @@ -1336,12 +1340,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
17475 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
17476 - * should be moved into arch/i386 instead?
17480 * sys_getpid - return the thread group id of the current process
17481 @@ -1370,10 +1368,23 @@ SYSCALL_DEFINE0(getppid)
17483 pid = task_tgid_vnr(current->real_parent);
17485 + return vx_map_pid(pid);
17492 + * The Alpha uses getxpid, getxuid, and getxgid instead.
17495 +asmlinkage long do_getxpid(long *ppid)
17497 + *ppid = sys_getppid();
17498 + return sys_getpid();
17501 +#else /* _alpha_ */
17503 SYSCALL_DEFINE0(getuid)
17505 /* Only we change this so SMP safe */
17506 diff -NurpP --minimal linux-3.0/kernel/user_namespace.c linux-3.0-vs2.3.1-pre7/kernel/user_namespace.c
17507 --- linux-3.0/kernel/user_namespace.c 2011-03-15 18:07:42.000000000 +0100
17508 +++ linux-3.0-vs2.3.1-pre7/kernel/user_namespace.c 2011-06-10 22:11:24.000000000 +0200
17510 #include <linux/user_namespace.h>
17511 #include <linux/highuid.h>
17512 #include <linux/cred.h>
17513 +#include <linux/vserver/global.h>
17515 static struct kmem_cache *user_ns_cachep __read_mostly;
17517 @@ -33,6 +34,7 @@ int create_user_ns(struct cred *new)
17520 kref_init(&ns->kref);
17521 + atomic_inc(&vs_global_user_ns);
17523 for (n = 0; n < UIDHASH_SZ; ++n)
17524 INIT_HLIST_HEAD(ns->uidhash_table + n);
17525 @@ -81,6 +83,8 @@ void free_user_ns(struct kref *kref)
17526 struct user_namespace *ns =
17527 container_of(kref, struct user_namespace, kref);
17529 + /* FIXME: maybe move into destroyer? */
17530 + atomic_dec(&vs_global_user_ns);
17531 INIT_WORK(&ns->destroyer, free_user_ns_work);
17532 schedule_work(&ns->destroyer);
17534 diff -NurpP --minimal linux-3.0/kernel/utsname.c linux-3.0-vs2.3.1-pre7/kernel/utsname.c
17535 --- linux-3.0/kernel/utsname.c 2011-07-22 11:18:12.000000000 +0200
17536 +++ linux-3.0-vs2.3.1-pre7/kernel/utsname.c 2011-06-13 14:09:44.000000000 +0200
17537 @@ -16,14 +16,17 @@
17538 #include <linux/slab.h>
17539 #include <linux/user_namespace.h>
17540 #include <linux/proc_fs.h>
17541 +#include <linux/vserver/global.h>
17543 static struct uts_namespace *create_uts_ns(void)
17545 struct uts_namespace *uts_ns;
17547 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
17550 kref_init(&uts_ns->kref);
17551 + atomic_inc(&vs_global_uts_ns);
17556 @@ -32,8 +35,8 @@ static struct uts_namespace *create_uts_
17557 * @old_ns: namespace to clone
17558 * Return NULL on error (failure to kmalloc), new ns otherwise
17560 -static struct uts_namespace *clone_uts_ns(struct task_struct *tsk,
17561 - struct uts_namespace *old_ns)
17562 +static struct uts_namespace *clone_uts_ns(struct uts_namespace *old_ns,
17563 + struct user_namespace *old_user)
17565 struct uts_namespace *ns;
17567 @@ -43,7 +46,7 @@ static struct uts_namespace *clone_uts_n
17569 down_read(&uts_sem);
17570 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
17571 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
17572 + ns->user_ns = get_user_ns(old_user);
17576 @@ -55,9 +58,9 @@ static struct uts_namespace *clone_uts_n
17579 struct uts_namespace *copy_utsname(unsigned long flags,
17580 - struct task_struct *tsk)
17581 + struct uts_namespace *old_ns,
17582 + struct user_namespace *user_ns)
17584 - struct uts_namespace *old_ns = tsk->nsproxy->uts_ns;
17585 struct uts_namespace *new_ns;
17588 @@ -66,7 +69,7 @@ struct uts_namespace *copy_utsname(unsig
17589 if (!(flags & CLONE_NEWUTS))
17592 - new_ns = clone_uts_ns(tsk, old_ns);
17593 + new_ns = clone_uts_ns(old_ns, user_ns);
17595 put_uts_ns(old_ns);
17597 @@ -78,6 +81,7 @@ void free_uts_ns(struct kref *kref)
17599 ns = container_of(kref, struct uts_namespace, kref);
17600 put_user_ns(ns->user_ns);
17601 + atomic_dec(&vs_global_uts_ns);
17605 diff -NurpP --minimal linux-3.0/kernel/vserver/Kconfig linux-3.0-vs2.3.1-pre7/kernel/vserver/Kconfig
17606 --- linux-3.0/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
17607 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/Kconfig 2011-07-20 02:15:23.000000000 +0200
17610 +# Linux VServer configuration
17613 +menu "Linux VServer"
17615 +config VSERVER_AUTO_LBACK
17616 + bool "Automatically Assign Loopback IP"
17619 + Automatically assign a guest specific loopback
17620 + IP and add it to the kernel network stack on
17623 +config VSERVER_AUTO_SINGLE
17624 + bool "Automatic Single IP Special Casing"
17625 + depends on EXPERIMENTAL
17628 + This allows network contexts with a single IP to
17629 + automatically remap 0.0.0.0 bindings to that IP,
17630 + avoiding further network checks and improving
17633 + (note: such guests do not allow to change the ip
17634 + on the fly and do not show loopback addresses)
17636 +config VSERVER_COWBL
17637 + bool "Enable COW Immutable Link Breaking"
17640 + This enables the COW (Copy-On-Write) link break code.
17641 + It allows you to treat unified files like normal files
17642 + when writing to them (which will implicitely break the
17643 + link and create a copy of the unified file)
17645 +config VSERVER_VTIME
17646 + bool "Enable Virtualized Guest Time"
17647 + depends on EXPERIMENTAL
17650 + This enables per guest time offsets to allow for
17651 + adjusting the system clock individually per guest.
17652 + this adds some overhead to the time functions and
17653 + therefore should not be enabled without good reason.
17655 +config VSERVER_DEVICE
17656 + bool "Enable Guest Device Mapping"
17657 + depends on EXPERIMENTAL
17660 + This enables generic device remapping.
17662 +config VSERVER_PROC_SECURE
17663 + bool "Enable Proc Security"
17664 + depends on PROC_FS
17667 + This configures ProcFS security to initially hide
17668 + non-process entries for all contexts except the main and
17669 + spectator context (i.e. for all guests), which is a secure
17672 + (note: on 1.2x the entries were visible by default)
17675 + prompt "Persistent Inode Tagging"
17676 + default TAGGING_ID24
17678 + This adds persistent context information to filesystems
17679 + mounted with the tagxid option. Tagging is a requirement
17680 + for per-context disk limits and per-context quota.
17683 +config TAGGING_NONE
17686 + do not store per-context information in inodes.
17688 +config TAGGING_UID16
17689 + bool "UID16/GID32"
17691 + reduces UID to 16 bit, but leaves GID at 32 bit.
17693 +config TAGGING_GID16
17694 + bool "UID32/GID16"
17696 + reduces GID to 16 bit, but leaves UID at 32 bit.
17698 +config TAGGING_ID24
17699 + bool "UID24/GID24"
17701 + uses the upper 8bit from UID and GID for XID tagging
17702 + which leaves 24bit for UID/GID each, which should be
17703 + more than sufficient for normal use.
17705 +config TAGGING_INTERN
17706 + bool "UID32/GID32"
17708 + this uses otherwise reserved inode fields in the on
17709 + disk representation, which limits the use to a few
17710 + filesystems (currently ext2 and ext3)
17715 + bool "Tag NFSD User Auth and Files"
17718 + Enable this if you do want the in-kernel NFS
17719 + Server to use the tagging specified above.
17720 + (will require patched clients too)
17722 +config VSERVER_PRIVACY
17723 + bool "Honor Privacy Aspects of Guests"
17726 + When enabled, most context checks will disallow
17727 + access to structures assigned to a specific context,
17728 + like ptys or loop devices.
17730 +config VSERVER_CONTEXTS
17731 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
17733 + default "768" if 64BIT
17736 + This setting will optimize certain data structures
17737 + and memory allocations according to the expected
17740 + note: this is not a strict upper limit.
17742 +config VSERVER_WARN
17743 + bool "VServer Warnings"
17746 + This enables various runtime warnings, which will
17747 + notify about potential manipulation attempts or
17748 + resource shortage. It is generally considered to
17749 + be a good idea to have that enabled.
17751 +config VSERVER_WARN_DEVPTS
17752 + bool "VServer DevPTS Warnings"
17753 + depends on VSERVER_WARN
17756 + This enables DevPTS related warnings, issued when a
17757 + process inside a context tries to lookup or access
17758 + a dynamic pts from the host or a different context.
17760 +config VSERVER_DEBUG
17761 + bool "VServer Debugging Code"
17764 + Set this to yes if you want to be able to activate
17765 + debugging output at runtime. It adds a very small
17766 + overhead to all vserver related functions and
17767 + increases the kernel size by about 20k.
17769 +config VSERVER_HISTORY
17770 + bool "VServer History Tracing"
17771 + depends on VSERVER_DEBUG
17774 + Set this to yes if you want to record the history of
17775 + linux-vserver activities, so they can be replayed in
17776 + the event of a kernel panic or oops.
17778 +config VSERVER_HISTORY_SIZE
17779 + int "Per-CPU History Size (32-65536)"
17780 + depends on VSERVER_HISTORY
17784 + This allows you to specify the number of entries in
17785 + the per-CPU history buffer.
17787 +config VSERVER_LEGACY_MEM
17788 + bool "Legacy Memory Limits"
17791 + This provides fake memory limits to keep
17792 + older tools happy in the face of memory
17796 + prompt "Quotes used in debug and warn messages"
17797 + default QUOTES_ISO8859
17799 +config QUOTES_ISO8859
17800 + bool "Extended ASCII (ISO 8859) angle quotes"
17802 + This uses the extended ASCII characters \xbb
17803 + and \xab for quoting file and process names.
17805 +config QUOTES_UTF8
17806 + bool "UTF-8 angle quotes"
17808 + This uses the the UTF-8 sequences for angle
17809 + quotes to quote file and process names.
17811 +config QUOTES_ASCII
17812 + bool "ASCII single quotes"
17814 + This uses the ASCII single quote character
17815 + (\x27) to quote file and process names.
17825 + select NAMESPACES
17831 +config VSERVER_SECURITY
17833 + depends on SECURITY
17835 + select SECURITY_CAPABILITIES
17837 diff -NurpP --minimal linux-3.0/kernel/vserver/Makefile linux-3.0-vs2.3.1-pre7/kernel/vserver/Makefile
17838 --- linux-3.0/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
17839 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/Makefile 2011-06-10 22:11:24.000000000 +0200
17842 +# Makefile for the Linux vserver routines.
17846 +obj-y += vserver.o
17848 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
17849 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
17852 +vserver-$(CONFIG_INET) += inet.o
17853 +vserver-$(CONFIG_PROC_FS) += proc.o
17854 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
17855 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
17856 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
17857 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
17859 diff -NurpP --minimal linux-3.0/kernel/vserver/cacct.c linux-3.0-vs2.3.1-pre7/kernel/vserver/cacct.c
17860 --- linux-3.0/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
17861 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/cacct.c 2011-06-10 22:11:24.000000000 +0200
17864 + * linux/kernel/vserver/cacct.c
17866 + * Virtual Server: Context Accounting
17868 + * Copyright (C) 2006-2007 Herbert Pötzl
17870 + * V0.01 added accounting stats
17874 +#include <linux/types.h>
17875 +#include <linux/vs_context.h>
17876 +#include <linux/vserver/cacct_cmd.h>
17877 +#include <linux/vserver/cacct_int.h>
17879 +#include <asm/errno.h>
17880 +#include <asm/uaccess.h>
17883 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
17885 + struct vcmd_sock_stat_v0 vc_data;
17888 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17891 + field = vc_data.field;
17892 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
17895 + for (j = 0; j < 3; j++) {
17896 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
17897 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
17900 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17905 diff -NurpP --minimal linux-3.0/kernel/vserver/cacct_init.h linux-3.0-vs2.3.1-pre7/kernel/vserver/cacct_init.h
17906 --- linux-3.0/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
17907 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/cacct_init.h 2011-06-10 22:11:24.000000000 +0200
17911 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
17916 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
17917 + for (j = 0; j < 3; j++) {
17918 + atomic_long_set(&cacct->sock[i][j].count, 0);
17919 + atomic_long_set(&cacct->sock[i][j].total, 0);
17922 + for (i = 0; i < 8; i++)
17923 + atomic_set(&cacct->slab[i], 0);
17924 + for (i = 0; i < 5; i++)
17925 + for (j = 0; j < 4; j++)
17926 + atomic_set(&cacct->page[i][j], 0);
17929 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
17934 diff -NurpP --minimal linux-3.0/kernel/vserver/cacct_proc.h linux-3.0-vs2.3.1-pre7/kernel/vserver/cacct_proc.h
17935 --- linux-3.0/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
17936 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/cacct_proc.h 2011-06-10 22:11:24.000000000 +0200
17938 +#ifndef _VX_CACCT_PROC_H
17939 +#define _VX_CACCT_PROC_H
17941 +#include <linux/vserver/cacct_int.h>
17944 +#define VX_SOCKA_TOP \
17945 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
17947 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
17949 + int i, j, length = 0;
17950 + static char *type[VXA_SOCK_SIZE] = {
17951 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
17954 + length += sprintf(buffer + length, VX_SOCKA_TOP);
17955 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
17956 + length += sprintf(buffer + length, "%s:", type[i]);
17957 + for (j = 0; j < 3; j++) {
17958 + length += sprintf(buffer + length,
17959 + "\t%10lu/%-10lu",
17960 + vx_sock_count(cacct, i, j),
17961 + vx_sock_total(cacct, i, j));
17963 + buffer[length++] = '\n';
17966 + length += sprintf(buffer + length, "\n");
17967 + length += sprintf(buffer + length,
17968 + "slab:\t %8u %8u %8u %8u\n",
17969 + atomic_read(&cacct->slab[1]),
17970 + atomic_read(&cacct->slab[4]),
17971 + atomic_read(&cacct->slab[0]),
17972 + atomic_read(&cacct->slab[2]));
17974 + length += sprintf(buffer + length, "\n");
17975 + for (i = 0; i < 5; i++) {
17976 + length += sprintf(buffer + length,
17977 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
17978 + atomic_read(&cacct->page[i][0]),
17979 + atomic_read(&cacct->page[i][1]),
17980 + atomic_read(&cacct->page[i][2]),
17981 + atomic_read(&cacct->page[i][3]),
17982 + atomic_read(&cacct->page[i][4]),
17983 + atomic_read(&cacct->page[i][5]),
17984 + atomic_read(&cacct->page[i][6]),
17985 + atomic_read(&cacct->page[i][7]));
17990 +#endif /* _VX_CACCT_PROC_H */
17991 diff -NurpP --minimal linux-3.0/kernel/vserver/context.c linux-3.0-vs2.3.1-pre7/kernel/vserver/context.c
17992 --- linux-3.0/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
17993 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/context.c 2011-07-19 19:22:49.000000000 +0200
17996 + * linux/kernel/vserver/context.c
17998 + * Virtual Server: Context Support
18000 + * Copyright (C) 2003-2010 Herbert Pötzl
18002 + * V0.01 context helper
18003 + * V0.02 vx_ctx_kill syscall command
18004 + * V0.03 replaced context_info calls
18005 + * V0.04 redesign of struct (de)alloc
18006 + * V0.05 rlimit basic implementation
18007 + * V0.06 task_xid and info commands
18008 + * V0.07 context flags and caps
18009 + * V0.08 switch to RCU based hash
18010 + * V0.09 revert to non RCU for now
18011 + * V0.10 and back to working RCU hash
18012 + * V0.11 and back to locking again
18013 + * V0.12 referenced context store
18014 + * V0.13 separate per cpu data
18015 + * V0.14 changed vcmds to vxi arg
18016 + * V0.15 added context stat
18017 + * V0.16 have __create claim() the vxi
18018 + * V0.17 removed older and legacy stuff
18019 + * V0.18 added user credentials
18023 +#include <linux/slab.h>
18024 +#include <linux/types.h>
18025 +#include <linux/security.h>
18026 +#include <linux/pid_namespace.h>
18027 +#include <linux/capability.h>
18029 +#include <linux/vserver/context.h>
18030 +#include <linux/vserver/network.h>
18031 +#include <linux/vserver/debug.h>
18032 +#include <linux/vserver/limit.h>
18033 +#include <linux/vserver/limit_int.h>
18034 +#include <linux/vserver/space.h>
18035 +#include <linux/init_task.h>
18036 +#include <linux/fs_struct.h>
18037 +#include <linux/cred.h>
18039 +#include <linux/vs_context.h>
18040 +#include <linux/vs_limit.h>
18041 +#include <linux/vs_pid.h>
18042 +#include <linux/vserver/context_cmd.h>
18044 +#include "cvirt_init.h"
18045 +#include "cacct_init.h"
18046 +#include "limit_init.h"
18047 +#include "sched_init.h"
18050 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
18051 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
18054 +/* now inactive context structures */
18056 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
18058 +static DEFINE_SPINLOCK(vx_info_inactive_lock);
18061 +/* __alloc_vx_info()
18063 + * allocate an initialized vx_info struct
18064 + * doesn't make it visible (hash) */
18066 +static struct vx_info *__alloc_vx_info(xid_t xid)
18068 + struct vx_info *new = NULL;
18071 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
18073 + /* would this benefit from a slab cache? */
18074 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
18078 + memset(new, 0, sizeof(struct vx_info));
18080 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
18081 + if (!new->ptr_pc)
18084 + new->vx_id = xid;
18085 + INIT_HLIST_NODE(&new->vx_hlist);
18086 + atomic_set(&new->vx_usecnt, 0);
18087 + atomic_set(&new->vx_tasks, 0);
18088 + new->vx_parent = NULL;
18089 + new->vx_state = 0;
18090 + init_waitqueue_head(&new->vx_wait);
18092 + /* prepare reaper */
18093 + get_task_struct(init_pid_ns.child_reaper);
18094 + new->vx_reaper = init_pid_ns.child_reaper;
18095 + new->vx_badness_bias = 0;
18097 + /* rest of init goes here */
18098 + vx_info_init_limit(&new->limit);
18099 + vx_info_init_sched(&new->sched);
18100 + vx_info_init_cvirt(&new->cvirt);
18101 + vx_info_init_cacct(&new->cacct);
18103 + /* per cpu data structures */
18104 + for_each_possible_cpu(cpu) {
18105 + vx_info_init_sched_pc(
18106 + &vx_per_cpu(new, sched_pc, cpu), cpu);
18107 + vx_info_init_cvirt_pc(
18108 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
18111 + new->vx_flags = VXF_INIT_SET;
18112 + new->vx_bcaps = CAP_FULL_SET; // maybe ~CAP_SETPCAP
18113 + new->vx_ccaps = 0;
18114 + new->vx_umask = 0;
18116 + new->reboot_cmd = 0;
18117 + new->exit_code = 0;
18119 + // preconfig spaces
18120 + for (index = 0; index < VX_SPACES; index++) {
18121 + struct _vx_space *space = &new->space[index];
18124 + spin_lock(&init_fs.lock);
18126 + spin_unlock(&init_fs.lock);
18127 + space->vx_fs = &init_fs;
18129 + /* FIXME: do we want defaults? */
18130 + // space->vx_real_cred = 0;
18131 + // space->vx_cred = 0;
18135 + vxdprintk(VXD_CBIT(xid, 0),
18136 + "alloc_vx_info(%d) = %p", xid, new);
18137 + vxh_alloc_vx_info(new);
18138 + atomic_inc(&vx_global_ctotal);
18147 +/* __dealloc_vx_info()
18149 + * final disposal of vx_info */
18151 +static void __dealloc_vx_info(struct vx_info *vxi)
18153 +#ifdef CONFIG_VSERVER_WARN
18154 + struct vx_info_save vxis;
18157 + vxdprintk(VXD_CBIT(xid, 0),
18158 + "dealloc_vx_info(%p)", vxi);
18159 + vxh_dealloc_vx_info(vxi);
18161 +#ifdef CONFIG_VSERVER_WARN
18162 + enter_vx_info(vxi, &vxis);
18163 + vx_info_exit_limit(&vxi->limit);
18164 + vx_info_exit_sched(&vxi->sched);
18165 + vx_info_exit_cvirt(&vxi->cvirt);
18166 + vx_info_exit_cacct(&vxi->cacct);
18168 + for_each_possible_cpu(cpu) {
18169 + vx_info_exit_sched_pc(
18170 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
18171 + vx_info_exit_cvirt_pc(
18172 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
18174 + leave_vx_info(&vxis);
18178 + vxi->vx_state |= VXS_RELEASED;
18181 + free_percpu(vxi->ptr_pc);
18184 + atomic_dec(&vx_global_ctotal);
18187 +static void __shutdown_vx_info(struct vx_info *vxi)
18189 + struct nsproxy *nsproxy;
18190 + struct fs_struct *fs;
18191 + struct cred *cred;
18196 + vxi->vx_state |= VXS_SHUTDOWN;
18197 + vs_state_change(vxi, VSC_SHUTDOWN);
18199 + for (index = 0; index < VX_SPACES; index++) {
18200 + struct _vx_space *space = &vxi->space[index];
18202 + nsproxy = xchg(&space->vx_nsproxy, NULL);
18204 + put_nsproxy(nsproxy);
18206 + fs = xchg(&space->vx_fs, NULL);
18207 + spin_lock(&fs->lock);
18208 + kill = !--fs->users;
18209 + spin_unlock(&fs->lock);
18211 + free_fs_struct(fs);
18213 + cred = (struct cred *)xchg(&space->vx_cred, NULL);
18215 + abort_creds(cred);
18219 +/* exported stuff */
18221 +void free_vx_info(struct vx_info *vxi)
18223 + unsigned long flags;
18226 + /* check for reference counts first */
18227 + BUG_ON(atomic_read(&vxi->vx_usecnt));
18228 + BUG_ON(atomic_read(&vxi->vx_tasks));
18230 + /* context must not be hashed */
18231 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
18233 + /* context shutdown is mandatory */
18234 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
18236 + /* spaces check */
18237 + for (index = 0; index < VX_SPACES; index++) {
18238 + struct _vx_space *space = &vxi->space[index];
18240 + BUG_ON(space->vx_nsproxy);
18241 + BUG_ON(space->vx_fs);
18242 + // BUG_ON(space->vx_real_cred);
18243 + // BUG_ON(space->vx_cred);
18246 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
18247 + hlist_del(&vxi->vx_hlist);
18248 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
18250 + __dealloc_vx_info(vxi);
18254 +/* hash table for vx_info hash */
18256 +#define VX_HASH_SIZE 13
18258 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
18259 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
18261 +static DEFINE_SPINLOCK(vx_info_hash_lock);
18264 +static inline unsigned int __hashval(xid_t xid)
18266 + return (xid % VX_HASH_SIZE);
18271 +/* __hash_vx_info()
18273 + * add the vxi to the global hash table
18274 + * requires the hash_lock to be held */
18276 +static inline void __hash_vx_info(struct vx_info *vxi)
18278 + struct hlist_head *head;
18280 + vxd_assert_lock(&vx_info_hash_lock);
18281 + vxdprintk(VXD_CBIT(xid, 4),
18282 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
18283 + vxh_hash_vx_info(vxi);
18285 + /* context must not be hashed */
18286 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
18288 + vxi->vx_state |= VXS_HASHED;
18289 + head = &vx_info_hash[__hashval(vxi->vx_id)];
18290 + hlist_add_head(&vxi->vx_hlist, head);
18291 + atomic_inc(&vx_global_cactive);
18294 +/* __unhash_vx_info()
18296 + * remove the vxi from the global hash table
18297 + * requires the hash_lock to be held */
18299 +static inline void __unhash_vx_info(struct vx_info *vxi)
18301 + unsigned long flags;
18303 + vxd_assert_lock(&vx_info_hash_lock);
18304 + vxdprintk(VXD_CBIT(xid, 4),
18305 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
18306 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
18307 + vxh_unhash_vx_info(vxi);
18309 + /* context must be hashed */
18310 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
18311 + /* but without tasks */
18312 + BUG_ON(atomic_read(&vxi->vx_tasks));
18314 + vxi->vx_state &= ~VXS_HASHED;
18315 + hlist_del_init(&vxi->vx_hlist);
18316 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
18317 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
18318 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
18319 + atomic_dec(&vx_global_cactive);
18323 +/* __lookup_vx_info()
18325 + * requires the hash_lock to be held
18326 + * doesn't increment the vx_refcnt */
18328 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
18330 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
18331 + struct hlist_node *pos;
18332 + struct vx_info *vxi;
18334 + vxd_assert_lock(&vx_info_hash_lock);
18335 + hlist_for_each(pos, head) {
18336 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
18338 + if (vxi->vx_id == xid)
18343 + vxdprintk(VXD_CBIT(xid, 0),
18344 + "__lookup_vx_info(#%u): %p[#%u]",
18345 + xid, vxi, vxi ? vxi->vx_id : 0);
18346 + vxh_lookup_vx_info(vxi, xid);
18351 +/* __create_vx_info()
18353 + * create the requested context
18354 + * get(), claim() and hash it */
18356 +static struct vx_info *__create_vx_info(int id)
18358 + struct vx_info *new, *vxi = NULL;
18360 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
18362 + if (!(new = __alloc_vx_info(id)))
18363 + return ERR_PTR(-ENOMEM);
18365 + /* required to make dynamic xids unique */
18366 + spin_lock(&vx_info_hash_lock);
18368 + /* static context requested */
18369 + if ((vxi = __lookup_vx_info(id))) {
18370 + vxdprintk(VXD_CBIT(xid, 0),
18371 + "create_vx_info(%d) = %p (already there)", id, vxi);
18372 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18373 + vxi = ERR_PTR(-EBUSY);
18375 + vxi = ERR_PTR(-EEXIST);
18378 + /* new context */
18379 + vxdprintk(VXD_CBIT(xid, 0),
18380 + "create_vx_info(%d) = %p (new)", id, new);
18381 + claim_vx_info(new, NULL);
18382 + __hash_vx_info(get_vx_info(new));
18383 + vxi = new, new = NULL;
18386 + spin_unlock(&vx_info_hash_lock);
18387 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
18389 + __dealloc_vx_info(new);
18394 +/* exported stuff */
18397 +void unhash_vx_info(struct vx_info *vxi)
18399 + spin_lock(&vx_info_hash_lock);
18400 + __unhash_vx_info(vxi);
18401 + spin_unlock(&vx_info_hash_lock);
18402 + __shutdown_vx_info(vxi);
18403 + __wakeup_vx_info(vxi);
18407 +/* lookup_vx_info()
18409 + * search for a vx_info and get() it
18410 + * negative id means current */
18412 +struct vx_info *lookup_vx_info(int id)
18414 + struct vx_info *vxi = NULL;
18417 + vxi = get_vx_info(current_vx_info());
18418 + } else if (id > 1) {
18419 + spin_lock(&vx_info_hash_lock);
18420 + vxi = get_vx_info(__lookup_vx_info(id));
18421 + spin_unlock(&vx_info_hash_lock);
18426 +/* xid_is_hashed()
18428 + * verify that xid is still hashed */
18430 +int xid_is_hashed(xid_t xid)
18434 + spin_lock(&vx_info_hash_lock);
18435 + hashed = (__lookup_vx_info(xid) != NULL);
18436 + spin_unlock(&vx_info_hash_lock);
18440 +#ifdef CONFIG_PROC_FS
18444 + * get a subset of hashed xids for proc
18445 + * assumes size is at least one */
18447 +int get_xid_list(int index, unsigned int *xids, int size)
18449 + int hindex, nr_xids = 0;
18451 + /* only show current and children */
18452 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
18455 + xids[nr_xids] = vx_current_xid();
18459 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
18460 + struct hlist_head *head = &vx_info_hash[hindex];
18461 + struct hlist_node *pos;
18463 + spin_lock(&vx_info_hash_lock);
18464 + hlist_for_each(pos, head) {
18465 + struct vx_info *vxi;
18470 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
18471 + xids[nr_xids] = vxi->vx_id;
18472 + if (++nr_xids >= size) {
18473 + spin_unlock(&vx_info_hash_lock);
18477 + /* keep the lock time short */
18478 + spin_unlock(&vx_info_hash_lock);
18485 +#ifdef CONFIG_VSERVER_DEBUG
18487 +void dump_vx_info_inactive(int level)
18489 + struct hlist_node *entry, *next;
18491 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
18492 + struct vx_info *vxi =
18493 + list_entry(entry, struct vx_info, vx_hlist);
18495 + dump_vx_info(vxi, level);
18502 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
18504 + struct user_struct *new_user, *old_user;
18509 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
18512 + new_user = alloc_uid(vxi->vx_id, p->uid);
18516 + old_user = p->user;
18517 + if (new_user != old_user) {
18518 + atomic_inc(&new_user->processes);
18519 + atomic_dec(&old_user->processes);
18520 + p->user = new_user;
18522 + free_uid(old_user);
18528 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
18530 + // p->cap_effective &= vxi->vx_cap_bset;
18531 + p->cap_effective =
18532 + cap_intersect(p->cap_effective, vxi->cap_bset);
18533 + // p->cap_inheritable &= vxi->vx_cap_bset;
18534 + p->cap_inheritable =
18535 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
18536 + // p->cap_permitted &= vxi->vx_cap_bset;
18537 + p->cap_permitted =
18538 + cap_intersect(p->cap_permitted, vxi->cap_bset);
18543 +#include <linux/file.h>
18544 +#include <linux/fdtable.h>
18546 +static int vx_openfd_task(struct task_struct *tsk)
18548 + struct files_struct *files = tsk->files;
18549 + struct fdtable *fdt;
18550 + const unsigned long *bptr;
18551 + int count, total;
18553 + /* no rcu_read_lock() because of spin_lock() */
18554 + spin_lock(&files->file_lock);
18555 + fdt = files_fdtable(files);
18556 + bptr = fdt->open_fds->fds_bits;
18557 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
18558 + for (total = 0; count > 0; count--) {
18560 + total += hweight_long(*bptr);
18563 + spin_unlock(&files->file_lock);
18568 +/* for *space compatibility */
18570 +asmlinkage long sys_unshare(unsigned long);
18573 + * migrate task to new context
18574 + * gets vxi, puts old_vxi on change
18575 + * optionally unshares namespaces (hack)
18578 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
18580 + struct vx_info *old_vxi;
18586 + vxdprintk(VXD_CBIT(xid, 5),
18587 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
18588 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
18590 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
18591 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
18594 + if (vx_info_state(vxi, VXS_SHUTDOWN))
18597 + old_vxi = task_get_vx_info(p);
18598 + if (old_vxi == vxi)
18601 +// if (!(ret = vx_migrate_user(p, vxi))) {
18606 + openfd = vx_openfd_task(p);
18609 + atomic_dec(&old_vxi->cvirt.nr_threads);
18610 + atomic_dec(&old_vxi->cvirt.nr_running);
18611 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
18612 + /* FIXME: what about the struct files here? */
18613 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
18614 + /* account for the executable */
18615 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
18617 + atomic_inc(&vxi->cvirt.nr_threads);
18618 + atomic_inc(&vxi->cvirt.nr_running);
18619 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
18620 + /* FIXME: what about the struct files here? */
18621 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
18622 + /* account for the executable */
18623 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
18626 + release_vx_info(old_vxi, p);
18627 + clr_vx_info(&p->vx_info);
18629 + claim_vx_info(vxi, p);
18630 + set_vx_info(&p->vx_info, vxi);
18631 + p->xid = vxi->vx_id;
18633 + vxdprintk(VXD_CBIT(xid, 5),
18634 + "moved task %p into vxi:%p[#%d]",
18635 + p, vxi, vxi->vx_id);
18637 + // vx_mask_cap_bset(vxi, p);
18640 + /* hack for *spaces to provide compatibility */
18642 + struct nsproxy *old_nsp, *new_nsp;
18644 + ret = unshare_nsproxy_namespaces(
18645 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
18650 + old_nsp = xchg(&p->nsproxy, new_nsp);
18651 + vx_set_space(vxi,
18652 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
18653 + put_nsproxy(old_nsp);
18657 + put_vx_info(old_vxi);
18661 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
18663 + struct task_struct *old_reaper;
18668 + vxdprintk(VXD_CBIT(xid, 6),
18669 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
18670 + vxi, vxi->vx_id, p, p->xid, p->pid);
18672 + old_reaper = vxi->vx_reaper;
18673 + if (old_reaper == p)
18676 + /* set new child reaper */
18677 + get_task_struct(p);
18678 + vxi->vx_reaper = p;
18679 + put_task_struct(old_reaper);
18683 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
18688 + vxdprintk(VXD_CBIT(xid, 6),
18689 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
18690 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18692 + vxi->vx_flags &= ~VXF_STATE_INIT;
18693 + // vxi->vx_initpid = p->tgid;
18694 + vxi->vx_initpid = p->pid;
18698 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
18700 + vxdprintk(VXD_CBIT(xid, 6),
18701 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
18702 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
18704 + vxi->exit_code = code;
18705 + vxi->vx_initpid = 0;
18709 +void vx_set_persistent(struct vx_info *vxi)
18711 + vxdprintk(VXD_CBIT(xid, 6),
18712 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
18714 + get_vx_info(vxi);
18715 + claim_vx_info(vxi, NULL);
18718 +void vx_clear_persistent(struct vx_info *vxi)
18720 + vxdprintk(VXD_CBIT(xid, 6),
18721 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
18723 + release_vx_info(vxi, NULL);
18724 + put_vx_info(vxi);
18727 +void vx_update_persistent(struct vx_info *vxi)
18729 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
18730 + vx_set_persistent(vxi);
18732 + vx_clear_persistent(vxi);
18736 +/* task must be current or locked */
18738 +void exit_vx_info(struct task_struct *p, int code)
18740 + struct vx_info *vxi = p->vx_info;
18743 + atomic_dec(&vxi->cvirt.nr_threads);
18746 + vxi->exit_code = code;
18747 + release_vx_info(vxi, p);
18751 +void exit_vx_info_early(struct task_struct *p, int code)
18753 + struct vx_info *vxi = p->vx_info;
18756 + if (vxi->vx_initpid == p->pid)
18757 + vx_exit_init(vxi, p, code);
18758 + if (vxi->vx_reaper == p)
18759 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
18764 +/* vserver syscall commands below here */
18766 +/* taks xid and vx_info functions */
18768 +#include <asm/uaccess.h>
18771 +int vc_task_xid(uint32_t id)
18776 + struct task_struct *tsk;
18779 + tsk = find_task_by_real_pid(id);
18780 + xid = (tsk) ? tsk->xid : -ESRCH;
18781 + rcu_read_unlock();
18783 + xid = vx_current_xid();
18788 +int vc_vx_info(struct vx_info *vxi, void __user *data)
18790 + struct vcmd_vx_info_v0 vc_data;
18792 + vc_data.xid = vxi->vx_id;
18793 + vc_data.initpid = vxi->vx_initpid;
18795 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18801 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
18803 + struct vcmd_ctx_stat_v0 vc_data;
18805 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
18806 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
18808 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18814 +/* context functions */
18816 +int vc_ctx_create(uint32_t xid, void __user *data)
18818 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
18819 + struct vx_info *new_vxi;
18822 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18825 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
18828 + new_vxi = __create_vx_info(xid);
18829 + if (IS_ERR(new_vxi))
18830 + return PTR_ERR(new_vxi);
18832 + /* initial flags */
18833 + new_vxi->vx_flags = vc_data.flagword;
18836 + if (vs_state_change(new_vxi, VSC_STARTUP))
18839 + ret = vx_migrate_task(current, new_vxi, (!data));
18843 + /* return context id on success */
18844 + ret = new_vxi->vx_id;
18846 + /* get a reference for persistent contexts */
18847 + if ((vc_data.flagword & VXF_PERSISTENT))
18848 + vx_set_persistent(new_vxi);
18850 + release_vx_info(new_vxi, NULL);
18851 + put_vx_info(new_vxi);
18856 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
18858 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
18861 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
18864 + ret = vx_migrate_task(current, vxi, 0);
18867 + if (vc_data.flagword & VXM_SET_INIT)
18868 + ret = vx_set_init(vxi, current);
18871 + if (vc_data.flagword & VXM_SET_REAPER)
18872 + ret = vx_set_reaper(vxi, current);
18877 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
18879 + struct vcmd_ctx_flags_v0 vc_data;
18881 + vc_data.flagword = vxi->vx_flags;
18883 + /* special STATE flag handling */
18884 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
18886 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18891 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
18893 + struct vcmd_ctx_flags_v0 vc_data;
18894 + uint64_t mask, trigger;
18896 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18899 + /* special STATE flag handling */
18900 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
18901 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
18903 + if (vxi == current_vx_info()) {
18904 + /* if (trigger & VXF_STATE_SETUP)
18905 + vx_mask_cap_bset(vxi, current); */
18906 + if (trigger & VXF_STATE_INIT) {
18909 + ret = vx_set_init(vxi, current);
18912 + ret = vx_set_reaper(vxi, current);
18918 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
18919 + vc_data.flagword, mask);
18920 + if (trigger & VXF_PERSISTENT)
18921 + vx_update_persistent(vxi);
18927 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
18929 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
18931 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
18935 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
18937 + kernel_cap_t c = __cap_empty_set;
18939 + c.cap[0] = v & 0xFFFFFFFF;
18940 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
18942 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
18947 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
18950 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
18952 + *ccaps = vxi->vx_ccaps;
18957 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
18959 + struct vcmd_ctx_caps_v1 vc_data;
18962 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
18965 + vc_data.cmask = ~0ULL;
18967 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18972 +static int do_set_caps(struct vx_info *vxi,
18973 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
18975 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
18978 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
18979 + bcaps, bmask, ccaps, cmask);
18981 + vxi->vx_bcaps = cap_t_from_caps(
18982 + vs_mask_flags(bcold, bcaps, bmask));
18983 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
18988 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
18990 + struct vcmd_ctx_caps_v1 vc_data;
18992 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18995 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
18998 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
19000 + struct vcmd_bcaps vc_data;
19003 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
19006 + vc_data.bmask = ~0ULL;
19008 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19013 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
19015 + struct vcmd_bcaps vc_data;
19017 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19020 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
19024 +int vc_get_umask(struct vx_info *vxi, void __user *data)
19026 + struct vcmd_umask vc_data;
19028 + vc_data.umask = vxi->vx_umask;
19029 + vc_data.mask = ~0ULL;
19031 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19036 +int vc_set_umask(struct vx_info *vxi, void __user *data)
19038 + struct vcmd_umask vc_data;
19040 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19043 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
19044 + vc_data.umask, vc_data.mask);
19049 +int vc_get_badness(struct vx_info *vxi, void __user *data)
19051 + struct vcmd_badness_v0 vc_data;
19053 + vc_data.bias = vxi->vx_badness_bias;
19055 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19060 +int vc_set_badness(struct vx_info *vxi, void __user *data)
19062 + struct vcmd_badness_v0 vc_data;
19064 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19067 + vxi->vx_badness_bias = vc_data.bias;
19071 +#include <linux/module.h>
19073 +EXPORT_SYMBOL_GPL(free_vx_info);
19075 diff -NurpP --minimal linux-3.0/kernel/vserver/cvirt.c linux-3.0-vs2.3.1-pre7/kernel/vserver/cvirt.c
19076 --- linux-3.0/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
19077 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/cvirt.c 2011-06-13 14:57:26.000000000 +0200
19080 + * linux/kernel/vserver/cvirt.c
19082 + * Virtual Server: Context Virtualization
19084 + * Copyright (C) 2004-2007 Herbert Pötzl
19086 + * V0.01 broken out from limit.c
19087 + * V0.02 added utsname stuff
19088 + * V0.03 changed vcmds to vxi arg
19092 +#include <linux/types.h>
19093 +#include <linux/utsname.h>
19094 +#include <linux/vs_cvirt.h>
19095 +#include <linux/vserver/switch.h>
19096 +#include <linux/vserver/cvirt_cmd.h>
19098 +#include <asm/uaccess.h>
19101 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
19103 + struct vx_info *vxi = current_vx_info();
19105 + set_normalized_timespec(uptime,
19106 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
19107 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
19110 + set_normalized_timespec(idle,
19111 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
19112 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
19116 +uint64_t vx_idle_jiffies(void)
19118 + return init_task.utime + init_task.stime;
19123 +static inline uint32_t __update_loadavg(uint32_t load,
19124 + int wsize, int delta, int n)
19126 + unsigned long long calc, prev;
19128 + /* just set it to n */
19129 + if (unlikely(delta >= wsize))
19130 + return (n << FSHIFT);
19132 + calc = delta * n;
19134 + prev = (wsize - delta);
19137 + do_div(calc, wsize);
19142 +void vx_update_load(struct vx_info *vxi)
19144 + uint32_t now, last, delta;
19145 + unsigned int nr_running, nr_uninterruptible;
19146 + unsigned int total;
19147 + unsigned long flags;
19149 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
19152 + last = vxi->cvirt.load_last;
19153 + delta = now - last;
19155 + if (delta < 5*HZ)
19158 + nr_running = atomic_read(&vxi->cvirt.nr_running);
19159 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
19160 + total = nr_running + nr_uninterruptible;
19162 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
19163 + 60*HZ, delta, total);
19164 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
19165 + 5*60*HZ, delta, total);
19166 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
19167 + 15*60*HZ, delta, total);
19169 + vxi->cvirt.load_last = now;
19171 + atomic_inc(&vxi->cvirt.load_updates);
19172 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
19177 + * Commands to do_syslog:
19179 + * 0 -- Close the log. Currently a NOP.
19180 + * 1 -- Open the log. Currently a NOP.
19181 + * 2 -- Read from the log.
19182 + * 3 -- Read all messages remaining in the ring buffer.
19183 + * 4 -- Read and clear all messages remaining in the ring buffer
19184 + * 5 -- Clear ring buffer.
19185 + * 6 -- Disable printk's to console
19186 + * 7 -- Enable printk's to console
19187 + * 8 -- Set level of messages printed to console
19188 + * 9 -- Return number of unread characters in the log buffer
19189 + * 10 -- Return size of the log buffer
19191 +int vx_do_syslog(int type, char __user *buf, int len)
19194 + int do_clear = 0;
19195 + struct vx_info *vxi = current_vx_info();
19196 + struct _vx_syslog *log;
19200 + log = &vxi->cvirt.syslog;
19203 + case 0: /* Close log */
19204 + case 1: /* Open log */
19206 + case 2: /* Read from log */
19207 + error = wait_event_interruptible(log->log_wait,
19208 + (log->log_start - log->log_end));
19211 + spin_lock_irq(&log->logbuf_lock);
19212 + spin_unlock_irq(&log->logbuf_lock);
19214 + case 4: /* Read/clear last kernel messages */
19216 + /* fall through */
19217 + case 3: /* Read last kernel messages */
19220 + case 5: /* Clear ring buffer */
19223 + case 6: /* Disable logging to console */
19224 + case 7: /* Enable logging to console */
19225 + case 8: /* Set level of messages printed to console */
19228 + case 9: /* Number of chars in the log buffer */
19230 + case 10: /* Size of the log buffer */
19240 +/* virtual host info names */
19242 +static char *vx_vhi_name(struct vx_info *vxi, int id)
19244 + struct nsproxy *nsproxy;
19245 + struct uts_namespace *uts;
19247 + if (id == VHIN_CONTEXT)
19248 + return vxi->vx_name;
19250 + nsproxy = vxi->space[0].vx_nsproxy;
19254 + uts = nsproxy->uts_ns;
19259 + case VHIN_SYSNAME:
19260 + return uts->name.sysname;
19261 + case VHIN_NODENAME:
19262 + return uts->name.nodename;
19263 + case VHIN_RELEASE:
19264 + return uts->name.release;
19265 + case VHIN_VERSION:
19266 + return uts->name.version;
19267 + case VHIN_MACHINE:
19268 + return uts->name.machine;
19269 + case VHIN_DOMAINNAME:
19270 + return uts->name.domainname;
19277 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
19279 + struct vcmd_vhi_name_v0 vc_data;
19282 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19285 + name = vx_vhi_name(vxi, vc_data.field);
19289 + memcpy(name, vc_data.name, 65);
19293 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
19295 + struct vcmd_vhi_name_v0 vc_data;
19298 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19301 + name = vx_vhi_name(vxi, vc_data.field);
19305 + memcpy(vc_data.name, name, 65);
19306 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19312 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
19314 + struct vcmd_virt_stat_v0 vc_data;
19315 + struct _vx_cvirt *cvirt = &vxi->cvirt;
19316 + struct timespec uptime;
19318 + do_posix_clock_monotonic_gettime(&uptime);
19319 + set_normalized_timespec(&uptime,
19320 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
19321 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
19323 + vc_data.offset = timespec_to_ns(&cvirt->bias_ts);
19324 + vc_data.uptime = timespec_to_ns(&uptime);
19325 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
19326 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
19327 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
19328 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
19329 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
19330 + vc_data.load[0] = cvirt->load[0];
19331 + vc_data.load[1] = cvirt->load[1];
19332 + vc_data.load[2] = cvirt->load[2];
19334 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19340 +#ifdef CONFIG_VSERVER_VTIME
19342 +/* virtualized time base */
19344 +void vx_adjust_timespec(struct timespec *ts)
19346 + struct vx_info *vxi;
19348 + if (!vx_flags(VXF_VIRT_TIME, 0))
19351 + vxi = current_vx_info();
19352 + ts->tv_sec += vxi->cvirt.bias_ts.tv_sec;
19353 + ts->tv_nsec += vxi->cvirt.bias_ts.tv_nsec;
19355 + if (ts->tv_nsec >= NSEC_PER_SEC) {
19357 + ts->tv_nsec -= NSEC_PER_SEC;
19358 + } else if (ts->tv_nsec < 0) {
19360 + ts->tv_nsec += NSEC_PER_SEC;
19364 +int vx_settimeofday(const struct timespec *ts)
19366 + struct timespec ats, delta;
19367 + struct vx_info *vxi;
19369 + if (!vx_flags(VXF_VIRT_TIME, 0))
19370 + return do_settimeofday(ts);
19372 + getnstimeofday(&ats);
19373 + delta = timespec_sub(*ts, ats);
19375 + vxi = current_vx_info();
19376 + vxi->cvirt.bias_ts = timespec_add(vxi->cvirt.bias_ts, delta);
19382 diff -NurpP --minimal linux-3.0/kernel/vserver/cvirt_init.h linux-3.0-vs2.3.1-pre7/kernel/vserver/cvirt_init.h
19383 --- linux-3.0/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
19384 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/cvirt_init.h 2011-06-10 22:11:24.000000000 +0200
19388 +extern uint64_t vx_idle_jiffies(void);
19390 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
19392 + uint64_t idle_jiffies = vx_idle_jiffies();
19393 + uint64_t nsuptime;
19395 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
19396 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
19397 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
19398 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
19399 + cvirt->bias_ts.tv_sec = 0;
19400 + cvirt->bias_ts.tv_nsec = 0;
19402 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
19403 + atomic_set(&cvirt->nr_threads, 0);
19404 + atomic_set(&cvirt->nr_running, 0);
19405 + atomic_set(&cvirt->nr_uninterruptible, 0);
19406 + atomic_set(&cvirt->nr_onhold, 0);
19408 + spin_lock_init(&cvirt->load_lock);
19409 + cvirt->load_last = jiffies;
19410 + atomic_set(&cvirt->load_updates, 0);
19411 + cvirt->load[0] = 0;
19412 + cvirt->load[1] = 0;
19413 + cvirt->load[2] = 0;
19414 + atomic_set(&cvirt->total_forks, 0);
19416 + spin_lock_init(&cvirt->syslog.logbuf_lock);
19417 + init_waitqueue_head(&cvirt->syslog.log_wait);
19418 + cvirt->syslog.log_start = 0;
19419 + cvirt->syslog.log_end = 0;
19420 + cvirt->syslog.con_start = 0;
19421 + cvirt->syslog.logged_chars = 0;
19425 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19427 + // cvirt_pc->cpustat = { 0 };
19430 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
19432 +#ifdef CONFIG_VSERVER_WARN
19435 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
19436 + "!!! cvirt: %p[nr_threads] = %d on exit.",
19438 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
19439 + "!!! cvirt: %p[nr_running] = %d on exit.",
19441 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
19442 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
19444 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
19445 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
19451 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
19456 diff -NurpP --minimal linux-3.0/kernel/vserver/cvirt_proc.h linux-3.0-vs2.3.1-pre7/kernel/vserver/cvirt_proc.h
19457 --- linux-3.0/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
19458 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/cvirt_proc.h 2011-06-10 22:11:24.000000000 +0200
19460 +#ifndef _VX_CVIRT_PROC_H
19461 +#define _VX_CVIRT_PROC_H
19463 +#include <linux/nsproxy.h>
19464 +#include <linux/mnt_namespace.h>
19465 +#include <linux/ipc_namespace.h>
19466 +#include <linux/utsname.h>
19467 +#include <linux/ipc.h>
19471 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
19473 + struct mnt_namespace *ns;
19474 + struct uts_namespace *uts;
19475 + struct ipc_namespace *ipc;
19476 + struct path path;
19477 + char *pstr, *root;
19483 + length += sprintf(buffer + length,
19484 + "NSProxy:\t%p [%p,%p,%p]\n",
19485 + nsproxy, nsproxy->mnt_ns,
19486 + nsproxy->uts_ns, nsproxy->ipc_ns);
19488 + ns = nsproxy->mnt_ns;
19492 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
19496 + path.mnt = ns->root;
19497 + path.dentry = ns->root->mnt_root;
19498 + root = d_path(&path, pstr, PATH_MAX - 2);
19499 + length += sprintf(buffer + length,
19500 + "Namespace:\t%p [#%u]\n"
19501 + "RootPath:\t%s\n",
19502 + ns, atomic_read(&ns->count),
19507 + uts = nsproxy->uts_ns;
19511 + length += sprintf(buffer + length,
19512 + "SysName:\t%.*s\n"
19513 + "NodeName:\t%.*s\n"
19514 + "Release:\t%.*s\n"
19515 + "Version:\t%.*s\n"
19516 + "Machine:\t%.*s\n"
19517 + "DomainName:\t%.*s\n",
19518 + __NEW_UTS_LEN, uts->name.sysname,
19519 + __NEW_UTS_LEN, uts->name.nodename,
19520 + __NEW_UTS_LEN, uts->name.release,
19521 + __NEW_UTS_LEN, uts->name.version,
19522 + __NEW_UTS_LEN, uts->name.machine,
19523 + __NEW_UTS_LEN, uts->name.domainname);
19526 + ipc = nsproxy->ipc_ns;
19530 + length += sprintf(buffer + length,
19531 + "SEMS:\t\t%d %d %d %d %d\n"
19532 + "MSG:\t\t%d %d %d\n"
19533 + "SHM:\t\t%lu %lu %d %d\n",
19534 + ipc->sem_ctls[0], ipc->sem_ctls[1],
19535 + ipc->sem_ctls[2], ipc->sem_ctls[3],
19537 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
19538 + (unsigned long)ipc->shm_ctlmax,
19539 + (unsigned long)ipc->shm_ctlall,
19540 + ipc->shm_ctlmni, ipc->shm_tot);
19547 +#include <linux/sched.h>
19549 +#define LOAD_INT(x) ((x) >> FSHIFT)
19550 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
19553 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
19558 + length += sprintf(buffer + length,
19559 + "BiasUptime:\t%lu.%02lu\n",
19560 + (unsigned long)cvirt->bias_uptime.tv_sec,
19561 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
19563 + a = cvirt->load[0] + (FIXED_1 / 200);
19564 + b = cvirt->load[1] + (FIXED_1 / 200);
19565 + c = cvirt->load[2] + (FIXED_1 / 200);
19566 + length += sprintf(buffer + length,
19567 + "nr_threads:\t%d\n"
19568 + "nr_running:\t%d\n"
19569 + "nr_unintr:\t%d\n"
19570 + "nr_onhold:\t%d\n"
19571 + "load_updates:\t%d\n"
19572 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
19573 + "total_forks:\t%d\n",
19574 + atomic_read(&cvirt->nr_threads),
19575 + atomic_read(&cvirt->nr_running),
19576 + atomic_read(&cvirt->nr_uninterruptible),
19577 + atomic_read(&cvirt->nr_onhold),
19578 + atomic_read(&cvirt->load_updates),
19579 + LOAD_INT(a), LOAD_FRAC(a),
19580 + LOAD_INT(b), LOAD_FRAC(b),
19581 + LOAD_INT(c), LOAD_FRAC(c),
19582 + atomic_read(&cvirt->total_forks));
19587 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
19588 + char *buffer, int cpu)
19594 +#endif /* _VX_CVIRT_PROC_H */
19595 diff -NurpP --minimal linux-3.0/kernel/vserver/debug.c linux-3.0-vs2.3.1-pre7/kernel/vserver/debug.c
19596 --- linux-3.0/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
19597 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/debug.c 2011-06-10 22:11:24.000000000 +0200
19600 + * kernel/vserver/debug.c
19602 + * Copyright (C) 2005-2007 Herbert Pötzl
19604 + * V0.01 vx_info dump support
19608 +#include <linux/module.h>
19610 +#include <linux/vserver/context.h>
19613 +void dump_vx_info(struct vx_info *vxi, int level)
19615 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
19616 + atomic_read(&vxi->vx_usecnt),
19617 + atomic_read(&vxi->vx_tasks),
19620 + __dump_vx_limit(&vxi->limit);
19621 + __dump_vx_sched(&vxi->sched);
19622 + __dump_vx_cvirt(&vxi->cvirt);
19623 + __dump_vx_cacct(&vxi->cacct);
19629 +EXPORT_SYMBOL_GPL(dump_vx_info);
19631 diff -NurpP --minimal linux-3.0/kernel/vserver/device.c linux-3.0-vs2.3.1-pre7/kernel/vserver/device.c
19632 --- linux-3.0/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
19633 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/device.c 2011-06-10 23:20:56.000000000 +0200
19636 + * linux/kernel/vserver/device.c
19638 + * Linux-VServer: Device Support
19640 + * Copyright (C) 2006 Herbert Pötzl
19641 + * Copyright (C) 2007 Daniel Hokka Zakrisson
19643 + * V0.01 device mapping basics
19644 + * V0.02 added defaults
19648 +#include <linux/slab.h>
19649 +#include <linux/rcupdate.h>
19650 +#include <linux/fs.h>
19651 +#include <linux/namei.h>
19652 +#include <linux/hash.h>
19654 +#include <asm/errno.h>
19655 +#include <asm/uaccess.h>
19656 +#include <linux/vserver/base.h>
19657 +#include <linux/vserver/debug.h>
19658 +#include <linux/vserver/context.h>
19659 +#include <linux/vserver/device.h>
19660 +#include <linux/vserver/device_cmd.h>
19663 +#define DMAP_HASH_BITS 4
19666 +struct vs_mapping {
19668 + struct hlist_node hlist;
19669 + struct list_head list;
19671 +#define dm_hlist u.hlist
19672 +#define dm_list u.list
19675 + struct vx_dmap_target target;
19679 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
19681 +static DEFINE_SPINLOCK(dmap_main_hash_lock);
19683 +static struct vx_dmap_target dmap_defaults[2] = {
19684 + { .flags = DATTR_OPEN },
19685 + { .flags = DATTR_OPEN },
19689 +struct kmem_cache *dmap_cachep __read_mostly;
19691 +int __init dmap_cache_init(void)
19693 + dmap_cachep = kmem_cache_create("dmap_cache",
19694 + sizeof(struct vs_mapping), 0,
19695 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
19699 +__initcall(dmap_cache_init);
19702 +static inline unsigned int __hashval(dev_t dev, int bits)
19704 + return hash_long((unsigned long)dev, bits);
19708 +/* __hash_mapping()
19709 + * add the mapping to the hash table
19711 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
19713 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19714 + struct hlist_head *head, *hash = dmap_main_hash;
19715 + int device = vdm->device;
19717 + spin_lock(hash_lock);
19718 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
19719 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
19721 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
19722 + hlist_add_head(&vdm->dm_hlist, head);
19723 + spin_unlock(hash_lock);
19727 +static inline int __mode_to_default(umode_t mode)
19740 +/* __set_default()
19743 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
19744 + struct vx_dmap_target *vdmt)
19746 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19747 + spin_lock(hash_lock);
19750 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
19752 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
19755 + spin_unlock(hash_lock);
19757 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
19758 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
19762 +/* __remove_default()
19763 + * remove a default
19765 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
19767 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19768 + spin_lock(hash_lock);
19771 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
19772 + else /* remove == reset */
19773 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
19775 + spin_unlock(hash_lock);
19780 +/* __find_mapping()
19781 + * find a mapping in the hash table
19783 + * caller must hold hash_lock
19785 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
19786 + struct vs_mapping **local, struct vs_mapping **global)
19788 + struct hlist_head *hash = dmap_main_hash;
19789 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
19790 + struct hlist_node *pos;
19791 + struct vs_mapping *vdm;
19797 + hlist_for_each(pos, head) {
19798 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
19800 + if ((vdm->device == device) &&
19801 + !((vdm->target.flags ^ mode) & S_IFMT)) {
19802 + if (vdm->xid == xid) {
19805 + } else if (global && vdm->xid == 0)
19810 + if (global && *global)
19817 +/* __lookup_mapping()
19818 + * find a mapping and store the result in target and flags
19820 +static inline int __lookup_mapping(struct vx_info *vxi,
19821 + dev_t device, dev_t *target, int *flags, umode_t mode)
19823 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19824 + struct vs_mapping *vdm, *global;
19825 + struct vx_dmap_target *vdmt;
19827 + xid_t xid = vxi->vx_id;
19830 + spin_lock(hash_lock);
19831 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
19833 + vdmt = &vdm->target;
19837 + index = __mode_to_default(mode);
19838 + if (vxi && vxi->dmap.targets[index].flags) {
19840 + vdmt = &vxi->dmap.targets[index];
19841 + } else if (global) {
19843 + vdmt = &global->target;
19847 + vdmt = &dmap_defaults[index];
19851 + if (target && (vdmt->flags & DATTR_REMAP))
19852 + *target = vdmt->target;
19854 + *target = device;
19856 + *flags = vdmt->flags;
19858 + spin_unlock(hash_lock);
19864 +/* __remove_mapping()
19865 + * remove a mapping from the hash table
19867 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
19870 + spinlock_t *hash_lock = &dmap_main_hash_lock;
19871 + struct vs_mapping *vdm = NULL;
19874 + spin_lock(hash_lock);
19876 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
19878 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
19879 + vxi, vxi ? vxi->vx_id : 0, device, mode);
19882 + hlist_del(&vdm->dm_hlist);
19885 + spin_unlock(hash_lock);
19887 + kmem_cache_free(dmap_cachep, vdm);
19893 +int vs_map_device(struct vx_info *vxi,
19894 + dev_t device, dev_t *target, umode_t mode)
19896 + int ret, flags = DATTR_MASK;
19900 + *target = device;
19903 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
19904 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
19905 + device, target ? *target : 0, flags, mode, ret);
19907 + return (flags & DATTR_MASK);
19912 +static int do_set_mapping(struct vx_info *vxi,
19913 + dev_t device, dev_t target, int flags, umode_t mode)
19916 + struct vs_mapping *new;
19918 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
19922 + INIT_HLIST_NODE(&new->dm_hlist);
19923 + new->device = device;
19924 + new->target.target = target;
19925 + new->target.flags = flags | mode;
19926 + new->xid = (vxi ? vxi->vx_id : 0);
19928 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
19929 + __hash_mapping(vxi, new);
19931 + struct vx_dmap_target new = {
19932 + .target = target,
19933 + .flags = flags | mode,
19935 + __set_default(vxi, mode, &new);
19941 +static int do_unset_mapping(struct vx_info *vxi,
19942 + dev_t device, dev_t target, int flags, umode_t mode)
19944 + int ret = -EINVAL;
19947 + ret = __remove_mapping(vxi, device, mode);
19951 + ret = __remove_default(vxi, mode);
19961 +static inline int __user_device(const char __user *name, dev_t *dev,
19964 + struct nameidata nd;
19971 + ret = user_lpath(name, &nd.path);
19974 + if (nd.path.dentry->d_inode) {
19975 + *dev = nd.path.dentry->d_inode->i_rdev;
19976 + *mode = nd.path.dentry->d_inode->i_mode;
19978 + path_put(&nd.path);
19982 +static inline int __mapping_mode(dev_t device, dev_t target,
19983 + umode_t device_mode, umode_t target_mode, umode_t *mode)
19986 + *mode = device_mode & S_IFMT;
19988 + *mode = target_mode & S_IFMT;
19992 + /* if both given, device and target mode have to match */
19993 + if (device && target &&
19994 + ((device_mode ^ target_mode) & S_IFMT))
20000 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
20001 + const char __user *target_path, int flags, int set)
20003 + dev_t device = ~0, target = ~0;
20004 + umode_t device_mode = 0, target_mode = 0, mode;
20007 + ret = __user_device(device_path, &device, &device_mode);
20010 + ret = __user_device(target_path, &target, &target_mode);
20014 + ret = __mapping_mode(device, target,
20015 + device_mode, target_mode, &mode);
20020 + return do_set_mapping(vxi, device, target,
20023 + return do_unset_mapping(vxi, device, target,
20028 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
20030 + struct vcmd_set_mapping_v0 vc_data;
20032 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20035 + return do_mapping(vxi, vc_data.device, vc_data.target,
20036 + vc_data.flags, 1);
20039 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
20041 + struct vcmd_set_mapping_v0 vc_data;
20043 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20046 + return do_mapping(vxi, vc_data.device, vc_data.target,
20047 + vc_data.flags, 0);
20051 +#ifdef CONFIG_COMPAT
20053 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
20055 + struct vcmd_set_mapping_v0_x32 vc_data;
20057 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20060 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
20061 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
20064 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
20066 + struct vcmd_set_mapping_v0_x32 vc_data;
20068 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20071 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
20072 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
20075 +#endif /* CONFIG_COMPAT */
20078 diff -NurpP --minimal linux-3.0/kernel/vserver/dlimit.c linux-3.0-vs2.3.1-pre7/kernel/vserver/dlimit.c
20079 --- linux-3.0/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
20080 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/dlimit.c 2011-06-10 23:20:56.000000000 +0200
20083 + * linux/kernel/vserver/dlimit.c
20085 + * Virtual Server: Context Disk Limits
20087 + * Copyright (C) 2004-2009 Herbert Pötzl
20089 + * V0.01 initial version
20090 + * V0.02 compat32 splitup
20091 + * V0.03 extended interface
20095 +#include <linux/statfs.h>
20096 +#include <linux/sched.h>
20097 +#include <linux/namei.h>
20098 +#include <linux/vs_tag.h>
20099 +#include <linux/vs_dlimit.h>
20100 +#include <linux/vserver/dlimit_cmd.h>
20101 +#include <linux/slab.h>
20102 +// #include <linux/gfp.h>
20104 +#include <asm/uaccess.h>
20106 +/* __alloc_dl_info()
20108 + * allocate an initialized dl_info struct
20109 + * doesn't make it visible (hash) */
20111 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
20113 + struct dl_info *new = NULL;
20115 + vxdprintk(VXD_CBIT(dlim, 5),
20116 + "alloc_dl_info(%p,%d)*", sb, tag);
20118 + /* would this benefit from a slab cache? */
20119 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
20123 + memset(new, 0, sizeof(struct dl_info));
20124 + new->dl_tag = tag;
20126 + // INIT_RCU_HEAD(&new->dl_rcu);
20127 + INIT_HLIST_NODE(&new->dl_hlist);
20128 + spin_lock_init(&new->dl_lock);
20129 + atomic_set(&new->dl_refcnt, 0);
20130 + atomic_set(&new->dl_usecnt, 0);
20132 + /* rest of init goes here */
20134 + vxdprintk(VXD_CBIT(dlim, 4),
20135 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
20139 +/* __dealloc_dl_info()
20141 + * final disposal of dl_info */
20143 +static void __dealloc_dl_info(struct dl_info *dli)
20145 + vxdprintk(VXD_CBIT(dlim, 4),
20146 + "dealloc_dl_info(%p)", dli);
20148 + dli->dl_hlist.next = LIST_POISON1;
20149 + dli->dl_tag = -1;
20152 + BUG_ON(atomic_read(&dli->dl_usecnt));
20153 + BUG_ON(atomic_read(&dli->dl_refcnt));
20159 +/* hash table for dl_info hash */
20161 +#define DL_HASH_SIZE 13
20163 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
20165 +static DEFINE_SPINLOCK(dl_info_hash_lock);
20168 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
20170 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
20175 +/* __hash_dl_info()
20177 + * add the dli to the global hash table
20178 + * requires the hash_lock to be held */
20180 +static inline void __hash_dl_info(struct dl_info *dli)
20182 + struct hlist_head *head;
20184 + vxdprintk(VXD_CBIT(dlim, 6),
20185 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
20186 + get_dl_info(dli);
20187 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
20188 + hlist_add_head_rcu(&dli->dl_hlist, head);
20191 +/* __unhash_dl_info()
20193 + * remove the dli from the global hash table
20194 + * requires the hash_lock to be held */
20196 +static inline void __unhash_dl_info(struct dl_info *dli)
20198 + vxdprintk(VXD_CBIT(dlim, 6),
20199 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
20200 + hlist_del_rcu(&dli->dl_hlist);
20201 + put_dl_info(dli);
20205 +/* __lookup_dl_info()
20207 + * requires the rcu_read_lock()
20208 + * doesn't increment the dl_refcnt */
20210 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
20212 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
20213 + struct hlist_node *pos;
20214 + struct dl_info *dli;
20216 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
20218 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
20226 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
20228 + struct dl_info *dli;
20231 + dli = get_dl_info(__lookup_dl_info(sb, tag));
20232 + vxdprintk(VXD_CBIT(dlim, 7),
20233 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
20234 + rcu_read_unlock();
20238 +void rcu_free_dl_info(struct rcu_head *head)
20240 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
20241 + int usecnt, refcnt;
20243 + BUG_ON(!dli || !head);
20245 + usecnt = atomic_read(&dli->dl_usecnt);
20246 + BUG_ON(usecnt < 0);
20248 + refcnt = atomic_read(&dli->dl_refcnt);
20249 + BUG_ON(refcnt < 0);
20251 + vxdprintk(VXD_CBIT(dlim, 3),
20252 + "rcu_free_dl_info(%p)", dli);
20254 + __dealloc_dl_info(dli);
20256 + printk("!!! rcu didn't free\n");
20262 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
20263 + uint32_t flags, int add)
20265 + struct path path;
20268 + ret = user_lpath(name, &path);
20270 + struct super_block *sb;
20271 + struct dl_info *dli;
20274 + if (!path.dentry->d_inode)
20275 + goto out_release;
20276 + if (!(sb = path.dentry->d_inode->i_sb))
20277 + goto out_release;
20280 + dli = __alloc_dl_info(sb, id);
20281 + spin_lock(&dl_info_hash_lock);
20284 + if (__lookup_dl_info(sb, id))
20286 + __hash_dl_info(dli);
20289 + spin_lock(&dl_info_hash_lock);
20290 + dli = __lookup_dl_info(sb, id);
20295 + __unhash_dl_info(dli);
20299 + spin_unlock(&dl_info_hash_lock);
20301 + __dealloc_dl_info(dli);
20308 +int vc_add_dlimit(uint32_t id, void __user *data)
20310 + struct vcmd_ctx_dlimit_base_v0 vc_data;
20312 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20315 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
20318 +int vc_rem_dlimit(uint32_t id, void __user *data)
20320 + struct vcmd_ctx_dlimit_base_v0 vc_data;
20322 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20325 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
20328 +#ifdef CONFIG_COMPAT
20330 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
20332 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
20334 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20337 + return do_addrem_dlimit(id,
20338 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
20341 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
20343 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
20345 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20348 + return do_addrem_dlimit(id,
20349 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
20352 +#endif /* CONFIG_COMPAT */
20356 +int do_set_dlimit(uint32_t id, const char __user *name,
20357 + uint32_t space_used, uint32_t space_total,
20358 + uint32_t inodes_used, uint32_t inodes_total,
20359 + uint32_t reserved, uint32_t flags)
20361 + struct path path;
20364 + ret = user_lpath(name, &path);
20366 + struct super_block *sb;
20367 + struct dl_info *dli;
20370 + if (!path.dentry->d_inode)
20371 + goto out_release;
20372 + if (!(sb = path.dentry->d_inode->i_sb))
20373 + goto out_release;
20375 + /* sanity checks */
20376 + if ((reserved != CDLIM_KEEP &&
20377 + reserved > 100) ||
20378 + (inodes_used != CDLIM_KEEP &&
20379 + inodes_used > inodes_total) ||
20380 + (space_used != CDLIM_KEEP &&
20381 + space_used > space_total))
20382 + goto out_release;
20385 + dli = locate_dl_info(sb, id);
20387 + goto out_release;
20389 + spin_lock(&dli->dl_lock);
20391 + if (inodes_used != CDLIM_KEEP)
20392 + dli->dl_inodes_used = inodes_used;
20393 + if (inodes_total != CDLIM_KEEP)
20394 + dli->dl_inodes_total = inodes_total;
20395 + if (space_used != CDLIM_KEEP)
20396 + dli->dl_space_used = dlimit_space_32to64(
20397 + space_used, flags, DLIMS_USED);
20399 + if (space_total == CDLIM_INFINITY)
20400 + dli->dl_space_total = DLIM_INFINITY;
20401 + else if (space_total != CDLIM_KEEP)
20402 + dli->dl_space_total = dlimit_space_32to64(
20403 + space_total, flags, DLIMS_TOTAL);
20405 + if (reserved != CDLIM_KEEP)
20406 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
20408 + spin_unlock(&dli->dl_lock);
20410 + put_dl_info(dli);
20419 +int vc_set_dlimit(uint32_t id, void __user *data)
20421 + struct vcmd_ctx_dlimit_v0 vc_data;
20423 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20426 + return do_set_dlimit(id, vc_data.name,
20427 + vc_data.space_used, vc_data.space_total,
20428 + vc_data.inodes_used, vc_data.inodes_total,
20429 + vc_data.reserved, vc_data.flags);
20432 +#ifdef CONFIG_COMPAT
20434 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
20436 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
20438 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20441 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
20442 + vc_data.space_used, vc_data.space_total,
20443 + vc_data.inodes_used, vc_data.inodes_total,
20444 + vc_data.reserved, vc_data.flags);
20447 +#endif /* CONFIG_COMPAT */
20451 +int do_get_dlimit(uint32_t id, const char __user *name,
20452 + uint32_t *space_used, uint32_t *space_total,
20453 + uint32_t *inodes_used, uint32_t *inodes_total,
20454 + uint32_t *reserved, uint32_t *flags)
20456 + struct path path;
20459 + ret = user_lpath(name, &path);
20461 + struct super_block *sb;
20462 + struct dl_info *dli;
20465 + if (!path.dentry->d_inode)
20466 + goto out_release;
20467 + if (!(sb = path.dentry->d_inode->i_sb))
20468 + goto out_release;
20471 + dli = locate_dl_info(sb, id);
20473 + goto out_release;
20475 + spin_lock(&dli->dl_lock);
20476 + *inodes_used = dli->dl_inodes_used;
20477 + *inodes_total = dli->dl_inodes_total;
20479 + *space_used = dlimit_space_64to32(
20480 + dli->dl_space_used, flags, DLIMS_USED);
20482 + if (dli->dl_space_total == DLIM_INFINITY)
20483 + *space_total = CDLIM_INFINITY;
20485 + *space_total = dlimit_space_64to32(
20486 + dli->dl_space_total, flags, DLIMS_TOTAL);
20488 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
20489 + spin_unlock(&dli->dl_lock);
20491 + put_dl_info(dli);
20502 +int vc_get_dlimit(uint32_t id, void __user *data)
20504 + struct vcmd_ctx_dlimit_v0 vc_data;
20507 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20510 + ret = do_get_dlimit(id, vc_data.name,
20511 + &vc_data.space_used, &vc_data.space_total,
20512 + &vc_data.inodes_used, &vc_data.inodes_total,
20513 + &vc_data.reserved, &vc_data.flags);
20517 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20522 +#ifdef CONFIG_COMPAT
20524 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
20526 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
20529 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20532 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
20533 + &vc_data.space_used, &vc_data.space_total,
20534 + &vc_data.inodes_used, &vc_data.inodes_total,
20535 + &vc_data.reserved, &vc_data.flags);
20539 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20544 +#endif /* CONFIG_COMPAT */
20547 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
20549 + struct dl_info *dli;
20550 + __u64 blimit, bfree, bavail;
20553 + dli = locate_dl_info(sb, dx_current_tag());
20557 + spin_lock(&dli->dl_lock);
20558 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
20561 + /* reduce max inodes available to limit */
20562 + if (buf->f_files > dli->dl_inodes_total)
20563 + buf->f_files = dli->dl_inodes_total;
20565 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
20566 + /* reduce free inodes to min */
20567 + if (ifree < buf->f_ffree)
20568 + buf->f_ffree = ifree;
20571 + if (dli->dl_space_total == DLIM_INFINITY)
20574 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
20576 + if (dli->dl_space_total < dli->dl_space_used)
20579 + bfree = (dli->dl_space_total - dli->dl_space_used)
20580 + >> sb->s_blocksize_bits;
20582 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
20583 + if (bavail < dli->dl_space_used)
20586 + bavail = (bavail - dli->dl_space_used)
20587 + >> sb->s_blocksize_bits;
20589 + /* reduce max space available to limit */
20590 + if (buf->f_blocks > blimit)
20591 + buf->f_blocks = blimit;
20593 + /* reduce free space to min */
20594 + if (bfree < buf->f_bfree)
20595 + buf->f_bfree = bfree;
20597 + /* reduce avail space to min */
20598 + if (bavail < buf->f_bavail)
20599 + buf->f_bavail = bavail;
20602 + spin_unlock(&dli->dl_lock);
20603 + put_dl_info(dli);
20608 +#include <linux/module.h>
20610 +EXPORT_SYMBOL_GPL(locate_dl_info);
20611 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
20613 diff -NurpP --minimal linux-3.0/kernel/vserver/helper.c linux-3.0-vs2.3.1-pre7/kernel/vserver/helper.c
20614 --- linux-3.0/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
20615 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/helper.c 2011-06-10 22:11:24.000000000 +0200
20618 + * linux/kernel/vserver/helper.c
20620 + * Virtual Context Support
20622 + * Copyright (C) 2004-2007 Herbert Pötzl
20624 + * V0.01 basic helper
20628 +#include <linux/kmod.h>
20629 +#include <linux/reboot.h>
20630 +#include <linux/vs_context.h>
20631 +#include <linux/vs_network.h>
20632 +#include <linux/vserver/signal.h>
20635 +char vshelper_path[255] = "/sbin/vshelper";
20638 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
20642 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
20643 + printk( KERN_WARNING
20644 + "%s: (%s %s) returned %s with %d\n",
20645 + name, argv[1], argv[2],
20646 + sync ? "sync" : "async", ret);
20648 + vxdprintk(VXD_CBIT(switch, 4),
20649 + "%s: (%s %s) returned %s with %d",
20650 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
20655 + * vshelper path is set via /proc/sys
20656 + * invoked by vserver sys_reboot(), with
20657 + * the following arguments
20659 + * argv [0] = vshelper_path;
20660 + * argv [1] = action: "restart", "halt", "poweroff", ...
20661 + * argv [2] = context identifier
20663 + * envp [*] = type-specific parameters
20666 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
20668 + char id_buf[8], cmd_buf[16];
20669 + char uid_buf[16], pid_buf[16];
20672 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20673 + char *envp[] = {"HOME=/", "TERM=linux",
20674 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
20675 + uid_buf, pid_buf, cmd_buf, 0};
20677 + if (vx_info_state(vxi, VXS_HELPER))
20679 + vxi->vx_state |= VXS_HELPER;
20681 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20683 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20684 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
20685 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
20688 + case LINUX_REBOOT_CMD_RESTART:
20689 + argv[1] = "restart";
20692 + case LINUX_REBOOT_CMD_HALT:
20693 + argv[1] = "halt";
20696 + case LINUX_REBOOT_CMD_POWER_OFF:
20697 + argv[1] = "poweroff";
20700 + case LINUX_REBOOT_CMD_SW_SUSPEND:
20701 + argv[1] = "swsusp";
20704 + case LINUX_REBOOT_CMD_OOM:
20709 + vxi->vx_state &= ~VXS_HELPER;
20713 + ret = do_vshelper(vshelper_path, argv, envp, 0);
20714 + vxi->vx_state &= ~VXS_HELPER;
20715 + __wakeup_vx_info(vxi);
20716 + return (ret) ? -EPERM : 0;
20720 +long vs_reboot(unsigned int cmd, void __user *arg)
20722 + struct vx_info *vxi = current_vx_info();
20725 + vxdprintk(VXD_CBIT(misc, 5),
20726 + "vs_reboot(%p[#%d],%u)",
20727 + vxi, vxi ? vxi->vx_id : 0, cmd);
20729 + ret = vs_reboot_helper(vxi, cmd, arg);
20733 + vxi->reboot_cmd = cmd;
20734 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20736 + case LINUX_REBOOT_CMD_RESTART:
20737 + case LINUX_REBOOT_CMD_HALT:
20738 + case LINUX_REBOOT_CMD_POWER_OFF:
20739 + vx_info_kill(vxi, 0, SIGKILL);
20740 + vx_info_kill(vxi, 1, SIGKILL);
20748 +long vs_oom_action(unsigned int cmd)
20750 + struct vx_info *vxi = current_vx_info();
20753 + vxdprintk(VXD_CBIT(misc, 5),
20754 + "vs_oom_action(%p[#%d],%u)",
20755 + vxi, vxi ? vxi->vx_id : 0, cmd);
20757 + ret = vs_reboot_helper(vxi, cmd, NULL);
20761 + vxi->reboot_cmd = cmd;
20762 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
20763 + vx_info_kill(vxi, 0, SIGKILL);
20764 + vx_info_kill(vxi, 1, SIGKILL);
20770 + * argv [0] = vshelper_path;
20771 + * argv [1] = action: "startup", "shutdown"
20772 + * argv [2] = context identifier
20774 + * envp [*] = type-specific parameters
20777 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
20779 + char id_buf[8], cmd_buf[16];
20780 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20781 + char *envp[] = {"HOME=/", "TERM=linux",
20782 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20784 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
20787 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
20788 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20791 + case VSC_STARTUP:
20792 + argv[1] = "startup";
20794 + case VSC_SHUTDOWN:
20795 + argv[1] = "shutdown";
20801 + return do_vshelper(vshelper_path, argv, envp, 1);
20806 + * argv [0] = vshelper_path;
20807 + * argv [1] = action: "netup", "netdown"
20808 + * argv [2] = context identifier
20810 + * envp [*] = type-specific parameters
20813 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
20815 + char id_buf[8], cmd_buf[16];
20816 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
20817 + char *envp[] = {"HOME=/", "TERM=linux",
20818 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
20820 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
20823 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
20824 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
20828 + argv[1] = "netup";
20830 + case VSC_NETDOWN:
20831 + argv[1] = "netdown";
20837 + return do_vshelper(vshelper_path, argv, envp, 1);
20840 diff -NurpP --minimal linux-3.0/kernel/vserver/history.c linux-3.0-vs2.3.1-pre7/kernel/vserver/history.c
20841 --- linux-3.0/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
20842 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/history.c 2011-06-10 22:11:24.000000000 +0200
20845 + * kernel/vserver/history.c
20847 + * Virtual Context History Backtrace
20849 + * Copyright (C) 2004-2007 Herbert Pötzl
20851 + * V0.01 basic structure
20852 + * V0.02 hash/unhash and trace
20853 + * V0.03 preemption fixes
20857 +#include <linux/module.h>
20858 +#include <asm/uaccess.h>
20860 +#include <linux/vserver/context.h>
20861 +#include <linux/vserver/debug.h>
20862 +#include <linux/vserver/debug_cmd.h>
20863 +#include <linux/vserver/history.h>
20866 +#ifdef CONFIG_VSERVER_HISTORY
20867 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
20869 +#define VXH_SIZE 64
20872 +struct _vx_history {
20873 + unsigned int counter;
20875 + struct _vx_hist_entry entry[VXH_SIZE + 1];
20879 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
20881 +unsigned volatile int vxh_active = 1;
20883 +static atomic_t sequence = ATOMIC_INIT(0);
20888 + * requires disabled preemption */
20890 +struct _vx_hist_entry *vxh_advance(void *loc)
20892 + unsigned int cpu = smp_processor_id();
20893 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
20894 + struct _vx_hist_entry *entry;
20895 + unsigned int index;
20897 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
20898 + entry = &hist->entry[index];
20900 + entry->seq = atomic_inc_return(&sequence);
20901 + entry->loc = loc;
20905 +EXPORT_SYMBOL_GPL(vxh_advance);
20908 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
20910 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
20913 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
20915 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
20916 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
20917 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
20918 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
20920 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
20922 + switch (e->type) {
20923 + case VXH_THROW_OOPS:
20924 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
20927 + case VXH_GET_VX_INFO:
20928 + case VXH_PUT_VX_INFO:
20929 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20931 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
20932 + VXH_VXI_ARGS(e));
20935 + case VXH_INIT_VX_INFO:
20936 + case VXH_SET_VX_INFO:
20937 + case VXH_CLR_VX_INFO:
20938 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20940 + (e->type == VXH_INIT_VX_INFO) ? "init" :
20941 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
20942 + VXH_VXI_ARGS(e), e->sc.data);
20945 + case VXH_CLAIM_VX_INFO:
20946 + case VXH_RELEASE_VX_INFO:
20947 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
20949 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
20950 + VXH_VXI_ARGS(e), e->sc.data);
20953 + case VXH_ALLOC_VX_INFO:
20954 + case VXH_DEALLOC_VX_INFO:
20955 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
20957 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
20958 + VXH_VXI_ARGS(e));
20961 + case VXH_HASH_VX_INFO:
20962 + case VXH_UNHASH_VX_INFO:
20963 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
20965 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
20966 + VXH_VXI_ARGS(e));
20969 + case VXH_LOC_VX_INFO:
20970 + case VXH_LOOKUP_VX_INFO:
20971 + case VXH_CREATE_VX_INFO:
20972 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
20974 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
20975 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
20976 + e->ll.arg, VXH_VXI_ARGS(e));
20981 +static void __vxh_dump_history(void)
20983 + unsigned int i, cpu;
20985 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
20986 + atomic_read(&sequence), NR_CPUS);
20988 + for (i = 0; i < VXH_SIZE; i++) {
20989 + for_each_online_cpu(cpu) {
20990 + struct _vx_history *hist =
20991 + &per_cpu(vx_history_buffer, cpu);
20992 + unsigned int index = (hist->counter - i) % VXH_SIZE;
20993 + struct _vx_hist_entry *entry = &hist->entry[index];
20995 + vxh_dump_entry(entry, cpu);
21000 +void vxh_dump_history(void)
21004 + local_irq_enable();
21006 + local_irq_disable();
21008 + __vxh_dump_history();
21012 +/* vserver syscall commands below here */
21015 +int vc_dump_history(uint32_t id)
21018 + __vxh_dump_history();
21025 +int do_read_history(struct __user _vx_hist_entry *data,
21026 + int cpu, uint32_t *index, uint32_t *count)
21028 + int pos, ret = 0;
21029 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
21030 + int end = hist->counter;
21031 + int start = end - VXH_SIZE + 2;
21032 + int idx = *index;
21034 + /* special case: get current pos */
21040 + /* have we lost some data? */
21044 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
21045 + struct _vx_hist_entry *entry =
21046 + &hist->entry[idx % VXH_SIZE];
21048 + /* send entry to userspace */
21049 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
21053 + /* save new index and count */
21056 + return ret ? ret : (*index < end);
21059 +int vc_read_history(uint32_t id, void __user *data)
21061 + struct vcmd_read_history_v0 vc_data;
21064 + if (id >= NR_CPUS)
21067 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21070 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
21071 + id, &vc_data.index, &vc_data.count);
21073 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21078 +#ifdef CONFIG_COMPAT
21080 +int vc_read_history_x32(uint32_t id, void __user *data)
21082 + struct vcmd_read_history_v0_x32 vc_data;
21085 + if (id >= NR_CPUS)
21088 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21091 + ret = do_read_history((struct __user _vx_hist_entry *)
21092 + compat_ptr(vc_data.data_ptr),
21093 + id, &vc_data.index, &vc_data.count);
21095 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21100 +#endif /* CONFIG_COMPAT */
21102 diff -NurpP --minimal linux-3.0/kernel/vserver/inet.c linux-3.0-vs2.3.1-pre7/kernel/vserver/inet.c
21103 --- linux-3.0/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
21104 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/inet.c 2011-06-13 18:20:44.000000000 +0200
21107 +#include <linux/in.h>
21108 +#include <linux/inetdevice.h>
21109 +#include <linux/vs_inet.h>
21110 +#include <linux/vs_inet6.h>
21111 +#include <linux/vserver/debug.h>
21112 +#include <net/route.h>
21113 +#include <net/addrconf.h>
21116 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
21120 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
21123 + struct nx_addr_v4 *ptr;
21125 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
21126 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
21133 + vxdprintk(VXD_CBIT(net, 2),
21134 + "nx_v4_addr_conflict(%p,%p): %d",
21135 + nxi1, nxi2, ret);
21141 +#ifdef CONFIG_IPV6
21143 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
21147 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
21150 + struct nx_addr_v6 *ptr;
21152 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
21153 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
21160 + vxdprintk(VXD_CBIT(net, 2),
21161 + "nx_v6_addr_conflict(%p,%p): %d",
21162 + nxi1, nxi2, ret);
21169 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
21171 + struct in_device *in_dev;
21172 + struct in_ifaddr **ifap;
21173 + struct in_ifaddr *ifa;
21178 + in_dev = in_dev_get(dev);
21182 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
21183 + ifap = &ifa->ifa_next) {
21184 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
21189 + in_dev_put(in_dev);
21195 +#ifdef CONFIG_IPV6
21197 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
21199 + struct inet6_dev *in_dev;
21200 + struct inet6_ifaddr *ifa;
21205 + in_dev = in6_dev_get(dev);
21209 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
21210 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
21211 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
21216 + in6_dev_put(in_dev);
21223 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
21229 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
21231 +#ifdef CONFIG_IPV6
21233 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
21238 + vxdprintk(VXD_CBIT(net, 3),
21239 + "dev_in_nx_info(%p,%p[#%d]) = %d",
21240 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
21244 +struct rtable *ip_v4_find_src(struct net *net, struct nx_info *nxi,
21245 + struct flowi4 *fl4)
21247 + struct rtable *rt;
21252 + /* FIXME: handle lback only case */
21253 + if (!NX_IPV4(nxi))
21254 + return ERR_PTR(EPERM);
21256 + vxdprintk(VXD_CBIT(net, 4),
21257 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
21258 + nxi, nxi ? nxi->nx_id : 0,
21259 + NIPQUAD(fl4->saddr), NIPQUAD(fl4->daddr));
21261 + /* single IP is unconditional */
21262 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
21263 + (fl4->saddr == INADDR_ANY))
21264 + fl4->saddr = nxi->v4.ip[0].s_addr;
21266 + if (fl4->saddr == INADDR_ANY) {
21267 + struct nx_addr_v4 *ptr;
21268 + __be32 found = 0;
21270 + rt = __ip_route_output_key(net, fl4);
21271 + if (!IS_ERR(rt)) {
21272 + found = fl4->saddr;
21274 + vxdprintk(VXD_CBIT(net, 4),
21275 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
21276 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(found));
21277 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
21281 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
21282 + __be32 primary = ptr->ip[0].s_addr;
21283 + __be32 mask = ptr->mask.s_addr;
21284 + __be32 neta = primary & mask;
21286 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
21287 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
21288 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
21289 + NIPQUAD(mask), NIPQUAD(neta));
21290 + if ((found & mask) != neta)
21293 + fl4->saddr = primary;
21294 + rt = __ip_route_output_key(net, fl4);
21295 + vxdprintk(VXD_CBIT(net, 4),
21296 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
21297 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(primary));
21298 + if (!IS_ERR(rt)) {
21299 + found = fl4->saddr;
21301 + if (found == primary)
21305 + /* still no source ip? */
21306 + found = ipv4_is_loopback(fl4->daddr)
21307 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
21309 + /* assign src ip to flow */
21310 + fl4->saddr = found;
21313 + if (!v4_addr_in_nx_info(nxi, fl4->saddr, NXA_MASK_BIND))
21314 + return ERR_PTR(EPERM);
21317 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
21318 + if (ipv4_is_loopback(fl4->daddr))
21319 + fl4->daddr = nxi->v4_lback.s_addr;
21320 + if (ipv4_is_loopback(fl4->saddr))
21321 + fl4->saddr = nxi->v4_lback.s_addr;
21322 + } else if (ipv4_is_loopback(fl4->daddr) &&
21323 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
21324 + return ERR_PTR(EPERM);
21329 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
21331 diff -NurpP --minimal linux-3.0/kernel/vserver/init.c linux-3.0-vs2.3.1-pre7/kernel/vserver/init.c
21332 --- linux-3.0/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
21333 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/init.c 2011-06-10 22:11:24.000000000 +0200
21336 + * linux/kernel/init.c
21338 + * Virtual Server Init
21340 + * Copyright (C) 2004-2007 Herbert Pötzl
21342 + * V0.01 basic structure
21346 +#include <linux/init.h>
21348 +int vserver_register_sysctl(void);
21349 +void vserver_unregister_sysctl(void);
21352 +static int __init init_vserver(void)
21356 +#ifdef CONFIG_VSERVER_DEBUG
21357 + vserver_register_sysctl();
21363 +static void __exit exit_vserver(void)
21366 +#ifdef CONFIG_VSERVER_DEBUG
21367 + vserver_unregister_sysctl();
21372 +/* FIXME: GFP_ZONETYPES gone
21373 +long vx_slab[GFP_ZONETYPES]; */
21377 +module_init(init_vserver);
21378 +module_exit(exit_vserver);
21380 diff -NurpP --minimal linux-3.0/kernel/vserver/inode.c linux-3.0-vs2.3.1-pre7/kernel/vserver/inode.c
21381 --- linux-3.0/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
21382 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/inode.c 2011-06-10 22:11:24.000000000 +0200
21385 + * linux/kernel/vserver/inode.c
21387 + * Virtual Server: File System Support
21389 + * Copyright (C) 2004-2007 Herbert Pötzl
21391 + * V0.01 separated from vcontext V0.05
21392 + * V0.02 moved to tag (instead of xid)
21396 +#include <linux/tty.h>
21397 +#include <linux/proc_fs.h>
21398 +#include <linux/devpts_fs.h>
21399 +#include <linux/fs.h>
21400 +#include <linux/file.h>
21401 +#include <linux/mount.h>
21402 +#include <linux/parser.h>
21403 +#include <linux/namei.h>
21404 +#include <linux/vserver/inode.h>
21405 +#include <linux/vserver/inode_cmd.h>
21406 +#include <linux/vs_base.h>
21407 +#include <linux/vs_tag.h>
21409 +#include <asm/uaccess.h>
21412 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21414 + struct proc_dir_entry *entry;
21416 + if (!in || !in->i_sb)
21419 + *flags = IATTR_TAG
21420 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
21421 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
21422 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
21423 + | (IS_COW(in) ? IATTR_COW : 0);
21424 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
21426 + if (S_ISDIR(in->i_mode))
21427 + *mask |= IATTR_BARRIER;
21429 + if (IS_TAGGED(in)) {
21430 + *tag = in->i_tag;
21431 + *mask |= IATTR_TAG;
21434 + switch (in->i_sb->s_magic) {
21435 + case PROC_SUPER_MAGIC:
21436 + entry = PROC_I(in)->pde;
21438 + /* check for specific inodes? */
21440 + *mask |= IATTR_FLAGS;
21442 + *flags |= (entry->vx_flags & IATTR_FLAGS);
21444 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
21447 + case DEVPTS_SUPER_MAGIC:
21448 + *tag = in->i_tag;
21449 + *mask |= IATTR_TAG;
21458 +int vc_get_iattr(void __user *data)
21460 + struct path path;
21461 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
21464 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21467 + ret = user_lpath(vc_data.name, &path);
21469 + ret = __vc_get_iattr(path.dentry->d_inode,
21470 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21476 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21481 +#ifdef CONFIG_COMPAT
21483 +int vc_get_iattr_x32(void __user *data)
21485 + struct path path;
21486 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
21489 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21492 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21494 + ret = __vc_get_iattr(path.dentry->d_inode,
21495 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21501 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21506 +#endif /* CONFIG_COMPAT */
21509 +int vc_fget_iattr(uint32_t fd, void __user *data)
21511 + struct file *filp;
21512 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
21515 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21519 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21522 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
21523 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21527 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21533 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
21535 + struct inode *in = de->d_inode;
21536 + int error = 0, is_proc = 0, has_tag = 0;
21537 + struct iattr attr = { 0 };
21539 + if (!in || !in->i_sb)
21542 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
21543 + if ((*mask & IATTR_FLAGS) && !is_proc)
21546 + has_tag = IS_TAGGED(in) ||
21547 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
21548 + if ((*mask & IATTR_TAG) && !has_tag)
21551 + mutex_lock(&in->i_mutex);
21552 + if (*mask & IATTR_TAG) {
21553 + attr.ia_tag = *tag;
21554 + attr.ia_valid |= ATTR_TAG;
21557 + if (*mask & IATTR_FLAGS) {
21558 + struct proc_dir_entry *entry = PROC_I(in)->pde;
21559 + unsigned int iflags = PROC_I(in)->vx_flags;
21561 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
21562 + | (*flags & IATTR_FLAGS);
21563 + PROC_I(in)->vx_flags = iflags;
21565 + entry->vx_flags = iflags;
21568 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
21569 + IATTR_BARRIER | IATTR_COW)) {
21570 + int iflags = in->i_flags;
21571 + int vflags = in->i_vflags;
21573 + if (*mask & IATTR_IMMUTABLE) {
21574 + if (*flags & IATTR_IMMUTABLE)
21575 + iflags |= S_IMMUTABLE;
21577 + iflags &= ~S_IMMUTABLE;
21579 + if (*mask & IATTR_IXUNLINK) {
21580 + if (*flags & IATTR_IXUNLINK)
21581 + iflags |= S_IXUNLINK;
21583 + iflags &= ~S_IXUNLINK;
21585 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
21586 + if (*flags & IATTR_BARRIER)
21587 + vflags |= V_BARRIER;
21589 + vflags &= ~V_BARRIER;
21591 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
21592 + if (*flags & IATTR_COW)
21595 + vflags &= ~V_COW;
21597 + if (in->i_op && in->i_op->sync_flags) {
21598 + error = in->i_op->sync_flags(in, iflags, vflags);
21604 + if (attr.ia_valid) {
21605 + if (in->i_op && in->i_op->setattr)
21606 + error = in->i_op->setattr(de, &attr);
21608 + error = inode_change_ok(in, &attr);
21610 + setattr_copy(in, &attr);
21611 + mark_inode_dirty(in);
21617 + mutex_unlock(&in->i_mutex);
21621 +int vc_set_iattr(void __user *data)
21623 + struct path path;
21624 + struct vcmd_ctx_iattr_v1 vc_data;
21627 + if (!capable(CAP_LINUX_IMMUTABLE))
21629 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21632 + ret = user_lpath(vc_data.name, &path);
21634 + ret = __vc_set_iattr(path.dentry,
21635 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21639 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21644 +#ifdef CONFIG_COMPAT
21646 +int vc_set_iattr_x32(void __user *data)
21648 + struct path path;
21649 + struct vcmd_ctx_iattr_v1_x32 vc_data;
21652 + if (!capable(CAP_LINUX_IMMUTABLE))
21654 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21657 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
21659 + ret = __vc_set_iattr(path.dentry,
21660 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
21664 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21669 +#endif /* CONFIG_COMPAT */
21671 +int vc_fset_iattr(uint32_t fd, void __user *data)
21673 + struct file *filp;
21674 + struct vcmd_ctx_fiattr_v0 vc_data;
21677 + if (!capable(CAP_LINUX_IMMUTABLE))
21679 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21683 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
21686 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
21687 + &vc_data.flags, &vc_data.mask);
21691 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21697 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
21699 +static match_table_t tokens = {
21700 + {Opt_notagcheck, "notagcheck"},
21701 +#ifdef CONFIG_PROPAGATE
21702 + {Opt_notag, "notag"},
21703 + {Opt_tag, "tag"},
21704 + {Opt_tagid, "tagid=%u"},
21710 +static void __dx_parse_remove(char *string, char *opt)
21712 + char *p = strstr(string, opt);
21716 + while (*q != '\0' && *q != ',')
21725 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
21726 + unsigned long *flags)
21729 + substring_t args[MAX_OPT_ARGS];
21731 + char *s, *p, *opts;
21732 +#if defined(CONFIG_PROPAGATE) || defined(CONFIG_VSERVER_WARN)
21738 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
21743 + while ((p = strsep(&opts, ",")) != NULL) {
21744 + token = match_token(p, tokens, args);
21747 +#ifdef CONFIG_PROPAGATE
21752 + __dx_parse_remove(s, "tag");
21753 + *mnt_flags |= MNT_TAGID;
21754 + set |= MNT_TAGID;
21758 + __dx_parse_remove(s, "notag");
21759 + *mnt_flags |= MNT_NOTAG;
21760 + set |= MNT_NOTAG;
21763 + if (tag && !match_int(args, &option))
21766 + __dx_parse_remove(s, "tagid");
21767 + *mnt_flags |= MNT_TAGID;
21768 + set |= MNT_TAGID;
21771 + case Opt_notagcheck:
21773 + __dx_parse_remove(s, "notagcheck");
21774 + *flags |= MS_NOTAGCHECK;
21775 + set |= MS_NOTAGCHECK;
21778 + vxdprintk(VXD_CBIT(tag, 7),
21779 + "dx_parse_tag(" VS_Q("%s") "): %d:#%d",
21780 + p, token, option);
21783 + strcpy(string, s);
21788 +#ifdef CONFIG_PROPAGATE
21790 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
21792 + tag_t new_tag = 0;
21793 + struct vfsmount *mnt;
21798 + mnt = nd->path.mnt;
21802 + propagate = (mnt->mnt_flags & MNT_TAGID);
21804 + new_tag = mnt->mnt_tag;
21806 + vxdprintk(VXD_CBIT(tag, 7),
21807 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
21808 + inode, inode->i_ino, inode->i_tag,
21809 + new_tag, (propagate) ? 1 : 0);
21812 + inode->i_tag = new_tag;
21815 +#include <linux/module.h>
21817 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
21819 +#endif /* CONFIG_PROPAGATE */
21821 diff -NurpP --minimal linux-3.0/kernel/vserver/limit.c linux-3.0-vs2.3.1-pre7/kernel/vserver/limit.c
21822 --- linux-3.0/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
21823 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/limit.c 2011-06-10 22:11:24.000000000 +0200
21826 + * linux/kernel/vserver/limit.c
21828 + * Virtual Server: Context Limits
21830 + * Copyright (C) 2004-2010 Herbert Pötzl
21832 + * V0.01 broken out from vcontext V0.05
21833 + * V0.02 changed vcmds to vxi arg
21834 + * V0.03 added memory cgroup support
21838 +#include <linux/sched.h>
21839 +#include <linux/module.h>
21840 +#include <linux/memcontrol.h>
21841 +#include <linux/res_counter.h>
21842 +#include <linux/vs_limit.h>
21843 +#include <linux/vserver/limit.h>
21844 +#include <linux/vserver/limit_cmd.h>
21846 +#include <asm/uaccess.h>
21849 +const char *vlimit_name[NUM_LIMITS] = {
21850 +#ifdef CONFIG_VSERVER_LEGACY_MEM
21851 + [RLIMIT_RSS] = "RSS",
21852 + [RLIMIT_AS] = "VM",
21853 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
21854 + [RLIMIT_CPU] = "CPU",
21855 + [RLIMIT_NPROC] = "NPROC",
21856 + [RLIMIT_NOFILE] = "NOFILE",
21857 + [RLIMIT_LOCKS] = "LOCKS",
21858 + [RLIMIT_SIGPENDING] = "SIGP",
21859 + [RLIMIT_MSGQUEUE] = "MSGQ",
21861 + [VLIMIT_NSOCK] = "NSOCK",
21862 + [VLIMIT_OPENFD] = "OPENFD",
21863 + [VLIMIT_SHMEM] = "SHMEM",
21864 + [VLIMIT_DENTRY] = "DENTRY",
21867 +EXPORT_SYMBOL_GPL(vlimit_name);
21869 +#define MASK_ENTRY(x) (1 << (x))
21871 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
21874 + , /* softlimit */
21875 +#ifdef CONFIG_VSERVER_LEGACY_MEM
21876 + MASK_ENTRY( RLIMIT_RSS ) |
21877 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
21880 +#ifdef CONFIG_VSERVER_LEGACY_MEM
21881 + MASK_ENTRY( RLIMIT_RSS ) |
21882 + MASK_ENTRY( RLIMIT_AS ) |
21883 +#endif /* CONFIG_VSERVER_LEGACY_MEM */
21884 + MASK_ENTRY( RLIMIT_NPROC ) |
21885 + MASK_ENTRY( RLIMIT_NOFILE ) |
21886 + MASK_ENTRY( RLIMIT_LOCKS ) |
21887 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
21889 + MASK_ENTRY( VLIMIT_NSOCK ) |
21890 + MASK_ENTRY( VLIMIT_OPENFD ) |
21891 + MASK_ENTRY( VLIMIT_SHMEM ) |
21892 + MASK_ENTRY( VLIMIT_DENTRY ) |
21895 + /* accounting only */
21896 +uint32_t account_mask =
21897 + MASK_ENTRY( VLIMIT_SEMARY ) |
21898 + MASK_ENTRY( VLIMIT_NSEMS ) |
21899 + MASK_ENTRY( VLIMIT_MAPPED ) |
21903 +static int is_valid_vlimit(int id)
21905 + uint32_t mask = vlimit_mask.minimum |
21906 + vlimit_mask.softlimit | vlimit_mask.maximum;
21907 + return mask & (1 << id);
21910 +static int is_accounted_vlimit(int id)
21912 + if (is_valid_vlimit(id))
21914 + return account_mask & (1 << id);
21918 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
21920 + rlim_t limit = __rlim_soft(&vxi->limit, id);
21921 + return VX_VLIM(limit);
21924 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
21926 + rlim_t limit = __rlim_hard(&vxi->limit, id);
21927 + return VX_VLIM(limit);
21930 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
21931 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
21933 + if (!is_valid_vlimit(id))
21937 + *minimum = CRLIM_UNSET;
21939 + *softlimit = vc_get_soft(vxi, id);
21941 + *maximum = vc_get_hard(vxi, id);
21945 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
21947 + struct vcmd_ctx_rlimit_v0 vc_data;
21950 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21953 + ret = do_get_rlimit(vxi, vc_data.id,
21954 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
21958 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21963 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
21964 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
21966 + if (!is_valid_vlimit(id))
21969 + if (maximum != CRLIM_KEEP)
21970 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
21971 + if (softlimit != CRLIM_KEEP)
21972 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
21974 + /* clamp soft limit */
21975 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
21976 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
21981 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
21983 + struct vcmd_ctx_rlimit_v0 vc_data;
21985 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21988 + return do_set_rlimit(vxi, vc_data.id,
21989 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
21992 +#ifdef CONFIG_IA32_EMULATION
21994 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
21996 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
21998 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22001 + return do_set_rlimit(vxi, vc_data.id,
22002 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
22005 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
22007 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
22010 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22013 + ret = do_get_rlimit(vxi, vc_data.id,
22014 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
22018 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22023 +#endif /* CONFIG_IA32_EMULATION */
22026 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
22028 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
22034 +static inline void vx_reset_hits(struct _vx_limit *limit)
22038 + for (lim = 0; lim < NUM_LIMITS; lim++) {
22039 + atomic_set(&__rlim_lhit(limit, lim), 0);
22043 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
22045 + vx_reset_hits(&vxi->limit);
22049 +static inline void vx_reset_minmax(struct _vx_limit *limit)
22054 + for (lim = 0; lim < NUM_LIMITS; lim++) {
22055 + value = __rlim_get(limit, lim);
22056 + __rlim_rmax(limit, lim) = value;
22057 + __rlim_rmin(limit, lim) = value;
22061 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
22063 + vx_reset_minmax(&vxi->limit);
22068 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
22070 + struct vcmd_rlimit_stat_v0 vc_data;
22071 + struct _vx_limit *limit = &vxi->limit;
22074 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22078 + if (!is_accounted_vlimit(id))
22081 + vx_limit_fixup(limit, id);
22082 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
22083 + vc_data.value = __rlim_get(limit, id);
22084 + vc_data.minimum = __rlim_rmin(limit, id);
22085 + vc_data.maximum = __rlim_rmax(limit, id);
22087 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22093 +void vx_vsi_meminfo(struct sysinfo *val)
22095 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
22096 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22097 + u64 res_limit, res_usage;
22102 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
22103 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
22105 + if (res_limit != RESOURCE_MAX)
22106 + val->totalram = (res_limit >> PAGE_SHIFT);
22107 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
22108 + val->bufferram = 0;
22109 + val->totalhigh = 0;
22110 + val->freehigh = 0;
22111 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
22115 +void vx_vsi_swapinfo(struct sysinfo *val)
22117 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
22118 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
22119 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22120 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
22121 + s64 swap_limit, swap_usage;
22126 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
22127 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
22128 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
22129 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
22131 + if (res_limit == RESOURCE_MAX)
22134 + swap_limit = memsw_limit - res_limit;
22135 + if (memsw_limit != RESOURCE_MAX)
22136 + val->totalswap = swap_limit >> PAGE_SHIFT;
22138 + swap_usage = memsw_usage - res_usage;
22139 + val->freeswap = (swap_usage < swap_limit) ?
22140 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
22141 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
22142 + val->totalswap = 0;
22143 + val->freeswap = 0;
22144 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
22145 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
22149 +long vx_vsi_cached(struct sysinfo *val)
22151 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
22152 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
22154 + return mem_cgroup_stat_read_cache(mcg);
22161 +unsigned long vx_badness(struct task_struct *task, struct mm_struct *mm)
22163 + struct vx_info *vxi = mm->mm_vx_info;
22164 + unsigned long points;
22170 + points = vxi->vx_badness_bias;
22172 + v = __vx_cres_array_fixup(&vxi->limit, VLA_RSS);
22173 + w = __rlim_soft(&vxi->limit, RLIMIT_RSS);
22174 + points += (v > w) ? (v - w) : 0;
22179 diff -NurpP --minimal linux-3.0/kernel/vserver/limit_init.h linux-3.0-vs2.3.1-pre7/kernel/vserver/limit_init.h
22180 --- linux-3.0/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
22181 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/limit_init.h 2011-06-10 22:11:24.000000000 +0200
22185 +static inline void vx_info_init_limit(struct _vx_limit *limit)
22189 + for (lim = 0; lim < NUM_LIMITS; lim++) {
22190 + __rlim_soft(limit, lim) = RLIM_INFINITY;
22191 + __rlim_hard(limit, lim) = RLIM_INFINITY;
22192 + __rlim_set(limit, lim, 0);
22193 + atomic_set(&__rlim_lhit(limit, lim), 0);
22194 + __rlim_rmin(limit, lim) = 0;
22195 + __rlim_rmax(limit, lim) = 0;
22199 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
22204 + for (lim = 0; lim < NUM_LIMITS; lim++) {
22205 + if ((1 << lim) & VLIM_NOCHECK)
22207 + value = __rlim_get(limit, lim);
22208 + vxwprintk_xid(value,
22209 + "!!! limit: %p[%s,%d] = %ld on exit.",
22210 + limit, vlimit_name[lim], lim, (long)value);
22214 diff -NurpP --minimal linux-3.0/kernel/vserver/limit_proc.h linux-3.0-vs2.3.1-pre7/kernel/vserver/limit_proc.h
22215 --- linux-3.0/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
22216 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/limit_proc.h 2011-06-10 22:11:24.000000000 +0200
22218 +#ifndef _VX_LIMIT_PROC_H
22219 +#define _VX_LIMIT_PROC_H
22221 +#include <linux/vserver/limit_int.h>
22224 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
22225 +#define VX_LIMIT_TOP \
22226 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
22228 +#define VX_LIMIT_ARG(r) \
22229 + (unsigned long)__rlim_get(limit, r), \
22230 + (unsigned long)__rlim_rmin(limit, r), \
22231 + (unsigned long)__rlim_rmax(limit, r), \
22232 + VX_VLIM(__rlim_soft(limit, r)), \
22233 + VX_VLIM(__rlim_hard(limit, r)), \
22234 + atomic_read(&__rlim_lhit(limit, r))
22236 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
22238 + vx_limit_fixup(limit, -1);
22239 + return sprintf(buffer, VX_LIMIT_TOP
22240 + "PROC" VX_LIMIT_FMT
22241 + "VM" VX_LIMIT_FMT
22242 + "VML" VX_LIMIT_FMT
22243 + "RSS" VX_LIMIT_FMT
22244 + "ANON" VX_LIMIT_FMT
22245 + "RMAP" VX_LIMIT_FMT
22246 + "FILES" VX_LIMIT_FMT
22247 + "OFD" VX_LIMIT_FMT
22248 + "LOCKS" VX_LIMIT_FMT
22249 + "SOCK" VX_LIMIT_FMT
22250 + "MSGQ" VX_LIMIT_FMT
22251 + "SHM" VX_LIMIT_FMT
22252 + "SEMA" VX_LIMIT_FMT
22253 + "SEMS" VX_LIMIT_FMT
22254 + "DENT" VX_LIMIT_FMT,
22255 + VX_LIMIT_ARG(RLIMIT_NPROC),
22256 + VX_LIMIT_ARG(RLIMIT_AS),
22257 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
22258 + VX_LIMIT_ARG(RLIMIT_RSS),
22259 + VX_LIMIT_ARG(VLIMIT_ANON),
22260 + VX_LIMIT_ARG(VLIMIT_MAPPED),
22261 + VX_LIMIT_ARG(RLIMIT_NOFILE),
22262 + VX_LIMIT_ARG(VLIMIT_OPENFD),
22263 + VX_LIMIT_ARG(RLIMIT_LOCKS),
22264 + VX_LIMIT_ARG(VLIMIT_NSOCK),
22265 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
22266 + VX_LIMIT_ARG(VLIMIT_SHMEM),
22267 + VX_LIMIT_ARG(VLIMIT_SEMARY),
22268 + VX_LIMIT_ARG(VLIMIT_NSEMS),
22269 + VX_LIMIT_ARG(VLIMIT_DENTRY));
22272 +#endif /* _VX_LIMIT_PROC_H */
22275 diff -NurpP --minimal linux-3.0/kernel/vserver/network.c linux-3.0-vs2.3.1-pre7/kernel/vserver/network.c
22276 --- linux-3.0/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
22277 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/network.c 2011-06-10 23:20:56.000000000 +0200
22280 + * linux/kernel/vserver/network.c
22282 + * Virtual Server: Network Support
22284 + * Copyright (C) 2003-2007 Herbert Pötzl
22286 + * V0.01 broken out from vcontext V0.05
22287 + * V0.02 cleaned up implementation
22288 + * V0.03 added equiv nx commands
22289 + * V0.04 switch to RCU based hash
22290 + * V0.05 and back to locking again
22291 + * V0.06 changed vcmds to nxi arg
22292 + * V0.07 have __create claim() the nxi
22296 +#include <linux/err.h>
22297 +#include <linux/slab.h>
22298 +#include <linux/rcupdate.h>
22300 +#include <linux/vs_network.h>
22301 +#include <linux/vs_pid.h>
22302 +#include <linux/vserver/network_cmd.h>
22305 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
22306 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
22308 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
22309 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
22312 +static int __init init_network(void)
22314 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
22315 + sizeof(struct nx_addr_v4), 0,
22316 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22317 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
22318 + sizeof(struct nx_addr_v6), 0,
22319 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
22324 +/* __alloc_nx_addr_v4() */
22326 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
22328 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
22329 + nx_addr_v4_cachep, GFP_KERNEL);
22331 + if (!IS_ERR(nxa))
22332 + memset(nxa, 0, sizeof(*nxa));
22336 +/* __dealloc_nx_addr_v4() */
22338 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
22340 + kmem_cache_free(nx_addr_v4_cachep, nxa);
22343 +/* __dealloc_nx_addr_v4_all() */
22345 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
22348 + struct nx_addr_v4 *next = nxa->next;
22350 + __dealloc_nx_addr_v4(nxa);
22356 +#ifdef CONFIG_IPV6
22358 +/* __alloc_nx_addr_v6() */
22360 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
22362 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
22363 + nx_addr_v6_cachep, GFP_KERNEL);
22365 + if (!IS_ERR(nxa))
22366 + memset(nxa, 0, sizeof(*nxa));
22370 +/* __dealloc_nx_addr_v6() */
22372 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
22374 + kmem_cache_free(nx_addr_v6_cachep, nxa);
22377 +/* __dealloc_nx_addr_v6_all() */
22379 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
22382 + struct nx_addr_v6 *next = nxa->next;
22384 + __dealloc_nx_addr_v6(nxa);
22389 +#endif /* CONFIG_IPV6 */
22391 +/* __alloc_nx_info()
22393 + * allocate an initialized nx_info struct
22394 + * doesn't make it visible (hash) */
22396 +static struct nx_info *__alloc_nx_info(nid_t nid)
22398 + struct nx_info *new = NULL;
22400 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
22402 + /* would this benefit from a slab cache? */
22403 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
22407 + memset(new, 0, sizeof(struct nx_info));
22408 + new->nx_id = nid;
22409 + INIT_HLIST_NODE(&new->nx_hlist);
22410 + atomic_set(&new->nx_usecnt, 0);
22411 + atomic_set(&new->nx_tasks, 0);
22412 + new->nx_state = 0;
22414 + new->nx_flags = NXF_INIT_SET;
22416 + /* rest of init goes here */
22418 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
22419 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
22421 + vxdprintk(VXD_CBIT(nid, 0),
22422 + "alloc_nx_info(%d) = %p", nid, new);
22423 + atomic_inc(&nx_global_ctotal);
22427 +/* __dealloc_nx_info()
22429 + * final disposal of nx_info */
22431 +static void __dealloc_nx_info(struct nx_info *nxi)
22433 + vxdprintk(VXD_CBIT(nid, 0),
22434 + "dealloc_nx_info(%p)", nxi);
22436 + nxi->nx_hlist.next = LIST_POISON1;
22439 + BUG_ON(atomic_read(&nxi->nx_usecnt));
22440 + BUG_ON(atomic_read(&nxi->nx_tasks));
22442 + __dealloc_nx_addr_v4_all(nxi->v4.next);
22444 + nxi->nx_state |= NXS_RELEASED;
22446 + atomic_dec(&nx_global_ctotal);
22449 +static void __shutdown_nx_info(struct nx_info *nxi)
22451 + nxi->nx_state |= NXS_SHUTDOWN;
22452 + vs_net_change(nxi, VSC_NETDOWN);
22455 +/* exported stuff */
22457 +void free_nx_info(struct nx_info *nxi)
22459 + /* context shutdown is mandatory */
22460 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
22462 + /* context must not be hashed */
22463 + BUG_ON(nxi->nx_state & NXS_HASHED);
22465 + BUG_ON(atomic_read(&nxi->nx_usecnt));
22466 + BUG_ON(atomic_read(&nxi->nx_tasks));
22468 + __dealloc_nx_info(nxi);
22472 +void __nx_set_lback(struct nx_info *nxi)
22474 + int nid = nxi->nx_id;
22475 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
22477 + nxi->v4_lback.s_addr = lback;
22480 +extern int __nx_inet_add_lback(__be32 addr);
22481 +extern int __nx_inet_del_lback(__be32 addr);
22484 +/* hash table for nx_info hash */
22486 +#define NX_HASH_SIZE 13
22488 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
22490 +static DEFINE_SPINLOCK(nx_info_hash_lock);
22493 +static inline unsigned int __hashval(nid_t nid)
22495 + return (nid % NX_HASH_SIZE);
22500 +/* __hash_nx_info()
22502 + * add the nxi to the global hash table
22503 + * requires the hash_lock to be held */
22505 +static inline void __hash_nx_info(struct nx_info *nxi)
22507 + struct hlist_head *head;
22509 + vxd_assert_lock(&nx_info_hash_lock);
22510 + vxdprintk(VXD_CBIT(nid, 4),
22511 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
22513 + /* context must not be hashed */
22514 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
22516 + nxi->nx_state |= NXS_HASHED;
22517 + head = &nx_info_hash[__hashval(nxi->nx_id)];
22518 + hlist_add_head(&nxi->nx_hlist, head);
22519 + atomic_inc(&nx_global_cactive);
22522 +/* __unhash_nx_info()
22524 + * remove the nxi from the global hash table
22525 + * requires the hash_lock to be held */
22527 +static inline void __unhash_nx_info(struct nx_info *nxi)
22529 + vxd_assert_lock(&nx_info_hash_lock);
22530 + vxdprintk(VXD_CBIT(nid, 4),
22531 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
22532 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
22534 + /* context must be hashed */
22535 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
22536 + /* but without tasks */
22537 + BUG_ON(atomic_read(&nxi->nx_tasks));
22539 + nxi->nx_state &= ~NXS_HASHED;
22540 + hlist_del(&nxi->nx_hlist);
22541 + atomic_dec(&nx_global_cactive);
22545 +/* __lookup_nx_info()
22547 + * requires the hash_lock to be held
22548 + * doesn't increment the nx_refcnt */
22550 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
22552 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
22553 + struct hlist_node *pos;
22554 + struct nx_info *nxi;
22556 + vxd_assert_lock(&nx_info_hash_lock);
22557 + hlist_for_each(pos, head) {
22558 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22560 + if (nxi->nx_id == nid)
22565 + vxdprintk(VXD_CBIT(nid, 0),
22566 + "__lookup_nx_info(#%u): %p[#%u]",
22567 + nid, nxi, nxi ? nxi->nx_id : 0);
22572 +/* __create_nx_info()
22574 + * create the requested context
22575 + * get(), claim() and hash it */
22577 +static struct nx_info *__create_nx_info(int id)
22579 + struct nx_info *new, *nxi = NULL;
22581 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
22583 + if (!(new = __alloc_nx_info(id)))
22584 + return ERR_PTR(-ENOMEM);
22586 + /* required to make dynamic xids unique */
22587 + spin_lock(&nx_info_hash_lock);
22589 + /* static context requested */
22590 + if ((nxi = __lookup_nx_info(id))) {
22591 + vxdprintk(VXD_CBIT(nid, 0),
22592 + "create_nx_info(%d) = %p (already there)", id, nxi);
22593 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22594 + nxi = ERR_PTR(-EBUSY);
22596 + nxi = ERR_PTR(-EEXIST);
22599 + /* new context */
22600 + vxdprintk(VXD_CBIT(nid, 0),
22601 + "create_nx_info(%d) = %p (new)", id, new);
22602 + claim_nx_info(new, NULL);
22603 + __nx_set_lback(new);
22604 + __hash_nx_info(get_nx_info(new));
22605 + nxi = new, new = NULL;
22608 + spin_unlock(&nx_info_hash_lock);
22610 + __dealloc_nx_info(new);
22616 +/* exported stuff */
22619 +void unhash_nx_info(struct nx_info *nxi)
22621 + __shutdown_nx_info(nxi);
22622 + spin_lock(&nx_info_hash_lock);
22623 + __unhash_nx_info(nxi);
22624 + spin_unlock(&nx_info_hash_lock);
22627 +/* lookup_nx_info()
22629 + * search for a nx_info and get() it
22630 + * negative id means current */
22632 +struct nx_info *lookup_nx_info(int id)
22634 + struct nx_info *nxi = NULL;
22637 + nxi = get_nx_info(current_nx_info());
22638 + } else if (id > 1) {
22639 + spin_lock(&nx_info_hash_lock);
22640 + nxi = get_nx_info(__lookup_nx_info(id));
22641 + spin_unlock(&nx_info_hash_lock);
22646 +/* nid_is_hashed()
22648 + * verify that nid is still hashed */
22650 +int nid_is_hashed(nid_t nid)
22654 + spin_lock(&nx_info_hash_lock);
22655 + hashed = (__lookup_nx_info(nid) != NULL);
22656 + spin_unlock(&nx_info_hash_lock);
22661 +#ifdef CONFIG_PROC_FS
22665 + * get a subset of hashed nids for proc
22666 + * assumes size is at least one */
22668 +int get_nid_list(int index, unsigned int *nids, int size)
22670 + int hindex, nr_nids = 0;
22672 + /* only show current and children */
22673 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
22676 + nids[nr_nids] = nx_current_nid();
22680 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
22681 + struct hlist_head *head = &nx_info_hash[hindex];
22682 + struct hlist_node *pos;
22684 + spin_lock(&nx_info_hash_lock);
22685 + hlist_for_each(pos, head) {
22686 + struct nx_info *nxi;
22691 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
22692 + nids[nr_nids] = nxi->nx_id;
22693 + if (++nr_nids >= size) {
22694 + spin_unlock(&nx_info_hash_lock);
22698 + /* keep the lock time short */
22699 + spin_unlock(&nx_info_hash_lock);
22708 + * migrate task to new network
22709 + * gets nxi, puts old_nxi on change
22712 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
22714 + struct nx_info *old_nxi;
22720 + vxdprintk(VXD_CBIT(nid, 5),
22721 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
22722 + p, nxi, nxi->nx_id,
22723 + atomic_read(&nxi->nx_usecnt),
22724 + atomic_read(&nxi->nx_tasks));
22726 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
22727 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
22730 + if (nx_info_state(nxi, NXS_SHUTDOWN))
22733 + /* maybe disallow this completely? */
22734 + old_nxi = task_get_nx_info(p);
22735 + if (old_nxi == nxi)
22740 + clr_nx_info(&p->nx_info);
22741 + claim_nx_info(nxi, p);
22742 + set_nx_info(&p->nx_info, nxi);
22743 + p->nid = nxi->nx_id;
22746 + vxdprintk(VXD_CBIT(nid, 5),
22747 + "moved task %p into nxi:%p[#%d]",
22748 + p, nxi, nxi->nx_id);
22751 + release_nx_info(old_nxi, p);
22754 + put_nx_info(old_nxi);
22759 +void nx_set_persistent(struct nx_info *nxi)
22761 + vxdprintk(VXD_CBIT(nid, 6),
22762 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
22764 + get_nx_info(nxi);
22765 + claim_nx_info(nxi, NULL);
22768 +void nx_clear_persistent(struct nx_info *nxi)
22770 + vxdprintk(VXD_CBIT(nid, 6),
22771 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
22773 + release_nx_info(nxi, NULL);
22774 + put_nx_info(nxi);
22777 +void nx_update_persistent(struct nx_info *nxi)
22779 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
22780 + nx_set_persistent(nxi);
22782 + nx_clear_persistent(nxi);
22785 +/* vserver syscall commands below here */
22787 +/* taks nid and nx_info functions */
22789 +#include <asm/uaccess.h>
22792 +int vc_task_nid(uint32_t id)
22797 + struct task_struct *tsk;
22800 + tsk = find_task_by_real_pid(id);
22801 + nid = (tsk) ? tsk->nid : -ESRCH;
22802 + rcu_read_unlock();
22804 + nid = nx_current_nid();
22809 +int vc_nx_info(struct nx_info *nxi, void __user *data)
22811 + struct vcmd_nx_info_v0 vc_data;
22813 + vc_data.nid = nxi->nx_id;
22815 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22821 +/* network functions */
22823 +int vc_net_create(uint32_t nid, void __user *data)
22825 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
22826 + struct nx_info *new_nxi;
22829 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22832 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
22835 + new_nxi = __create_nx_info(nid);
22836 + if (IS_ERR(new_nxi))
22837 + return PTR_ERR(new_nxi);
22839 + /* initial flags */
22840 + new_nxi->nx_flags = vc_data.flagword;
22843 + if (vs_net_change(new_nxi, VSC_NETUP))
22846 + ret = nx_migrate_task(current, new_nxi);
22850 + /* return context id on success */
22851 + ret = new_nxi->nx_id;
22853 + /* get a reference for persistent contexts */
22854 + if ((vc_data.flagword & NXF_PERSISTENT))
22855 + nx_set_persistent(new_nxi);
22857 + release_nx_info(new_nxi, NULL);
22858 + put_nx_info(new_nxi);
22863 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
22865 + return nx_migrate_task(current, nxi);
22870 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
22871 + uint16_t type, uint16_t flags)
22873 + struct nx_addr_v4 *nxa = &nxi->v4;
22875 + if (NX_IPV4(nxi)) {
22876 + /* locate last entry */
22877 + for (; nxa->next; nxa = nxa->next);
22878 + nxa->next = __alloc_nx_addr_v4();
22882 + return PTR_ERR(nxa);
22885 + if (nxi->v4.next)
22886 + /* remove single ip for ip list */
22887 + nxi->nx_flags &= ~NXF_SINGLE_IP;
22889 + nxa->ip[0].s_addr = ip;
22890 + nxa->ip[1].s_addr = ip2;
22891 + nxa->mask.s_addr = mask;
22892 + nxa->type = type;
22893 + nxa->flags = flags;
22897 +int do_remove_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
22898 + uint16_t type, uint16_t flags)
22900 + struct nx_addr_v4 *nxa = &nxi->v4;
22903 +/* case NXA_TYPE_ADDR:
22906 + case NXA_TYPE_ANY:
22907 + __dealloc_nx_addr_v4_all(xchg(&nxa->next, NULL));
22908 + memset(nxa, 0, sizeof(*nxa));
22918 +int vc_net_add(struct nx_info *nxi, void __user *data)
22920 + struct vcmd_net_addr_v0 vc_data;
22921 + int index, ret = 0;
22923 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22926 + switch (vc_data.type) {
22927 + case NXA_TYPE_IPV4:
22928 + if ((vc_data.count < 1) || (vc_data.count > 4))
22932 + while (index < vc_data.count) {
22933 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
22934 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
22942 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
22943 + nxi->v4_bcast = vc_data.ip[0];
22947 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
22948 + nxi->v4_lback = vc_data.ip[0];
22959 +int vc_net_remove(struct nx_info *nxi, void __user *data)
22961 + struct vcmd_net_addr_v0 vc_data;
22963 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22966 + switch (vc_data.type) {
22967 + case NXA_TYPE_ANY:
22968 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
22969 + memset(&nxi->v4, 0, sizeof(nxi->v4));
22979 +int vc_net_add_ipv4_v1(struct nx_info *nxi, void __user *data)
22981 + struct vcmd_net_addr_ipv4_v1 vc_data;
22983 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22986 + switch (vc_data.type) {
22987 + case NXA_TYPE_ADDR:
22988 + case NXA_TYPE_MASK:
22989 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
22990 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
22992 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
22993 + nxi->v4_bcast = vc_data.ip;
22996 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
22997 + nxi->v4_lback = vc_data.ip;
23006 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
23008 + struct vcmd_net_addr_ipv4_v2 vc_data;
23010 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23013 + switch (vc_data.type) {
23014 + case NXA_TYPE_ADDR:
23015 + case NXA_TYPE_MASK:
23016 + case NXA_TYPE_RANGE:
23017 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
23018 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
23020 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
23021 + nxi->v4_bcast = vc_data.ip;
23024 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
23025 + nxi->v4_lback = vc_data.ip;
23034 +int vc_net_rem_ipv4_v1(struct nx_info *nxi, void __user *data)
23036 + struct vcmd_net_addr_ipv4_v1 vc_data;
23038 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23041 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, 0,
23042 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
23045 +int vc_net_rem_ipv4(struct nx_info *nxi, void __user *data)
23047 + struct vcmd_net_addr_ipv4_v2 vc_data;
23049 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23052 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
23053 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
23056 +#ifdef CONFIG_IPV6
23058 +int do_add_v6_addr(struct nx_info *nxi,
23059 + struct in6_addr *ip, struct in6_addr *mask,
23060 + uint32_t prefix, uint16_t type, uint16_t flags)
23062 + struct nx_addr_v6 *nxa = &nxi->v6;
23064 + if (NX_IPV6(nxi)) {
23065 + /* locate last entry */
23066 + for (; nxa->next; nxa = nxa->next);
23067 + nxa->next = __alloc_nx_addr_v6();
23071 + return PTR_ERR(nxa);
23075 + nxa->mask = *mask;
23076 + nxa->prefix = prefix;
23077 + nxa->type = type;
23078 + nxa->flags = flags;
23083 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
23085 + struct vcmd_net_addr_ipv6_v1 vc_data;
23087 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23090 + switch (vc_data.type) {
23091 + case NXA_TYPE_ADDR:
23092 + memset(&vc_data.mask, ~0, sizeof(vc_data.mask));
23093 + /* fallthrough */
23094 + case NXA_TYPE_MASK:
23095 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
23096 + vc_data.prefix, vc_data.type, vc_data.flags);
23103 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
23105 + struct vcmd_net_addr_ipv6_v1 vc_data;
23107 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
23110 + switch (vc_data.type) {
23111 + case NXA_TYPE_ANY:
23112 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
23113 + memset(&nxi->v6, 0, sizeof(nxi->v6));
23122 +#endif /* CONFIG_IPV6 */
23125 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
23127 + struct vcmd_net_flags_v0 vc_data;
23129 + vc_data.flagword = nxi->nx_flags;
23131 + /* special STATE flag handling */
23132 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
23134 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23139 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
23141 + struct vcmd_net_flags_v0 vc_data;
23142 + uint64_t mask, trigger;
23144 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23147 + /* special STATE flag handling */
23148 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
23149 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
23151 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
23152 + vc_data.flagword, mask);
23153 + if (trigger & NXF_PERSISTENT)
23154 + nx_update_persistent(nxi);
23159 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
23161 + struct vcmd_net_caps_v0 vc_data;
23163 + vc_data.ncaps = nxi->nx_ncaps;
23164 + vc_data.cmask = ~0ULL;
23166 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
23171 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
23173 + struct vcmd_net_caps_v0 vc_data;
23175 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
23178 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
23179 + vc_data.ncaps, vc_data.cmask);
23184 +#include <linux/module.h>
23186 +module_init(init_network);
23188 +EXPORT_SYMBOL_GPL(free_nx_info);
23189 +EXPORT_SYMBOL_GPL(unhash_nx_info);
23191 diff -NurpP --minimal linux-3.0/kernel/vserver/proc.c linux-3.0-vs2.3.1-pre7/kernel/vserver/proc.c
23192 --- linux-3.0/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
23193 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/proc.c 2011-06-10 22:11:24.000000000 +0200
23196 + * linux/kernel/vserver/proc.c
23198 + * Virtual Context Support
23200 + * Copyright (C) 2003-2007 Herbert Pötzl
23202 + * V0.01 basic structure
23203 + * V0.02 adaptation vs1.3.0
23204 + * V0.03 proc permissions
23205 + * V0.04 locking/generic
23206 + * V0.05 next generation procfs
23207 + * V0.06 inode validation
23208 + * V0.07 generic rewrite vid
23209 + * V0.08 remove inode type
23213 +#include <linux/proc_fs.h>
23214 +#include <linux/fs_struct.h>
23215 +#include <linux/mount.h>
23216 +#include <asm/unistd.h>
23218 +#include <linux/vs_context.h>
23219 +#include <linux/vs_network.h>
23220 +#include <linux/vs_cvirt.h>
23222 +#include <linux/in.h>
23223 +#include <linux/inetdevice.h>
23224 +#include <linux/vs_inet.h>
23225 +#include <linux/vs_inet6.h>
23227 +#include <linux/vserver/global.h>
23229 +#include "cvirt_proc.h"
23230 +#include "cacct_proc.h"
23231 +#include "limit_proc.h"
23232 +#include "sched_proc.h"
23233 +#include "vci_config.h"
23236 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
23240 + CAP_FOR_EACH_U32(__capi) {
23241 + buffer += sprintf(buffer, "%08x",
23242 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
23248 +static struct proc_dir_entry *proc_virtual;
23250 +static struct proc_dir_entry *proc_virtnet;
23253 +/* first the actual feeds */
23256 +static int proc_vci(char *buffer)
23258 + return sprintf(buffer,
23259 + "VCIVersion:\t%04x:%04x\n"
23260 + "VCISyscall:\t%d\n"
23261 + "VCIKernel:\t%08x\n",
23262 + VCI_VERSION >> 16,
23263 + VCI_VERSION & 0xFFFF,
23265 + vci_kernel_config());
23268 +static int proc_virtual_info(char *buffer)
23270 + return proc_vci(buffer);
23273 +static int proc_virtual_status(char *buffer)
23275 + return sprintf(buffer,
23277 + "#CActive:\t%d\n"
23278 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
23279 + "#InitTask:\t%d\t%d %d\n",
23280 + atomic_read(&vx_global_ctotal),
23281 + atomic_read(&vx_global_cactive),
23282 + atomic_read(&vs_global_nsproxy),
23283 + atomic_read(&vs_global_fs),
23284 + atomic_read(&vs_global_mnt_ns),
23285 + atomic_read(&vs_global_uts_ns),
23286 + atomic_read(&nr_ipc_ns),
23287 + atomic_read(&vs_global_user_ns),
23288 + atomic_read(&vs_global_pid_ns),
23289 + atomic_read(&init_task.usage),
23290 + atomic_read(&init_task.nsproxy->count),
23291 + init_task.fs->users);
23295 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
23299 + length = sprintf(buffer,
23307 + vxi->vx_badness_bias);
23311 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
23313 + char *orig = buffer;
23315 + buffer += sprintf(buffer,
23318 + "Flags:\t%016llx\n",
23319 + atomic_read(&vxi->vx_usecnt),
23320 + atomic_read(&vxi->vx_tasks),
23321 + (unsigned long long)vxi->vx_flags);
23323 + buffer += sprintf(buffer, "BCaps:\t");
23324 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
23325 + buffer += sprintf(buffer, "\n");
23327 + buffer += sprintf(buffer,
23328 + "CCaps:\t%016llx\n"
23329 + "Umask:\t%16llx\n"
23330 + "Spaces:\t%08lx %08lx\n",
23331 + (unsigned long long)vxi->vx_ccaps,
23332 + (unsigned long long)vxi->vx_umask,
23333 + vxi->space[0].vx_nsmask, vxi->space[1].vx_nsmask);
23334 + return buffer - orig;
23337 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
23339 + return vx_info_proc_limit(&vxi->limit, buffer);
23342 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
23346 + length = vx_info_proc_sched(&vxi->sched, buffer);
23347 + for_each_online_cpu(cpu) {
23348 + length += vx_info_proc_sched_pc(
23349 + &vx_per_cpu(vxi, sched_pc, cpu),
23350 + buffer + length, cpu);
23355 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
23357 + return vx_info_proc_nsproxy(vxi->space[0].vx_nsproxy, buffer);
23360 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
23362 + return vx_info_proc_nsproxy(vxi->space[1].vx_nsproxy, buffer);
23365 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
23369 + vx_update_load(vxi);
23370 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
23371 + for_each_online_cpu(cpu) {
23372 + length += vx_info_proc_cvirt_pc(
23373 + &vx_per_cpu(vxi, cvirt_pc, cpu),
23374 + buffer + length, cpu);
23379 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
23381 + return vx_info_proc_cacct(&vxi->cacct, buffer);
23385 +static int proc_virtnet_info(char *buffer)
23387 + return proc_vci(buffer);
23390 +static int proc_virtnet_status(char *buffer)
23392 + return sprintf(buffer,
23394 + "#CActive:\t%d\n",
23395 + atomic_read(&nx_global_ctotal),
23396 + atomic_read(&nx_global_cactive));
23399 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
23401 + struct nx_addr_v4 *v4a;
23402 +#ifdef CONFIG_IPV6
23403 + struct nx_addr_v6 *v6a;
23407 + length = sprintf(buffer,
23410 + "Bcast:\t" NIPQUAD_FMT "\n"
23411 + "Lback:\t" NIPQUAD_FMT "\n",
23414 + NIPQUAD(nxi->v4_bcast.s_addr),
23415 + NIPQUAD(nxi->v4_lback.s_addr));
23417 + if (!NX_IPV4(nxi))
23419 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
23420 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
23423 +#ifdef CONFIG_IPV6
23424 + if (!NX_IPV6(nxi))
23426 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
23427 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
23434 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
23438 + length = sprintf(buffer,
23441 + "Flags:\t%016llx\n"
23442 + "NCaps:\t%016llx\n",
23443 + atomic_read(&nxi->nx_usecnt),
23444 + atomic_read(&nxi->nx_tasks),
23445 + (unsigned long long)nxi->nx_flags,
23446 + (unsigned long long)nxi->nx_ncaps);
23452 +/* here the inode helpers */
23458 + struct inode_operations *iop;
23459 + struct file_operations *fop;
23460 + union proc_op op;
23463 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
23465 + struct inode *inode = new_inode(sb);
23470 + inode->i_mode = p->mode;
23472 + inode->i_op = p->iop;
23474 + inode->i_fop = p->fop;
23476 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
23477 + inode->i_flags |= S_IMMUTABLE;
23479 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
23481 + inode->i_uid = 0;
23482 + inode->i_gid = 0;
23483 + inode->i_tag = 0;
23488 +static struct dentry *vs_proc_instantiate(struct inode *dir,
23489 + struct dentry *dentry, int id, void *ptr)
23491 + struct vs_entry *p = ptr;
23492 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
23493 + struct dentry *error = ERR_PTR(-EINVAL);
23498 + PROC_I(inode)->op = p->op;
23499 + PROC_I(inode)->fd = id;
23500 + d_add(dentry, inode);
23508 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
23511 + * Fill a directory entry.
23513 + * If possible create the dcache entry and derive our inode number and
23514 + * file type from dcache entry.
23516 + * Since all of the proc inode numbers are dynamically generated, the inode
23517 + * numbers do not exist until the inode is cache. This means creating the
23518 + * the dcache entry in readdir is necessary to keep the inode numbers
23519 + * reported by readdir in sync with the inode numbers reported
23522 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
23523 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
23525 + struct dentry *child, *dir = filp->f_dentry;
23526 + struct inode *inode;
23527 + struct qstr qname;
23529 + unsigned type = DT_UNKNOWN;
23531 + qname.name = name;
23533 + qname.hash = full_name_hash(name, len);
23535 + child = d_lookup(dir, &qname);
23537 + struct dentry *new;
23538 + new = d_alloc(dir, &qname);
23540 + child = instantiate(dir->d_inode, new, id, ptr);
23547 + if (!child || IS_ERR(child) || !child->d_inode)
23548 + goto end_instantiate;
23549 + inode = child->d_inode;
23551 + ino = inode->i_ino;
23552 + type = inode->i_mode >> 12;
23557 + ino = find_inode_number(dir, &qname);
23560 + return filldir(dirent, name, len, filp->f_pos, ino, type);
23565 +/* get and revalidate vx_info/xid */
23568 +struct vx_info *get_proc_vx_info(struct inode *inode)
23570 + return lookup_vx_info(PROC_I(inode)->fd);
23573 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
23575 + struct inode *inode = dentry->d_inode;
23576 + xid_t xid = PROC_I(inode)->fd;
23578 + if (!xid || xid_is_hashed(xid))
23585 +/* get and revalidate nx_info/nid */
23587 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
23589 + struct inode *inode = dentry->d_inode;
23590 + nid_t nid = PROC_I(inode)->fd;
23592 + if (!nid || nid_is_hashed(nid))
23600 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
23602 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
23603 + size_t count, loff_t *ppos)
23605 + struct inode *inode = file->f_dentry->d_inode;
23606 + unsigned long page;
23607 + ssize_t length = 0;
23609 + if (count > PROC_BLOCK_SIZE)
23610 + count = PROC_BLOCK_SIZE;
23612 + /* fade that out as soon as stable */
23613 + WARN_ON(PROC_I(inode)->fd);
23615 + if (!(page = __get_free_page(GFP_KERNEL)))
23618 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
23619 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
23622 + length = simple_read_from_buffer(buf, count, ppos,
23623 + (char *)page, length);
23629 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
23630 + size_t count, loff_t *ppos)
23632 + struct inode *inode = file->f_dentry->d_inode;
23633 + struct vx_info *vxi = NULL;
23634 + xid_t xid = PROC_I(inode)->fd;
23635 + unsigned long page;
23636 + ssize_t length = 0;
23638 + if (count > PROC_BLOCK_SIZE)
23639 + count = PROC_BLOCK_SIZE;
23641 + /* fade that out as soon as stable */
23643 + vxi = lookup_vx_info(xid);
23647 + length = -ENOMEM;
23648 + if (!(page = __get_free_page(GFP_KERNEL)))
23651 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
23652 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
23655 + length = simple_read_from_buffer(buf, count, ppos,
23656 + (char *)page, length);
23660 + put_vx_info(vxi);
23665 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
23666 + size_t count, loff_t *ppos)
23668 + struct inode *inode = file->f_dentry->d_inode;
23669 + struct nx_info *nxi = NULL;
23670 + nid_t nid = PROC_I(inode)->fd;
23671 + unsigned long page;
23672 + ssize_t length = 0;
23674 + if (count > PROC_BLOCK_SIZE)
23675 + count = PROC_BLOCK_SIZE;
23677 + /* fade that out as soon as stable */
23679 + nxi = lookup_nx_info(nid);
23683 + length = -ENOMEM;
23684 + if (!(page = __get_free_page(GFP_KERNEL)))
23687 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
23688 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
23691 + length = simple_read_from_buffer(buf, count, ppos,
23692 + (char *)page, length);
23696 + put_nx_info(nxi);
23703 +/* here comes the lower level */
23706 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
23707 + .len = sizeof(NAME) - 1, \
23708 + .name = (NAME), \
23716 +#define DIR(NAME, MODE, OTYPE) \
23717 + NOD(NAME, (S_IFDIR | (MODE)), \
23718 + &proc_ ## OTYPE ## _inode_operations, \
23719 + &proc_ ## OTYPE ## _file_operations, { } )
23721 +#define INF(NAME, MODE, OTYPE) \
23722 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23723 + &proc_vs_info_file_operations, \
23724 + { .proc_vs_read = &proc_##OTYPE } )
23726 +#define VINF(NAME, MODE, OTYPE) \
23727 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23728 + &proc_vx_info_file_operations, \
23729 + { .proc_vxi_read = &proc_##OTYPE } )
23731 +#define NINF(NAME, MODE, OTYPE) \
23732 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
23733 + &proc_nx_info_file_operations, \
23734 + { .proc_nxi_read = &proc_##OTYPE } )
23737 +static struct file_operations proc_vs_info_file_operations = {
23738 + .read = proc_vs_info_read,
23741 +static struct file_operations proc_vx_info_file_operations = {
23742 + .read = proc_vx_info_read,
23745 +static struct dentry_operations proc_xid_dentry_operations = {
23746 + .d_revalidate = proc_xid_revalidate,
23749 +static struct vs_entry vx_base_stuff[] = {
23750 + VINF("info", S_IRUGO, vxi_info),
23751 + VINF("status", S_IRUGO, vxi_status),
23752 + VINF("limit", S_IRUGO, vxi_limit),
23753 + VINF("sched", S_IRUGO, vxi_sched),
23754 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
23755 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
23756 + VINF("cvirt", S_IRUGO, vxi_cvirt),
23757 + VINF("cacct", S_IRUGO, vxi_cacct),
23764 +static struct dentry *proc_xid_instantiate(struct inode *dir,
23765 + struct dentry *dentry, int id, void *ptr)
23767 + dentry->d_op = &proc_xid_dentry_operations;
23768 + return vs_proc_instantiate(dir, dentry, id, ptr);
23771 +static struct dentry *proc_xid_lookup(struct inode *dir,
23772 + struct dentry *dentry, struct nameidata *nd)
23774 + struct vs_entry *p = vx_base_stuff;
23775 + struct dentry *error = ERR_PTR(-ENOENT);
23777 + for (; p->name; p++) {
23778 + if (p->len != dentry->d_name.len)
23780 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23786 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23791 +static int proc_xid_readdir(struct file *filp,
23792 + void *dirent, filldir_t filldir)
23794 + struct dentry *dentry = filp->f_dentry;
23795 + struct inode *inode = dentry->d_inode;
23796 + struct vs_entry *p = vx_base_stuff;
23797 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
23801 + pos = filp->f_pos;
23804 + ino = inode->i_ino;
23805 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23808 + /* fall through */
23810 + ino = parent_ino(dentry);
23811 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23814 + /* fall through */
23817 + if (index >= size)
23819 + for (p += index; p->name; p++) {
23820 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23821 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23827 + filp->f_pos = pos;
23833 +static struct file_operations proc_nx_info_file_operations = {
23834 + .read = proc_nx_info_read,
23837 +static struct dentry_operations proc_nid_dentry_operations = {
23838 + .d_revalidate = proc_nid_revalidate,
23841 +static struct vs_entry nx_base_stuff[] = {
23842 + NINF("info", S_IRUGO, nxi_info),
23843 + NINF("status", S_IRUGO, nxi_status),
23848 +static struct dentry *proc_nid_instantiate(struct inode *dir,
23849 + struct dentry *dentry, int id, void *ptr)
23851 + dentry->d_op = &proc_nid_dentry_operations;
23852 + return vs_proc_instantiate(dir, dentry, id, ptr);
23855 +static struct dentry *proc_nid_lookup(struct inode *dir,
23856 + struct dentry *dentry, struct nameidata *nd)
23858 + struct vs_entry *p = nx_base_stuff;
23859 + struct dentry *error = ERR_PTR(-ENOENT);
23861 + for (; p->name; p++) {
23862 + if (p->len != dentry->d_name.len)
23864 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23870 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
23875 +static int proc_nid_readdir(struct file *filp,
23876 + void *dirent, filldir_t filldir)
23878 + struct dentry *dentry = filp->f_dentry;
23879 + struct inode *inode = dentry->d_inode;
23880 + struct vs_entry *p = nx_base_stuff;
23881 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
23885 + pos = filp->f_pos;
23888 + ino = inode->i_ino;
23889 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
23892 + /* fall through */
23894 + ino = parent_ino(dentry);
23895 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
23898 + /* fall through */
23901 + if (index >= size)
23903 + for (p += index; p->name; p++) {
23904 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
23905 + vs_proc_instantiate, PROC_I(inode)->fd, p))
23911 + filp->f_pos = pos;
23916 +#define MAX_MULBY10 ((~0U - 9) / 10)
23918 +static inline int atovid(const char *str, int len)
23923 + while (len-- > 0) {
23928 + if (vid >= MAX_MULBY10)
23938 +/* now the upper level (virtual) */
23941 +static struct file_operations proc_xid_file_operations = {
23942 + .read = generic_read_dir,
23943 + .readdir = proc_xid_readdir,
23946 +static struct inode_operations proc_xid_inode_operations = {
23947 + .lookup = proc_xid_lookup,
23950 +static struct vs_entry vx_virtual_stuff[] = {
23951 + INF("info", S_IRUGO, virtual_info),
23952 + INF("status", S_IRUGO, virtual_status),
23953 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
23957 +static struct dentry *proc_virtual_lookup(struct inode *dir,
23958 + struct dentry *dentry, struct nameidata *nd)
23960 + struct vs_entry *p = vx_virtual_stuff;
23961 + struct dentry *error = ERR_PTR(-ENOENT);
23964 + for (; p->name; p++) {
23965 + if (p->len != dentry->d_name.len)
23967 + if (!memcmp(dentry->d_name.name, p->name, p->len))
23971 + goto instantiate;
23973 + id = atovid(dentry->d_name.name, dentry->d_name.len);
23974 + if ((id < 0) || !xid_is_hashed(id))
23978 + error = proc_xid_instantiate(dir, dentry, id, p);
23983 +static struct file_operations proc_nid_file_operations = {
23984 + .read = generic_read_dir,
23985 + .readdir = proc_nid_readdir,
23988 +static struct inode_operations proc_nid_inode_operations = {
23989 + .lookup = proc_nid_lookup,
23992 +static struct vs_entry nx_virtnet_stuff[] = {
23993 + INF("info", S_IRUGO, virtnet_info),
23994 + INF("status", S_IRUGO, virtnet_status),
23995 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
23999 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
24000 + struct dentry *dentry, struct nameidata *nd)
24002 + struct vs_entry *p = nx_virtnet_stuff;
24003 + struct dentry *error = ERR_PTR(-ENOENT);
24006 + for (; p->name; p++) {
24007 + if (p->len != dentry->d_name.len)
24009 + if (!memcmp(dentry->d_name.name, p->name, p->len))
24013 + goto instantiate;
24015 + id = atovid(dentry->d_name.name, dentry->d_name.len);
24016 + if ((id < 0) || !nid_is_hashed(id))
24020 + error = proc_nid_instantiate(dir, dentry, id, p);
24026 +#define PROC_MAXVIDS 32
24028 +int proc_virtual_readdir(struct file *filp,
24029 + void *dirent, filldir_t filldir)
24031 + struct dentry *dentry = filp->f_dentry;
24032 + struct inode *inode = dentry->d_inode;
24033 + struct vs_entry *p = vx_virtual_stuff;
24034 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
24036 + unsigned int xid_array[PROC_MAXVIDS];
24037 + char buf[PROC_NUMBUF];
24038 + unsigned int nr_xids, i;
24041 + pos = filp->f_pos;
24044 + ino = inode->i_ino;
24045 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24048 + /* fall through */
24050 + ino = parent_ino(dentry);
24051 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24054 + /* fall through */
24057 + if (index >= size)
24059 + for (p += index; p->name; p++) {
24060 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24061 + vs_proc_instantiate, 0, p))
24066 + index = pos - size;
24067 + p = &vx_virtual_stuff[size - 1];
24068 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
24069 + for (i = 0; i < nr_xids; i++) {
24070 + int n, xid = xid_array[i];
24071 + unsigned int j = PROC_NUMBUF;
24075 + buf[--j] = '0' + (n % 10);
24078 + if (proc_fill_cache(filp, dirent, filldir,
24079 + buf + j, PROC_NUMBUF - j,
24080 + vs_proc_instantiate, xid, p))
24086 + filp->f_pos = pos;
24090 +static int proc_virtual_getattr(struct vfsmount *mnt,
24091 + struct dentry *dentry, struct kstat *stat)
24093 + struct inode *inode = dentry->d_inode;
24095 + generic_fillattr(inode, stat);
24096 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
24100 +static struct file_operations proc_virtual_dir_operations = {
24101 + .read = generic_read_dir,
24102 + .readdir = proc_virtual_readdir,
24105 +static struct inode_operations proc_virtual_dir_inode_operations = {
24106 + .getattr = proc_virtual_getattr,
24107 + .lookup = proc_virtual_lookup,
24114 +int proc_virtnet_readdir(struct file *filp,
24115 + void *dirent, filldir_t filldir)
24117 + struct dentry *dentry = filp->f_dentry;
24118 + struct inode *inode = dentry->d_inode;
24119 + struct vs_entry *p = nx_virtnet_stuff;
24120 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
24122 + unsigned int nid_array[PROC_MAXVIDS];
24123 + char buf[PROC_NUMBUF];
24124 + unsigned int nr_nids, i;
24127 + pos = filp->f_pos;
24130 + ino = inode->i_ino;
24131 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
24134 + /* fall through */
24136 + ino = parent_ino(dentry);
24137 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
24140 + /* fall through */
24143 + if (index >= size)
24145 + for (p += index; p->name; p++) {
24146 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
24147 + vs_proc_instantiate, 0, p))
24152 + index = pos - size;
24153 + p = &nx_virtnet_stuff[size - 1];
24154 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
24155 + for (i = 0; i < nr_nids; i++) {
24156 + int n, nid = nid_array[i];
24157 + unsigned int j = PROC_NUMBUF;
24161 + buf[--j] = '0' + (n % 10);
24164 + if (proc_fill_cache(filp, dirent, filldir,
24165 + buf + j, PROC_NUMBUF - j,
24166 + vs_proc_instantiate, nid, p))
24172 + filp->f_pos = pos;
24176 +static int proc_virtnet_getattr(struct vfsmount *mnt,
24177 + struct dentry *dentry, struct kstat *stat)
24179 + struct inode *inode = dentry->d_inode;
24181 + generic_fillattr(inode, stat);
24182 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
24186 +static struct file_operations proc_virtnet_dir_operations = {
24187 + .read = generic_read_dir,
24188 + .readdir = proc_virtnet_readdir,
24191 +static struct inode_operations proc_virtnet_dir_inode_operations = {
24192 + .getattr = proc_virtnet_getattr,
24193 + .lookup = proc_virtnet_lookup,
24198 +void proc_vx_init(void)
24200 + struct proc_dir_entry *ent;
24202 + ent = proc_mkdir("virtual", 0);
24204 + ent->proc_fops = &proc_virtual_dir_operations;
24205 + ent->proc_iops = &proc_virtual_dir_inode_operations;
24207 + proc_virtual = ent;
24209 + ent = proc_mkdir("virtnet", 0);
24211 + ent->proc_fops = &proc_virtnet_dir_operations;
24212 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
24214 + proc_virtnet = ent;
24220 +/* per pid info */
24223 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
24225 + struct vx_info *vxi;
24226 + char *orig = buffer;
24228 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
24230 + vxi = task_get_vx_info(p);
24234 + buffer += sprintf(buffer, "BCaps:\t");
24235 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
24236 + buffer += sprintf(buffer, "\n");
24237 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
24238 + (unsigned long long)vxi->vx_ccaps);
24239 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
24240 + (unsigned long long)vxi->vx_flags);
24241 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
24243 + put_vx_info(vxi);
24245 + return buffer - orig;
24249 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
24251 + struct nx_info *nxi;
24252 + struct nx_addr_v4 *v4a;
24253 +#ifdef CONFIG_IPV6
24254 + struct nx_addr_v6 *v6a;
24256 + char *orig = buffer;
24259 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
24261 + nxi = task_get_nx_info(p);
24265 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
24266 + (unsigned long long)nxi->nx_ncaps);
24267 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
24268 + (unsigned long long)nxi->nx_flags);
24270 + buffer += sprintf(buffer,
24271 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
24272 + NIPQUAD(nxi->v4_bcast.s_addr));
24273 + buffer += sprintf (buffer,
24274 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
24275 + NIPQUAD(nxi->v4_lback.s_addr));
24276 + if (!NX_IPV4(nxi))
24278 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
24279 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
24282 +#ifdef CONFIG_IPV6
24283 + if (!NX_IPV6(nxi))
24285 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
24286 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
24290 + put_nx_info(nxi);
24292 + return buffer - orig;
24295 diff -NurpP --minimal linux-3.0/kernel/vserver/sched.c linux-3.0-vs2.3.1-pre7/kernel/vserver/sched.c
24296 --- linux-3.0/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
24297 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/sched.c 2011-06-10 22:11:24.000000000 +0200
24300 + * linux/kernel/vserver/sched.c
24302 + * Virtual Server: Scheduler Support
24304 + * Copyright (C) 2004-2010 Herbert Pötzl
24306 + * V0.01 adapted Sam Vilains version to 2.6.3
24307 + * V0.02 removed legacy interface
24308 + * V0.03 changed vcmds to vxi arg
24309 + * V0.04 removed older and legacy interfaces
24310 + * V0.05 removed scheduler code/commands
24314 +#include <linux/vs_context.h>
24315 +#include <linux/vs_sched.h>
24316 +#include <linux/vserver/sched_cmd.h>
24318 +#include <asm/uaccess.h>
24321 +void vx_update_sched_param(struct _vx_sched *sched,
24322 + struct _vx_sched_pc *sched_pc)
24324 + sched_pc->prio_bias = sched->prio_bias;
24327 +static int do_set_prio_bias(struct vx_info *vxi, struct vcmd_prio_bias *data)
24331 + if (data->prio_bias > MAX_PRIO_BIAS)
24332 + data->prio_bias = MAX_PRIO_BIAS;
24333 + if (data->prio_bias < MIN_PRIO_BIAS)
24334 + data->prio_bias = MIN_PRIO_BIAS;
24336 + if (data->cpu_id != ~0) {
24337 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
24338 + cpus_and(vxi->sched.update, cpu_online_map,
24339 + vxi->sched.update);
24341 + vxi->sched.update = cpu_online_map;
24343 + for_each_cpu_mask(cpu, vxi->sched.update)
24344 + vx_update_sched_param(&vxi->sched,
24345 + &vx_per_cpu(vxi, sched_pc, cpu));
24349 +int vc_set_prio_bias(struct vx_info *vxi, void __user *data)
24351 + struct vcmd_prio_bias vc_data;
24353 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24356 + return do_set_prio_bias(vxi, &vc_data);
24359 +int vc_get_prio_bias(struct vx_info *vxi, void __user *data)
24361 + struct vcmd_prio_bias vc_data;
24362 + struct _vx_sched_pc *pcd;
24365 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24368 + cpu = vc_data.cpu_id;
24370 + if (!cpu_possible(cpu))
24373 + pcd = &vx_per_cpu(vxi, sched_pc, cpu);
24374 + vc_data.prio_bias = pcd->prio_bias;
24376 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24381 diff -NurpP --minimal linux-3.0/kernel/vserver/sched_init.h linux-3.0-vs2.3.1-pre7/kernel/vserver/sched_init.h
24382 --- linux-3.0/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
24383 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/sched_init.h 2011-06-10 22:11:24.000000000 +0200
24386 +static inline void vx_info_init_sched(struct _vx_sched *sched)
24388 + /* scheduling; hard code starting values as constants */
24389 + sched->prio_bias = 0;
24393 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24395 + sched_pc->prio_bias = 0;
24397 + sched_pc->user_ticks = 0;
24398 + sched_pc->sys_ticks = 0;
24399 + sched_pc->hold_ticks = 0;
24402 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
24408 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
24412 diff -NurpP --minimal linux-3.0/kernel/vserver/sched_proc.h linux-3.0-vs2.3.1-pre7/kernel/vserver/sched_proc.h
24413 --- linux-3.0/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
24414 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/sched_proc.h 2011-06-10 22:11:24.000000000 +0200
24416 +#ifndef _VX_SCHED_PROC_H
24417 +#define _VX_SCHED_PROC_H
24421 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
24425 + length += sprintf(buffer,
24426 + "PrioBias:\t%8d\n",
24427 + sched->prio_bias);
24432 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
24433 + char *buffer, int cpu)
24437 + length += sprintf(buffer + length,
24438 + "cpu %d: %lld %lld %lld", cpu,
24439 + (unsigned long long)sched_pc->user_ticks,
24440 + (unsigned long long)sched_pc->sys_ticks,
24441 + (unsigned long long)sched_pc->hold_ticks);
24442 + length += sprintf(buffer + length,
24443 + " %d\n", sched_pc->prio_bias);
24447 +#endif /* _VX_SCHED_PROC_H */
24448 diff -NurpP --minimal linux-3.0/kernel/vserver/signal.c linux-3.0-vs2.3.1-pre7/kernel/vserver/signal.c
24449 --- linux-3.0/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
24450 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/signal.c 2011-06-10 22:11:24.000000000 +0200
24453 + * linux/kernel/vserver/signal.c
24455 + * Virtual Server: Signal Support
24457 + * Copyright (C) 2003-2007 Herbert Pötzl
24459 + * V0.01 broken out from vcontext V0.05
24460 + * V0.02 changed vcmds to vxi arg
24461 + * V0.03 adjusted siginfo for kill
24465 +#include <asm/uaccess.h>
24467 +#include <linux/vs_context.h>
24468 +#include <linux/vs_pid.h>
24469 +#include <linux/vserver/signal_cmd.h>
24472 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
24474 + int retval, count = 0;
24475 + struct task_struct *p;
24476 + struct siginfo *sip = SEND_SIG_PRIV;
24479 + vxdprintk(VXD_CBIT(misc, 4),
24480 + "vx_info_kill(%p[#%d],%d,%d)*",
24481 + vxi, vxi->vx_id, pid, sig);
24482 + read_lock(&tasklist_lock);
24486 + for_each_process(p) {
24489 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
24490 + (pid && vxi->vx_initpid == p->pid))
24493 + err = group_send_sig_info(sig, sip, p);
24495 + if (err != -EPERM)
24501 + if (vxi->vx_initpid) {
24502 + pid = vxi->vx_initpid;
24503 + /* for now, only SIGINT to private init ... */
24504 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24505 + /* ... as long as there are tasks left */
24506 + (atomic_read(&vxi->vx_tasks) > 1))
24509 + /* fallthrough */
24512 + p = find_task_by_real_pid(pid);
24513 + rcu_read_unlock();
24515 + if (vx_task_xid(p) == vxi->vx_id)
24516 + retval = group_send_sig_info(sig, sip, p);
24520 + read_unlock(&tasklist_lock);
24521 + vxdprintk(VXD_CBIT(misc, 4),
24522 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
24523 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
24527 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
24529 + struct vcmd_ctx_kill_v0 vc_data;
24531 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
24534 + /* special check to allow guest shutdown */
24535 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
24536 + /* forbid killall pid=0 when init is present */
24537 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
24538 + (vc_data.pid > 1)))
24541 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
24545 +static int __wait_exit(struct vx_info *vxi)
24547 + DECLARE_WAITQUEUE(wait, current);
24550 + add_wait_queue(&vxi->vx_wait, &wait);
24551 + set_current_state(TASK_INTERRUPTIBLE);
24554 + if (vx_info_state(vxi,
24555 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
24557 + if (signal_pending(current)) {
24558 + ret = -ERESTARTSYS;
24565 + set_current_state(TASK_RUNNING);
24566 + remove_wait_queue(&vxi->vx_wait, &wait);
24572 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
24574 + struct vcmd_wait_exit_v0 vc_data;
24577 + ret = __wait_exit(vxi);
24578 + vc_data.reboot_cmd = vxi->reboot_cmd;
24579 + vc_data.exit_code = vxi->exit_code;
24581 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
24586 diff -NurpP --minimal linux-3.0/kernel/vserver/space.c linux-3.0-vs2.3.1-pre7/kernel/vserver/space.c
24587 --- linux-3.0/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
24588 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/space.c 2011-07-20 02:11:49.000000000 +0200
24591 + * linux/kernel/vserver/space.c
24593 + * Virtual Server: Context Space Support
24595 + * Copyright (C) 2003-2010 Herbert Pötzl
24597 + * V0.01 broken out from context.c 0.07
24598 + * V0.02 added task locking for namespace
24599 + * V0.03 broken out vx_enter_namespace
24600 + * V0.04 added *space support and commands
24601 + * V0.05 added credential support
24605 +#include <linux/utsname.h>
24606 +#include <linux/nsproxy.h>
24607 +#include <linux/err.h>
24608 +#include <linux/fs_struct.h>
24609 +#include <linux/cred.h>
24610 +#include <asm/uaccess.h>
24612 +#include <linux/vs_context.h>
24613 +#include <linux/vserver/space.h>
24614 +#include <linux/vserver/space_cmd.h>
24616 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
24617 +atomic_t vs_global_fs = ATOMIC_INIT(0);
24618 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
24619 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
24620 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
24621 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
24624 +/* namespace functions */
24626 +#include <linux/mnt_namespace.h>
24627 +#include <linux/user_namespace.h>
24628 +#include <linux/pid_namespace.h>
24629 +#include <linux/ipc_namespace.h>
24630 +#include <net/net_namespace.h>
24633 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
24634 + .mask = CLONE_FS |
24636 +#ifdef CONFIG_UTS_NS
24639 +#ifdef CONFIG_IPC_NS
24642 +#ifdef CONFIG_USER_NS
24648 +static const struct vcmd_space_mask_v1 space_mask = {
24649 + .mask = CLONE_FS |
24651 +#ifdef CONFIG_UTS_NS
24654 +#ifdef CONFIG_IPC_NS
24657 +#ifdef CONFIG_USER_NS
24660 +#ifdef CONFIG_PID_NS
24663 +#ifdef CONFIG_NET_NS
24669 +static const struct vcmd_space_mask_v1 default_space_mask = {
24670 + .mask = CLONE_FS |
24672 +#ifdef CONFIG_UTS_NS
24675 +#ifdef CONFIG_IPC_NS
24678 +#ifdef CONFIG_USER_NS
24681 +#ifdef CONFIG_PID_NS
24688 + * build a new nsproxy mix
24689 + * assumes that both proxies are 'const'
24690 + * does not touch nsproxy refcounts
24691 + * will hold a reference on the result.
24694 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
24695 + struct nsproxy *new_nsproxy, unsigned long mask)
24697 + struct mnt_namespace *old_ns;
24698 + struct uts_namespace *old_uts;
24699 + struct ipc_namespace *old_ipc;
24700 +#ifdef CONFIG_PID_NS
24701 + struct pid_namespace *old_pid;
24703 +#ifdef CONFIG_NET_NS
24704 + struct net *old_net;
24706 + struct nsproxy *nsproxy;
24708 + nsproxy = copy_nsproxy(old_nsproxy);
24712 + if (mask & CLONE_NEWNS) {
24713 + old_ns = nsproxy->mnt_ns;
24714 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
24715 + if (nsproxy->mnt_ns)
24716 + get_mnt_ns(nsproxy->mnt_ns);
24720 + if (mask & CLONE_NEWUTS) {
24721 + old_uts = nsproxy->uts_ns;
24722 + nsproxy->uts_ns = new_nsproxy->uts_ns;
24723 + if (nsproxy->uts_ns)
24724 + get_uts_ns(nsproxy->uts_ns);
24728 + if (mask & CLONE_NEWIPC) {
24729 + old_ipc = nsproxy->ipc_ns;
24730 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
24731 + if (nsproxy->ipc_ns)
24732 + get_ipc_ns(nsproxy->ipc_ns);
24736 +#ifdef CONFIG_PID_NS
24737 + if (mask & CLONE_NEWPID) {
24738 + old_pid = nsproxy->pid_ns;
24739 + nsproxy->pid_ns = new_nsproxy->pid_ns;
24740 + if (nsproxy->pid_ns)
24741 + get_pid_ns(nsproxy->pid_ns);
24745 +#ifdef CONFIG_NET_NS
24746 + if (mask & CLONE_NEWNET) {
24747 + old_net = nsproxy->net_ns;
24748 + nsproxy->net_ns = new_nsproxy->net_ns;
24749 + if (nsproxy->net_ns)
24750 + get_net(nsproxy->net_ns);
24755 + put_mnt_ns(old_ns);
24757 + put_uts_ns(old_uts);
24759 + put_ipc_ns(old_ipc);
24760 +#ifdef CONFIG_PID_NS
24762 + put_pid_ns(old_pid);
24764 +#ifdef CONFIG_NET_NS
24766 + put_net(old_net);
24774 + * merge two nsproxy structs into a new one.
24775 + * will hold a reference on the result.
24779 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
24780 + struct nsproxy *proxy, unsigned long mask)
24782 + struct nsproxy null_proxy = { .mnt_ns = NULL };
24788 + /* vs_mix_nsproxy returns with reference */
24789 + return vs_mix_nsproxy(old ? old : &null_proxy,
24792 + get_nsproxy(proxy);
24797 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
24799 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
24800 + struct fs_struct *fs_cur, *fs = NULL;
24801 + struct _vx_space *space;
24802 + int ret, kill = 0;
24804 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
24805 + vxi, vxi->vx_id, mask, index);
24807 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
24810 + if (index >= VX_SPACES)
24813 + space = &vxi->space[index];
24816 + mask = space->vx_nsmask;
24818 + if ((mask & space->vx_nsmask) != mask)
24821 + if (mask & CLONE_FS) {
24822 + fs = copy_fs_struct(space->vx_fs);
24826 + proxy = space->vx_nsproxy;
24828 + vxdprintk(VXD_CBIT(space, 9),
24829 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
24830 + vxi, vxi->vx_id, mask, index, proxy, fs);
24832 + task_lock(current);
24833 + fs_cur = current->fs;
24835 + if (mask & CLONE_FS) {
24836 + spin_lock(&fs_cur->lock);
24837 + current->fs = fs;
24838 + kill = !--fs_cur->users;
24839 + spin_unlock(&fs_cur->lock);
24842 + proxy_cur = current->nsproxy;
24843 + get_nsproxy(proxy_cur);
24844 + task_unlock(current);
24847 + free_fs_struct(fs_cur);
24849 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
24850 + if (IS_ERR(proxy_new)) {
24851 + ret = PTR_ERR(proxy_new);
24855 + proxy_new = xchg(¤t->nsproxy, proxy_new);
24857 + if (mask & CLONE_NEWUSER) {
24858 + struct cred *cred;
24860 + vxdprintk(VXD_CBIT(space, 10),
24861 + "vx_enter_space(%p[#%u],%p) cred (%p,%p)",
24862 + vxi, vxi->vx_id, space->vx_cred,
24863 + current->real_cred, current->cred);
24865 + if (space->vx_cred) {
24866 + cred = __prepare_creds(space->vx_cred);
24868 + commit_creds(cred);
24875 + put_nsproxy(proxy_new);
24878 + put_nsproxy(proxy_cur);
24883 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
24885 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
24886 + struct fs_struct *fs_vxi, *fs;
24887 + struct _vx_space *space;
24888 + int ret, kill = 0;
24890 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
24891 + vxi, vxi->vx_id, mask, index);
24893 + if ((mask & space_mask.mask) != mask)
24896 + if (index >= VX_SPACES)
24899 + space = &vxi->space[index];
24901 + proxy_vxi = space->vx_nsproxy;
24902 + fs_vxi = space->vx_fs;
24904 + if (mask & CLONE_FS) {
24905 + fs = copy_fs_struct(current->fs);
24910 + task_lock(current);
24912 + if (mask & CLONE_FS) {
24913 + spin_lock(&fs_vxi->lock);
24914 + space->vx_fs = fs;
24915 + kill = !--fs_vxi->users;
24916 + spin_unlock(&fs_vxi->lock);
24919 + proxy_cur = current->nsproxy;
24920 + get_nsproxy(proxy_cur);
24921 + task_unlock(current);
24924 + free_fs_struct(fs_vxi);
24926 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
24927 + if (IS_ERR(proxy_new)) {
24928 + ret = PTR_ERR(proxy_new);
24932 + proxy_new = xchg(&space->vx_nsproxy, proxy_new);
24933 + space->vx_nsmask |= mask;
24935 + if (mask & CLONE_NEWUSER) {
24936 + struct cred *cred;
24938 + vxdprintk(VXD_CBIT(space, 10),
24939 + "vx_set_space(%p[#%u],%p) cred (%p,%p)",
24940 + vxi, vxi->vx_id, space->vx_cred,
24941 + current->real_cred, current->cred);
24943 + cred = prepare_creds();
24944 + cred = (struct cred *)xchg(&space->vx_cred, cred);
24946 + abort_creds(cred);
24952 + put_nsproxy(proxy_new);
24955 + put_nsproxy(proxy_cur);
24960 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
24962 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
24964 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24967 + return vx_enter_space(vxi, vc_data.mask, 0);
24970 +int vc_enter_space(struct vx_info *vxi, void __user *data)
24972 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
24974 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24977 + if (vc_data.index >= VX_SPACES)
24980 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
24983 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
24985 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
24987 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
24990 + return vx_set_space(vxi, vc_data.mask, 0);
24993 +int vc_set_space(struct vx_info *vxi, void __user *data)
24995 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
24997 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
25000 + if (vc_data.index >= VX_SPACES)
25003 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
25006 +int vc_get_space_mask(void __user *data, int type)
25008 + const struct vcmd_space_mask_v1 *mask;
25011 + mask = &space_mask_v0;
25012 + else if (type == 1)
25013 + mask = &space_mask;
25015 + mask = &default_space_mask;
25017 + vxdprintk(VXD_CBIT(space, 10),
25018 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
25020 + if (copy_to_user(data, mask, sizeof(*mask)))
25025 diff -NurpP --minimal linux-3.0/kernel/vserver/switch.c linux-3.0-vs2.3.1-pre7/kernel/vserver/switch.c
25026 --- linux-3.0/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
25027 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/switch.c 2011-07-20 02:40:51.000000000 +0200
25030 + * linux/kernel/vserver/switch.c
25032 + * Virtual Server: Syscall Switch
25034 + * Copyright (C) 2003-2007 Herbert Pötzl
25036 + * V0.01 syscall switch
25037 + * V0.02 added signal to context
25038 + * V0.03 added rlimit functions
25039 + * V0.04 added iattr, task/xid functions
25040 + * V0.05 added debug/history stuff
25041 + * V0.06 added compat32 layer
25042 + * V0.07 vcmd args and perms
25043 + * V0.08 added status commands
25044 + * V0.09 added tag commands
25045 + * V0.10 added oom bias
25046 + * V0.11 added device commands
25050 +#include <linux/vs_context.h>
25051 +#include <linux/vs_network.h>
25052 +#include <linux/vserver/switch.h>
25054 +#include "vci_config.h"
25058 +int vc_get_version(uint32_t id)
25060 + return VCI_VERSION;
25064 +int vc_get_vci(uint32_t id)
25066 + return vci_kernel_config();
25069 +#include <linux/vserver/context_cmd.h>
25070 +#include <linux/vserver/cvirt_cmd.h>
25071 +#include <linux/vserver/cacct_cmd.h>
25072 +#include <linux/vserver/limit_cmd.h>
25073 +#include <linux/vserver/network_cmd.h>
25074 +#include <linux/vserver/sched_cmd.h>
25075 +#include <linux/vserver/debug_cmd.h>
25076 +#include <linux/vserver/inode_cmd.h>
25077 +#include <linux/vserver/dlimit_cmd.h>
25078 +#include <linux/vserver/signal_cmd.h>
25079 +#include <linux/vserver/space_cmd.h>
25080 +#include <linux/vserver/tag_cmd.h>
25081 +#include <linux/vserver/device_cmd.h>
25083 +#include <linux/vserver/inode.h>
25084 +#include <linux/vserver/dlimit.h>
25087 +#ifdef CONFIG_COMPAT
25088 +#define __COMPAT(name, id, data, compat) \
25089 + (compat) ? name ## _x32(id, data) : name(id, data)
25090 +#define __COMPAT_NO_ID(name, data, compat) \
25091 + (compat) ? name ## _x32(data) : name(data)
25093 +#define __COMPAT(name, id, data, compat) \
25095 +#define __COMPAT_NO_ID(name, data, compat) \
25101 +long do_vcmd(uint32_t cmd, uint32_t id,
25102 + struct vx_info *vxi, struct nx_info *nxi,
25103 + void __user *data, int compat)
25107 + case VCMD_get_version:
25108 + return vc_get_version(id);
25109 + case VCMD_get_vci:
25110 + return vc_get_vci(id);
25112 + case VCMD_task_xid:
25113 + return vc_task_xid(id);
25114 + case VCMD_vx_info:
25115 + return vc_vx_info(vxi, data);
25117 + case VCMD_task_nid:
25118 + return vc_task_nid(id);
25119 + case VCMD_nx_info:
25120 + return vc_nx_info(nxi, data);
25122 + case VCMD_task_tag:
25123 + return vc_task_tag(id);
25125 + case VCMD_set_space_v1:
25126 + return vc_set_space_v1(vxi, data);
25127 + /* this is version 2 */
25128 + case VCMD_set_space:
25129 + return vc_set_space(vxi, data);
25131 + case VCMD_get_space_mask_v0:
25132 + return vc_get_space_mask(data, 0);
25133 + /* this is version 1 */
25134 + case VCMD_get_space_mask:
25135 + return vc_get_space_mask(data, 1);
25137 + case VCMD_get_space_default:
25138 + return vc_get_space_mask(data, -1);
25140 + case VCMD_set_umask:
25141 + return vc_set_umask(vxi, data);
25143 + case VCMD_get_umask:
25144 + return vc_get_umask(vxi, data);
25146 +#ifdef CONFIG_IA32_EMULATION
25147 + case VCMD_get_rlimit:
25148 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
25149 + case VCMD_set_rlimit:
25150 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
25152 + case VCMD_get_rlimit:
25153 + return vc_get_rlimit(vxi, data);
25154 + case VCMD_set_rlimit:
25155 + return vc_set_rlimit(vxi, data);
25157 + case VCMD_get_rlimit_mask:
25158 + return vc_get_rlimit_mask(id, data);
25159 + case VCMD_reset_hits:
25160 + return vc_reset_hits(vxi, data);
25161 + case VCMD_reset_minmax:
25162 + return vc_reset_minmax(vxi, data);
25164 + case VCMD_get_vhi_name:
25165 + return vc_get_vhi_name(vxi, data);
25166 + case VCMD_set_vhi_name:
25167 + return vc_set_vhi_name(vxi, data);
25169 + case VCMD_ctx_stat:
25170 + return vc_ctx_stat(vxi, data);
25171 + case VCMD_virt_stat:
25172 + return vc_virt_stat(vxi, data);
25173 + case VCMD_sock_stat:
25174 + return vc_sock_stat(vxi, data);
25175 + case VCMD_rlimit_stat:
25176 + return vc_rlimit_stat(vxi, data);
25178 + case VCMD_set_cflags:
25179 + return vc_set_cflags(vxi, data);
25180 + case VCMD_get_cflags:
25181 + return vc_get_cflags(vxi, data);
25183 + /* this is version 1 */
25184 + case VCMD_set_ccaps:
25185 + return vc_set_ccaps(vxi, data);
25186 + /* this is version 1 */
25187 + case VCMD_get_ccaps:
25188 + return vc_get_ccaps(vxi, data);
25189 + case VCMD_set_bcaps:
25190 + return vc_set_bcaps(vxi, data);
25191 + case VCMD_get_bcaps:
25192 + return vc_get_bcaps(vxi, data);
25194 + case VCMD_set_badness:
25195 + return vc_set_badness(vxi, data);
25196 + case VCMD_get_badness:
25197 + return vc_get_badness(vxi, data);
25199 + case VCMD_set_nflags:
25200 + return vc_set_nflags(nxi, data);
25201 + case VCMD_get_nflags:
25202 + return vc_get_nflags(nxi, data);
25204 + case VCMD_set_ncaps:
25205 + return vc_set_ncaps(nxi, data);
25206 + case VCMD_get_ncaps:
25207 + return vc_get_ncaps(nxi, data);
25209 + case VCMD_set_prio_bias:
25210 + return vc_set_prio_bias(vxi, data);
25211 + case VCMD_get_prio_bias:
25212 + return vc_get_prio_bias(vxi, data);
25213 + case VCMD_add_dlimit:
25214 + return __COMPAT(vc_add_dlimit, id, data, compat);
25215 + case VCMD_rem_dlimit:
25216 + return __COMPAT(vc_rem_dlimit, id, data, compat);
25217 + case VCMD_set_dlimit:
25218 + return __COMPAT(vc_set_dlimit, id, data, compat);
25219 + case VCMD_get_dlimit:
25220 + return __COMPAT(vc_get_dlimit, id, data, compat);
25222 + case VCMD_ctx_kill:
25223 + return vc_ctx_kill(vxi, data);
25225 + case VCMD_wait_exit:
25226 + return vc_wait_exit(vxi, data);
25228 + case VCMD_get_iattr:
25229 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
25230 + case VCMD_set_iattr:
25231 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
25233 + case VCMD_fget_iattr:
25234 + return vc_fget_iattr(id, data);
25235 + case VCMD_fset_iattr:
25236 + return vc_fset_iattr(id, data);
25238 + case VCMD_enter_space_v0:
25239 + return vc_enter_space_v1(vxi, NULL);
25240 + case VCMD_enter_space_v1:
25241 + return vc_enter_space_v1(vxi, data);
25242 + /* this is version 2 */
25243 + case VCMD_enter_space:
25244 + return vc_enter_space(vxi, data);
25246 + case VCMD_ctx_create_v0:
25247 + return vc_ctx_create(id, NULL);
25248 + case VCMD_ctx_create:
25249 + return vc_ctx_create(id, data);
25250 + case VCMD_ctx_migrate_v0:
25251 + return vc_ctx_migrate(vxi, NULL);
25252 + case VCMD_ctx_migrate:
25253 + return vc_ctx_migrate(vxi, data);
25255 + case VCMD_net_create_v0:
25256 + return vc_net_create(id, NULL);
25257 + case VCMD_net_create:
25258 + return vc_net_create(id, data);
25259 + case VCMD_net_migrate:
25260 + return vc_net_migrate(nxi, data);
25262 + case VCMD_tag_migrate:
25263 + return vc_tag_migrate(id);
25265 + case VCMD_net_add:
25266 + return vc_net_add(nxi, data);
25267 + case VCMD_net_remove:
25268 + return vc_net_remove(nxi, data);
25270 + case VCMD_net_add_ipv4_v1:
25271 + return vc_net_add_ipv4_v1(nxi, data);
25272 + /* this is version 2 */
25273 + case VCMD_net_add_ipv4:
25274 + return vc_net_add_ipv4(nxi, data);
25276 + case VCMD_net_rem_ipv4_v1:
25277 + return vc_net_rem_ipv4_v1(nxi, data);
25278 + /* this is version 2 */
25279 + case VCMD_net_rem_ipv4:
25280 + return vc_net_rem_ipv4(nxi, data);
25281 +#ifdef CONFIG_IPV6
25282 + case VCMD_net_add_ipv6:
25283 + return vc_net_add_ipv6(nxi, data);
25284 + case VCMD_net_remove_ipv6:
25285 + return vc_net_remove_ipv6(nxi, data);
25287 +/* case VCMD_add_match_ipv4:
25288 + return vc_add_match_ipv4(nxi, data);
25289 + case VCMD_get_match_ipv4:
25290 + return vc_get_match_ipv4(nxi, data);
25291 +#ifdef CONFIG_IPV6
25292 + case VCMD_add_match_ipv6:
25293 + return vc_add_match_ipv6(nxi, data);
25294 + case VCMD_get_match_ipv6:
25295 + return vc_get_match_ipv6(nxi, data);
25298 +#ifdef CONFIG_VSERVER_DEVICE
25299 + case VCMD_set_mapping:
25300 + return __COMPAT(vc_set_mapping, vxi, data, compat);
25301 + case VCMD_unset_mapping:
25302 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
25304 +#ifdef CONFIG_VSERVER_HISTORY
25305 + case VCMD_dump_history:
25306 + return vc_dump_history(id);
25307 + case VCMD_read_history:
25308 + return __COMPAT(vc_read_history, id, data, compat);
25311 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
25312 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
25318 +#define __VCMD(vcmd, _perm, _args, _flags) \
25319 + case VCMD_ ## vcmd: perm = _perm; \
25320 + args = _args; flags = _flags; break
25323 +#define VCA_NONE 0x00
25324 +#define VCA_VXI 0x01
25325 +#define VCA_NXI 0x02
25327 +#define VCF_NONE 0x00
25328 +#define VCF_INFO 0x01
25329 +#define VCF_ADMIN 0x02
25330 +#define VCF_ARES 0x06 /* includes admin */
25331 +#define VCF_SETUP 0x08
25333 +#define VCF_ZIDOK 0x10 /* zero id okay */
25337 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
25340 + int permit = -1, state = 0;
25341 + int perm = -1, args = 0, flags = 0;
25342 + struct vx_info *vxi = NULL;
25343 + struct nx_info *nxi = NULL;
25346 + /* unpriviledged commands */
25347 + __VCMD(get_version, 0, VCA_NONE, 0);
25348 + __VCMD(get_vci, 0, VCA_NONE, 0);
25349 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
25350 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
25351 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
25352 + __VCMD(get_space_default,0, VCA_NONE, 0);
25354 + /* info commands */
25355 + __VCMD(task_xid, 2, VCA_NONE, 0);
25356 + __VCMD(reset_hits, 2, VCA_VXI, 0);
25357 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
25358 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
25359 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
25360 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
25361 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
25362 + __VCMD(get_umask, 3, VCA_VXI, VCF_INFO);
25363 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
25364 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
25365 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
25367 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
25368 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
25369 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
25370 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
25372 + __VCMD(task_nid, 2, VCA_NONE, 0);
25373 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
25374 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
25375 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
25377 + __VCMD(task_tag, 2, VCA_NONE, 0);
25379 + __VCMD(get_iattr, 2, VCA_NONE, 0);
25380 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
25381 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
25382 + __VCMD(get_prio_bias, 3, VCA_VXI, VCF_INFO);
25384 + /* lower admin commands */
25385 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
25386 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
25387 + __VCMD(ctx_create, 5, VCA_NONE, 0);
25388 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
25389 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
25390 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
25391 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
25392 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
25394 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
25395 + __VCMD(net_create, 5, VCA_NONE, 0);
25396 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
25398 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
25400 + /* higher admin commands */
25401 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
25402 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25403 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25405 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25406 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25407 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25408 + __VCMD(set_umask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25409 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25411 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25412 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25413 + __VCMD(set_prio_bias, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
25415 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25416 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
25417 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25418 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25419 + __VCMD(net_add_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25420 + __VCMD(net_rem_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25421 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25422 + __VCMD(net_rem_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25423 +#ifdef CONFIG_IPV6
25424 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25425 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
25427 + __VCMD(set_iattr, 7, VCA_NONE, 0);
25428 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
25429 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
25430 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
25431 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
25433 +#ifdef CONFIG_VSERVER_DEVICE
25434 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
25435 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
25437 + /* debug level admin commands */
25438 +#ifdef CONFIG_VSERVER_HISTORY
25439 + __VCMD(dump_history, 9, VCA_NONE, 0);
25440 + __VCMD(read_history, 9, VCA_NONE, 0);
25447 + vxdprintk(VXD_CBIT(switch, 0),
25448 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
25449 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25450 + VC_VERSION(cmd), id, data, compat,
25451 + perm, args, flags);
25458 + if (!capable(CAP_CONTEXT))
25462 + /* moved here from the individual commands */
25464 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
25468 + /* vcmd involves resource management */
25470 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
25474 + /* various legacy exceptions */
25476 + /* will go away when spectator is a cap */
25477 + case VCMD_ctx_migrate_v0:
25478 + case VCMD_ctx_migrate:
25480 + current->xid = 1;
25486 + /* will go away when spectator is a cap */
25487 + case VCMD_net_migrate:
25489 + current->nid = 1;
25496 + /* vcmds are fine by default */
25499 + /* admin type vcmds require admin ... */
25500 + if (flags & VCF_ADMIN)
25501 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
25503 + /* ... but setup type vcmds override that */
25504 + if (!permit && (flags & VCF_SETUP))
25505 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
25513 + if (!id && (flags & VCF_ZIDOK))
25517 + if (args & VCA_VXI) {
25518 + vxi = lookup_vx_info(id);
25522 + if ((flags & VCF_ADMIN) &&
25523 + /* special case kill for shutdown */
25524 + (cmd != VCMD_ctx_kill) &&
25525 + /* can context be administrated? */
25526 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
25532 + if (args & VCA_NXI) {
25533 + nxi = lookup_nx_info(id);
25537 + if ((flags & VCF_ADMIN) &&
25538 + /* can context be administrated? */
25539 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
25546 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
25549 + if ((args & VCA_NXI) && nxi)
25550 + put_nx_info(nxi);
25552 + if ((args & VCA_VXI) && vxi)
25553 + put_vx_info(vxi);
25555 + vxdprintk(VXD_CBIT(switch, 1),
25556 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
25557 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
25558 + VC_VERSION(cmd), ret, ret, state, permit);
25563 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
25565 + return do_vserver(cmd, id, data, 0);
25568 +#ifdef CONFIG_COMPAT
25571 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
25573 + return do_vserver(cmd, id, data, 1);
25576 +#endif /* CONFIG_COMPAT */
25577 diff -NurpP --minimal linux-3.0/kernel/vserver/sysctl.c linux-3.0-vs2.3.1-pre7/kernel/vserver/sysctl.c
25578 --- linux-3.0/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
25579 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/sysctl.c 2011-06-10 22:11:24.000000000 +0200
25582 + * kernel/vserver/sysctl.c
25584 + * Virtual Context Support
25586 + * Copyright (C) 2004-2007 Herbert Pötzl
25588 + * V0.01 basic structure
25592 +#include <linux/module.h>
25593 +#include <linux/ctype.h>
25594 +#include <linux/sysctl.h>
25595 +#include <linux/parser.h>
25596 +#include <asm/uaccess.h>
25599 + CTL_DEBUG_ERROR = 0,
25600 + CTL_DEBUG_SWITCH = 1,
25615 +unsigned int vx_debug_switch = 0;
25616 +unsigned int vx_debug_xid = 0;
25617 +unsigned int vx_debug_nid = 0;
25618 +unsigned int vx_debug_tag = 0;
25619 +unsigned int vx_debug_net = 0;
25620 +unsigned int vx_debug_limit = 0;
25621 +unsigned int vx_debug_cres = 0;
25622 +unsigned int vx_debug_dlim = 0;
25623 +unsigned int vx_debug_quota = 0;
25624 +unsigned int vx_debug_cvirt = 0;
25625 +unsigned int vx_debug_space = 0;
25626 +unsigned int vx_debug_misc = 0;
25629 +static struct ctl_table_header *vserver_table_header;
25630 +static ctl_table vserver_root_table[];
25633 +void vserver_register_sysctl(void)
25635 + if (!vserver_table_header) {
25636 + vserver_table_header = register_sysctl_table(vserver_root_table);
25641 +void vserver_unregister_sysctl(void)
25643 + if (vserver_table_header) {
25644 + unregister_sysctl_table(vserver_table_header);
25645 + vserver_table_header = NULL;
25650 +static int proc_dodebug(ctl_table *table, int write,
25651 + void __user *buffer, size_t *lenp, loff_t *ppos)
25653 + char tmpbuf[20], *p, c;
25654 + unsigned int value;
25655 + size_t left, len;
25657 + if ((*ppos && !write) || !*lenp) {
25665 + if (!access_ok(VERIFY_READ, buffer, left))
25667 + p = (char *)buffer;
25668 + while (left && __get_user(c, p) >= 0 && isspace(c))
25673 + if (left > sizeof(tmpbuf) - 1)
25675 + if (copy_from_user(tmpbuf, p, left))
25677 + tmpbuf[left] = '\0';
25679 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
25680 + value = 10 * value + (*p - '0');
25681 + if (*p && !isspace(*p))
25683 + while (left && isspace(*p))
25685 + *(unsigned int *)table->data = value;
25687 + if (!access_ok(VERIFY_WRITE, buffer, left))
25689 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
25692 + if (__copy_to_user(buffer, tmpbuf, len))
25694 + if ((left -= len) > 0) {
25695 + if (put_user('\n', (char *)buffer + len))
25709 +#define CTL_ENTRY(ctl, name) \
25711 + .procname = #name, \
25712 + .data = &vx_ ## name, \
25713 + .maxlen = sizeof(int), \
25715 + .proc_handler = &proc_dodebug, \
25716 + .extra1 = &zero, \
25717 + .extra2 = &zero, \
25720 +static ctl_table vserver_debug_table[] = {
25721 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
25722 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
25723 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
25724 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
25725 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
25726 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
25727 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
25728 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
25729 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
25730 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
25731 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
25732 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
25736 +static ctl_table vserver_root_table[] = {
25738 + .procname = "vserver",
25740 + .child = vserver_debug_table
25746 +static match_table_t tokens = {
25747 + { CTL_DEBUG_SWITCH, "switch=%x" },
25748 + { CTL_DEBUG_XID, "xid=%x" },
25749 + { CTL_DEBUG_NID, "nid=%x" },
25750 + { CTL_DEBUG_TAG, "tag=%x" },
25751 + { CTL_DEBUG_NET, "net=%x" },
25752 + { CTL_DEBUG_LIMIT, "limit=%x" },
25753 + { CTL_DEBUG_CRES, "cres=%x" },
25754 + { CTL_DEBUG_DLIM, "dlim=%x" },
25755 + { CTL_DEBUG_QUOTA, "quota=%x" },
25756 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
25757 + { CTL_DEBUG_SPACE, "space=%x" },
25758 + { CTL_DEBUG_MISC, "misc=%x" },
25759 + { CTL_DEBUG_ERROR, NULL }
25762 +#define HANDLE_CASE(id, name, val) \
25763 + case CTL_DEBUG_ ## id: \
25764 + vx_debug_ ## name = val; \
25765 + printk("vs_debug_" #name "=0x%x\n", val); \
25769 +static int __init vs_debug_setup(char *str)
25774 + printk("vs_debug_setup(%s)\n", str);
25775 + while ((p = strsep(&str, ",")) != NULL) {
25776 + substring_t args[MAX_OPT_ARGS];
25777 + unsigned int value;
25782 + token = match_token(p, tokens, args);
25783 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
25786 + HANDLE_CASE(SWITCH, switch, value);
25787 + HANDLE_CASE(XID, xid, value);
25788 + HANDLE_CASE(NID, nid, value);
25789 + HANDLE_CASE(TAG, tag, value);
25790 + HANDLE_CASE(NET, net, value);
25791 + HANDLE_CASE(LIMIT, limit, value);
25792 + HANDLE_CASE(CRES, cres, value);
25793 + HANDLE_CASE(DLIM, dlim, value);
25794 + HANDLE_CASE(QUOTA, quota, value);
25795 + HANDLE_CASE(CVIRT, cvirt, value);
25796 + HANDLE_CASE(SPACE, space, value);
25797 + HANDLE_CASE(MISC, misc, value);
25806 +__setup("vsdebug=", vs_debug_setup);
25810 +EXPORT_SYMBOL_GPL(vx_debug_switch);
25811 +EXPORT_SYMBOL_GPL(vx_debug_xid);
25812 +EXPORT_SYMBOL_GPL(vx_debug_nid);
25813 +EXPORT_SYMBOL_GPL(vx_debug_net);
25814 +EXPORT_SYMBOL_GPL(vx_debug_limit);
25815 +EXPORT_SYMBOL_GPL(vx_debug_cres);
25816 +EXPORT_SYMBOL_GPL(vx_debug_dlim);
25817 +EXPORT_SYMBOL_GPL(vx_debug_quota);
25818 +EXPORT_SYMBOL_GPL(vx_debug_cvirt);
25819 +EXPORT_SYMBOL_GPL(vx_debug_space);
25820 +EXPORT_SYMBOL_GPL(vx_debug_misc);
25822 diff -NurpP --minimal linux-3.0/kernel/vserver/tag.c linux-3.0-vs2.3.1-pre7/kernel/vserver/tag.c
25823 --- linux-3.0/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
25824 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/tag.c 2011-06-10 22:11:24.000000000 +0200
25827 + * linux/kernel/vserver/tag.c
25829 + * Virtual Server: Shallow Tag Space
25831 + * Copyright (C) 2007 Herbert Pötzl
25833 + * V0.01 basic implementation
25837 +#include <linux/sched.h>
25838 +#include <linux/vserver/debug.h>
25839 +#include <linux/vs_pid.h>
25840 +#include <linux/vs_tag.h>
25842 +#include <linux/vserver/tag_cmd.h>
25845 +int dx_migrate_task(struct task_struct *p, tag_t tag)
25850 + vxdprintk(VXD_CBIT(tag, 5),
25851 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
25857 + vxdprintk(VXD_CBIT(tag, 5),
25858 + "moved task %p into [#%d]", p, tag);
25862 +/* vserver syscall commands below here */
25864 +/* taks xid and vx_info functions */
25867 +int vc_task_tag(uint32_t id)
25872 + struct task_struct *tsk;
25874 + tsk = find_task_by_real_pid(id);
25875 + tag = (tsk) ? tsk->tag : -ESRCH;
25876 + rcu_read_unlock();
25878 + tag = dx_current_tag();
25883 +int vc_tag_migrate(uint32_t tag)
25885 + return dx_migrate_task(current, tag & 0xFFFF);
25889 diff -NurpP --minimal linux-3.0/kernel/vserver/vci_config.h linux-3.0-vs2.3.1-pre7/kernel/vserver/vci_config.h
25890 --- linux-3.0/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
25891 +++ linux-3.0-vs2.3.1-pre7/kernel/vserver/vci_config.h 2011-06-10 22:11:24.000000000 +0200
25894 +/* interface version */
25896 +#define VCI_VERSION 0x00020308
25900 + VCI_KCBIT_NO_DYNAMIC = 0,
25902 + VCI_KCBIT_PROC_SECURE = 4,
25903 + /* VCI_KCBIT_HARDCPU = 5, */
25904 + /* VCI_KCBIT_IDLELIMIT = 6, */
25905 + /* VCI_KCBIT_IDLETIME = 7, */
25907 + VCI_KCBIT_COWBL = 8,
25908 + VCI_KCBIT_FULLCOWBL = 9,
25909 + VCI_KCBIT_SPACES = 10,
25910 + VCI_KCBIT_NETV2 = 11,
25911 + VCI_KCBIT_MEMCG = 12,
25913 + VCI_KCBIT_DEBUG = 16,
25914 + VCI_KCBIT_HISTORY = 20,
25915 + VCI_KCBIT_TAGGED = 24,
25916 + VCI_KCBIT_PPTAG = 28,
25918 + VCI_KCBIT_MORE = 31,
25922 +static inline uint32_t vci_kernel_config(void)
25925 + (1 << VCI_KCBIT_NO_DYNAMIC) |
25927 + /* configured features */
25928 +#ifdef CONFIG_VSERVER_PROC_SECURE
25929 + (1 << VCI_KCBIT_PROC_SECURE) |
25931 +#ifdef CONFIG_VSERVER_COWBL
25932 + (1 << VCI_KCBIT_COWBL) |
25933 + (1 << VCI_KCBIT_FULLCOWBL) |
25935 + (1 << VCI_KCBIT_SPACES) |
25936 + (1 << VCI_KCBIT_NETV2) |
25937 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
25938 + (1 << VCI_KCBIT_MEMCG) |
25941 + /* debug options */
25942 +#ifdef CONFIG_VSERVER_DEBUG
25943 + (1 << VCI_KCBIT_DEBUG) |
25945 +#ifdef CONFIG_VSERVER_HISTORY
25946 + (1 << VCI_KCBIT_HISTORY) |
25949 + /* inode context tagging */
25950 +#if defined(CONFIG_TAGGING_NONE)
25951 + (0 << VCI_KCBIT_TAGGED) |
25952 +#elif defined(CONFIG_TAGGING_UID16)
25953 + (1 << VCI_KCBIT_TAGGED) |
25954 +#elif defined(CONFIG_TAGGING_GID16)
25955 + (2 << VCI_KCBIT_TAGGED) |
25956 +#elif defined(CONFIG_TAGGING_ID24)
25957 + (3 << VCI_KCBIT_TAGGED) |
25958 +#elif defined(CONFIG_TAGGING_INTERN)
25959 + (4 << VCI_KCBIT_TAGGED) |
25960 +#elif defined(CONFIG_TAGGING_RUNTIME)
25961 + (5 << VCI_KCBIT_TAGGED) |
25963 + (7 << VCI_KCBIT_TAGGED) |
25965 + (1 << VCI_KCBIT_PPTAG) |
25969 diff -NurpP --minimal linux-3.0/mm/filemap_xip.c linux-3.0-vs2.3.1-pre7/mm/filemap_xip.c
25970 --- linux-3.0/mm/filemap_xip.c 2011-07-22 11:18:12.000000000 +0200
25971 +++ linux-3.0-vs2.3.1-pre7/mm/filemap_xip.c 2011-06-10 22:11:24.000000000 +0200
25973 #include <linux/seqlock.h>
25974 #include <linux/mutex.h>
25975 #include <linux/gfp.h>
25976 +#include <linux/vs_memory.h>
25977 #include <asm/tlbflush.h>
25978 #include <asm/io.h>
25980 diff -NurpP --minimal linux-3.0/mm/fremap.c linux-3.0-vs2.3.1-pre7/mm/fremap.c
25981 --- linux-3.0/mm/fremap.c 2011-07-22 11:18:12.000000000 +0200
25982 +++ linux-3.0-vs2.3.1-pre7/mm/fremap.c 2011-06-10 22:11:24.000000000 +0200
25984 #include <linux/module.h>
25985 #include <linux/syscalls.h>
25986 #include <linux/mmu_notifier.h>
25987 +#include <linux/vs_memory.h>
25989 #include <asm/mmu_context.h>
25990 #include <asm/cacheflush.h>
25991 diff -NurpP --minimal linux-3.0/mm/hugetlb.c linux-3.0-vs2.3.1-pre7/mm/hugetlb.c
25992 --- linux-3.0/mm/hugetlb.c 2011-07-22 11:18:12.000000000 +0200
25993 +++ linux-3.0-vs2.3.1-pre7/mm/hugetlb.c 2011-06-22 12:39:16.000000000 +0200
25996 #include <linux/hugetlb.h>
25997 #include <linux/node.h>
25998 +#include <linux/vs_memory.h>
25999 #include "internal.h"
26001 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
26002 diff -NurpP --minimal linux-3.0/mm/memcontrol.c linux-3.0-vs2.3.1-pre7/mm/memcontrol.c
26003 --- linux-3.0/mm/memcontrol.c 2011-07-22 11:18:12.000000000 +0200
26004 +++ linux-3.0-vs2.3.1-pre7/mm/memcontrol.c 2011-07-19 00:44:39.000000000 +0200
26005 @@ -741,6 +741,31 @@ struct mem_cgroup *mem_cgroup_from_task(
26006 struct mem_cgroup, css);
26009 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
26011 + return res_counter_read_u64(&mem->res, member);
26014 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
26016 + return res_counter_read_u64(&mem->memsw, member);
26019 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
26021 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
26024 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
26026 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
26029 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
26031 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
26034 struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
26036 struct mem_cgroup *mem = NULL;
26037 diff -NurpP --minimal linux-3.0/mm/memory.c linux-3.0-vs2.3.1-pre7/mm/memory.c
26038 --- linux-3.0/mm/memory.c 2011-07-22 11:18:12.000000000 +0200
26039 +++ linux-3.0-vs2.3.1-pre7/mm/memory.c 2011-07-19 00:44:39.000000000 +0200
26040 @@ -3332,6 +3332,7 @@ int handle_pte_fault(struct mm_struct *m
26044 + int ret = 0, type = VXPT_UNKNOWN;
26047 if (!pte_present(entry)) {
26048 @@ -3356,9 +3357,12 @@ int handle_pte_fault(struct mm_struct *m
26049 if (unlikely(!pte_same(*pte, entry)))
26051 if (flags & FAULT_FLAG_WRITE) {
26052 - if (!pte_write(entry))
26053 - return do_wp_page(mm, vma, address,
26054 + if (!pte_write(entry)) {
26055 + ret = do_wp_page(mm, vma, address,
26056 pte, pmd, ptl, entry);
26057 + type = VXPT_WRITE;
26060 entry = pte_mkdirty(entry);
26062 entry = pte_mkyoung(entry);
26063 @@ -3376,7 +3380,10 @@ int handle_pte_fault(struct mm_struct *m
26066 pte_unmap_unlock(pte, ptl);
26070 + vx_page_fault(mm, vma, type, ret);
26075 diff -NurpP --minimal linux-3.0/mm/mremap.c linux-3.0-vs2.3.1-pre7/mm/mremap.c
26076 --- linux-3.0/mm/mremap.c 2011-07-22 11:18:12.000000000 +0200
26077 +++ linux-3.0-vs2.3.1-pre7/mm/mremap.c 2011-06-10 22:11:24.000000000 +0200
26079 #include <linux/security.h>
26080 #include <linux/syscalls.h>
26081 #include <linux/mmu_notifier.h>
26082 +#include <linux/vs_memory.h>
26084 #include <asm/uaccess.h>
26085 #include <asm/cacheflush.h>
26086 diff -NurpP --minimal linux-3.0/mm/oom_kill.c linux-3.0-vs2.3.1-pre7/mm/oom_kill.c
26087 --- linux-3.0/mm/oom_kill.c 2011-07-22 11:18:12.000000000 +0200
26088 +++ linux-3.0-vs2.3.1-pre7/mm/oom_kill.c 2011-06-10 22:11:24.000000000 +0200
26090 #include <linux/mempolicy.h>
26091 #include <linux/security.h>
26092 #include <linux/ptrace.h>
26093 +#include <linux/reboot.h>
26094 +#include <linux/vs_memory.h>
26095 +#include <linux/vs_context.h>
26097 int sysctl_panic_on_oom;
26098 int sysctl_oom_kill_allocating_task;
26099 @@ -134,11 +137,18 @@ struct task_struct *find_lock_task_mm(st
26100 static bool oom_unkillable_task(struct task_struct *p,
26101 const struct mem_cgroup *mem, const nodemask_t *nodemask)
26103 - if (is_global_init(p))
26104 + unsigned xid = vx_current_xid();
26106 + /* skip the init task, global and per guest */
26107 + if (task_is_init(p))
26109 if (p->flags & PF_KTHREAD)
26112 + /* skip other guest and host processes if oom in guest */
26113 + if (xid && vx_task_xid(p) != xid)
26116 /* When mem_cgroup_out_of_memory() and p is not member of the group */
26117 if (mem && !task_in_mem_cgroup(p, mem))
26119 @@ -214,6 +224,18 @@ unsigned int oom_badness(struct task_str
26120 points += p->signal->oom_score_adj;
26123 + * add points for context badness and
26124 + * reduce badness for processes belonging to
26125 + * a different context
26128 + points += vx_badness(p, p->mm);
26130 + if ((vx_current_xid() > 1) &&
26131 + vx_current_xid() != vx_task_xid(p))
26135 * Never return 0 for an eligible task that may be killed since it's
26136 * possible that no single user task uses more than 0.1% of memory and
26137 * no single admin tasks uses more than 3.0%.
26138 @@ -427,8 +449,8 @@ static int oom_kill_task(struct task_str
26139 /* mm cannot be safely dereferenced after task_unlock(p) */
26142 - pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
26143 - task_pid_nr(p), p->comm, K(p->mm->total_vm),
26144 + pr_err("Killed process %d:#%u (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
26145 + task_pid_nr(p), p->xid, p->comm, K(p->mm->total_vm),
26146 K(get_mm_counter(p->mm, MM_ANONPAGES)),
26147 K(get_mm_counter(p->mm, MM_FILEPAGES)));
26149 @@ -482,8 +504,8 @@ static int oom_kill_process(struct task_
26153 - pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
26154 - message, task_pid_nr(p), p->comm, points);
26155 + pr_err("%s: Kill process %d:#%u (%s) score %d or sacrifice child\n",
26156 + message, task_pid_nr(p), p->xid, p->comm, points);
26160 @@ -584,6 +606,8 @@ int unregister_oom_notifier(struct notif
26162 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
26164 +long vs_oom_action(unsigned int);
26167 * Try to acquire the OOM killer lock for the zones in zonelist. Returns zero
26168 * if a parallel OOM killing is already taking place that includes a zone in
26169 @@ -742,7 +766,12 @@ retry:
26171 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
26172 read_unlock(&tasklist_lock);
26173 - panic("Out of memory and no killable processes...\n");
26175 + /* avoid panic for guest OOM */
26176 + if (current->xid)
26177 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
26179 + panic("Out of memory and no killable processes...\n");
26182 if (oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
26183 diff -NurpP --minimal linux-3.0/mm/page_alloc.c linux-3.0-vs2.3.1-pre7/mm/page_alloc.c
26184 --- linux-3.0/mm/page_alloc.c 2011-07-22 11:18:12.000000000 +0200
26185 +++ linux-3.0-vs2.3.1-pre7/mm/page_alloc.c 2011-06-10 22:24:12.000000000 +0200
26187 #include <linux/ftrace_event.h>
26188 #include <linux/memcontrol.h>
26189 #include <linux/prefetch.h>
26190 +#include <linux/vs_base.h>
26191 +#include <linux/vs_limit.h>
26193 #include <asm/tlbflush.h>
26194 #include <asm/div64.h>
26195 @@ -2470,6 +2472,9 @@ void si_meminfo(struct sysinfo *val)
26196 val->totalhigh = totalhigh_pages;
26197 val->freehigh = nr_free_highpages();
26198 val->mem_unit = PAGE_SIZE;
26200 + if (vx_flags(VXF_VIRT_MEM, 0))
26201 + vx_vsi_meminfo(val);
26204 EXPORT_SYMBOL(si_meminfo);
26205 @@ -2490,6 +2495,9 @@ void si_meminfo_node(struct sysinfo *val
26208 val->mem_unit = PAGE_SIZE;
26210 + if (vx_flags(VXF_VIRT_MEM, 0))
26211 + vx_vsi_meminfo(val);
26215 diff -NurpP --minimal linux-3.0/mm/pgtable-generic.c linux-3.0-vs2.3.1-pre7/mm/pgtable-generic.c
26216 --- linux-3.0/mm/pgtable-generic.c 2011-03-15 18:07:42.000000000 +0100
26217 +++ linux-3.0-vs2.3.1-pre7/mm/pgtable-generic.c 2011-06-10 22:11:24.000000000 +0200
26219 * Copyright (C) 2010 Linus Torvalds
26222 +#include <linux/mm.h>
26224 #include <linux/pagemap.h>
26225 #include <asm/tlb.h>
26226 #include <asm-generic/pgtable.h>
26227 diff -NurpP --minimal linux-3.0/mm/rmap.c linux-3.0-vs2.3.1-pre7/mm/rmap.c
26228 --- linux-3.0/mm/rmap.c 2011-07-22 11:18:12.000000000 +0200
26229 +++ linux-3.0-vs2.3.1-pre7/mm/rmap.c 2011-07-01 11:35:35.000000000 +0200
26231 #include <linux/mmu_notifier.h>
26232 #include <linux/migrate.h>
26233 #include <linux/hugetlb.h>
26234 +#include <linux/vs_memory.h>
26236 #include <asm/tlbflush.h>
26238 diff -NurpP --minimal linux-3.0/mm/shmem.c linux-3.0-vs2.3.1-pre7/mm/shmem.c
26239 --- linux-3.0/mm/shmem.c 2011-07-22 11:18:12.000000000 +0200
26240 +++ linux-3.0-vs2.3.1-pre7/mm/shmem.c 2011-07-01 11:35:35.000000000 +0200
26241 @@ -1850,7 +1850,7 @@ static int shmem_statfs(struct dentry *d
26243 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
26245 - buf->f_type = TMPFS_MAGIC;
26246 + buf->f_type = TMPFS_SUPER_MAGIC;
26247 buf->f_bsize = PAGE_CACHE_SIZE;
26248 buf->f_namelen = NAME_MAX;
26249 if (sbinfo->max_blocks) {
26250 @@ -2605,7 +2605,7 @@ int shmem_fill_super(struct super_block
26251 sb->s_maxbytes = SHMEM_MAX_BYTES;
26252 sb->s_blocksize = PAGE_CACHE_SIZE;
26253 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
26254 - sb->s_magic = TMPFS_MAGIC;
26255 + sb->s_magic = TMPFS_SUPER_MAGIC;
26256 sb->s_op = &shmem_ops;
26257 sb->s_time_gran = 1;
26258 #ifdef CONFIG_TMPFS_XATTR
26259 diff -NurpP --minimal linux-3.0/mm/slab.c linux-3.0-vs2.3.1-pre7/mm/slab.c
26260 --- linux-3.0/mm/slab.c 2011-07-22 11:18:12.000000000 +0200
26261 +++ linux-3.0-vs2.3.1-pre7/mm/slab.c 2011-06-15 02:41:23.000000000 +0200
26262 @@ -411,6 +411,8 @@ static void kmem_list3_init(struct kmem_
26263 #define STATS_INC_FREEMISS(x) do { } while (0)
26266 +#include "slab_vs.h"
26271 @@ -3348,6 +3350,7 @@ retry:
26273 obj = slab_get_obj(cachep, slabp, nodeid);
26274 check_slabp(cachep, slabp);
26275 + vx_slab_alloc(cachep, flags);
26276 l3->free_objects--;
26277 /* move slabp to correct slabp list: */
26278 list_del(&slabp->list);
26279 @@ -3425,6 +3428,7 @@ __cache_alloc_node(struct kmem_cache *ca
26280 /* ___cache_alloc_node can fall back to other nodes */
26281 ptr = ____cache_alloc_node(cachep, flags, nodeid);
26283 + vx_slab_alloc(cachep, flags);
26284 local_irq_restore(save_flags);
26285 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
26286 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
26287 @@ -3612,6 +3616,7 @@ static inline void __cache_free(struct k
26289 kmemleak_free_recursive(objp, cachep->flags);
26290 objp = cache_free_debugcheck(cachep, objp, caller);
26291 + vx_slab_free(cachep);
26293 kmemcheck_slab_free(cachep, objp, obj_size(cachep));
26295 diff -NurpP --minimal linux-3.0/mm/slab_vs.h linux-3.0-vs2.3.1-pre7/mm/slab_vs.h
26296 --- linux-3.0/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
26297 +++ linux-3.0-vs2.3.1-pre7/mm/slab_vs.h 2011-06-10 22:11:24.000000000 +0200
26300 +#include <linux/vserver/context.h>
26302 +#include <linux/vs_context.h>
26305 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
26307 + int what = gfp_zone(cachep->gfpflags);
26308 + struct vx_info *vxi = current_vx_info();
26313 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
26317 +void vx_slab_free(struct kmem_cache *cachep)
26319 + int what = gfp_zone(cachep->gfpflags);
26320 + struct vx_info *vxi = current_vx_info();
26325 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
26328 diff -NurpP --minimal linux-3.0/mm/swapfile.c linux-3.0-vs2.3.1-pre7/mm/swapfile.c
26329 --- linux-3.0/mm/swapfile.c 2011-07-22 11:18:12.000000000 +0200
26330 +++ linux-3.0-vs2.3.1-pre7/mm/swapfile.c 2011-07-01 11:35:35.000000000 +0200
26332 #include <asm/tlbflush.h>
26333 #include <linux/swapops.h>
26334 #include <linux/page_cgroup.h>
26335 +#include <linux/vs_base.h>
26336 +#include <linux/vs_memory.h>
26338 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
26340 @@ -1759,6 +1761,16 @@ static int swap_show(struct seq_file *sw
26342 if (si == SEQ_START_TOKEN) {
26343 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
26344 + if (vx_flags(VXF_VIRT_MEM, 0)) {
26345 + struct sysinfo si;
26347 + vx_vsi_swapinfo(&si);
26348 + if (si.totalswap < (1 << 10))
26350 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
26351 + "hdv0", "partition", si.totalswap >> 10,
26352 + (si.totalswap - si.freeswap) >> 10, -1);
26357 @@ -2186,6 +2198,8 @@ void si_swapinfo(struct sysinfo *val)
26358 val->freeswap = nr_swap_pages + nr_to_be_unused;
26359 val->totalswap = total_swap_pages + nr_to_be_unused;
26360 spin_unlock(&swap_lock);
26361 + if (vx_flags(VXF_VIRT_MEM, 0))
26362 + vx_vsi_swapinfo(val);
26366 diff -NurpP --minimal linux-3.0/net/bridge/br_multicast.c linux-3.0-vs2.3.1-pre7/net/bridge/br_multicast.c
26367 --- linux-3.0/net/bridge/br_multicast.c 2011-07-22 11:18:12.000000000 +0200
26368 +++ linux-3.0-vs2.3.1-pre7/net/bridge/br_multicast.c 2011-07-19 00:44:39.000000000 +0200
26369 @@ -447,7 +447,7 @@ static struct sk_buff *br_ip6_multicast_
26370 ip6h->hop_limit = 1;
26371 ipv6_addr_set(&ip6h->daddr, htonl(0xff020000), 0, 0, htonl(1));
26372 ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0,
26374 + &ip6h->saddr, NULL);
26375 ipv6_eth_mc_map(&ip6h->daddr, eth->h_dest);
26377 hopopt = (u8 *)(ip6h + 1);
26378 diff -NurpP --minimal linux-3.0/net/core/dev.c linux-3.0-vs2.3.1-pre7/net/core/dev.c
26379 --- linux-3.0/net/core/dev.c 2011-07-22 11:18:13.000000000 +0200
26380 +++ linux-3.0-vs2.3.1-pre7/net/core/dev.c 2011-06-15 02:40:14.000000000 +0200
26381 @@ -127,6 +127,7 @@
26382 #include <linux/in.h>
26383 #include <linux/jhash.h>
26384 #include <linux/random.h>
26385 +#include <linux/vs_inet.h>
26386 #include <trace/events/napi.h>
26387 #include <trace/events/net.h>
26388 #include <trace/events/skb.h>
26389 @@ -609,7 +610,8 @@ struct net_device *__dev_get_by_name(str
26390 struct hlist_head *head = dev_name_hash(net, name);
26392 hlist_for_each_entry(dev, p, head, name_hlist)
26393 - if (!strncmp(dev->name, name, IFNAMSIZ))
26394 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
26395 + nx_dev_visible(current_nx_info(), dev))
26399 @@ -635,7 +637,8 @@ struct net_device *dev_get_by_name_rcu(s
26400 struct hlist_head *head = dev_name_hash(net, name);
26402 hlist_for_each_entry_rcu(dev, p, head, name_hlist)
26403 - if (!strncmp(dev->name, name, IFNAMSIZ))
26404 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
26405 + nx_dev_visible(current_nx_info(), dev))
26409 @@ -686,7 +689,8 @@ struct net_device *__dev_get_by_index(st
26410 struct hlist_head *head = dev_index_hash(net, ifindex);
26412 hlist_for_each_entry(dev, p, head, index_hlist)
26413 - if (dev->ifindex == ifindex)
26414 + if ((dev->ifindex == ifindex) &&
26415 + nx_dev_visible(current_nx_info(), dev))
26419 @@ -711,7 +715,8 @@ struct net_device *dev_get_by_index_rcu(
26420 struct hlist_head *head = dev_index_hash(net, ifindex);
26422 hlist_for_each_entry_rcu(dev, p, head, index_hlist)
26423 - if (dev->ifindex == ifindex)
26424 + if ((dev->ifindex == ifindex) &&
26425 + nx_dev_visible(current_nx_info(), dev))
26429 @@ -764,7 +769,8 @@ struct net_device *dev_getbyhwaddr_rcu(s
26431 for_each_netdev_rcu(net, dev)
26432 if (dev->type == type &&
26433 - !memcmp(dev->dev_addr, ha, dev->addr_len))
26434 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
26435 + nx_dev_visible(current_nx_info(), dev))
26439 @@ -776,9 +782,11 @@ struct net_device *__dev_getfirstbyhwtyp
26440 struct net_device *dev;
26443 - for_each_netdev(net, dev)
26444 - if (dev->type == type)
26445 + for_each_netdev(net, dev) {
26446 + if ((dev->type == type) &&
26447 + nx_dev_visible(current_nx_info(), dev))
26453 @@ -896,6 +904,8 @@ static int __dev_alloc_name(struct net *
26455 if (i < 0 || i >= max_netdevices)
26457 + if (!nx_dev_visible(current_nx_info(), d))
26460 /* avoid cases where sscanf is not exact inverse of printf */
26461 snprintf(buf, IFNAMSIZ, name, i);
26462 @@ -3937,6 +3947,8 @@ static int dev_ifconf(struct net *net, c
26465 for_each_netdev(net, dev) {
26466 + if (!nx_dev_visible(current_nx_info(), dev))
26468 for (i = 0; i < NPROTO; i++) {
26469 if (gifconf_list[i]) {
26471 @@ -4011,6 +4023,10 @@ static void dev_seq_printf_stats(struct
26472 struct rtnl_link_stats64 temp;
26473 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
26475 + /* device visible inside network context? */
26476 + if (!nx_dev_visible(current_nx_info(), dev))
26479 seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
26480 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
26481 dev->name, stats->rx_bytes, stats->rx_packets,
26482 diff -NurpP --minimal linux-3.0/net/core/rtnetlink.c linux-3.0-vs2.3.1-pre7/net/core/rtnetlink.c
26483 --- linux-3.0/net/core/rtnetlink.c 2011-07-22 11:18:13.000000000 +0200
26484 +++ linux-3.0-vs2.3.1-pre7/net/core/rtnetlink.c 2011-06-10 22:11:24.000000000 +0200
26485 @@ -1015,6 +1015,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
26486 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
26489 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
26491 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
26492 NETLINK_CB(cb->skb).pid,
26493 cb->nlh->nlmsg_seq, 0,
26494 @@ -1848,6 +1850,9 @@ void rtmsg_ifinfo(int type, struct net_d
26495 struct sk_buff *skb;
26496 int err = -ENOBUFS;
26498 + if (!nx_dev_visible(current_nx_info(), dev))
26501 skb = nlmsg_new(if_nlmsg_size(dev), GFP_KERNEL);
26504 diff -NurpP --minimal linux-3.0/net/core/sock.c linux-3.0-vs2.3.1-pre7/net/core/sock.c
26505 --- linux-3.0/net/core/sock.c 2011-05-22 16:18:00.000000000 +0200
26506 +++ linux-3.0-vs2.3.1-pre7/net/core/sock.c 2011-06-10 22:11:24.000000000 +0200
26507 @@ -127,6 +127,10 @@
26508 #include <net/cls_cgroup.h>
26510 #include <linux/filter.h>
26511 +#include <linux/vs_socket.h>
26512 +#include <linux/vs_limit.h>
26513 +#include <linux/vs_context.h>
26514 +#include <linux/vs_network.h>
26517 #include <net/tcp.h>
26518 @@ -1070,6 +1074,8 @@ static struct sock *sk_prot_alloc(struct
26520 sk_tx_queue_clear(sk);
26522 + sock_vx_init(sk);
26523 + sock_nx_init(sk);
26527 @@ -1169,6 +1175,11 @@ static void __sk_free(struct sock *sk)
26528 put_cred(sk->sk_peer_cred);
26529 put_pid(sk->sk_peer_pid);
26530 put_net(sock_net(sk));
26532 + clr_vx_info(&sk->sk_vx_info);
26534 + clr_nx_info(&sk->sk_nx_info);
26536 sk_prot_free(sk->sk_prot_creator, sk);
26539 @@ -1216,6 +1227,8 @@ struct sock *sk_clone(const struct sock
26542 get_net(sock_net(newsk));
26543 + sock_vx_init(newsk);
26544 + sock_nx_init(newsk);
26545 sk_node_init(&newsk->sk_node);
26546 sock_lock_init(newsk);
26547 bh_lock_sock(newsk);
26548 @@ -1271,6 +1284,12 @@ struct sock *sk_clone(const struct sock
26550 atomic_set(&newsk->sk_refcnt, 2);
26552 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
26553 + newsk->sk_xid = sk->sk_xid;
26554 + vx_sock_inc(newsk);
26555 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
26556 + newsk->sk_nid = sk->sk_nid;
26559 * Increment the counter in the same struct proto as the master
26560 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
26561 @@ -2017,6 +2036,12 @@ void sock_init_data(struct socket *sock,
26563 sk->sk_stamp = ktime_set(-1L, 0);
26565 + set_vx_info(&sk->sk_vx_info, current_vx_info());
26566 + sk->sk_xid = vx_current_xid();
26568 + set_nx_info(&sk->sk_nx_info, current_nx_info());
26569 + sk->sk_nid = nx_current_nid();
26572 * Before updating sk_refcnt, we must commit prior changes to memory
26573 * (Documentation/RCU/rculist_nulls.txt for details)
26574 diff -NurpP --minimal linux-3.0/net/ipv4/af_inet.c linux-3.0-vs2.3.1-pre7/net/ipv4/af_inet.c
26575 --- linux-3.0/net/ipv4/af_inet.c 2011-07-22 11:18:13.000000000 +0200
26576 +++ linux-3.0-vs2.3.1-pre7/net/ipv4/af_inet.c 2011-07-19 00:44:39.000000000 +0200
26577 @@ -117,6 +117,7 @@
26578 #ifdef CONFIG_IP_MROUTE
26579 #include <linux/mroute.h>
26581 +#include <linux/vs_limit.h>
26584 /* The inetsw table contains everything that inet_create needs to
26585 @@ -326,9 +327,13 @@ lookup_protocol:
26589 + if ((protocol == IPPROTO_ICMP) &&
26590 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
26593 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
26594 goto out_rcu_unlock;
26597 err = -EAFNOSUPPORT;
26598 if (!inet_netns_ok(net, protocol))
26599 goto out_rcu_unlock;
26600 @@ -452,6 +457,7 @@ int inet_bind(struct socket *sock, struc
26601 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
26602 struct sock *sk = sock->sk;
26603 struct inet_sock *inet = inet_sk(sk);
26604 + struct nx_v4_sock_addr nsa;
26605 unsigned short snum;
26608 @@ -470,7 +476,11 @@ int inet_bind(struct socket *sock, struc
26612 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
26613 + err = v4_map_sock_addr(inet, addr, &nsa);
26617 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
26619 /* Not specified by any standard per-se, however it breaks too
26620 * many applications when removed. It is unfortunate since
26621 @@ -482,7 +492,7 @@ int inet_bind(struct socket *sock, struc
26622 err = -EADDRNOTAVAIL;
26623 if (!sysctl_ip_nonlocal_bind &&
26624 !(inet->freebind || inet->transparent) &&
26625 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
26626 + nsa.saddr != htonl(INADDR_ANY) &&
26627 chk_addr_ret != RTN_LOCAL &&
26628 chk_addr_ret != RTN_MULTICAST &&
26629 chk_addr_ret != RTN_BROADCAST)
26630 @@ -507,7 +517,7 @@ int inet_bind(struct socket *sock, struc
26631 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
26632 goto out_release_sock;
26634 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
26635 + v4_set_sock_addr(inet, &nsa);
26636 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
26637 inet->inet_saddr = 0; /* Use device */
26639 @@ -710,11 +720,13 @@ int inet_getname(struct socket *sock, st
26642 sin->sin_port = inet->inet_dport;
26643 - sin->sin_addr.s_addr = inet->inet_daddr;
26644 + sin->sin_addr.s_addr =
26645 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
26647 __be32 addr = inet->inet_rcv_saddr;
26649 addr = inet->inet_saddr;
26650 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
26651 sin->sin_port = inet->inet_sport;
26652 sin->sin_addr.s_addr = addr;
26654 diff -NurpP --minimal linux-3.0/net/ipv4/devinet.c linux-3.0-vs2.3.1-pre7/net/ipv4/devinet.c
26655 --- linux-3.0/net/ipv4/devinet.c 2011-07-22 11:18:13.000000000 +0200
26656 +++ linux-3.0-vs2.3.1-pre7/net/ipv4/devinet.c 2011-06-10 22:11:24.000000000 +0200
26657 @@ -518,6 +518,7 @@ struct in_device *inetdev_by_index(struc
26659 EXPORT_SYMBOL(inetdev_by_index);
26662 /* Called only from RTNL semaphored context. No locks. */
26664 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
26665 @@ -759,6 +760,8 @@ int devinet_ioctl(struct net *net, unsig
26667 in_dev = __in_dev_get_rtnl(dev);
26669 + struct nx_info *nxi = current_nx_info();
26671 if (tryaddrmatch) {
26672 /* Matthias Andree */
26673 /* compare label and address (4.4BSD style) */
26674 @@ -767,6 +770,8 @@ int devinet_ioctl(struct net *net, unsig
26675 This is checked above. */
26676 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26677 ifap = &ifa->ifa_next) {
26678 + if (!nx_v4_ifa_visible(nxi, ifa))
26680 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
26681 sin_orig.sin_addr.s_addr ==
26683 @@ -779,9 +784,12 @@ int devinet_ioctl(struct net *net, unsig
26684 comparing just the label */
26686 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
26687 - ifap = &ifa->ifa_next)
26688 + ifap = &ifa->ifa_next) {
26689 + if (!nx_v4_ifa_visible(nxi, ifa))
26691 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
26697 @@ -934,6 +942,8 @@ static int inet_gifconf(struct net_devic
26700 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
26701 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
26704 done += sizeof(ifr);
26706 @@ -1294,6 +1304,7 @@ static int inet_dump_ifaddr(struct sk_bu
26707 struct net_device *dev;
26708 struct in_device *in_dev;
26709 struct in_ifaddr *ifa;
26710 + struct sock *sk = skb->sk;
26711 struct hlist_head *head;
26712 struct hlist_node *node;
26714 @@ -1316,6 +1327,8 @@ static int inet_dump_ifaddr(struct sk_bu
26716 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
26717 ifa = ifa->ifa_next, ip_idx++) {
26718 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
26720 if (ip_idx < s_ip_idx)
26722 if (inet_fill_ifaddr(skb, ifa,
26723 diff -NurpP --minimal linux-3.0/net/ipv4/inet_connection_sock.c linux-3.0-vs2.3.1-pre7/net/ipv4/inet_connection_sock.c
26724 --- linux-3.0/net/ipv4/inet_connection_sock.c 2011-07-22 11:18:13.000000000 +0200
26725 +++ linux-3.0-vs2.3.1-pre7/net/ipv4/inet_connection_sock.c 2011-06-10 22:11:24.000000000 +0200
26726 @@ -52,6 +52,37 @@ void inet_get_local_port_range(int *low,
26728 EXPORT_SYMBOL(inet_get_local_port_range);
26730 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
26732 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1),
26733 + sk2_rcv_saddr = sk_rcv_saddr(sk2);
26735 + if (inet_v6_ipv6only(sk2))
26738 + if (sk1_rcv_saddr &&
26740 + sk1_rcv_saddr == sk2_rcv_saddr)
26743 + if (sk1_rcv_saddr &&
26744 + !sk2_rcv_saddr &&
26745 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
26748 + if (sk2_rcv_saddr &&
26749 + !sk1_rcv_saddr &&
26750 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
26753 + if (!sk1_rcv_saddr &&
26754 + !sk2_rcv_saddr &&
26755 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
26761 int inet_csk_bind_conflict(const struct sock *sk,
26762 const struct inet_bind_bucket *tb)
26764 @@ -74,9 +105,7 @@ int inet_csk_bind_conflict(const struct
26765 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
26766 if (!reuse || !sk2->sk_reuse ||
26767 sk2->sk_state == TCP_LISTEN) {
26768 - const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
26769 - if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
26770 - sk2_rcv_saddr == sk_rcv_saddr(sk))
26771 + if (ipv4_rcv_saddr_equal(sk, sk2))
26775 diff -NurpP --minimal linux-3.0/net/ipv4/inet_diag.c linux-3.0-vs2.3.1-pre7/net/ipv4/inet_diag.c
26776 --- linux-3.0/net/ipv4/inet_diag.c 2011-07-22 11:18:13.000000000 +0200
26777 +++ linux-3.0-vs2.3.1-pre7/net/ipv4/inet_diag.c 2011-06-22 12:39:16.000000000 +0200
26779 #include <linux/stddef.h>
26781 #include <linux/inet_diag.h>
26782 +#include <linux/vs_network.h>
26783 +#include <linux/vs_inet.h>
26785 static const struct inet_diag_handler **inet_diag_table;
26787 @@ -119,8 +121,10 @@ static int inet_csk_diag_fill(struct soc
26789 r->id.idiag_sport = inet->inet_sport;
26790 r->id.idiag_dport = inet->inet_dport;
26791 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
26792 - r->id.idiag_dst[0] = inet->inet_daddr;
26793 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
26794 + inet->inet_rcv_saddr);
26795 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
26796 + inet->inet_daddr);
26798 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
26799 if (r->idiag_family == AF_INET6) {
26800 @@ -205,8 +209,8 @@ static int inet_twsk_diag_fill(struct in
26801 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
26802 r->id.idiag_sport = tw->tw_sport;
26803 r->id.idiag_dport = tw->tw_dport;
26804 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
26805 - r->id.idiag_dst[0] = tw->tw_daddr;
26806 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
26807 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
26808 r->idiag_state = tw->tw_substate;
26809 r->idiag_timer = 3;
26810 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
26811 @@ -263,6 +267,7 @@ static int inet_diag_get_exact(struct sk
26814 if (req->idiag_family == AF_INET) {
26815 + /* TODO: lback */
26816 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
26817 req->id.idiag_dport, req->id.idiag_src[0],
26818 req->id.idiag_sport, req->id.idiag_if);
26819 @@ -505,6 +510,7 @@ static int inet_csk_diag_dump(struct soc
26823 + /* TODO: lback */
26824 entry.saddr = &inet->inet_rcv_saddr;
26825 entry.daddr = &inet->inet_daddr;
26827 @@ -543,6 +549,7 @@ static int inet_twsk_diag_dump(struct in
26831 + /* TODO: lback */
26832 entry.saddr = &tw->tw_rcv_saddr;
26833 entry.daddr = &tw->tw_daddr;
26835 @@ -589,8 +596,8 @@ static int inet_diag_fill_req(struct sk_
26837 r->id.idiag_sport = inet->inet_sport;
26838 r->id.idiag_dport = ireq->rmt_port;
26839 - r->id.idiag_src[0] = ireq->loc_addr;
26840 - r->id.idiag_dst[0] = ireq->rmt_addr;
26841 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
26842 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
26843 r->idiag_expires = jiffies_to_msecs(tmo);
26844 r->idiag_rqueue = 0;
26845 r->idiag_wqueue = 0;
26846 @@ -661,6 +668,7 @@ static int inet_diag_dump_reqs(struct sk
26850 + /* TODO: lback */
26852 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
26853 (entry.family == AF_INET6) ?
26854 @@ -731,6 +739,8 @@ static int inet_diag_dump(struct sk_buff
26855 sk_nulls_for_each(sk, node, &ilb->head) {
26856 struct inet_sock *inet = inet_sk(sk);
26858 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26863 @@ -797,6 +807,8 @@ skip_listen_ht:
26864 sk_nulls_for_each(sk, node, &head->chain) {
26865 struct inet_sock *inet = inet_sk(sk);
26867 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
26871 if (!(r->idiag_states & (1 << sk->sk_state)))
26872 @@ -821,6 +833,8 @@ next_normal:
26873 inet_twsk_for_each(tw, node,
26876 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
26880 if (r->id.idiag_sport != tw->tw_sport &&
26881 diff -NurpP --minimal linux-3.0/net/ipv4/inet_hashtables.c linux-3.0-vs2.3.1-pre7/net/ipv4/inet_hashtables.c
26882 --- linux-3.0/net/ipv4/inet_hashtables.c 2011-01-05 21:50:42.000000000 +0100
26883 +++ linux-3.0-vs2.3.1-pre7/net/ipv4/inet_hashtables.c 2011-06-10 22:11:24.000000000 +0200
26886 #include <net/inet_connection_sock.h>
26887 #include <net/inet_hashtables.h>
26888 +#include <net/route.h>
26889 #include <net/ip.h>
26892 @@ -155,6 +156,11 @@ static inline int compute_score(struct s
26893 if (rcv_saddr != daddr)
26897 + /* block non nx_info ips */
26898 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
26899 + daddr, NXA_MASK_BIND))
26902 if (sk->sk_bound_dev_if) {
26903 if (sk->sk_bound_dev_if != dif)
26904 @@ -172,7 +178,6 @@ static inline int compute_score(struct s
26905 * wildcarded during the search since they can never be otherwise.
26909 struct sock *__inet_lookup_listener(struct net *net,
26910 struct inet_hashinfo *hashinfo,
26911 const __be32 daddr, const unsigned short hnum,
26912 @@ -195,6 +200,7 @@ begin:
26918 * if the nulls value we got at the end of this lookup is
26919 * not the expected one, we must restart lookup.
26920 diff -NurpP --minimal linux-3.0/net/ipv4/netfilter/nf_nat_helper.c linux-3.0-vs2.3.1-pre7/net/ipv4/netfilter/nf_nat_helper.c
26921 --- linux-3.0/net/ipv4/netfilter/nf_nat_helper.c 2011-07-22 11:18:13.000000000 +0200
26922 +++ linux-3.0-vs2.3.1-pre7/net/ipv4/netfilter/nf_nat_helper.c 2011-06-15 02:40:14.000000000 +0200
26924 #include <net/route.h>
26926 #include <linux/netfilter_ipv4.h>
26927 +#include <net/route.h>
26928 #include <net/netfilter/nf_conntrack.h>
26929 #include <net/netfilter/nf_conntrack_helper.h>
26930 #include <net/netfilter/nf_conntrack_ecache.h>
26931 diff -NurpP --minimal linux-3.0/net/ipv4/netfilter.c linux-3.0-vs2.3.1-pre7/net/ipv4/netfilter.c
26932 --- linux-3.0/net/ipv4/netfilter.c 2011-07-22 11:18:13.000000000 +0200
26933 +++ linux-3.0-vs2.3.1-pre7/net/ipv4/netfilter.c 2011-07-19 00:44:39.000000000 +0200
26935 #include <linux/ip.h>
26936 #include <linux/skbuff.h>
26937 #include <linux/gfp.h>
26938 -#include <net/route.h>
26939 +// #include <net/route.h>
26940 #include <net/xfrm.h>
26941 #include <net/ip.h>
26942 #include <net/netfilter/nf_queue.h>
26943 diff -NurpP --minimal linux-3.0/net/ipv4/raw.c linux-3.0-vs2.3.1-pre7/net/ipv4/raw.c
26944 --- linux-3.0/net/ipv4/raw.c 2011-07-22 11:18:13.000000000 +0200
26945 +++ linux-3.0-vs2.3.1-pre7/net/ipv4/raw.c 2011-06-10 22:11:24.000000000 +0200
26946 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
26948 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
26949 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
26950 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
26951 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
26952 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
26953 goto found; /* gotcha */
26955 @@ -385,6 +385,12 @@ static int raw_send_hdrinc(struct sock *
26956 icmp_out_count(net, ((struct icmphdr *)
26957 skb_transport_header(skb))->type);
26960 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
26961 + sk->sk_nx_info &&
26962 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
26965 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
26966 rt->dst.dev, dst_output);
26968 @@ -647,17 +653,19 @@ static int raw_bind(struct sock *sk, str
26970 struct inet_sock *inet = inet_sk(sk);
26971 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
26972 + struct nx_v4_sock_addr nsa = { 0 };
26976 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
26978 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
26979 + v4_map_sock_addr(inet, addr, &nsa);
26980 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
26981 ret = -EADDRNOTAVAIL;
26982 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
26983 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
26984 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
26986 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
26987 + v4_set_sock_addr(inet, &nsa);
26988 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
26989 inet->inet_saddr = 0; /* Use device */
26991 @@ -709,7 +717,8 @@ static int raw_recvmsg(struct kiocb *ioc
26992 /* Copy the address. */
26994 sin->sin_family = AF_INET;
26995 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
26996 + sin->sin_addr.s_addr =
26997 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
26999 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
27001 @@ -905,7 +914,8 @@ static struct sock *raw_get_first(struct
27002 struct hlist_node *node;
27004 sk_for_each(sk, node, &state->h->ht[state->bucket])
27005 - if (sock_net(sk) == seq_file_net(seq))
27006 + if ((sock_net(sk) == seq_file_net(seq)) &&
27007 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27011 @@ -921,7 +931,8 @@ static struct sock *raw_get_next(struct
27015 - } while (sk && sock_net(sk) != seq_file_net(seq));
27016 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
27017 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27019 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
27020 sk = sk_head(&state->h->ht[state->bucket]);
27021 diff -NurpP --minimal linux-3.0/net/ipv4/tcp.c linux-3.0-vs2.3.1-pre7/net/ipv4/tcp.c
27022 --- linux-3.0/net/ipv4/tcp.c 2011-07-22 11:18:13.000000000 +0200
27023 +++ linux-3.0-vs2.3.1-pre7/net/ipv4/tcp.c 2011-07-19 00:44:39.000000000 +0200
27024 @@ -266,6 +266,7 @@
27025 #include <linux/crypto.h>
27026 #include <linux/time.h>
27027 #include <linux/slab.h>
27028 +#include <linux/in.h>
27030 #include <net/icmp.h>
27031 #include <net/tcp.h>
27032 diff -NurpP --minimal linux-3.0/net/ipv4/tcp_ipv4.c linux-3.0-vs2.3.1-pre7/net/ipv4/tcp_ipv4.c
27033 --- linux-3.0/net/ipv4/tcp_ipv4.c 2011-07-22 11:18:13.000000000 +0200
27034 +++ linux-3.0-vs2.3.1-pre7/net/ipv4/tcp_ipv4.c 2011-06-22 12:39:16.000000000 +0200
27035 @@ -2002,6 +2002,12 @@ static void *listening_get_next(struct s
27036 req = req->dl_next;
27039 + vxdprintk(VXD_CBIT(net, 6),
27040 + "sk,req: %p [#%d] (from %d)", req->sk,
27041 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
27043 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
27045 if (req->rsk_ops->family == st->family) {
27048 @@ -2026,6 +2032,10 @@ get_req:
27051 sk_nulls_for_each_from(sk, node) {
27052 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
27053 + sk, sk->sk_nid, nx_current_nid());
27054 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27056 if (!net_eq(sock_net(sk), net))
27058 if (sk->sk_family == st->family) {
27059 @@ -2102,6 +2112,11 @@ static void *established_get_first(struc
27061 spin_lock_bh(lock);
27062 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
27063 + vxdprintk(VXD_CBIT(net, 6),
27064 + "sk,egf: %p [#%d] (from %d)",
27065 + sk, sk->sk_nid, nx_current_nid());
27066 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27068 if (sk->sk_family != st->family ||
27069 !net_eq(sock_net(sk), net)) {
27071 @@ -2112,6 +2127,11 @@ static void *established_get_first(struc
27072 st->state = TCP_SEQ_STATE_TIME_WAIT;
27073 inet_twsk_for_each(tw, node,
27074 &tcp_hashinfo.ehash[st->bucket].twchain) {
27075 + vxdprintk(VXD_CBIT(net, 6),
27076 + "tw: %p [#%d] (from %d)",
27077 + tw, tw->tw_nid, nx_current_nid());
27078 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
27080 if (tw->tw_family != st->family ||
27081 !net_eq(twsk_net(tw), net)) {
27083 @@ -2141,7 +2161,9 @@ static void *established_get_next(struct
27087 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
27088 + while (tw && (tw->tw_family != st->family ||
27089 + !net_eq(twsk_net(tw), net) ||
27090 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
27094 @@ -2165,6 +2187,11 @@ get_tw:
27095 sk = sk_nulls_next(sk);
27097 sk_nulls_for_each_from(sk, node) {
27098 + vxdprintk(VXD_CBIT(net, 6),
27099 + "sk,egn: %p [#%d] (from %d)",
27100 + sk, sk->sk_nid, nx_current_nid());
27101 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27103 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
27106 @@ -2374,9 +2401,9 @@ static void get_openreq4(struct sock *sk
27107 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
27108 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %pK%n",
27111 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
27112 ntohs(inet_sk(sk)->inet_sport),
27114 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
27115 ntohs(ireq->rmt_port),
27117 0, 0, /* could print option size, but that is af dependent. */
27118 diff -NurpP --minimal linux-3.0/net/ipv4/tcp_minisocks.c linux-3.0-vs2.3.1-pre7/net/ipv4/tcp_minisocks.c
27119 --- linux-3.0/net/ipv4/tcp_minisocks.c 2011-03-15 18:07:45.000000000 +0100
27120 +++ linux-3.0-vs2.3.1-pre7/net/ipv4/tcp_minisocks.c 2011-06-10 22:11:24.000000000 +0200
27122 #include <linux/slab.h>
27123 #include <linux/sysctl.h>
27124 #include <linux/workqueue.h>
27125 +#include <linux/vs_limit.h>
27126 +#include <linux/vs_socket.h>
27127 +#include <linux/vs_context.h>
27128 #include <net/tcp.h>
27129 #include <net/inet_common.h>
27130 #include <net/xfrm.h>
27131 @@ -335,6 +338,11 @@ void tcp_time_wait(struct sock *sk, int
27132 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
27133 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
27135 + tw->tw_xid = sk->sk_xid;
27136 + tw->tw_vx_info = NULL;
27137 + tw->tw_nid = sk->sk_nid;
27138 + tw->tw_nx_info = NULL;
27140 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
27141 if (tw->tw_family == PF_INET6) {
27142 struct ipv6_pinfo *np = inet6_sk(sk);
27143 diff -NurpP --minimal linux-3.0/net/ipv4/udp.c linux-3.0-vs2.3.1-pre7/net/ipv4/udp.c
27144 --- linux-3.0/net/ipv4/udp.c 2011-07-22 11:18:13.000000000 +0200
27145 +++ linux-3.0-vs2.3.1-pre7/net/ipv4/udp.c 2011-07-19 00:44:39.000000000 +0200
27146 @@ -296,14 +296,7 @@ fail:
27148 EXPORT_SYMBOL(udp_lib_get_port);
27150 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27152 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
27154 - return (!ipv6_only_sock(sk2) &&
27155 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
27156 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
27158 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
27160 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
27162 @@ -338,6 +331,11 @@ static inline int compute_score(struct s
27163 if (inet->inet_rcv_saddr != daddr)
27167 + /* block non nx_info ips */
27168 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
27169 + daddr, NXA_MASK_BIND))
27172 if (inet->inet_daddr) {
27173 if (inet->inet_daddr != saddr)
27174 @@ -441,6 +439,7 @@ exact_match:
27179 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
27180 * harder than this. -DaveM
27182 @@ -486,6 +485,11 @@ begin:
27183 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
27184 score = compute_score(sk, net, saddr, hnum, sport,
27185 daddr, dport, dif);
27186 + /* FIXME: disabled?
27187 + if (score == 9) {
27191 if (score > badness) {
27194 @@ -499,6 +503,7 @@ begin:
27195 if (get_nulls_value(node) != slot)
27200 if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
27202 @@ -508,6 +513,7 @@ begin:
27210 @@ -550,8 +556,7 @@ static inline struct sock *udp_v4_mcast_
27211 udp_sk(s)->udp_port_hash != hnum ||
27212 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
27213 (inet->inet_dport != rmt_port && inet->inet_dport) ||
27214 - (inet->inet_rcv_saddr &&
27215 - inet->inet_rcv_saddr != loc_addr) ||
27216 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
27217 ipv6_only_sock(s) ||
27218 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
27220 @@ -1226,7 +1231,8 @@ try_again:
27222 sin->sin_family = AF_INET;
27223 sin->sin_port = udp_hdr(skb)->source;
27224 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
27225 + sin->sin_addr.s_addr = nx_map_sock_lback(
27226 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
27227 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
27229 if (inet->cmsg_flags)
27230 @@ -1970,6 +1976,8 @@ static struct sock *udp_get_first(struct
27231 sk_nulls_for_each(sk, node, &hslot->head) {
27232 if (!net_eq(sock_net(sk), net))
27234 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
27236 if (sk->sk_family == state->family)
27239 @@ -1987,7 +1995,9 @@ static struct sock *udp_get_next(struct
27242 sk = sk_nulls_next(sk);
27243 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
27244 + } while (sk && (!net_eq(sock_net(sk), net) ||
27245 + sk->sk_family != state->family ||
27246 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
27249 if (state->bucket <= state->udp_table->mask)
27250 diff -NurpP --minimal linux-3.0/net/ipv6/Kconfig linux-3.0-vs2.3.1-pre7/net/ipv6/Kconfig
27251 --- linux-3.0/net/ipv6/Kconfig 2010-08-02 16:52:59.000000000 +0200
27252 +++ linux-3.0-vs2.3.1-pre7/net/ipv6/Kconfig 2011-06-10 22:11:24.000000000 +0200
27255 # IPv6 as module will cause a CRASH if you try to unload it
27257 - tristate "The IPv6 protocol"
27259 + bool "The IPv6 protocol"
27262 This is complemental support for the IP version 6.
27263 You will still be able to do traditional IPv4 networking as well.
27264 diff -NurpP --minimal linux-3.0/net/ipv6/addrconf.c linux-3.0-vs2.3.1-pre7/net/ipv6/addrconf.c
27265 --- linux-3.0/net/ipv6/addrconf.c 2011-07-22 11:18:13.000000000 +0200
27266 +++ linux-3.0-vs2.3.1-pre7/net/ipv6/addrconf.c 2011-06-10 22:11:24.000000000 +0200
27269 #include <linux/proc_fs.h>
27270 #include <linux/seq_file.h>
27271 +#include <linux/vs_network.h>
27272 +#include <linux/vs_inet6.h>
27274 /* Set to 3 to get tracing... */
27275 #define ACONF_DEBUG 2
27276 @@ -1108,7 +1110,7 @@ out:
27278 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
27279 const struct in6_addr *daddr, unsigned int prefs,
27280 - struct in6_addr *saddr)
27281 + struct in6_addr *saddr, struct nx_info *nxi)
27283 struct ipv6_saddr_score scores[2],
27284 *score = &scores[0], *hiscore = &scores[1];
27285 @@ -1180,6 +1182,8 @@ int ipv6_dev_get_saddr(struct net *net,
27289 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
27293 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
27294 @@ -3048,7 +3052,10 @@ static void if6_seq_stop(struct seq_file
27295 static int if6_seq_show(struct seq_file *seq, void *v)
27297 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
27298 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
27300 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
27301 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
27302 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
27304 ifp->idev->dev->ifindex,
27306 @@ -3554,6 +3561,11 @@ static int in6_dump_addrs(struct inet6_d
27307 struct ifacaddr6 *ifaca;
27309 int ip_idx = *p_ip_idx;
27310 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27312 + /* disable ipv6 on non v6 guests */
27313 + if (nxi && !nx_info_has_v6(nxi))
27316 read_lock_bh(&idev->lock);
27318 @@ -3564,6 +3576,8 @@ static int in6_dump_addrs(struct inet6_d
27319 list_for_each_entry(ifa, &idev->addr_list, if_list) {
27320 if (++ip_idx < s_ip_idx)
27322 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
27324 err = inet6_fill_ifaddr(skb, ifa,
27325 NETLINK_CB(cb->skb).pid,
27326 cb->nlh->nlmsg_seq,
27327 @@ -3580,6 +3594,8 @@ static int in6_dump_addrs(struct inet6_d
27328 ifmca = ifmca->next, ip_idx++) {
27329 if (ip_idx < s_ip_idx)
27331 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
27333 err = inet6_fill_ifmcaddr(skb, ifmca,
27334 NETLINK_CB(cb->skb).pid,
27335 cb->nlh->nlmsg_seq,
27336 @@ -3595,6 +3611,8 @@ static int in6_dump_addrs(struct inet6_d
27337 ifaca = ifaca->aca_next, ip_idx++) {
27338 if (ip_idx < s_ip_idx)
27340 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
27342 err = inet6_fill_ifacaddr(skb, ifaca,
27343 NETLINK_CB(cb->skb).pid,
27344 cb->nlh->nlmsg_seq,
27345 @@ -3980,6 +3998,11 @@ static int inet6_dump_ifinfo(struct sk_b
27346 struct inet6_dev *idev;
27347 struct hlist_head *head;
27348 struct hlist_node *node;
27349 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
27351 + /* FIXME: maybe disable ipv6 on non v6 guests?
27352 + if (skb->sk && skb->sk->sk_vx_info)
27353 + return skb->len; */
27356 s_idx = cb->args[1];
27357 @@ -3991,6 +4014,8 @@ static int inet6_dump_ifinfo(struct sk_b
27358 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
27361 + if (!v6_dev_in_nx_info(dev, nxi))
27363 idev = __in6_dev_get(dev);
27366 diff -NurpP --minimal linux-3.0/net/ipv6/af_inet6.c linux-3.0-vs2.3.1-pre7/net/ipv6/af_inet6.c
27367 --- linux-3.0/net/ipv6/af_inet6.c 2011-07-22 11:18:13.000000000 +0200
27368 +++ linux-3.0-vs2.3.1-pre7/net/ipv6/af_inet6.c 2011-07-19 00:44:39.000000000 +0200
27370 #include <linux/netdevice.h>
27371 #include <linux/icmpv6.h>
27372 #include <linux/netfilter_ipv6.h>
27373 +#include <linux/vs_inet.h>
27374 +#include <linux/vs_inet6.h>
27376 #include <net/ip.h>
27377 #include <net/ipv6.h>
27378 @@ -160,9 +162,12 @@ lookup_protocol:
27382 + if ((protocol == IPPROTO_ICMPV6) &&
27383 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
27385 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
27386 goto out_rcu_unlock;
27389 sock->ops = answer->ops;
27390 answer_prot = answer->prot;
27391 answer_no_check = answer->no_check;
27392 @@ -261,6 +266,7 @@ int inet6_bind(struct socket *sock, stru
27393 struct inet_sock *inet = inet_sk(sk);
27394 struct ipv6_pinfo *np = inet6_sk(sk);
27395 struct net *net = sock_net(sk);
27396 + struct nx_v6_sock_addr nsa;
27398 unsigned short snum;
27400 @@ -276,6 +282,10 @@ int inet6_bind(struct socket *sock, stru
27401 if (addr->sin6_family != AF_INET6)
27402 return -EAFNOSUPPORT;
27404 + err = v6_map_sock_addr(inet, addr, &nsa);
27408 addr_type = ipv6_addr_type(&addr->sin6_addr);
27409 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
27411 @@ -307,6 +317,7 @@ int inet6_bind(struct socket *sock, stru
27412 /* Reproduce AF_INET checks to make the bindings consistent */
27413 v4addr = addr->sin6_addr.s6_addr32[3];
27414 chk_addr_ret = inet_addr_type(net, v4addr);
27416 if (!sysctl_ip_nonlocal_bind &&
27417 !(inet->freebind || inet->transparent) &&
27418 v4addr != htonl(INADDR_ANY) &&
27419 @@ -316,6 +327,10 @@ int inet6_bind(struct socket *sock, stru
27420 err = -EADDRNOTAVAIL;
27423 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
27424 + err = -EADDRNOTAVAIL;
27428 if (addr_type != IPV6_ADDR_ANY) {
27429 struct net_device *dev = NULL;
27430 @@ -342,6 +357,11 @@ int inet6_bind(struct socket *sock, stru
27434 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27435 + err = -EADDRNOTAVAIL;
27439 /* ipv4 addr of the socket is invalid. Only the
27440 * unspecified and mapped address have a v4 equivalent.
27442 @@ -358,6 +378,9 @@ int inet6_bind(struct socket *sock, stru
27446 + /* what's that for? */
27447 + v6_set_sock_addr(inet, &nsa);
27449 inet->inet_rcv_saddr = v4addr;
27450 inet->inet_saddr = v4addr;
27452 @@ -459,9 +482,11 @@ int inet6_getname(struct socket *sock, s
27454 sin->sin6_port = inet->inet_dport;
27455 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
27456 + /* FIXME: remap lback? */
27458 sin->sin6_flowinfo = np->flow_label;
27460 + /* FIXME: remap lback? */
27461 if (ipv6_addr_any(&np->rcv_saddr))
27462 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
27464 diff -NurpP --minimal linux-3.0/net/ipv6/fib6_rules.c linux-3.0-vs2.3.1-pre7/net/ipv6/fib6_rules.c
27465 --- linux-3.0/net/ipv6/fib6_rules.c 2011-05-22 16:18:00.000000000 +0200
27466 +++ linux-3.0-vs2.3.1-pre7/net/ipv6/fib6_rules.c 2011-06-10 22:11:24.000000000 +0200
27467 @@ -90,7 +90,7 @@ static int fib6_rule_action(struct fib_r
27468 ip6_dst_idev(&rt->dst)->dev,
27470 rt6_flags2srcprefs(flags),
27474 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
27476 diff -NurpP --minimal linux-3.0/net/ipv6/inet6_hashtables.c linux-3.0-vs2.3.1-pre7/net/ipv6/inet6_hashtables.c
27477 --- linux-3.0/net/ipv6/inet6_hashtables.c 2011-05-22 16:18:00.000000000 +0200
27478 +++ linux-3.0-vs2.3.1-pre7/net/ipv6/inet6_hashtables.c 2011-06-10 22:11:24.000000000 +0200
27481 #include <linux/module.h>
27482 #include <linux/random.h>
27483 +#include <linux/vs_inet6.h>
27485 #include <net/inet_connection_sock.h>
27486 #include <net/inet_hashtables.h>
27487 @@ -82,7 +83,6 @@ struct sock *__inet6_lookup_established(
27488 unsigned int slot = hash & hashinfo->ehash_mask;
27489 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
27494 sk_nulls_for_each_rcu(sk, node, &head->chain) {
27495 @@ -94,7 +94,7 @@ begin:
27503 if (get_nulls_value(node) != slot)
27504 @@ -140,6 +140,9 @@ static inline int compute_score(struct s
27505 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
27509 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
27512 if (sk->sk_bound_dev_if) {
27513 if (sk->sk_bound_dev_if != dif)
27514 diff -NurpP --minimal linux-3.0/net/ipv6/ip6_output.c linux-3.0-vs2.3.1-pre7/net/ipv6/ip6_output.c
27515 --- linux-3.0/net/ipv6/ip6_output.c 2011-07-22 11:18:13.000000000 +0200
27516 +++ linux-3.0-vs2.3.1-pre7/net/ipv6/ip6_output.c 2011-06-16 14:16:51.000000000 +0200
27517 @@ -933,7 +933,8 @@ static int ip6_dst_lookup_tail(struct so
27518 struct rt6_info *rt = (struct rt6_info *) *dst;
27519 err = ip6_route_get_saddr(net, rt, &fl6->daddr,
27520 sk ? inet6_sk(sk)->srcprefs : 0,
27523 + sk ? sk->sk_nx_info : NULL);
27525 goto out_err_release;
27527 diff -NurpP --minimal linux-3.0/net/ipv6/ndisc.c linux-3.0-vs2.3.1-pre7/net/ipv6/ndisc.c
27528 --- linux-3.0/net/ipv6/ndisc.c 2011-07-22 11:18:13.000000000 +0200
27529 +++ linux-3.0-vs2.3.1-pre7/net/ipv6/ndisc.c 2011-06-10 22:11:24.000000000 +0200
27530 @@ -597,7 +597,7 @@ static void ndisc_send_na(struct net_dev
27532 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
27533 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
27537 src_addr = &tmpaddr;
27539 diff -NurpP --minimal linux-3.0/net/ipv6/raw.c linux-3.0-vs2.3.1-pre7/net/ipv6/raw.c
27540 --- linux-3.0/net/ipv6/raw.c 2011-07-22 11:18:13.000000000 +0200
27541 +++ linux-3.0-vs2.3.1-pre7/net/ipv6/raw.c 2011-06-10 22:11:24.000000000 +0200
27543 #include <linux/icmpv6.h>
27544 #include <linux/netfilter.h>
27545 #include <linux/netfilter_ipv6.h>
27546 +#include <linux/vs_inet6.h>
27547 #include <linux/skbuff.h>
27548 #include <linux/compat.h>
27549 #include <asm/uaccess.h>
27550 @@ -284,6 +285,13 @@ static int rawv6_bind(struct sock *sk, s
27554 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
27555 + err = -EADDRNOTAVAIL;
27561 /* ipv4 addr of the socket is invalid. Only the
27562 * unspecified and mapped address have a v4 equivalent.
27564 diff -NurpP --minimal linux-3.0/net/ipv6/route.c linux-3.0-vs2.3.1-pre7/net/ipv6/route.c
27565 --- linux-3.0/net/ipv6/route.c 2011-07-22 11:18:13.000000000 +0200
27566 +++ linux-3.0-vs2.3.1-pre7/net/ipv6/route.c 2011-07-19 00:44:39.000000000 +0200
27568 #include <net/xfrm.h>
27569 #include <net/netevent.h>
27570 #include <net/netlink.h>
27571 +#include <linux/vs_inet6.h>
27573 #include <asm/uaccess.h>
27575 @@ -2050,15 +2051,17 @@ int ip6_route_get_saddr(struct net *net,
27576 struct rt6_info *rt,
27577 const struct in6_addr *daddr,
27578 unsigned int prefs,
27579 - struct in6_addr *saddr)
27580 + struct in6_addr *saddr,
27581 + struct nx_info *nxi)
27583 struct inet6_dev *idev = ip6_dst_idev((struct dst_entry*)rt);
27585 - if (rt->rt6i_prefsrc.plen)
27586 + if (rt->rt6i_prefsrc.plen && (!nxi ||
27587 + v6_addr_in_nx_info(nxi, &rt->rt6i_prefsrc.addr, NXA_TYPE_ADDR)))
27588 ipv6_addr_copy(saddr, &rt->rt6i_prefsrc.addr);
27590 err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
27591 - daddr, prefs, saddr);
27592 + daddr, prefs, saddr, nxi);
27596 @@ -2387,7 +2390,8 @@ static int rt6_fill_node(struct net *net
27597 NLA_PUT_U32(skb, RTA_IIF, iif);
27599 struct in6_addr saddr_buf;
27600 - if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf) == 0)
27601 + if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf,
27602 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
27603 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
27606 diff -NurpP --minimal linux-3.0/net/ipv6/tcp_ipv6.c linux-3.0-vs2.3.1-pre7/net/ipv6/tcp_ipv6.c
27607 --- linux-3.0/net/ipv6/tcp_ipv6.c 2011-07-22 11:18:13.000000000 +0200
27608 +++ linux-3.0-vs2.3.1-pre7/net/ipv6/tcp_ipv6.c 2011-06-22 12:39:16.000000000 +0200
27611 #include <linux/crypto.h>
27612 #include <linux/scatterlist.h>
27613 +#include <linux/vs_inet6.h>
27615 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
27616 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
27617 @@ -161,8 +162,15 @@ static int tcp_v6_connect(struct sock *s
27618 * connect() to INADDR_ANY means loopback (BSD'ism).
27621 - if(ipv6_addr_any(&usin->sin6_addr))
27622 - usin->sin6_addr.s6_addr[15] = 0x1;
27623 + if(ipv6_addr_any(&usin->sin6_addr)) {
27624 + struct nx_info *nxi = sk->sk_nx_info;
27626 + if (nxi && nx_info_has_v6(nxi))
27627 + /* FIXME: remap lback? */
27628 + usin->sin6_addr = nxi->v6.ip;
27630 + usin->sin6_addr.s6_addr[15] = 0x1;
27633 addr_type = ipv6_addr_type(&usin->sin6_addr);
27635 diff -NurpP --minimal linux-3.0/net/ipv6/udp.c linux-3.0-vs2.3.1-pre7/net/ipv6/udp.c
27636 --- linux-3.0/net/ipv6/udp.c 2011-07-22 11:18:13.000000000 +0200
27637 +++ linux-3.0-vs2.3.1-pre7/net/ipv6/udp.c 2011-07-19 00:44:39.000000000 +0200
27638 @@ -45,41 +45,67 @@
27639 #include <net/tcp_states.h>
27640 #include <net/ip6_checksum.h>
27641 #include <net/xfrm.h>
27642 +#include <linux/vs_inet6.h>
27644 #include <linux/proc_fs.h>
27645 #include <linux/seq_file.h>
27646 #include "udp_impl.h"
27648 -int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
27649 +int ipv6_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
27651 - const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
27652 + const struct in6_addr *sk1_rcv_saddr6 = &inet6_sk(sk1)->rcv_saddr;
27653 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
27654 - __be32 sk1_rcv_saddr = sk_rcv_saddr(sk);
27655 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1);
27656 __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
27657 - int sk_ipv6only = ipv6_only_sock(sk);
27658 + int sk1_ipv6only = ipv6_only_sock(sk1);
27659 int sk2_ipv6only = inet_v6_ipv6only(sk2);
27660 - int addr_type = ipv6_addr_type(sk_rcv_saddr6);
27661 + int addr_type = ipv6_addr_type(sk1_rcv_saddr6);
27662 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
27664 /* if both are mapped, treat as IPv4 */
27665 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
27666 - return (!sk2_ipv6only &&
27667 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
27668 + if (!sk2_ipv6only &&
27669 (!sk1_rcv_saddr || !sk2_rcv_saddr ||
27670 - sk1_rcv_saddr == sk2_rcv_saddr));
27671 + sk1_rcv_saddr == sk2_rcv_saddr))
27677 if (addr_type2 == IPV6_ADDR_ANY &&
27678 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
27682 if (addr_type == IPV6_ADDR_ANY &&
27683 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
27685 + !(sk1_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
27688 if (sk2_rcv_saddr6 &&
27689 - ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
27691 + ipv6_addr_equal(sk1_rcv_saddr6, sk2_rcv_saddr6))
27697 + if (!sk1_rcv_saddr && !sk2_rcv_saddr)
27698 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
27699 + if (!sk2_rcv_saddr)
27700 + return v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, -1);
27701 + if (!sk1_rcv_saddr)
27702 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, -1);
27705 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
27706 + return nx_v6_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
27707 + else if (addr_type2 == IPV6_ADDR_ANY)
27708 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr6, -1);
27709 + else if (addr_type == IPV6_ADDR_ANY) {
27710 + if (addr_type2 == IPV6_ADDR_MAPPED)
27711 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
27713 + return v6_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr6, -1);
27718 static unsigned int udp6_portaddr_hash(struct net *net,
27719 @@ -143,6 +169,10 @@ static inline int compute_score(struct s
27720 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
27724 + /* block non nx_info ips */
27725 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
27728 if (!ipv6_addr_any(&np->daddr)) {
27729 if (!ipv6_addr_equal(&np->daddr, saddr))
27730 diff -NurpP --minimal linux-3.0/net/ipv6/xfrm6_policy.c linux-3.0-vs2.3.1-pre7/net/ipv6/xfrm6_policy.c
27731 --- linux-3.0/net/ipv6/xfrm6_policy.c 2011-07-22 11:18:13.000000000 +0200
27732 +++ linux-3.0-vs2.3.1-pre7/net/ipv6/xfrm6_policy.c 2011-06-10 22:11:24.000000000 +0200
27733 @@ -63,7 +63,7 @@ static int xfrm6_get_saddr(struct net *n
27734 dev = ip6_dst_idev(dst)->dev;
27735 ipv6_dev_get_saddr(dev_net(dev), dev,
27736 (struct in6_addr *)&daddr->a6, 0,
27737 - (struct in6_addr *)&saddr->a6);
27738 + (struct in6_addr *)&saddr->a6, NULL);
27742 diff -NurpP --minimal linux-3.0/net/netfilter/ipvs/ip_vs_xmit.c linux-3.0-vs2.3.1-pre7/net/netfilter/ipvs/ip_vs_xmit.c
27743 --- linux-3.0/net/netfilter/ipvs/ip_vs_xmit.c 2011-07-22 11:18:13.000000000 +0200
27744 +++ linux-3.0-vs2.3.1-pre7/net/netfilter/ipvs/ip_vs_xmit.c 2011-07-22 15:27:52.000000000 +0200
27745 @@ -226,7 +226,7 @@ __ip_vs_route_output_v6(struct net *net,
27747 if (ipv6_addr_any(&fl6.saddr) &&
27748 ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
27749 - &fl6.daddr, 0, &fl6.saddr) < 0)
27750 + &fl6.daddr, 0, &fl6.saddr, NULL) < 0)
27753 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
27754 diff -NurpP --minimal linux-3.0/net/netlink/af_netlink.c linux-3.0-vs2.3.1-pre7/net/netlink/af_netlink.c
27755 --- linux-3.0/net/netlink/af_netlink.c 2011-07-22 11:18:13.000000000 +0200
27756 +++ linux-3.0-vs2.3.1-pre7/net/netlink/af_netlink.c 2011-06-10 22:11:24.000000000 +0200
27758 #include <linux/types.h>
27759 #include <linux/audit.h>
27760 #include <linux/mutex.h>
27761 +#include <linux/vs_context.h>
27762 +#include <linux/vs_network.h>
27763 +#include <linux/vs_limit.h>
27765 #include <net/net_namespace.h>
27766 #include <net/sock.h>
27767 @@ -1907,6 +1910,8 @@ static struct sock *netlink_seq_socket_i
27768 sk_for_each(s, node, &hash->table[j]) {
27769 if (sock_net(s) != seq_file_net(seq))
27771 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
27775 iter->hash_idx = j;
27776 @@ -1941,7 +1946,8 @@ static void *netlink_seq_next(struct seq
27780 - } while (s && sock_net(s) != seq_file_net(seq));
27781 + } while (s && (sock_net(s) != seq_file_net(seq) ||
27782 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
27786 @@ -1953,7 +1959,8 @@ static void *netlink_seq_next(struct seq
27788 for (; j <= hash->mask; j++) {
27789 s = sk_head(&hash->table[j]);
27790 - while (s && sock_net(s) != seq_file_net(seq))
27791 + while (s && (sock_net(s) != seq_file_net(seq) ||
27792 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
27796 diff -NurpP --minimal linux-3.0/net/socket.c linux-3.0-vs2.3.1-pre7/net/socket.c
27797 --- linux-3.0/net/socket.c 2011-07-22 11:18:13.000000000 +0200
27798 +++ linux-3.0-vs2.3.1-pre7/net/socket.c 2011-06-16 14:16:51.000000000 +0200
27801 #include <net/sock.h>
27802 #include <linux/netfilter.h>
27803 +#include <linux/vs_base.h>
27804 +#include <linux/vs_socket.h>
27805 +#include <linux/vs_inet.h>
27806 +#include <linux/vs_inet6.h>
27808 #include <linux/if_tun.h>
27809 #include <linux/ipv6_route.h>
27810 @@ -546,6 +550,7 @@ static inline int __sock_sendmsg_nosec(s
27811 struct msghdr *msg, size_t size)
27813 struct sock_iocb *si = kiocb_to_siocb(iocb);
27816 sock_update_classid(sock->sk);
27818 @@ -554,7 +559,22 @@ static inline int __sock_sendmsg_nosec(s
27822 - return sock->ops->sendmsg(iocb, sock, msg, size);
27823 + len = sock->ops->sendmsg(iocb, sock, msg, size);
27826 + vx_sock_send(sock->sk, size);
27828 + vx_sock_fail(sock->sk, size);
27830 + vxdprintk(VXD_CBIT(net, 7),
27831 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
27833 + (sock->sk)?sock->sk->sk_nx_info:0,
27834 + (sock->sk)?sock->sk->sk_vx_info:0,
27835 + (sock->sk)?sock->sk->sk_xid:0,
27836 + (sock->sk)?sock->sk->sk_nid:0,
27837 + (unsigned int)size, len);
27841 static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock,
27842 @@ -694,6 +714,7 @@ static inline int __sock_recvmsg_nosec(s
27843 struct msghdr *msg, size_t size, int flags)
27845 struct sock_iocb *si = kiocb_to_siocb(iocb);
27848 sock_update_classid(sock->sk);
27850 @@ -703,7 +724,18 @@ static inline int __sock_recvmsg_nosec(s
27854 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
27855 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
27856 + if ((len >= 0) && sock->sk)
27857 + vx_sock_recv(sock->sk, len);
27858 + vxdprintk(VXD_CBIT(net, 7),
27859 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
27861 + (sock->sk)?sock->sk->sk_nx_info:0,
27862 + (sock->sk)?sock->sk->sk_vx_info:0,
27863 + (sock->sk)?sock->sk->sk_xid:0,
27864 + (sock->sk)?sock->sk->sk_nid:0,
27865 + (unsigned int)size, len);
27869 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
27870 @@ -1188,6 +1220,13 @@ int __sock_create(struct net *net, int f
27871 if (type < 0 || type >= SOCK_MAX)
27874 + if (!nx_check(0, VS_ADMIN)) {
27875 + if (family == PF_INET && !current_nx_info_has_v4())
27876 + return -EAFNOSUPPORT;
27877 + if (family == PF_INET6 && !current_nx_info_has_v6())
27878 + return -EAFNOSUPPORT;
27883 This uglymoron is moved from INET layer to here to avoid
27884 @@ -1323,6 +1362,7 @@ SYSCALL_DEFINE3(socket, int, family, int
27888 + set_bit(SOCK_USER_SOCKET, &sock->flags);
27889 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
27892 @@ -1364,10 +1404,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
27893 err = sock_create(family, type, protocol, &sock1);
27896 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
27898 err = sock_create(family, type, protocol, &sock2);
27900 goto out_release_1;
27901 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
27903 err = sock1->ops->socketpair(sock1, sock2);
27905 diff -NurpP --minimal linux-3.0/net/sunrpc/auth.c linux-3.0-vs2.3.1-pre7/net/sunrpc/auth.c
27906 --- linux-3.0/net/sunrpc/auth.c 2011-07-22 11:18:13.000000000 +0200
27907 +++ linux-3.0-vs2.3.1-pre7/net/sunrpc/auth.c 2011-06-10 22:11:24.000000000 +0200
27909 #include <linux/hash.h>
27910 #include <linux/sunrpc/clnt.h>
27911 #include <linux/spinlock.h>
27912 +#include <linux/vs_tag.h>
27915 # define RPCDBG_FACILITY RPCDBG_AUTH
27916 @@ -427,6 +428,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
27917 memset(&acred, 0, sizeof(acred));
27918 acred.uid = cred->fsuid;
27919 acred.gid = cred->fsgid;
27920 + acred.tag = dx_current_tag();
27921 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
27923 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
27924 @@ -467,6 +469,7 @@ rpcauth_bind_root_cred(struct rpc_task *
27925 struct auth_cred acred = {
27928 + .tag = dx_current_tag(),
27931 dprintk("RPC: %5u looking up %s cred\n",
27932 diff -NurpP --minimal linux-3.0/net/sunrpc/auth_unix.c linux-3.0-vs2.3.1-pre7/net/sunrpc/auth_unix.c
27933 --- linux-3.0/net/sunrpc/auth_unix.c 2010-10-21 13:08:01.000000000 +0200
27934 +++ linux-3.0-vs2.3.1-pre7/net/sunrpc/auth_unix.c 2011-06-10 22:11:24.000000000 +0200
27935 @@ -12,12 +12,14 @@
27936 #include <linux/module.h>
27937 #include <linux/sunrpc/clnt.h>
27938 #include <linux/sunrpc/auth.h>
27939 +#include <linux/vs_tag.h>
27941 #define NFS_NGROUPS 16
27944 struct rpc_cred uc_base;
27947 gid_t uc_gids[NFS_NGROUPS];
27949 #define uc_uid uc_base.cr_uid
27950 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
27951 groups = NFS_NGROUPS;
27953 cred->uc_gid = acred->gid;
27954 + cred->uc_tag = acred->tag;
27955 for (i = 0; i < groups; i++)
27956 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
27957 if (i < NFS_NGROUPS)
27958 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
27962 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
27963 + if (cred->uc_uid != acred->uid ||
27964 + cred->uc_gid != acred->gid ||
27965 + cred->uc_tag != acred->tag)
27968 if (acred->group_info != NULL)
27969 @@ -142,7 +147,7 @@ unx_marshal(struct rpc_task *task, __be3
27970 struct rpc_clnt *clnt = task->tk_client;
27971 struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base);
27972 __be32 *base, *hold;
27976 *p++ = htonl(RPC_AUTH_UNIX);
27978 @@ -152,9 +157,12 @@ unx_marshal(struct rpc_task *task, __be3
27979 * Copy the UTS nodename captured when the client was created.
27981 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
27982 + tag = task->tk_client->cl_tag;
27984 - *p++ = htonl((u32) cred->uc_uid);
27985 - *p++ = htonl((u32) cred->uc_gid);
27986 + *p++ = htonl((u32) TAGINO_UID(tag,
27987 + cred->uc_uid, cred->uc_tag));
27988 + *p++ = htonl((u32) TAGINO_GID(tag,
27989 + cred->uc_gid, cred->uc_tag));
27991 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
27992 *p++ = htonl((u32) cred->uc_gids[i]);
27993 diff -NurpP --minimal linux-3.0/net/sunrpc/clnt.c linux-3.0-vs2.3.1-pre7/net/sunrpc/clnt.c
27994 --- linux-3.0/net/sunrpc/clnt.c 2011-07-22 11:18:13.000000000 +0200
27995 +++ linux-3.0-vs2.3.1-pre7/net/sunrpc/clnt.c 2011-07-01 11:35:35.000000000 +0200
27997 #include <linux/in.h>
27998 #include <linux/in6.h>
27999 #include <linux/un.h>
28000 +#include <linux/vs_cvirt.h>
28002 #include <linux/sunrpc/clnt.h>
28003 #include <linux/sunrpc/rpc_pipe_fs.h>
28004 @@ -362,6 +363,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
28005 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
28006 clnt->cl_chatty = 1;
28008 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
28009 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
28010 + clnt->cl_tag = 1; */
28013 EXPORT_SYMBOL_GPL(rpc_create);
28014 diff -NurpP --minimal linux-3.0/net/unix/af_unix.c linux-3.0-vs2.3.1-pre7/net/unix/af_unix.c
28015 --- linux-3.0/net/unix/af_unix.c 2011-07-22 11:18:13.000000000 +0200
28016 +++ linux-3.0-vs2.3.1-pre7/net/unix/af_unix.c 2011-06-10 22:11:24.000000000 +0200
28017 @@ -114,6 +114,8 @@
28018 #include <linux/mount.h>
28019 #include <net/checksum.h>
28020 #include <linux/security.h>
28021 +#include <linux/vs_context.h>
28022 +#include <linux/vs_limit.h>
28024 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
28025 static DEFINE_SPINLOCK(unix_table_lock);
28026 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
28027 if (!net_eq(sock_net(s), net))
28030 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28032 if (u->addr->len == len &&
28033 !memcmp(u->addr->name, sunname, len))
28035 @@ -2208,6 +2212,8 @@ static struct sock *unix_seq_idx(struct
28036 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
28037 if (sock_net(s) != seq_file_net(seq))
28039 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
28044 @@ -2232,7 +2238,8 @@ static void *unix_seq_next(struct seq_fi
28045 sk = first_unix_socket(&iter->i);
28047 sk = next_unix_socket(&iter->i, sk);
28048 - while (sk && (sock_net(sk) != seq_file_net(seq)))
28049 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
28050 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
28051 sk = next_unix_socket(&iter->i, sk);
28054 diff -NurpP --minimal linux-3.0/scripts/checksyscalls.sh linux-3.0-vs2.3.1-pre7/scripts/checksyscalls.sh
28055 --- linux-3.0/scripts/checksyscalls.sh 2011-03-15 18:07:46.000000000 +0100
28056 +++ linux-3.0-vs2.3.1-pre7/scripts/checksyscalls.sh 2011-06-10 22:11:24.000000000 +0200
28057 @@ -193,7 +193,6 @@ cat << EOF
28058 #define __IGNORE_afs_syscall
28059 #define __IGNORE_getpmsg
28060 #define __IGNORE_putpmsg
28061 -#define __IGNORE_vserver
28065 diff -NurpP --minimal linux-3.0/security/commoncap.c linux-3.0-vs2.3.1-pre7/security/commoncap.c
28066 --- linux-3.0/security/commoncap.c 2011-07-22 11:18:14.000000000 +0200
28067 +++ linux-3.0-vs2.3.1-pre7/security/commoncap.c 2011-06-16 14:16:51.000000000 +0200
28068 @@ -62,6 +62,7 @@ int cap_netlink_recv(struct sk_buff *skb
28073 EXPORT_SYMBOL(cap_netlink_recv);
28076 @@ -83,14 +84,20 @@ EXPORT_SYMBOL(cap_netlink_recv);
28077 int cap_capable(struct task_struct *tsk, const struct cred *cred,
28078 struct user_namespace *targ_ns, int cap, int audit)
28080 + struct vx_info *vxi = tsk->vx_info;
28083 /* The creator of the user namespace has all caps. */
28084 if (targ_ns != &init_user_ns && targ_ns->creator == cred->user)
28087 /* Do we have the necessary capabilities? */
28088 - if (targ_ns == cred->user->user_ns)
28089 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
28090 + if (targ_ns == cred->user->user_ns) {
28091 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
28092 + cap_raised(cred->cap_effective, cap))
28094 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
28097 /* Have we tried all of the parent namespaces? */
28098 if (targ_ns == &init_user_ns)
28099 @@ -611,7 +618,7 @@ int cap_inode_setxattr(struct dentry *de
28101 if (!strncmp(name, XATTR_SECURITY_PREFIX,
28102 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
28103 - !capable(CAP_SYS_ADMIN))
28104 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
28108 @@ -637,7 +644,7 @@ int cap_inode_removexattr(struct dentry
28110 if (!strncmp(name, XATTR_SECURITY_PREFIX,
28111 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
28112 - !capable(CAP_SYS_ADMIN))
28113 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
28117 @@ -971,3 +978,4 @@ int cap_file_mmap(struct file *file, uns
28122 diff -NurpP --minimal linux-3.0/security/selinux/hooks.c linux-3.0-vs2.3.1-pre7/security/selinux/hooks.c
28123 --- linux-3.0/security/selinux/hooks.c 2011-07-22 11:18:14.000000000 +0200
28124 +++ linux-3.0-vs2.3.1-pre7/security/selinux/hooks.c 2011-06-15 02:40:14.000000000 +0200
28126 #include <linux/dccp.h>
28127 #include <linux/quota.h>
28128 #include <linux/un.h> /* for Unix socket types */
28129 -#include <net/af_unix.h> /* for Unix socket types */
28130 #include <linux/parser.h>
28131 #include <linux/nfs_mount.h>
28132 #include <net/ipv6.h>