linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH 4/6] tools/bootconfig: Add a script to generate ftrace shell-command from bootconfig
Date: Sat, 15 Aug 2020 19:57:49 +0900	[thread overview]
Message-ID: <20200815195749.9d25395fd2f9fbcda6efc423@kernel.org> (raw)
In-Reply-To: <20200813210100.23a706ab@oasis.local.home>

On Thu, 13 Aug 2020 21:01:00 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Mon, 10 Aug 2020 17:35:11 +0900
> Masami Hiramatsu <mhiramat@kernel.org> wrote:
> 
> 
> > --- /dev/null
> > +++ b/tools/bootconfig/scripts/xbc.sh
> > @@ -0,0 +1,56 @@
> > +#!/bin/sh
> > +# SPDX-License-Identifier: GPL-2.0-only
> > +
> > +# bootconfig utility functions
> > +
> > +XBC_TMPFILE=
> > +XBC_BASEDIR=`dirname $0`
> > +BOOTCONFIG=${BOOTCONFIG:=$XBC_BASEDIR/../bootconfig}
> > +if [ ! -x "$BOOTCONFIG" ]; then
> > +	BOOTCONFIG=`which bootconfig`
> > +	if [ -z "$BOOTCONFIG" ]; then
> > +		echo "Erorr: bootconfig command is not found" 1>&2
> > +		exit 1
> > +	fi
> > +fi
> > +
> > +xbc_cleanup() {
> > +	if [ "$XBC_TMPFILE" ]; then
> 
> Should the above be:
> 
> 	if [ -f "$XBC_TMPFILE" ]; then
> ?

Ah, good catch!
I didn't call xbc_cleanup except for the trap in bconf2ftrace,
but for user who call xbc_cleanup explicitly, we need -f.

Thank you!

> 
> 
> -- Steve
> 
> > +		rm -f "$XBC_TMPFILE"
> > +	fi
> > +}
> > +
> > +xbc_init() { # bootconfig-file
> > +	xbc_cleanup
> > +	XBC_TMPFILE=`mktemp bconf-XXXX`
> > +	trap xbc_cleanup EXIT TERM
> > +
> > +	$BOOTCONFIG -l $1 > $XBC_TMPFILE || exit 1
> > +}
> > +
> > +nr_args() { # args
> > +	echo $#
> > +}
> > +
> > +xbc_get_val() { # key [maxnum]
> > +	if [ "$2" ]; then
> > +		MAXOPT="-L $2"
> > +	fi
> > +	grep "^$1 =" $XBC_TMPFILE | cut -d= -f2- | \
> > +		sed -e 's/", /" /g' -e "s/',/' /g" | \
> > +		xargs $MAXOPT -n 1 echo
> > +}
> > +
> > +xbc_has_key() { # key
> > +	grep -q "^$1 =" $XBC_TMPFILE
> > +}
> > +
> > +xbc_has_branch() { # prefix-key
> > +	grep -q "^$1" $XBC_TMPFILE
> > +}
> > +
> > +xbc_subkeys() { # prefix-key depth
> > +	__keys=`echo $1 | sed "s/\./ /g"`
> > +	__s=`nr_args $__keys`
> > +	grep "^$1" $XBC_TMPFILE | cut -d= -f1| cut -d. -f$((__s + 1))-$((__s + $2)) | uniq
> > +}
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

  reply	other threads:[~2020-08-15 22:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-10  8:34 [PATCH 0/6] tools/bootconfig: Add boot-time tracing script Masami Hiramatsu
2020-08-10  8:34 ` [PATCH 1/6] tools/bootconfig: Show bootconfig compact tree from bootconfig file Masami Hiramatsu
2020-08-10  8:34 ` [PATCH 2/6] tools/bootconfig: Add list option Masami Hiramatsu
2020-08-10  8:35 ` [PATCH 3/6] tools/bootconfig: Make all functions static Masami Hiramatsu
2020-08-10  8:35 ` [PATCH 4/6] tools/bootconfig: Add a script to generate ftrace shell-command from bootconfig Masami Hiramatsu
2020-08-14  1:01   ` Steven Rostedt
2020-08-15 10:57     ` Masami Hiramatsu [this message]
2020-08-10  8:35 ` [PATCH 5/6] tools/bootconfig: Add a script to generates bootconfig from ftrace Masami Hiramatsu
2020-08-10  8:35 ` [PATCH 6/6] tools/bootconfig: Add --init option for bconf2ftrace.sh Masami Hiramatsu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200815195749.9d25395fd2f9fbcda6efc423@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).