~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/bootconfig/scripts/xbc.sh

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/sh
  2 # SPDX-License-Identifier: GPL-2.0-only
  3 
  4 # bootconfig utility functions
  5 
  6 XBC_TMPFILE=
  7 XBC_BASEDIR=`dirname $0`
  8 BOOTCONFIG=${BOOTCONFIG:=$XBC_BASEDIR/../bootconfig}
  9 if [ ! -x "$BOOTCONFIG" ]; then
 10         BOOTCONFIG=`which bootconfig`
 11         if [ -z "$BOOTCONFIG" ]; then
 12                 echo "Erorr: bootconfig command is not found" 1>&2
 13                 exit 1
 14         fi
 15 fi
 16 
 17 xbc_cleanup() {
 18         if [ "$XBC_TMPFILE" ]; then
 19                 rm -f "$XBC_TMPFILE"
 20         fi
 21 }
 22 
 23 xbc_init() { # bootconfig-file
 24         xbc_cleanup
 25         XBC_TMPFILE=`mktemp bconf-XXXX`
 26         trap xbc_cleanup EXIT TERM
 27 
 28         $BOOTCONFIG -l $1 > $XBC_TMPFILE || exit 1
 29 }
 30 
 31 nr_args() { # args
 32         echo $#
 33 }
 34 
 35 xbc_get_val() { # key [maxnum]
 36         if [ "$2" ]; then
 37                 MAXOPT="-L $2"
 38         fi
 39         grep "^$1 =" $XBC_TMPFILE | cut -d= -f2- | \
 40                 sed -e 's/", /" /g' -e "s/',/' /g" | \
 41                 xargs $MAXOPT -n 1 echo
 42 }
 43 
 44 xbc_has_key() { # key
 45         grep -q "^$1 =" $XBC_TMPFILE
 46 }
 47 
 48 xbc_has_branch() { # prefix-key
 49         grep -q "^$1" $XBC_TMPFILE
 50 }
 51 
 52 xbc_subkeys() { # prefix-key depth [subkey-pattern]
 53         __keys=`echo $1 | sed "s/\./ /g"`
 54         __s=`nr_args $__keys`
 55         grep "^$1$3" $XBC_TMPFILE | cut -d= -f1| cut -d. -f$((__s + 1))-$((__s + $2)) | uniq
 56 }

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php