Linux XFS filesystem development
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Lukas Herbolt <lukas@herbolt.com>
Cc: sandeen@sandeen.net, aalbersh@kernel.org, dgc@kernel.org,
	linux-xfs@vger.kernel.org
Subject: Re: [RFC PATCH v2 4/5] xfs_admin: add -d option to manage default mkfs config file
Date: Wed, 27 May 2026 22:00:57 -0700	[thread overview]
Message-ID: <20260528050057.GF6078@frogsfrogsfrogs> (raw)
In-Reply-To: <20260525075752.4159504-5-lukas@herbolt.com>

On Mon, May 25, 2026 at 09:57:51AM +0200, Lukas Herbolt wrote:
> Add -d <file> to install a config file as the system-wide mkfs.xfs
> default, and -d clear to remove it. The default config directory is
> substituted at build time from the configured sysconfdir. The
> xfs_admin.sh is now generated from xfs_admin.sh.in to set the default
> config file location bsed on the ./configure.
> 
> Signed-off-by: Lukas Herbolt <lukas@herbolt.com>
> ---
>  .gitignore                           |  3 +++
>  db/Makefile                          | 11 ++++++++--
>  db/{xfs_admin.sh => xfs_admin.sh.in} | 30 ++++++++++++++++++++++++++--
>  3 files changed, 40 insertions(+), 4 deletions(-)
>  rename db/{xfs_admin.sh => xfs_admin.sh.in} (70%)
> 
> diff --git a/.gitignore b/.gitignore
> index eb3decd108be..fc695dbbd0b1 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -89,3 +89,6 @@ cscope.*
>  # docs
>  /man/man8/mkfs.xfs.8
>  /man/man8/xfs_scrub_all.8
> +
> +#generated bash
> +db/xfs_admin.sh
> diff --git a/db/Makefile b/db/Makefile
> index e36e775eee60..b9016d2a057b 100644
> --- a/db/Makefile
> +++ b/db/Makefile
> @@ -67,7 +67,8 @@ CFILES = $(HFILES:.h=.c) \
>  	iunlink.c \
>  	rdump.c \
>  	timelimit.c
> -LSRCFILES = xfs_admin.sh xfs_ncheck.sh xfs_metadump.sh
> +LSRCFILES = xfs_admin.sh.in xfs_ncheck.sh xfs_metadump.sh
> +LDIRT = xfs_admin.sh
>  
>  LLDLIBS	= $(LIBXFS) $(LIBXLOG) $(LIBFROG) $(LIBUUID) $(LIBRT) $(LIBURCU) \
>  	  $(LIBPTHREAD)
> @@ -79,10 +80,16 @@ LLDLIBS += $(LIBEDITLINE) $(LIBTERMCAP)
>  CFLAGS += -DENABLE_EDITLINE
>  endif
>  
> -default: depend $(LTCOMMAND)
> +default: depend $(LTCOMMAND) xfs_admin.sh
>  
>  include $(BUILDRULES)
>  
> +xfs_admin.sh: xfs_admin.sh.in $(TOPDIR)/include/builddefs
> +	@echo "    [SED]    $@"
> +	$(Q)$(SED) -e "s|@mkfs_syscfg_dir@|$(MKFS_SYSCFG_DIR)|g" \
> +		< $< > $@
> +	$(Q)chmod a+x $@
> +
>  install: default
>  	$(INSTALL) -m 755 -d $(PKG_SBIN_DIR)
>  	$(LTINSTALL) -m 755 $(LTCOMMAND) $(PKG_SBIN_DIR)
> diff --git a/db/xfs_admin.sh b/db/xfs_admin.sh.in
> similarity index 70%
> rename from db/xfs_admin.sh
> rename to db/xfs_admin.sh.in
> index 52a658ba4a54..e87a64467662 100755
> --- a/db/xfs_admin.sh
> +++ b/db/xfs_admin.sh.in
> @@ -13,11 +13,37 @@ REPAIR_OPTS=""
>  IO_OPTS=""
>  REPAIR_DEV_OPTS=""
>  LOG_OPTS=""
> -USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-L label] [-O v5_feature] [-r rtdev] [-U uuid] device [logdev]"
> +MKFS_DEFAULT_CFGDIR="@mkfs_syscfg_dir@"
> +MKFS_DEFAULT_CFGFILE="$MKFS_DEFAULT_CFGDIR/default.conf"
> +USAGE="Usage: xfs_admin [-efjlpuV] [-c 0|1] [-d file|clear] [-L label] [-O v5_feature] [-r rtdev] [-U uuid] device [logdev]"
>  
> -while getopts "c:efjlL:O:pr:uU:V" c
> +while getopts "c:d:efjlL:O:pr:uU:V" c
>  do
>  	case $c in
> +	d)	if [ "$OPTARG" = "clear" ]; then

I wish this were a long option (e.g. xfs_admin --set-defaults /root/my.cfg)
but I don't have a clue how to do this in bash.

> +			rm -f "$MKFS_DEFAULT_CFGFILE"
> +			status=$?
> +			if [ $status -eq 0 ]; then
> +				echo "Removed $MKFS_DEFAULT_CFGFILE"
> +			else
> +				echo "xfs_admin: failed to remove $MKFS_DEFAULT_CFGFILE" 1>&2
> +			fi
> +		else
> +			if [ ! -f "$OPTARG" ]; then
> +				echo "xfs_admin: cannot read '$OPTARG'" 1>&2

Shouldn't this be -r(eadable) not -f(ile path exists) given the error
message?

This new functionality also needs a manpage update.

--D

> +				exit 2
> +			fi
> +			mkdir -p "$MKFS_DEFAULT_CFGDIR" &&
> +			cp "$OPTARG" "$MKFS_DEFAULT_CFGFILE"
> +			status=$?
> +			if [ $status -eq 0 ]; then
> +				echo "Installed $OPTARG as $MKFS_DEFAULT_CFGFILE"
> +			else
> +				echo "xfs_admin: failed to install $MKFS_DEFAULT_CFGFILE" 1>&2
> +			fi
> +		fi
> +		exit $status
> +		;;
>  	c)	REPAIR_OPTS=$REPAIR_OPTS" -c lazycount="$OPTARG
>  		require_offline=1
>  		;;
> -- 
> 2.54.0
> 
> 

  reply	other threads:[~2026-05-28  5:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-25  7:57 [RFC PATCH v2 0/5] Add option to use default config file Lukas Herbolt
2026-05-25  7:57 ` [RFC PATCH v2 1/5] xfsprogs: mkfs.xfs Add buildtime default cli_params as global variable Lukas Herbolt
2026-05-28  4:50   ` Darrick J. Wong
2026-05-29 18:02     ` Lukas Herbolt
2026-05-25  7:57 ` [RFC PATCH v2 2/5] xfsprogs: mkfs.xfs add default configuration file Lukas Herbolt
2026-05-28  4:56   ` Darrick J. Wong
2026-05-29 18:06     ` Lukas Herbolt
2026-05-25  7:57 ` [RFC PATCH v2 3/5] xfsprogs: mkfs.xfs add auto|autodetect value for -d/l/r concurrency Lukas Herbolt
2026-05-28  4:57   ` Darrick J. Wong
2026-05-29 18:07     ` Lukas Herbolt
2026-05-25  7:57 ` [RFC PATCH v2 4/5] xfs_admin: add -d option to manage default mkfs config file Lukas Herbolt
2026-05-28  5:00   ` Darrick J. Wong [this message]
2026-05-25  7:57 ` [RFC PATCH v2 5/5] xfsprogs: mkfs.xfs clean up unused dft option in various validators Lukas Herbolt
2026-05-28  5:01   ` Darrick J. Wong
2026-05-28  5:10 ` [RFC PATCH v2 0/5] Add option to use default config file Darrick J. Wong
2026-05-29 18:01   ` Lukas Herbolt
2026-06-02  4:55     ` 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=20260528050057.GF6078@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=aalbersh@kernel.org \
    --cc=dgc@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=lukas@herbolt.com \
    --cc=sandeen@sandeen.net \
    /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