Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/w - Remove SUPPORT_FTPD_UTMP flag. Enable it only fo...
details: https://anonhg.NetBSD.org/src/rev/c012e5e1dd71
branches: trunk
changeset: 543485:c012e5e1dd71
user: christos <christos%NetBSD.org@localhost>
date: Wed Feb 26 15:01:09 2003 +0000
description:
- Remove SUPPORT_FTPD_UTMP flag. Enable it only for utmp entries, utmpx does
not need it since it can get the pid from the utmpx structure.
- If the line is not found, and the pid is present (from utmpx) use that to
determine the process information for that particular entry.
diffstat:
usr.bin/w/Makefile | 4 ++--
usr.bin/w/w.c | 54 +++++++++++++++++++++++++-----------------------------
2 files changed, 27 insertions(+), 31 deletions(-)
diffs (134 lines):
diff -r 483b02dd03f8 -r c012e5e1dd71 usr.bin/w/Makefile
--- a/usr.bin/w/Makefile Wed Feb 26 14:36:43 2003 +0000
+++ b/usr.bin/w/Makefile Wed Feb 26 15:01:09 2003 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.18 2002/09/18 14:00:43 lukem Exp $
+# $NetBSD: Makefile,v 1.19 2003/02/26 15:01:09 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 6/6/93
.include <bsd.own.mk>
@@ -9,7 +9,7 @@
DPADD= ${LIBKVM}
LDADD= -lkvm
LINKS= ${BINDIR}/w ${BINDIR}/uptime
-CPPFLAGS+= -DSUPPORT_FTPD_UTMP -DSUPPORT_UTMP -DSUPPORT_UTMPX
+CPPFLAGS+= -DSUPPORT_UTMP -DSUPPORT_UTMPX
.PATH: ${NETBSDSRCDIR}/bin/ps
diff -r 483b02dd03f8 -r c012e5e1dd71 usr.bin/w/w.c
--- a/usr.bin/w/w.c Wed Feb 26 14:36:43 2003 +0000
+++ b/usr.bin/w/w.c Wed Feb 26 15:01:09 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: w.c,v 1.54 2002/10/21 10:18:23 enami Exp $ */
+/* $NetBSD: w.c,v 1.55 2003/02/26 15:01:09 christos Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993, 1994
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)w.c 8.6 (Berkeley) 6/30/94";
#else
-__RCSID("$NetBSD: w.c,v 1.54 2002/10/21 10:18:23 enami Exp $");
+__RCSID("$NetBSD: w.c,v 1.55 2003/02/26 15:01:09 christos Exp $");
#endif
#endif /* not lint */
@@ -119,9 +119,7 @@
dev_t tdev; /* dev_t of terminal */
time_t idle; /* idle time of terminal in seconds */
struct kinfo_proc2 *kp; /* `most interesting' proc */
-#ifdef SUPPORT_FTPD_UTMP
- pid_t ftpd_pid; /* pid as extracted from ftpd's entry */
-#endif
+ pid_t pid; /* pid or ~0 if not known */
} *ep, *ehead = NULL, **nextp = &ehead;
static void pr_args(struct kinfo_proc2 *);
@@ -231,6 +229,7 @@
ep->host[sizeof(utx->ut_host)] = '\0';
}
ep->tv = utx->ut_tv;
+ ep->pid = utx->ut_pid;
*nextp = ep;
nextp = &(ep->next);
if (wcmd != 0)
@@ -266,7 +265,6 @@
ep->line[sizeof(ut->ut_line)] = '\0';
ep->host[sizeof(ut->ut_host)] = '\0';
ep->tv.tv_sec = ut->ut_time;
- ep->tv.tv_usec = 0;
*nextp = ep;
nextp = &(ep->next);
if (wcmd != 0)
@@ -298,25 +296,22 @@
continue;
for (ep = ehead; ep != NULL; ep = ep->next) {
- if (ep->tdev == kp->p_tdev &&
- kp->p__pgid == kp->p_tpgid) {
- /*
- * Proc is in foreground of this terminal
- */
- if (proc_compare(ep->kp, kp)) {
- ep->kp = kp;
+ if (ep->tdev != 0) {
+ if (ep->tdev == kp->p_tdev &&
+ kp->p__pgid == kp->p_tpgid) {
+ /*
+ * Proc is in foreground of this
+ * terminal
+ */
+ if (proc_compare(ep->kp, kp)) {
+ ep->kp = kp;
+ }
+ break;
}
+ } else if (ep->pid != 0 && ep->pid == kp->p_pid) {
+ ep->kp = kp;
break;
}
-#ifdef SUPPORT_FTPD_UTMP
- /*
- * Hack to match process to ftp utmp entry.
- */
- else if (ep->tdev == 0 && kp->p_tdev == NODEV &&
- ep->ftpd_pid == kp->p_pid) {
- ep->kp = kp;
- }
-#endif /* SUPPORT_FTPD_UTMP */
}
}
@@ -552,23 +547,24 @@
if ((max = strlen(ep->host)) > maxhost)
maxhost = max;
- if ((stp = ttystat(ep->line)) == NULL)
- return;
-#ifdef SUPPORT_FTPD_UTMP
+#ifdef SUPPORT_UTMP
/*
* Hack to recognize and correctly parse
* ut entry made by ftpd. The "tty" used
* by ftpd is not a real tty, just identifier in
* form ftpSUPPORT_ID. Pid parsed from the "tty name"
* is used later to match corresponding process.
+ * NB: This is only used for utmp entries. For utmpx,
+ * we already have the pid.
*/
- if (strncmp(ep->line, "ftp", 3) == 0) {
- ep->ftpd_pid = strtol(ep->line + 3, NULL, 10);
-
+ if (ep->pid == 0 && strncmp(ep->line, "ftp", 3) == 0) {
+ ep->pid = strtol(ep->line + 3, NULL, 10);
return;
}
-#endif /* SUPPORT_FTPD_UTMP */
+#endif
+ if ((stp = ttystat(ep->line)) == NULL)
+ return;
ep->tdev = stp->st_rdev;
/*
Home |
Main Index |
Thread Index |
Old Index