Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions init.d/localmount.in
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@ stop()
no_umounts_r="$no_umounts_r|$x"
done

# Prevent file system housing rc.log from been unmounted to keep log file writable during shutdown
if yesno ${rc_logger:-NO}; then
local _log_file=${rc_log_path:-'/var/log/rc.log'}

if [ ! -f "${_log_file}" ]; then
touch "${_log_file}" || unset _log_file
fi
Comment on lines +76 to +78
Copy link
Copy Markdown
Member

@navi-desu navi-desu May 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we skip this whole block if the file doesn't exist? e.g.

if yesno ${rc_logger:-NO} || [ -f "${_log_file=:${rc_log_path:-/var/log/rc.log}}" ]
	local rc_log_mntpnt="$(df ${_log_file} 2>/dev/null | awk 'NR==2 { print $6 }')"
	if [ "$rc_log_mntpnt" != '/' ]; then
		no_umounts_r="$no_umounts_r|${rc_log_mntpnt}"
	fi
fi

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, touching is needed for the df to work correctly. The highlighted block addresses the "corner" case when user enables logging for the first time and the log file is missing. df will not work for the missing file therefore all messages during shutdown process will be lost, to circumvent this rare case I introduced the touch and an extra safety unset measure. On the next boot log file will be created and everything will start to work as expected. This covers all cases when log file is missing. Block removal will make user lose shutdown messages from current "session". I found this during live tests (as mentioned before). Originally I had something as suggested, but I believe this is pretty important to support such condition, especially the solution is pretty easy and short.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did my home work very well as I understand the responsibility if this PR is accepted and rolls out to all Gentoo and Alpine systems :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i forgot live logs go to tmpfs before going to the log file dir (and i have no idea why we do that, concurrent openrc.1 instances isn't really a thing we support)

hmm


if [ -n "${_log_file}" ]; then
local rc_log_mntpnt="$(df ${_log_file} 2>/dev/null | awk 'NR==2 { print $6 }')"

if [ $rc_log_mntpnt != '/' ]; then
no_umounts_r="$no_umounts_r|${rc_log_mntpnt}"
fi
fi
fi

if [ "$RC_UNAME" = Linux ]; then
no_umounts_r="$no_umounts_r|/proc|/proc/.*|/run|/sys|/sys/.*"
if [ -e "$rc_svcdir"/usr_premounted ]; then
Expand Down
Loading