[openwrt/openwrt] ubox: fix logging to external filesystem

LEDE Commits lede-commits at lists.infradead.org
Sat Mar 22 05:03:54 PDT 2025


dangole pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/6ef0a35bb1a48f7c7daebaf8eeca877feffb47c7

commit 6ef0a35bb1a48f7c7daebaf8eeca877feffb47c7
Author: Daniel F. Dickinson <dfdpublic at wildtechgarden.ca>
AuthorDate: Tue Feb 18 23:58:06 2025 -0500

    ubox: fix logging to external filesystem
    
    As described in #13873, from 23.05.0 onwards logging to a file on an
    external filesystem fails under some conditions.
    
    This occurs because the log initscript had code added to prevent start
    logging to an external filesystem on boot, and added a trigger to start
    said logging when the external filesystem gets mounted.
    
    The issue is that for filesystems mount with fstab uci, the fstab
    scripts runs at START=11, while log runs at START=12, which means the
    external filesystem may already be mounted by the time the log initscript
    runs. Since the external filesystem is already mounted it does not
    trigger a hotplug event to trigger the trigger to start logging. This
    combination means the logging never automatically starts when the log
    file is on an external filesystem.
    
    We therefore add a check for the presence of a mounted filesystem when
    the log file is being sent to an fstab mounted filesystem. If the
    filesystem is mounted, we don't skip starting logging during boot.
    
    If the filesystem is not mounted then file logging is not started and
    the trigger will start the logging when the filesystem is mounted.
    
    Signed-off-by: Daniel F. Dickinson <dfdpublic at wildtechgarden.ca>
    [improved commit message]
    Signed-off-by: Daniel Golle <daniel at makrotopia.org>
---
 package/system/ubox/files/log.init | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/package/system/ubox/files/log.init b/package/system/ubox/files/log.init
index c6fdf44292..e02cc273da 100644
--- a/package/system/ubox/files/log.init
+++ b/package/system/ubox/files/log.init
@@ -52,8 +52,12 @@ start_service_file()
 	}
 	[ -z "${log_file}" ] && return
 
+	local mountpoint="$(procd_get_mountpoints "${log_file}")"
+
 	[ "$_BOOT" = "1" ] &&
-		[ "$(procd_get_mountpoints "${log_file}")" ] && return 0
+		[ "$mountpoint" ] &&
+		! grep -q ".* $mountpoint " /proc/mounts &&
+		return 0
 
 	mkdir -p "$(dirname "${log_file}")"
 




More information about the lede-commits mailing list