1 /* Copyright (C) 2017 Robert Roth
2    This file is part of LibGTop.
3 
4    Contributed by Robert Roth <robert.roth.off@gmail.com>, February 2017.
5 
6    LibGTop is free software; you can redistribute it and/or modify it
7    under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License,
9    or (at your option) any later version.
10 
11    LibGTop is distributed in the hope that it will be useful, but WITHOUT
12    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14    for more details.
15 
16    You should have received a copy of the GNU General Public License
17    along with LibGTop; see the file COPYING. If not, write to the
18    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19    Boston, MA 02110-1301, USA.
20 */
21 
22 #ifndef __GLIBTOP_PROCIO_H__
23 #define __GLIBTOP_PROCIO_H__
24 
25 #include <glibtop.h>
26 #include <glibtop/global.h>
27 
28 G_BEGIN_DECLS
29 
30 #define GLIBTOP_PROC_IO_DISK_RCHAR	0
31 #define GLIBTOP_PROC_IO_DISK_WCHAR	1
32 #define GLIBTOP_PROC_IO_DISK_RBYTES	2
33 #define GLIBTOP_PROC_IO_DISK_WBYTES	3
34 
35 #define GLIBTOP_MAX_PROC_IO		3
36 
37 typedef struct _glibtop_proc_io	glibtop_proc_io;
38 
39 /* Time section */
40 
41 /**
42  * glibtop_proc_io:
43  * @disk_rchar: The number of bytes which this task has caused to be read from storage. This
44  * is simply the sum of bytes which this process passed to read() and pread(), also including tty IO,
45  * and it is unaffected by whether or not actual physical disk IO was required.
46  * @disk_wchar: The number of bytes which this task has caused, or shall cause to be written
47  * to disk. Similar caveats apply here as with rchar.
48  * @disk_rbytes: Attempt to count the number of bytes which this process really did cause to
49  * be fetched from the storage layer. Done at the submit_bio() level, so it is
50  * accurate for block-backed filesystems.
51  * @disk_wbytes: Attempt to count the number of bytes which this process caused to be sent to
52  * the storage layer. This is done at page-dirtying time.
53  *
54  * Process disk io data filled by glibtop_get_proc_io().
55  *
56  */
57 struct _glibtop_proc_io
58 {
59 	guint64	flags;
60 	guint64 disk_rchar;
61 	guint64 disk_wchar;
62 	guint64 disk_rbytes;
63 	guint64 disk_wbytes;
64 
65     /* reserved for future extensions, e.g. per-process netio */
66     guint64 reserved[10];
67 };
68 
69 
70 void glibtop_get_proc_io (glibtop_proc_io *buf, pid_t pid);
71 
72 #if GLIBTOP_SUID_PROC_IO
73 #define glibtop_get_proc_io_r	glibtop_get_proc_io_p
74 #else
75 #define glibtop_get_proc_io_r	glibtop_get_proc_io_s
76 #endif
77 
78 void glibtop_get_proc_io_l (glibtop *server, glibtop_proc_io *buf, pid_t pid);
79 
80 #if GLIBTOP_SUID_PROC_IO
81 void _glibtop_init_proc_io_p (glibtop *server);
82 void glibtop_get_proc_io_p (glibtop *server, glibtop_proc_io *buf, pid_t pid);
83 #else
84 void _glibtop_init_proc_io_s (glibtop *server);
85 void glibtop_get_proc_io_s (glibtop *server, glibtop_proc_io *buf, pid_t pid);
86 #endif
87 
88 
89 G_END_DECLS
90 
91 #endif
92