1
0

acct.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* Copyright (C) 1996-2026 Free Software Foundation, Inc.
  17. This file is part of the GNU C Library.
  18. The GNU C Library is free software; you can redistribute it and/or
  19. modify it under the terms of the GNU Lesser General Public
  20. License as published by the Free Software Foundation; either
  21. version 2.1 of the License, or (at your option) any later version.
  22. The GNU C Library is distributed in the hope that it will be useful,
  23. but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  25. Lesser General Public License for more details.
  26. You should have received a copy of the GNU Lesser General Public
  27. License along with the GNU C Library; if not, see
  28. <https://www.gnu.org/licenses/>. */
  29. #ifndef _SYS_ACCT_H
  30. #define _SYS_ACCT_H 1
  31. #include <sys/types.h>
  32. #include <stdint.h>
  33. #include <bits/endian.h>
  34. #include <bits/types/time_t.h>
  35. __BEGIN_DECLS
  36. #define ACCT_COMM 16
  37. /*
  38. comp_t is a 16-bit "floating" point number with a 3-bit base 8
  39. exponent and a 13-bit fraction. See linux/kernel/acct.c for the
  40. specific encoding system used.
  41. */
  42. typedef uint16_t comp_t;
  43. struct acct
  44. {
  45. char ac_flag; /* Flags. */
  46. uint16_t ac_uid; /* Real user ID. */
  47. uint16_t ac_gid; /* Real group ID. */
  48. uint16_t ac_tty; /* Controlling terminal. */
  49. uint32_t ac_btime; /* Beginning time. */
  50. comp_t ac_utime; /* User time. */
  51. comp_t ac_stime; /* System time. */
  52. comp_t ac_etime; /* Elapsed time. */
  53. comp_t ac_mem; /* Average memory usage. */
  54. comp_t ac_io; /* Chars transferred. */
  55. comp_t ac_rw; /* Blocks read or written. */
  56. comp_t ac_minflt; /* Minor pagefaults. */
  57. comp_t ac_majflt; /* Major pagefaults. */
  58. comp_t ac_swaps; /* Number of swaps. */
  59. uint32_t ac_exitcode; /* Process exitcode. */
  60. char ac_comm[ACCT_COMM+1]; /* Command name. */
  61. char ac_pad[10]; /* Padding bytes. */
  62. };
  63. struct acct_v3
  64. {
  65. char ac_flag; /* Flags */
  66. char ac_version; /* Always set to ACCT_VERSION */
  67. uint16_t ac_tty; /* Control Terminal */
  68. uint32_t ac_exitcode; /* Exitcode */
  69. uint32_t ac_uid; /* Real User ID */
  70. uint32_t ac_gid; /* Real Group ID */
  71. uint32_t ac_pid; /* Process ID */
  72. uint32_t ac_ppid; /* Parent Process ID */
  73. uint32_t ac_btime; /* Process Creation Time */
  74. float ac_etime; /* Elapsed Time */
  75. comp_t ac_utime; /* User Time */
  76. comp_t ac_stime; /* System Time */
  77. comp_t ac_mem; /* Average Memory Usage */
  78. comp_t ac_io; /* Chars Transferred */
  79. comp_t ac_rw; /* Blocks Read or Written */
  80. comp_t ac_minflt; /* Minor Pagefaults */
  81. comp_t ac_majflt; /* Major Pagefaults */
  82. comp_t ac_swaps; /* Number of Swaps */
  83. char ac_comm[ACCT_COMM]; /* Command Name */
  84. };
  85. enum
  86. {
  87. AFORK = 0x01, /* Has executed fork, but no exec. */
  88. ASU = 0x02, /* Used super-user privileges. */
  89. ACORE = 0x08, /* Dumped core. */
  90. AXSIG = 0x10, /* Killed by a signal. */
  91. AGROUP = 0x20 /* Was the last task of the process
  92. (task group). */
  93. };
  94. #if __BYTE_ORDER == __BIG_ENDIAN
  95. # define ACCT_BYTEORDER 0x80 /* Accounting file is big endian. */
  96. #else
  97. # define ACCT_BYTEORDER 0x00 /* Accounting file is little endian. */
  98. #endif
  99. #define AHZ 100
  100. /* Switch process accounting on and off. */
  101. extern int acct (const char *__filename) __THROW;
  102. __END_DECLS
  103. #endif /* sys/acct.h */