diff --git a/sysdeps/linux/ChangeLog b/sysdeps/linux/ChangeLog index 84e29bf7..d72c32a4 100644 --- a/sysdeps/linux/ChangeLog +++ b/sysdeps/linux/ChangeLog @@ -1,3 +1,7 @@ +2005-01-10 Benoît Dejean + + * procopenfiles.c: (get_socket_endpoint): Fixed. + 2005-01-10 Benoît Dejean * glibtop_server.h: diff --git a/sysdeps/linux/procopenfiles.c b/sysdeps/linux/procopenfiles.c index 3cd55d5e..de489cb3 100644 --- a/sysdeps/linux/procopenfiles.c +++ b/sysdeps/linux/procopenfiles.c @@ -33,6 +33,7 @@ #include #include +#include "glibtop_private.h" static const unsigned long _glibtop_sysdeps_proc_open_files = (1L << GLIBTOP_PROC_OPEN_FILES_NUMBER)| @@ -52,23 +53,26 @@ static void get_socket_endpoint(char *buf, int *prmtport, int s) { FILE *f; - char l[1024]; + char line[1024]; buf[0] = '\0'; - prmtport = 0; + *prmtport = 0; f = fopen("/proc/net/tcp", "r"); - if(!f) return; - while(fgets(l, sizeof l, f)) + if(!fgets(line, sizeof line, f)) goto eof; + + + while(fgets(line, sizeof line, f)) { - unsigned int loc, locport, rmt; + unsigned int rmt; int sock = -42; - /* FIXME - sscanf(l, "%*d: %8x:%4x %8x:%4x %*x %*x:%*x %*x:%*x %*d %*d %*d %d", - &loc, &locport, &rmt, prmtport, &sock); */ + + 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); @@ -76,6 +80,7 @@ get_socket_endpoint(char *buf, int *prmtport, int s) } } + eof: fclose(f); }