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 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/* |
80 * Accounting callout used for periodic scheduling of acctwatch. |
81 */ |
82static struct callout acctwatch_callout; |
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) { |
149 callout_stop(&acctwatch_callout); |
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); |
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 } |
331 callout_reset(&acctwatch_callout, acctchkfreq * hz, acctwatch, NULL); |
332} |