lkml.org 
[lkml]   [1996]   [May]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
Subjecttool patch - netstat
I've made a patch to fix the output of "netstat" for AF_UNIX (Path is 
just a number). The patch is against the netstat version from the
German S.u.S.E. distribution (i.e. Beta #6 of it). The patch is maybe
simple, but it works for me. I'll attach it. -- Ulrich
DEFECT DESCRIPTION
For Recent Linux kernels (e.g. pre2.0) the output of netstat
incorrectly prints a number instead of the path of the socket.

FIX
The shown number is the i-node number of the socket. This field has
been added recently. The fix just adds the new field to the output.

AUTHOR
Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>

Index: netstat.c
===================================================================
RCS file: /tmp/REPOS/net_tools/netstat.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- netstat.c 1996/02/15 00:50:30 1.1
+++ netstat.c 1996/05/21 19:59:50 1.2
@@ -27,6 +27,7 @@
*960204 {1.11} Bernd Eckenfels: netlink support
*960204 {1.12} Bernd Eckenfels: route_init()
*960215 {1.13} Bernd Eckenfels: netlink_print honors HAVE_
+ *960521 {1.13} Ulrich Windl: get the path for AF_UNIX right
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
@@ -669,7 +670,7 @@
{
char buffer[8192], path[MAXPATHLEN], ss_flags[32];
char *ss_proto, *ss_state, *ss_type;
- int num, state, type, lnr = 0;
+ int num, state, type, lnr = 0, inode;
void *d;
unsigned long refcnt, proto, flags;

@@ -691,13 +692,13 @@

printf(NLS_CATGETS(catfd, netstatSet, netstat_unix, "Active UNIX domain sockets\n"));
printf(NLS_CATGETS(catfd, netstatSet, netstat_header_unix,
- "Proto RefCnt Flags Type State Path\n"));
+ "Proto RefCnt Flags Type State Inode Path\n"));
while (lnr >= 0) {
path[0] = '\0';
- num = sscanf(line[lnr--], "%p: %lX %lX %lX %X %X %s\n",
- &d, &refcnt, &proto, &flags, &type, &state, path);
+ num = sscanf(line[lnr--], "%p: %lX %lX %lX %X %X %d %s\n",
+ &d, &refcnt, &proto, &flags, &type, &state, &inode, path);
if (flag_deb) fprintf(stderr, NLS_CATGETS(catfd, netstatSet, netstat_args, "%s -> %d args"), line[lnr+1], num);
- if (num < 6) continue;
+ if (num < 7) continue;

switch(proto) {
case 0:
@@ -772,8 +773,8 @@
if (ss_flags[strlen(ss_flags)-1] != ' ') strcat(ss_flags, " ");
strcat(ss_flags, "]");

- printf("%-5s %-6ld %-10s %-15s %-15s %s\n",
- ss_proto, refcnt, ss_flags, ss_type, ss_state, path);
+ printf("%-5s %-6ld %-10s %-15s %-15s %5d %s\n",
+ ss_proto, refcnt, ss_flags, ss_type, ss_state, inode, path);
}
return(0);
}
\
 
 \ /
  Last update: 2005-03-22 13:37    [W:0.022 / U:45.636 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site