tools/bootconfig/scripts/bconf2ftrace.sh

Source file repositories/reference/linux-study-clean/tools/bootconfig/scripts/bconf2ftrace.sh

File Facts

System
Linux kernel
Corpus path
tools/bootconfig/scripts/bconf2ftrace.sh
Extension
.sh
Size
6915 bytes
Lines
302
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: tools
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only

usage() {
	echo "Ftrace boottime trace test tool"
	echo "Usage: $0 [--apply|--init] [--debug] BOOTCONFIG-FILE"
	echo "    --apply: Test actual apply to tracefs (need sudo)"
	echo "    --init:  Initialize ftrace before applying (imply --apply)"
	exit 1
}

[ $# -eq 0 ] && usage

BCONF=
DEBUG=
APPLY=
INIT=
while [ x"$1" != x ]; do
	case "$1" in
	"--debug")
		DEBUG=$1;;
	"--apply")
		APPLY=$1;;
	"--init")
		APPLY=$1
		INIT=$1;;
	*)
		[ ! -f $1 ] && usage
		BCONF=$1;;
	esac
	shift 1
done

if [ x"$APPLY" != x ]; then
	if [ `id -u` -ne 0 ]; then
		echo "This must be run by root user. Try sudo." 1>&2
		exec sudo $0 $DEBUG $APPLY $BCONF
	fi
fi

run_cmd() { # command
	echo "$*"
	if [ x"$APPLY" != x ]; then # apply command
		eval $*
	fi
}

if [ x"$DEBUG" != x ]; then
	set -x
fi

TRACEFS=`grep -m 1 -w tracefs /proc/mounts | cut -f 2 -d " "`
if [ -z "$TRACEFS" ]; then
	if ! grep -wq debugfs /proc/mounts; then
		echo "Error: No tracefs/debugfs was mounted." 1>&2
		exit 1
	fi
	TRACEFS=`grep -m 1 -w debugfs /proc/mounts | cut -f 2 -d " "`/tracing
	if [ ! -d $TRACEFS ]; then
		echo "Error: ftrace is not enabled on this kernel." 1>&2
		exit 1
	fi
fi

if [ x"$INIT" != x ]; then
	. `dirname $0`/ftrace.sh
	(cd $TRACEFS; initialize_ftrace)
fi

. `dirname $0`/xbc.sh

Annotation

Implementation Notes