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