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