From owner-freebsd-arch@FreeBSD.ORG Mon Mar 30 22:35:25 2009 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C0005106566B; Mon, 30 Mar 2009 22:35:25 +0000 (UTC) (envelope-from kientzle@freebsd.org) Received: from kientzle.com (kientzle.com [66.166.149.50]) by mx1.freebsd.org (Postfix) with ESMTP id 2F9AD8FC16; Mon, 30 Mar 2009 22:35:25 +0000 (UTC) (envelope-from kientzle@freebsd.org) Received: (from root@localhost) by kientzle.com (8.14.3/8.14.3) id n2UMZOiH094170; Mon, 30 Mar 2009 15:35:24 -0700 (PDT) (envelope-from kientzle@freebsd.org) Received: from dark.x.kientzle.com (fw2.kientzle.com [10.123.1.2]) by kientzle.com with SMTP id rejmf2sm78zt7hd2scij7fb65a; Mon, 30 Mar 2009 15:35:24 -0700 (PDT) (envelope-from kientzle@freebsd.org) Message-ID: <49D1492C.5050101@freebsd.org> Date: Mon, 30 Mar 2009 15:35:24 -0700 From: Tim Kientzle User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8.1.19) Gecko/20090226 SeaMonkey/1.1.14 MIME-Version: 1.0 To: Daniel Eischen References: <93378.1238438607@critter.freebsd.dk> <49D115B9.7030501@freebsd.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: FreeBSD Arch , Poul-Henning Kamp , Tim Kientzle , Marcel Moolenaar Subject: Re: On errno X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Mar 2009 22:35:26 -0000 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