Date: Mon, 30 Mar 2009 15:35:24 -0700 From: Tim Kientzle <kientzle@freebsd.org> To: Daniel Eischen <deischen@freebsd.org> Cc: FreeBSD Arch <arch@freebsd.org>, Poul-Henning Kamp <phk@phk.freebsd.dk>, Tim Kientzle <kientzle@freebsd.org>, Marcel Moolenaar <xcllnt@mac.com> Subject: Re: On errno Message-ID: <49D1492C.5050101@freebsd.org> In-Reply-To: <Pine.GSO.4.64.0903301529230.2318@sea.ntplx.net> References: <93378.1238438607@critter.freebsd.dk> <49D115B9.7030501@freebsd.org> <Pine.GSO.4.64.0903301529230.2318@sea.ntplx.net>
next in thread | previous in thread | raw e-mail | index | archive | help
Marcel Moolenar suggests adding new values of errno to further distinguish error conditions, leading to the following comments: Daniel Eischen wrote: > On Mon, 30 Mar 2009, Tim Kientzle wrote: >> Poul-Henning Kamp wrote: >>> Long time ago, I proposed a scheme where a process can register >>> a userland error-text buffer with the kernel. >> >> This is the right direction: Basically, add a new variable >> that augments errno instead of extending the possible values of >> errno. > > Just add the other error values in the upper half of the > word, and have __errno() return with the upper half > masked out. VxWorks doesn't something similar with > their errno,... I thought of that, but it won't work. Old binaries exist and you don't want to version every single system call. Poul-Henning Kamp wrote: > The probelm with an integer is that you cannot give details > like: > "partition 3 overlaps bootcode" > without precreating the N^2 possible messages of that kind. The standard solution if you need variable parameters, of course, is to pass the parameters back: int code: EPARTITIONOVERLAPSBOOTCODE char *default_text: "partition %1d overlaps bootcode" arg1: 3 This provides everything necessary for libc to generate an appropriate translated text. The "default_text" return is a common tweak, mostly to to make the code at the error source easier to read, though it also helps the consumer to provide something even when the translation catalogs are missing or damaged. Note that the code at the error source is essentially the same either way: generate_error(EPARTITIONOVERLAPSBOOTCODE, "partition %1d overlaps bootcode", partno); but the varargs values get passed back to userland to be formatted instead of being formatted in the kernel. Tim
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?49D1492C.5050101>