xref: /netbsd-src/share/man/man5/acct.5 (revision 5b125427f232e3ec1f384020cd19a93b6b50a838)
1.\"	$NetBSD: acct.5,v 1.12 2024/08/05 13:04:14 christos Exp $
2.\"
3.\" Copyright (c) 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"     @(#)acct.5	8.1 (Berkeley) 6/5/93
31.\"
32.Dd August 5, 2024
33.Dt ACCT 5
34.Os
35.Sh NAME
36.Nm acct
37.Nd execution accounting file
38.Sh SYNOPSIS
39.In sys/acct.h
40.Sh DESCRIPTION
41The kernel maintains the following
42.Fa acct
43information structure for all
44processes. If a process terminates, and accounting is enabled,
45the kernel calls the
46.Xr acct_process 9
47function call to prepare and append the record
48to the accounting file.
49.Bd -literal
50/*
51 * Accounting structures; these use a comp_t type which is a 3 bits base 8
52 * exponent, 13 bit fraction ``floating point'' number.  Units are 1/AHZ
53 * seconds.
54 */
55typedef uint16_t comp_t;
56
57struct acct {
58	char	  ac_comm[16];	/* name of command */
59	comp_t	  ac_utime;	/* user time */
60	comp_t	  ac_stime;	/* system time */
61	comp_t	  ac_etime;	/* elapsed time */
62	time_t	  ac_btime;	/* starting time */
63	uid_t	  ac_uid;	/* user id */
64	gid_t	  ac_gid;	/* group id */
65	uint16_t  ac_mem;	/* memory usage average */
66	comp_t	  ac_io;	/* count of IO blocks */
67	dev_t	  ac_tty;	/* controlling tty */
68#define	AFORK	0x01		/* fork'd but not exec'd */
69#define	ASU	0x02		/* used super-user permissions */
70#define	ACOMPAT	0x04		/* used compatibility mode */
71#define	ACORE	0x08		/* dumped core */
72#define	AXSIG	0x10		/* killed by a signal */
73	uint8_t	  ac_flag;	/* accounting flags */
74};
75
76/*
77 * 1/AHZ is the granularity of the data encoded in the comp_t fields.
78 * This is not necessarily equal to hz.
79 */
80#define	AHZ	64
81
82#ifdef _KERNEL
83void   acct_init(void);
84int    acct_process(struct lwp *);
85endif
86.Ed
87.Pp
88If a terminated process was created by an
89.Xr execve 2 ,
90the name of the executed file (at most ten characters of it)
91is saved in the field
92.Fa ac_comm
93and its status is saved by setting one of more of the following flags in
94.Fa ac_flag :
95.Dv AFORK ,
96.Dv ACORE ,
97and
98.Dv AXSIG .
99.Pp
100The
101.Dv ASU
102flag is not recorded anymore because with the switch to
103.Xr kauth 9 ,
104the superuser model is optional and passing the affected process to every
105authorization call in order to record
106.Dv ASU
107in
108.Fa p_acflag ,
109would require many source changes and would not reflect reality because
110the authorization decision might not have been done based on the
111.Xr secmodel_suser 9
112model.
113.Pp
114The
115.Dv ACOMPAT
116flag was never recorded in
117.Nx ;
118we could consider setting when the a process is running under emulation,
119but this is not currently done.
120.Pp
121Both the
122.Dv ASU
123and the
124.Dv ACOMPAT
125flags are retained for source compatibility.
126.Sh SEE ALSO
127.Xr lastcomm 1 ,
128.Xr acct 2 ,
129.Xr execve 2 ,
130.Xr accton 8 ,
131.Xr sa 8 ,
132.Xr acct_process 9
133.Sh HISTORY
134A
135.Nm
136file format appeared in
137.At v7 .
138