git: 3c61bbebc416 - main - Update rc.initdiskless, fix error handling of remount_optional
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 24 Jan 2025 19:41:50 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=3c61bbebc4166ca209b9becfd1529298bac6ed66
commit 3c61bbebc4166ca209b9becfd1529298bac6ed66
Author: Keve Müller <kevemueller@users.noreply.github.com>
AuthorDate: 2024-10-27 13:09:24 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-01-24 19:40:33 +0000
Update rc.initdiskless, fix error handling of remount_optional
chkerr() ignores the exit code of a preceding mount command in case a
file ```remount_optional``` exists. The check is performed and a
subshell is launched to log the informational message and return. The
return is executed in the context of the subshell, not the context of
the chkerr() function, hence is a NOP. The remount_optional check is
hence ineffective.
Change the code to if/then/fi, so the return is evaluated in the context
of the chkerr function, to make the check effective.
Reviewed by: imp, emaste
Pull Request: https://github.com/freebsd/freebsd-src/pull/1497
---
libexec/rc/rc.initdiskless | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libexec/rc/rc.initdiskless b/libexec/rc/rc.initdiskless
index a4c6c613b85a..3b66a3c4928a 100644
--- a/libexec/rc/rc.initdiskless
+++ b/libexec/rc/rc.initdiskless
@@ -174,7 +174,10 @@ log() {
chkerr() {
lastitem () ( n=$(($# - 1)) ; shift $n ; echo $1 )
mountpoint="$(lastitem $2)"
- [ -r $mountpoint/remount_optional ] && ( echo "$2 failed: ignoring due to remount_optional" ; return )
+ if [ -r $mountpoint/remount_optional ]; then
+ echo "$2 failed: ignoring due to remount_optional"
+ return
+ fi
case $1 in
0)
;;