Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../lib/dracut/modules..../99memstr...
File: memstrack-start.sh
#!/bin/sh
[0] Fix | Delete
# Mount kernel debug fs so debug tools can work.
[1] Fix | Delete
# memdebug=4 and memdebug=5 requires debug fs to be mounted.
[2] Fix | Delete
# And there is no need to umount it.
[3] Fix | Delete
[4] Fix | Delete
type getargnum >/dev/null 2>&1 || . /lib/dracut-lib.sh
[5] Fix | Delete
[6] Fix | Delete
# "sys/kernel/tracing" has the priority if exists.
[7] Fix | Delete
get_trace_base() {
[8] Fix | Delete
# trace access through debugfs would be obsolete if "/sys/kernel/tracing" is available.
[9] Fix | Delete
if [ -d "/sys/kernel/tracing" ]; then
[10] Fix | Delete
echo "/sys/kernel"
[11] Fix | Delete
else
[12] Fix | Delete
echo "/sys/kernel/debug"
[13] Fix | Delete
fi
[14] Fix | Delete
}
[15] Fix | Delete
[16] Fix | Delete
is_debugfs_ready() {
[17] Fix | Delete
[ -f "$(get_trace_base)/tracing/trace" ]
[18] Fix | Delete
}
[19] Fix | Delete
[20] Fix | Delete
prepare_debugfs() {
[21] Fix | Delete
local trace_base
[22] Fix | Delete
[23] Fix | Delete
trace_base=$(get_trace_base)
[24] Fix | Delete
# old debugfs interface case.
[25] Fix | Delete
if ! [ -d "$trace_base/tracing" ]; then
[26] Fix | Delete
mount none -t debugfs $trace_base
[27] Fix | Delete
# new tracefs interface case.
[28] Fix | Delete
elif ! [ -f "$trace_base/tracing/trace" ]; then
[29] Fix | Delete
mount none -t tracefs "$trace_base/tracing"
[30] Fix | Delete
fi
[31] Fix | Delete
[32] Fix | Delete
if ! [ -f "$trace_base/tracing/trace" ]; then
[33] Fix | Delete
echo "WARN: failed to mount debugfs"
[34] Fix | Delete
return 1
[35] Fix | Delete
fi
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
if ! is_debugfs_ready ; then
[39] Fix | Delete
prepare_debugfs
[40] Fix | Delete
fi
[41] Fix | Delete
[42] Fix | Delete
if [ -n "$DEBUG_MEM_LEVEL" ]; then
[43] Fix | Delete
if [ "$DEBUG_MEM_LEVEL" -ge 5 ]; then
[44] Fix | Delete
echo "memstrack - will report kernel module memory usage summary and top allocation stack"
[45] Fix | Delete
memstrack --report module_summary,module_top --notui --throttle 80 -o /.memstrack &
[46] Fix | Delete
elif [ "$DEBUG_MEM_LEVEL" -ge 4 ]; then
[47] Fix | Delete
echo "memstrack - will report memory usage summary"
[48] Fix | Delete
memstrack --report module_summary --notui --throttle 80 -o /.memstrack &
[49] Fix | Delete
else
[50] Fix | Delete
exit 0;
[51] Fix | Delete
fi
[52] Fix | Delete
fi
[53] Fix | Delete
[54] Fix | Delete
PID=$!
[55] Fix | Delete
RET=$?
[56] Fix | Delete
[57] Fix | Delete
if [ $RET -ne 0 ]; then
[58] Fix | Delete
echo "Failed to start memstrack, exit status: $RET"
[59] Fix | Delete
exit $RET
[60] Fix | Delete
fi
[61] Fix | Delete
[62] Fix | Delete
# Wait a second for memstrack to setup everything, avoid missing any event
[63] Fix | Delete
sleep 1
[64] Fix | Delete
[65] Fix | Delete
echo $PID > /run/memstrack.pid
[66] Fix | Delete
disown
[67] Fix | Delete
[68] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function