2 * BSD Process Accounting for Linux - Definitions
4 * Author: Marco van Wieringen (mvw@planets.elm.net)
6 * This header file contains the definitions needed to implement
7 * BSD-style process accounting. The kernel accounting code and all
8 * user-level programs that try to do something useful with the
9 * process accounting log must include this file.
11 * Copyright (C) 1995 - 1997 Marco van Wieringen - ELM Consultancy B.V.
18 #include <linux/types.h>
19 #include <asm/param.h>
22 * comp_t is a 16-bit "floating" point number with a 3-bit base 8
23 * exponent and a 13-bit fraction.
24 * comp2_t is 24-bit with 5-bit base 2 exponent and 20 bit fraction
25 * (leading 1 not stored).
26 * See linux/kernel/acct.c for the specific encoding systems used.
30 typedef __u32 comp2_t;
33 * accounting file record
35 * This structure contains all of the information written out to the
36 * process accounting file whenever a process exits.
43 char ac_flag; /* Flags */
44 char ac_version; /* Always set to ACCT_VERSION */
45 /* for binary compatibility back until 2.0 */
46 __u16 ac_uid16; /* LSB of Real User ID */
47 __u16 ac_gid16; /* LSB of Real Group ID */
48 __u16 ac_tty; /* Control Terminal */
49 __u32 ac_btime; /* Process Creation Time */
50 comp_t ac_utime; /* User Time */
51 comp_t ac_stime; /* System Time */
52 comp_t ac_etime; /* Elapsed Time */
53 comp_t ac_mem; /* Average Memory Usage */
54 comp_t ac_io; /* Chars Transferred */
55 comp_t ac_rw; /* Blocks Read or Written */
56 comp_t ac_minflt; /* Minor Pagefaults */
57 comp_t ac_majflt; /* Major Pagefaults */
58 comp_t ac_swaps; /* Number of Swaps */
59 /* m68k had no padding here. */
60 #if !defined(CONFIG_M68K) || !defined(__KERNEL__)
61 __u16 ac_ahz; /* AHZ */
63 __u32 ac_exitcode; /* Exitcode */
64 char ac_comm[ACCT_COMM + 1]; /* Command Name */
65 __u8 ac_etime_hi; /* Elapsed Time MSB */
66 __u16 ac_etime_lo; /* Elapsed Time LSB */
67 __u32 ac_uid; /* Real User ID */
68 __u32 ac_gid; /* Real Group ID */
73 char ac_flag; /* Flags */
74 char ac_version; /* Always set to ACCT_VERSION */
75 __u16 ac_tty; /* Control Terminal */
76 __u32 ac_exitcode; /* Exitcode */
77 __u32 ac_uid; /* Real User ID */
78 __u32 ac_gid; /* Real Group ID */
79 __u32 ac_pid; /* Process ID */
80 __u32 ac_ppid; /* Parent Process ID */
81 __u32 ac_btime; /* Process Creation Time */
83 __u32 ac_etime; /* Elapsed Time */
85 float ac_etime; /* Elapsed Time */
87 comp_t ac_utime; /* User Time */
88 comp_t ac_stime; /* System Time */
89 comp_t ac_mem; /* Average Memory Usage */
90 comp_t ac_io; /* Chars Transferred */
91 comp_t ac_rw; /* Blocks Read or Written */
92 comp_t ac_minflt; /* Minor Pagefaults */
93 comp_t ac_majflt; /* Major Pagefaults */
94 comp_t ac_swaps; /* Number of Swaps */
95 char ac_comm[ACCT_COMM]; /* Command Name */
101 /* bit set when the process ... */
102 #define AFORK 0x01 /* ... executed fork, but did not exec */
103 #define ASU 0x02 /* ... used super-user privileges */
104 #define ACOMPAT 0x04 /* ... used compatibility mode (VAX only not used) */
105 #define ACORE 0x08 /* ... dumped core */
106 #define AXSIG 0x10 /* ... was killed by a signal */
107 #define ABYTESEX 0x80 /* always set, allows to detect byteorder */
111 #include <linux/config.h>
113 #ifdef CONFIG_BSD_PROCESS_ACCT
115 extern void acct_auto_close(struct super_block *sb);
116 extern void acct_process(long exitcode);
118 #define acct_auto_close(x) do { } while (0)
119 #define acct_process(x) do { } while (0)
123 * ACCT_VERSION numbers as yet defined:
124 * 0: old format (until 2.6.7) with 16 bit uid/gid
125 * 1: extended variant (binary compatible on M68K)
126 * 2: extended variant (binary compatible on everything except M68K)
127 * 3: new binary incompatible format (64 bytes)
128 * 4: new binary incompatible format (128 bytes)
129 * 5: new binary incompatible format (128 bytes, second half)
133 #ifdef CONFIG_BSD_PROCESS_ACCT_V3
134 #define ACCT_VERSION 3
136 typedef struct acct_v3 acct_t;
139 #define ACCT_VERSION 1
141 #define ACCT_VERSION 2
143 #define AHZ (USER_HZ)
144 typedef struct acct acct_t;
148 #define ACCT_VERSION 2
150 #endif /* __KERNEL */
154 * Yet another set of HZ to *HZ helper functions.
155 * See <linux/times.h> for the original.
158 static inline u32 jiffies_to_AHZ(unsigned long x)
160 #if (TICK_NSEC % (NSEC_PER_SEC / AHZ)) == 0
161 return x / (HZ / USER_HZ);
163 u64 tmp = (u64)x * TICK_NSEC;
164 do_div(tmp, (NSEC_PER_SEC / AHZ));
169 static inline u64 jiffies_64_to_AHZ(u64 x)
171 #if (TICK_NSEC % (NSEC_PER_SEC / AHZ)) == 0
177 do_div(x, (NSEC_PER_SEC / AHZ));
182 #endif /* __KERNEL */
184 #endif /* _LINUX_ACCT_H */