16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2607ca46eSDavid Howells /* 3607ca46eSDavid Howells * BSD Process Accounting for Linux - Definitions 4607ca46eSDavid Howells * 5607ca46eSDavid Howells * Author: Marco van Wieringen (mvw@planets.elm.net) 6607ca46eSDavid Howells * 7607ca46eSDavid Howells * This header file contains the definitions needed to implement 8607ca46eSDavid Howells * BSD-style process accounting. The kernel accounting code and all 9607ca46eSDavid Howells * user-level programs that try to do something useful with the 10607ca46eSDavid Howells * process accounting log must include this file. 11607ca46eSDavid Howells * 12607ca46eSDavid Howells * Copyright (C) 1995 - 1997 Marco van Wieringen - ELM Consultancy B.V. 13607ca46eSDavid Howells * 14607ca46eSDavid Howells */ 15607ca46eSDavid Howells 16607ca46eSDavid Howells #ifndef _UAPI_LINUX_ACCT_H 17607ca46eSDavid Howells #define _UAPI_LINUX_ACCT_H 18607ca46eSDavid Howells 19607ca46eSDavid Howells #include <linux/types.h> 20607ca46eSDavid Howells 21607ca46eSDavid Howells #include <asm/param.h> 22607ca46eSDavid Howells #include <asm/byteorder.h> 23607ca46eSDavid Howells 24607ca46eSDavid Howells /* 25607ca46eSDavid Howells * comp_t is a 16-bit "floating" point number with a 3-bit base 8 26607ca46eSDavid Howells * exponent and a 13-bit fraction. 27607ca46eSDavid Howells * comp2_t is 24-bit with 5-bit base 2 exponent and 20 bit fraction 28607ca46eSDavid Howells * (leading 1 not stored). 29607ca46eSDavid Howells * See linux/kernel/acct.c for the specific encoding systems used. 30607ca46eSDavid Howells */ 31607ca46eSDavid Howells 32607ca46eSDavid Howells typedef __u16 comp_t; 33607ca46eSDavid Howells typedef __u32 comp2_t; 34607ca46eSDavid Howells 35607ca46eSDavid Howells /* 36607ca46eSDavid Howells * accounting file record 37607ca46eSDavid Howells * 38607ca46eSDavid Howells * This structure contains all of the information written out to the 39607ca46eSDavid Howells * process accounting file whenever a process exits. 40607ca46eSDavid Howells */ 41607ca46eSDavid Howells 42607ca46eSDavid Howells #define ACCT_COMM 16 43607ca46eSDavid Howells 44607ca46eSDavid Howells struct acct 45607ca46eSDavid Howells { 46607ca46eSDavid Howells char ac_flag; /* Flags */ 47607ca46eSDavid Howells char ac_version; /* Always set to ACCT_VERSION */ 48607ca46eSDavid Howells /* for binary compatibility back until 2.0 */ 49607ca46eSDavid Howells __u16 ac_uid16; /* LSB of Real User ID */ 50607ca46eSDavid Howells __u16 ac_gid16; /* LSB of Real Group ID */ 51607ca46eSDavid Howells __u16 ac_tty; /* Control Terminal */ 522d602bf2SArnd Bergmann /* __u32 range means times from 1970 to 2106 */ 53607ca46eSDavid Howells __u32 ac_btime; /* Process Creation Time */ 54607ca46eSDavid Howells comp_t ac_utime; /* User Time */ 55607ca46eSDavid Howells comp_t ac_stime; /* System Time */ 56607ca46eSDavid Howells comp_t ac_etime; /* Elapsed Time */ 57607ca46eSDavid Howells comp_t ac_mem; /* Average Memory Usage */ 58607ca46eSDavid Howells comp_t ac_io; /* Chars Transferred */ 59607ca46eSDavid Howells comp_t ac_rw; /* Blocks Read or Written */ 60607ca46eSDavid Howells comp_t ac_minflt; /* Minor Pagefaults */ 61607ca46eSDavid Howells comp_t ac_majflt; /* Major Pagefaults */ 62607ca46eSDavid Howells comp_t ac_swaps; /* Number of Swaps */ 63607ca46eSDavid Howells /* m68k had no padding here. */ 64607ca46eSDavid Howells #if !defined(CONFIG_M68K) || !defined(__KERNEL__) 65607ca46eSDavid Howells __u16 ac_ahz; /* AHZ */ 66607ca46eSDavid Howells #endif 67607ca46eSDavid Howells __u32 ac_exitcode; /* Exitcode */ 68607ca46eSDavid Howells char ac_comm[ACCT_COMM + 1]; /* Command Name */ 69607ca46eSDavid Howells __u8 ac_etime_hi; /* Elapsed Time MSB */ 70607ca46eSDavid Howells __u16 ac_etime_lo; /* Elapsed Time LSB */ 71607ca46eSDavid Howells __u32 ac_uid; /* Real User ID */ 72607ca46eSDavid Howells __u32 ac_gid; /* Real Group ID */ 73607ca46eSDavid Howells }; 74607ca46eSDavid Howells 75607ca46eSDavid Howells struct acct_v3 76607ca46eSDavid Howells { 77607ca46eSDavid Howells char ac_flag; /* Flags */ 78607ca46eSDavid Howells char ac_version; /* Always set to ACCT_VERSION */ 79607ca46eSDavid Howells __u16 ac_tty; /* Control Terminal */ 80607ca46eSDavid Howells __u32 ac_exitcode; /* Exitcode */ 81607ca46eSDavid Howells __u32 ac_uid; /* Real User ID */ 82607ca46eSDavid Howells __u32 ac_gid; /* Real Group ID */ 83607ca46eSDavid Howells __u32 ac_pid; /* Process ID */ 84607ca46eSDavid Howells __u32 ac_ppid; /* Parent Process ID */ 852d602bf2SArnd Bergmann /* __u32 range means times from 1970 to 2106 */ 86607ca46eSDavid Howells __u32 ac_btime; /* Process Creation Time */ 87607ca46eSDavid Howells #ifdef __KERNEL__ 88607ca46eSDavid Howells __u32 ac_etime; /* Elapsed Time */ 89607ca46eSDavid Howells #else 90607ca46eSDavid Howells float ac_etime; /* Elapsed Time */ 91607ca46eSDavid Howells #endif 92607ca46eSDavid Howells comp_t ac_utime; /* User Time */ 93607ca46eSDavid Howells comp_t ac_stime; /* System Time */ 94607ca46eSDavid Howells comp_t ac_mem; /* Average Memory Usage */ 95607ca46eSDavid Howells comp_t ac_io; /* Chars Transferred */ 96607ca46eSDavid Howells comp_t ac_rw; /* Blocks Read or Written */ 97607ca46eSDavid Howells comp_t ac_minflt; /* Minor Pagefaults */ 98607ca46eSDavid Howells comp_t ac_majflt; /* Major Pagefaults */ 99607ca46eSDavid Howells comp_t ac_swaps; /* Number of Swaps */ 100607ca46eSDavid Howells char ac_comm[ACCT_COMM]; /* Command Name */ 101607ca46eSDavid Howells }; 102607ca46eSDavid Howells 103607ca46eSDavid Howells /* 104607ca46eSDavid Howells * accounting flags 105607ca46eSDavid Howells */ 106*0e0af57eSDr. Thomas Orgis /* bit set when the process/task ... */ 107607ca46eSDavid Howells #define AFORK 0x01 /* ... executed fork, but did not exec */ 108607ca46eSDavid Howells #define ASU 0x02 /* ... used super-user privileges */ 109607ca46eSDavid Howells #define ACOMPAT 0x04 /* ... used compatibility mode (VAX only not used) */ 110607ca46eSDavid Howells #define ACORE 0x08 /* ... dumped core */ 111607ca46eSDavid Howells #define AXSIG 0x10 /* ... was killed by a signal */ 112*0e0af57eSDr. Thomas Orgis #define AGROUP 0x20 /* ... was the last task of the process (task group) */ 113607ca46eSDavid Howells 11429ba06b9SDavid Howells #if defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN) 115607ca46eSDavid Howells #define ACCT_BYTEORDER 0x80 /* accounting file is big endian */ 11629ba06b9SDavid Howells #elif defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN) 117607ca46eSDavid Howells #define ACCT_BYTEORDER 0x00 /* accounting file is little endian */ 11829ba06b9SDavid Howells #else 11929ba06b9SDavid Howells #error unspecified endianness 120607ca46eSDavid Howells #endif 121607ca46eSDavid Howells 122607ca46eSDavid Howells #ifndef __KERNEL__ 123607ca46eSDavid Howells #define ACCT_VERSION 2 124607ca46eSDavid Howells #define AHZ (HZ) 125607ca46eSDavid Howells #endif /* __KERNEL */ 126607ca46eSDavid Howells 127607ca46eSDavid Howells 128607ca46eSDavid Howells #endif /* _UAPI_LINUX_ACCT_H */ 129