Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 348416
Collapse All | Expand All

(-)a/sh/init.sh.Linux.in (-13 / +7 lines)
Lines 65-91 mount_svcdir() Link Here
65
# By default VServer already has /proc mounted, but OpenVZ does not!
65
# By default VServer already has /proc mounted, but OpenVZ does not!
66
# However, some of our users have an old proc image in /proc
66
# However, some of our users have an old proc image in /proc
67
# NFC how they managed that, but the end result means we have to test if
67
# NFC how they managed that, but the end result means we have to test if
68
# /proc actually works or not. We to this by comparing two reads of
68
# /proc actually works or not. We do this by comparing two reads of
69
# /proc/self/stat. They will not match, because at least the minor fault count
69
# /proc/self/environ. We set an environment variable before the first
70
# field (field 10) should have changed.
70
# read which we do not set before the second read, so
71
#
71
# if the comparison comes back equal, we know that /proc is not working.
72
# We can use any file here that fills the following requirements:
73
# - changes between sequential reads
74
# - is world-readable (not blocked in hardened kernel)
75
# - Is only a single line (ergo entire check is doable with no forks)
76
mountproc=true
72
mountproc=true
77
f=/proc/self/stat
73
f=/proc/self/environ
78
if [ -e $f ]; then
74
if [ -e $f ]; then
79
	exec 9<$f ; read a <&9 ; exec 9<&-
75
	if [ "$(VAR=a cat $f)" = "$(cat $f)" ]; then
80
	exec 9<$f ; read b <&9 ; exec 9<&-
81
	if [ "$a" = "$b" ]; then
82
		eerror "You have cruft in /proc that should be deleted"
76
		eerror "You have cruft in /proc that should be deleted"
83
	else
77
	else
84
		einfo "/proc is already mounted, skipping"
78
		einfo "/proc is already mounted, skipping"
85
		mountproc=false
79
		mountproc=false
86
	fi
80
	fi
87
fi
81
fi
88
unset a b f
82
unset f
89
83
90
if $mountproc; then
84
if $mountproc; then
91
	procfs="proc"
85
	procfs="proc"

Return to bug 348416