FreeBSD kernel kern code
kern_acct.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/acct.h>
#include <sys/fcntl.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/mount.h>
#include <sys/mutex.h>
#include <sys/namei.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
#include <sys/sched.h>
#include <sys/sx.h>
#include <sys/sysctl.h>
#include <sys/sysent.h>
#include <sys/syslog.h>
#include <sys/sysproto.h>
#include <sys/tty.h>
#include <sys/vnode.h>
#include <security/mac/mac_framework.h>
Include dependency graph for kern_acct.c:

Go to the source code of this file.

Macros

#define FLT_MANT_DIG   24 /* p */
 
#define FLT_MAX_EXP   128 /* emax */
 
#define ACCT_RUNNING   1 /* Accounting kthread is running. */
 
#define ACCT_EXITREQ   2 /* Accounting kthread should exit. */
 
#define MANT_MASK   ((1 << (FLT_MANT_DIG - 1)) - 1)
 
#define CALC_BITS   28
 
#define LOG2_1M   20
 

Functions

 __FBSDID ("$BSDSUniX$")
 
static uint32_t encode_timeval (struct timeval)
 
static uint32_t encode_long (long)
 
static void acctwatch (void)
 
static void acct_thread (void *)
 
static int acct_disable (struct thread *, int)
 
 SX_SYSINIT (acct,&acct_sx,"acct_sx")
 
 SYSCTL_INT (_kern, OID_AUTO, acct_suspend, CTLFLAG_RW,&acctsuspend, 0,"percentage of free disk space below which accounting stops")
 
 SYSCTL_INT (_kern, OID_AUTO, acct_resume, CTLFLAG_RW,&acctresume, 0,"percentage of free disk space above which accounting resumes")
 
static int sysctl_acct_chkfreq (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_kern, OID_AUTO, acct_chkfreq, CTLTYPE_INT|CTLFLAG_RW,&acctchkfreq, 0, sysctl_acct_chkfreq,"I","frequency for checking the free space")
 
 SYSCTL_INT (_kern, OID_AUTO, acct_configured, CTLFLAG_RD,&acct_configured, 0,"Accounting configured or not")
 
 SYSCTL_INT (_kern, OID_AUTO, acct_suspended, CTLFLAG_RD,&acct_suspended, 0,"Accounting suspended or not")
 
int sys_acct (struct thread *td, struct acct_args *uap)
 
int acct_process (struct thread *td)
 

Variables

static int acct_configured
 
static int acct_suspended
 
static struct vnode * acct_vp
 
static struct ucred * acct_cred
 
static struct plimit * acct_limit
 
static int acct_flags
 
static struct sx acct_sx
 
static int acct_state
 
static int acctsuspend = 2
 
static int acctresume = 4
 
static int acctchkfreq = 15
 

Macro Definition Documentation

#define ACCT_EXITREQ   2 /* Accounting kthread should exit. */

Definition at line 148 of file kern_acct.c.

Referenced by acct_thread(), acctwatch(), and sys_acct().

#define ACCT_RUNNING   1 /* Accounting kthread is running. */

Definition at line 147 of file kern_acct.c.

Referenced by acct_thread(), and sys_acct().

#define CALC_BITS   28

Definition at line 468 of file kern_acct.c.

Referenced by encode_timeval().

#define FLT_MANT_DIG   24 /* p */

Definition at line 113 of file kern_acct.c.

Referenced by encode_long(), and encode_timeval().

#define FLT_MAX_EXP   128 /* emax */

Definition at line 114 of file kern_acct.c.

Referenced by encode_long(), and encode_timeval().

#define LOG2_1M   20

Definition at line 471 of file kern_acct.c.

Referenced by encode_timeval().

#define MANT_MASK   ((1 << (FLT_MANT_DIG - 1)) - 1)

Definition at line 460 of file kern_acct.c.

Referenced by encode_long(), and encode_timeval().

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
static int acct_disable ( struct thread *  td,
int  logging 
)
static

Definition at line 324 of file kern_acct.c.

References acct_configured, acct_cred, acct_flags, acct_limit, acct_sx, acct_vp, crfree(), lim_free(), log(), and vn_close().

Referenced by acctwatch(), and sys_acct().

Here is the call graph for this function:

Here is the caller graph for this function:

int acct_process ( struct thread *  td)

Definition at line 348 of file kern_acct.c.

References acct_cred, acct_limit, acct_suspended, acct_sx, acct_vp, boottime, encode_long(), encode_timeval(), hz, lim_free(), lim_hold(), microuptime(), proctree_lock, rufetchcalc(), tick, timevaladd(), timevalsub(), tty_udev(), and vn_rdwr().

Referenced by exit1().

Here is the call graph for this function:

Here is the caller graph for this function:

static void acct_thread ( void *  dummy)
static

Definition at line 622 of file kern_acct.c.

References ACCT_EXITREQ, ACCT_RUNNING, acct_state, acct_sx, acctchkfreq, acctwatch(), hz, kproc_exit(), and sched_prio().

Referenced by sys_acct().

Here is the call graph for this function:

Here is the caller graph for this function:

static void acctwatch ( void  )
static

Definition at line 564 of file kern_acct.c.

References acct_disable(), ACCT_EXITREQ, acct_state, acct_suspended, acct_sx, acct_vp, acctresume, acctsuspend, and log().

Referenced by acct_thread().

Here is the call graph for this function:

Here is the caller graph for this function:

static uint32_t encode_long ( long  val)
static

Definition at line 529 of file kern_acct.c.

References FLT_MANT_DIG, FLT_MAX_EXP, log(), MANT_MASK, and printf().

Referenced by acct_process().

Here is the call graph for this function:

Here is the caller graph for this function:

static uint32_t encode_timeval ( struct timeval  tv)
static

Definition at line 479 of file kern_acct.c.

References CALC_BITS, FLT_MANT_DIG, FLT_MAX_EXP, LOG2_1M, MANT_MASK, and printf().

Referenced by acct_process().

Here is the call graph for this function:

Here is the caller graph for this function:

SX_SYSINIT ( acct  ,
acct_sx,
"acct_sx"   
)
int sys_acct ( struct thread *  td,
struct acct_args *  uap 
)
static int sysctl_acct_chkfreq ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 164 of file kern_acct.c.

References acctchkfreq, and value.

SYSCTL_INT ( _kern  ,
OID_AUTO  ,
acct_suspend  ,
CTLFLAG_RW  ,
acctsuspend,
,
"percentage of free disk space below which accounting stops"   
)
SYSCTL_INT ( _kern  ,
OID_AUTO  ,
acct_resume  ,
CTLFLAG_RW  ,
acctresume,
,
"percentage of free disk space above which accounting resumes"   
)
SYSCTL_INT ( _kern  ,
OID_AUTO  ,
acct_configured  ,
CTLFLAG_RD  ,
acct_configured,
,
"Accounting configured or not"   
)
SYSCTL_INT ( _kern  ,
OID_AUTO  ,
acct_suspended  ,
CTLFLAG_RD  ,
acct_suspended,
,
"Accounting suspended or not"   
)
SYSCTL_PROC ( _kern  ,
OID_AUTO  ,
acct_chkfreq  ,
CTLTYPE_INT|  CTLFLAG_RW,
acctchkfreq,
,
sysctl_acct_chkfreq  ,
"I"  ,
"frequency for checking the free space"   
)

Variable Documentation

int acct_configured
static

Definition at line 132 of file kern_acct.c.

Referenced by acct_disable(), and sys_acct().

struct ucred* acct_cred
static

Definition at line 135 of file kern_acct.c.

Referenced by acct_disable(), acct_process(), and sys_acct().

int acct_flags
static

Definition at line 137 of file kern_acct.c.

Referenced by acct_disable(), and sys_acct().

struct plimit* acct_limit
static

Definition at line 136 of file kern_acct.c.

Referenced by acct_disable(), acct_process(), and sys_acct().

int acct_state
static

Definition at line 145 of file kern_acct.c.

Referenced by acct_thread(), acctwatch(), and sys_acct().

int acct_suspended
static

Definition at line 133 of file kern_acct.c.

Referenced by acct_process(), acctwatch(), and sys_acct().

struct sx acct_sx
static

Definition at line 138 of file kern_acct.c.

Referenced by acct_disable(), acct_process(), acct_thread(), acctwatch(), and sys_acct().

struct vnode* acct_vp
static

Definition at line 134 of file kern_acct.c.

Referenced by acct_disable(), acct_process(), acctwatch(), and sys_acct().

int acctchkfreq = 15
static

Definition at line 161 of file kern_acct.c.

Referenced by acct_thread(), and sysctl_acct_chkfreq().

int acctresume = 4
static

Definition at line 157 of file kern_acct.c.

Referenced by acctwatch().

int acctsuspend = 2
static

Definition at line 153 of file kern_acct.c.

Referenced by acctwatch().