Deleted Added
full compact
kern_acct.c (62550) kern_acct.c (69286)
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 * $FreeBSD: head/sys/kern/kern_acct.c 62550 2000-07-04 03:34:11Z mckusick $
40 * $FreeBSD: head/sys/kern/kern_acct.c 69286 2000-11-27 22:52:31Z jake $
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>

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

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 */
76static comp_t encode_comp_t __P((u_long, u_long));
77static void acctwatch __P((void *));
78
79/*
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>

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

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 */
76static comp_t encode_comp_t __P((u_long, u_long));
77static void acctwatch __P((void *));
78
79/*
80 * Accounting callout handle used for periodic scheduling of
81 * acctwatch.
80 * Accounting callout used for periodic scheduling of acctwatch.
82 */
81 */
83static struct callout_handle acctwatch_handle
84 = CALLOUT_HANDLE_INITIALIZER(&acctwatch_handle);
82static struct callout acctwatch_callout;
85
86/*
87 * Accounting vnode pointer, and saved vnode pointer.
88 */
89static struct vnode *acctp;
90static struct vnode *savacctp;
91
92/*

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

143 }
144 }
145
146 /*
147 * If accounting was previously enabled, kill the old space-watcher,
148 * close the file, and (if no new file was specified, leave).
149 */
150 if (acctp != NULLVP || savacctp != NULLVP) {
83
84/*
85 * Accounting vnode pointer, and saved vnode pointer.
86 */
87static struct vnode *acctp;
88static struct vnode *savacctp;
89
90/*

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

141 }
142 }
143
144 /*
145 * If accounting was previously enabled, kill the old space-watcher,
146 * close the file, and (if no new file was specified, leave).
147 */
148 if (acctp != NULLVP || savacctp != NULLVP) {
151 untimeout(acctwatch, NULL, acctwatch_handle);
149 callout_stop(&acctwatch_callout);
152 error = vn_close((acctp != NULLVP ? acctp : savacctp), FWRITE,
153 p->p_ucred, p);
154 acctp = savacctp = NULLVP;
155 }
156 if (SCARG(uap, path) == NULL)
157 return (error);
158
159 /*
160 * Save the new accounting file vnode, and schedule the new
161 * free space watcher.
162 */
163 acctp = nd.ni_vp;
150 error = vn_close((acctp != NULLVP ? acctp : savacctp), FWRITE,
151 p->p_ucred, p);
152 acctp = savacctp = NULLVP;
153 }
154 if (SCARG(uap, path) == NULL)
155 return (error);
156
157 /*
158 * Save the new accounting file vnode, and schedule the new
159 * free space watcher.
160 */
161 acctp = nd.ni_vp;
162 callout_init(&acctwatch_callout, 0);
164 acctwatch(NULL);
165 return (error);
166}
167
168/*
169 * Write out process accounting information, on process exit.
170 * Data to be written out is specified in Leffler, et al.
171 * and are enumerated below. (They're also noted in the system

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

324 }
325 (void)VFS_STATFS(acctp->v_mount, &sb, (struct proc *)0);
326 if (sb.f_bavail <= acctsuspend * sb.f_blocks / 100) {
327 savacctp = acctp;
328 acctp = NULLVP;
329 log(LOG_NOTICE, "Accounting suspended\n");
330 }
331 }
163 acctwatch(NULL);
164 return (error);
165}
166
167/*
168 * Write out process accounting information, on process exit.
169 * Data to be written out is specified in Leffler, et al.
170 * and are enumerated below. (They're also noted in the system

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

323 }
324 (void)VFS_STATFS(acctp->v_mount, &sb, (struct proc *)0);
325 if (sb.f_bavail <= acctsuspend * sb.f_blocks / 100) {
326 savacctp = acctp;
327 acctp = NULLVP;
328 log(LOG_NOTICE, "Accounting suspended\n");
329 }
330 }
332 acctwatch_handle = timeout(acctwatch, NULL, acctchkfreq * hz);
331 callout_reset(&acctwatch_callout, acctchkfreq * hz, acctwatch, NULL);
333}
332}