-
Notifications
You must be signed in to change notification settings - Fork 0
/
40-lkm.sh
87 lines (81 loc) · 2.06 KB
/
40-lkm.sh
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Here is a nice bash to be run as root that will show a
# list of all the currently loaded modules and all of their
# parameters, including the current value of the parameter. It
# uses /proc/modules to retrieve the current list of loaded modules,
# then access the module file directly with modinfo
aa_mod_parameters()
{
N=/dev/null;
C=`tput op` O=$(echo -en "\n`tput setaf 2`>>> `tput op`");
for mod in $(cat /proc/modules|cut -d" " -f1);
do
md=/sys/module/$mod/parameters;
[[ ! -d $md ]] && continue;
m=$mod;
d=`modinfo -d $m 2>$N | tr "\n" "\t"`;
echo -en "$O$m$C";
[[ ${#d} -gt 0 ]] && echo -n " - $d";
echo;
for mc in $(cd $md; echo *);
do
de=`modinfo -p $mod 2>$N | grep ^$mc 2>$N|sed "s/^$mc=//" 2>$N`;
echo -en "\t$mc=`cat $md/$mc 2>$N`";
[[ ${#de} -gt 1 ]] && echo -en " - $de";
echo;
done;
done
}
show_mod_parameter_info()
{
if tty -s <&1
then
green="\e[1;32m"
yellow="\e[1;33m"
cyan="\e[1;36m"
reset="\e[0m"
else
green=
yellow=
cyan=
reset=
fi
newline="
"
while read mod
do
md=/sys/module/$mod/parameters
[[ ! -d $md ]] && continue
d="$(modinfo -d $mod 2>/dev/null | tr "\n" "\t")"
echo -en "$green$mod$reset"
[[ ${#d} -gt 0 ]] && echo -n " - $d"
echo
pnames=()
pdescs=()
pvals=()
pdesc=
add_desc=false
while IFS="$newline" read p
do
if [[ $p =~ ^[[:space:]] ]]
then
pdesc+="$newline $p"
else
$add_desc && pdescs+=("$pdesc")
pname="${p%%:*}"
pnames+=("$pname")
pdesc=(" ${p#*:}")
pvals+=("$(cat $md/$pname 2>/dev/null)")
fi
add_desc=true
done < <(modinfo -p $mod 2>/dev/null)
$add_desc && pdescs+=("$pdesc")
for ((i=0; i<${#pnames[@]}; i++))
do
printf " $cyan%s$reset = $yellow%s$reset\n%s\n" \
${pnames[i]} \
"${pvals[i]}" \
"${pdescs[i]}"
done
echo
done < <(cut -d' ' -f1 /proc/modules | sort)
}