11541Srgrimes/*- 214507Shsu * Copyright (c) 1990, 1993, 1994 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * (c) UNIX System Laboratories, Inc. 51541Srgrimes * All or some portions of this file are derived from material licensed 61541Srgrimes * to the University of California by American Telephone and Telegraph 71541Srgrimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with 81541Srgrimes * the permission of UNIX System Laboratories, Inc. 91541Srgrimes * 101541Srgrimes * Redistribution and use in source and binary forms, with or without 111541Srgrimes * modification, are permitted provided that the following conditions 121541Srgrimes * are met: 131541Srgrimes * 1. Redistributions of source code must retain the above copyright 141541Srgrimes * notice, this list of conditions and the following disclaimer. 151541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 161541Srgrimes * notice, this list of conditions and the following disclaimer in the 171541Srgrimes * documentation and/or other materials provided with the distribution. 181541Srgrimes * 4. Neither the name of the University nor the names of its contributors 191541Srgrimes * may be used to endorse or promote products derived from this software 201541Srgrimes * without specific prior written permission. 211541Srgrimes * 221541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 231541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 241541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 251541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 261541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 271541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 281541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 291541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 301541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 311541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 321541Srgrimes * SUCH DAMAGE. 331541Srgrimes * 3414507Shsu * @(#)acct.h 8.4 (Berkeley) 1/9/95 3550477Speter * $FreeBSD: releng/10.2/sys/sys/acct.h 169857 2007-05-22 06:51:38Z dds $ 361541Srgrimes */ 371541Srgrimes 382165Spaul#ifndef _SYS_ACCT_H_ 392165Spaul#define _SYS_ACCT_H_ 402165Spaul 41169857Sdds#ifdef _KERNEL 42169857Sdds#define float uint32_t 43169857Sdds#endif 44169857Sdds 45169857Sdds#define AC_COMM_LEN 16 46169857Sdds 471541Srgrimes/* 48169857Sdds * Accounting structure version 2 (current). 49169857Sdds * The first byte is always zero. 50169857Sdds * Time units are microseconds. 511541Srgrimes */ 521541Srgrimes 53169857Sddsstruct acctv2 { 54169857Sdds uint8_t ac_zero; /* zero identifies new version */ 55169857Sdds uint8_t ac_version; /* record version number */ 56169857Sdds uint16_t ac_len; /* record length */ 57169857Sdds 5814507Shsu char ac_comm[AC_COMM_LEN]; /* command name */ 59169857Sdds float ac_utime; /* user time */ 60169857Sdds float ac_stime; /* system time */ 61169857Sdds float ac_etime; /* elapsed time */ 6214507Shsu time_t ac_btime; /* starting time */ 6314507Shsu uid_t ac_uid; /* user id */ 6414507Shsu gid_t ac_gid; /* group id */ 65169857Sdds float ac_mem; /* average memory usage */ 66169857Sdds float ac_io; /* count of IO blocks */ 67130640Sphk __dev_t ac_tty; /* controlling tty */ 6814507Shsu 69169857Sdds uint16_t ac_len2; /* record length */ 70169857Sdds union { 71169857Sdds __dev_t ac_align; /* force v1 compatible alignment */ 72169857Sdds 7314507Shsu#define AFORK 0x01 /* forked but not exec'ed */ 7482619Srwatson/* ASU is no longer supported */ 751541Srgrimes#define ASU 0x02 /* used super-user permissions */ 761541Srgrimes#define ACOMPAT 0x04 /* used compatibility mode */ 771541Srgrimes#define ACORE 0x08 /* dumped core */ 781541Srgrimes#define AXSIG 0x10 /* killed by a signal */ 79169857Sdds#define ANVER 0x20 /* new record version */ 80169857Sdds 81169857Sdds uint8_t ac_flag; /* accounting flags */ 82169857Sdds } ac_trailer; 83169857Sdds 84169857Sdds#define ac_flagx ac_trailer.ac_flag 851541Srgrimes}; 861541Srgrimes 87169857Sdds 881541Srgrimes/* 89169857Sdds * Legacy accounting structure (rev. 1.5-1.18). 90169857Sdds * The first byte is always non-zero. 91169857Sdds * Some fields use a comp_t type which is a 3 bits base 8 92169857Sdds * exponent, 13 bit fraction ``floating point'' number. 93169857Sdds * Units are 1/AHZV1 seconds. 94169857Sdds */ 95169857Sdds 96169857Sddstypedef uint16_t comp_t; 97169857Sdds 98169857Sddsstruct acctv1 { 99169857Sdds char ac_comm[AC_COMM_LEN]; /* command name */ 100169857Sdds comp_t ac_utime; /* user time */ 101169857Sdds comp_t ac_stime; /* system time */ 102169857Sdds comp_t ac_etime; /* elapsed time */ 103169857Sdds time_t ac_btime; /* starting time */ 104169857Sdds uid_t ac_uid; /* user id */ 105169857Sdds gid_t ac_gid; /* group id */ 106169857Sdds uint16_t ac_mem; /* average memory usage */ 107169857Sdds comp_t ac_io; /* count of IO blocks */ 108169857Sdds __dev_t ac_tty; /* controlling tty */ 109169857Sdds uint8_t ac_flag; /* accounting flags */ 110169857Sdds}; 111169857Sdds 112169857Sdds/* 113169857Sdds * 1/AHZV1 is the granularity of the data encoded in the comp_t fields. 1141541Srgrimes * This is not necessarily equal to hz. 1151541Srgrimes */ 116169857Sdds#define AHZV1 64 1171541Srgrimes 11855205Speter#ifdef _KERNEL 11983366Sjulianstruct thread; 12032995Sbde 12192719Salfredint acct_process(struct thread *td); 122169857Sdds#undef float 1231541Srgrimes#endif 12414507Shsu 12514507Shsu#endif /* !_SYS_ACCT_H_ */ 126