From nobody Sun Jun 28 09:43:56 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4gp4HK0M8Xz6jw6r for ; Sun, 28 Jun 2026 09:43:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gp4HJ2L7lz3dZL for ; Sun, 28 Jun 2026 09:43:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782639836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=aDWVbSfhkuWfkzjr4Lmr+wO5pfX/WLJJke+4T8P7qsc=; b=GXBEKqfwSyxdQpbOFfl3Qd38tSRFUQyUvUYqH60mUs+xq03CjW9GCen+pK68W9rCR1ifck CmiTJwzUS92rGMgU+U0VpqWlJaMuyGfOaWPBq/OJvcHbncxwBQQ+ni7269j9eFBeIUrMCF tGr0b58Wl0tyQCMyU96OvoyzspysXroNPZXYrlYozrrfXglUBIN8aRceWkb5qDoyS+T3Bo m3LqSPfRyAmDPwj+Dsv9lu3x+azt9fQkQ/wn03Lk3iRismjcu+/3nL398R+Zml5DPEfwso 1lQW+xhNZ3EZgHd7LwLIbmyVdVD8wCFJFS/RPHNrG6n4BafUltJfCiI5wYPtVQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1782639836; a=rsa-sha256; cv=none; b=LY1uwNWnQrNXFQ9YkGLCHT7Ue8gye8xJTE8rnJhig0iCPDsmoH7cRnYoKozKyaUSHO+q55 aPMd/93OMQzX61uhx77mkuhrz6vFT+nCzaDg45pNHgA1PS6ajOSq3zqRcr3pCWJ7uoiXSS c/RkV8Cvxt3AkIbBGKy4oGEkVWpeO305rY0z8d7d4FhxNHOi5JHbQ2udUGEza3k7a4NaTG lFqvG/xh9Z4yHVFH6zHkhSlDCH5epXohEV7AOk7ECoe89nnrCstItUFr/Z1jV+dH/XeNjX 3MC0RBS8lwrAXuoNuZzhb12PxFuNGqMiiMOic4K1rYhzocykMa+d7GDMui3KOA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782639836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=aDWVbSfhkuWfkzjr4Lmr+wO5pfX/WLJJke+4T8P7qsc=; b=T+8xLTLnozKRM1jMawc/HIP42QnOqgMkzpxAXDayJuOuxQPOPBNKUmu8SiFsJ1UMDzidim jP3Ca5BNgkkuEYB7e1mIUgvqeq/m+teazLB+AfIM8BJbeTiKmLtmjlWqfHYsC6u4ExGi29 O+8e8MYhVnC6s3sGd8tbeEqnX7OFv3fC8fAarcimiD3IEb/PdJH6MDg8e03BgnjT5LOIS7 Il/a9wYGOutVUZB2fFaeyv025J5yYexOfwoOiGLu7XAxla4P945+BWU7+kBqmvo0nKy23E JQNBHlyY0az2x9uVheGTME675vuOZhDRQLtLb3M9sVdLoob4J7IxiF/uOreI1g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gp4HJ17ygz13l2 for ; Sun, 28 Jun 2026 09:43:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 31b1c by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 28 Jun 2026 09:43:56 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: 10ae3fc0b06a - stable/14 - rc: Improve load_kld List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 10ae3fc0b06af407b31d00778836ae9844b8b0b1 Auto-Submitted: auto-generated Date: Sun, 28 Jun 2026 09:43:56 +0000 Message-Id: <6a40ecdc.31b1c.340f543b@gitrepo.freebsd.org> The branch stable/14 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=10ae3fc0b06af407b31d00778836ae9844b8b0b1 commit 10ae3fc0b06af407b31d00778836ae9844b8b0b1 Author: Dag-Erling Smørgrav AuthorDate: 2026-06-23 15:23:30 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-06-28 09:43:43 +0000 rc: Improve load_kld * Centralize the usage message. * Document and enforce that -e and -m are mutually exclusive; previously, speficying both would result in only -e being applied. * If -e was not specified, and -m was not specified or did not match, fall back to `kldstat -n file` which will always work for modules that aren't built into the kernel. This means the kld and ntpd scripts can now rely on load_kld to dtrt. MFC after: 1 week Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D57706 (cherry picked from commit a95d324dd3107afcbc16767d183acca7a57ebca9) --- libexec/rc/rc.d/kld | 6 ++++-- libexec/rc/rc.d/ntpd | 2 +- libexec/rc/rc.subr | 27 ++++++++++++++------------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/libexec/rc/rc.d/kld b/libexec/rc/rc.d/kld index ccfffe3091a6..c7f667107e8f 100755 --- a/libexec/rc/rc.d/kld +++ b/libexec/rc/rc.d/kld @@ -44,10 +44,12 @@ kld_start() local _kld - echo 'Loading kernel modules:' $kld_list + startmsg -n "Loading kernel modules:" for _kld in $kld_list ; do - load_kld -e ${_kld}.ko $_kld + load_kld $_kld + startmsg -n " ${_kld}" done + startmsg "." } load_rc_config $name diff --git a/libexec/rc/rc.d/ntpd b/libexec/rc/rc.d/ntpd index 76d83149ae1a..75bed16413ea 100755 --- a/libexec/rc/rc.d/ntpd +++ b/libexec/rc/rc.d/ntpd @@ -64,7 +64,7 @@ can_run_nonroot() # the policy module if not already present, then check whether the # policy has been disabled via tunable or sysctl. [ -n "$(sysctl -qn security.mac.version)" ] || return 1 - sysctl -qn security.mac.ntpd >/dev/null || kldload -qn mac_ntpd || return 1 + load_kld mac_ntpd || return 1 [ "$(sysctl -qn security.mac.ntpd.enabled)" == "1" ] || return 1 # On older existing systems, the ntp dir may by owned by root, change diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr index bef364af0843..2cc664cf473d 100644 --- a/libexec/rc/rc.subr +++ b/libexec/rc/rc.subr @@ -1957,37 +1957,38 @@ mount_md() # Code common to scripts that need to load a kernel module # if it isn't in the kernel yet. Syntax: -# load_kld [-e regex] [-m module] file +# load_kld [-e regex | -m module] file # where -e or -m chooses the way to check if the module # is already loaded: -# regex is egrep'd in the output from `kldstat -v', -# module is passed to `kldstat -m'. -# The default way is as though `-m file' were specified. +# -e greps the output from `kldstat -v', +# -m uses `kldstat -m module'. +# The default way is as though `-m file` was specified. load_kld() { - local _loaded _mod _opt _re + local _loaded _mod _opt _re _x + _x=0 while getopts "e:m:" _opt; do case "$_opt" in e) _re="$OPTARG" ;; m) _mod="$OPTARG" ;; - *) err 3 'USAGE: load_kld [-e regex] [-m module] file' ;; + *) _x=999 ;; esac + _x=$((_x + 1)) done shift $(($OPTIND - 1)) - if [ $# -ne 1 ]; then - err 3 'USAGE: load_kld [-e regex] [-m module] file' + if [ $# -ne 1 ] || [ $_x -gt 1 ]; then + err 3 'USAGE: load_kld [-e regex | -m module] file' fi - _mod=${_mod:-$1} _loaded=false if [ -n "$_re" ]; then if kldstat -v | egrep -q -e "$_re"; then _loaded=true fi - else - if kldstat -q -m "$_mod"; then - _loaded=true - fi + elif kldstat -q -m "${_mod:-$1}"; then + _loaded=true + elif kldstat -q -n "$1"; then + _loaded=true fi if ! $_loaded; then if ! kldload "$1"; then