Compare commits
18 Commits
LIBGTOP_2_
...
LIBGTOP_2_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78c10bca9b | ||
|
|
270ec235c1 | ||
|
|
2362be986b | ||
|
|
8a1e1cff91 | ||
|
|
46380bf655 | ||
|
|
91dda5b70d | ||
|
|
9b263e0fbb | ||
|
|
793807b07e | ||
|
|
9898e7ee58 | ||
|
|
7ecdcd712d | ||
|
|
703a17f3f0 | ||
|
|
92a9e7d937 | ||
|
|
01c7e99aa6 | ||
|
|
6fe16f1d91 | ||
|
|
fcb83e637d | ||
|
|
50e4e07013 | ||
|
|
ab40c94db3 | ||
|
|
fee415ecd8 |
21
ChangeLog
21
ChangeLog
@@ -1,3 +1,24 @@
|
||||
2005-01-24 Benoît Dejean <TazForEver@dlfp.org>
|
||||
|
||||
* NEWS:
|
||||
* configure.in: Released 2.9.90.
|
||||
|
||||
2005-01-24 Benoît Dejean <TazForEver@dlfp.org>
|
||||
|
||||
* include/glibtop/procopenfiles.h:
|
||||
* sysdeps/linux/procopenfiles.c:
|
||||
* sysdeps/stub/procopenfiles.c: UTF-8-ified.
|
||||
|
||||
2005-01-22 Benoît Dejean <TazForEver@dlfp.org>
|
||||
|
||||
* examples/openfiles.c: (show_open_files):
|
||||
* include/glibtop/procopenfiles.h: added localsock { name } to
|
||||
glibtop_open_files_entry. Should not break ABI.
|
||||
|
||||
2005-01-12 Benoît Dejean <TazForEver@dlfp.org>
|
||||
|
||||
* configure.in: 2.9.5.
|
||||
|
||||
2005-01-10 Benoît Dejean <TazForEver@dlfp.org>
|
||||
|
||||
* NEWS: Released 2.9.4.
|
||||
|
||||
4
NEWS
4
NEWS
@@ -1,3 +1,7 @@
|
||||
January 24, 2004: Overview of Changes from 2.9.4 to 2.9.90
|
||||
==========================================================
|
||||
* Updated Linux support.
|
||||
|
||||
January 10, 2004: Overview of Changes from 2.9.3 to 2.9.4
|
||||
=========================================================
|
||||
* New glibtop_proc_open_files nick@reloco.com.ar (Nicolás Lichtmaier).
|
||||
|
||||
@@ -8,7 +8,7 @@ AC_CANONICAL_SYSTEM
|
||||
|
||||
LIBGTOP_MAJOR_VERSION=2
|
||||
LIBGTOP_MINOR_VERSION=9
|
||||
LIBGTOP_MICRO_VERSION=4
|
||||
LIBGTOP_MICRO_VERSION=90
|
||||
LIBGTOP_VERSION=$LIBGTOP_MAJOR_VERSION.$LIBGTOP_MINOR_VERSION.$LIBGTOP_MICRO_VERSION
|
||||
AM_INIT_AUTOMAKE(libgtop, $LIBGTOP_VERSION)
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
2005-01-22 Benoît Dejean <TazForEver@dlfp.org>
|
||||
|
||||
* openfiles.c: (show_open_files): Updated.
|
||||
|
||||
2004-12-23 Benoît Dejean <tazforever@dlfp.org>
|
||||
|
||||
* netload.c: (main):
|
||||
|
||||
@@ -34,7 +34,7 @@ static void show_open_files(pid_t pid)
|
||||
break;
|
||||
|
||||
case GLIBTOP_FILE_TYPE_LOCALSOCKET:
|
||||
printf("localsocket\n");
|
||||
printf("localsocket %s\n", files[i].info.localsock.name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
Copyright (C) 2004 Nicol<EFBFBD>s Lichtmaier
|
||||
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<EFBFBD>s Lichtmaier to give open process files.
|
||||
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
|
||||
@@ -77,6 +77,12 @@ struct _glibtop_open_files_entry
|
||||
struct {
|
||||
char name[GLIBTOP_OPEN_FILENAME_LEN+1];
|
||||
} file;
|
||||
|
||||
/* When type == GLIBTOP_FILE_TYPE_LOCALSOCKET */
|
||||
struct {
|
||||
char name[GLIBTOP_OPEN_FILENAME_LEN+1];
|
||||
} localsock;
|
||||
|
||||
} info;
|
||||
};
|
||||
|
||||
|
||||
32
po/ChangeLog
32
po/ChangeLog
@@ -1,3 +1,35 @@
|
||||
2005-01-24 Alexander Shopov <ash@contact.bg>
|
||||
|
||||
* bg.po: Updated Bulgarian translation by
|
||||
Vladimir Petkov <vpetkov@i-space.org>
|
||||
|
||||
2005-01-24 Benoît Dejean <TazForEver@dlfp.org>
|
||||
|
||||
* POTFILES.in:
|
||||
* POTFILES.skip: Removed lib/lib.c as it is generated.
|
||||
Closes #165038.
|
||||
|
||||
2005-01-17 Benoît Dejean <TazForEver@dlfp.org>
|
||||
|
||||
* POTFILES.in: Updated.
|
||||
|
||||
2005-01-16 Hendrik Richter <hendrik@gnome-de.org>
|
||||
|
||||
* de.po: Updated German translation.
|
||||
|
||||
2005-01-16 Takeshi AIHANA <aihana@gnome.gr.jp>
|
||||
|
||||
* ja.po: Updated Japanese translation.
|
||||
|
||||
2005-01-13 Benoît Dejean <TazForEver@dlfp.org>
|
||||
|
||||
* POTFILES.in:
|
||||
* POTFILES.skip: Don't translate examples/smp.c.
|
||||
|
||||
2005-01-13 Christian Rose <menthos@menthos.com>
|
||||
|
||||
* POTFILES.in: Added missing file.
|
||||
|
||||
2005-01-02 Miloslav Trmac <mitr@volny.cz>
|
||||
|
||||
* cs.po: Updated Czech translation.
|
||||
|
||||
@@ -2,3 +2,5 @@ support/error.c
|
||||
support/getopt.c
|
||||
support/popt.c
|
||||
support/popthelp.c
|
||||
examples/smp.c
|
||||
lib/lib.c
|
||||
|
||||
4
po/es.po
4
po/es.po
@@ -40,8 +40,8 @@ msgstr "leído tamaño de datos"
|
||||
#, c-format
|
||||
msgid "read %lu byte of data"
|
||||
msgid_plural "read %lu bytes of data"
|
||||
msgstr[0] "leído %d byte de datos"
|
||||
msgstr[1] "leídos %d bytes de datos"
|
||||
msgstr[0] "leído %lu byte de datos"
|
||||
msgstr[1] "leídos %lu bytes de datos"
|
||||
|
||||
#: lib/write.c:51
|
||||
#, c-format
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
2005-01-18 Benoît Dejean <TazForEver@dlfp.org>
|
||||
|
||||
* mountlist.c: (ignore_mount_entry): Re-worked with bsearch.
|
||||
|
||||
2004-12-09 Benoît Dejean <tazforever@dlfp.org>
|
||||
|
||||
* mountlist.c: (ignore_mount_entry): Ignores "unkown" file system type.
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <glib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
|
||||
@@ -535,31 +536,28 @@ read_filesystem_list (void)
|
||||
|
||||
static gboolean ignore_mount_entry(const struct mount_entry *me)
|
||||
{
|
||||
/* keep sorted */
|
||||
static const char ignored[][12] = {
|
||||
"autofs",
|
||||
"binfmt_misc",
|
||||
"devpts",
|
||||
"mntfs",
|
||||
"none",
|
||||
"openpromfs",
|
||||
"proc",
|
||||
"procfs",
|
||||
"autofs",
|
||||
"sysfs",
|
||||
"usbfs",
|
||||
"none",
|
||||
"devpts",
|
||||
"usbdevfs",
|
||||
"binfmt_misc",
|
||||
"supermount",
|
||||
"mntfs",
|
||||
"openpromfs",
|
||||
"unknown"
|
||||
"sysfs",
|
||||
"unknown",
|
||||
"usbdevfs",
|
||||
"usbfs"
|
||||
};
|
||||
|
||||
const char (*i)[12] = &ignored[0];
|
||||
typedef int (*Comparator)(const void*, const void*);
|
||||
|
||||
while(i != (&ignored[0] + G_N_ELEMENTS(ignored))) {
|
||||
if(strcmp(*i, me->me_type) == 0)
|
||||
return TRUE;
|
||||
++i;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return bsearch(me->me_type,
|
||||
ignored, G_N_ELEMENTS(ignored), sizeof ignored[0],
|
||||
(Comparator) strcmp) != NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,26 @@
|
||||
2005-01-22 Benoît Dejean <TazForEver@dlfp.org>
|
||||
|
||||
* procopenfiles.c: (parse_file), (get_all), (inet_socket_parser),
|
||||
(get_all_inet_sockets), (local_socket_parser),
|
||||
(get_all_local_sockets), (glibtop_get_proc_open_files_s): Total rewrite.
|
||||
socket/localsocket should be much faster.
|
||||
|
||||
2005-01-16 Benoît Dejean <TazForEver@dlfp.org>
|
||||
|
||||
* glibtop_private.c: (skip_token):
|
||||
* glibtop_private.h: Uninlined.
|
||||
|
||||
2005-01-13 Benoît Dejean <TazForEver@dlfp.org>
|
||||
|
||||
* fsusage.c: (get_partition), (get_sys_path), (linux_2_6_0): Reworked.
|
||||
Should works with IDE, SCSI. DM support is ready, but i don't know why
|
||||
their /stat is empty ...
|
||||
|
||||
2005-01-12 Benoît Dejean <TazForEver@dlfp.org>
|
||||
|
||||
* procopenfiles.c: (get_all_sockets),
|
||||
(glibtop_get_proc_open_files_s): Parses /proc/net/tcp only once.
|
||||
|
||||
2005-01-10 Benoît Dejean <TazForEver@dlfp.org>
|
||||
|
||||
* procopenfiles.c: (get_socket_endpoint): Fixed.
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <mntent.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <linux/kdev_t.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -24,68 +25,97 @@ _glibtop_linux_get_fsusage_read_write(glibtop *server,
|
||||
* linux/Documentation/iostats.txt
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
static char *
|
||||
get_partition(const char *mountpoint)
|
||||
{
|
||||
FILE *partitions;
|
||||
char *name = NULL;
|
||||
char line[1024];
|
||||
struct stat statb;
|
||||
|
||||
if(stat(mountpoint, &statb) == -1)
|
||||
return NULL;
|
||||
|
||||
g_return_val_if_fail((partitions = fopen("/proc/partitions", "r")), NULL);
|
||||
|
||||
while(fgets(line, sizeof line, partitions))
|
||||
{
|
||||
unsigned major, minor;
|
||||
char dev[32];
|
||||
|
||||
if(sscanf(line, "%u %u %*u %31s", &major, &minor, dev) != 3)
|
||||
continue;
|
||||
|
||||
if(MKDEV(major, minor) != statb.st_dev)
|
||||
continue;
|
||||
|
||||
name = g_strdup(dev);
|
||||
break;
|
||||
}
|
||||
|
||||
fclose(partitions);
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
get_sys_path(const char *device)
|
||||
{
|
||||
if(g_str_has_prefix(device, "hd") || g_str_has_prefix(device, "sd"))
|
||||
{
|
||||
char *prefix;
|
||||
char *path;
|
||||
size_t offset;
|
||||
|
||||
offset = strcspn(device, "0123456789");
|
||||
|
||||
prefix = g_strdup(device);
|
||||
prefix [offset] = '\0';
|
||||
|
||||
path = g_strdup_printf("/sys/block/%s/%s/stat",
|
||||
prefix, device);
|
||||
|
||||
g_free(prefix);
|
||||
return path;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return g_strdup_printf("/sys/block/%s/stat", device);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void linux_2_6_0(glibtop *server, glibtop_fsusage *buf, const char *path)
|
||||
{
|
||||
FILE *mtab = setmntent("/etc/mtab", "r");
|
||||
char *device;
|
||||
char *filename;
|
||||
int ret;
|
||||
char buffer[BUFSIZ];
|
||||
char *p;
|
||||
|
||||
struct mntent *emnt;
|
||||
device = get_partition(path);
|
||||
if(!device) return;
|
||||
|
||||
while((emnt = getmntent(mtab)) != NULL)
|
||||
{
|
||||
if(strcmp(emnt->mnt_dir, path) == 0)
|
||||
{
|
||||
char filename[64]; /* magic */
|
||||
filename = get_sys_path(device);
|
||||
g_free(device);
|
||||
|
||||
char buffer[1024]; /* magic */
|
||||
char *p;
|
||||
ret = try_file_to_buffer(buffer, filename);
|
||||
g_free(filename);
|
||||
|
||||
char device[32]; /* magic */
|
||||
unsigned partition;
|
||||
if(ret < 0) return;
|
||||
|
||||
const char *devname = emnt->mnt_fsname;
|
||||
size_t offset;
|
||||
p = buffer;
|
||||
p = skip_token(p);
|
||||
buf->read = strtoull(p, &p, 0);
|
||||
p = skip_token(p);
|
||||
buf->write = strtoull(p, &p, 0);
|
||||
|
||||
/*
|
||||
we only deal with /dev block devices "/dev/<DEVICE><PARTITION>"
|
||||
i don't know if other block devices such as network block
|
||||
devices provide this kind of information.
|
||||
*/
|
||||
|
||||
if(!g_str_has_prefix(devname, "/dev/"))
|
||||
break;
|
||||
|
||||
/* skip the "/dev/" */
|
||||
devname += sizeof "/dev/" - 1;
|
||||
|
||||
g_strlcpy(device, devname, sizeof device);
|
||||
|
||||
offset = strcspn(devname, "0123456789");
|
||||
partition = strtoul(devname + offset, NULL, 0);
|
||||
|
||||
device[offset] = '\0';
|
||||
|
||||
if((size_t) g_snprintf(filename, sizeof filename,
|
||||
"/sys/block/%s/%s%u/stat",
|
||||
device, device, partition) >= sizeof filename)
|
||||
break;
|
||||
|
||||
|
||||
if(try_file_to_buffer(buffer, filename) < 0)
|
||||
break;
|
||||
|
||||
p = buffer;
|
||||
p = skip_token(p);
|
||||
buf->read = strtoull(p, &p, 0);
|
||||
p = skip_token(p);
|
||||
buf->write = strtoull(p, &p, 0);
|
||||
|
||||
buf->flags |= (1 << GLIBTOP_FSUSAGE_READ) | (1 << GLIBTOP_FSUSAGE_WRITE);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
endmntent(mtab);
|
||||
buf->flags |= (1 << GLIBTOP_FSUSAGE_READ) | (1 << GLIBTOP_FSUSAGE_WRITE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -32,6 +32,16 @@ get_scaled(const char *buffer, const char *key)
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
skip_token (const char *p)
|
||||
{
|
||||
p = next_token(p);
|
||||
while (*p && !isspace(*p)) p++;
|
||||
p = next_token(p);
|
||||
return (char *)p;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Read functions
|
||||
*/
|
||||
|
||||
@@ -40,14 +40,8 @@ next_token(const char *p)
|
||||
return (char*) p;
|
||||
}
|
||||
|
||||
static inline char *
|
||||
skip_token (const char *p)
|
||||
{
|
||||
p = next_token(p);
|
||||
while (*p && !isspace(*p)) p++;
|
||||
p = next_token(p);
|
||||
return (char *)p;
|
||||
}
|
||||
char * G_GNUC_INTERNAL
|
||||
skip_token (const char *p);
|
||||
|
||||
static inline char *
|
||||
skip_multiple_token (const char *p, size_t count)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
Copyright (C) 2004 Nicol<EFBFBD>s Lichtmaier
|
||||
Copyright (C) 2004 Nicolás Lichtmaier
|
||||
This file is part of LibGTop 1.0.
|
||||
|
||||
Modified by Nicol<EFBFBD>s Lichtmaier to give a process open files.
|
||||
Modified by Nicolás Lichtmaier to give a process open files.
|
||||
|
||||
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
|
||||
|
||||
@@ -49,41 +49,127 @@ glibtop_init_proc_open_files_s (glibtop *server)
|
||||
}
|
||||
|
||||
|
||||
|
||||
typedef void (*LineParser)(GHashTable *dict, const char *line);
|
||||
|
||||
|
||||
static void
|
||||
get_socket_endpoint(char *buf, int *prmtport, int s)
|
||||
parse_file(const char *filename, LineParser parser, GHashTable *dict)
|
||||
{
|
||||
FILE *f;
|
||||
char line[1024];
|
||||
|
||||
buf[0] = '\0';
|
||||
*prmtport = 0;
|
||||
f = fopen(filename, "r");
|
||||
|
||||
f = fopen("/proc/net/tcp", "r");
|
||||
if(!f)
|
||||
if(!f) {
|
||||
g_warning("Cannot open '%s'", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
/* skip the first line */
|
||||
if(!fgets(line, sizeof line, f)) goto eof;
|
||||
|
||||
|
||||
while(fgets(line, sizeof line, f))
|
||||
{
|
||||
unsigned int rmt;
|
||||
int sock = -42;
|
||||
|
||||
sscanf(line, "%*d: %*x:%*x %8x:%4x %*x %*x:%*x %*x:%*x %*d %*d %*d %d",
|
||||
&rmt, prmtport, &sock);
|
||||
|
||||
if(sock == s)
|
||||
{
|
||||
inet_ntop(AF_INET, &rmt, buf, GLIBTOP_OPEN_DEST_HOST_LEN);
|
||||
break;
|
||||
}
|
||||
parser(dict, line);
|
||||
}
|
||||
|
||||
eof:
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
|
||||
static GHashTable*
|
||||
get_all(const char *filename, LineParser parser)
|
||||
{
|
||||
GHashTable *dict;
|
||||
|
||||
dict = g_hash_table_new_full(g_direct_hash, g_direct_equal,
|
||||
NULL, g_free);
|
||||
|
||||
parse_file(filename, parser, dict);
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct InetSocketEntry
|
||||
{
|
||||
char host[GLIBTOP_OPEN_DEST_HOST_LEN + 1];
|
||||
int port;
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
inet_socket_parser(GHashTable *dict, const char* line)
|
||||
{
|
||||
struct InetSocketEntry *se;
|
||||
int sock;
|
||||
unsigned addr;
|
||||
|
||||
se = g_malloc0(sizeof *se);
|
||||
|
||||
if(sscanf(line, "%*d: %*x:%*x %8x:%4x %*x %*x:%*x %*x:%*x %*d %*d %*d %d",
|
||||
&addr, &se->port, &sock) != 3)
|
||||
goto error;
|
||||
|
||||
if(!inet_ntop(AF_INET, &addr, se->host, sizeof se->host))
|
||||
goto error;
|
||||
|
||||
g_hash_table_insert(dict, GINT_TO_POINTER(sock), se);
|
||||
return;
|
||||
|
||||
error:
|
||||
g_free(se);
|
||||
}
|
||||
|
||||
|
||||
static inline GHashTable *
|
||||
get_all_inet_sockets()
|
||||
{
|
||||
return get_all("/proc/net/tcp", inet_socket_parser);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct LocalSocketEntry
|
||||
{
|
||||
char name[GLIBTOP_OPEN_DEST_HOST_LEN + 1];
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
local_socket_parser(GHashTable *dict, const char *line)
|
||||
{
|
||||
int sock;
|
||||
struct LocalSocketEntry *use;
|
||||
char *p;
|
||||
|
||||
use = g_malloc0(sizeof *use);
|
||||
|
||||
/* dfaf1640: 00000003 00000000 00000000 0001 03 6457 /dev/log */
|
||||
p = skip_multiple_token(line, 6);
|
||||
|
||||
sock = strtoul(p, &p, 10);
|
||||
g_strlcpy(use->name, p, sizeof use->name);
|
||||
g_strstrip(use->name);
|
||||
g_hash_table_insert(dict, GINT_TO_POINTER(sock), use);
|
||||
}
|
||||
|
||||
|
||||
static inline GHashTable *
|
||||
get_all_local_sockets()
|
||||
{
|
||||
return get_all("/proc/net/unix", local_socket_parser);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Provides detailed information about a process' open files */
|
||||
|
||||
glibtop_open_files_entry *
|
||||
@@ -91,8 +177,8 @@ glibtop_get_proc_open_files_s (glibtop *server, glibtop_proc_open_files *buf, pi
|
||||
{
|
||||
char fn [BUFSIZ];
|
||||
GArray *entries;
|
||||
GHashTable *inet_sockets = NULL, *local_sockets = NULL;
|
||||
struct dirent *direntry;
|
||||
int rv;
|
||||
DIR *dir;
|
||||
|
||||
glibtop_init_s (&server, GLIBTOP_SYSDEPS_PROC_OPEN_FILES, 0);
|
||||
@@ -108,9 +194,9 @@ glibtop_get_proc_open_files_s (glibtop *server, glibtop_proc_open_files *buf, pi
|
||||
|
||||
while((direntry = readdir(dir))) {
|
||||
char tgt [BUFSIZ];
|
||||
int rv;
|
||||
glibtop_open_files_entry entry = {0};
|
||||
|
||||
|
||||
if(direntry->d_name[0] == '.')
|
||||
continue;
|
||||
|
||||
@@ -126,11 +212,37 @@ glibtop_get_proc_open_files_s (glibtop *server, glibtop_proc_open_files *buf, pi
|
||||
if(g_str_has_prefix(tgt, "socket:["))
|
||||
{
|
||||
int sockfd;
|
||||
entry.type = GLIBTOP_FILE_TYPE_INETSOCKET;
|
||||
struct InetSocketEntry *ise;
|
||||
struct LocalSocketEntry *lse;
|
||||
|
||||
if(!inet_sockets) inet_sockets = get_all_inet_sockets();
|
||||
if(!local_sockets) local_sockets = get_all_local_sockets();
|
||||
|
||||
sockfd = atoi(tgt + 8);
|
||||
get_socket_endpoint(entry.info.sock.dest_host,
|
||||
&(entry.info.sock.dest_port),
|
||||
sockfd);
|
||||
|
||||
ise = g_hash_table_lookup(inet_sockets,
|
||||
GINT_TO_POINTER(sockfd));
|
||||
|
||||
if(ise) {
|
||||
entry.type = GLIBTOP_FILE_TYPE_INETSOCKET;
|
||||
entry.info.sock.dest_port = ise->port;
|
||||
g_strlcpy(entry.info.sock.dest_host, ise->host,
|
||||
sizeof entry.info.sock.dest_host);
|
||||
goto found;
|
||||
}
|
||||
|
||||
lse = g_hash_table_lookup(local_sockets,
|
||||
GINT_TO_POINTER(sockfd));
|
||||
|
||||
if(lse) {
|
||||
entry.type = GLIBTOP_FILE_TYPE_LOCALSOCKET;
|
||||
g_strlcpy(entry.info.localsock.name, lse->name,
|
||||
sizeof entry.info.localsock.name);
|
||||
goto found;
|
||||
}
|
||||
|
||||
found:
|
||||
(void)0; /* kills warning */
|
||||
}
|
||||
else if(g_str_has_prefix(tgt, "pipe:["))
|
||||
{
|
||||
@@ -147,6 +259,9 @@ glibtop_get_proc_open_files_s (glibtop *server, glibtop_proc_open_files *buf, pi
|
||||
|
||||
closedir (dir);
|
||||
|
||||
if(inet_sockets) g_hash_table_destroy(inet_sockets);
|
||||
if(local_sockets) g_hash_table_destroy(local_sockets);
|
||||
|
||||
buf->flags = _glibtop_sysdeps_proc_open_files;
|
||||
buf->number = entries->len;
|
||||
buf->size = sizeof(glibtop_open_files_entry);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Copyright (C) 1998-99 Martin Baulig
|
||||
Copyright (C) 2004 Nicol<EFBFBD>s Lichtmaier
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user