Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/kern_acct.c
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | |||||
#include <sys/sysent.h> | #include <sys/sysent.h> | ||||
#include <sys/syslog.h> | #include <sys/syslog.h> | ||||
#include <sys/sysproto.h> | #include <sys/sysproto.h> | ||||
#include <sys/tty.h> | #include <sys/tty.h> | ||||
#include <sys/vnode.h> | #include <sys/vnode.h> | ||||
#include <security/mac/mac_framework.h> | #include <security/mac/mac_framework.h> | ||||
_Static_assert(sizeof(struct acctv3) - offsetof(struct acctv3, ac_trailer) == | |||||
sizeof(struct acctv2) - offsetof(struct acctv2, ac_trailer), "trailer"); | |||||
_Static_assert(sizeof(struct acctv3) - offsetof(struct acctv3, ac_len2) == | |||||
sizeof(struct acctv2) - offsetof(struct acctv2, ac_len2), "len2"); | |||||
/* | /* | ||||
* The routines implemented in this file are described in: | * The routines implemented in this file are described in: | ||||
* Leffler, et al.: The Design and Implementation of the 4.3BSD | * Leffler, et al.: The Design and Implementation of the 4.3BSD | ||||
* UNIX Operating System (Addison Welley, 1989) | * UNIX Operating System (Addison Welley, 1989) | ||||
* on pages 62-63. | * on pages 62-63. | ||||
* On May 2007 the historic 3 bits base 8 exponent, 13 bit fraction | * On May 2007 the historic 3 bits base 8 exponent, 13 bit fraction | ||||
* compt_t representation described in the above reference was replaced | * compt_t representation described in the above reference was replaced | ||||
* with that of IEEE-754 floats. | * with that of IEEE-754 floats. | ||||
▲ Show 20 Lines • Show All 227 Lines • ▼ Show 20 Lines | |||||
* Write out process accounting information, on process exit. | * Write out process accounting information, on process exit. | ||||
* Data to be written out is specified in Leffler, et al. | * Data to be written out is specified in Leffler, et al. | ||||
* and are enumerated below. (They're also noted in the system | * and are enumerated below. (They're also noted in the system | ||||
* "acct.h" header file.) | * "acct.h" header file.) | ||||
*/ | */ | ||||
int | int | ||||
acct_process(struct thread *td) | acct_process(struct thread *td) | ||||
{ | { | ||||
struct acctv2 acct; | struct acctv3 acct; | ||||
struct timeval ut, st, tmp; | struct timeval ut, st, tmp; | ||||
struct plimit *oldlim; | struct plimit *oldlim; | ||||
struct proc *p; | struct proc *p; | ||||
struct rusage ru; | struct rusage ru; | ||||
int t, ret; | int t, ret; | ||||
/* | /* | ||||
* Lockless check of accounting condition before doing the hard | * Lockless check of accounting condition before doing the hard | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | acct_process(struct thread *td) | ||||
acct.ac_gid = p->p_ucred->cr_rgid; | acct.ac_gid = p->p_ucred->cr_rgid; | ||||
/* (8) The boolean flags that tell how the process terminated, etc. */ | /* (8) The boolean flags that tell how the process terminated, etc. */ | ||||
acct.ac_flagx = p->p_acflag; | acct.ac_flagx = p->p_acflag; | ||||
/* Setup ancillary structure fields. */ | /* Setup ancillary structure fields. */ | ||||
acct.ac_flagx |= ANVER; | acct.ac_flagx |= ANVER; | ||||
acct.ac_zero = 0; | acct.ac_zero = 0; | ||||
acct.ac_version = 2; | acct.ac_version = 3; | ||||
acct.ac_len = acct.ac_len2 = sizeof(acct); | acct.ac_len = acct.ac_len2 = sizeof(acct); | ||||
/* | /* | ||||
* Eliminate rlimits (file size limit in particular). | * Eliminate rlimits (file size limit in particular). | ||||
*/ | */ | ||||
oldlim = p->p_limit; | oldlim = p->p_limit; | ||||
p->p_limit = lim_hold(acct_limit); | p->p_limit = lim_hold(acct_limit); | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
▲ Show 20 Lines • Show All 220 Lines • Show Last 20 Lines |