Accounting changes

Diomidis Spinellis dds at aueb.gr
Fri May 4 15:58:38 UTC 2007


I've put a proposed new version of acct.h at 
http://www.spinellis.gr/FreeBSD/acct.h

Following earlier discussion and comments, here is its design rationale. 
  [In square brackets is the identifier of people whose comments are 
addressed by each design decision.]


On modern processors the various time values were 0, because many 
commands took less than 1/64s to execute [bde].  Now time values are 
stored with microsecond precision as float numbers.(I've written code 
that allows the kernel to write them without any floating point 
operations.)

Users often keep accounting data for many years back; we should offer 
backwards compatibility [rwatson, sam]. Binary compatibility of legacy 
accounting data will be documented (in acct.h and acct(5)) and 
maintained.  I will modify sa(8) and lastcomm(1) to read both acctv1 and 
acctv2 accounting records.  Backwards compatibility of the 
sa(8)-generated compacted accounting files can be maintained by 
continuing to store in them time in AHZV1 units.

Third-party programs reading accounting data may get confused by the new 
format  [dds].  I intentionally broke source-code compatibility by 
renaming "struct acct" to "struct acctv1", so that other programs 
reading accounting records will not accidentally try to read new records 
into the old structure.

Files containing records of acctv1 and/or acctv2 structures should be 
readable backwards and forwards.  (lastcomm(1) requires this capability 
  [dds].)  A length field exists at both ends.  At the heading-end a 
zero byte indicates a post v1 version.  At the trailing-end an ANVER 
flag indicates the same.

Alignment differences might have ac_flag to be in different relative 
locations from the end of the file in the two versions [rwatson].  To 
guarantee that the location of ac_flag at the end of the acctv2 record 
remains in the same location from the end as on the legacy acctv1 
record, I used a union to force the same alignment.  Although an 
anonymous union would result in clearer code, I did not use it, because 
this is a gcc extension.

The field ac_tty is nowadays useless and should be replaced with a 
credential identifier  [phk].  A credential identifier has not been 
added, because this could be inferred from a (suitably updated) wtmp. 
The current structure provides a clean upgrade path, if we wish to add 
such a feature in the future.

Diomidis - dds@


More information about the freebsd-arch mailing list