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>
20 #include <asm/byteorder.h>
23 * comp_t is a 16-bit "floating" point number with a 3-bit base 8
24 * exponent and a 13-bit fraction.
25 * comp2_t is 24-bit with 5-bit base 2 exponent and 20 bit fraction
26 * (leading 1 not stored).
27 * See linux/kernel/acct.c for the specific encoding systems used.
31 typedef __u32 comp2_t;
34 * accounting file record
36 * This structure contains all of the information written out to the
37 * process accounting file whenever a process exits.
44 char ac_flag; /* Flags */
45 char ac_version; /* Always set to ACCT_VERSION */
46 /* for binary compatibility back until 2.0 */
47 __u16 ac_uid16; /* LSB of Real User ID */
48 __u16 ac_gid16; /* LSB of Real Group ID */
49 __u16 ac_tty; /* Control Terminal */
50 __u32 ac_btime; /* Process Creation Time */
51 comp_t ac_utime; /* User Time */
52 comp_t ac_stime; /* System Time */
53 comp_t ac_etime; /* Elapsed Time */
54 comp_t ac_mem; /* Average Memory Usage */
55 comp_t ac_io; /* Chars Transferred */
56 comp_t ac_rw; /* Blocks Read or Written */
57 comp_t ac_minflt; /* Minor Pagefaults */
58 comp_t ac_majflt; /* Major Pagefaults */
59 comp_t ac_swaps; /* Number of Swaps */
60 /* m68k had no padding here. */
61 #if !defined(CONFIG_M68K) || !defined(__KERNEL__)
62 __u16 ac_ahz; /* AHZ */
64 __u32 ac_exitcode; /* Exitcode */
65 char ac_comm[ACCT_COMM + 1]; /* Command Name */
66 __u8 ac_etime_hi; /* Elapsed Time MSB */
67 __u16 ac_etime_lo; /* Elapsed Time LSB */
68 __u32 ac_uid; /* Real User ID */
69 __u32 ac_gid; /* Real Group ID */
74 char ac_flag; /* Flags */
75 char ac_version; /* Always set to ACCT_VERSION */
76 __u16 ac_tty; /* Control Terminal */
77 __u32 ac_exitcode; /* Exitcode */
78 __u32 ac_uid; /* Real User ID */
79 __u32 ac_gid; /* Real Group ID */
80 __u32 ac_pid; /* Process ID */
81 __u32 ac_ppid; /* Parent Process ID */
82 __u32 ac_btime; /* Process Creation Time */
84 __u32 ac_etime; /* Elapsed Time */
86 float ac_etime; /* Elapsed Time */
88 comp_t ac_utime; /* User Time */
89 comp_t ac_stime; /* System Time */
90 comp_t ac_mem; /* Average Memory Usage */
91 comp_t ac_io; /* Chars Transferred */
92 comp_t ac_rw; /* Blocks Read or Written */
93 comp_t ac_minflt; /* Minor Pagefaults */
94 comp_t ac_majflt; /* Major Pagefaults */
95 comp_t ac_swaps; /* Number of Swaps */
96 char ac_comm[ACCT_COMM]; /* Command Name */
102 /* bit set when the process ... */
103 #define AFORK 0x01 /* ... executed fork, but did not exec */
104 #define ASU 0x02 /* ... used super-user privileges */
105 #define ACOMPAT 0x04 /* ... used compatibility mode (VAX only not used) */
106 #define ACORE 0x08 /* ... dumped core */
107 #define AXSIG 0x10 /* ... was killed by a signal */
110 #define ACCT_BYTEORDER 0x80 /* accounting file is big endian */
112 #define ACCT_BYTEORDER 0x00 /* accounting file is little endian */
117 #include <linux/config.h>
119 #ifdef CONFIG_BSD_PROCESS_ACCT
121 extern void acct_auto_close(struct super_block *sb);
122 extern void acct_process(long exitcode);
124 #define acct_auto_close(x) do { } while (0)
125 #define acct_process(x) do { } while (0)
129 * ACCT_VERSION numbers as yet defined:
130 * 0: old format (until 2.6.7) with 16 bit uid/gid
131 * 1: extended variant (binary compatible on M68K)
132 * 2: extended variant (binary compatible on everything except M68K)
133 * 3: new binary incompatible format (64 bytes)
134 * 4: new binary incompatible format (128 bytes)
135 * 5: new binary incompatible format (128 bytes, second half)
139 #ifdef CONFIG_BSD_PROCESS_ACCT_V3
140 #define ACCT_VERSION 3
142 typedef struct acct_v3 acct_t;
145 #define ACCT_VERSION 1
147 #define ACCT_VERSION 2
149 #define AHZ (USER_HZ)
150 typedef struct acct acct_t;
154 #define ACCT_VERSION 2
156 #endif /* __KERNEL */
160 * Yet another set of HZ to *HZ helper functions.
161 * See <linux/times.h> for the original.
164 static inline u32 jiffies_to_AHZ(unsigned long x)
166 #if (TICK_NSEC % (NSEC_PER_SEC / AHZ)) == 0
167 return x / (HZ / USER_HZ);
169 u64 tmp = (u64)x * TICK_NSEC;
170 do_div(tmp, (NSEC_PER_SEC / AHZ));
175 static inline u64 jiffies_64_to_AHZ(u64 x)
177 #if (TICK_NSEC % (NSEC_PER_SEC / AHZ)) == 0
183 do_div(x, (NSEC_PER_SEC / AHZ));
188 #endif /* __KERNEL */
190 #endif /* _LINUX_ACCT_H */