Home | History | Annotate | Download | only in linux
      1 /*
      2  *  BSD Process Accounting for Linux - Definitions
      3  *
      4  *  Author: Marco van Wieringen (mvw (at) 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 #include <asm/param.h>
     21 #include <asm/byteorder.h>
     22 
     23 /*
     24  *  comp_t is a 16-bit "floating" point number with a 3-bit base 8
     25  *  exponent and a 13-bit fraction.
     26  *  comp2_t is 24-bit with 5-bit base 2 exponent and 20 bit fraction
     27  *  (leading 1 not stored).
     28  *  See linux/kernel/acct.c for the specific encoding systems used.
     29  */
     30 
     31 typedef __u16	comp_t;
     32 typedef __u32	comp2_t;
     33 
     34 /*
     35  *   accounting file record
     36  *
     37  *   This structure contains all of the information written out to the
     38  *   process accounting file whenever a process exits.
     39  */
     40 
     41 #define ACCT_COMM	16
     42 
     43 struct acct
     44 {
     45 	char		ac_flag;		/* Flags */
     46 	char		ac_version;		/* Always set to ACCT_VERSION */
     47 	/* for binary compatibility back until 2.0 */
     48 	__u16		ac_uid16;		/* LSB of Real User ID */
     49 	__u16		ac_gid16;		/* LSB of Real Group ID */
     50 	__u16		ac_tty;			/* Control Terminal */
     51 	__u32		ac_btime;		/* Process Creation Time */
     52 	comp_t		ac_utime;		/* User Time */
     53 	comp_t		ac_stime;		/* System Time */
     54 	comp_t		ac_etime;		/* Elapsed Time */
     55 	comp_t		ac_mem;			/* Average Memory Usage */
     56 	comp_t		ac_io;			/* Chars Transferred */
     57 	comp_t		ac_rw;			/* Blocks Read or Written */
     58 	comp_t		ac_minflt;		/* Minor Pagefaults */
     59 	comp_t		ac_majflt;		/* Major Pagefaults */
     60 	comp_t		ac_swaps;		/* Number of Swaps */
     61 /* m68k had no padding here. */
     62 	__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 */
     69 };
     70 
     71 struct acct_v3
     72 {
     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 */
     82 	float		ac_etime;		/* Elapsed Time */
     83 	comp_t		ac_utime;		/* User Time */
     84 	comp_t		ac_stime;		/* System Time */
     85 	comp_t		ac_mem;			/* Average Memory Usage */
     86 	comp_t		ac_io;			/* Chars Transferred */
     87 	comp_t		ac_rw;			/* Blocks Read or Written */
     88 	comp_t		ac_minflt;		/* Minor Pagefaults */
     89 	comp_t		ac_majflt;		/* Major Pagefaults */
     90 	comp_t		ac_swaps;		/* Number of Swaps */
     91 	char		ac_comm[ACCT_COMM];	/* Command Name */
     92 };
     93 
     94 /*
     95  *  accounting flags
     96  */
     97 				/* bit set when the process ... */
     98 #define AFORK		0x01	/* ... executed fork, but did not exec */
     99 #define ASU		0x02	/* ... used super-user privileges */
    100 #define ACOMPAT		0x04	/* ... used compatibility mode (VAX only not used) */
    101 #define ACORE		0x08	/* ... dumped core */
    102 #define AXSIG		0x10	/* ... was killed by a signal */
    103 
    104 #ifdef __BIG_ENDIAN
    105 #define ACCT_BYTEORDER	0x80	/* accounting file is big endian */
    106 #else
    107 #define ACCT_BYTEORDER	0x00	/* accounting file is little endian */
    108 #endif
    109 
    110 #define ACCT_VERSION	2
    111 #define AHZ		(HZ)
    112 
    113 
    114 #endif	/* _LINUX_ACCT_H */
    115