From nobody Thu Feb 26 06:29:16 2026 X-Original-To: dev-commits-src-main@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 4fM1l55DkLz6Sm8L for ; Thu, 26 Feb 2026 06:29:21 +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 "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fM1l54bnNz3bvG for ; Thu, 26 Feb 2026 06:29:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1772087361; 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=+ESwxpP3IP1kxrNmkpuBi7XqKzifWyyYHxvYAL7sET0=; b=nHgcmqUUKN5AAaRDP/cYR/jZUQ4W4YhROL9QpIYSNR8k4py+gI5B43v4JBMbw8RDZt2zCG aOXWeLcr0FLUIYGhUTdaI6rF/GOntxafEluvux0hGZFrh4ApETNwGQLfIAlLqQRdNMN0gX vCllAocJ5dXLsGh9vUvnG6iZMkU8JaLM+RD82+HkvyOWlowcqmY9/EGfRS5ltCzmOxswH/ 6vxT+A9Sy0/53BlcY4cWckER14YhU4mM2TWU34rfIiFcWmnh/qtTmYHaWCCkusyrq4fAMD 9ixsBJvOYzBhYPmKpDHUU7tGrpsi1ToK/JEAcBToPUNSAiFYpb9pG1I7ANNczA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1772087361; a=rsa-sha256; cv=none; b=lDWeQ+5h9rBUylsuDZJV3W/SF4tpOLEsu863sfY0IODidOgkAdzJybX4U/vCJI4VdwvxiB EaLQskO4DHhA0G4WG1HyReEpNWek6m6EvUfKtnb2X9ALxsCbav/Ym4XYnsed0hxP8OE/ou vheqEzgoGdXmSKBhuMb3Jpy7CAoPWoRlf2bDq13XxLAsljgxQzQYArj25JNPtdiPDKzXIU Re6R2vljf1N1K/iGgwuTA3iTp+tSPqS+S1WfRaMZgUFEwE4FUya6M+w5myJNYLo/zy9oOY vArlKwsp5OjS3VsX2S25ZuMUH5uiMh2Jx9IppTUgfZsvZ91WBOsT8P5Uv5XqIg== 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=1772087361; 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=+ESwxpP3IP1kxrNmkpuBi7XqKzifWyyYHxvYAL7sET0=; b=RaimTXD/tkLZ9BammUDvF2sNCAHN3DAh+agpMUCrpzWMP7KLfJvUH+T3lLRFDvspdT0BLO evqiZITVb+U4uDB6w7Urb58vzJVqABICSrJSvmeZQXkM++TiPt7IhGObsIap28fJLwgy9O GnWyXjoJbGog2ZhfLIdvcFuhn33nNBl+DObU07eaU7MdrxY/pMTQ3wqjZExv0d33j+Cfep sagpaun2KsdScgXEQVFJjKUwBUzmlEZZGuS6Pe5h7Mb1dWjzExbBn6sbx5WavLLZB/wi7S 3ASjfhkbjWsCaCSZ4S9TY/XlA+rmJcxbIZuo7mZZUfsOYMRL2FUCQizaqRKp7w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fM1l54Bj1z4ML for ; Thu, 26 Feb 2026 06:29:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 40050 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 26 Feb 2026 06:29:16 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kirk McKusick Subject: git: 6fd98877de63 - main - Refinements to the output when the EXTERROR_VERBOSE environment is set List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mckusick X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6fd98877de633f5ec6f028e78d5a2d94527d63d0 Auto-Submitted: auto-generated Date: Thu, 26 Feb 2026 06:29:16 +0000 Message-Id: <699fe83c.40050.5e7aeeb1@gitrepo.freebsd.org> The branch main has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=6fd98877de633f5ec6f028e78d5a2d94527d63d0 commit 6fd98877de633f5ec6f028e78d5a2d94527d63d0 Author: Kirk McKusick AuthorDate: 2026-02-26 06:20:12 +0000 Commit: Kirk McKusick CommitDate: 2026-02-26 06:20:12 +0000 Refinements to the output when the EXTERROR_VERBOSE environment is set When kernel external errors are available they are included in the err(3) library function messages. In addition to the extended error itself, the kernel also tracks the kernel file and line number at which the error was generated. This additional information is not included in the err(3) messages unless the EXTERROR_VERBOSE environment variable is present. Currently, when EXTERROR_VERBOSE is present, all the internal extended error information associated with the error is printed most of which is redundant with the formatted error message printed by err(3). This change will add only the kernel file and line number to the err(3) message when EXTERROR_VERBOSE is present and set to "brief". Sample output with bad protection bits to mmap: guest_16 % ./Example bigfile Example: mmap bigfile: Invalid argument (unknown PROT bits 0x8) guest_16 % setenv EXTERROR_VERBOSE guest_16 % ./Example bigfile Example: mmap bigfile: Invalid argument (unknown PROT bits 0x8 errno 22 category 1 (src sys/vm/vm_mmap.c:200) p1 0x8 p2 0) guest_16 % setenv EXTERROR_VERBOSE brief guest_16 % ./Example bigfile Example: mmap bigfile: Invalid argument (unknown PROT bits 0x8 (src sys/vm/vm_mmap.c:200)) Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D55494 MFC-after: 1 week Sponsored-by: Netflix --- lib/libc/gen/err.3 | 8 +++++++- lib/libc/gen/uexterr_format.c | 28 ++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/lib/libc/gen/err.3 b/lib/libc/gen/err.3 index 70a214152a19..2df03c2dcdde 100644 --- a/lib/libc/gen/err.3 +++ b/lib/libc/gen/err.3 @@ -25,7 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd March 29, 2012 +.Dd February 23, 2026 .Dt ERR 3 .Os .Sh NAME @@ -128,6 +128,12 @@ environment variable is present, an additional report is printed. The report includes at least the category of the error, the name of the source file (if known by the used version of libc), the source line number, and parameters. +If the +.Ev EXTERROR_VERBOSE +environment variable is present and set to "brief", +the report adds only the name of +the source file (if known by the used version of libc) +and the source line number. The format of the printed string is not contractual and might be changed. .Pp In the case of the diff --git a/lib/libc/gen/uexterr_format.c b/lib/libc/gen/uexterr_format.c index c1974f3c361a..308220adea1f 100644 --- a/lib/libc/gen/uexterr_format.c +++ b/lib/libc/gen/uexterr_format.c @@ -35,13 +35,16 @@ static const char exterror_verbose_name[] = "EXTERROR_VERBOSE"; enum exterr_verbose_state { EXTERR_VERBOSE_UNKNOWN = 100, EXTERR_VERBOSE_DEFAULT, - EXTERR_VERBOSE_ALLOW, + EXTERR_VERBOSE_ALLOW_BRIEF, + EXTERR_VERBOSE_ALLOW_FULL, }; static enum exterr_verbose_state exterror_verbose = EXTERR_VERBOSE_UNKNOWN; static void exterr_verbose_init(void) { + const char *v; + /* * No need to care about thread-safety, the result is * idempotent. @@ -50,8 +53,9 @@ exterr_verbose_init(void) return; if (issetugid()) { exterror_verbose = EXTERR_VERBOSE_DEFAULT; - } else if (getenv(exterror_verbose_name) != NULL) { - exterror_verbose = EXTERR_VERBOSE_ALLOW; + } else if ((v = getenv(exterror_verbose_name)) != NULL) { + exterror_verbose = strcmp(v, "brief") == 0 ? + EXTERR_VERBOSE_ALLOW_BRIEF : EXTERR_VERBOSE_ALLOW_FULL; } else { exterror_verbose = EXTERR_VERBOSE_DEFAULT; } @@ -78,13 +82,21 @@ __uexterr_format(const struct uexterror *ue, char *buf, size_t bufsz) strlcpy(buf, "", bufsz); } - if (exterror_verbose == EXTERR_VERBOSE_ALLOW || !has_msg) { + if (exterror_verbose > EXTERR_VERBOSE_DEFAULT || !has_msg) { char lbuf[128]; - snprintf(lbuf, sizeof(lbuf), - "errno %d category %u (src sys/%s:%u) p1 %#jx p2 %#jx", - ue->error, ue->cat, cat_to_filename(ue->cat), - ue->src_line, (uintmax_t)ue->p1, (uintmax_t)ue->p2); +#define SRC_FMT "(src sys/%s:%u)" + if (exterror_verbose == EXTERR_VERBOSE_ALLOW_BRIEF) { + snprintf(lbuf, sizeof(lbuf), SRC_FMT, + cat_to_filename(ue->cat), ue->src_line); + } else if (!has_msg || + exterror_verbose == EXTERR_VERBOSE_ALLOW_FULL) { + snprintf(lbuf, sizeof(lbuf), + "errno %d category %u " SRC_FMT " p1 %#jx p2 %#jx", + ue->error, ue->cat, cat_to_filename(ue->cat), + ue->src_line, (uintmax_t)ue->p1, (uintmax_t)ue->p2); + } +#undef SRC_FMT if (has_msg) strlcat(buf, " ", bufsz); strlcat(buf, lbuf, bufsz);