1 /*
2  *  BSD Process Accounting for Linux - Definitions
3  *
4  *  Author: Marco van Wieringen (mvw@planets.elm.net)
5  *
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.
10  *
11  *  Copyright (C) 1995 - 1997 Marco van Wieringen - ELM Consultancy B.V.
12  *
13  */
14 
15 #ifndef _LINUX_ACCT_H
16 #define _LINUX_ACCT_H
17 
18 #include <linux/types.h>
19 
20 /*
21  *  comp_t is a 16-bit "floating" point number with a 3-bit base 8
22  *  exponent and a 13-bit fraction. See linux/kernel/acct.c for the
23  *  specific encoding system used.
24  */
25 
26 typedef __u16	comp_t;
27 
28 /*
29  *   accounting file record
30  *
31  *   This structure contains all of the information written out to the
32  *   process accounting file whenever a process exits.
33  */
34 
35 #define ACCT_COMM	16
36 
37 struct acct
38 {
39 	char		ac_flag;		/* Accounting Flags */
40 /*
41  *	No binary format break with 2.0 - but when we hit 32bit uid we'll
42  *	have to bite one
43  */
44 	__u16		ac_uid;			/* Accounting Real User ID */
45 	__u16		ac_gid;			/* Accounting Real Group ID */
46 	__u16		ac_tty;			/* Accounting Control Terminal */
47 	__u32		ac_btime;		/* Accounting Process Creation Time */
48 	comp_t		ac_utime;		/* Accounting User Time */
49 	comp_t		ac_stime;		/* Accounting System Time */
50 	comp_t		ac_etime;		/* Accounting Elapsed Time */
51 	comp_t		ac_mem;			/* Accounting Average Memory Usage */
52 	comp_t		ac_io;			/* Accounting Chars Transferred */
53 	comp_t		ac_rw;			/* Accounting Blocks Read or Written */
54 	comp_t		ac_minflt;		/* Accounting Minor Pagefaults */
55 	comp_t		ac_majflt;		/* Accounting Major Pagefaults */
56 	comp_t		ac_swaps;		/* Accounting Number of Swaps */
57 	__u32		ac_exitcode;		/* Accounting Exitcode */
58 	char		ac_comm[ACCT_COMM + 1];	/* Accounting Command Name */
59 	char		ac_pad[10];		/* Accounting Padding Bytes */
60 };
61 
62 /*
63  *  accounting flags
64  */
65 				/* bit set when the process ... */
66 #define AFORK		0x01	/* ... executed fork, but did not exec */
67 #define ASU		0x02	/* ... used super-user privileges */
68 #define ACOMPAT		0x04	/* ... used compatibility mode (VAX only not used) */
69 #define ACORE		0x08	/* ... dumped core */
70 #define AXSIG		0x10	/* ... was killed by a signal */
71 
72 #define AHZ		100
73 
74 #ifdef __KERNEL__
75 
76 #include <linux/config.h>
77 
78 #ifdef CONFIG_BSD_PROCESS_ACCT
79 extern void acct_auto_close(kdev_t dev);
80 extern int acct_process(long exitcode);
81 #else
82 #define acct_auto_close(x)	do { } while (0)
83 #define acct_process(x)		do { } while (0)
84 #endif
85 
86 #endif	/* __KERNEL */
87 
88 #endif	/* _LINUX_ACCT_H */
89