summaryrefslogtreecommitdiffstats
path: root/library/include
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 20:34:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 20:34:44 +0000
commite3be059d4da38aa36f1aee1d56f8ceb943d92f1c (patch)
tree26edef31e4e503dd1c92a112de174f366dd61802 /library/include
parentInitial commit. (diff)
downloadprocps-e3be059d4da38aa36f1aee1d56f8ceb943d92f1c.tar.xz
procps-e3be059d4da38aa36f1aee1d56f8ceb943d92f1c.zip
Adding upstream version 2:4.0.4.upstream/2%4.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/include')
-rw-r--r--library/include/devname.h10
-rw-r--r--library/include/diskstats.h135
-rw-r--r--library/include/escape.h35
-rw-r--r--library/include/meminfo.h216
-rw-r--r--library/include/misc.h90
-rw-r--r--library/include/numa.h30
-rw-r--r--library/include/pids.h287
-rw-r--r--library/include/procps-private.h28
-rw-r--r--library/include/pwcache.h38
-rw-r--r--library/include/readproc.h303
-rw-r--r--library/include/slabinfo.h140
-rw-r--r--library/include/stat.h175
-rw-r--r--library/include/vmstat.h382
-rw-r--r--library/include/wchan.h27
-rw-r--r--library/include/xtra-procps-debug.h208
15 files changed, 2104 insertions, 0 deletions
diff --git a/library/include/devname.h b/library/include/devname.h
new file mode 100644
index 0000000..467cd29
--- /dev/null
+++ b/library/include/devname.h
@@ -0,0 +1,10 @@
+#ifndef PROC_DEVNAME_H
+#define PROC_DEVNAME_H
+
+#define ABBREV_DEV 1 /* remove /dev/ */
+#define ABBREV_TTY 2 /* remove tty */
+#define ABBREV_PTS 4 /* remove pts/ */
+
+unsigned dev_to_tty(char *__restrict ret, unsigned chop, dev_t dev_t_dev, int pid, unsigned int flags);
+
+#endif
diff --git a/library/include/diskstats.h b/library/include/diskstats.h
new file mode 100644
index 0000000..d5a4b1f
--- /dev/null
+++ b/library/include/diskstats.h
@@ -0,0 +1,135 @@
+/*
+ * diskstats.h - disk I/O related declarations for libproc2
+ *
+ * Copyright © 2015-2023 Jim Warner <james.warner@comcast.net>
+ * Copyright © 2015-2023 Craig Small <csmall@dropbear.xyz>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef PROCPS_DISKSTATS_H
+#define PROCPS_DISKSTATS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum diskstats_item {
+ DISKSTATS_noop, // ( never altered )
+ DISKSTATS_extra, // ( reset to zero )
+ // returns origin, see proc(5)
+ // ------- -------------------
+ DISKSTATS_NAME, // str /proc/diskstats
+ DISKSTATS_TYPE, // s_int "
+ DISKSTATS_MAJOR, // s_int "
+ DISKSTATS_MINOR, // s_int "
+
+ DISKSTATS_READS, // ul_int "
+ DISKSTATS_READS_MERGED, // ul_int "
+ DISKSTATS_READ_SECTORS, // ul_int "
+ DISKSTATS_READ_TIME, // ul_int "
+ DISKSTATS_WRITES, // ul_int "
+ DISKSTATS_WRITES_MERGED, // ul_int "
+ DISKSTATS_WRITE_SECTORS, // ul_int "
+ DISKSTATS_WRITE_TIME, // ul_int "
+ DISKSTATS_IO_TIME, // ul_int "
+ DISKSTATS_WEIGHTED_TIME, // ul_int "
+
+ DISKSTATS_IO_INPROGRESS, // s_int "
+
+ DISKSTATS_DELTA_READS, // s_int derived from above
+ DISKSTATS_DELTA_READS_MERGED, // s_int "
+ DISKSTATS_DELTA_READ_SECTORS, // s_int "
+ DISKSTATS_DELTA_READ_TIME, // s_int "
+ DISKSTATS_DELTA_WRITES, // s_int "
+ DISKSTATS_DELTA_WRITES_MERGED, // s_int "
+ DISKSTATS_DELTA_WRITE_SECTORS, // s_int "
+ DISKSTATS_DELTA_WRITE_TIME, // s_int "
+ DISKSTATS_DELTA_IO_TIME, // s_int "
+ DISKSTATS_DELTA_WEIGHTED_TIME // s_int "
+};
+
+enum diskstats_sort_order {
+ DISKSTATS_SORT_ASCEND = +1,
+ DISKSTATS_SORT_DESCEND = -1
+};
+
+
+struct diskstats_result {
+ enum diskstats_item item;
+ union {
+ signed int s_int;
+ unsigned long ul_int;
+ char *str;
+ } result;
+};
+
+struct diskstats_stack {
+ struct diskstats_result *head;
+};
+
+struct diskstats_reaped {
+ int total;
+ struct diskstats_stack **stacks;
+};
+
+struct diskstats_info;
+
+
+#define DISKSTATS_TYPE_DISK -11111
+#define DISKSTATS_TYPE_PARTITION -22222
+
+#define DISKSTATS_GET( info, name, actual_enum, type ) ( { \
+ struct diskstats_result *r = procps_diskstats_get( info, name, actual_enum ); \
+ r ? r->result . type : 0; } )
+
+#define DISKSTATS_VAL( relative_enum, type, stack, info ) \
+ stack -> head [ relative_enum ] . result . type
+
+
+int procps_diskstats_new (struct diskstats_info **info);
+int procps_diskstats_ref (struct diskstats_info *info);
+int procps_diskstats_unref (struct diskstats_info **info);
+
+struct diskstats_result *procps_diskstats_get (
+ struct diskstats_info *info,
+ const char *name,
+ enum diskstats_item item);
+
+struct diskstats_reaped *procps_diskstats_reap (
+ struct diskstats_info *info,
+ enum diskstats_item *items,
+ int numitems);
+
+struct diskstats_stack *procps_diskstats_select (
+ struct diskstats_info *info,
+ const char *name,
+ enum diskstats_item *items,
+ int numitems);
+
+struct diskstats_stack **procps_diskstats_sort (
+ struct diskstats_info *info,
+ struct diskstats_stack *stacks[],
+ int numstacked,
+ enum diskstats_item sortitem,
+ enum diskstats_sort_order order);
+
+
+#ifdef XTRA_PROCPS_DEBUG
+# include "xtra-procps-debug.h"
+#endif
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/library/include/escape.h b/library/include/escape.h
new file mode 100644
index 0000000..1f0b0f9
--- /dev/null
+++ b/library/include/escape.h
@@ -0,0 +1,35 @@
+/*
+ * escape.h - printing handling
+ *
+ * Copyright © 2011-2023 Jim Warner <james.warner@comcast.net>
+ * Copyright © 2016-2023 Craig Small <csmall@dropbear.xyz>
+ * Copyright © 1998-2005 Albert Cahalan
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef PROCPS_PROC_ESCAPE_H
+#define PROCPS_PROC_ESCAPE_H
+
+#include "readproc.h"
+
+#define ESC_BRACKETS 0x2 // if using cmd, put '[' and ']' around it
+#define ESC_DEFUNCT 0x4 // mark zombies with " <defunct>"
+
+int escape_command (char *outbuf, const proc_t *pp, int bytes, unsigned flags);
+
+int escape_str (char *dst, const char *src, int bufsize);
+
+#endif
diff --git a/library/include/meminfo.h b/library/include/meminfo.h
new file mode 100644
index 0000000..edca8d2
--- /dev/null
+++ b/library/include/meminfo.h
@@ -0,0 +1,216 @@
+/*
+ * meminfo.h - memory related declarations for libproc2
+ *
+ * Copyright © 2015-2023 Jim Warner <james.warner@comcast.net>
+ * Copyright © 2015-2023 Craig Small <csmall@dropbear.xyz>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef PROCPS_MEMINFO_H
+#define PROCPS_MEMINFO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum meminfo_item {
+ MEMINFO_noop, // ( never altered )
+ MEMINFO_extra, // ( reset to zero )
+ /*
+ note: all of the following values are expressed as KiB
+ */
+ // returns origin, see proc(5)
+ // ------- -------------------
+ MEMINFO_MEM_ACTIVE, // ul_int /proc/meminfo
+ MEMINFO_MEM_ACTIVE_ANON, // ul_int "
+ MEMINFO_MEM_ACTIVE_FILE, // ul_int "
+ MEMINFO_MEM_ANON, // ul_int "
+ MEMINFO_MEM_AVAILABLE, // ul_int "
+ MEMINFO_MEM_BOUNCE, // ul_int "
+ MEMINFO_MEM_BUFFERS, // ul_int "
+ MEMINFO_MEM_CACHED, // ul_int "
+ MEMINFO_MEM_CACHED_ALL, // ul_int derived from MEM_CACHED + MEM_SLAB_RECLAIM
+ MEMINFO_MEM_CMA_FREE, // ul_int /proc/meminfo
+ MEMINFO_MEM_CMA_TOTAL, // ul_int "
+ MEMINFO_MEM_COMMITTED_AS, // ul_int "
+ MEMINFO_MEM_COMMIT_LIMIT, // ul_int "
+ MEMINFO_MEM_DIRECTMAP_1G, // ul_int "
+ MEMINFO_MEM_DIRECTMAP_2M, // ul_int "
+ MEMINFO_MEM_DIRECTMAP_4K, // ul_int "
+ MEMINFO_MEM_DIRECTMAP_4M, // ul_int "
+ MEMINFO_MEM_DIRTY, // ul_int "
+ MEMINFO_MEM_FILE_HUGEPAGES, // ul_int "
+ MEMINFO_MEM_FILE_PMDMAPPED, // ul_int "
+ MEMINFO_MEM_FREE, // ul_int "
+ MEMINFO_MEM_HARD_CORRUPTED, // ul_int "
+ MEMINFO_MEM_HIGH_FREE, // ul_int "
+ MEMINFO_MEM_HIGH_TOTAL, // ul_int "
+ MEMINFO_MEM_HIGH_USED, // ul_int derived from MEM_HIGH_TOTAL - MEM_HIGH_FREE
+ MEMINFO_MEM_HUGETBL, // ul_int /proc/meminfo
+ MEMINFO_MEM_HUGE_ANON, // ul_int "
+ MEMINFO_MEM_HUGE_FREE, // ul_int "
+ MEMINFO_MEM_HUGE_RSVD, // ul_int "
+ MEMINFO_MEM_HUGE_SIZE, // ul_int "
+ MEMINFO_MEM_HUGE_SURPLUS, // ul_int "
+ MEMINFO_MEM_HUGE_TOTAL, // ul_int "
+ MEMINFO_MEM_INACTIVE, // ul_int "
+ MEMINFO_MEM_INACTIVE_ANON, // ul_int "
+ MEMINFO_MEM_INACTIVE_FILE, // ul_int "
+ MEMINFO_MEM_KERNEL_RECLAIM, // ul_int "
+ MEMINFO_MEM_KERNEL_STACK, // ul_int "
+ MEMINFO_MEM_LOCKED, // ul_int "
+ MEMINFO_MEM_LOW_FREE, // ul_int "
+ MEMINFO_MEM_LOW_TOTAL, // ul_int "
+ MEMINFO_MEM_LOW_USED, // ul_int derived from MEM_LOW_TOTAL - MEM_LOW_FREE
+ MEMINFO_MEM_MAPPED, // ul_int /proc/meminfo
+ MEMINFO_MEM_MAP_COPY, // ul_int "
+ MEMINFO_MEM_NFS_UNSTABLE, // ul_int "
+ MEMINFO_MEM_PAGE_TABLES, // ul_int "
+ MEMINFO_MEM_PER_CPU, // ul_int "
+ MEMINFO_MEM_SHADOWCALLSTACK, // ul_int "
+ MEMINFO_MEM_SHARED, // ul_int "
+ MEMINFO_MEM_SHMEM_HUGE, // ul_int "
+ MEMINFO_MEM_SHMEM_HUGE_MAP, // ul_int "
+ MEMINFO_MEM_SLAB, // ul_int "
+ MEMINFO_MEM_SLAB_RECLAIM, // ul_int "
+ MEMINFO_MEM_SLAB_UNRECLAIM, // ul_int "
+ MEMINFO_MEM_TOTAL, // ul_int "
+ MEMINFO_MEM_UNEVICTABLE, // ul_int "
+ MEMINFO_MEM_USED, // ul_int derived from MEM_TOTAL - MEM_AVAILABLE
+ MEMINFO_MEM_VM_ALLOC_CHUNK, // ul_int /proc/meminfo
+ MEMINFO_MEM_VM_ALLOC_TOTAL, // ul_int "
+ MEMINFO_MEM_VM_ALLOC_USED, // ul_int "
+ MEMINFO_MEM_WRITEBACK, // ul_int "
+ MEMINFO_MEM_WRITEBACK_TMP, // ul_int "
+
+ MEMINFO_DELTA_ACTIVE, // s_int derived from above
+ MEMINFO_DELTA_ACTIVE_ANON, // s_int "
+ MEMINFO_DELTA_ACTIVE_FILE, // s_int "
+ MEMINFO_DELTA_ANON, // s_int "
+ MEMINFO_DELTA_AVAILABLE, // s_int "
+ MEMINFO_DELTA_BOUNCE, // s_int "
+ MEMINFO_DELTA_BUFFERS, // s_int "
+ MEMINFO_DELTA_CACHED, // s_int "
+ MEMINFO_DELTA_CACHED_ALL, // s_int "
+ MEMINFO_DELTA_CMA_FREE, // s_int "
+ MEMINFO_DELTA_CMA_TOTAL, // s_int "
+ MEMINFO_DELTA_COMMITTED_AS, // s_int "
+ MEMINFO_DELTA_COMMIT_LIMIT, // s_int "
+ MEMINFO_DELTA_DIRECTMAP_1G, // s_int "
+ MEMINFO_DELTA_DIRECTMAP_2M, // s_int "
+ MEMINFO_DELTA_DIRECTMAP_4K, // s_int "
+ MEMINFO_DELTA_DIRECTMAP_4M, // s_int "
+ MEMINFO_DELTA_DIRTY, // s_int "
+ MEMINFO_DELTA_FILE_HUGEPAGES, // s_int "
+ MEMINFO_DELTA_FILE_PMDMAPPED, // s_int "
+ MEMINFO_DELTA_FREE, // s_int "
+ MEMINFO_DELTA_HARD_CORRUPTED, // s_int "
+ MEMINFO_DELTA_HIGH_FREE, // s_int "
+ MEMINFO_DELTA_HIGH_TOTAL, // s_int "
+ MEMINFO_DELTA_HIGH_USED, // s_int "
+ MEMINFO_DELTA_HUGETBL, // s_int "
+ MEMINFO_DELTA_HUGE_ANON, // s_int "
+ MEMINFO_DELTA_HUGE_FREE, // s_int "
+ MEMINFO_DELTA_HUGE_RSVD, // s_int "
+ MEMINFO_DELTA_HUGE_SIZE, // s_int "
+ MEMINFO_DELTA_HUGE_SURPLUS, // s_int "
+ MEMINFO_DELTA_HUGE_TOTAL, // s_int "
+ MEMINFO_DELTA_INACTIVE, // s_int "
+ MEMINFO_DELTA_INACTIVE_ANON, // s_int "
+ MEMINFO_DELTA_INACTIVE_FILE, // s_int "
+ MEMINFO_DELTA_KERNEL_RECLAIM, // s_int "
+ MEMINFO_DELTA_KERNEL_STACK, // s_int "
+ MEMINFO_DELTA_LOCKED, // s_int "
+ MEMINFO_DELTA_LOW_FREE, // s_int "
+ MEMINFO_DELTA_LOW_TOTAL, // s_int "
+ MEMINFO_DELTA_LOW_USED, // s_int "
+ MEMINFO_DELTA_MAPPED, // s_int "
+ MEMINFO_DELTA_MAP_COPY, // s_int "
+ MEMINFO_DELTA_NFS_UNSTABLE, // s_int "
+ MEMINFO_DELTA_PAGE_TABLES, // s_int "
+ MEMINFO_DELTA_PER_CPU, // s_int "
+ MEMINFO_DELTA_SHADOWCALLSTACK, // s_int "
+ MEMINFO_DELTA_SHARED, // s_int "
+ MEMINFO_DELTA_SHMEM_HUGE, // s_int "
+ MEMINFO_DELTA_SHMEM_HUGE_MAP, // s_int "
+ MEMINFO_DELTA_SLAB, // s_int "
+ MEMINFO_DELTA_SLAB_RECLAIM, // s_int "
+ MEMINFO_DELTA_SLAB_UNRECLAIM, // s_int "
+ MEMINFO_DELTA_TOTAL, // s_int "
+ MEMINFO_DELTA_UNEVICTABLE, // s_int "
+ MEMINFO_DELTA_USED, // s_int "
+ MEMINFO_DELTA_VM_ALLOC_CHUNK, // s_int "
+ MEMINFO_DELTA_VM_ALLOC_TOTAL, // s_int "
+ MEMINFO_DELTA_VM_ALLOC_USED, // s_int "
+ MEMINFO_DELTA_WRITEBACK, // s_int "
+ MEMINFO_DELTA_WRITEBACK_TMP, // s_int "
+
+ MEMINFO_SWAP_CACHED, // ul_int /proc/meminfo
+ MEMINFO_SWAP_FREE, // ul_int "
+ MEMINFO_SWAP_TOTAL, // ul_int "
+ MEMINFO_SWAP_USED, // ul_int derived from SWAP_TOTAL - SWAP_FREE
+
+ MEMINFO_SWAP_DELTA_CACHED, // s_int derived from above
+ MEMINFO_SWAP_DELTA_FREE, // s_int "
+ MEMINFO_SWAP_DELTA_TOTAL, // s_int "
+ MEMINFO_SWAP_DELTA_USED // s_int "
+};
+
+
+struct meminfo_result {
+ enum meminfo_item item;
+ union {
+ signed int s_int;
+ unsigned long ul_int;
+ } result;
+};
+
+struct meminfo_stack {
+ struct meminfo_result *head;
+};
+
+struct meminfo_info;
+
+
+#define MEMINFO_GET( info, actual_enum, type ) ( { \
+ struct meminfo_result *r = procps_meminfo_get( info, actual_enum ); \
+ r ? r->result . type : 0; } )
+
+#define MEMINFO_VAL( relative_enum, type, stack, info ) \
+ stack -> head [ relative_enum ] . result . type
+
+
+int procps_meminfo_new (struct meminfo_info **info);
+int procps_meminfo_ref (struct meminfo_info *info);
+int procps_meminfo_unref (struct meminfo_info **info);
+
+struct meminfo_result *procps_meminfo_get (
+ struct meminfo_info *info,
+ enum meminfo_item item);
+
+struct meminfo_stack *procps_meminfo_select (
+ struct meminfo_info *info,
+ enum meminfo_item *items,
+ int numitems);
+
+
+#ifdef XTRA_PROCPS_DEBUG
+# include "xtra-procps-debug.h"
+#endif
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/library/include/misc.h b/library/include/misc.h
new file mode 100644
index 0000000..bbfa5e2
--- /dev/null
+++ b/library/include/misc.h
@@ -0,0 +1,90 @@
+/*
+ * misc.h - miscellaneous declarations for libproc2
+ *
+ * Copyright © 2015-2023 Craig Small <csmall@dropbear.xyz>
+ * Copyright © 2021-2023 Jim Warner <james.warner@comcast.net>
+ * Copyright © 1998-2003 Albert Cahalan
+ * Copyright © 1992-1998 Michael K. Johnson <johnsonm@redhat.com>
+ * Copyright © 1996 Charles Blake <cblake@bbn.com>
+ * Copyright © 1993 J. Cowley
+ * Copyright © 1995 Martin Schulze <joey@infodrom.north.de>
+ * Copyright © ???? Larry Greenfield <greenfie@gauss.rutgers.edu>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef PROC_MISC_H
+#define PROC_MISC_H
+#include <sys/types.h>
+#include <dirent.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+// //////////////////////////////////////////////////////////////////
+// Platform Particulars /////////////////////////////////////////////
+
+long procps_cpu_count (void);
+long procps_hertz_get (void);
+unsigned int procps_pid_length (void);
+
+ // Convenience macros for composing/decomposing version codes
+#define LINUX_VERSION(x,y,z) (0x10000*((x)&0x7fff) + 0x100*((y)&0xff) + ((z)&0xff))
+#define LINUX_VERSION_MAJOR(x) (((x)>>16) & 0xFF)
+#define LINUX_VERSION_MINOR(x) (((x)>> 8) & 0xFF)
+#define LINUX_VERSION_PATCH(x) ( (x) & 0xFF)
+
+int procps_linux_version(void);
+
+
+// //////////////////////////////////////////////////////////////////
+// Runtime Particulars //////////////////////////////////////////////
+
+int procps_loadavg (double *av1, double *av5, double *av15);
+int procps_uptime (double *uptime_secs, double *idle_secs);
+char *procps_uptime_sprint (void);
+char *procps_uptime_sprint_short (void);
+
+
+// //////////////////////////////////////////////////////////////////
+// Namespace Particulars ////////////////////////////////////////////
+
+enum namespace_type {
+ PROCPS_NS_CGROUP,
+ PROCPS_NS_IPC,
+ PROCPS_NS_MNT,
+ PROCPS_NS_NET,
+ PROCPS_NS_PID,
+ PROCPS_NS_TIME,
+ PROCPS_NS_USER,
+ PROCPS_NS_UTS,
+ PROCPS_NS_COUNT // total namespaces (fencepost)
+};
+
+struct procps_ns {
+ unsigned long ns[PROCPS_NS_COUNT];
+};
+
+const char *procps_ns_get_name (const int id);
+int procps_ns_get_id (const char *name);
+int procps_ns_read_pid (const int pid, struct procps_ns *nsp);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/library/include/numa.h b/library/include/numa.h
new file mode 100644
index 0000000..5a4368b
--- /dev/null
+++ b/library/include/numa.h
@@ -0,0 +1,30 @@
+/*
+ * NUMA node support for <PIDS> & <STAT> interfaces
+ *
+ * Copyright © 2017-2023 Jim Warner <james.warner@comcast.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef PROCPS_NUMA_H
+#define PROCPS_NUMA_H
+
+void numa_init (void);
+void numa_uninit (void);
+
+extern int (*numa_max_node) (void);
+extern int (*numa_node_of_cpu) (int);
+
+#endif
diff --git a/library/include/pids.h b/library/include/pids.h
new file mode 100644
index 0000000..8245e36
--- /dev/null
+++ b/library/include/pids.h
@@ -0,0 +1,287 @@
+/*
+ * pids.h - process related declarations for libproc2
+ *
+ * Copyright © 2015-2023 Jim Warner <james.warner@comcast.net>
+ * Copyright © 2015-2023 Craig Small <csmall@dropbear.xyz>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef PROCPS_PIDS_H
+#define PROCPS_PIDS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum pids_item {
+ PIDS_noop, // ( never altered )
+ PIDS_extra, // ( reset to zero )
+ // returns origin, see proc(5)
+ // ------- -------------------
+ PIDS_ADDR_CODE_END, // ul_int stat: end_code
+ PIDS_ADDR_CODE_START, // ul_int stat: start_code
+ PIDS_ADDR_CURR_EIP, // ul_int stat: eip
+ PIDS_ADDR_CURR_ESP, // ul_int stat: esp
+ PIDS_ADDR_STACK_START, // ul_int stat: start_stack
+ PIDS_AUTOGRP_ID, // s_int autogroup
+ PIDS_AUTOGRP_NICE, // s_int autogroup
+ PIDS_CGNAME, // str derived from CGROUP ':name='
+ PIDS_CGROUP, // str cgroup
+ PIDS_CGROUP_V, // strv cgroup, as *str[]
+ PIDS_CMD, // str stat: comm or status: Name
+ PIDS_CMDLINE, // str cmdline
+ PIDS_CMDLINE_V, // strv cmdline, as *str[]
+ PIDS_ENVIRON, // str environ
+ PIDS_ENVIRON_V, // strv environ, as *str[]
+ PIDS_EXE, // str exe
+ PIDS_EXIT_SIGNAL, // s_int stat: exit_signal
+ PIDS_FLAGS, // ul_int stat: flags
+ PIDS_FLT_MAJ, // ul_int stat: maj_flt
+ PIDS_FLT_MAJ_C, // ul_int derived from stat: maj_flt + cmaj_flt
+ PIDS_FLT_MAJ_DELTA, // s_int derived from FLT_MAJ
+ PIDS_FLT_MIN, // ul_int stat: min_flt
+ PIDS_FLT_MIN_C, // ul_int derived from stat: min_flt + cmin_flt
+ PIDS_FLT_MIN_DELTA, // s_int derived from FLT_MIN
+ PIDS_ID_EGID, // u_int status: Gid
+ PIDS_ID_EGROUP, // str derived from EGID, see getgrgid(3)
+ PIDS_ID_EUID, // u_int status: Uid
+ PIDS_ID_EUSER, // str derived from EUID, see getpwuid(3)
+ PIDS_ID_FGID, // u_int status: Gid
+ PIDS_ID_FGROUP, // str derived from FGID, see getgrgid(3)
+ PIDS_ID_FUID, // u_int status: Uid
+ PIDS_ID_FUSER, // str derived from FUID, see getpwuid(3)
+ PIDS_ID_LOGIN, // s_int loginuid
+ PIDS_ID_PGRP, // s_int stat: pgrp
+ PIDS_ID_PID, // s_int from /proc/<pid>
+ PIDS_ID_PPID, // s_int stat: ppid or status: PPid
+ PIDS_ID_RGID, // u_int status: Gid
+ PIDS_ID_RGROUP, // str derived from RGID, see getgrgid(3)
+ PIDS_ID_RUID, // u_int status: Uid
+ PIDS_ID_RUSER, // str derived from RUID, see getpwuid(3)
+ PIDS_ID_SESSION, // s_int stat: sid
+ PIDS_ID_SGID, // u_int status: Gid
+ PIDS_ID_SGROUP, // str derived from SGID, see getgrgid(3)
+ PIDS_ID_SUID, // u_int status: Uid
+ PIDS_ID_SUSER, // str derived from SUID, see getpwuid(3)
+ PIDS_ID_TGID, // s_int status: Tgid
+ PIDS_ID_TID, // s_int from /proc/<pid>/task/<tid>
+ PIDS_ID_TPGID, // s_int stat: tty_pgrp
+ PIDS_IO_READ_BYTES, // ul_int io: read_bytes
+ PIDS_IO_READ_CHARS, // ul_int io: rchar
+ PIDS_IO_READ_OPS, // ul_int io: syscr
+ PIDS_IO_WRITE_BYTES, // ul_int io: write_bytes
+ PIDS_IO_WRITE_CBYTES, // ul_int io: cancelled_write_bytes
+ PIDS_IO_WRITE_CHARS, // ul_int io: wchar
+ PIDS_IO_WRITE_OPS, // ul_int io: syscw
+ PIDS_LXCNAME, // str derived from CGROUP 'lxc.payload'
+ PIDS_MEM_CODE, // ul_int derived from MEM_CODE_PGS, as KiB
+ PIDS_MEM_CODE_PGS, // ul_int statm: trs
+ PIDS_MEM_DATA, // ul_int derived from MEM_DATA_PGS, as KiB
+ PIDS_MEM_DATA_PGS, // ul_int statm: drs
+ PIDS_MEM_RES, // ul_int derived from MEM_RES_PGS, as KiB
+ PIDS_MEM_RES_PGS, // ul_int statm: resident
+ PIDS_MEM_SHR, // ul_int derived from MEM_SHR_PGS, as KiB
+ PIDS_MEM_SHR_PGS, // ul_int statm: shared
+ PIDS_MEM_VIRT, // ul_int derived from MEM_VIRT_PGS, as KiB
+ PIDS_MEM_VIRT_PGS, // ul_int statm: size
+ PIDS_NICE, // s_int stat: nice
+ PIDS_NLWP, // s_int stat: num_threads or status: Threads
+ PIDS_NS_CGROUP, // ul_int ns/
+ PIDS_NS_IPC, // ul_int "
+ PIDS_NS_MNT, // ul_int "
+ PIDS_NS_NET, // ul_int "
+ PIDS_NS_PID, // ul_int "
+ PIDS_NS_TIME, // ul_int "
+ PIDS_NS_USER, // ul_int "
+ PIDS_NS_UTS, // ul_int "
+ PIDS_OOM_ADJ, // s_int oom_score_adj
+ PIDS_OOM_SCORE, // s_int oom_score
+ PIDS_PRIORITY, // s_int stat: priority
+ PIDS_PRIORITY_RT, // s_int stat: rt_priority
+ PIDS_PROCESSOR, // s_int stat: task_cpu
+ PIDS_PROCESSOR_NODE, // s_int derived from PROCESSOR, see numa(3)
+ PIDS_RSS, // ul_int stat: rss
+ PIDS_RSS_RLIM, // ul_int stat: rsslim
+ PIDS_SCHED_CLASS, // s_int stat: policy
+ PIDS_SD_MACH, // str derived from PID/TID, see sd-login(3)
+ PIDS_SD_OUID, // str "
+ PIDS_SD_SEAT, // str "
+ PIDS_SD_SESS, // str "
+ PIDS_SD_SLICE, // str "
+ PIDS_SD_UNIT, // str "
+ PIDS_SD_UUNIT, // str "
+ PIDS_SIGBLOCKED, // str status: SigBlk
+ PIDS_SIGCATCH, // str status: SigCgt
+ PIDS_SIGIGNORE, // str status: SigIgn
+ PIDS_SIGNALS, // str status: ShdPnd
+ PIDS_SIGPENDING, // str status: SigPnd
+ PIDS_SMAP_ANONYMOUS, // ul_int smaps_rollup: Anonymous
+ PIDS_SMAP_HUGE_ANON, // ul_int smaps_rollup: AnonHugePages
+ PIDS_SMAP_HUGE_FILE, // ul_int smaps_rollup: FilePmdMapped
+ PIDS_SMAP_HUGE_SHMEM, // ul_int smaps_rollup: ShmemPmdMapped
+ PIDS_SMAP_HUGE_TLBPRV, // ul_int smaps_rollup: Private_Hugetlb
+ PIDS_SMAP_HUGE_TLBSHR, // ul_int smaps_rollup: Shared_Hugetlb
+ PIDS_SMAP_LAZY_FREE, // ul_int smaps_rollup: LazyFree
+ PIDS_SMAP_LOCKED, // ul_int smaps_rollup: Locked
+ PIDS_SMAP_PRV_CLEAN, // ul_int smaps_rollup: Private_Clean
+ PIDS_SMAP_PRV_DIRTY, // ul_int smaps_rollup: Private_Dirty
+ PIDS_SMAP_PRV_TOTAL, // ul_int derived from SMAP_PRV_CLEAN + SMAP_PRV_DIRTY
+ PIDS_SMAP_PSS, // ul_int smaps_rollup: Pss
+ PIDS_SMAP_PSS_ANON, // ul_int smaps_rollup: Pss_Anon
+ PIDS_SMAP_PSS_FILE, // ul_int smaps_rollup: Pss_File
+ PIDS_SMAP_PSS_SHMEM, // ul_int smaps_rollup: Pss_Shmem
+ PIDS_SMAP_REFERENCED, // ul_int smaps_rollup: Referenced
+ PIDS_SMAP_RSS, // ul_int smaps_rollup: Rss
+ PIDS_SMAP_SHR_CLEAN, // ul_int smaps_rollup: Shared_Clean
+ PIDS_SMAP_SHR_DIRTY, // ul_int smaps_rollup: Shared_Dirty
+ PIDS_SMAP_SWAP, // ul_int smaps_rollup: Swap
+ PIDS_SMAP_SWAP_PSS, // ul_int smaps_rollup: SwapPss
+ PIDS_STATE, // s_ch stat: state or status: State
+ PIDS_SUPGIDS, // str status: Groups
+ PIDS_SUPGROUPS, // str derived from SUPGIDS, see getgrgid(3)
+ PIDS_TICS_ALL, // ull_int derived from stat: stime + utime
+ PIDS_TICS_ALL_C, // ull_int derived from stat: stime + utime + cstime + cutime
+ PIDS_TICS_ALL_DELTA, // u_int derived from TICS_ALL
+ PIDS_TICS_BEGAN, // ull_int stat: start_time
+ PIDS_TICS_BLKIO, // ull_int stat: blkio_ticks
+ PIDS_TICS_GUEST, // ull_int stat: gtime
+ PIDS_TICS_GUEST_C, // ull_int derived from stat: gtime + cgtime
+ PIDS_TICS_SYSTEM, // ull_int stat: stime
+ PIDS_TICS_SYSTEM_C, // ull_int derived from stat: stime + cstime
+ PIDS_TICS_USER, // ull_int stat: utime
+ PIDS_TICS_USER_C, // ull_int derived from stat: utime + cutime
+ PIDS_TIME_ALL, // real * derived from stat: (utime + stime) / hertz
+ PIDS_TIME_ALL_C, // real * derived from stat: (utime + stime + cutime + cstime) / hertz
+ PIDS_TIME_ELAPSED, // real * derived from stat: (/proc/uptime - start_time) / hertz
+ PIDS_TIME_START, // real * derived from stat: start_time / hertz
+ PIDS_TTY, // s_int stat: tty_nr
+ PIDS_TTY_NAME, // str derived from TTY
+ PIDS_TTY_NUMBER, // str derived from TTY as str
+ PIDS_UTILIZATION, // real derived from TIME_ALL / TIME_ELAPSED, as percentage
+ PIDS_UTILIZATION_C, // real derived from TIME_ALL_C / TIME_ELAPSED, as percentage
+ PIDS_VM_DATA, // ul_int status: VmData
+ PIDS_VM_EXE, // ul_int status: VmExe
+ PIDS_VM_LIB, // ul_int status: VmLib
+ PIDS_VM_RSS, // ul_int status: VmRSS
+ PIDS_VM_RSS_ANON, // ul_int status: RssAnon
+ PIDS_VM_RSS_FILE, // ul_int status: RssFile
+ PIDS_VM_RSS_LOCKED, // ul_int status: VmLck
+ PIDS_VM_RSS_SHARED, // ul_int status: RssShmem
+ PIDS_VM_SIZE, // ul_int status: VmSize
+ PIDS_VM_STACK, // ul_int status: VmStk
+ PIDS_VM_SWAP, // ul_int status: VmSwap
+ PIDS_VM_USED, // ul_int derived from status: VmRSS + VmSwap
+ PIDS_VSIZE_BYTES, // ul_int stat: vsize
+ PIDS_WCHAN_NAME // str wchan
+};
+ // * while these are all expressed as seconds, each can be
+ // converted into tics/jiffies with no loss of precision
+ // when multiplied by hertz obtained via procps_misc(3).
+enum pids_fetch_type {
+ PIDS_FETCH_TASKS_ONLY,
+ PIDS_FETCH_THREADS_TOO
+};
+
+enum pids_select_type {
+ PIDS_SELECT_PID = 0x10000,
+ PIDS_SELECT_PID_THREADS = 0x10001,
+ PIDS_SELECT_UID = 0x20000,
+ PIDS_SELECT_UID_THREADS = 0x20001
+};
+
+enum pids_sort_order {
+ PIDS_SORT_ASCEND = +1,
+ PIDS_SORT_DESCEND = -1
+};
+
+
+struct pids_result {
+ enum pids_item item;
+ union {
+ signed char s_ch;
+ signed int s_int;
+ unsigned int u_int;
+ unsigned long ul_int;
+ unsigned long long ull_int;
+ char *str;
+ char **strv;
+ double real;
+ } result;
+};
+
+struct pids_stack {
+ struct pids_result *head;
+};
+
+struct pids_counts {
+ int total;
+ int running, sleeping, stopped, zombied, other;
+};
+
+struct pids_fetch {
+ struct pids_counts *counts;
+ struct pids_stack **stacks;
+};
+
+struct pids_info;
+
+
+#define PIDS_VAL( relative_enum, type, stack, info ) \
+ stack -> head [ relative_enum ] . result . type
+
+
+int procps_pids_new (struct pids_info **info, enum pids_item *items, int numitems);
+int procps_pids_ref (struct pids_info *info);
+int procps_pids_unref (struct pids_info **info);
+
+struct pids_stack *fatal_proc_unmounted (
+ struct pids_info *info,
+ int return_self);
+
+struct pids_stack *procps_pids_get (
+ struct pids_info *info,
+ enum pids_fetch_type which);
+
+struct pids_fetch *procps_pids_reap (
+ struct pids_info *info,
+ enum pids_fetch_type which);
+
+int procps_pids_reset (
+ struct pids_info *info,
+ enum pids_item *newitems,
+ int newnumitems);
+
+struct pids_fetch *procps_pids_select (
+ struct pids_info *info,
+ unsigned *these,
+ int numthese,
+ enum pids_select_type which);
+
+struct pids_stack **procps_pids_sort (
+ struct pids_info *info,
+ struct pids_stack *stacks[],
+ int numstacked,
+ enum pids_item sortitem,
+ enum pids_sort_order order);
+
+
+#ifdef XTRA_PROCPS_DEBUG
+# include "xtra-procps-debug.h"
+#endif
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/library/include/procps-private.h b/library/include/procps-private.h
new file mode 100644
index 0000000..835ea21
--- /dev/null
+++ b/library/include/procps-private.h
@@ -0,0 +1,28 @@
+/*
+ * libprocps - Library to read proc filesystem
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef PROCPS_PRIVATE_H
+#define PROCPS_PRIVATE_H
+
+#define PROCPS_EXPORT __attribute__ ((visibility("default")))
+
+#define STRINGIFY_ARG(a) #a
+#define STRINGIFY(a) STRINGIFY_ARG(a)
+
+#define MAXTABLE(t) (int)(sizeof(t) / sizeof(t[0]))
+
+#endif
diff --git a/library/include/pwcache.h b/library/include/pwcache.h
new file mode 100644
index 0000000..524a2af
--- /dev/null
+++ b/library/include/pwcache.h
@@ -0,0 +1,38 @@
+/*
+ * pwcache.c - memory cache passwd file handling
+ *
+ * Copyright © 2011-2023 Jim Warner <james.warner@comcast.net>
+ * Copyright © 2015-2023 Craig Small <csmall@dropbear.xyz>
+ * Copyright © 2002 Albert Cahalan
+ *
+ * Older version:
+ * Copyright © 1992-1998 Michael K. Johnson <johnsonm@redhat.com>
+ * Note: most likely none of his code remains
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef PROCPS_PROC_PWCACHE_H
+#define PROCPS_PROC_PWCACHE_H
+
+#include <sys/types.h>
+
+// used in pwcache and in readproc to set size of username or groupname
+#define P_G_SZ 33
+
+char *pwcache_get_user(uid_t uid);
+char *pwcache_get_group(gid_t gid);
+
+#endif
diff --git a/library/include/readproc.h b/library/include/readproc.h
new file mode 100644
index 0000000..33c630e
--- /dev/null
+++ b/library/include/readproc.h
@@ -0,0 +1,303 @@
+/*
+ * readproc - interface to process table
+ *
+ * Copyright © 2002-2023 Craig Small <csmall@dropbear.xyz>
+ * Copyright © 2011-2023 Jim Warner <james.warner@comcast.net>
+ * Copyright © 1998-2010 Albert Cahalan
+ * Copyright © 1998 Michael K. Johnson
+ * Copyright © 1996 Charles L. Blake.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef PROCPS_PROC_READPROC_H
+#define PROCPS_PROC_READPROC_H
+
+#include <sys/types.h>
+#include <dirent.h>
+#include <unistd.h>
+#include "misc.h"
+
+// the following is development only, forcing display of "[ duplicate ENUM ]" strings
+// #define FALSE_THREADS /* set most child string fields to NULL */
+
+
+// This is to help document a transition from pid to tgid/tid caused
+// by the introduction of thread support. It is used in cases where
+// neither tgid nor tid seemed correct. (in other words, FIXME)
+#define XXXID tid
+
+// Basic data structure which holds all information we can get about a process.
+// (unless otherwise specified, fields are read from /proc/#/stat)
+//
+// Most of it comes from task_struct in linux/sched.h
+//
+typedef struct proc_t {
+ int
+ tid, // (special) task id, the POSIX thread ID (see also: tgid)
+ ppid; // stat,status pid of parent process
+ char
+ state, // stat,status single-char code for process state (S=sleeping)
+ pad_1, // n/a padding
+ pad_2, // n/a padding
+ pad_3; // n/a padding
+ unsigned long long
+ utime, // stat user-mode CPU time accumulated by process
+ stime, // stat kernel-mode CPU time accumulated by process
+ cutime, // stat cumulative utime of process and reaped children
+ cstime, // stat cumulative stime of process and reaped children
+ start_time, // stat start time of process -- seconds since system boot
+ blkio_tics, // stat time spent waiting for block IO
+ gtime, // stat guest time of the task in jiffies
+ cgtime; // stat guest time of the task children in jiffies
+ int // next 3 fields are NOT filled in by readproc
+ pcpu, // stat (special) elapsed tics for %CPU usage calculation
+ maj_delta, // stat (special) major page faults since last update
+ min_delta; // stat (special) minor page faults since last update
+ char
+ // Linux 2.1.7x and up have 64 signals. Allow 64, plus '\0' and padding.
+ signal[18], // status mask of pending signals
+ blocked[18], // status mask of blocked signals
+ sigignore[18], // status mask of ignored signals
+ sigcatch[18], // status mask of caught signals
+ _sigpnd[18]; // status mask of PER TASK pending signals
+ unsigned long
+ start_code, // stat address of beginning of code segment
+ end_code, // stat address of end of code segment
+ start_stack, // stat address of the bottom of stack for the process
+ kstk_esp, // stat kernel stack pointer
+ kstk_eip, // stat kernel instruction pointer
+ wchan, // stat (special) address of kernel wait channel proc is sleeping in
+ rss, // stat identical to 'resident'
+ alarm; // stat ?
+ int
+ priority, // stat kernel scheduling priority
+ nice; // stat standard unix nice level of process
+ unsigned long
+ // the next 7 members come from /proc/#/statm
+ size, // statm total virtual memory (as # pages)
+ resident, // statm resident non-swapped memory (as # pages)
+ share, // statm shared (mmap'd) memory (as # pages)
+ trs, // statm text (exe) resident set (as # pages)
+ lrs, // statm library resident set (always 0 w/ 2.6)
+ drs, // statm data+stack resident set (as # pages)
+ dt; // statm dirty pages (always 0 w/ 2.6)
+ unsigned long
+ vm_size, // status equals 'size' (as kb)
+ vm_lock, // status locked pages (as kb)
+ vm_rss, // status equals 'rss' and/or 'resident' (as kb)
+ vm_rss_anon, // status the 'anonymous' portion of vm_rss (as kb)
+ vm_rss_file, // status the 'file-backed' portion of vm_rss (as kb)
+ vm_rss_shared, // status the 'shared' portion of vm_rss (as kb)
+ vm_data, // status data only size (as kb)
+ vm_stack, // status stack only size (as kb)
+ vm_swap, // status based on linux-2.6.34 "swap ents" (as kb)
+ vm_exe, // status equals 'trs' (as kb)
+ vm_lib, // status total, not just used, library pages (as kb)
+ vsize, // stat number of pages of virtual memory ...
+ rss_rlim, // stat resident set size limit?
+ flags, // stat kernel flags for the process
+ min_flt, // stat number of minor page faults since process start
+ maj_flt, // stat number of major page faults since process start
+ cmin_flt, // stat cumulative min_flt of process and child processes
+ cmaj_flt, // stat cumulative maj_flt of process and child processes
+ rchar, // io characters read
+ wchar, // io characters written
+ syscr, // io number of read I/O operations
+ syscw, // io number of write I/O operations
+ read_bytes, // io number of bytes fetched from the storage layer
+ write_bytes, // io number of bytes sent to the storage layer
+ cancelled_write_bytes, // io number of bytes truncating pagecache
+ smap_Rss, // smaps_rollup mapping currently resident in RAM
+ smap_Pss, // " Rss divided by total processes sharing it
+ smap_Pss_Anon, // " proportional share of 'anonymous' memory
+ smap_Pss_File, // " proportional share of 'file' memory
+ smap_Pss_Shmem, // " proportional share of 'shmem' memory
+ smap_Shared_Clean, // " unmodified shared memory
+ smap_Shared_Dirty, // " altered shared memory
+ smap_Private_Clean, // " unmodified private memory
+ smap_Private_Dirty, // " altered private memory
+ smap_Referenced, // " memory marked as referenced/accessed
+ smap_Anonymous, // " memory not belonging to any file
+ smap_LazyFree, // " memory marked by madvise(MADV_FREE)
+ smap_AnonHugePages, // " memory backed by transparent huge pages
+ smap_ShmemPmdMapped, // " shmem/tmpfs memory backed by huge pages
+ smap_FilePmdMapped, // " file memory backed by huge pages
+ smap_Shared_Hugetlb, // " hugetlbfs backed memory *not* counted in Rss/Pss
+ smap_Private_Hugetlb, // " hugetlbfs backed memory *not* counted in Rss/Pss
+ smap_Swap, // " swapped would-be-anonymous memory (includes swapped out shmem)
+ smap_SwapPss, // " the proportional share of 'Swap' (excludes swapped out shmem)
+ smap_Locked; // " memory amount locked to RAM
+ char
+ *environ, // (special) environment as string (/proc/#/environ)
+ *cmdline, // (special) command line as string (/proc/#/cmdline)
+ *cgroup, // (special) cgroup as string (/proc/#/cgroup)
+ *cgname, // (special) name portion of above (if possible)
+ *supgid, // status supplementary gids as comma delimited str
+ *supgrp, // supp grp names as comma delimited str, derived from supgid
+ **environ_v, // (special) environment string vectors (/proc/#/environ)
+ **cmdline_v, // (special) command line string vectors (/proc/#/cmdline)
+ **cgroup_v; // (special) cgroup string vectors (/proc/#/cgroup)
+ char
+ *euser, // stat(),status effective user name
+ *ruser, // status real user name
+ *suser, // status saved user name
+ *fuser, // status filesystem user name
+ *rgroup, // status real group name
+ *egroup, // status effective group name
+ *sgroup, // status saved group name
+ *fgroup, // status filesystem group name
+ *cmd; // stat,status basename of executable file in call to exec(2)
+ int
+ rtprio, // stat real-time priority
+ sched, // stat scheduling class
+ pgrp, // stat process group id
+ session, // stat session id
+ nlwp, // stat,status number of threads, or 0 if no clue
+ tgid, // (special) thread group ID, the POSIX PID (see also: tid)
+ tty; // stat full device number of controlling terminal
+ /* FIXME: int uids & gids should be uid_t or gid_t from pwd.h */
+ uid_t euid; gid_t egid; // stat(),status effective
+ uid_t ruid; gid_t rgid; // status real
+ uid_t suid; gid_t sgid; // status saved
+ uid_t fuid; gid_t fgid; // status fs (used for file access only)
+ int
+ tpgid, // stat terminal process group id
+ exit_signal, // stat might not be SIGCHLD
+ processor; // stat current (or most recent?) CPU
+ int
+ oom_score, // oom_score (badness for OOM killer)
+ oom_adj; // oom_adj (adjustment to OOM score)
+ struct procps_ns ns; // (ns subdir) inode number of namespaces
+ char
+ *sd_mach, // n/a systemd vm/container name
+ *sd_ouid, // n/a systemd session owner uid
+ *sd_seat, // n/a systemd login session seat
+ *sd_sess, // n/a systemd login session id
+ *sd_slice, // n/a systemd slice unit
+ *sd_unit, // n/a systemd system unit id
+ *sd_uunit; // n/a systemd user unit id
+ char
+ *lxcname, // n/a lxc container name
+ *exe; // exe executable path + name
+ int
+ luid, // loginuid user id at login
+ autogrp_id, // autogroup autogroup number (id)
+ autogrp_nice; // autogroup autogroup nice value
+} proc_t;
+
+// PROCTAB: data structure holding the persistent information readproc needs
+// from openproc(). The setup is intentionally similar to the dirent interface
+// and other system table interfaces (utmp+wtmp come to mind).
+
+#define PROCPATHLEN 64 // must hold /proc/2000222000/task/2000222000/cmdline
+
+typedef struct PROCTAB {
+ DIR *procfs;
+// char deBug0[64];
+ DIR *taskdir; // for threads
+// char deBug1[64];
+ pid_t taskdir_user; // for threads
+ int(*finder)(struct PROCTAB *__restrict const, proc_t *__restrict const);
+ proc_t*(*reader)(struct PROCTAB *__restrict const, proc_t *__restrict const);
+ int(*taskfinder)(struct PROCTAB *__restrict const, const proc_t *__restrict const, proc_t *__restrict const, char *__restrict const);
+ proc_t*(*taskreader)(struct PROCTAB *__restrict const, proc_t *__restrict const, char *__restrict const);
+ pid_t *pids; // pids of the procs
+ uid_t *uids; // uids of procs
+ int nuid; // cannot really sentinel-terminate unsigned short[]
+ int i; // generic
+ int hide_kernel; // getenv LIBPROC_HIDE_KERNEL was set
+ unsigned flags;
+ unsigned u; // generic
+ void * vp; // generic
+ char path[PROCPATHLEN]; // must hold /proc/2000222000/task/2000222000/cmdline
+ unsigned pathlen; // length of string in the above (w/o '\0')
+} PROCTAB;
+
+
+// openproc/readproctab:
+//
+// Return PROCTAB* / *proc_t[] or NULL on error ((probably) "/proc" cannot be
+// opened.) By default readproc will consider all processes as valid to parse
+// and return, but not actually fill in the cmdline, environ, and /proc/#/statm
+// derived memory fields.
+//
+// `flags' (a bitwise-or of PROC_* below) modifies the default behavior. The
+// "fill" options will cause more of the proc_t to be filled in. The "filter"
+// options all use the second argument as the pointer to a list of objects:
+// process status', process id's, user id's. The third
+// argument is the length of the list (currently only used for lists of user
+// id's since uid_t supports no convenient termination sentinel.)
+
+#define PROC_FILLMEM 0x00000001 // read statm
+#define PROC_FILLARG 0x00000002 // alloc and fill in `cmdline' vectors
+#define PROC_FILLENV 0x00000004 // alloc and fill in `environ' vectors
+#define PROC_FILLUSR 0x00000008 // resolve user id number -> user name
+#define PROC_FILLGRP 0x00000010 // resolve group id number -> group name
+#define PROC_FILLSTATUS 0x00000020 // read status
+#define PROC_FILLSTAT 0x00000040 // read stat
+#define PROC_FILLCGROUP 0x00000080 // alloc and fill in `cgroup` vectors
+#define PROC_FILLOOM 0x00000100 // fill in proc_t oom_score and oom_adj
+#define PROC_FILLNS 0x00000200 // fill in proc_t namespace information
+#define PROC_FILLSYSTEMD 0x00000400 // fill in proc_t systemd information
+#define PROC_FILL_LXC 0x00000800 // fill in proc_t lxcname, if possible
+#define PROC_FILL_LUID 0x00001000 // fill in proc_t luid (login user id)
+#define PROC_FILL_EXE 0x00002000 // fill in proc_t exe path + pgm name
+#define PROC_FILLIO 0x00004000 // fill in proc_t io information
+#define PROC_FILLSMAPS 0x00008000 // fill in proc_t smaps_rollup stuff
+
+// consider only processes with one of the passed:
+#define PROC_PID 0x00010000 // process id numbers ( 0 terminated )
+#define PROC_UID 0x00020000 // user id numbers ( length needed )
+// Note: the above 2 values must NOT change without also changing pids.h !!!
+
+#define PROC_EDITCGRPCVT 0x00040000 // edit `cgroup' as regular string
+#define PROC_EDITCMDLCVT 0x00080000 // edit `cmdline' as regular string
+#define PROC_EDITENVRCVT 0x00100000 // edit `environ' as regular string
+
+// these three also require the PROC_FILLSTATUS flage
+#define PROC_FILL_OUSERS ( 0x00200000 | PROC_FILLSTATUS ) // obtain other user names
+#define PROC_FILL_OGROUPS ( 0x00400000 | PROC_FILLSTATUS ) // obtain other group names
+#define PROC_FILL_SUPGRP ( 0x00800000 | PROC_FILLSTATUS ) // obtain supplementary group names
+
+// and let's put new flags here ...
+#define PROC_FILLAUTOGRP 0x01000000 // fill in proc_t autogroup stuff
+
+// it helps to give app code a few spare bits
+#define PROC_SPARE_1 0x10000000
+#define PROC_SPARE_2 0x20000000
+#define PROC_SPARE_3 0x40000000
+#define PROC_SPARE_4 0x80000000
+
+// Function definitions
+// Initialize a PROCTAB structure holding needed call-to-call persistent data
+PROCTAB *openproc(unsigned flags, ... /* pid_t *| uid_t *| dev_t *| char *[, int n] */ );
+// Retrieve the next process or task matching the criteria set by the openproc().
+//
+// Note: When NULL is used as the readproc 'p' or readeither 'x'
+// parameter, the library will allocate the necessary proc_t storage.
+//
+// Alternatively, you may provide your own reuseable buffer address
+// in which case that buffer *MUST* be initialized to zero one time
+// only before first use. Thereafter, the library will manage such
+// a passed proc_t, freeing any additional acquired memory associated
+// with the previous process or thread.
+proc_t *readproc(PROCTAB *__restrict const PT, proc_t *__restrict p);
+proc_t *readeither(PROCTAB *__restrict const PT, proc_t *__restrict x);
+int look_up_our_self(void);
+void closeproc(PROCTAB *PT);
+char **vectorize_this_str(const char *src);
+
+#endif
diff --git a/library/include/slabinfo.h b/library/include/slabinfo.h
new file mode 100644
index 0000000..f63ca79
--- /dev/null
+++ b/library/include/slabinfo.h
@@ -0,0 +1,140 @@
+/*
+ * slabinfo.h - slab pools related declarations for libproc2
+ *
+ * Copyright © 2015-2023 Jim Warner <james.warner@comcast.net>
+ * Copyright © 2015-2023 Craig Small <csmall@dropbear.xyz>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef PROCPS_SLABINFO_H
+#define PROCPS_SLABINFO_H
+
+#ifdef __cplusplus
+extern "C "{
+#endif
+
+enum slabinfo_item {
+ SLABINFO_noop, // ( never altered )
+ SLABINFO_extra, // ( reset to zero )
+ // returns origin, see proc(5)
+ // ------- -------------------
+ SLAB_NAME, // str /proc/slabinfo
+ SLAB_NUM_OBJS, // u_int "
+ SLAB_ACTIVE_OBJS, // u_int "
+ SLAB_OBJ_SIZE, // u_int "
+ SLAB_OBJ_PER_SLAB, // u_int "
+ SLAB_NUMS_SLABS, // u_int "
+ SLAB_ACTIVE_SLABS, // u_int "
+ SLAB_PAGES_PER_SLAB, // u_int "
+ SLAB_PERCENT_USED, // u_int derived from ACTIVE_OBJS / NUM_OBJS
+ SLAB_SIZE_TOTAL, // ul_int derived from page size * NUMS_SLABS * PAGES_PER_SLAB
+
+ SLABS_CACHES_TOTAL, // u_int derived from all caches
+ SLABS_CACHES_ACTIVE, // u_int "
+ SLABS_NUM_OBJS, // u_int "
+ SLABS_ACTIVE_OBJS, // u_int "
+ SLABS_OBJ_SIZE_AVG, // u_int "
+ SLABS_OBJ_SIZE_MIN, // u_int "
+ SLABS_OBJ_SIZE_MAX, // u_int "
+ SLABS_NUMS_SLABS, // u_int "
+ SLABS_ACTIVE_SLABS, // u_int "
+ SLABS_PAGES_TOTAL, // u_int "
+ SLABS_SIZE_ACTIVE, // ul_int "
+ SLABS_SIZE_TOTAL, // ul_int "
+
+ SLABS_DELTA_CACHES_TOTAL, // s_int derived from above
+ SLABS_DELTA_CACHES_ACTIVE, // s_int "
+ SLABS_DELTA_NUM_OBJS, // s_int "
+ SLABS_DELTA_ACTIVE_OBJS, // s_int "
+ SLABS_DELTA_OBJ_SIZE_AVG, // s_int "
+ SLABS_DELTA_OBJ_SIZE_MIN, // s_int "
+ SLABS_DELTA_OBJ_SIZE_MAX, // s_int "
+ SLABS_DELTA_NUMS_SLABS, // s_int "
+ SLABS_DELTA_ACTIVE_SLABS, // s_int "
+ SLABS_DELTA_PAGES_TOTAL, // s_int "
+ SLABS_DELTA_SIZE_ACTIVE, // s_int "
+ SLABS_DELTA_SIZE_TOTAL // s_int "
+};
+
+enum slabinfo_sort_order {
+ SLABINFO_SORT_ASCEND = +1,
+ SLABINFO_SORT_DESCEND = -1
+};
+
+
+struct slabinfo_result {
+ enum slabinfo_item item;
+ union {
+ signed int s_int;
+ unsigned int u_int;
+ unsigned long ul_int;
+ char *str;
+ } result;
+};
+
+struct slabinfo_stack {
+ struct slabinfo_result *head;
+};
+
+struct slabinfo_reaped {
+ int total;
+ struct slabinfo_stack **stacks;
+};
+
+struct slabinfo_info;
+
+
+#define SLABINFO_GET( info, actual_enum, type ) ( { \
+ struct slabinfo_result *r = procps_slabinfo_get( info, actual_enum ); \
+ r ? r->result . type : 0; } )
+
+#define SLABINFO_VAL( relative_enum, type, stack, info ) \
+ stack -> head [ relative_enum ] . result . type
+
+
+int procps_slabinfo_new (struct slabinfo_info **info);
+int procps_slabinfo_ref (struct slabinfo_info *info);
+int procps_slabinfo_unref (struct slabinfo_info **info);
+
+struct slabinfo_result *procps_slabinfo_get (
+ struct slabinfo_info *info,
+ enum slabinfo_item item);
+
+struct slabinfo_reaped *procps_slabinfo_reap (
+ struct slabinfo_info *info,
+ enum slabinfo_item *items,
+ int numitems);
+
+struct slabinfo_stack *procps_slabinfo_select (
+ struct slabinfo_info *info,
+ enum slabinfo_item *items,
+ int numitems);
+
+struct slabinfo_stack **procps_slabinfo_sort (
+ struct slabinfo_info *info,
+ struct slabinfo_stack *stacks[],
+ int numstacked,
+ enum slabinfo_item sortitem,
+ enum slabinfo_sort_order order);
+
+
+#ifdef XTRA_PROCPS_DEBUG
+# include "xtra-procps-debug.h"
+#endif
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/library/include/stat.h b/library/include/stat.h
new file mode 100644
index 0000000..7adefa6
--- /dev/null
+++ b/library/include/stat.h
@@ -0,0 +1,175 @@
+/*
+ * stat.h - cpu/numa related declarations for libproc2
+ *
+ * Copyright © 2015-2023 Jim Warner <james.warner@comcast.net>
+ * Copyright © 2015-2023 Craig Small <csmall@dropbear.xyz>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef PROCPS_STAT_H
+#define PROCPS_STAT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum stat_item {
+ STAT_noop, // ( never altered )
+ STAT_extra, // ( reset to zero )
+ // returns origin, see proc(5)
+ // ------- -------------------
+ STAT_TIC_ID, // s_int /proc/stat, cpu or numa node id
+ STAT_TIC_ID_CORE, // s_int /proc/cpuinfo: 'core id', -1 = n/a
+ STAT_TIC_NUMA_NODE, // s_int [ CPU ID based, see: numa(3) ]
+ STAT_TIC_NUM_CONTRIBUTORS, // s_int [ total CPUs contributing to TIC counts ]
+ STAT_TIC_TYPE_CORE, // s_int [ 2 = P-core, 1 = E-core, 0 = n/a ]
+
+ STAT_TIC_USER, // ull_int /proc/stat
+ STAT_TIC_NICE, // ull_int "
+ STAT_TIC_SYSTEM, // ull_int "
+ STAT_TIC_IDLE, // ull_int "
+ STAT_TIC_IOWAIT, // ull_int "
+ STAT_TIC_IRQ, // ull_int "
+ STAT_TIC_SOFTIRQ, // ull_int "
+ STAT_TIC_STOLEN, // ull_int "
+ STAT_TIC_GUEST, // ull_int "
+ STAT_TIC_GUEST_NICE, // ull_int "
+
+ STAT_TIC_DELTA_USER, // sl_int derived from above
+ STAT_TIC_DELTA_NICE, // sl_int "
+ STAT_TIC_DELTA_SYSTEM, // sl_int "
+ STAT_TIC_DELTA_IDLE, // sl_int "
+ STAT_TIC_DELTA_IOWAIT, // sl_int "
+ STAT_TIC_DELTA_IRQ, // sl_int "
+ STAT_TIC_DELTA_SOFTIRQ, // sl_int "
+ STAT_TIC_DELTA_STOLEN, // sl_int "
+ STAT_TIC_DELTA_GUEST, // sl_int "
+ STAT_TIC_DELTA_GUEST_NICE, // sl_int "
+
+ STAT_TIC_SUM_USER, // ull_int derived from USER + NICE tics
+ STAT_TIC_SUM_SYSTEM, // ull_int derived from SYSTEM + IRQ + SOFTIRQ tics
+ STAT_TIC_SUM_IDLE, // ull_int derived from IDLE + IOWAIT tics
+ STAT_TIC_SUM_BUSY, // ull_int derived from SUM_TOTAL - SUM_IDLE tics
+ STAT_TIC_SUM_TOTAL, // ull_int derived from sum of all 10 tics
+
+ STAT_TIC_SUM_DELTA_USER, // sl_int derived from above
+ STAT_TIC_SUM_DELTA_SYSTEM, // sl_int "
+ STAT_TIC_SUM_DELTA_IDLE, // sl_int "
+ STAT_TIC_SUM_DELTA_BUSY, // sl_int "
+ STAT_TIC_SUM_DELTA_TOTAL, // sl_int "
+
+ STAT_SYS_CTX_SWITCHES, // ul_int /proc/stat
+ STAT_SYS_INTERRUPTS, // ul_int "
+ STAT_SYS_PROC_BLOCKED, // ul_int "
+ STAT_SYS_PROC_CREATED, // ul_int "
+ STAT_SYS_PROC_RUNNING, // ul_int "
+ STAT_SYS_TIME_OF_BOOT, // ul_int "
+
+ STAT_SYS_DELTA_CTX_SWITCHES, // s_int derived from above
+ STAT_SYS_DELTA_INTERRUPTS, // s_int "
+ STAT_SYS_DELTA_PROC_BLOCKED, // s_int "
+ STAT_SYS_DELTA_PROC_CREATED, // s_int "
+ STAT_SYS_DELTA_PROC_RUNNING // s_int "
+};
+
+enum stat_reap_type {
+ STAT_REAP_CPUS_ONLY,
+ STAT_REAP_NUMA_NODES_TOO
+};
+
+enum stat_sort_order {
+ STAT_SORT_ASCEND = +1,
+ STAT_SORT_DESCEND = -1
+};
+
+
+struct stat_result {
+ enum stat_item item;
+ union {
+ signed int s_int;
+ signed long sl_int;
+ unsigned long ul_int;
+ unsigned long long ull_int;
+ } result;
+};
+
+struct stat_stack {
+ struct stat_result *head;
+};
+
+struct stat_reap {
+ int total;
+ struct stat_stack **stacks;
+};
+
+struct stat_reaped {
+ struct stat_stack *summary;
+ struct stat_reap *cpus;
+ struct stat_reap *numa;
+};
+
+struct stat_info;
+
+
+ // STAT_TIC_ID value for /proc/stat cpu summary
+#define STAT_SUMMARY_ID -11111
+ // STAT_TIC_NUMA_NODE value for STAT_REAP_CPUS_ONLY or
+ // for STAT_REAP_NUMA_NODES_TOO when node was inactive
+#define STAT_NODE_INVALID -22222
+
+
+#define STAT_GET( info, actual_enum, type ) ( { \
+ struct stat_result *r = procps_stat_get( info, actual_enum ); \
+ r ? r->result . type : 0; } )
+
+#define STAT_VAL( relative_enum, type, stack, info ) \
+ stack -> head [ relative_enum ] . result . type
+
+
+int procps_stat_new (struct stat_info **info);
+int procps_stat_ref (struct stat_info *info);
+int procps_stat_unref (struct stat_info **info);
+
+struct stat_result *procps_stat_get (
+ struct stat_info *info,
+ enum stat_item item);
+
+struct stat_reaped *procps_stat_reap (
+ struct stat_info *info,
+ enum stat_reap_type what,
+ enum stat_item *items,
+ int numitems);
+
+struct stat_stack *procps_stat_select (
+ struct stat_info *info,
+ enum stat_item *items,
+ int numitems);
+
+struct stat_stack **procps_stat_sort (
+ struct stat_info *info,
+ struct stat_stack *stacks[],
+ int numstacked,
+ enum stat_item sortitem,
+ enum stat_sort_order order);
+
+
+#ifdef XTRA_PROCPS_DEBUG
+# include "xtra-procps-debug.h"
+#endif
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/library/include/vmstat.h b/library/include/vmstat.h
new file mode 100644
index 0000000..9b94931
--- /dev/null
+++ b/library/include/vmstat.h
@@ -0,0 +1,382 @@
+/*
+ * vmstat.h - virtual memory related declarations for libproc2
+ *
+ * Copyright © 2015-2023 Jim Warner <james.warner@comcast.net>
+ * Copyright © 2015-2023 Craig Small <csmall@dropbear.xyz>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef PROCPS_VMSTAT_H
+#define PROCPS_VMSTAT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum vmstat_item {
+ VMSTAT_noop, // ( never altered )
+ VMSTAT_extra, // ( reset to zero )
+ // returns origin, see proc(5)
+ // ------- -------------------
+ VMSTAT_ALLOCSTALL_DMA, // ul_int /proc/vmstat
+ VMSTAT_ALLOCSTALL_DMA32, // ul_int "
+ VMSTAT_ALLOCSTALL_HIGH, // ul_int "
+ VMSTAT_ALLOCSTALL_MOVABLE, // ul_int "
+ VMSTAT_ALLOCSTALL_NORMAL, // ul_int "
+ VMSTAT_BALLOON_DEFLATE, // ul_int "
+ VMSTAT_BALLOON_INFLATE, // ul_int "
+ VMSTAT_BALLOON_MIGRATE, // ul_int "
+ VMSTAT_COMPACT_DAEMON_FREE_SCANNED, // ul_int "
+ VMSTAT_COMPACT_DAEMON_MIGRATE_SCANNED, // ul_int "
+ VMSTAT_COMPACT_DAEMON_WAKE, // ul_int "
+ VMSTAT_COMPACT_FAIL, // ul_int "
+ VMSTAT_COMPACT_FREE_SCANNED, // ul_int "
+ VMSTAT_COMPACT_ISOLATED, // ul_int "
+ VMSTAT_COMPACT_MIGRATE_SCANNED, // ul_int "
+ VMSTAT_COMPACT_STALL, // ul_int "
+ VMSTAT_COMPACT_SUCCESS, // ul_int "
+ VMSTAT_DROP_PAGECACHE, // ul_int "
+ VMSTAT_DROP_SLAB, // ul_int "
+ VMSTAT_HTLB_BUDDY_ALLOC_FAIL, // ul_int "
+ VMSTAT_HTLB_BUDDY_ALLOC_SUCCESS, // ul_int "
+ VMSTAT_KSWAPD_HIGH_WMARK_HIT_QUICKLY, // ul_int "
+ VMSTAT_KSWAPD_INODESTEAL, // ul_int "
+ VMSTAT_KSWAPD_LOW_WMARK_HIT_QUICKLY, // ul_int "
+ VMSTAT_NR_ACTIVE_ANON, // ul_int "
+ VMSTAT_NR_ACTIVE_FILE, // ul_int "
+ VMSTAT_NR_ANON_PAGES, // ul_int "
+ VMSTAT_NR_ANON_TRANSPARENT_HUGEPAGES, // ul_int "
+ VMSTAT_NR_BOUNCE, // ul_int "
+ VMSTAT_NR_DIRTIED, // ul_int "
+ VMSTAT_NR_DIRTY, // ul_int "
+ VMSTAT_NR_DIRTY_BACKGROUND_THRESHOLD, // ul_int "
+ VMSTAT_NR_DIRTY_THRESHOLD, // ul_int "
+ VMSTAT_NR_FILE_HUGEPAGES, // ul_int "
+ VMSTAT_NR_FILE_PAGES, // ul_int "
+ VMSTAT_NR_FILE_PMDMAPPED, // ul_int "
+ VMSTAT_NR_FOLL_PIN_ACQUIRED, // ul_int "
+ VMSTAT_NR_FOLL_PIN_RELEASED, // ul_int "
+ VMSTAT_NR_FREE_CMA, // ul_int "
+ VMSTAT_NR_FREE_PAGES, // ul_int "
+ VMSTAT_NR_INACTIVE_ANON, // ul_int "
+ VMSTAT_NR_INACTIVE_FILE, // ul_int "
+ VMSTAT_NR_ISOLATED_ANON, // ul_int "
+ VMSTAT_NR_ISOLATED_FILE, // ul_int "
+ VMSTAT_NR_KERNEL_MISC_RECLAIMABLE, // ul_int "
+ VMSTAT_NR_KERNEL_STACK, // ul_int "
+ VMSTAT_NR_MAPPED, // ul_int "
+ VMSTAT_NR_MLOCK, // ul_int "
+ VMSTAT_NR_PAGE_TABLE_PAGES, // ul_int "
+ VMSTAT_NR_SHADOW_CALL_STACK, // ul_int "
+ VMSTAT_NR_SHMEM, // ul_int "
+ VMSTAT_NR_SHMEM_HUGEPAGES, // ul_int "
+ VMSTAT_NR_SHMEM_PMDMAPPED, // ul_int "
+ VMSTAT_NR_SLAB_RECLAIMABLE, // ul_int "
+ VMSTAT_NR_SLAB_UNRECLAIMABLE, // ul_int "
+ VMSTAT_NR_UNEVICTABLE, // ul_int "
+ VMSTAT_NR_UNSTABLE, // ul_int "
+ VMSTAT_NR_VMSCAN_IMMEDIATE_RECLAIM, // ul_int "
+ VMSTAT_NR_VMSCAN_WRITE, // ul_int "
+ VMSTAT_NR_WRITEBACK, // ul_int "
+ VMSTAT_NR_WRITEBACK_TEMP, // ul_int "
+ VMSTAT_NR_WRITTEN, // ul_int "
+ VMSTAT_NR_ZONE_ACTIVE_ANON, // ul_int "
+ VMSTAT_NR_ZONE_ACTIVE_FILE, // ul_int "
+ VMSTAT_NR_ZONE_INACTIVE_ANON, // ul_int "
+ VMSTAT_NR_ZONE_INACTIVE_FILE, // ul_int "
+ VMSTAT_NR_ZONE_UNEVICTABLE, // ul_int "
+ VMSTAT_NR_ZONE_WRITE_PENDING, // ul_int "
+ VMSTAT_NR_ZSPAGES, // ul_int "
+ VMSTAT_NUMA_FOREIGN, // ul_int "
+ VMSTAT_NUMA_HINT_FAULTS, // ul_int "
+ VMSTAT_NUMA_HINT_FAULTS_LOCAL, // ul_int "
+ VMSTAT_NUMA_HIT, // ul_int "
+ VMSTAT_NUMA_HUGE_PTE_UPDATES, // ul_int "
+ VMSTAT_NUMA_INTERLEAVE, // ul_int "
+ VMSTAT_NUMA_LOCAL, // ul_int "
+ VMSTAT_NUMA_MISS, // ul_int "
+ VMSTAT_NUMA_OTHER, // ul_int "
+ VMSTAT_NUMA_PAGES_MIGRATED, // ul_int "
+ VMSTAT_NUMA_PTE_UPDATES, // ul_int "
+ VMSTAT_OOM_KILL, // ul_int "
+ VMSTAT_PAGEOUTRUN, // ul_int "
+ VMSTAT_PGACTIVATE, // ul_int "
+ VMSTAT_PGALLOC_DMA, // ul_int "
+ VMSTAT_PGALLOC_DMA32, // ul_int "
+ VMSTAT_PGALLOC_HIGH, // ul_int "
+ VMSTAT_PGALLOC_MOVABLE, // ul_int "
+ VMSTAT_PGALLOC_NORMAL, // ul_int "
+ VMSTAT_PGDEACTIVATE, // ul_int "
+ VMSTAT_PGFAULT, // ul_int "
+ VMSTAT_PGFREE, // ul_int "
+ VMSTAT_PGINODESTEAL, // ul_int "
+ VMSTAT_PGLAZYFREE, // ul_int "
+ VMSTAT_PGLAZYFREED, // ul_int "
+ VMSTAT_PGMAJFAULT, // ul_int "
+ VMSTAT_PGMIGRATE_FAIL, // ul_int "
+ VMSTAT_PGMIGRATE_SUCCESS, // ul_int "
+ VMSTAT_PGPGIN, // ul_int "
+ VMSTAT_PGPGOUT, // ul_int "
+ VMSTAT_PGREFILL, // ul_int "
+ VMSTAT_PGROTATED, // ul_int "
+ VMSTAT_PGSCAN_ANON, // ul_int "
+ VMSTAT_PGSCAN_DIRECT, // ul_int "
+ VMSTAT_PGSCAN_DIRECT_THROTTLE, // ul_int "
+ VMSTAT_PGSCAN_FILE, // ul_int "
+ VMSTAT_PGSCAN_KSWAPD, // ul_int "
+ VMSTAT_PGSKIP_DMA, // ul_int "
+ VMSTAT_PGSKIP_DMA32, // ul_int "
+ VMSTAT_PGSKIP_HIGH, // ul_int "
+ VMSTAT_PGSKIP_MOVABLE, // ul_int "
+ VMSTAT_PGSKIP_NORMAL, // ul_int "
+ VMSTAT_PGSTEAL_ANON, // ul_int "
+ VMSTAT_PGSTEAL_DIRECT, // ul_int "
+ VMSTAT_PGSTEAL_FILE, // ul_int "
+ VMSTAT_PGSTEAL_KSWAPD, // ul_int "
+ VMSTAT_PSWPIN, // ul_int "
+ VMSTAT_PSWPOUT, // ul_int "
+ VMSTAT_SLABS_SCANNED, // ul_int "
+ VMSTAT_SWAP_RA, // ul_int "
+ VMSTAT_SWAP_RA_HIT, // ul_int "
+ VMSTAT_THP_COLLAPSE_ALLOC, // ul_int "
+ VMSTAT_THP_COLLAPSE_ALLOC_FAILED, // ul_int "
+ VMSTAT_THP_DEFERRED_SPLIT_PAGE, // ul_int "
+ VMSTAT_THP_FAULT_ALLOC, // ul_int "
+ VMSTAT_THP_FAULT_FALLBACK, // ul_int "
+ VMSTAT_THP_FAULT_FALLBACK_CHARGE, // ul_int "
+ VMSTAT_THP_FILE_ALLOC, // ul_int "
+ VMSTAT_THP_FILE_FALLBACK, // ul_int "
+ VMSTAT_THP_FILE_FALLBACK_CHARGE, // ul_int "
+ VMSTAT_THP_FILE_MAPPED, // ul_int "
+ VMSTAT_THP_SPLIT_PAGE, // ul_int "
+ VMSTAT_THP_SPLIT_PAGE_FAILED, // ul_int "
+ VMSTAT_THP_SPLIT_PMD, // ul_int "
+ VMSTAT_THP_SPLIT_PUD, // ul_int "
+ VMSTAT_THP_SWPOUT, // ul_int "
+ VMSTAT_THP_SWPOUT_FALLBACK, // ul_int "
+ VMSTAT_THP_ZERO_PAGE_ALLOC, // ul_int "
+ VMSTAT_THP_ZERO_PAGE_ALLOC_FAILED, // ul_int "
+ VMSTAT_UNEVICTABLE_PGS_CLEARED, // ul_int "
+ VMSTAT_UNEVICTABLE_PGS_CULLED, // ul_int "
+ VMSTAT_UNEVICTABLE_PGS_MLOCKED, // ul_int "
+ VMSTAT_UNEVICTABLE_PGS_MUNLOCKED, // ul_int "
+ VMSTAT_UNEVICTABLE_PGS_RESCUED, // ul_int "
+ VMSTAT_UNEVICTABLE_PGS_SCANNED, // ul_int "
+ VMSTAT_UNEVICTABLE_PGS_STRANDED, // ul_int "
+ VMSTAT_WORKINGSET_ACTIVATE, // ul_int "
+ VMSTAT_WORKINGSET_NODERECLAIM, // ul_int "
+ VMSTAT_WORKINGSET_NODES, // ul_int "
+ VMSTAT_WORKINGSET_REFAULT, // ul_int "
+ VMSTAT_WORKINGSET_RESTORE, // ul_int "
+ VMSTAT_ZONE_RECLAIM_FAILED, // ul_int "
+
+ VMSTAT_DELTA_ALLOCSTALL_DMA, // sl_int derived from above
+ VMSTAT_DELTA_ALLOCSTALL_DMA32, // sl_int "
+ VMSTAT_DELTA_ALLOCSTALL_HIGH, // sl_int "
+ VMSTAT_DELTA_ALLOCSTALL_MOVABLE, // sl_int "
+ VMSTAT_DELTA_ALLOCSTALL_NORMAL, // sl_int "
+ VMSTAT_DELTA_BALLOON_DEFLATE, // sl_int "
+ VMSTAT_DELTA_BALLOON_INFLATE, // sl_int "
+ VMSTAT_DELTA_BALLOON_MIGRATE, // sl_int "
+ VMSTAT_DELTA_COMPACT_DAEMON_FREE_SCANNED, // sl_int "
+ VMSTAT_DELTA_COMPACT_DAEMON_MIGRATE_SCANNED, // sl_int "
+ VMSTAT_DELTA_COMPACT_DAEMON_WAKE, // sl_int "
+ VMSTAT_DELTA_COMPACT_FAIL, // sl_int "
+ VMSTAT_DELTA_COMPACT_FREE_SCANNED, // sl_int "
+ VMSTAT_DELTA_COMPACT_ISOLATED, // sl_int "
+ VMSTAT_DELTA_COMPACT_MIGRATE_SCANNED, // sl_int "
+ VMSTAT_DELTA_COMPACT_STALL, // sl_int "
+ VMSTAT_DELTA_COMPACT_SUCCESS, // sl_int "
+ VMSTAT_DELTA_DROP_PAGECACHE, // sl_int "
+ VMSTAT_DELTA_DROP_SLAB, // sl_int "
+ VMSTAT_DELTA_HTLB_BUDDY_ALLOC_FAIL, // sl_int "
+ VMSTAT_DELTA_HTLB_BUDDY_ALLOC_SUCCESS, // sl_int "
+ VMSTAT_DELTA_KSWAPD_HIGH_WMARK_HIT_QUICKLY, // sl_int "
+ VMSTAT_DELTA_KSWAPD_INODESTEAL, // sl_int "
+ VMSTAT_DELTA_KSWAPD_LOW_WMARK_HIT_QUICKLY, // sl_int "
+ VMSTAT_DELTA_NR_ACTIVE_ANON, // sl_int "
+ VMSTAT_DELTA_NR_ACTIVE_FILE, // sl_int "
+ VMSTAT_DELTA_NR_ANON_PAGES, // sl_int "
+ VMSTAT_DELTA_NR_ANON_TRANSPARENT_HUGEPAGES, // sl_int "
+ VMSTAT_DELTA_NR_BOUNCE, // sl_int "
+ VMSTAT_DELTA_NR_DIRTIED, // sl_int "
+ VMSTAT_DELTA_NR_DIRTY, // sl_int "
+ VMSTAT_DELTA_NR_DIRTY_BACKGROUND_THRESHOLD, // sl_int "
+ VMSTAT_DELTA_NR_DIRTY_THRESHOLD, // sl_int "
+ VMSTAT_DELTA_NR_FILE_HUGEPAGES, // sl_int "
+ VMSTAT_DELTA_NR_FILE_PAGES, // sl_int "
+ VMSTAT_DELTA_NR_FILE_PMDMAPPED, // sl_int "
+ VMSTAT_DELTA_NR_FOLL_PIN_ACQUIRED, // sl_int "
+ VMSTAT_DELTA_NR_FOLL_PIN_RELEASED, // sl_int "
+ VMSTAT_DELTA_NR_FREE_CMA, // sl_int "
+ VMSTAT_DELTA_NR_FREE_PAGES, // sl_int "
+ VMSTAT_DELTA_NR_INACTIVE_ANON, // sl_int "
+ VMSTAT_DELTA_NR_INACTIVE_FILE, // sl_int "
+ VMSTAT_DELTA_NR_ISOLATED_ANON, // sl_int "
+ VMSTAT_DELTA_NR_ISOLATED_FILE, // sl_int "
+ VMSTAT_DELTA_NR_KERNEL_MISC_RECLAIMABLE, // sl_int "
+ VMSTAT_DELTA_NR_KERNEL_STACK, // sl_int "
+ VMSTAT_DELTA_NR_MAPPED, // sl_int "
+ VMSTAT_DELTA_NR_MLOCK, // sl_int "
+ VMSTAT_DELTA_NR_PAGE_TABLE_PAGES, // sl_int "
+ VMSTAT_DELTA_NR_SHADOW_CALL_STACK, // sl_int "
+ VMSTAT_DELTA_NR_SHMEM, // sl_int "
+ VMSTAT_DELTA_NR_SHMEM_HUGEPAGES, // sl_int "
+ VMSTAT_DELTA_NR_SHMEM_PMDMAPPED, // sl_int "
+ VMSTAT_DELTA_NR_SLAB_RECLAIMABLE, // sl_int "
+ VMSTAT_DELTA_NR_SLAB_UNRECLAIMABLE, // sl_int "
+ VMSTAT_DELTA_NR_UNEVICTABLE, // sl_int "
+ VMSTAT_DELTA_NR_UNSTABLE, // sl_int "
+ VMSTAT_DELTA_NR_VMSCAN_IMMEDIATE_RECLAIM, // sl_int "
+ VMSTAT_DELTA_NR_VMSCAN_WRITE, // sl_int "
+ VMSTAT_DELTA_NR_WRITEBACK, // sl_int "
+ VMSTAT_DELTA_NR_WRITEBACK_TEMP, // sl_int "
+ VMSTAT_DELTA_NR_WRITTEN, // sl_int "
+ VMSTAT_DELTA_NR_ZONE_ACTIVE_ANON, // sl_int "
+ VMSTAT_DELTA_NR_ZONE_ACTIVE_FILE, // sl_int "
+ VMSTAT_DELTA_NR_ZONE_INACTIVE_ANON, // sl_int "
+ VMSTAT_DELTA_NR_ZONE_INACTIVE_FILE, // sl_int "
+ VMSTAT_DELTA_NR_ZONE_UNEVICTABLE, // sl_int "
+ VMSTAT_DELTA_NR_ZONE_WRITE_PENDING, // sl_int "
+ VMSTAT_DELTA_NR_ZSPAGES, // sl_int "
+ VMSTAT_DELTA_NUMA_FOREIGN, // sl_int "
+ VMSTAT_DELTA_NUMA_HINT_FAULTS, // sl_int "
+ VMSTAT_DELTA_NUMA_HINT_FAULTS_LOCAL, // sl_int "
+ VMSTAT_DELTA_NUMA_HIT, // sl_int "
+ VMSTAT_DELTA_NUMA_HUGE_PTE_UPDATES, // sl_int "
+ VMSTAT_DELTA_NUMA_INTERLEAVE, // sl_int "
+ VMSTAT_DELTA_NUMA_LOCAL, // sl_int "
+ VMSTAT_DELTA_NUMA_MISS, // sl_int "
+ VMSTAT_DELTA_NUMA_OTHER, // sl_int "
+ VMSTAT_DELTA_NUMA_PAGES_MIGRATED, // sl_int "
+ VMSTAT_DELTA_NUMA_PTE_UPDATES, // sl_int "
+ VMSTAT_DELTA_OOM_KILL, // sl_int "
+ VMSTAT_DELTA_PAGEOUTRUN, // sl_int "
+ VMSTAT_DELTA_PGACTIVATE, // sl_int "
+ VMSTAT_DELTA_PGALLOC_DMA, // sl_int "
+ VMSTAT_DELTA_PGALLOC_DMA32, // sl_int "
+ VMSTAT_DELTA_PGALLOC_HIGH, // sl_int "
+ VMSTAT_DELTA_PGALLOC_MOVABLE, // sl_int "
+ VMSTAT_DELTA_PGALLOC_NORMAL, // sl_int "
+ VMSTAT_DELTA_PGDEACTIVATE, // sl_int "
+ VMSTAT_DELTA_PGFAULT, // sl_int "
+ VMSTAT_DELTA_PGFREE, // sl_int "
+ VMSTAT_DELTA_PGINODESTEAL, // sl_int "
+ VMSTAT_DELTA_PGLAZYFREE, // sl_int "
+ VMSTAT_DELTA_PGLAZYFREED, // sl_int "
+ VMSTAT_DELTA_PGMAJFAULT, // sl_int "
+ VMSTAT_DELTA_PGMIGRATE_FAIL, // sl_int "
+ VMSTAT_DELTA_PGMIGRATE_SUCCESS, // sl_int "
+ VMSTAT_DELTA_PGPGIN, // sl_int "
+ VMSTAT_DELTA_PGPGOUT, // sl_int "
+ VMSTAT_DELTA_PGREFILL, // sl_int "
+ VMSTAT_DELTA_PGROTATED, // sl_int "
+ VMSTAT_DELTA_PGSCAN_ANON, // sl_int "
+ VMSTAT_DELTA_PGSCAN_DIRECT, // sl_int "
+ VMSTAT_DELTA_PGSCAN_DIRECT_THROTTLE, // sl_int "
+ VMSTAT_DELTA_PGSCAN_FILE, // sl_int "
+ VMSTAT_DELTA_PGSCAN_KSWAPD, // sl_int "
+ VMSTAT_DELTA_PGSKIP_DMA, // sl_int "
+ VMSTAT_DELTA_PGSKIP_DMA32, // sl_int "
+ VMSTAT_DELTA_PGSKIP_HIGH, // sl_int "
+ VMSTAT_DELTA_PGSKIP_MOVABLE, // sl_int "
+ VMSTAT_DELTA_PGSKIP_NORMAL, // sl_int "
+ VMSTAT_DELTA_PGSTEAL_ANON, // sl_int "
+ VMSTAT_DELTA_PGSTEAL_DIRECT, // sl_int "
+ VMSTAT_DELTA_PGSTEAL_FILE, // sl_int "
+ VMSTAT_DELTA_PGSTEAL_KSWAPD, // sl_int "
+ VMSTAT_DELTA_PSWPIN, // sl_int "
+ VMSTAT_DELTA_PSWPOUT, // sl_int "
+ VMSTAT_DELTA_SLABS_SCANNED, // sl_int "
+ VMSTAT_DELTA_SWAP_RA, // sl_int "
+ VMSTAT_DELTA_SWAP_RA_HIT, // sl_int "
+ VMSTAT_DELTA_THP_COLLAPSE_ALLOC, // sl_int "
+ VMSTAT_DELTA_THP_COLLAPSE_ALLOC_FAILED, // sl_int "
+ VMSTAT_DELTA_THP_DEFERRED_SPLIT_PAGE, // sl_int "
+ VMSTAT_DELTA_THP_FAULT_ALLOC, // sl_int "
+ VMSTAT_DELTA_THP_FAULT_FALLBACK, // sl_int "
+ VMSTAT_DELTA_THP_FAULT_FALLBACK_CHARGE, // sl_int "
+ VMSTAT_DELTA_THP_FILE_ALLOC, // sl_int "
+ VMSTAT_DELTA_THP_FILE_FALLBACK, // sl_int "
+ VMSTAT_DELTA_THP_FILE_FALLBACK_CHARGE, // sl_int "
+ VMSTAT_DELTA_THP_FILE_MAPPED, // sl_int "
+ VMSTAT_DELTA_THP_SPLIT_PAGE, // sl_int "
+ VMSTAT_DELTA_THP_SPLIT_PAGE_FAILED, // sl_int "
+ VMSTAT_DELTA_THP_SPLIT_PMD, // sl_int "
+ VMSTAT_DELTA_THP_SPLIT_PUD, // sl_int "
+ VMSTAT_DELTA_THP_SWPOUT, // sl_int "
+ VMSTAT_DELTA_THP_SWPOUT_FALLBACK, // sl_int "
+ VMSTAT_DELTA_THP_ZERO_PAGE_ALLOC, // sl_int "
+ VMSTAT_DELTA_THP_ZERO_PAGE_ALLOC_FAILED, // sl_int "
+ VMSTAT_DELTA_UNEVICTABLE_PGS_CLEARED, // sl_int "
+ VMSTAT_DELTA_UNEVICTABLE_PGS_CULLED, // sl_int "
+ VMSTAT_DELTA_UNEVICTABLE_PGS_MLOCKED, // sl_int "
+ VMSTAT_DELTA_UNEVICTABLE_PGS_MUNLOCKED, // sl_int "
+ VMSTAT_DELTA_UNEVICTABLE_PGS_RESCUED, // sl_int "
+ VMSTAT_DELTA_UNEVICTABLE_PGS_SCANNED, // sl_int "
+ VMSTAT_DELTA_UNEVICTABLE_PGS_STRANDED, // sl_int "
+ VMSTAT_DELTA_WORKINGSET_ACTIVATE, // sl_int "
+ VMSTAT_DELTA_WORKINGSET_NODERECLAIM, // sl_int "
+ VMSTAT_DELTA_WORKINGSET_NODES, // sl_int "
+ VMSTAT_DELTA_WORKINGSET_REFAULT, // sl_int "
+ VMSTAT_DELTA_WORKINGSET_RESTORE, // sl_int "
+ VMSTAT_DELTA_ZONE_RECLAIM_FAILED // sl_int "
+};
+
+
+struct vmstat_result {
+ enum vmstat_item item;
+ union {
+ signed long sl_int;
+ unsigned long ul_int;
+ } result;
+};
+
+struct vmstat_stack {
+ struct vmstat_result *head;
+};
+
+struct vmstat_info;
+
+
+#define VMSTAT_GET( info, actual_enum, type ) ( { \
+ struct vmstat_result *r = procps_vmstat_get( info, actual_enum ); \
+ r ? r->result . type : 0; } )
+
+#define VMSTAT_VAL( relative_enum, type, stack, info ) \
+ stack -> head [ relative_enum ] . result . type
+
+
+int procps_vmstat_new (struct vmstat_info **info);
+int procps_vmstat_ref (struct vmstat_info *info);
+int procps_vmstat_unref (struct vmstat_info **info);
+
+struct vmstat_result *procps_vmstat_get (
+ struct vmstat_info *info,
+ enum vmstat_item item);
+
+struct vmstat_stack *procps_vmstat_select (
+ struct vmstat_info *info,
+ enum vmstat_item *items,
+ int numitems);
+
+
+#ifdef XTRA_PROCPS_DEBUG
+# include "xtra-procps-debug.h"
+#endif
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/library/include/wchan.h b/library/include/wchan.h
new file mode 100644
index 0000000..ef1d689
--- /dev/null
+++ b/library/include/wchan.h
@@ -0,0 +1,27 @@
+/*
+ * wchan.c - kernel symbol handling
+ *
+ * Copyright © 2015-2023 Jim Warner <james.warner@comcast.net>
+ * Copyright © 1998-2003 Albert Cahalan
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef PROCPS_PROC_WCHAN_H
+#define PROCPS_PROC_WCHAN_H
+
+extern const char *lookup_wchan (int pid);
+
+#endif
diff --git a/library/include/xtra-procps-debug.h b/library/include/xtra-procps-debug.h
new file mode 100644
index 0000000..ead8075
--- /dev/null
+++ b/library/include/xtra-procps-debug.h
@@ -0,0 +1,208 @@
+/*
+ * libproc2 - Library to read proc filesystem
+ *
+ * Copyright © 2016-2023 Jim Warner <james.warner@comcast.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#define STRINGIFY_ARG(a) #a
+#define STRINGIFY(a) STRINGIFY_ARG(a)
+
+
+// --- DISKSTATS ------------------------------------------
+#if defined(PROCPS_DISKSTATS_H) && !defined(PROCPS_DISKSTATS_H_DEBUG)
+#define PROCPS_DISKSTATS_H_DEBUG
+
+struct diskstats_result *xtra_diskstats_get (
+ struct diskstats_info *info,
+ const char *name,
+ enum diskstats_item actual_enum,
+ const char *typestr,
+ const char *file,
+ int lineno);
+
+# undef DISKSTATS_GET
+#define DISKSTATS_GET( info, name, actual_enum, type ) ( { \
+ struct diskstats_result *r; \
+ r = xtra_diskstats_get(info, name, actual_enum , STRINGIFY(type), __FILE__, __LINE__); \
+ r ? r->result . type : 0; } )
+
+struct diskstats_result *xtra_diskstats_val (
+ int relative_enum,
+ const char *typestr,
+ const struct diskstats_stack *stack,
+ struct diskstats_info *info,
+ const char *file,
+ int lineno);
+
+# undef DISKSTATS_VAL
+#define DISKSTATS_VAL( relative_enum, type, stack, info ) ( { \
+ struct diskstats_result *r; \
+ r = xtra_diskstats_val(relative_enum, STRINGIFY(type), stack, info, __FILE__, __LINE__); \
+ r ? r->result . type : 0; } )
+#endif // . . . . . . . . . .
+
+
+// --- MEMINFO --------------------------------------------
+#if defined(PROCPS_MEMINFO_H) && !defined(PROCPS_MEMINFO_H_DEBUG)
+#define PROCPS_MEMINFO_H_DEBUG
+
+struct meminfo_result *xtra_meminfo_get (
+ struct meminfo_info *info,
+ enum meminfo_item actual_enum,
+ const char *typestr,
+ const char *file,
+ int lineno);
+
+# undef MEMINFO_GET
+#define MEMINFO_GET( info, actual_enum, type ) ( { \
+ struct meminfo_result *r; \
+ r = xtra_meminfo_get(info, actual_enum , STRINGIFY(type), __FILE__, __LINE__); \
+ r ? r->result . type : 0; } )
+
+struct meminfo_result *xtra_meminfo_val (
+ int relative_enum,
+ const char *typestr,
+ const struct meminfo_stack *stack,
+ struct meminfo_info *info,
+ const char *file,
+ int lineno);
+
+# undef MEMINFO_VAL
+#define MEMINFO_VAL( relative_enum, type, stack, info ) ( { \
+ struct meminfo_result *r; \
+ r = xtra_meminfo_val(relative_enum, STRINGIFY(type), stack, info, __FILE__, __LINE__); \
+ r ? r->result . type : 0; } )
+#endif // . . . . . . . . . .
+
+
+// --- PIDS -----------------------------------------------
+#if defined(PROCPS_PIDS_H) && !defined(PROCPS_PIDS_H_DEBUG)
+#define PROCPS_PIDS_H_DEBUG
+
+struct pids_result *xtra_pids_val (
+ int relative_enum,
+ const char *typestr,
+ const struct pids_stack *stack,
+ struct pids_info *info,
+ const char *file,
+ int lineno);
+
+# undef PIDS_VAL
+#define PIDS_VAL( relative_enum, type, stack, info ) ( { \
+ struct pids_result *r; \
+ r = xtra_pids_val(relative_enum, STRINGIFY(type), stack, info, __FILE__, __LINE__); \
+ r ? r->result . type : 0; } )
+#endif // . . . . . . . . . .
+
+
+// --- SLABINFO -------------------------------------------
+#if defined(PROCPS_SLABINFO_H) && !defined(PROCPS_SLABINFO_H_DEBUG)
+#define PROCPS_SLABINFO_H_DEBUG
+
+struct slabinfo_result *xtra_slabinfo_get (
+ struct slabinfo_info *info,
+ enum slabinfo_item actual_enum,
+ const char *typestr,
+ const char *file,
+ int lineno);
+
+# undef SLABINFO_GET
+#define SLABINFO_GET( info, actual_enum, type ) ( { \
+ struct slabinfo_result *r; \
+ r = xtra_slabinfo_get(info, actual_enum , STRINGIFY(type), __FILE__, __LINE__); \
+ r ? r->result . type : 0; } )
+
+struct slabinfo_result *xtra_slabinfo_val (
+ int relative_enum,
+ const char *typestr,
+ const struct slabinfo_stack *stack,
+ struct slabinfo_info *info,
+ const char *file,
+ int lineno);
+
+# undef SLABINFO_VAL
+#define SLABINFO_VAL( relative_enum, type, stack, info ) ( { \
+ struct slabinfo_result *r; \
+ r = xtra_slabinfo_val(relative_enum, STRINGIFY(type), stack, info, __FILE__, __LINE__); \
+ r ? r->result . type : 0; } )
+#endif // . . . . . . . . . .
+
+
+// --- STAT -----------------------------------------------
+#if defined(PROCPS_STAT_H) && !defined(PROCPS_STAT_H_DEBUG)
+#define PROCPS_STAT_H_DEBUG
+
+struct stat_result *xtra_stat_get (
+ struct stat_info *info,
+ enum stat_item actual_enum,
+ const char *typestr,
+ const char *file,
+ int lineno);
+
+# undef STAT_GET
+#define STAT_GET( info, actual_enum, type ) ( { \
+ struct stat_result *r; \
+ r = xtra_stat_get(info, actual_enum , STRINGIFY(type), __FILE__, __LINE__); \
+ r ? r->result . type : 0; } )
+
+struct stat_result *xtra_stat_val (
+ int relative_enum,
+ const char *typestr,
+ const struct stat_stack *stack,
+ struct stat_info *info,
+ const char *file,
+ int lineno);
+
+# undef STAT_VAL
+#define STAT_VAL( relative_enum, type, stack, info ) ( { \
+ struct stat_result *r; \
+ r = xtra_stat_val(relative_enum, STRINGIFY(type), stack, info, __FILE__, __LINE__); \
+ r ? r->result . type : 0; } )
+#endif // . . . . . . . . . .
+
+
+// --- VMSTAT ---------------------------------------------
+#if defined(PROCPS_VMSTAT_H) && !defined(PROCPS_VMSTAT_H_DEBUG)
+#define PROCPS_VMSTAT_H_DEBUG
+
+struct vmstat_result *xtra_vmstat_get (
+ struct vmstat_info *info,
+ enum vmstat_item actual_enum,
+ const char *typestr,
+ const char *file,
+ int lineno);
+
+# undef VMSTAT_GET
+#define VMSTAT_GET( info, actual_enum, type ) ( { \
+ struct vmstat_result *r; \
+ r = xtra_vmstat_get(info, actual_enum , STRINGIFY(type), __FILE__, __LINE__); \
+ r ? r->result . type : 0; } )
+
+struct vmstat_result *xtra_vmstat_val (
+ int relative_enum,
+ const char *typestr,
+ const struct vmstat_stack *stack,
+ struct vmstat_info *info,
+ const char *file,
+ int lineno);
+
+# undef VMSTAT_VAL
+#define VMSTAT_VAL( relative_enum, type, stack, info ) ( { \
+ struct vmstat_result *r; \
+ r = xtra_vmstat_val(relative_enum, STRINGIFY(type), stack, info, __FILE__, __LINE__); \
+ r ? r->result . type : 0; } )
+#endif // . . . . . . . . . .