From owner-freebsd-arch@FreeBSD.ORG Thu Apr 19 21:46:36 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 9DC2C16A402; Thu, 19 Apr 2007 21:46:36 +0000 (UTC) (envelope-from dds@aueb.gr) Received: from mx-out-01.forthnet.gr (mx-out.forthnet.gr [193.92.150.103]) by mx1.freebsd.org (Postfix) with ESMTP id 1A34913C469; Thu, 19 Apr 2007 21:46:35 +0000 (UTC) (envelope-from dds@aueb.gr) Received: from mx-av-02.forthnet.gr (mx-av.forthnet.gr [193.92.150.27]) by mx-out-01.forthnet.gr (8.13.8/8.13.8) with ESMTP id l3JLkYvR025405; Fri, 20 Apr 2007 00:46:34 +0300 Received: from MX-IN-01.forthnet.gr (mx-in-01.forthnet.gr [193.92.150.23]) by mx-av-02.forthnet.gr (8.14.1/8.14.1) with ESMTP id l3JLkYm4032299; Fri, 20 Apr 2007 00:46:34 +0300 Received: from [192.168.136.22] (ppp121-97.adsl.forthnet.gr [193.92.228.97]) by MX-IN-01.forthnet.gr (8.14.1/8.14.1) with ESMTP id l3JLkVfn022770; Fri, 20 Apr 2007 00:46:32 +0300 Authentication-Results: MX-IN-01.forthnet.gr from=dds@aueb.gr; sender-id=neutral; spf=neutral Message-ID: <4627E311.6080500@aueb.gr> Date: Fri, 20 Apr 2007 00:45:53 +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: Robert Watson 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> In-Reply-To: <20070419212253.L2913@fledge.watson.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: arch@FreeBSD.org, re@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: Thu, 19 Apr 2007 21:46:36 -0000 Robert Watson wrote: > > On Thu, 19 Apr 2007, Diomidis Spinellis wrote: > >> I will work on developing a mechanism for backwards compatibility. >> >> Adding a version and length field in each record as you now propose is >> I think the way to go. However, it is not trivial, because >> lastcomm(1) often reads the file backwards. One approach would be to >> add a flag in ac_flags indicating a new version, and second copy of >> the length field before ac_flags. Thus, the new structure would be >> something like: > > Are there any alignment/padding considerations we should be taking into > account with the last two fields to make sure they are consistently > aligned with respect to the end of the record as new fields are added to > the middle? Thanks for pointing this out. True, we can't depend on ac_flag being in a fixed offset from the end of the record. On i386 the situation is: Old size=48 offsetof ac_flag=44 end-offset=4 New size=60 offsetof ac_flag=58 end-offset=2 and on amd64: Old size=56 offsetof ac_flag=48 end-offset=8 New size=64 offsetof ac_flag=62 end-offset=2 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! - dds PS The proposed layout in my previous email didn't include the changes for the fields. This is the correct layout I used for the above calculations: 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 */ 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 */ u_int16_t ac_len2; /* record length */ u_int8_t ac_flag; /* accounting flags */ };