1*a56fe703SKonstantin Belousov /*-
2*a56fe703SKonstantin Belousov * SPDX-License-Identifier: BSD-2-Clause
3*a56fe703SKonstantin Belousov *
4*a56fe703SKonstantin Belousov * Copyright (c) 2025 The FreeBSD Foundation
5*a56fe703SKonstantin Belousov * All rights reserved.
6*a56fe703SKonstantin Belousov *
7*a56fe703SKonstantin Belousov * This software were developed by Konstantin Belousov <kib@FreeBSD.org>
8*a56fe703SKonstantin Belousov * under sponsorship from the FreeBSD Foundation.
9*a56fe703SKonstantin Belousov */
10*a56fe703SKonstantin Belousov
11*a56fe703SKonstantin Belousov #include <sys/types.h>
12*a56fe703SKonstantin Belousov #include <sys/exterrvar.h>
13*a56fe703SKonstantin Belousov #include <exterr.h>
14*a56fe703SKonstantin Belousov #include <stdio.h>
15*a56fe703SKonstantin Belousov #include <string.h>
16*a56fe703SKonstantin Belousov
17*a56fe703SKonstantin Belousov int
__uexterr_format(const struct uexterror * ue,char * buf,size_t bufsz)18*a56fe703SKonstantin Belousov __uexterr_format(const struct uexterror *ue, char *buf, size_t bufsz)
19*a56fe703SKonstantin Belousov {
20*a56fe703SKonstantin Belousov if (bufsz > UEXTERROR_MAXLEN)
21*a56fe703SKonstantin Belousov bufsz = UEXTERROR_MAXLEN;
22*a56fe703SKonstantin Belousov if (ue->error == 0) {
23*a56fe703SKonstantin Belousov strlcpy(buf, "No error", bufsz);
24*a56fe703SKonstantin Belousov return (0);
25*a56fe703SKonstantin Belousov }
26*a56fe703SKonstantin Belousov snprintf(buf, bufsz,
27*a56fe703SKonstantin Belousov "errno %d category %u (src line %u) p1 %#jx p2 %#jx %s",
28*a56fe703SKonstantin Belousov ue->error, ue->cat, ue->src_line,
29*a56fe703SKonstantin Belousov (uintmax_t)ue->p1, (uintmax_t)ue->p2, ue->msg);
30*a56fe703SKonstantin Belousov return (0);
31*a56fe703SKonstantin Belousov }
32