acct.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. #ifndef _LINUX_ACCT_H
  15. #define _LINUX_ACCT_H
  16. #include <linux/types.h>
  17. #include <asm/param.h>
  18. #include <asm/byteorder.h>
  19. /*
  20. * comp_t is a 16-bit "floating" point number with a 3-bit base 8
  21. * exponent and a 13-bit fraction.
  22. * comp2_t is 24-bit with 5-bit base 2 exponent and 20 bit fraction
  23. * (leading 1 not stored).
  24. * See linux/kernel/acct.c for the specific encoding systems used.
  25. */
  26. typedef __u16 comp_t;
  27. typedef __u32 comp2_t;
  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. #define ACCT_COMM 16
  35. struct acct
  36. {
  37. char ac_flag; /* Flags */
  38. char ac_version; /* Always set to ACCT_VERSION */
  39. /* for binary compatibility back until 2.0 */
  40. __u16 ac_uid16; /* LSB of Real User ID */
  41. __u16 ac_gid16; /* LSB of Real Group ID */
  42. __u16 ac_tty; /* Control Terminal */
  43. __u32 ac_btime; /* Process Creation Time */
  44. comp_t ac_utime; /* User Time */
  45. comp_t ac_stime; /* System Time */
  46. comp_t ac_etime; /* Elapsed Time */
  47. comp_t ac_mem; /* Average Memory Usage */
  48. comp_t ac_io; /* Chars Transferred */
  49. comp_t ac_rw; /* Blocks Read or Written */
  50. comp_t ac_minflt; /* Minor Pagefaults */
  51. comp_t ac_majflt; /* Major Pagefaults */
  52. comp_t ac_swaps; /* Number of Swaps */
  53. /* m68k had no padding here. */
  54. __u16 ac_ahz; /* AHZ */
  55. __u32 ac_exitcode; /* Exitcode */
  56. char ac_comm[ACCT_COMM + 1]; /* Command Name */
  57. __u8 ac_etime_hi; /* Elapsed Time MSB */
  58. __u16 ac_etime_lo; /* Elapsed Time LSB */
  59. __u32 ac_uid; /* Real User ID */
  60. __u32 ac_gid; /* Real Group ID */
  61. };
  62. struct acct_v3
  63. {
  64. char ac_flag; /* Flags */
  65. char ac_version; /* Always set to ACCT_VERSION */
  66. __u16 ac_tty; /* Control Terminal */
  67. __u32 ac_exitcode; /* Exitcode */
  68. __u32 ac_uid; /* Real User ID */
  69. __u32 ac_gid; /* Real Group ID */
  70. __u32 ac_pid; /* Process ID */
  71. __u32 ac_ppid; /* Parent Process ID */
  72. __u32 ac_btime; /* Process Creation Time */
  73. float ac_etime; /* Elapsed Time */
  74. comp_t ac_utime; /* User Time */
  75. comp_t ac_stime; /* System Time */
  76. comp_t ac_mem; /* Average Memory Usage */
  77. comp_t ac_io; /* Chars Transferred */
  78. comp_t ac_rw; /* Blocks Read or Written */
  79. comp_t ac_minflt; /* Minor Pagefaults */
  80. comp_t ac_majflt; /* Major Pagefaults */
  81. comp_t ac_swaps; /* Number of Swaps */
  82. char ac_comm[ACCT_COMM]; /* Command Name */
  83. };
  84. /*
  85. * accounting flags
  86. */
  87. /* bit set when the process ... */
  88. #define AFORK 0x01 /* ... executed fork, but did not exec */
  89. #define ASU 0x02 /* ... used super-user privileges */
  90. #define ACOMPAT 0x04 /* ... used compatibility mode (VAX only not used) */
  91. #define ACORE 0x08 /* ... dumped core */
  92. #define AXSIG 0x10 /* ... was killed by a signal */
  93. #if defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN)
  94. #define ACCT_BYTEORDER 0x80 /* accounting file is big endian */
  95. #elif defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN)
  96. #define ACCT_BYTEORDER 0x00 /* accounting file is little endian */
  97. #else
  98. #error unspecified endianness
  99. #endif
  100. #define ACCT_VERSION 2
  101. #define AHZ (HZ)
  102. #endif /* _LINUX_ACCT_H */