From 7851679e8b0de29d80325fbc3a1b272a90a6b9cc Mon Sep 17 00:00:00 2001 From: cgd Date: Mon, 3 May 1993 01:53:21 +0000 Subject: [PATCH] change accton to work w/NWO --- usr.sbin/accton/Makefile | 4 ++- usr.sbin/accton/accton.8 | 59 ++++++++++++++++++++++++++++++++++++++++ usr.sbin/accton/accton.c | 27 +++++++++++++++--- 3 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 usr.sbin/accton/accton.8 diff --git a/usr.sbin/accton/Makefile b/usr.sbin/accton/Makefile index 752e58d4ccc2..52ad35d82403 100644 --- a/usr.sbin/accton/Makefile +++ b/usr.sbin/accton/Makefile @@ -1,6 +1,8 @@ # @(#)Makefile 5.3 (Berkeley) 5/11/90 PROG= accton -NOMAN= noman +MAN8= accton.0 +LINKS= ${BINDIR}/accton ${BINDIR}/acctoff +MLINKS= accton.8 acctoff.8 .include diff --git a/usr.sbin/accton/accton.8 b/usr.sbin/accton/accton.8 new file mode 100644 index 000000000000..371875f37b3e --- /dev/null +++ b/usr.sbin/accton/accton.8 @@ -0,0 +1,59 @@ +.\" Copyright (c) 1993 Christopher G. Demetriou +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +.\" DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +.\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $Id: accton.8,v 1.1 1993/05/03 01:53:22 cgd Exp $ +.\" +.Dd May 2, 1993 +.Dt ACCTON 8 +.Os NetBSD 0.8a +.Sh NAME +.Nm accton , +.Nm acctoff +.Nd enable/disable system accounting +.Sh SYNOPSIS +.Nm accton +.Nm acctoff +.Sh DESCRIPTION +.Nm Accton +enables generation of kernel accounting records, and +.Nm acctoff +disables their generation. +The actual logging of accounting records is done +by the +.Xr accoutant 8 +program. +.Sh SEE ALSO +.Xr accountant 8 , +.Xr lastcomm 1 , +.Xr acct 5 +.Sh HISTORY +The +.Nm accton +program probably appeared in Version 6 AT&T UNIX, +or thereabouts, but was substantially modified for +the new device-based accounting procedures in NetBSD 0.8a. +.Nm Acctoff +first appeard in NetBSD 0.8a. diff --git a/usr.sbin/accton/accton.c b/usr.sbin/accton/accton.c index 6e49055d4312..f965683cd449 100644 --- a/usr.sbin/accton/accton.c +++ b/usr.sbin/accton/accton.c @@ -1,4 +1,5 @@ /* + * Copyright (c) 1993 Christopher G. Demetriou * Copyright (c) 1988 Regents of the University of California. * All rights reserved. * @@ -38,20 +39,38 @@ char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)accton.c 4.3 (Berkeley) 6/1/90"; +/* from static char sccsid[] = "@(#)accton.c 4.3 (Berkeley) 6/1/90"; */ +static char rcsid[] = "$Id: accton.c,v 1.2 1993/05/03 01:53:23 cgd Exp $"; #endif /* not lint */ #include +#include main(argc, argv) int argc; char **argv; { - if (argc > 2) { - fputs("usage: accton [file]\n", stderr); + int turnon; + char *tail; + + if ((tail = strrchr(argv[0], '/')) == NULL) { + tail = argv[0]; + } else { + tail++; + } + if (!strcmp(tail, "accton")) { + turnon = 1; + } else if (!strcmp(tail, "acctoff")) { + turnon = 0; + } else { + turnon = -1; + } + if (argc != 1 || turnon == -1) { + fputs("usage: accton\n", stderr); + fputs("or: acctoff\n", stderr); exit(1); } - if (acct(argc == 2 ? argv[1] : (char *)NULL)) { + if (acct(turnon) < 0) { perror("accton"); exit(1); }