Deleted Added
full compact
kern_acct.c (12221) kern_acct.c (12819)
1/*-
2 * Copyright (c) 1994 Christopher G. Demetriou
3 * Copyright (c) 1982, 1986, 1989, 1993
4 * The Regents of the University of California. All rights reserved.
5 * (c) UNIX System Laboratories, Inc.
6 * All or some portions of this file are derived from material licensed
7 * to the University of California by American Telephone and Telegraph
8 * Co. or Unix System Laboratories, Inc. and are reproduced herein with

--- 23 unchanged lines hidden (view full) ---

32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 * @(#)kern_acct.c 8.1 (Berkeley) 6/14/93
1/*-
2 * Copyright (c) 1994 Christopher G. Demetriou
3 * Copyright (c) 1982, 1986, 1989, 1993
4 * The Regents of the University of California. All rights reserved.
5 * (c) UNIX System Laboratories, Inc.
6 * All or some portions of this file are derived from material licensed
7 * to the University of California by American Telephone and Telegraph
8 * Co. or Unix System Laboratories, Inc. and are reproduced herein with

--- 23 unchanged lines hidden (view full) ---

32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 * @(#)kern_acct.c 8.1 (Berkeley) 6/14/93
40 * $Id: kern_acct.c,v 1.8 1995/10/29 15:30:56 phk Exp $
40 * $Id: kern_acct.c,v 1.9 1995/11/12 06:42:51 bde Exp $
41 */
42
43#include <sys/param.h>
44#include <sys/systm.h>
45#include <sys/sysproto.h>
46#include <sys/proc.h>
47#include <sys/mount.h>
48#include <sys/vnode.h>
49#include <sys/file.h>
50#include <sys/syslog.h>
51#include <sys/kernel.h>
41 */
42
43#include <sys/param.h>
44#include <sys/systm.h>
45#include <sys/sysproto.h>
46#include <sys/proc.h>
47#include <sys/mount.h>
48#include <sys/vnode.h>
49#include <sys/file.h>
50#include <sys/syslog.h>
51#include <sys/kernel.h>
52#include <sys/sysctl.h>
52#include <sys/namei.h>
53#include <sys/errno.h>
54#include <sys/acct.h>
55#include <sys/resourcevar.h>
56#include <sys/ioctl.h>
57#include <sys/tty.h>
58
59/*

--- 7 unchanged lines hidden (view full) ---

67 * is read by a user process, etc. However, that has its own problems.
68 */
69
70/*
71 * Internal accounting functions.
72 * The former's operation is described in Leffler, et al., and the latter
73 * was provided by UCB with the 4.4BSD-Lite release
74 */
53#include <sys/namei.h>
54#include <sys/errno.h>
55#include <sys/acct.h>
56#include <sys/resourcevar.h>
57#include <sys/ioctl.h>
58#include <sys/tty.h>
59
60/*

--- 7 unchanged lines hidden (view full) ---

68 * is read by a user process, etc. However, that has its own problems.
69 */
70
71/*
72 * Internal accounting functions.
73 * The former's operation is described in Leffler, et al., and the latter
74 * was provided by UCB with the 4.4BSD-Lite release
75 */
75comp_t encode_comp_t __P((u_long, u_long));
76void acctwatch __P((void *));
76static comp_t encode_comp_t __P((u_long, u_long));
77static void acctwatch __P((void *));
77
78/*
79 * Accounting vnode pointer, and saved vnode pointer.
80 */
78
79/*
80 * Accounting vnode pointer, and saved vnode pointer.
81 */
81struct vnode *acctp;
82struct vnode *savacctp;
82static struct vnode *acctp;
83static struct vnode *savacctp;
83
84/*
85 * Values associated with enabling and disabling accounting
86 */
84
85/*
86 * Values associated with enabling and disabling accounting
87 */
87int acctsuspend = 2; /* stop accounting when < 2% free space left */
88int acctresume = 4; /* resume when free space risen to > 4% */
89int acctchkfreq = 15; /* frequency (in seconds) to check space */
88static int acctsuspend = 2; /* stop accounting when < 2% free space left */
89SYSCTL_INT(_kern, OID_AUTO, acct_suspend, CTLFLAG_RW,
90 &acctsuspend, 0, "");
90
91
92static int acctresume = 4; /* resume when free space risen to > 4% */
93SYSCTL_INT(_kern, OID_AUTO, acct_resume, CTLFLAG_RW,
94 &acctresume, 0, "");
95
96static int acctchkfreq = 15; /* frequency (in seconds) to check space */
97SYSCTL_INT(_kern, OID_AUTO, acct_chkfreq, CTLFLAG_RW,
98 &acctchkfreq, 0, "");
99
91/*
92 * Accounting system call. Written based on the specification and
93 * previous implementation done by Mark Tinguely.
94 */
95#ifndef _SYS_SYSPROTO_H_
96struct acct_args {
97 char *path;
98};

--- 131 unchanged lines hidden (view full) ---

230 * to ticks in 1/AHZ seconds. The encoding is described in
231 * Leffler, et al., on page 63.
232 */
233
234#define MANTSIZE 13 /* 13 bit mantissa. */
235#define EXPSIZE 3 /* Base 8 (3 bit) exponent. */
236#define MAXFRACT ((1 << MANTSIZE) - 1) /* Maximum fractional value. */
237
100/*
101 * Accounting system call. Written based on the specification and
102 * previous implementation done by Mark Tinguely.
103 */
104#ifndef _SYS_SYSPROTO_H_
105struct acct_args {
106 char *path;
107};

--- 131 unchanged lines hidden (view full) ---

239 * to ticks in 1/AHZ seconds. The encoding is described in
240 * Leffler, et al., on page 63.
241 */
242
243#define MANTSIZE 13 /* 13 bit mantissa. */
244#define EXPSIZE 3 /* Base 8 (3 bit) exponent. */
245#define MAXFRACT ((1 << MANTSIZE) - 1) /* Maximum fractional value. */
246
238comp_t
247static comp_t
239encode_comp_t(s, us)
240 u_long s, us;
241{
242 int exp, rnd;
243
244 exp = 0;
245 rnd = 0;
246 s *= AHZ;

--- 19 unchanged lines hidden (view full) ---

266
267/*
268 * Periodically check the file system to see if accounting
269 * should be turned on or off. Beware the case where the vnode
270 * has been vgone()'d out from underneath us, e.g. when the file
271 * system containing the accounting file has been forcibly unmounted.
272 */
273/* ARGSUSED */
248encode_comp_t(s, us)
249 u_long s, us;
250{
251 int exp, rnd;
252
253 exp = 0;
254 rnd = 0;
255 s *= AHZ;

--- 19 unchanged lines hidden (view full) ---

275
276/*
277 * Periodically check the file system to see if accounting
278 * should be turned on or off. Beware the case where the vnode
279 * has been vgone()'d out from underneath us, e.g. when the file
280 * system containing the accounting file has been forcibly unmounted.
281 */
282/* ARGSUSED */
274void
283static void
275acctwatch(a)
276 void *a;
277{
278 struct statfs sb;
279
280 if (savacctp != NULLVP) {
281 if (savacctp->v_type == VBAD) {
282 (void) vn_close(savacctp, FWRITE, NOCRED, NULL);

--- 25 unchanged lines hidden ---
284acctwatch(a)
285 void *a;
286{
287 struct statfs sb;
288
289 if (savacctp != NULLVP) {
290 if (savacctp->v_type == VBAD) {
291 (void) vn_close(savacctp, FWRITE, NOCRED, NULL);

--- 25 unchanged lines hidden ---