summaryrefslogtreecommitdiff
path: root/addons/bashrc.common
blob: 14e09d385cc33574b6431d1ff045a90423d20e7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/share/bcc/tools/
export TMPDIR=/tmp/

psk=/proc/sys/kernel/kptr_restrict
if [ -f $psk ]; then echo 0 > $psk; fi

override_vers=1
this_vers=$(/get_kvers.sh)
if [ -d /kernel-headers/ ]; then
	export BCC_KERNEL_SOURCE=/kernel-headers/;

	h_vers=0
	vers_line=$(grep LINUX_VERSION_CODE /kernel-headers/include/generated/uapi/linux/version.h)
	if [ "x$vers_line" != "x" ]; then
		h_vers=$(echo $vers_line | cut -d ' ' -f3)
	fi

	if [ $this_vers -eq $h_vers ]; then
		override_vers=0
	else
		this_major=$(($this_vers / (256 * 256)))
		this_minor=$(($this_vers / 256 % 256))
		h_major=$(($h_vers / (256 * 256)))
		h_minor=$(($h_vers / 256 % 256))
		if [ $this_major -ne $h_major ] || [ $this_minor -ne $h_minor ]; then
			echo "Error: kernel version does not match installed headers ($this_major.$this_minor <> $h_major.$h_minor)"
			echo "BCC will not work"
			override_vers=0
		fi
	fi
fi

# Override kernel version if we haven't found headers with them.
# Needed for BCC to work on slightly mismatched kernels.
if [ $override_vers -eq 1 ]; then
	export BCC_LINUX_VERSION_CODE=$this_vers
fi