\hypertarget{kern__acct_8c_source}{}\doxysection{kern\+\_\+acct.\+c}
\label{kern__acct_8c_source}\index{kern/kern\_acct.c@{kern/kern\_acct.c}}
\mbox{\hyperlink{kern__acct_8c}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00001}00001 \textcolor{comment}{/*-\/}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00002}00002 \textcolor{comment}{ * SPDX-\/License-\/Identifier: BSD-\/4-\/Clause}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00003}00003 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00004}00004 \textcolor{comment}{ * Copyright (c) 1982, 1986, 1989, 1993}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00005}00005 \textcolor{comment}{ *      The Regents of the University of California.  All rights reserved.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00006}00006 \textcolor{comment}{ * (c) UNIX System Laboratories, Inc.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00007}00007 \textcolor{comment}{ * Copyright (c) 2005 Robert N. M. Watson}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00008}00008 \textcolor{comment}{ * All rights reserved.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00009}00009 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00010}00010 \textcolor{comment}{ * All or some portions of this file are derived from material licensed}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00011}00011 \textcolor{comment}{ * to the University of California by American Telephone and Telegraph}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00012}00012 \textcolor{comment}{ * Co. or Unix System Laboratories, Inc. and are reproduced herein with}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00013}00013 \textcolor{comment}{ * the permission of UNIX System Laboratories, Inc.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00014}00014 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00015}00015 \textcolor{comment}{ * Redistribution and use in source and binary forms, with or without}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00016}00016 \textcolor{comment}{ * modification, are permitted provided that the following conditions}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00017}00017 \textcolor{comment}{ * are met:}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00018}00018 \textcolor{comment}{ * 1. Redistributions of source code must retain the above copyright}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00019}00019 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00020}00020 \textcolor{comment}{ * 2. Redistributions in binary form must reproduce the above copyright}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00021}00021 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer in the}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00022}00022 \textcolor{comment}{ *    documentation and/or other materials provided with the distribution.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00023}00023 \textcolor{comment}{ * 3. Neither the name of the University nor the names of its contributors}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00024}00024 \textcolor{comment}{ *    may be used to endorse or promote products derived from this software}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00025}00025 \textcolor{comment}{ *    without specific prior written permission.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00026}00026 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00027}00027 \textcolor{comment}{ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00028}00028 \textcolor{comment}{ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00029}00029 \textcolor{comment}{ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00030}00030 \textcolor{comment}{ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00031}00031 \textcolor{comment}{ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00032}00032 \textcolor{comment}{ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00033}00033 \textcolor{comment}{ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00034}00034 \textcolor{comment}{ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00035}00035 \textcolor{comment}{ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00036}00036 \textcolor{comment}{ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00037}00037 \textcolor{comment}{ * SUCH DAMAGE.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00038}00038 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00039}00039 \textcolor{comment}{ * Copyright (c) 1994 Christopher G. Demetriou}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00040}00040 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00041}00041 \textcolor{comment}{ * Redistribution and use in source and binary forms, with or without}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00042}00042 \textcolor{comment}{ * modification, are permitted provided that the following conditions}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00043}00043 \textcolor{comment}{ * are met:}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00044}00044 \textcolor{comment}{ * 1. Redistributions of source code must retain the above copyright}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00045}00045 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00046}00046 \textcolor{comment}{ * 2. Redistributions in binary form must reproduce the above copyright}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00047}00047 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer in the}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00048}00048 \textcolor{comment}{ *    documentation and/or other materials provided with the distribution.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00049}00049 \textcolor{comment}{ * 3. All advertising materials mentioning features or use of this software}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00050}00050 \textcolor{comment}{ *    must display the following acknowledgement:}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00051}00051 \textcolor{comment}{ *      This product includes software developed by the University of}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00052}00052 \textcolor{comment}{ *      California, Berkeley and its contributors.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00053}00053 \textcolor{comment}{ * 4. Neither the name of the University nor the names of its contributors}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00054}00054 \textcolor{comment}{ *    may be used to endorse or promote products derived from this software}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00055}00055 \textcolor{comment}{ *    without specific prior written permission.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00056}00056 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00057}00057 \textcolor{comment}{ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00058}00058 \textcolor{comment}{ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00059}00059 \textcolor{comment}{ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00060}00060 \textcolor{comment}{ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00061}00061 \textcolor{comment}{ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00062}00062 \textcolor{comment}{ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00063}00063 \textcolor{comment}{ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00064}00064 \textcolor{comment}{ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00065}00065 \textcolor{comment}{ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00066}00066 \textcolor{comment}{ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00067}00067 \textcolor{comment}{ * SUCH DAMAGE.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00068}00068 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00069}00069 \textcolor{comment}{ *      @(\#)kern\_acct.c 8.1 (Berkeley) 6/14/93}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00070}00070 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00071}00071 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00072}00072 \textcolor{preprocessor}{\#include <sys/cdefs.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00073}\mbox{\hyperlink{kern__acct_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{00073}} \mbox{\hyperlink{kern__acct_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{\_\_FBSDID}}(\textcolor{stringliteral}{"{}\$FreeBSD\$"{}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00074}00074 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00075}00075 \textcolor{preprocessor}{\#include <sys/param.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00076}00076 \textcolor{preprocessor}{\#include <sys/systm.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00077}00077 \textcolor{preprocessor}{\#include <sys/acct.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00078}00078 \textcolor{preprocessor}{\#include <sys/fcntl.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00079}00079 \textcolor{preprocessor}{\#include <sys/kernel.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00080}00080 \textcolor{preprocessor}{\#include <sys/kthread.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00081}00081 \textcolor{preprocessor}{\#include <sys/limits.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00082}00082 \textcolor{preprocessor}{\#include <sys/lock.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00083}00083 \textcolor{preprocessor}{\#include <sys/malloc.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00084}00084 \textcolor{preprocessor}{\#include <sys/mount.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00085}00085 \textcolor{preprocessor}{\#include <sys/mutex.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00086}00086 \textcolor{preprocessor}{\#include <sys/namei.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00087}00087 \textcolor{preprocessor}{\#include <sys/priv.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00088}00088 \textcolor{preprocessor}{\#include <sys/proc.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00089}00089 \textcolor{preprocessor}{\#include <sys/resourcevar.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00090}00090 \textcolor{preprocessor}{\#include <sys/sched.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00091}00091 \textcolor{preprocessor}{\#include <sys/sx.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00092}00092 \textcolor{preprocessor}{\#include <sys/sysctl.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00093}00093 \textcolor{preprocessor}{\#include <sys/sysent.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00094}00094 \textcolor{preprocessor}{\#include <sys/syslog.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00095}00095 \textcolor{preprocessor}{\#include <sys/sysproto.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00096}00096 \textcolor{preprocessor}{\#include <sys/tty.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00097}00097 \textcolor{preprocessor}{\#include <sys/vnode.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00098}00098 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00099}00099 \textcolor{preprocessor}{\#include <security/mac/mac\_framework.h>}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00100}00100 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00101}\mbox{\hyperlink{kern__acct_8c_ac91562d683728350d63efae3623a396d}{00101}} \mbox{\hyperlink{kern__acct_8c_ac91562d683728350d63efae3623a396d}{\_Static\_assert}}(\textcolor{keyword}{sizeof}(\textcolor{keyword}{struct} acctv3) -\/ offsetof(\textcolor{keyword}{struct} acctv3, ac\_trailer) ==}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00102}00102     \textcolor{keyword}{sizeof}(\textcolor{keyword}{struct} acctv2) -\/ offsetof(\textcolor{keyword}{struct} acctv2, ac\_trailer), \textcolor{stringliteral}{"{}trailer"{}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00103}\mbox{\hyperlink{kern__acct_8c_a60e731395e327eb39b302386c790e9e4}{00103}} \mbox{\hyperlink{kern__acct_8c_ac91562d683728350d63efae3623a396d}{\_Static\_assert}}(\textcolor{keyword}{sizeof}(\textcolor{keyword}{struct} acctv3) -\/ offsetof(\textcolor{keyword}{struct} acctv3, ac\_len2) ==}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00104}00104     \textcolor{keyword}{sizeof}(\textcolor{keyword}{struct} acctv2) -\/ offsetof(\textcolor{keyword}{struct} acctv2, ac\_len2), \textcolor{stringliteral}{"{}len2"{}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00105}00105 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00106}00106 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00107}00107 \textcolor{comment}{ * The routines implemented in this file are described in:}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00108}00108 \textcolor{comment}{ *      Leffler, et al.: The Design and Implementation of the 4.3BSD}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00109}00109 \textcolor{comment}{ *          UNIX Operating System (Addison Welley, 1989)}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00110}00110 \textcolor{comment}{ * on pages 62-\/63.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00111}00111 \textcolor{comment}{ * On May 2007 the historic 3 bits base 8 exponent, 13 bit fraction}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00112}00112 \textcolor{comment}{ * compt\_t representation described in the above reference was replaced}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00113}00113 \textcolor{comment}{ * with that of IEEE-\/754 floats.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00114}00114 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00115}00115 \textcolor{comment}{ * Arguably, to simplify accounting operations, this mechanism should}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00116}00116 \textcolor{comment}{ * be replaced by one in which an accounting log file (similar to /dev/klog)}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00117}00117 \textcolor{comment}{ * is read by a user process, etc.  However, that has its own problems.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00118}00118 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00119}00119 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00120}00120 \textcolor{comment}{/* Floating point definitions from <float.h>. */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00121}\mbox{\hyperlink{kern__acct_8c_a0c22779a3c997aa03c16f2d8a7e3128e}{00121}} \textcolor{preprocessor}{\#define FLT\_MANT\_DIG    24              }\textcolor{comment}{/* p */}\textcolor{preprocessor}{}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00122}\mbox{\hyperlink{kern__acct_8c_afcbc8f81f213d358c2aba21a4bcf943b}{00122}} \textcolor{preprocessor}{\#define FLT\_MAX\_EXP     128             }\textcolor{comment}{/* emax */}\textcolor{preprocessor}{}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00123}00123 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00124}00124 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00125}00125 \textcolor{comment}{ * Internal accounting functions.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00126}00126 \textcolor{comment}{ * The former's operation is described in Leffler, et al., and the latter}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00127}00127 \textcolor{comment}{ * was provided by UCB with the 4.4BSD-\/Lite release}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00128}00128 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00129}00129 \textcolor{keyword}{static} uint32\_t \mbox{\hyperlink{kern__acct_8c_ac694f3ef6ac875844bef350c10452fc4}{encode\_timeval}}(\textcolor{keyword}{struct} timeval);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00130}00130 \textcolor{keyword}{static} uint32\_t \mbox{\hyperlink{kern__acct_8c_a5c44828e609222ad6ce69bb786d6e7f7}{encode\_long}}(\textcolor{keywordtype}{long});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00131}00131 \textcolor{keyword}{static} \textcolor{keywordtype}{void}     \mbox{\hyperlink{kern__acct_8c_ad9d98804aab958e5769d17081b0ebba3}{acctwatch}}(\textcolor{keywordtype}{void});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00132}00132 \textcolor{keyword}{static} \textcolor{keywordtype}{void}     \mbox{\hyperlink{kern__acct_8c_a42aff4687b851c3d97708eac9436ec61}{acct\_thread}}(\textcolor{keywordtype}{void} *);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00133}00133 \textcolor{keyword}{static} \textcolor{keywordtype}{int}      \mbox{\hyperlink{kern__acct_8c_ab30a297d140c915a6a94d4744e65f904}{acct\_disable}}(\textcolor{keyword}{struct} thread *, \textcolor{keywordtype}{int});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00134}00134 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00135}00135 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00136}00136 \textcolor{comment}{ * Accounting vnode pointer, saved vnode pointer, and flags for each.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00137}00137 \textcolor{comment}{ * acct\_sx protects against changes to the active vnode and credentials}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00138}00138 \textcolor{comment}{ * while accounting records are being committed to disk.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00139}00139 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00140}\mbox{\hyperlink{kern__acct_8c_adaf6ae4e4ea77b91ebd96298c4e5895e}{00140}} \textcolor{keyword}{static} \textcolor{keywordtype}{int}               \mbox{\hyperlink{kern__acct_8c_adaf6ae4e4ea77b91ebd96298c4e5895e}{acct\_configured}};}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00141}\mbox{\hyperlink{kern__acct_8c_a52cf926f2da78c9f90d9f6f9b0c696df}{00141}} \textcolor{keyword}{static} \textcolor{keywordtype}{int}               \mbox{\hyperlink{kern__acct_8c_a52cf926f2da78c9f90d9f6f9b0c696df}{acct\_suspended}};}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00142}\mbox{\hyperlink{kern__acct_8c_ab32781e3a6710f338374ab272d41007d}{00142}} \textcolor{keyword}{static} \textcolor{keyword}{struct }vnode     *\mbox{\hyperlink{kern__acct_8c_ab32781e3a6710f338374ab272d41007d}{acct\_vp}};}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00143}\mbox{\hyperlink{kern__acct_8c_a78766da5b59632a4e48758808ae7acb7}{00143}} \textcolor{keyword}{static} \textcolor{keyword}{struct }ucred     *\mbox{\hyperlink{kern__acct_8c_a78766da5b59632a4e48758808ae7acb7}{acct\_cred}};}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00144}\mbox{\hyperlink{kern__acct_8c_aaa42a1e0e9906db0cbff805153271601}{00144}} \textcolor{keyword}{static} \textcolor{keywordtype}{int}               \mbox{\hyperlink{kern__acct_8c_aaa42a1e0e9906db0cbff805153271601}{acct\_flags}};}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00145}\mbox{\hyperlink{kern__acct_8c_a7a2674027c3979280b81539dae08bcda}{00145}} \textcolor{keyword}{static} \textcolor{keyword}{struct }sx         \mbox{\hyperlink{kern__acct_8c_a7a2674027c3979280b81539dae08bcda}{acct\_sx}};}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00146}00146 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00147}\mbox{\hyperlink{kern__acct_8c_a419967c606922d8058bc23a204ea347a}{00147}} \mbox{\hyperlink{kern__acct_8c_a419967c606922d8058bc23a204ea347a}{SX\_SYSINIT}}(acct, \&\mbox{\hyperlink{kern__acct_8c_a7a2674027c3979280b81539dae08bcda}{acct\_sx}}, \textcolor{stringliteral}{"{}acct\_sx"{}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00148}00148 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00149}00149 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00150}00150 \textcolor{comment}{ * State of the accounting kthread.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00151}00151 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00152}\mbox{\hyperlink{kern__acct_8c_aa6c65591d46293fb582f0d36bae6c1c3}{00152}} \textcolor{keyword}{static} \textcolor{keywordtype}{int}               \mbox{\hyperlink{kern__acct_8c_aa6c65591d46293fb582f0d36bae6c1c3}{acct\_state}};}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00153}00153 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00154}\mbox{\hyperlink{kern__acct_8c_a70083df0622c8d0a870a5015440b37ba}{00154}} \textcolor{preprocessor}{\#define ACCT\_RUNNING    1       }\textcolor{comment}{/* Accounting kthread is running. */}\textcolor{preprocessor}{}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00155}\mbox{\hyperlink{kern__acct_8c_a87c8361feb0d11c220fed3cf5fb89689}{00155}} \textcolor{preprocessor}{\#define ACCT\_EXITREQ    2       }\textcolor{comment}{/* Accounting kthread should exit. */}\textcolor{preprocessor}{}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00156}00156 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00157}00157 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00158}00158 \textcolor{comment}{ * Values associated with enabling and disabling accounting}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00159}00159 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00160}\mbox{\hyperlink{kern__acct_8c_a217aee7b52e712c66bc96c103e9ba6cc}{00160}} \textcolor{keyword}{static} \textcolor{keywordtype}{int} \mbox{\hyperlink{kern__acct_8c_a217aee7b52e712c66bc96c103e9ba6cc}{acctsuspend}} = 2;  \textcolor{comment}{/* stop accounting when < 2\% free space left */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00161}\mbox{\hyperlink{kern__acct_8c_a931f77a708c49b0f98101d90f4114306}{00161}} \mbox{\hyperlink{kern__acct_8c_a931f77a708c49b0f98101d90f4114306}{SYSCTL\_INT}}(\_kern, OID\_AUTO, acct\_suspend, CTLFLAG\_RW,}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00162}00162         \&\mbox{\hyperlink{kern__acct_8c_a217aee7b52e712c66bc96c103e9ba6cc}{acctsuspend}}, 0, \textcolor{stringliteral}{"{}percentage of free disk space below which accounting stops"{}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00163}00163 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00164}\mbox{\hyperlink{kern__acct_8c_a42c24cbda14c72436f148240f1b29a37}{00164}} \textcolor{keyword}{static} \textcolor{keywordtype}{int} \mbox{\hyperlink{kern__acct_8c_a42c24cbda14c72436f148240f1b29a37}{acctresume}} = 4;    \textcolor{comment}{/* resume when free space risen to > 4\% */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00165}\mbox{\hyperlink{kern__acct_8c_ab41ae0bebd35b578993803b123fe63d7}{00165}} \mbox{\hyperlink{kern__acct_8c_a931f77a708c49b0f98101d90f4114306}{SYSCTL\_INT}}(\_kern, OID\_AUTO, acct\_resume, CTLFLAG\_RW,}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00166}00166         \&\mbox{\hyperlink{kern__acct_8c_a42c24cbda14c72436f148240f1b29a37}{acctresume}}, 0, \textcolor{stringliteral}{"{}percentage of free disk space above which accounting resumes"{}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00167}00167 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00168}\mbox{\hyperlink{kern__acct_8c_ae0b279357d0c1071ef72233001fd1504}{00168}} \textcolor{keyword}{static} \textcolor{keywordtype}{int} \mbox{\hyperlink{kern__acct_8c_ae0b279357d0c1071ef72233001fd1504}{acctchkfreq}} = 15; \textcolor{comment}{/* frequency (in seconds) to check space */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00169}00169 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00170}00170 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00171}\mbox{\hyperlink{kern__acct_8c_a1d5416153a550e110af71a505a185949}{00171}} \mbox{\hyperlink{kern__acct_8c_a1d5416153a550e110af71a505a185949}{sysctl\_acct\_chkfreq}}(SYSCTL\_HANDLER\_ARGS)}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00172}00172 \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00173}00173         \textcolor{keywordtype}{int} error, \mbox{\hyperlink{linker__if_8m_ada553d85f70dc5b195a6b55a6100fc8d}{value}};}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00174}00174 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00175}00175         \textcolor{comment}{/* Write out the old value. */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00176}00176         error = SYSCTL\_OUT(req, \&\mbox{\hyperlink{kern__acct_8c_ae0b279357d0c1071ef72233001fd1504}{acctchkfreq}}, \textcolor{keyword}{sizeof}(\textcolor{keywordtype}{int}));}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00177}00177         \textcolor{keywordflow}{if} (error || req-\/>newptr == NULL)}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00178}00178                 \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00179}00179 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00180}00180         \textcolor{comment}{/* Read in and verify the new value. */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00181}00181         error = SYSCTL\_IN(req, \&\mbox{\hyperlink{linker__if_8m_ada553d85f70dc5b195a6b55a6100fc8d}{value}}, \textcolor{keyword}{sizeof}(\textcolor{keywordtype}{int}));}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00182}00182         \textcolor{keywordflow}{if} (error)}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00183}00183                 \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00184}00184         \textcolor{keywordflow}{if} (\mbox{\hyperlink{linker__if_8m_ada553d85f70dc5b195a6b55a6100fc8d}{value}} <= 0)}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00185}00185                 \textcolor{keywordflow}{return} (EINVAL);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00186}00186         \mbox{\hyperlink{kern__acct_8c_ae0b279357d0c1071ef72233001fd1504}{acctchkfreq}} = \mbox{\hyperlink{linker__if_8m_ada553d85f70dc5b195a6b55a6100fc8d}{value}};}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00187}00187         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00188}00188 \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00189}\mbox{\hyperlink{kern__acct_8c_a4e0620ed2de6635fb29faea12ab210d6}{00189}} \mbox{\hyperlink{kern__acct_8c_a4e0620ed2de6635fb29faea12ab210d6}{SYSCTL\_PROC}}(\_kern, OID\_AUTO, acct\_chkfreq,}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00190}00190     CTLTYPE\_INT | CTLFLAG\_RW | CTLFLAG\_MPSAFE, \&\mbox{\hyperlink{kern__acct_8c_ae0b279357d0c1071ef72233001fd1504}{acctchkfreq}}, 0,}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00191}00191     \mbox{\hyperlink{kern__acct_8c_a1d5416153a550e110af71a505a185949}{sysctl\_acct\_chkfreq}}, \textcolor{stringliteral}{"{}I"{}},}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00192}00192     \textcolor{stringliteral}{"{}frequency for checking the free space"{}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00193}00193 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00194}\mbox{\hyperlink{kern__acct_8c_a2aa8864b70c88825cafd22d6449c034e}{00194}} \mbox{\hyperlink{kern__acct_8c_a931f77a708c49b0f98101d90f4114306}{SYSCTL\_INT}}(\_kern, OID\_AUTO, \mbox{\hyperlink{kern__acct_8c_adaf6ae4e4ea77b91ebd96298c4e5895e}{acct\_configured}}, CTLFLAG\_RD, \&\mbox{\hyperlink{kern__acct_8c_adaf6ae4e4ea77b91ebd96298c4e5895e}{acct\_configured}}, 0,}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00195}00195         \textcolor{stringliteral}{"{}Accounting configured or not"{}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00196}00196 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00197}\mbox{\hyperlink{kern__acct_8c_a2f27b32621b8f4c18552db4ba11bffdb}{00197}} \mbox{\hyperlink{kern__acct_8c_a931f77a708c49b0f98101d90f4114306}{SYSCTL\_INT}}(\_kern, OID\_AUTO, \mbox{\hyperlink{kern__acct_8c_a52cf926f2da78c9f90d9f6f9b0c696df}{acct\_suspended}}, CTLFLAG\_RD, \&\mbox{\hyperlink{kern__acct_8c_a52cf926f2da78c9f90d9f6f9b0c696df}{acct\_suspended}}, 0,}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00198}00198         \textcolor{stringliteral}{"{}Accounting suspended or not"{}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00199}00199 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00200}00200 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00201}00201 \textcolor{comment}{ * Accounting system call.  Written based on the specification and previous}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00202}00202 \textcolor{comment}{ * implementation done by Mark Tinguely.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00203}00203 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00204}00204 \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00205}\mbox{\hyperlink{kern__acct_8c_ac7b30a6c15df03c8e7ed02df72ef3d0f}{00205}} \mbox{\hyperlink{kern__acct_8c_ac7b30a6c15df03c8e7ed02df72ef3d0f}{sys\_acct}}(\textcolor{keyword}{struct} thread *td, \textcolor{keyword}{struct} acct\_args *uap)}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00206}00206 \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00207}00207         \textcolor{keyword}{struct }nameidata nd;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00208}00208         \textcolor{keywordtype}{int} error, \mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}}, replacing;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00209}00209 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00210}00210         error = \mbox{\hyperlink{kern__priv_8c_ac4dc084503bdb7f59e5032c6bd761ef6}{priv\_check}}(td, PRIV\_ACCT);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00211}00211         \textcolor{keywordflow}{if} (error)}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00212}00212                 \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00213}00213 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00214}00214         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00215}00215 \textcolor{comment}{         * If accounting is to be started to a file, open that file for}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00216}00216 \textcolor{comment}{         * appending and make sure it's a 'normal'.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00217}00217 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00218}00218         \textcolor{keywordflow}{if} (uap-\/>path != NULL) \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00219}00219                 NDINIT(\&nd, LOOKUP, NOFOLLOW | AUDITVNODE1, UIO\_USERSPACE,}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00220}00220                     uap-\/>path);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00221}00221                 \mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}} = FWRITE | O\_APPEND;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00222}00222                 error = \mbox{\hyperlink{vfs__vnops_8c_ab8b1451b1fdf20e4fd83f8633a438565}{vn\_open}}(\&nd, \&\mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}}, 0, NULL);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00223}00223                 \textcolor{keywordflow}{if} (error)}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00224}00224                         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00225}00225                 \mbox{\hyperlink{vfs__lookup_8c_a96d86ee2448b6bb134242d8f6d076510}{NDFREE}}(\&nd, NDF\_ONLY\_PNBUF);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00226}00226 \textcolor{preprocessor}{\#ifdef MAC}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00227}00227                 error = mac\_system\_check\_acct(td-\/>td\_ucred, nd.ni\_vp);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00228}00228                 \textcolor{keywordflow}{if} (error) \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00229}00229                         VOP\_UNLOCK(nd.ni\_vp);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00230}00230                         \mbox{\hyperlink{vfs__vnops_8c_ad6e383a4e49132514f14b04785f1a423}{vn\_close}}(nd.ni\_vp, \mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}}, td-\/>td\_ucred, td);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00231}00231                         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00232}00232                 \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00233}00233 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00234}00234                 VOP\_UNLOCK(nd.ni\_vp);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00235}00235                 \textcolor{keywordflow}{if} (nd.ni\_vp-\/>v\_type != VREG) \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00236}00236                         \mbox{\hyperlink{vfs__vnops_8c_ad6e383a4e49132514f14b04785f1a423}{vn\_close}}(nd.ni\_vp, \mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}}, td-\/>td\_ucred, td);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00237}00237                         \textcolor{keywordflow}{return} (EACCES);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00238}00238                 \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00239}00239 \textcolor{preprocessor}{\#ifdef MAC}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00240}00240         \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00241}00241                 error = mac\_system\_check\_acct(td-\/>td\_ucred, NULL);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00242}00242                 \textcolor{keywordflow}{if} (error)}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00243}00243                         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00244}00244 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00245}00245         \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00246}00246 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00247}00247         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00248}00248 \textcolor{comment}{         * Disallow concurrent access to the accounting vnode while we swap}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00249}00249 \textcolor{comment}{         * it out, in order to prevent access after close.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00250}00250 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00251}00251         sx\_xlock(\&\mbox{\hyperlink{kern__acct_8c_a7a2674027c3979280b81539dae08bcda}{acct\_sx}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00252}00252 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00253}00253         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00254}00254 \textcolor{comment}{         * Don't log spurious disable/enable messages if we are}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00255}00255 \textcolor{comment}{         * switching from one accounting file to another due to log}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00256}00256 \textcolor{comment}{         * rotation.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00257}00257 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00258}00258         replacing = (\mbox{\hyperlink{kern__acct_8c_ab32781e3a6710f338374ab272d41007d}{acct\_vp}} != NULL \&\& uap-\/>path != NULL);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00259}00259 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00260}00260         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00261}00261 \textcolor{comment}{         * If accounting was previously enabled, kill the old space-\/watcher,}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00262}00262 \textcolor{comment}{         * close the file, and (if no new file was specified, leave).  Reset}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00263}00263 \textcolor{comment}{         * the suspended state regardless of whether accounting remains}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00264}00264 \textcolor{comment}{         * enabled.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00265}00265 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00266}00266         \mbox{\hyperlink{kern__acct_8c_a52cf926f2da78c9f90d9f6f9b0c696df}{acct\_suspended}} = 0;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00267}00267         \textcolor{keywordflow}{if} (\mbox{\hyperlink{kern__acct_8c_ab32781e3a6710f338374ab272d41007d}{acct\_vp}} != NULL)}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00268}00268                 error = \mbox{\hyperlink{kern__acct_8c_ab30a297d140c915a6a94d4744e65f904}{acct\_disable}}(td, !replacing);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00269}00269         \textcolor{keywordflow}{if} (uap-\/>path == NULL) \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00270}00270                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{kern__acct_8c_aa6c65591d46293fb582f0d36bae6c1c3}{acct\_state}} \& \mbox{\hyperlink{kern__acct_8c_a70083df0622c8d0a870a5015440b37ba}{ACCT\_RUNNING}}) \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00271}00271                         \mbox{\hyperlink{kern__acct_8c_aa6c65591d46293fb582f0d36bae6c1c3}{acct\_state}} |= \mbox{\hyperlink{kern__acct_8c_a87c8361feb0d11c220fed3cf5fb89689}{ACCT\_EXITREQ}};}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00272}00272                         \mbox{\hyperlink{kern__synch_8c_ab5e31e48f559b1015c09a61a83c59f19}{wakeup}}(\&\mbox{\hyperlink{kern__acct_8c_aa6c65591d46293fb582f0d36bae6c1c3}{acct\_state}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00273}00273                 \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00274}00274                 sx\_xunlock(\&\mbox{\hyperlink{kern__acct_8c_a7a2674027c3979280b81539dae08bcda}{acct\_sx}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00275}00275                 \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00276}00276         \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00277}00277 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00278}00278         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00279}00279 \textcolor{comment}{         * Save the new accounting file vnode, and schedule the new}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00280}00280 \textcolor{comment}{         * free space watcher.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00281}00281 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00282}00282         \mbox{\hyperlink{kern__acct_8c_ab32781e3a6710f338374ab272d41007d}{acct\_vp}} = nd.ni\_vp;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00283}00283         \mbox{\hyperlink{kern__acct_8c_a78766da5b59632a4e48758808ae7acb7}{acct\_cred}} = \mbox{\hyperlink{kern__prot_8c_ad1a89ae551efaeacec3465742bc1270e}{crhold}}(td-\/>td\_ucred);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00284}00284         \mbox{\hyperlink{kern__acct_8c_aaa42a1e0e9906db0cbff805153271601}{acct\_flags}} = \mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}};}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00285}00285         \textcolor{keywordflow}{if} (\mbox{\hyperlink{kern__acct_8c_aa6c65591d46293fb582f0d36bae6c1c3}{acct\_state}} \& \mbox{\hyperlink{kern__acct_8c_a70083df0622c8d0a870a5015440b37ba}{ACCT\_RUNNING}})}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00286}00286                 \mbox{\hyperlink{kern__acct_8c_aa6c65591d46293fb582f0d36bae6c1c3}{acct\_state}} \&= \string~ACCT\_EXITREQ;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00287}00287         \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00288}00288                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00289}00289 \textcolor{comment}{                 * Try to start up an accounting kthread.  We may start more}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00290}00290 \textcolor{comment}{                 * than one, but if so the extras will commit suicide as}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00291}00291 \textcolor{comment}{                 * soon as they start up.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00292}00292 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00293}00293                 error = \mbox{\hyperlink{kern__kthread_8c_a26508750f2d8b6e6ca6985c5315ebe77}{kproc\_create}}(\mbox{\hyperlink{kern__acct_8c_a42aff4687b851c3d97708eac9436ec61}{acct\_thread}}, NULL, NULL, 0, 0,}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00294}00294                     \textcolor{stringliteral}{"{}accounting"{}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00295}00295                 \textcolor{keywordflow}{if} (error) \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00296}00296                         (void) \mbox{\hyperlink{kern__acct_8c_ab30a297d140c915a6a94d4744e65f904}{acct\_disable}}(td, 0);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00297}00297                         sx\_xunlock(\&\mbox{\hyperlink{kern__acct_8c_a7a2674027c3979280b81539dae08bcda}{acct\_sx}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00298}00298                         \mbox{\hyperlink{subr__prf_8c_af8bf48b681a0471cae1be861c2102d5f}{log}}(LOG\_NOTICE, \textcolor{stringliteral}{"{}Unable to start accounting thread\(\backslash\)n"{}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00299}00299                         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00300}00300                 \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00301}00301         \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00302}00302         \mbox{\hyperlink{kern__acct_8c_adaf6ae4e4ea77b91ebd96298c4e5895e}{acct\_configured}} = 1;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00303}00303         sx\_xunlock(\&\mbox{\hyperlink{kern__acct_8c_a7a2674027c3979280b81539dae08bcda}{acct\_sx}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00304}00304         \textcolor{keywordflow}{if} (!replacing)}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00305}00305                 \mbox{\hyperlink{subr__prf_8c_af8bf48b681a0471cae1be861c2102d5f}{log}}(LOG\_NOTICE, \textcolor{stringliteral}{"{}Accounting enabled\(\backslash\)n"{}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00306}00306         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00307}00307 \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00308}00308 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00309}00309 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00310}00310 \textcolor{comment}{ * Disable currently in-\/progress accounting by closing the vnode, dropping}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00311}00311 \textcolor{comment}{ * our reference to the credential, and clearing the vnode's flags.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00312}00312 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00313}00313 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00314}\mbox{\hyperlink{kern__acct_8c_ab30a297d140c915a6a94d4744e65f904}{00314}} \mbox{\hyperlink{kern__acct_8c_ab30a297d140c915a6a94d4744e65f904}{acct\_disable}}(\textcolor{keyword}{struct} thread *td, \textcolor{keywordtype}{int} logging)}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00315}00315 \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00316}00316         \textcolor{keywordtype}{int} error;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00317}00317 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00318}00318         sx\_assert(\&\mbox{\hyperlink{kern__acct_8c_a7a2674027c3979280b81539dae08bcda}{acct\_sx}}, SX\_XLOCKED);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00319}00319         error = \mbox{\hyperlink{vfs__vnops_8c_ad6e383a4e49132514f14b04785f1a423}{vn\_close}}(\mbox{\hyperlink{kern__acct_8c_ab32781e3a6710f338374ab272d41007d}{acct\_vp}}, \mbox{\hyperlink{kern__acct_8c_aaa42a1e0e9906db0cbff805153271601}{acct\_flags}}, \mbox{\hyperlink{kern__acct_8c_a78766da5b59632a4e48758808ae7acb7}{acct\_cred}}, td);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00320}00320         \mbox{\hyperlink{kern__prot_8c_ad922e69ed6a14e1a6d8b0b8cb9d859a0}{crfree}}(\mbox{\hyperlink{kern__acct_8c_a78766da5b59632a4e48758808ae7acb7}{acct\_cred}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00321}00321         \mbox{\hyperlink{kern__acct_8c_adaf6ae4e4ea77b91ebd96298c4e5895e}{acct\_configured}} = 0;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00322}00322         \mbox{\hyperlink{kern__acct_8c_ab32781e3a6710f338374ab272d41007d}{acct\_vp}} = NULL;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00323}00323         \mbox{\hyperlink{kern__acct_8c_a78766da5b59632a4e48758808ae7acb7}{acct\_cred}} = NULL;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00324}00324         \mbox{\hyperlink{kern__acct_8c_aaa42a1e0e9906db0cbff805153271601}{acct\_flags}} = 0;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00325}00325         \textcolor{keywordflow}{if} (logging)}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00326}00326                 \mbox{\hyperlink{subr__prf_8c_af8bf48b681a0471cae1be861c2102d5f}{log}}(LOG\_NOTICE, \textcolor{stringliteral}{"{}Accounting disabled\(\backslash\)n"{}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00327}00327         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00328}00328 \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00329}00329 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00330}00330 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00331}00331 \textcolor{comment}{ * Write out process accounting information, on process exit.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00332}00332 \textcolor{comment}{ * Data to be written out is specified in Leffler, et al.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00333}00333 \textcolor{comment}{ * and are enumerated below.  (They're also noted in the system}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00334}00334 \textcolor{comment}{ * "{}acct.h"{} header file.)}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00335}00335 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00336}00336 \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00337}\mbox{\hyperlink{kern__acct_8c_ad7f3fd3ab2b00055dbb52e6ad2b5355c}{00337}} \mbox{\hyperlink{kern__acct_8c_ad7f3fd3ab2b00055dbb52e6ad2b5355c}{acct\_process}}(\textcolor{keyword}{struct} thread *td)}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00338}00338 \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00339}00339         \textcolor{keyword}{struct }acctv3 acct;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00340}00340         \textcolor{keyword}{struct }timeval ut, \mbox{\hyperlink{kern__boottrace_8c_ab0419db3c2ed9e9d1cadb7b425a097f9}{st}}, tmp;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00341}00341         \textcolor{keyword}{struct }proc *p;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00342}00342         \textcolor{keyword}{struct }rusage ru;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00343}00343         \textcolor{keywordtype}{int} t, ret;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00344}00344 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00345}00345         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00346}00346 \textcolor{comment}{         * Lockless check of accounting condition before doing the hard}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00347}00347 \textcolor{comment}{         * work.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00348}00348 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00349}00349         \textcolor{keywordflow}{if} (\mbox{\hyperlink{kern__acct_8c_ab32781e3a6710f338374ab272d41007d}{acct\_vp}} == NULL || \mbox{\hyperlink{kern__acct_8c_a52cf926f2da78c9f90d9f6f9b0c696df}{acct\_suspended}})}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00350}00350                 \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00351}00351 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00352}00352         memset(\&acct, 0, \textcolor{keyword}{sizeof}(acct));}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00353}00353 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00354}00354         sx\_slock(\&\mbox{\hyperlink{kern__acct_8c_a7a2674027c3979280b81539dae08bcda}{acct\_sx}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00355}00355 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00356}00356         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00357}00357 \textcolor{comment}{         * If accounting isn't enabled, don't bother.  Have to check again}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00358}00358 \textcolor{comment}{         * once we own the lock in case we raced with disabling of accounting}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00359}00359 \textcolor{comment}{         * by another thread.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00360}00360 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00361}00361         \textcolor{keywordflow}{if} (\mbox{\hyperlink{kern__acct_8c_ab32781e3a6710f338374ab272d41007d}{acct\_vp}} == NULL || \mbox{\hyperlink{kern__acct_8c_a52cf926f2da78c9f90d9f6f9b0c696df}{acct\_suspended}}) \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00362}00362                 sx\_sunlock(\&\mbox{\hyperlink{kern__acct_8c_a7a2674027c3979280b81539dae08bcda}{acct\_sx}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00363}00363                 \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00364}00364         \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00365}00365 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00366}00366         p = td-\/>td\_proc;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00367}00367         td-\/>td\_pflags2 |= TDP2\_ACCT;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00368}00368 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00369}00369         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00370}00370 \textcolor{comment}{         * Get process accounting information.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00371}00371 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00372}00372 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00373}00373         sx\_slock(\&\mbox{\hyperlink{kern__proc_8c_a52f6a4fe6856dd07ed75d23dab000b83}{proctree\_lock}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00374}00374         PROC\_LOCK(p);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00375}00375 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00376}00376         \textcolor{comment}{/* (1) The terminal from which the process was started */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00377}00377         \textcolor{keywordflow}{if} ((p-\/>p\_flag \& P\_CONTROLT) \&\& p-\/>p\_pgrp-\/>pg\_session-\/>s\_ttyp)}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00378}00378                 acct.ac\_tty = \mbox{\hyperlink{tty_8c_a392c3d059c0db3e25c23ef6b17ac110e}{tty\_udev}}(p-\/>p\_pgrp-\/>pg\_session-\/>s\_ttyp);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00379}00379         \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00380}00380                 acct.ac\_tty = NODEV;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00381}00381         sx\_sunlock(\&\mbox{\hyperlink{kern__proc_8c_a52f6a4fe6856dd07ed75d23dab000b83}{proctree\_lock}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00382}00382 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00383}00383         \textcolor{comment}{/* (2) The name of the command that ran */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00384}00384         bcopy(p-\/>p\_comm, acct.ac\_comm, \textcolor{keyword}{sizeof} acct.ac\_comm);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00385}00385 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00386}00386         \textcolor{comment}{/* (3) The amount of user and system time that was used */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00387}00387         \mbox{\hyperlink{kern__resource_8c_ae974871e2062829630e3726ea75937db}{rufetchcalc}}(p, \&ru, \&ut, \&\mbox{\hyperlink{kern__boottrace_8c_ab0419db3c2ed9e9d1cadb7b425a097f9}{st}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00388}00388         acct.ac\_utime = \mbox{\hyperlink{kern__acct_8c_ac694f3ef6ac875844bef350c10452fc4}{encode\_timeval}}(ut);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00389}00389         acct.ac\_stime = \mbox{\hyperlink{kern__acct_8c_ac694f3ef6ac875844bef350c10452fc4}{encode\_timeval}}(\mbox{\hyperlink{kern__boottrace_8c_ab0419db3c2ed9e9d1cadb7b425a097f9}{st}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00390}00390 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00391}00391         \textcolor{comment}{/* (4) The elapsed time the command ran (and its starting time) */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00392}00392         \mbox{\hyperlink{kern__tc_8c_a75c4aa2c1e0951b53133f5224e724673}{getboottime}}(\&tmp);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00393}00393         \mbox{\hyperlink{kern__time_8c_a43dffb0bea5ad902aae3674d1384ecda}{timevaladd}}(\&tmp, \&p-\/>p\_stats-\/>p\_start);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00394}00394         acct.ac\_btime = tmp.tv\_sec;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00395}00395         \mbox{\hyperlink{kern__tc_8c_ad2ee9cc3eb46aca2703cc3c5945c6c2d}{microuptime}}(\&tmp);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00396}00396         \mbox{\hyperlink{kern__time_8c_a800e9ded7c0a2b4666b49448f4ebe180}{timevalsub}}(\&tmp, \&p-\/>p\_stats-\/>p\_start);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00397}00397         acct.ac\_etime = \mbox{\hyperlink{kern__acct_8c_ac694f3ef6ac875844bef350c10452fc4}{encode\_timeval}}(tmp);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00398}00398 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00399}00399         \textcolor{comment}{/* (5) The average amount of memory used */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00400}00400         tmp = ut;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00401}00401         \mbox{\hyperlink{kern__time_8c_a43dffb0bea5ad902aae3674d1384ecda}{timevaladd}}(\&tmp, \&\mbox{\hyperlink{kern__boottrace_8c_ab0419db3c2ed9e9d1cadb7b425a097f9}{st}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00402}00402         \textcolor{comment}{/* Convert tmp (i.e. u + s) into hz units to match ru\_i*. */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00403}00403         t = tmp.tv\_sec * \mbox{\hyperlink{subr__param_8c_a873124c5659edc141c67aab7999e314a}{hz}} + tmp.tv\_usec / \mbox{\hyperlink{subr__param_8c_ad4e0bbc0cc0ffb91120206fb4de60261}{tick}};}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00404}00404         \textcolor{keywordflow}{if} (t)}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00405}00405                 acct.ac\_mem = \mbox{\hyperlink{kern__acct_8c_a5c44828e609222ad6ce69bb786d6e7f7}{encode\_long}}((ru.ru\_ixrss + ru.ru\_idrss +}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00406}00406                     + ru.ru\_isrss) / t);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00407}00407         \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00408}00408                 acct.ac\_mem = 0;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00409}00409 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00410}00410         \textcolor{comment}{/* (6) The number of disk I/O operations done */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00411}00411         acct.ac\_io = \mbox{\hyperlink{kern__acct_8c_a5c44828e609222ad6ce69bb786d6e7f7}{encode\_long}}(ru.ru\_inblock + ru.ru\_oublock);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00412}00412 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00413}00413         \textcolor{comment}{/* (7) The UID and GID of the process */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00414}00414         acct.ac\_uid = p-\/>p\_ucred-\/>cr\_ruid;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00415}00415         acct.ac\_gid = p-\/>p\_ucred-\/>cr\_rgid;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00416}00416 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00417}00417         \textcolor{comment}{/* (8) The boolean flags that tell how the process terminated, etc. */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00418}00418         acct.ac\_flagx = p-\/>p\_acflag;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00419}00419 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00420}00420         PROC\_UNLOCK(p);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00421}00421 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00422}00422         \textcolor{comment}{/* Setup ancillary structure fields. */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00423}00423         acct.ac\_flagx |= ANVER;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00424}00424         acct.ac\_zero = 0;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00425}00425         acct.ac\_version = 3;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00426}00426         acct.ac\_len = acct.ac\_len2 = \textcolor{keyword}{sizeof}(acct);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00427}00427 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00428}00428         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00429}00429 \textcolor{comment}{         * Write the accounting information to the file.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00430}00430 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00431}00431         ret = \mbox{\hyperlink{vfs__vnops_8c_a49b0ffdec9c53ba6314c11d8f7212edb}{vn\_rdwr}}(UIO\_WRITE, \mbox{\hyperlink{kern__acct_8c_ab32781e3a6710f338374ab272d41007d}{acct\_vp}}, (caddr\_t)\&acct, \textcolor{keyword}{sizeof} (acct),}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00432}00432             (off\_t)0, UIO\_SYSSPACE, IO\_APPEND|IO\_UNIT, \mbox{\hyperlink{kern__acct_8c_a78766da5b59632a4e48758808ae7acb7}{acct\_cred}}, NOCRED,}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00433}00433             NULL, td);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00434}00434         sx\_sunlock(\&\mbox{\hyperlink{kern__acct_8c_a7a2674027c3979280b81539dae08bcda}{acct\_sx}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00435}00435         td-\/>td\_pflags2 \&= \string~TDP2\_ACCT;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00436}00436         \textcolor{keywordflow}{return} (ret);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00437}00437 \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00438}00438 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00439}00439 \textcolor{comment}{/* FLOAT\_CONVERSION\_START (Regression testing; don't remove this line.) */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00440}00440 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00441}00441 \textcolor{comment}{/* Convert timevals and longs into IEEE-\/754 bit patterns. */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00442}00442 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00443}00443 \textcolor{comment}{/* Mantissa mask (MSB is implied, so subtract 1). */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00444}\mbox{\hyperlink{kern__acct_8c_a24fddc6a5744e169a20438ff219fa3da}{00444}} \textcolor{preprocessor}{\#define MANT\_MASK ((1 << (FLT\_MANT\_DIG -\/ 1)) -\/ 1)}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00445}00445 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00446}00446 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00447}00447 \textcolor{comment}{ * We calculate integer values to a precision of approximately}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00448}00448 \textcolor{comment}{ * 28 bits.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00449}00449 \textcolor{comment}{ * This is high-\/enough precision to fill the 24 float bits}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00450}00450 \textcolor{comment}{ * and low-\/enough to avoid overflowing the 32 int bits.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00451}00451 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00452}\mbox{\hyperlink{kern__acct_8c_a77464f73834a9633b45d1194d4a22950}{00452}} \textcolor{preprocessor}{\#define CALC\_BITS 28}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00453}00453 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00454}00454 \textcolor{comment}{/* log\_2(1000000). */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00455}\mbox{\hyperlink{kern__acct_8c_af6572d10a7d99643c1351800e565921a}{00455}} \textcolor{preprocessor}{\#define LOG2\_1M 20}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00456}00456 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00457}00457 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00458}00458 \textcolor{comment}{ * Convert the elements of a timeval into a 32-\/bit word holding}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00459}00459 \textcolor{comment}{ * the bits of a IEEE-\/754 float.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00460}00460 \textcolor{comment}{ * The float value represents the timeval's value in microsecond units.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00461}00461 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00462}00462 \textcolor{keyword}{static} uint32\_t}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00463}\mbox{\hyperlink{kern__acct_8c_ac694f3ef6ac875844bef350c10452fc4}{00463}} \mbox{\hyperlink{kern__acct_8c_ac694f3ef6ac875844bef350c10452fc4}{encode\_timeval}}(\textcolor{keyword}{struct} timeval tv)}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00464}00464 \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00465}00465         \textcolor{keywordtype}{int} log2\_s;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00466}00466         \textcolor{keywordtype}{int} val, exp;   \textcolor{comment}{/* Unnormalized value and exponent */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00467}00467         \textcolor{keywordtype}{int} norm\_exp;   \textcolor{comment}{/* Normalized exponent */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00468}00468         \textcolor{keywordtype}{int} shift;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00469}00469 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00470}00470         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00471}00471 \textcolor{comment}{         * First calculate value and exponent to about CALC\_BITS precision.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00472}00472 \textcolor{comment}{         * Note that the following conditionals have been ordered so that}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00473}00473 \textcolor{comment}{         * the most common cases appear first.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00474}00474 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00475}00475         \textcolor{keywordflow}{if} (tv.tv\_sec == 0) \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00476}00476                 \textcolor{keywordflow}{if} (tv.tv\_usec == 0)}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00477}00477                         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00478}00478                 exp = 0;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00479}00479                 val = tv.tv\_usec;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00480}00480         \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00481}00481                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00482}00482 \textcolor{comment}{                 * Calculate the value to a precision of approximately}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00483}00483 \textcolor{comment}{                 * CALC\_BITS.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00484}00484 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00485}00485                 log2\_s = fls(tv.tv\_sec) -\/ 1;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00486}00486                 \textcolor{keywordflow}{if} (log2\_s + \mbox{\hyperlink{kern__acct_8c_af6572d10a7d99643c1351800e565921a}{LOG2\_1M}} < \mbox{\hyperlink{kern__acct_8c_a77464f73834a9633b45d1194d4a22950}{CALC\_BITS}}) \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00487}00487                         exp = 0;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00488}00488                         val = 1000000 * tv.tv\_sec + tv.tv\_usec;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00489}00489                 \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00490}00490                         exp = log2\_s + \mbox{\hyperlink{kern__acct_8c_af6572d10a7d99643c1351800e565921a}{LOG2\_1M}} -\/ \mbox{\hyperlink{kern__acct_8c_a77464f73834a9633b45d1194d4a22950}{CALC\_BITS}};}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00491}00491                         val = (\textcolor{keywordtype}{unsigned} int)(((uint64\_t)1000000 * tv.tv\_sec +}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00492}00492                             tv.tv\_usec) >> exp);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00493}00493                 \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00494}00494         \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00495}00495         \textcolor{comment}{/* Now normalize and pack the value into an IEEE-\/754 float. */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00496}00496         norm\_exp = fls(val) -\/ 1;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00497}00497         shift = \mbox{\hyperlink{kern__acct_8c_a0c22779a3c997aa03c16f2d8a7e3128e}{FLT\_MANT\_DIG}} -\/ norm\_exp -\/ 1;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00498}00498 \textcolor{preprocessor}{\#ifdef ACCT\_DEBUG}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00499}00499         \mbox{\hyperlink{subr__prf_8c_a55f3d956bb2ba20b5059e9e25484a47f}{printf}}(\textcolor{stringliteral}{"{}val=\%d exp=\%d shift=\%d log2(val)=\%d\(\backslash\)n"{}},}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00500}00500             val, exp, shift, norm\_exp);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00501}00501         \mbox{\hyperlink{subr__prf_8c_a55f3d956bb2ba20b5059e9e25484a47f}{printf}}(\textcolor{stringliteral}{"{}exp=\%x mant=\%x\(\backslash\)n"{}}, \mbox{\hyperlink{kern__acct_8c_afcbc8f81f213d358c2aba21a4bcf943b}{FLT\_MAX\_EXP}} -\/ 1 + exp + norm\_exp,}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00502}00502             ((shift > 0 ? (val << shift) : (val >> -\/shift)) \& \mbox{\hyperlink{kern__acct_8c_a24fddc6a5744e169a20438ff219fa3da}{MANT\_MASK}}));}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00503}00503 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00504}00504         \textcolor{keywordflow}{return} (((\mbox{\hyperlink{kern__acct_8c_afcbc8f81f213d358c2aba21a4bcf943b}{FLT\_MAX\_EXP}} -\/ 1 + exp + norm\_exp) << (\mbox{\hyperlink{kern__acct_8c_a0c22779a3c997aa03c16f2d8a7e3128e}{FLT\_MANT\_DIG}} -\/ 1)) |}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00505}00505             ((shift > 0 ? val << shift : val >> -\/shift) \& \mbox{\hyperlink{kern__acct_8c_a24fddc6a5744e169a20438ff219fa3da}{MANT\_MASK}}));}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00506}00506 \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00507}00507 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00508}00508 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00509}00509 \textcolor{comment}{ * Convert a non-\/negative long value into the bit pattern of}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00510}00510 \textcolor{comment}{ * an IEEE-\/754 float value.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00511}00511 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00512}00512 \textcolor{keyword}{static} uint32\_t}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00513}\mbox{\hyperlink{kern__acct_8c_a5c44828e609222ad6ce69bb786d6e7f7}{00513}} \mbox{\hyperlink{kern__acct_8c_a5c44828e609222ad6ce69bb786d6e7f7}{encode\_long}}(\textcolor{keywordtype}{long} val)}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00514}00514 \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00515}00515         \textcolor{keywordtype}{int} norm\_exp;   \textcolor{comment}{/* Normalized exponent */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00516}00516         \textcolor{keywordtype}{int} shift;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00517}00517 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00518}00518         \textcolor{keywordflow}{if} (val == 0)}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00519}00519                 \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00520}00520         \textcolor{keywordflow}{if} (val < 0) \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00521}00521                 \mbox{\hyperlink{subr__prf_8c_af8bf48b681a0471cae1be861c2102d5f}{log}}(LOG\_NOTICE,}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00522}00522                     \textcolor{stringliteral}{"{}encode\_long: negative value \%ld in accounting record\(\backslash\)n"{}},}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00523}00523                     val);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00524}00524                 val = LONG\_MAX;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00525}00525         \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00526}00526         norm\_exp = fls(val) -\/ 1;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00527}00527         shift = \mbox{\hyperlink{kern__acct_8c_a0c22779a3c997aa03c16f2d8a7e3128e}{FLT\_MANT\_DIG}} -\/ norm\_exp -\/ 1;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00528}00528 \textcolor{preprocessor}{\#ifdef ACCT\_DEBUG}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00529}00529         \mbox{\hyperlink{subr__prf_8c_a55f3d956bb2ba20b5059e9e25484a47f}{printf}}(\textcolor{stringliteral}{"{}val=\%d shift=\%d log2(val)=\%d\(\backslash\)n"{}},}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00530}00530             val, shift, norm\_exp);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00531}00531         \mbox{\hyperlink{subr__prf_8c_a55f3d956bb2ba20b5059e9e25484a47f}{printf}}(\textcolor{stringliteral}{"{}exp=\%x mant=\%x\(\backslash\)n"{}}, \mbox{\hyperlink{kern__acct_8c_afcbc8f81f213d358c2aba21a4bcf943b}{FLT\_MAX\_EXP}} -\/ 1 + exp + norm\_exp,}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00532}00532             ((shift > 0 ? (val << shift) : (val >> -\/shift)) \& \mbox{\hyperlink{kern__acct_8c_a24fddc6a5744e169a20438ff219fa3da}{MANT\_MASK}}));}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00533}00533 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00534}00534         \textcolor{keywordflow}{return} (((\mbox{\hyperlink{kern__acct_8c_afcbc8f81f213d358c2aba21a4bcf943b}{FLT\_MAX\_EXP}} -\/ 1 + norm\_exp) << (\mbox{\hyperlink{kern__acct_8c_a0c22779a3c997aa03c16f2d8a7e3128e}{FLT\_MANT\_DIG}} -\/ 1)) |}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00535}00535             ((shift > 0 ? val << shift : val >> -\/shift) \& \mbox{\hyperlink{kern__acct_8c_a24fddc6a5744e169a20438ff219fa3da}{MANT\_MASK}}));}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00536}00536 \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00537}00537 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00538}00538 \textcolor{comment}{/* FLOAT\_CONVERSION\_END (Regression testing; don't remove this line.) */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00539}00539 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00540}00540 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00541}00541 \textcolor{comment}{ * Periodically check the filesystem to see if accounting}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00542}00542 \textcolor{comment}{ * should be turned on or off.  Beware the case where the vnode}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00543}00543 \textcolor{comment}{ * has been vgone()'d out from underneath us, e.g. when the file}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00544}00544 \textcolor{comment}{ * system containing the accounting file has been forcibly unmounted.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00545}00545 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00546}00546 \textcolor{comment}{/* ARGSUSED */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00547}00547 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00548}\mbox{\hyperlink{kern__acct_8c_ad9d98804aab958e5769d17081b0ebba3}{00548}} \mbox{\hyperlink{kern__acct_8c_ad9d98804aab958e5769d17081b0ebba3}{acctwatch}}(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00549}00549 \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00550}00550         \textcolor{keyword}{struct }statfs *sp;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00551}00551 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00552}00552         sx\_assert(\&\mbox{\hyperlink{kern__acct_8c_a7a2674027c3979280b81539dae08bcda}{acct\_sx}}, SX\_XLOCKED);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00553}00553 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00554}00554         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00555}00555 \textcolor{comment}{         * If accounting was disabled before our kthread was scheduled,}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00556}00556 \textcolor{comment}{         * then acct\_vp might be NULL.  If so, just ask our kthread to}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00557}00557 \textcolor{comment}{         * exit and return.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00558}00558 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00559}00559         \textcolor{keywordflow}{if} (\mbox{\hyperlink{kern__acct_8c_ab32781e3a6710f338374ab272d41007d}{acct\_vp}} == NULL) \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00560}00560                 \mbox{\hyperlink{kern__acct_8c_aa6c65591d46293fb582f0d36bae6c1c3}{acct\_state}} |= \mbox{\hyperlink{kern__acct_8c_a87c8361feb0d11c220fed3cf5fb89689}{ACCT\_EXITREQ}};}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00561}00561                 \textcolor{keywordflow}{return};}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00562}00562         \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00563}00563 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00564}00564         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00565}00565 \textcolor{comment}{         * If our vnode is no longer valid, tear it down and signal the}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00566}00566 \textcolor{comment}{         * accounting thread to die.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00567}00567 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00568}00568         \textcolor{keywordflow}{if} (\mbox{\hyperlink{kern__acct_8c_ab32781e3a6710f338374ab272d41007d}{acct\_vp}}-\/>v\_type == VBAD) \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00569}00569                 (void) \mbox{\hyperlink{kern__acct_8c_ab30a297d140c915a6a94d4744e65f904}{acct\_disable}}(NULL, 1);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00570}00570                 \mbox{\hyperlink{kern__acct_8c_aa6c65591d46293fb582f0d36bae6c1c3}{acct\_state}} |= \mbox{\hyperlink{kern__acct_8c_a87c8361feb0d11c220fed3cf5fb89689}{ACCT\_EXITREQ}};}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00571}00571                 \textcolor{keywordflow}{return};}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00572}00572         \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00573}00573 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00574}00574         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00575}00575 \textcolor{comment}{         * Stopping here is better than continuing, maybe it will be VBAD}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00576}00576 \textcolor{comment}{         * next time around.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00577}00577 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00578}00578         sp = \mbox{\hyperlink{kern__malloc_8c_a13e924a88f20870d2d55e3f7fb660352}{malloc}}(\textcolor{keyword}{sizeof}(\textcolor{keyword}{struct} statfs), M\_STATFS, M\_WAITOK);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00579}00579         \textcolor{keywordflow}{if} (VFS\_STATFS(\mbox{\hyperlink{kern__acct_8c_ab32781e3a6710f338374ab272d41007d}{acct\_vp}}-\/>v\_mount, sp) < 0) \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00580}00580                 \mbox{\hyperlink{kern__malloc_8c_af6592f7dfb186f55f99e52892336fff0}{free}}(sp, M\_STATFS);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00581}00581                 \textcolor{keywordflow}{return};}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00582}00582         \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00583}00583         \textcolor{keywordflow}{if} (\mbox{\hyperlink{kern__acct_8c_a52cf926f2da78c9f90d9f6f9b0c696df}{acct\_suspended}}) \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00584}00584                 \textcolor{keywordflow}{if} (sp-\/>f\_bavail > (int64\_t)(\mbox{\hyperlink{kern__acct_8c_a42c24cbda14c72436f148240f1b29a37}{acctresume}} * sp-\/>f\_blocks /}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00585}00585                     100)) \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00586}00586                         \mbox{\hyperlink{kern__acct_8c_a52cf926f2da78c9f90d9f6f9b0c696df}{acct\_suspended}} = 0;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00587}00587                         \mbox{\hyperlink{subr__prf_8c_af8bf48b681a0471cae1be861c2102d5f}{log}}(LOG\_NOTICE, \textcolor{stringliteral}{"{}Accounting resumed\(\backslash\)n"{}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00588}00588                 \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00589}00589         \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00590}00590                 \textcolor{keywordflow}{if} (sp-\/>f\_bavail <= (int64\_t)(\mbox{\hyperlink{kern__acct_8c_a217aee7b52e712c66bc96c103e9ba6cc}{acctsuspend}} * sp-\/>f\_blocks /}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00591}00591                     100)) \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00592}00592                         \mbox{\hyperlink{kern__acct_8c_a52cf926f2da78c9f90d9f6f9b0c696df}{acct\_suspended}} = 1;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00593}00593                         \mbox{\hyperlink{subr__prf_8c_af8bf48b681a0471cae1be861c2102d5f}{log}}(LOG\_NOTICE, \textcolor{stringliteral}{"{}Accounting suspended\(\backslash\)n"{}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00594}00594                 \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00595}00595         \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00596}00596         \mbox{\hyperlink{kern__malloc_8c_af6592f7dfb186f55f99e52892336fff0}{free}}(sp, M\_STATFS);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00597}00597 \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00598}00598 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00599}00599 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00600}00600 \textcolor{comment}{ * The main loop for the dedicated kernel thread that periodically calls}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00601}00601 \textcolor{comment}{ * acctwatch().}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00602}00602 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00603}00603 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00604}\mbox{\hyperlink{kern__acct_8c_a42aff4687b851c3d97708eac9436ec61}{00604}} \mbox{\hyperlink{kern__acct_8c_a42aff4687b851c3d97708eac9436ec61}{acct\_thread}}(\textcolor{keywordtype}{void} *\mbox{\hyperlink{uipc__sockbuf_8c_a7c1d654b7b6114d7a0abc8d351dd1bcd}{dummy}})}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00605}00605 \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00606}00606         u\_char pri;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00607}00607 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00608}00608         \textcolor{comment}{/* This is a low-\/priority kernel thread. */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00609}00609         pri = PRI\_MAX\_KERN;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00610}00610         thread\_lock(curthread);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00611}00611         \mbox{\hyperlink{sched__4bsd_8c_a798c873d2e4f42d44d2e8c1f88d9ace2}{sched\_prio}}(curthread, pri);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00612}00612         thread\_unlock(curthread);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00613}00613 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00614}00614         \textcolor{comment}{/* If another accounting kthread is already running, just die. */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00615}00615         sx\_xlock(\&\mbox{\hyperlink{kern__acct_8c_a7a2674027c3979280b81539dae08bcda}{acct\_sx}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00616}00616         \textcolor{keywordflow}{if} (\mbox{\hyperlink{kern__acct_8c_aa6c65591d46293fb582f0d36bae6c1c3}{acct\_state}} \& \mbox{\hyperlink{kern__acct_8c_a70083df0622c8d0a870a5015440b37ba}{ACCT\_RUNNING}}) \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00617}00617                 sx\_xunlock(\&\mbox{\hyperlink{kern__acct_8c_a7a2674027c3979280b81539dae08bcda}{acct\_sx}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00618}00618                 \mbox{\hyperlink{kern__kthread_8c_a2d02305bf2c694ac6c561cc5a6cba52a}{kproc\_exit}}(0);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00619}00619         \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00620}00620         \mbox{\hyperlink{kern__acct_8c_aa6c65591d46293fb582f0d36bae6c1c3}{acct\_state}} |= \mbox{\hyperlink{kern__acct_8c_a70083df0622c8d0a870a5015440b37ba}{ACCT\_RUNNING}};}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00621}00621 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00622}00622         \textcolor{comment}{/* Loop until we are asked to exit. */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00623}00623         \textcolor{keywordflow}{while} (!(\mbox{\hyperlink{kern__acct_8c_aa6c65591d46293fb582f0d36bae6c1c3}{acct\_state}} \& \mbox{\hyperlink{kern__acct_8c_a87c8361feb0d11c220fed3cf5fb89689}{ACCT\_EXITREQ}})) \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00624}00624                 \textcolor{comment}{/* Perform our periodic checks. */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00625}00625                 \mbox{\hyperlink{kern__acct_8c_ad9d98804aab958e5769d17081b0ebba3}{acctwatch}}();}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00626}00626 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00627}00627                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00628}00628 \textcolor{comment}{                 * We check this flag again before sleeping since the}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00629}00629 \textcolor{comment}{                 * acctwatch() might have shut down accounting and asked us}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00630}00630 \textcolor{comment}{                 * to exit.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00631}00631 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00632}00632                 \textcolor{keywordflow}{if} (!(\mbox{\hyperlink{kern__acct_8c_aa6c65591d46293fb582f0d36bae6c1c3}{acct\_state}} \& \mbox{\hyperlink{kern__acct_8c_a87c8361feb0d11c220fed3cf5fb89689}{ACCT\_EXITREQ}})) \{}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00633}00633                         sx\_sleep(\&\mbox{\hyperlink{kern__acct_8c_aa6c65591d46293fb582f0d36bae6c1c3}{acct\_state}}, \&\mbox{\hyperlink{kern__acct_8c_a7a2674027c3979280b81539dae08bcda}{acct\_sx}}, 0, \textcolor{stringliteral}{"{}-\/"{}},}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00634}00634                             \mbox{\hyperlink{kern__acct_8c_ae0b279357d0c1071ef72233001fd1504}{acctchkfreq}} * \mbox{\hyperlink{subr__param_8c_a873124c5659edc141c67aab7999e314a}{hz}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00635}00635                 \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00636}00636         \}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00637}00637 }
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00638}00638         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00639}00639 \textcolor{comment}{         * Acknowledge the exit request and shutdown.  We clear both the}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00640}00640 \textcolor{comment}{         * exit request and running flags.}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00641}00641 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00642}00642         \mbox{\hyperlink{kern__acct_8c_aa6c65591d46293fb582f0d36bae6c1c3}{acct\_state}} = 0;}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00643}00643         sx\_xunlock(\&\mbox{\hyperlink{kern__acct_8c_a7a2674027c3979280b81539dae08bcda}{acct\_sx}});}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00644}00644         \mbox{\hyperlink{kern__kthread_8c_a2d02305bf2c694ac6c561cc5a6cba52a}{kproc\_exit}}(0);}
\DoxyCodeLine{\Hypertarget{kern__acct_8c_source_l00645}00645 \}}

\end{DoxyCode}
