From owner-freebsd-arch@FreeBSD.ORG Fri Apr 20 05:39:21 2007 Return-Path: X-Original-To: arch@FreeBSD.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5F58416A401 for ; Fri, 20 Apr 2007 05:39:21 +0000 (UTC) (envelope-from dds@aueb.gr) Received: from mx-out-04.forthnet.gr (mx-out.forthnet.gr [193.92.150.103]) by mx1.freebsd.org (Postfix) with ESMTP id D413513C468 for ; Fri, 20 Apr 2007 05:39:20 +0000 (UTC) (envelope-from dds@aueb.gr) Received: from mx-av-01.forthnet.gr (mx-av.forthnet.gr [193.92.150.27]) by mx-out-04.forthnet.gr (8.13.8/8.13.8) with ESMTP id l3K5dJpp019332; Fri, 20 Apr 2007 08:39:19 +0300 Received: from MX-IN-02.forthnet.gr (mx-in-02.forthnet.gr [193.92.150.185]) by mx-av-01.forthnet.gr (8.14.1/8.14.1) with ESMTP id l3K5dIMN019982; Fri, 20 Apr 2007 08:39:18 +0300 Received: from [192.168.136.22] (ppp121-97.adsl.forthnet.gr [193.92.228.97]) by MX-IN-02.forthnet.gr (8.14.1/8.14.1) with ESMTP id l3K5d9IS011401; Fri, 20 Apr 2007 08:39:12 +0300 Authentication-Results: MX-IN-02.forthnet.gr from=dds@aueb.gr; sender-id=neutral; spf=neutral Message-ID: <462851D5.3020703@aueb.gr> Date: Fri, 20 Apr 2007 08:38:29 +0300 From: Diomidis Spinellis User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.9) Gecko/20061211 SeaMonkey/1.0.7 MIME-Version: 1.0 To: rick-freebsd@kiwi-computer.com References: <461958CC.4040804@aueb.gr> <20070414170218.M76326@fledge.watson.org> <4621E826.6050306@aueb.gr> <20070415105157.J84174@fledge.watson.org> <46231C64.9010707@aueb.gr> <20070419101815.Y2913@fledge.watson.org> <4627A6C3.2070409@aueb.gr> <20070419212253.L2913@fledge.watson.org> <4627E311.6080500@aueb.gr> <20070419220106.GA63814@keira.kiwi-computer.com> In-Reply-To: <20070419220106.GA63814@keira.kiwi-computer.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: arch@FreeBSD.org Subject: Re: Accounting changes 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: Fri, 20 Apr 2007 05:39:21 -0000 Rick C. Petty wrote: > On Fri, Apr 20, 2007 at 12:45:53AM +0300, Diomidis Spinellis wrote: >> If we follow the route of allowing the records to be read from both >> ends, we'll have to think of a construct that will portably maintain >> ac_flags at the same offset from the end as in the old struct acct. >> Proposals welcomed! > > How about rearranging the struct to have the fixed-sized fields first, > followed by the variable-sized fields. In fact I thought that was the > recommended practice.. The new structure has to provide backwards compatibility with the old structure for a program reading a single record either from the beginning of a file or from its end (backwards). This is why ac_flag and ac_len2 (which is a copy of ac_len) have to be in the end. A program reading backwards (e.g. lastcomm(1)) will first read ac_flag. If ANVER is set, it will then read ac_len2, and then the rest of the structure. It will the interpret the structure based on ac_version. If ANVER is not set, the structure is in the old format and the program will read the old struct acct. A program reading forwards will first examine ac_zero. If it is zero it will process the structure based on ac_len and ac_version. Otherwise the structure is in the old format and the program will read the old struct acct. - dds > i.e.: > >> struct nacct { >> u_int8_t ac_zero; /* zero identifies new version */ >> u_int8_t ac_version; /* record version number */ >> u_int16_t ac_len; /* record length */ >> >> char ac_comm[AC_COMM_LEN]; /* command name */ >> u_int16_t ac_len2; /* record length */ >> u_int8_t ac_flag; /* accounting flags */ > >> float ac_utime; /* user time */ >> float ac_stime; /* system time */ >> float ac_etime; /* elapsed time */ >> time_t ac_btime; /* starting time */ >> uid_t ac_uid; /* user id */ >> gid_t ac_gid; /* group id */ >> float ac_mem; /* average memory usage */ >> float ac_io; /* count of IO blocks */ >> __dev_t ac_tty; /* controlling tty */ > > -- Rick C. Petty