xref: /OK3568_Linux_fs/kernel/include/uapi/linux/acct.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  *  BSD Process Accounting for Linux - Definitions
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  *  Author: Marco van Wieringen (mvw@planets.elm.net)
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  *  This header file contains the definitions needed to implement
8*4882a593Smuzhiyun  *  BSD-style process accounting. The kernel accounting code and all
9*4882a593Smuzhiyun  *  user-level programs that try to do something useful with the
10*4882a593Smuzhiyun  *  process accounting log must include this file.
11*4882a593Smuzhiyun  *
12*4882a593Smuzhiyun  *  Copyright (C) 1995 - 1997 Marco van Wieringen - ELM Consultancy B.V.
13*4882a593Smuzhiyun  *
14*4882a593Smuzhiyun  */
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun #ifndef _UAPI_LINUX_ACCT_H
17*4882a593Smuzhiyun #define _UAPI_LINUX_ACCT_H
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun #include <linux/types.h>
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun #include <asm/param.h>
22*4882a593Smuzhiyun #include <asm/byteorder.h>
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun /*
25*4882a593Smuzhiyun  *  comp_t is a 16-bit "floating" point number with a 3-bit base 8
26*4882a593Smuzhiyun  *  exponent and a 13-bit fraction.
27*4882a593Smuzhiyun  *  comp2_t is 24-bit with 5-bit base 2 exponent and 20 bit fraction
28*4882a593Smuzhiyun  *  (leading 1 not stored).
29*4882a593Smuzhiyun  *  See linux/kernel/acct.c for the specific encoding systems used.
30*4882a593Smuzhiyun  */
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun typedef __u16	comp_t;
33*4882a593Smuzhiyun typedef __u32	comp2_t;
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun /*
36*4882a593Smuzhiyun  *   accounting file record
37*4882a593Smuzhiyun  *
38*4882a593Smuzhiyun  *   This structure contains all of the information written out to the
39*4882a593Smuzhiyun  *   process accounting file whenever a process exits.
40*4882a593Smuzhiyun  */
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun #define ACCT_COMM	16
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun struct acct
45*4882a593Smuzhiyun {
46*4882a593Smuzhiyun 	char		ac_flag;		/* Flags */
47*4882a593Smuzhiyun 	char		ac_version;		/* Always set to ACCT_VERSION */
48*4882a593Smuzhiyun 	/* for binary compatibility back until 2.0 */
49*4882a593Smuzhiyun 	__u16		ac_uid16;		/* LSB of Real User ID */
50*4882a593Smuzhiyun 	__u16		ac_gid16;		/* LSB of Real Group ID */
51*4882a593Smuzhiyun 	__u16		ac_tty;			/* Control Terminal */
52*4882a593Smuzhiyun 	/* __u32 range means times from 1970 to 2106 */
53*4882a593Smuzhiyun 	__u32		ac_btime;		/* Process Creation Time */
54*4882a593Smuzhiyun 	comp_t		ac_utime;		/* User Time */
55*4882a593Smuzhiyun 	comp_t		ac_stime;		/* System Time */
56*4882a593Smuzhiyun 	comp_t		ac_etime;		/* Elapsed Time */
57*4882a593Smuzhiyun 	comp_t		ac_mem;			/* Average Memory Usage */
58*4882a593Smuzhiyun 	comp_t		ac_io;			/* Chars Transferred */
59*4882a593Smuzhiyun 	comp_t		ac_rw;			/* Blocks Read or Written */
60*4882a593Smuzhiyun 	comp_t		ac_minflt;		/* Minor Pagefaults */
61*4882a593Smuzhiyun 	comp_t		ac_majflt;		/* Major Pagefaults */
62*4882a593Smuzhiyun 	comp_t		ac_swaps;		/* Number of Swaps */
63*4882a593Smuzhiyun /* m68k had no padding here. */
64*4882a593Smuzhiyun #if !defined(CONFIG_M68K) || !defined(__KERNEL__)
65*4882a593Smuzhiyun 	__u16		ac_ahz;			/* AHZ */
66*4882a593Smuzhiyun #endif
67*4882a593Smuzhiyun 	__u32		ac_exitcode;		/* Exitcode */
68*4882a593Smuzhiyun 	char		ac_comm[ACCT_COMM + 1];	/* Command Name */
69*4882a593Smuzhiyun 	__u8		ac_etime_hi;		/* Elapsed Time MSB */
70*4882a593Smuzhiyun 	__u16		ac_etime_lo;		/* Elapsed Time LSB */
71*4882a593Smuzhiyun 	__u32		ac_uid;			/* Real User ID */
72*4882a593Smuzhiyun 	__u32		ac_gid;			/* Real Group ID */
73*4882a593Smuzhiyun };
74*4882a593Smuzhiyun 
75*4882a593Smuzhiyun struct acct_v3
76*4882a593Smuzhiyun {
77*4882a593Smuzhiyun 	char		ac_flag;		/* Flags */
78*4882a593Smuzhiyun 	char		ac_version;		/* Always set to ACCT_VERSION */
79*4882a593Smuzhiyun 	__u16		ac_tty;			/* Control Terminal */
80*4882a593Smuzhiyun 	__u32		ac_exitcode;		/* Exitcode */
81*4882a593Smuzhiyun 	__u32		ac_uid;			/* Real User ID */
82*4882a593Smuzhiyun 	__u32		ac_gid;			/* Real Group ID */
83*4882a593Smuzhiyun 	__u32		ac_pid;			/* Process ID */
84*4882a593Smuzhiyun 	__u32		ac_ppid;		/* Parent Process ID */
85*4882a593Smuzhiyun 	/* __u32 range means times from 1970 to 2106 */
86*4882a593Smuzhiyun 	__u32		ac_btime;		/* Process Creation Time */
87*4882a593Smuzhiyun #ifdef __KERNEL__
88*4882a593Smuzhiyun 	__u32		ac_etime;		/* Elapsed Time */
89*4882a593Smuzhiyun #else
90*4882a593Smuzhiyun 	float		ac_etime;		/* Elapsed Time */
91*4882a593Smuzhiyun #endif
92*4882a593Smuzhiyun 	comp_t		ac_utime;		/* User Time */
93*4882a593Smuzhiyun 	comp_t		ac_stime;		/* System Time */
94*4882a593Smuzhiyun 	comp_t		ac_mem;			/* Average Memory Usage */
95*4882a593Smuzhiyun 	comp_t		ac_io;			/* Chars Transferred */
96*4882a593Smuzhiyun 	comp_t		ac_rw;			/* Blocks Read or Written */
97*4882a593Smuzhiyun 	comp_t		ac_minflt;		/* Minor Pagefaults */
98*4882a593Smuzhiyun 	comp_t		ac_majflt;		/* Major Pagefaults */
99*4882a593Smuzhiyun 	comp_t		ac_swaps;		/* Number of Swaps */
100*4882a593Smuzhiyun 	char		ac_comm[ACCT_COMM];	/* Command Name */
101*4882a593Smuzhiyun };
102*4882a593Smuzhiyun 
103*4882a593Smuzhiyun /*
104*4882a593Smuzhiyun  *  accounting flags
105*4882a593Smuzhiyun  */
106*4882a593Smuzhiyun 				/* bit set when the process ... */
107*4882a593Smuzhiyun #define AFORK		0x01	/* ... executed fork, but did not exec */
108*4882a593Smuzhiyun #define ASU		0x02	/* ... used super-user privileges */
109*4882a593Smuzhiyun #define ACOMPAT		0x04	/* ... used compatibility mode (VAX only not used) */
110*4882a593Smuzhiyun #define ACORE		0x08	/* ... dumped core */
111*4882a593Smuzhiyun #define AXSIG		0x10	/* ... was killed by a signal */
112*4882a593Smuzhiyun 
113*4882a593Smuzhiyun #if defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN)
114*4882a593Smuzhiyun #define ACCT_BYTEORDER	0x80	/* accounting file is big endian */
115*4882a593Smuzhiyun #elif defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN)
116*4882a593Smuzhiyun #define ACCT_BYTEORDER	0x00	/* accounting file is little endian */
117*4882a593Smuzhiyun #else
118*4882a593Smuzhiyun #error unspecified endianness
119*4882a593Smuzhiyun #endif
120*4882a593Smuzhiyun 
121*4882a593Smuzhiyun #ifndef __KERNEL__
122*4882a593Smuzhiyun #define ACCT_VERSION	2
123*4882a593Smuzhiyun #define AHZ		(HZ)
124*4882a593Smuzhiyun #endif	/* __KERNEL */
125*4882a593Smuzhiyun 
126*4882a593Smuzhiyun 
127*4882a593Smuzhiyun #endif /* _UAPI_LINUX_ACCT_H */
128