lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20200815195749.9d25395fd2f9fbcda6efc423@kernel.org>
Date:   Sat, 15 Aug 2020 19:57:49 +0900
From:   Masami Hiramatsu <mhiramat@...nel.org>
To:     Steven Rostedt <rostedt@...dmis.org>
Cc:     LKML <linux-kernel@...r.kernel.org>, Ingo Molnar <mingo@...hat.com>
Subject: Re: [PATCH 4/6] tools/bootconfig: Add a script to generate ftrace
 shell-command from bootconfig

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

> On Mon, 10 Aug 2020 17:35:11 +0900
> Masami Hiramatsu <mhiramat@...nel.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@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ