]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
fsck.xfs: fix fsck.xfs run by different shells when fsck.mode=force is set
authorGerald Yang <gerald.yang@canonical.com>
Tue, 13 Aug 2024 07:25:51 +0000 (15:25 +0800)
committerCarlos Maiolino <cem@kernel.org>
Mon, 16 Sep 2024 07:20:51 +0000 (09:20 +0200)
commit19dde7fac0f38af2990e367ef4dd8ec512920c12
tree3b5fed68114a0ddb7cdd06865fa1d6dba11ede3c
parentbaf5cde86f22e210fe560ccd5f862a27a0fbc1eb
fsck.xfs: fix fsck.xfs run by different shells when fsck.mode=force is set

When fsck.mode=force is specified in the kernel command line, fsck.xfs
is executed during the boot process. However, when the default shell is
not bash, $PS1 should be a different value, consider the following script:
cat ps1.sh
echo "$PS1"

run ps1.sh with different shells:
ash ./ps1.sh
$
bash ./ps1.sh

dash ./ps1.sh
$
ksh ./ps1.sh

zsh ./ps1.sh

On systems like Ubuntu, where dash is the default shell during the boot
process to improve startup speed. This results in FORCE being incorrectly
set to false and then xfs_repair is not invoked:
if [ -n "$PS1" -o -t 0 ]; then
        FORCE=false
fi

Other distros may encounter this issue too if the default shell is set
to anoother shell.

Check "-t 0" is enough to determine if we are in interactive mode, and
xfs_repair is invoked as expected regardless of the shell used.

Fixes: 04a2d5dc ("fsck.xfs: allow forced repairs using xfs_repair")
Signed-off-by: Gerald Yang <gerald.yang@canonical.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
fsck/xfs_fsck.sh