acct.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * BSD Process Accounting for Linux - Definitions
  4. *
  5. * Author: Marco van Wieringen ([email protected])
  6. *
  7. * This header file contains the definitions needed to implement
  8. * BSD-style process accounting. The kernel accounting code and all
  9. * user-level programs that try to do something useful with the
  10. * process accounting log must include this file.
  11. *
  12. * Copyright (C) 1995 - 1997 Marco van Wieringen - ELM Consultancy B.V.
  13. *
  14. */
  15. #ifndef _UAPI_LINUX_ACCT_H
  16. #define _UAPI_LINUX_ACCT_H
  17. #include <linux/types.h>
  18. #include <asm/param.h>
  19. #include <asm/byteorder.h>
  20. /*
  21. * comp_t is a 16-bit "floating" point number with a 3-bit base 8
  22. * exponent and a 13-bit fraction.
  23. * comp2_t is 24-bit with 5-bit base 2 exponent and 20 bit fraction
  24. * (leading 1 not stored).
  25. * See linux/kernel/acct.c for the specific encoding systems used.
  26. */
  27. typedef __u16 comp_t;
  28. typedef __u32 comp2_t;
  29. /*
  30. * accounting file record
  31. *
  32. * This structure contains all of the information written out to the
  33. * process accounting file whenever a process exits.
  34. */
  35. #define ACCT_COMM 16
  36. struct acct
  37. {
  38. char ac_flag; /* Flags */
  39. char ac_version; /* Always set to ACCT_VERSION */
  40. /* for binary compatibility back until 2.0 */
  41. __u16 ac_uid16; /* LSB of Real User ID */
  42. __u16 ac_gid16; /* LSB of Real Group ID */
  43. __u16 ac_tty; /* Control Terminal */
  44. /* __u32 range means times from 1970 to 2106 */
  45. __u32 ac_btime; /* Process Creation Time */
  46. comp_t ac_utime; /* User Time */
  47. comp_t ac_stime; /* System Time */
  48. comp_t ac_etime; /* Elapsed Time */
  49. comp_t ac_mem; /* Average Memory Usage */
  50. comp_t ac_io; /* Chars Transferred */
  51. comp_t ac_rw; /* Blocks Read or Written */
  52. comp_t ac_minflt; /* Minor Pagefaults */
  53. comp_t ac_majflt; /* Major Pagefaults */
  54. comp_t ac_swaps; /* Number of Swaps */
  55. /* m68k had no padding here. */
  56. #if !defined(CONFIG_M68K) || !defined(__KERNEL__)
  57. __u16 ac_ahz; /* AHZ */
  58. #endif
  59. __u32 ac_exitcode; /* Exitcode */
  60. char ac_comm[ACCT_COMM + 1]; /* Command Name */
  61. __u8 ac_etime_hi; /* Elapsed Time MSB */
  62. __u16 ac_etime_lo; /* Elapsed Time LSB */
  63. __u32 ac_uid; /* Real User ID */
  64. __u32 ac_gid; /* Real Group ID */
  65. };
  66. struct acct_v3
  67. {
  68. char ac_flag; /* Flags */
  69. char ac_version; /* Always set to ACCT_VERSION */
  70. __u16 ac_tty; /* Control Terminal */
  71. __u32 ac_exitcode; /* Exitcode */
  72. __u32 ac_uid; /* Real User ID */
  73. __u32 ac_gid; /* Real Group ID */
  74. __u32 ac_pid; /* Process ID */
  75. __u32 ac_ppid; /* Parent Process ID */
  76. /* __u32 range means times from 1970 to 2106 */
  77. __u32 ac_btime; /* Process Creation Time */
  78. #ifdef __KERNEL__
  79. __u32 ac_etime; /* Elapsed Time */
  80. #else
  81. float ac_etime; /* Elapsed Time */
  82. #endif
  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. * accounting flags
  95. */
  96. /* bit set when the process/task ... */
  97. #define AFORK 0x01 /* ... executed fork, but did not exec */
  98. #define ASU 0x02 /* ... used super-user privileges */
  99. #define ACOMPAT 0x04 /* ... used compatibility mode (VAX only not used) */
  100. #define ACORE 0x08 /* ... dumped core */
  101. #define AXSIG 0x10 /* ... was killed by a signal */
  102. #define AGROUP 0x20 /* ... was the last task of the process (task group) */
  103. #if defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN)
  104. #define ACCT_BYTEORDER 0x80 /* accounting file is big endian */
  105. #elif defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN)
  106. #define ACCT_BYTEORDER 0x00 /* accounting file is little endian */
  107. #else
  108. #error unspecified endianness
  109. #endif
  110. #ifndef __KERNEL__
  111. #define ACCT_VERSION 2
  112. #define AHZ (HZ)
  113. #endif /* __KERNEL */
  114. #endif /* _UAPI_LINUX_ACCT_H */