diff options
author | ru <ru@FreeBSD.org> | 1999-07-02 13:25:49 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 1999-07-02 13:25:49 +0000 |
commit | 4ba1aeb45483ea5367f4a84d015dc6a808c0f5dc (patch) | |
tree | 079c20d8da1493f20455fbc0c0eec5b6165911c2 | |
parent | 9b08a567c1d6bdc82429bde3fafebf9effe09bba (diff) | |
download | FreeBSD-src-4ba1aeb45483ea5367f4a84d015dc6a808c0f5dc.zip FreeBSD-src-4ba1aeb45483ea5367f4a84d015dc6a808c0f5dc.tar.gz |
o use getprotobynumber(3) instead of hardcoded protocol names.
Divert(4) sockets will now appear as "internet raw divert"
instead of "internet raw 254".
o -Wall tweak.
Reviewed by: bde
-rw-r--r-- | usr.bin/fstat/Makefile | 3 | ||||
-rw-r--r-- | usr.bin/fstat/fstat.c | 39 |
2 files changed, 15 insertions, 27 deletions
diff --git a/usr.bin/fstat/Makefile b/usr.bin/fstat/Makefile index 32d0aef..6ff6ab1 100644 --- a/usr.bin/fstat/Makefile +++ b/usr.bin/fstat/Makefile @@ -1,7 +1,8 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 -# $Id$ +# $Id: Makefile,v 1.2 1997/08/22 14:22:31 jmg Exp $ PROG= fstat +CFLAGS+=-Wall CFLAGS+=-I${.CURDIR}/../../sys DPADD= ${LIBKVM} LDADD= -lkvm diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c index eef5698..424f137 100644 --- a/usr.bin/fstat/fstat.c +++ b/usr.bin/fstat/fstat.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)fstat.c 8.3 (Berkeley) 5/2/95"; #endif static const char rcsid[] = - "$Id: fstat.c,v 1.15 1998/05/16 21:35:37 markm Exp $"; + "$Id: fstat.c,v 1.16 1998/07/06 21:01:16 bde Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -90,6 +90,7 @@ static const char rcsid[] = #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <netdb.h> #define TEXT -1 #define CDIR -2 @@ -535,6 +536,9 @@ nfs_filestat(vp, fsp) case VFIFO: mode |= S_IFIFO; break; + case VNON: + case VBAD: + return 0; }; fsp->mode = mode; @@ -733,32 +737,15 @@ void getinetproto(number) int number; { - char *cp; - - switch(number) { - case IPPROTO_IP: - cp = "ip"; break; - case IPPROTO_ICMP: - cp ="icmp"; break; - case IPPROTO_GGP: - cp ="ggp"; break; - case IPPROTO_TCP: - cp ="tcp"; break; - case IPPROTO_EGP: - cp ="egp"; break; - case IPPROTO_PUP: - cp ="pup"; break; - case IPPROTO_UDP: - cp ="udp"; break; - case IPPROTO_IDP: - cp ="idp"; break; - case IPPROTO_RAW: - cp ="raw"; break; - default: + static int isopen; + register struct protoent *pe; + + if (!isopen) + setprotoent(++isopen); + if ((pe = getprotobynumber(number)) != NULL) + printf(" %s", pe->p_name); + else printf(" %d", number); - return; - } - printf(" %s", cp); } int |