Deleted Added
full compact
kern_acct.c (29041) kern_acct.c (29680)
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.15 1997/03/24 11:24:34 bde Exp $
40 * $Id: kern_acct.c,v 1.16 1997/09/02 20:05:36 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>

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

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

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

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 */
75static comp_t encode_comp_t __P((u_long, u_long));
76static void acctwatch __P((void *));
77
78/*
79 * Accounting callout handle used for periodic scheduling of
80 * acctwatch.
81 */
82static struct callout_handle acctwatch_handle
83 = CALLOUT_HANDLE_INITIALIZER(&acctwatch_handle);
84
85/*
79 * Accounting vnode pointer, and saved vnode pointer.
80 */
81static struct vnode *acctp;
82static struct vnode *savacctp;
83
84/*
85 * Values associated with enabling and disabling accounting
86 */

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

134 }
135 }
136
137 /*
138 * If accounting was previously enabled, kill the old space-watcher,
139 * close the file, and (if no new file was specified, leave).
140 */
141 if (acctp != NULLVP || savacctp != NULLVP) {
86 * Accounting vnode pointer, and saved vnode pointer.
87 */
88static struct vnode *acctp;
89static struct vnode *savacctp;
90
91/*
92 * Values associated with enabling and disabling accounting
93 */

--- 47 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) {
142 untimeout(acctwatch, NULL);
149 untimeout(acctwatch, NULL, acctwatch_handle);
143 error = vn_close((acctp != NULLVP ? acctp : savacctp), FWRITE,
144 p->p_ucred, p);
145 acctp = savacctp = NULLVP;
146 }
147 if (SCARG(uap, path) == NULL)
148 return (error);
149
150 /*

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

305 }
306 (void)VFS_STATFS(acctp->v_mount, &sb, (struct proc *)0);
307 if (sb.f_bavail <= acctsuspend * sb.f_blocks / 100) {
308 savacctp = acctp;
309 acctp = NULLVP;
310 log(LOG_NOTICE, "Accounting suspended\n");
311 }
312 }
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 /*

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

312 }
313 (void)VFS_STATFS(acctp->v_mount, &sb, (struct proc *)0);
314 if (sb.f_bavail <= acctsuspend * sb.f_blocks / 100) {
315 savacctp = acctp;
316 acctp = NULLVP;
317 log(LOG_NOTICE, "Accounting suspended\n");
318 }
319 }
313 timeout(acctwatch, NULL, acctchkfreq * hz);
320 acctwatch_handle = timeout(acctwatch, NULL, acctchkfreq * hz);
314}
321}