The branch stable/15 has been updated by mckusick:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=b7a7d51107f37a2753921f18478341a92662066a

commit b7a7d51107f37a2753921f18478341a92662066a
Author:     Kirk McKusick <[email protected]>
AuthorDate: 2026-02-26 06:20:12 +0000
Commit:     Kirk McKusick <[email protected]>
CommitDate: 2026-03-06 21:13:28 +0000

    Refinements to the output when the EXTERROR_VERBOSE environment is set
    
    Reviewed by: kib
    Differential Revision: https://reviews.freebsd.org/D55494
    Sponsored-by: Netflix
    
    (cherry picked from commit 6fd98877de633f5ec6f028e78d5a2d94527d63d0)
---
 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);

Reply via email to