tools/include/uapi/linux/acct.h | 128 ++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 tools/include/uapi/linux/acct.h
From: Wang Yaxin <wang.yaxin@zte.com.cn>
Background
==========
After commit 9b93f7e32774 ("tools/getdelays: use the static UAPI
headers from tools/include/uapi"), the Makefile was changed to use
-I../include/uapi/ instead of -I../../usr/include to ensure tools
always use the up-to-date UAPI headers.
However, only linux/taskstats.h was added to tools/include/uapi/ in
commit e5bbb35a07b3 ("tools headers UAPI: sync linux/taskstats.h"),
but linux/acct.h was missing.
Problem
=======
This causes procacct.c to fail to compile with:
procacct.c:234:37: error: 'AGROUP' undeclared (first use in this function)
gcc -I../include/uapi/ getdelays.c -o getdelays
gcc -I../include/uapi/ procacct.c -o procacct
procacct.c: In function ‘print_procacct’:
procacct.c:234:37: error: ‘AGROUP’ undeclared (first use in this function)
did you mean ‘NOGROUP’?
234 | , t->version >= 12 ? (t->ac_flag & AGROUP ? 'P' : 'T') : '?'
| ^~~~~~
| NOGROUP
procacct.c:234:37: note: each undeclared ident
because procacct.c uses the AGROUP macro defined in linux/acct.h.
Solution
========
Add the missing linux/acct.h to complete the static UAPI header set.
Fixes: 9b93f7e32774 ("tools/getdelays: use the static UAPI headers from tools/include/uapi")
Signed-off-by: Wang Yaxin <wang.yaxin@zte.com.cn>
---
tools/include/uapi/linux/acct.h | 128 ++++++++++++++++++++++++++++++++
1 file changed, 128 insertions(+)
create mode 100644 tools/include/uapi/linux/acct.h
diff --git a/tools/include/uapi/linux/acct.h b/tools/include/uapi/linux/acct.h
new file mode 100644
index 000000000000..0e591152aa8a
--- /dev/null
+++ b/tools/include/uapi/linux/acct.h
@@ -0,0 +1,128 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * BSD Process Accounting for Linux - Definitions
+ *
+ * Author: Marco van Wieringen (mvw@planets.elm.net)
+ *
+ * This header file contains the definitions needed to implement
+ * BSD-style process accounting. The kernel accounting code and all
+ * user-level programs that try to do something useful with the
+ * process accounting log must include this file.
+ *
+ * Copyright (C) 1995 - 1997 Marco van Wieringen - ELM Consultancy B.V.
+ *
+ */
+
+#ifndef _UAPI_LINUX_ACCT_H
+#define _UAPI_LINUX_ACCT_H
+
+#include <linux/types.h>
+
+#include <asm/param.h>
+#include <asm/byteorder.h>
+
+/*
+ * comp_t is a 16-bit "floating" point number with a 3-bit base 8
+ * exponent and a 13-bit fraction.
+ * comp2_t is 24-bit with 5-bit base 2 exponent and 20 bit fraction
+ * (leading 1 not stored).
+ * See linux/kernel/acct.c for the specific encoding systems used.
+ */
+
+typedef __u16 comp_t;
+typedef __u32 comp2_t;
+
+/*
+ * accounting file record
+ *
+ * This structure contains all of the information written out to the
+ * process accounting file whenever a process exits.
+ */
+
+#define ACCT_COMM 16
+
+struct acct
+{
+ char ac_flag; /* Flags */
+ char ac_version; /* Always set to ACCT_VERSION */
+ /* for binary compatibility back until 2.0 */
+ __u16 ac_uid16; /* LSB of Real User ID */
+ __u16 ac_gid16; /* LSB of Real Group ID */
+ __u16 ac_tty; /* Control Terminal */
+ /* __u32 range means times from 1970 to 2106 */
+ __u32 ac_btime; /* Process Creation Time */
+ comp_t ac_utime; /* User Time */
+ comp_t ac_stime; /* System Time */
+ comp_t ac_etime; /* Elapsed Time */
+ comp_t ac_mem; /* Average Memory Usage */
+ comp_t ac_io; /* Chars Transferred */
+ comp_t ac_rw; /* Blocks Read or Written */
+ comp_t ac_minflt; /* Minor Pagefaults */
+ comp_t ac_majflt; /* Major Pagefaults */
+ comp_t ac_swaps; /* Number of Swaps */
+/* m68k had no padding here. */
+#if !defined(CONFIG_M68K) || !defined(__KERNEL__)
+ __u16 ac_ahz; /* AHZ */
+#endif
+ __u32 ac_exitcode; /* Exitcode */
+ char ac_comm[ACCT_COMM + 1]; /* Command Name */
+ __u8 ac_etime_hi; /* Elapsed Time MSB */
+ __u16 ac_etime_lo; /* Elapsed Time LSB */
+ __u32 ac_uid; /* Real User ID */
+ __u32 ac_gid; /* Real Group ID */
+};
+
+struct acct_v3
+{
+ char ac_flag; /* Flags */
+ char ac_version; /* Always set to ACCT_VERSION */
+ __u16 ac_tty; /* Control Terminal */
+ __u32 ac_exitcode; /* Exitcode */
+ __u32 ac_uid; /* Real User ID */
+ __u32 ac_gid; /* Real Group ID */
+ __u32 ac_pid; /* Process ID */
+ __u32 ac_ppid; /* Parent Process ID */
+ /* __u32 range means times from 1970 to 2106 */
+ __u32 ac_btime; /* Process Creation Time */
+#ifdef __KERNEL__
+ __u32 ac_etime; /* Elapsed Time */
+#else
+ float ac_etime; /* Elapsed Time */
+#endif
+ comp_t ac_utime; /* User Time */
+ comp_t ac_stime; /* System Time */
+ comp_t ac_mem; /* Average Memory Usage */
+ comp_t ac_io; /* Chars Transferred */
+ comp_t ac_rw; /* Blocks Read or Written */
+ comp_t ac_minflt; /* Minor Pagefaults */
+ comp_t ac_majflt; /* Major Pagefaults */
+ comp_t ac_swaps; /* Number of Swaps */
+ char ac_comm[ACCT_COMM]; /* Command Name */
+};
+
+/*
+ * accounting flags
+ */
+ /* bit set when the process/task ... */
+#define AFORK 0x01 /* ... executed fork, but did not exec */
+#define ASU 0x02 /* ... used super-user privileges */
+#define ACOMPAT 0x04 /* ... used compatibility mode (VAX only not used) */
+#define ACORE 0x08 /* ... dumped core */
+#define AXSIG 0x10 /* ... was killed by a signal */
+#define AGROUP 0x20 /* ... was the last task of the process (task group) */
+
+#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN)
+#define ACCT_BYTEORDER 0x80 /* accounting file is big endian */
+#elif defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN)
+#define ACCT_BYTEORDER 0x00 /* accounting file is little endian */
+#else
+#error unspecified endianness
+#endif
+
+#ifndef __KERNEL__
+#define ACCT_VERSION 2
+#define AHZ (HZ)
+#endif /* __KERNEL */
+
+
+#endif /* _UAPI_LINUX_ACCT_H */
--
2.25.1
On Wed, 27 May 2026 21:35:58 +0800 (CST) <wang.yaxin@zte.com.cn> wrote:
> From: Wang Yaxin <wang.yaxin@zte.com.cn>
>
> Background
> ==========
> After commit 9b93f7e32774 ("tools/getdelays: use the static UAPI
> headers from tools/include/uapi"), the Makefile was changed to use
> -I../include/uapi/ instead of -I../../usr/include to ensure tools
> always use the up-to-date UAPI headers.
>
> However, only linux/taskstats.h was added to tools/include/uapi/ in
> commit e5bbb35a07b3 ("tools headers UAPI: sync linux/taskstats.h"),
> but linux/acct.h was missing.
Please let's Cc the author of both of these commits!
> Problem
> =======
> This causes procacct.c to fail to compile with:
>
> procacct.c:234:37: error: 'AGROUP' undeclared (first use in this function)
>
> gcc -I../include/uapi/ getdelays.c -o getdelays
> gcc -I../include/uapi/ procacct.c -o procacct
> procacct.c: In function ‘print_procacct’:
> procacct.c:234:37: error: ‘AGROUP’ undeclared (first use in this function)
> did you mean ‘NOGROUP’?
> 234 | , t->version >= 12 ? (t->ac_flag & AGROUP ? 'P' : 'T') : '?'
> | ^~~~~~
> | NOGROUP
> procacct.c:234:37: note: each undeclared ident
>
> because procacct.c uses the AGROUP macro defined in linux/acct.h.
>
> Solution
> ========
> Add the missing linux/acct.h to complete the static UAPI header set.
It has always annoyed me that we do this by copying the file. I'm
surprised that there isn't a way of using the original file directly.
> Fixes: 9b93f7e32774 ("tools/getdelays: use the static UAPI headers from tools/include/uapi")
>
> ...
>
> --- /dev/null
> +++ b/tools/include/uapi/linux/acct.h
>
> ...
>
>> From: Wang Yaxin <wang.yaxin@zte.com.cn>
>>
>> Background
>> ==========
>> After commit 9b93f7e32774 ("tools/getdelays: use the static UAPI
>> headers from tools/include/uapi"), the Makefile was changed to use
>> -I../include/uapi/ instead of -I../../usr/include to ensure tools
>> always use the up-to-date UAPI headers.
>>
>> However, only linux/taskstats.h was added to tools/include/uapi/ in
>> commit e5bbb35a07b3 ("tools headers UAPI: sync linux/taskstats.h"),
>> but linux/acct.h was missing.
>
>Please let's Cc the author of both of these commits!
Ok
>> Problem
>> =======
>> This causes procacct.c to fail to compile with:
>>
>> procacct.c:234:37: error: 'AGROUP' undeclared (first use in this function)
>>
>> gcc -I../include/uapi/ getdelays.c -o getdelays
>> gcc -I../include/uapi/ procacct.c -o procacct
>> procacct.c: In function ‘print_procacct’:
>> procacct.c:234:37: error: ‘AGROUP’ undeclared (first use in this function)
>> did you mean ‘NOGROUP’?
>> 234 | , t->version >= 12 ? (t->ac_flag & AGROUP ? 'P' : 'T') : '?'
>> | ^~~~~~
>> | NOGROUP
>> procacct.c:234:37: note: each undeclared ident
>>
>> because procacct.c uses the AGROUP macro defined in linux/acct.h.
>>
>> Solution
>> ========
>> Add the missing linux/acct.h to complete the static UAPI header set.
>
>It has always annoyed me that we do this by copying the file. I'm
>surprised that there isn't a way of using the original file directly.
Using -I../../usr/include avoids duplicate headers and relies on a
single original copy, but requires make headers_install. This aligns
with commit 9b93f7e32774 ("tools/getdelays: use the static UAPI headers
from tools/include/uapi").
Using -I../include/uapi/ keeps two separate header copies, which may
cause inconsistencies when one copy is updated. Can we optimize it
with symbolic links, or revert to the first solution?
Thanks
Yaxin
Hi!
On 2026-05-29 12:44:10+0800, wang.yaxin@zte.com.cn wrote:
> >> From: Wang Yaxin <wang.yaxin@zte.com.cn>
> >>
> >> Background
> >> ==========
> >> After commit 9b93f7e32774 ("tools/getdelays: use the static UAPI
> >> headers from tools/include/uapi"), the Makefile was changed to use
> >> -I../include/uapi/ instead of -I../../usr/include to ensure tools
> >> always use the up-to-date UAPI headers.
> >>
> >> However, only linux/taskstats.h was added to tools/include/uapi/ in
> >> commit e5bbb35a07b3 ("tools headers UAPI: sync linux/taskstats.h"),
> >> but linux/acct.h was missing.
> >
> >Please let's Cc the author of both of these commits!
>
> Ok
>
> >> Problem
> >> =======
> >> This causes procacct.c to fail to compile with:
> >>
> >> procacct.c:234:37: error: 'AGROUP' undeclared (first use in this function)
> >>
> >> gcc -I../include/uapi/ getdelays.c -o getdelays
> >> gcc -I../include/uapi/ procacct.c -o procacct
> >> procacct.c: In function ‘print_procacct’:
> >> procacct.c:234:37: error: ‘AGROUP’ undeclared (first use in this function)
> >> did you mean ‘NOGROUP’?
> >> 234 | , t->version >= 12 ? (t->ac_flag & AGROUP ? 'P' : 'T') : '?'
> >> | ^~~~~~
> >> | NOGROUP
> >> procacct.c:234:37: note: each undeclared ident
> >>
> >> because procacct.c uses the AGROUP macro defined in linux/acct.h.
AGROUP is somewhat old. When linux/acct.h is not present in
tools/include/uapi the system header will be used. In my case this
symbol existed there, so I didn't see the error.
> >> Solution
> >> ========
> >> Add the missing linux/acct.h to complete the static UAPI header set.
Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
> >
> >It has always annoyed me that we do this by copying the file. I'm
> >surprised that there isn't a way of using the original file directly.
>
> Using -I../../usr/include avoids duplicate headers and relies on a
> single original copy, but requires make headers_install. This aligns
> with commit 9b93f7e32774 ("tools/getdelays: use the static UAPI headers
> from tools/include/uapi").
This requires the presence of a kernel build. Which is not guaranteed
for tools/. You could put it in samples/ which is part of the regular
kernel build and can depend on up-to-date UAPI headers.
> Using -I../include/uapi/ keeps two separate header copies, which may
> cause inconsistencies when one copy is updated. Can we optimize it
> with symbolic links, or revert to the first solution?
See tools/include/uapi/README for the background of the current
solution. I would stick with it.
diff --git a/tools/include/uapi/linux/acct.h b/tools/include/uapi/linux/acct.h
new file mode 100644
index 000000000000..0e591152aa8a
--- /dev/null
+++ b/tools/include/uapi/linux/acct.h
@@ -0,0 +1,128 @@
(...)
+#ifndef _UAPI_LINUX_ACCT_H
+#define _UAPI_LINUX_ACCT_H
+
+#include <linux/types.h>
+
+#include <asm/param.h>
+#include <asm/byteorder.h>
These headers do not exist in exist in tools/include/uapi/ either.
So we need to rely on them to exist in the system UAPI headers.
This should be fine.
(...)
+struct acct
+{
+ char ac_flag; /* Flags */
+ char ac_version; /* Always set to ACCT_VERSION */
+ /* for binary compatibility back until 2.0 */
+ __u16 ac_uid16; /* LSB of Real User ID */
+ __u16 ac_gid16; /* LSB of Real Group ID */
+ __u16 ac_tty; /* Control Terminal */
+ /* __u32 range means times from 1970 to 2106 */
+ __u32 ac_btime; /* Process Creation Time */
+ comp_t ac_utime; /* User Time */
+ comp_t ac_stime; /* System Time */
+ comp_t ac_etime; /* Elapsed Time */
+ comp_t ac_mem; /* Average Memory Usage */
+ comp_t ac_io; /* Chars Transferred */
+ comp_t ac_rw; /* Blocks Read or Written */
+ comp_t ac_minflt; /* Minor Pagefaults */
+ comp_t ac_majflt; /* Major Pagefaults */
+ comp_t ac_swaps; /* Number of Swaps */
+/* m68k had no padding here. */
+#if !defined(CONFIG_M68K) || !defined(__KERNEL__)
+ __u16 ac_ahz; /* AHZ */
+#endif
Pre-existing issue, unvalidated:
This looks problematic, as on m68k userspace and kernel disagree on
the existence of this field. This should probably use
!defined(__m68k__).
+ __u32 ac_exitcode; /* Exitcode */
+ char ac_comm[ACCT_COMM + 1]; /* Command Name */
+ __u8 ac_etime_hi; /* Elapsed Time MSB */
+ __u16 ac_etime_lo; /* Elapsed Time LSB */
+ __u32 ac_uid; /* Real User ID */
+ __u32 ac_gid; /* Real Group ID */
+};
(...)
Thomas
Hi, Thomas
>> >It has always annoyed me that we do this by copying the file. I'm
>> >surprised that there isn't a way of using the original file directly.
>>
>> Using -I../../usr/include avoids duplicate headers and relies on a
>> single original copy, but requires make headers_install. This aligns
>> with commit 9b93f7e32774 ("tools/getdelays: use the static UAPI headers
>> from tools/include/uapi").
>
>This requires the presence of a kernel build. Which is not guaranteed
>for tools/. You could put it in samples/ which is part of the regular
>kernel build and can depend on up-to-date UAPI headers.
>
>> Using -I../include/uapi/ keeps two separate header copies, which may
>> cause inconsistencies when one copy is updated. Can we optimize it
>> with symbolic links, or revert to the first solution?
>
>See tools/include/uapi/README for the background of the current
>solution. I would stick with it.
Thanks for your reply. After reading tools/include/uapi/README, I now
understand the background of this solution. It seems the second approach
is indeed the recommended one for now.
Thanks
Yaxin
© 2016 - 2026 Red Hat, Inc.