linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Lukas Czerner <lczerner@redhat.com>
Cc: fstests@vger.kernel.org, linux-ext4@vger.kernel.org,
	tytso@mit.edu, guan@eryu.me
Subject: Re: [PATCH 1/2] common/rc: add _require_kernel_config and _has_kernel_config
Date: Mon, 8 Nov 2021 09:18:05 -0800	[thread overview]
Message-ID: <20211108171805.GJ24282@magnolia> (raw)
In-Reply-To: <20211108151916.27845-1-lczerner@redhat.com>

On Mon, Nov 08, 2021 at 04:19:15PM +0100, Lukas Czerner wrote:
> Add _require_kernel_config() and _has_kernel_config() helpers to check
> whether a specific kernel configuration is enabled on the kernel.
> 
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> ---
>  common/config |  1 +
>  common/rc     | 29 +++++++++++++++++++++++++++++
>  2 files changed, 30 insertions(+)
> 
> diff --git a/common/config b/common/config
> index 164381b7..e0a5c5df 100644
> --- a/common/config
> +++ b/common/config
> @@ -226,6 +226,7 @@ export OPENSSL_PROG="$(type -P openssl)"
>  export ACCTON_PROG="$(type -P accton)"
>  export E2IMAGE_PROG="$(type -P e2image)"
>  export BLKZONE_PROG="$(type -P blkzone)"
> +export GZIP_PROG="$(type -P gzip)"
>  
>  # use 'udevadm settle' or 'udevsettle' to wait for lv to be settled.
>  # newer systems have udevadm command but older systems like RHEL5 don't.
> diff --git a/common/rc b/common/rc
> index 0d261184..84154868 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -4703,6 +4703,35 @@ _require_names_are_bytes() {
>          esac
>  }
>  
> +_has_kernel_config()
> +{
> +	option=$1
> +	uname=$(uname -r)
> +	config_list="$KCONFIG_PATH

This new KCONFIG_PATH variable should be documented in the README.

Otherwise, the logic looks solid.

--D

> +		     /proc/config.gz
> +		     /lib/modules/$uname/build/.config
> +		     /boot/config-$uname
> +		     /lib/kernel/config-$uname"
> +
> +	for config in $config_list; do
> +		[ ! -f $config ] && continue
> +		[ $config = "/proc/config.gz" ] && break
> +		grep -qE "^${option}=[my]" $config
> +		return
> +	done
> +
> +	[ ! -f $config ] && _notrun "Could not locate kernel config file"
> +
> +	# We can only get here with /proc/config.gz
> +	_require_command "$GZIP_PROG" gzip
> +	$GZIP_PROG -cd $config | grep -qE "^${option}=[my]"
> +}
> +
> +_require_kernel_config()
> +{
> +	_has_kernel_config $1 || _notrun "Installed kernel not built with $1"
> +}
> +
>  init_rc
>  
>  ################################################################################
> -- 
> 2.31.1
> 

  parent reply	other threads:[~2021-11-08 17:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-08 15:19 [PATCH 1/2] common/rc: add _require_kernel_config and _has_kernel_config Lukas Czerner
2021-11-08 15:19 ` [PATCH v6 2/2] ext4: add test for all ext4/ext3/ext2 mount options Lukas Czerner
2021-11-08 17:18 ` Darrick J. Wong [this message]
2021-11-08 21:04 ` [PATCH v2 1/2] common/rc: add _require_kernel_config and _has_kernel_config Lukas Czerner
2021-11-08 22:31   ` Darrick J. Wong
2021-11-09  9:28     ` Lukas Czerner
2021-11-09 17:29       ` Darrick J. Wong

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=20211108171805.GJ24282@magnolia \
    --to=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=guan@eryu.me \
    --cc=lczerner@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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).