summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorBenoît Dejean <bdejean@src.gnome.org>2005-01-10 08:43:04 +0000
committerBenoît Dejean <bdejean@src.gnome.org>2005-01-10 08:43:04 +0000
commit7ca4171652dff239b35b1959bb7a32a2d066dca8 (patch)
tree5bf03f60ca927540b061a57885d85300bf250109 /include
parent1537eea7e5abfff849d1b239c15446699668811b (diff)
downloadlibgtop-7ca4171652dff239b35b1959bb7a32a2d066dca8.tar.gz
New feature by nick@reloco.com.ar (Nicolás Lichtmaier).
* configure.in: * examples/.cvsignore: * examples/Makefile.am: * examples/openfiles.c: (show_open_files), (main): * features.def: * include/glibtop/Makefile.am: * include/glibtop/command.h: * include/glibtop/procopenfiles.h: * include/glibtop/sysdeps.h: * include/glibtop/union.h: * structures.def: * sysdeps/linux/Makefile.am: * sysdeps/linux/procopenfiles.c: (glibtop_init_proc_open_files_s), (get_socket_endpoint), (glibtop_get_proc_open_files_s): * sysdeps/stub/Makefile.am: * sysdeps/stub/procopenfiles.c: (glibtop_init_proc_open_files_s), (glibtop_get_proc_open_files_s): New feature by nick@reloco.com.ar (Nicolás Lichtmaier). glibtop_get_open_files(pid) -> list of files by process. TODO: Add documentation.
Diffstat (limited to 'include')
-rw-r--r--include/glibtop/Makefile.am3
-rw-r--r--include/glibtop/command.h3
-rw-r--r--include/glibtop/procopenfiles.h116
-rw-r--r--include/glibtop/sysdeps.h4
-rw-r--r--include/glibtop/union.h2
5 files changed, 125 insertions, 3 deletions
diff --git a/include/glibtop/Makefile.am b/include/glibtop/Makefile.am
index ba0b59c6..8e4d36b2 100644
--- a/include/glibtop/Makefile.am
+++ b/include/glibtop/Makefile.am
@@ -7,4 +7,5 @@ glibtop_HEADERS = close.h loadavg.h prockernel.h procstate.h \
procsegment.h read.h sysdeps.h global.h \
procsignal.h read_data.h union.h types.h gnuserv.h \
parameter.h mountlist.h fsusage.h procmap.h signal.h \
- inodedb.h sysinfo.h ppp.h procargs.h netload.h netlist.h
+ inodedb.h sysinfo.h ppp.h procargs.h netload.h \
+ netlist.h procopenfiles.h
diff --git a/include/glibtop/command.h b/include/glibtop/command.h
index aa940ddc..9ffef35f 100644
--- a/include/glibtop/command.h
+++ b/include/glibtop/command.h
@@ -58,8 +58,9 @@ G_BEGIN_DECLS
#define GLIBTOP_CMND_NETLOAD 22
#define GLIBTOP_CMND_PPP 23
#define GLIBTOP_CMND_NETLIST 24
+#define GLIBTOP_CMND_PROC_OPEN_FILES 25
-#define GLIBTOP_MAX_CMND 25
+#define GLIBTOP_MAX_CMND 26
#define _GLIBTOP_PARAM_SIZE 16
diff --git a/include/glibtop/procopenfiles.h b/include/glibtop/procopenfiles.h
new file mode 100644
index 00000000..29b2390c
--- /dev/null
+++ b/include/glibtop/procopenfiles.h
@@ -0,0 +1,116 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ Copyright (C) 2004 Nicolás Lichtmaier
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ Modified by Nicolás Lichtmaier to give open process files.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop 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 General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __GLIBTOP_PROC_OPEN_FILES_H__
+#define __GLIBTOP_PROC_OPEN_FILES_H__
+
+#include <glibtop.h>
+#include <glibtop/global.h>
+
+
+G_BEGIN_DECLS
+
+#define GLIBTOP_PROC_OPEN_FILES_NUMBER 0
+#define GLIBTOP_PROC_OPEN_FILES_TOTAL 1
+#define GLIBTOP_PROC_OPEN_FILES_SIZE 2
+
+#define GLIBTOP_MAX_PROC_OPEN_FILES 3
+
+#define GLIBTOP_FILE_ENTRY_FD 0
+#define GLIBTOP_FILE_ENTRY_NAME 1
+#define GLIBTOP_FILE_ENTRY_TYPE 2
+#define GLIBTOP_FILE_ENTRY_INETSOCKET_DST_HOST 3
+#define GLIBTOP_FILE_ENTRY_INETSOCKET_DST_PORT 4
+
+#define GLIBTOP_MAX_OPEN_FILE_ENTRY 5
+
+#define GLIBTOP_OPEN_FILENAME_LEN 215
+ /* ready for IPv6 */
+#define GLIBTOP_OPEN_DEST_HOST_LEN 46
+
+enum glibtop_file_type {
+ GLIBTOP_FILE_TYPE_FILE = 1,
+ GLIBTOP_FILE_TYPE_PIPE = 2,
+ GLIBTOP_FILE_TYPE_INETSOCKET = 4,
+ GLIBTOP_FILE_TYPE_LOCALSOCKET = 8
+};
+
+typedef struct _glibtop_open_files_entry glibtop_open_files_entry;
+
+typedef struct _glibtop_proc_open_files glibtop_proc_open_files;
+
+struct _glibtop_open_files_entry
+{
+ int fd;
+ guint16 type; /* An "enum glibtop_file_type" value. */
+ union {
+ /* When type == GLIBTOP_FILE_TYPE_INETSOCKET */
+ struct {
+ char dest_host[GLIBTOP_OPEN_DEST_HOST_LEN+1];
+ int dest_port;
+ } sock;
+
+ /* When type == GLIBTOP_FILE_TYPE_FILE */
+ struct {
+ char name[GLIBTOP_OPEN_FILENAME_LEN+1];
+ } file;
+ } info;
+};
+
+struct _glibtop_proc_open_files
+{
+ guint64 flags,
+ number, /* GLIBTOP_PROC_OPEN_FILES_NUMBER */
+ total, /* GLIBTOP_PROC_OPEN_FILES_TOTAL */
+ size; /* GLIBTOP_PROC_OPEN_FILES_SIZE */
+};
+
+#define glibtop_get_proc_open_files(proc_open_files,pid) glibtop_get_proc_open_files_l(glibtop_global_server, proc_open_files, pid)
+
+#if GLIBTOP_SUID_PROC_FILE
+#define glibtop_get_proc_open_files_r glibtop_get_proc_open_files_p
+#else
+#define glibtop_get_proc_open_files_r glibtop_get_proc_open_files_s
+#endif
+
+glibtop_open_files_entry *
+glibtop_get_proc_open_files_l (glibtop *server, glibtop_proc_open_files *buf, pid_t pid);
+
+#if GLIBTOP_SUID_PROC_FILE
+void glibtop_init_proc_open_files_p (glibtop *server);
+
+glibtop_open_files_entry *
+glibtop_get_proc_open_files_p (glibtop *server, glibtop_proc_open_files *buf, pid_t pid);
+#else
+void glibtop_init_proc_open_files_s (glibtop *server);
+
+glibtop_open_files_entry *
+glibtop_get_proc_open_files_s (glibtop *server, glibtop_proc_open_files *buf, pid_t pid);
+#endif
+
+G_END_DECLS
+
+#endif
diff --git a/include/glibtop/sysdeps.h b/include/glibtop/sysdeps.h
index af490fd3..5547ccfd 100644
--- a/include/glibtop/sysdeps.h
+++ b/include/glibtop/sysdeps.h
@@ -52,8 +52,9 @@ G_BEGIN_DECLS
#define GLIBTOP_SYSDEPS_NETLOAD 21
#define GLIBTOP_SYSDEPS_PPP 22
#define GLIBTOP_SYSDEPS_NETLIST 23
+#define GLIBTOP_SYSDEPS_PROC_OPEN_FILES 24
-#define GLIBTOP_MAX_SYSDEPS 24
+#define GLIBTOP_MAX_SYSDEPS 25
#define GLIBTOP_SYSDEPS_ALL ((1 << GLIBTOP_MAX_SYSDEPS) - 1)
@@ -85,6 +86,7 @@ struct _glibtop_sysdeps
proc_segment, /* glibtop_proc_segment */
proc_args, /* glibtop_proc_args */
proc_map, /* glibtop_proc_map */
+ proc_open_files, /* glibtop_proc_open_files */
mountlist, /* glibtop_mountlist */
fsusage, /* glibtop_fsusage */
netlist, /* glibtop_netlist */
diff --git a/include/glibtop/union.h b/include/glibtop/union.h
index ed462468..1fc628dc 100644
--- a/include/glibtop/union.h
+++ b/include/glibtop/union.h
@@ -43,6 +43,7 @@
#include <glibtop/procsegment.h>
#include <glibtop/procargs.h>
#include <glibtop/procmap.h>
+#include <glibtop/procopenfiles.h>
#include <glibtop/mountlist.h>
#include <glibtop/fsusage.h>
@@ -80,6 +81,7 @@ union _glibtop_union
glibtop_netlist netlist;
glibtop_netload netload;
glibtop_ppp ppp;
+ glibtop_proc_open_files proc_open_files;
};
G_END_DECLS