diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/ChangeLog | 24 | ||||
-rw-r--r-- | utils/parse.c | 20 | ||||
-rw-r--r-- | utils/ping.c | 89 | ||||
-rw-r--r-- | utils/portinfo.c | 4 | ||||
-rw-r--r-- | utils/psout.c | 22 | ||||
-rw-r--r-- | utils/settrans.c | 16 | ||||
-rw-r--r-- | utils/showtrans.c | 10 | ||||
-rw-r--r-- | utils/vminfo.c | 50 | ||||
-rw-r--r-- | utils/w.c | 46 |
9 files changed, 136 insertions, 145 deletions
diff --git a/utils/ChangeLog b/utils/ChangeLog index b6799f0c..47771afc 100644 --- a/utils/ChangeLog +++ b/utils/ChangeLog @@ -1,3 +1,27 @@ +1998-10-20 Roland McGrath <roland@baalperazim.frob.com> + + * Makefile (OBJS): Use % pattern instead of explicit list. + + * parse.c (parse_enum): Add braces to silence gcc warning. + * psout.c (psout): Likewise. + * settrans.c (main): Likewise. + * showtrans.c (main): Likewise. + * w.c (w_fetch): Likewise. + * vminfo.c (main): Likewise. + +1998-09-05 Roland McGrath <roland@baalperazim.frob.com> + + * ping.c: <linux/icmp.h> -> <netinet/ip_icmp.h>; + struct icmphdr -> struct icmp; + Remove macro hacks to cope with old headers. + (pinger_wrapper): Take and return void *, so we're a cthread_fn_t. + +1998-09-04 Roland McGrath <roland@baalperazim.frob.com> + + * portinfo.c (hold): Declare explicit `int' to silence warning. + + * Makefile (OBJS): Use pattern %.sh instead of explicit list. + Fri Aug 21 19:25:12 1998 Jose M. Moya <josem@gnu.org> * msgport.c: Comments added. diff --git a/utils/parse.c b/utils/parse.c index 5f82a393..5334dbda 100644 --- a/utils/parse.c +++ b/utils/parse.c @@ -1,6 +1,6 @@ /* Random helpful option parsing functions - Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. Written by Miles Bader <miles@gnu.ai.mit.edu> @@ -149,7 +149,7 @@ parse_numlist (char *arg, that ARG matches no entry , otherwise, an error message is printed and the program exits in this event. If ARG is an ambiguous match, an error message is printed and the program exits. */ -int +int parse_enum (const char *arg, const char *(*choice_fn)(unsigned n), const char *kind, int allow_mismatches, @@ -166,13 +166,15 @@ parse_enum (const char *arg, else { if (strncasecmp (choice, arg, arglen) == 0) - if (partial_match >= 0) - { - argp_error (state, "%s: Ambiguous %s", arg, kind); - return -1; - } - else - partial_match = n; + { + if (partial_match >= 0) + { + argp_error (state, "%s: Ambiguous %s", arg, kind); + return -1; + } + else + partial_match = n; + } n++; } diff --git a/utils/ping.c b/utils/ping.c index 525707b2..2f979e2c 100644 --- a/utils/ping.c +++ b/utils/ping.c @@ -40,7 +40,7 @@ char copyright[] = /* * From: @(#)ping.c 5.9 (Berkeley) 5/12/91 */ -char rcsid[] = "$Id: ping.c,v 1.2 1998/04/22 20:44:38 tb Exp $"; +char rcsid[] = "$Id: ping.c,v 1.3 1998/10/20 09:42:49 roland Exp $"; char pkg[] = "netkit-base-0.10"; /* @@ -69,8 +69,7 @@ char pkg[] = "netkit-base-0.10"; #include <netinet/in.h> #include <netinet/ip.h> -#include <linux/icmp.h> -/* #include <netinet/ip_icmp.h> */ +#include <netinet/ip_icmp.h> #include <arpa/inet.h> #include <netdb.h> #include <unistd.h> @@ -91,38 +90,6 @@ char pkg[] = "netkit-base-0.10"; #define SAFE_TO_DROP_ROOT #endif -#if defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ != 0) -#define icmphdr icmp -#define ICMP_DEST_UNREACH ICMP_UNREACH -#define ICMP_NET_UNREACH ICMP_UNREACH_NET -#define ICMP_HOST_UNREACH ICMP_UNREACH_HOST -#define ICMP_PORT_UNREACH ICMP_UNREACH_PORT -#define ICMP_PROT_UNREACH ICMP_UNREACH_PROTOCOL -#define ICMP_FRAG_NEEDED ICMP_UNREACH_NEEDFRAG -#define ICMP_SR_FAILED ICMP_UNREACH_SRCFAIL -#define ICMP_NET_UNKNOWN ICMP_UNREACH_NET_UNKNOWN -#define ICMP_HOST_UNKNOWN ICMP_UNREACH_HOST_UNKNOWN -#define ICMP_HOST_ISOLATED ICMP_UNREACH_ISOLATED -#define ICMP_NET_UNR_TOS ICMP_UNREACH_TOSNET -#define ICMP_HOST_UNR_TOS ICMP_UNREACH_TOSHOST -#define ICMP_SOURCE_QUENCH ICMP_SOURCEQUENCH -#define ICMP_REDIR_NET ICMP_REDIRECT_NET -#define ICMP_REDIR_HOST ICMP_REDIRECT_HOST -#define ICMP_REDIR_NETTOS ICMP_REDIRECT_TOSNET -#define ICMP_REDIR_HOSTTOS ICMP_REDIRECT_TOSHOST -#define ICMP_TIME_EXCEEDED ICMP_TIMXCEED -#define ICMP_EXC_TTL ICMP_TIMXCEED_INTRANS -#define ICMP_EXC_FRAGTIME ICMP_TIMXCEED_REASS -#define ICMP_PARAMETERPROB ICMP_PARAMPROB -#define ICMP_TIMESTAMP ICMP_TSTAMP -#define ICMP_TIMESTAMPREPLY ICMP_TSTAMPREPLY -#define ICMP_INFO_REQUEST ICMP_IREQ -#define ICMP_INFO_REPLY ICMP_IREQREPLY -#else -#define ICMP_MINLEN 28 -#define inet_ntoa(x) inet_ntoa(*((struct in_addr *)&(x))) -#endif - #define DEFDATALEN (64 - 8) /* default data length */ #define MAXIPLEN 60 #define MAXICMPLEN 76 @@ -195,17 +162,19 @@ static void fill(void *bp, char *patp); static void usage(void); static void pr_pack(char *buf, int cc, struct sockaddr_in *from); static void tvsub(struct timeval *out, struct timeval *in); -static void pr_icmph(struct icmphdr *icp); +static void pr_icmph(struct icmp *icp); static void pr_retip(struct ip *ip); /* Only wrapper to call pinger (). */ -pinger_wrapper () +void * +pinger_wrapper (void *ignored) { for (;;) { pinger (); sleep (interval); } + return 0; } int @@ -231,7 +200,7 @@ main(int argc, char *argv[]) am_i_root = (getuid()==0); cthread_init (); - + /* * Pull this stuff up front so we can drop root if desired. */ @@ -363,7 +332,7 @@ main(int argc, char *argv[]) } argc -= optind; argv += optind; - + if (argc != 1) usage(); target = *argv; @@ -487,13 +456,13 @@ main(int argc, char *argv[]) /* I replace this with thread -- Kunihiro (void)signal(SIGALRM, catcher); */ - + while (preload--) /* fire off them quickies */ pinger(); if ((options & F_FLOOD) == 0) - cthread_detach (cthread_fork ((cthread_fn_t) pinger_wrapper, NULL)); + cthread_detach (cthread_fork (pinger_wrapper, NULL)); for (;;) { @@ -531,7 +500,7 @@ main(int argc, char *argv[]) * catcher -- * This routine causes another PING to be transmitted, and then * schedules another SIGALRM for 1 second from now. - * + * * bug -- * Our sense of time will slowly skew (i.e., packets will not be * launched exactly at 1-second intervals). This does not affect the @@ -561,28 +530,6 @@ catcher(int ignore) } } -/* This is quick hack to compile this file under old Linux's linux/icmp.h */ -#if defined(__GLIBC__) && (__GLIBC__ >= 2) -#define icmp_type type -#define icmp_code code -#define icmp_cksum checksum -#define icmp_id un.echo.id -#define icmp_seq un.echo.sequence -#define icmp_gwaddr un.gateway -#else -#define ip_hl ihl -#define ip_v version -#define ip_tos tos -#define ip_len tot_len -#define ip_id id -#define ip_off frag_off -#define ip_ttl ttl -#define ip_p protocol -#define ip_sum check -#define ip_src saddr -#define ip_dst daddr -#endif - /* * pinger -- * Compose and transmit an ICMP ECHO REQUEST packet. The IP packet @@ -594,11 +541,11 @@ catcher(int ignore) static void pinger(void) { - register struct icmphdr *icp; + register struct icmp *icp; register int cc; int i; - icp = (struct icmphdr *)outpack; + icp = (struct icmp *)outpack; icp->icmp_type = ICMP_ECHO; icp->icmp_code = 0; icp->icmp_cksum = 0; @@ -639,7 +586,7 @@ pinger(void) void pr_pack(char *buf, int cc, struct sockaddr_in *from) { - register struct icmphdr *icp; + register struct icmp *icp; register int i; register u_char *cp,*dp; /*#if 0*/ @@ -668,7 +615,7 @@ pr_pack(char *buf, int cc, struct sockaddr_in *from) /* Now the ICMP part */ cc -= hlen; - icp = (struct icmphdr *)(buf + hlen); + icp = (struct icmp *)(buf + hlen); if (icp->icmp_type == ICMP_ECHOREPLY) { if (icp->icmp_id != ident) return; /* 'Twas not our ECHO */ @@ -932,7 +879,7 @@ static char *ttab[] = { * Print a descriptive string about an ICMP header. */ static void -pr_icmph(struct icmphdr *icp) +pr_icmph(struct icmp *icp) { switch(icp->icmp_type) { case ICMP_ECHOREPLY: @@ -1027,7 +974,7 @@ pr_icmph(struct icmphdr *icp) (void)printf("Redirect, Bad Code: %d", icp->icmp_code); break; } - (void)printf("(New addr: %s)\n", + (void)printf("(New addr: %s)\n", inet_ntoa(icp->icmp_gwaddr)); #ifndef icmp_data pr_retip((struct ip *)(icp + 1)); @@ -1139,7 +1086,7 @@ pr_addr(u_long l) if ((options & F_NUMERIC) || !(hp = gethostbyaddr((char *)&l, 4, AF_INET))) - (void)snprintf(buf, sizeof(buf), "%s", + (void)snprintf(buf, sizeof(buf), "%s", inet_ntoa(*(struct in_addr *)&l)); else (void)snprintf(buf, sizeof(buf), "%s (%s)", hp->h_name, diff --git a/utils/portinfo.c b/utils/portinfo.c index c56027b0..dd2f0ba1 100644 --- a/utils/portinfo.c +++ b/utils/portinfo.c @@ -1,6 +1,6 @@ /* Print information about a task's ports - Copyright (C) 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. Written by Miles Bader <miles@gnu.ai.mit.edu> @@ -102,7 +102,7 @@ parse_task (char *arg) return task; } -static volatile hold = 0; +static volatile int hold = 0; int main (int argc, char **argv) diff --git a/utils/psout.c b/utils/psout.c index 3c39eff0..d3bde0cf 100644 --- a/utils/psout.c +++ b/utils/psout.c @@ -1,6 +1,6 @@ /* Common output function for ps & w - Copyright (C) 1995, 1996 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc. Written by Miles Bader <miles@gnu.ai.mit.edu> @@ -97,15 +97,17 @@ psout (struct proc_stat_list *procs, error (5, err, "Can't make output stream"); if (print_heading) - if (procs->num_procs > 0) - { - err = ps_fmt_write_titles (fmt, output); - if (err) - error (0, err, "Can't print titles"); - ps_stream_newline (output); - } - else - error (0, 0, "No applicable processes"); + { + if (procs->num_procs > 0) + { + err = ps_fmt_write_titles (fmt, output); + if (err) + error (0, err, "Can't print titles"); + ps_stream_newline (output); + } + else + error (0, 0, "No applicable processes"); + } if (output_width) /* Try and restrict the number of output columns. */ diff --git a/utils/settrans.c b/utils/settrans.c index 4f82c666..408849a3 100644 --- a/utils/settrans.c +++ b/utils/settrans.c @@ -151,13 +151,15 @@ main(int argc, char *argv[]) active_flags = FS_TRANS_SET | (excl ? FS_TRANS_EXCL : 0); if (passive && !active) - /* When setting just the passive, decide what to do with any active. */ - if (kill_active) - /* Make it go away. */ - active_flags = FS_TRANS_SET; - else if (! keep_active) - /* Ensure that there isn't one. */ - active_flags = FS_TRANS_SET | FS_TRANS_EXCL; + { + /* When setting just the passive, decide what to do with any active. */ + if (kill_active) + /* Make it go away. */ + active_flags = FS_TRANS_SET; + else if (! keep_active) + /* Ensure that there isn't one. */ + active_flags = FS_TRANS_SET | FS_TRANS_EXCL; + } if (active && argz_len > 0) { diff --git a/utils/showtrans.c b/utils/showtrans.c index 5ec36a0c..74da61fa 100644 --- a/utils/showtrans.c +++ b/utils/showtrans.c @@ -77,10 +77,12 @@ main (int argc, char *argv[]) argz_stringify (trans, trans_len, ' '); if (!silent) - if (print_prefix) - printf ("%s: %s\n", name, trans); - else - puts (trans); + { + if (print_prefix) + printf ("%s: %s\n", name, trans); + else + puts (trans); + } if (trans != buf) vm_deallocate (mach_task_self (), diff --git a/utils/vminfo.c b/utils/vminfo.c index 73ddb99d..4440c00b 100644 --- a/utils/vminfo.c +++ b/utils/vminfo.c @@ -1,6 +1,6 @@ /* Print task vm information - Copyright (C) 1996, 1997 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. Written by Miles Bader <miles@gnu.ai.mit.edu> @@ -143,7 +143,7 @@ main (int argc, char **argv) break; case ARGP_KEY_NO_ARGS: - argp_usage (state); + argp_usage (state); default: return ARGP_ERR_UNKNOWN; @@ -179,16 +179,22 @@ main (int argc, char **argv) } if (holes && hole_addr != addr) - if ((what & (W_ADDRS|W_SIZES)) == (W_ADDRS|W_SIZES)) - if (hex) - printf (" [%#x] (hole)\n", addr - hole_addr); - else - printf (" [%d] (hole)\n", addr - hole_addr); - else if ((what & (W_ADDRS|W_SIZES)) == W_SIZES) - if (hex) - printf ("%#10x (hole)\n", addr - hole_addr); - else - printf ("%10u (hole)\n", addr - hole_addr); + { + if ((what & (W_ADDRS|W_SIZES)) == (W_ADDRS|W_SIZES)) + { + if (hex) + printf (" [%#x] (hole)\n", addr - hole_addr); + else + printf (" [%d] (hole)\n", addr - hole_addr); + } + else if ((what & (W_ADDRS|W_SIZES)) == W_SIZES) + { + if (hex) + printf ("%#10x (hole)\n", addr - hole_addr); + else + printf ("%10u (hole)\n", addr - hole_addr); + } + } if ((what & (W_ADDRS|W_SIZES)) == (W_ADDRS|W_SIZES)) if (hex) @@ -201,10 +207,12 @@ main (int argc, char **argv) else printf ("%10u", addr); else if ((what & (W_ADDRS|W_SIZES)) == W_SIZES) - if (hex) - printf ("%#10x", size); - else - printf ("%10u", size); + { + if (hex) + printf ("%#10x", size); + else + printf ("%10u", size); + } if (what & W_DETAILS) { printf (" (prot=%s", prot_rep (prot)); @@ -217,10 +225,12 @@ main (int argc, char **argv) if (obj != MACH_PORT_NULL) printf (", mem_obj=%d", obj); if (offs != 0) - if (hex) - printf (", offs=%#x", offs); - else - printf (", offs=%d", offs); + { + if (hex) + printf (", offs=%#x", offs); + else + printf (", offs=%d", offs); + } putchar (')'); } putchar ('\n'); @@ -135,28 +135,30 @@ w_fetch (struct proc_stat *ps, ps_flags_t need, ps_flags_t have) } if (need & W_PSTAT_IDLE) - if (have & PSTAT_TTY) - { - struct stat stat; - struct ps_tty *tty = ps->tty; - - hook->idle.tv_usec = 0; - if (! tty) - { - hook->idle.tv_sec = 0; - have |= W_PSTAT_IDLE; - } - else - { - if (io_stat (tty->port, &stat) == 0) - { - hook->idle.tv_sec = now.tv_sec - stat.st_atime; - have |= W_PSTAT_IDLE; - } - } - } - else if (ps->inapp & PSTAT_TTY) - ps->inapp |= W_PSTAT_IDLE; + { + if (have & PSTAT_TTY) + { + struct stat stat; + struct ps_tty *tty = ps->tty; + + hook->idle.tv_usec = 0; + if (! tty) + { + hook->idle.tv_sec = 0; + have |= W_PSTAT_IDLE; + } + else + { + if (io_stat (tty->port, &stat) == 0) + { + hook->idle.tv_sec = now.tv_sec - stat.st_atime; + have |= W_PSTAT_IDLE; + } + } + } + else if (ps->inapp & PSTAT_TTY) + ps->inapp |= W_PSTAT_IDLE; + } if (need & W_PSTAT_USER) if (ps_user_uname_create (hook->utmp.ut_name, &hook->user) == 0) |