• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //SPDX-License-Identifier: GPL-2.0-or-later
2 
3 #ifndef LAPI_ACCT_H
4 #define LAPI_ACCT_H
5 
6 #include <sys/types.h>
7 #include "config.h"
8 
9 #ifdef HAVE_STRUCT_ACCT_V3
10 #include <sys/acct.h>
11 #else
12 
13 #define ACCT_COMM 16
14 
15 typedef uint16_t comp_t;
16 
17 /* Fallback structures to parse the process accounting file */
18 struct acct {
19 	char ac_flag;
20 	uint16_t ac_uid;
21 	uint16_t ac_gid;
22 	uint16_t ac_tty;
23 	uint32_t ac_btime;
24 	comp_t    ac_utime;
25 	comp_t    ac_stime;
26 	comp_t    ac_etime;
27 	comp_t    ac_mem;
28 	comp_t    ac_io;
29 	comp_t    ac_rw;
30 	comp_t    ac_minflt;
31 	comp_t    ac_majflt;
32 	comp_t    ac_swaps;
33 	uint32_t ac_exitcode;
34 	char      ac_comm[ACCT_COMM+1];
35 	char      ac_pad[10];
36 };
37 
38 struct acct_v3 {
39 	char      ac_flag;
40 	char      ac_version;
41 	uint16_t ac_tty;
42 	uint32_t ac_exitcode;
43 	uint32_t ac_uid;
44 	uint32_t ac_gid;
45 	uint32_t ac_pid;
46 	uint32_t ac_ppid;
47 	uint32_t ac_btime;
48 	float     ac_etime;
49 	comp_t    ac_utime;
50 	comp_t    ac_stime;
51 	comp_t    ac_mem;
52 	comp_t    ac_io;
53 	comp_t    ac_rw;
54 	comp_t    ac_minflt;
55 	comp_t    ac_majflt;
56 	comp_t    ac_swaps;
57 	char      ac_comm[ACCT_COMM];
58 };
59 
60 /* Possible values for the ac_flag member */
61 enum {
62 	AFORK = 0x01,
63 	ASU   = 0x02,
64 	ACORE = 0x08,
65 	AXSIG = 0x10
66 };
67 # if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
68 # define ACCT_BYTEORDER  0x80
69 # elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
70 # define ACCT_BYTEORDER  0x00
71 # endif
72 #endif /* HAVE_STRUCT_ACCT_V3 */
73 
74 #endif /* LAPI_ACCT_H */
75