/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#include <sys/sysmacros.h>
#include <sys/resource.h>
/*
* Each zone has its own accounting settings (on or off) and associated
* file. The global zone is not special in this aspect; it will only
* generate records for processes that ran in the global zone. We could
* allow the global zone to record all activity on the system, but there
* would be no way of knowing the zone in which the processes executed.
* sysacct() is thus virtualized to only act on the caller's zone.
*/
struct acct_globals {
};
/*
* We need a list of all accounting settings for all zones, so we can
* accurately determine if a file is in use for accounting (possibly by
* another zone).
*/
1,
};
};
#ifdef _SYSCALL32_IMPL
};
#endif
&modlsys,
#ifdef _SYSCALL32_IMPL
#endif
};
/*ARGSUSED*/
static void *
{
return (ag);
}
/* ARGSUSED */
static void
{
/*
* This needs to be done as a shutdown callback, otherwise this
* held vnode may cause filesystems to be busy, and the zone
* shutdown operation to fail.
*/
NULL);
}
}
/*ARGSUSED*/
static void
{
}
int
_init(void)
{
int error;
/*
* Using an initializer here wastes a bit of memory for zones that
* don't use accounting, but vastly simplifies the locking.
*/
(void) zone_key_delete(acct_zone_key);
}
return (error);
}
int
{
}
/*
* acct() is a "weak stub" routine called from exit().
* Once this module has been loaded, we refuse to allow
* it to unload - otherwise accounting would quietly
* cease. See 1211661. It's possible to make this module
* unloadable but it's substantially safer not to bother.
*/
int
_fini(void)
{
return (EBUSY);
}
/*
* See if vp is in use by the accounting system on any zone. This does a deep
* comparison of vnodes such that a file and a lofs "shadow" node of it will
* appear to be the same.
*
* If 'compare_vfs' is true, the function will do a comparison of vfs_t's
* instead (ie, is the vfs_t on which the vnode resides in use by the
* accounting system in any zone).
*
* Returns 1 if found (in use), 0 otherwise.
*/
static int
{
continue;
}
if (compare_vfs) {
} else {
}
if (found)
return (1);
}
return (0);
}
/*
* Returns 1 if the vfs that vnode resides on is in use for the accounting
* subsystem, 0 otherwise.
*/
int
{
int found;
return (0);
return (found);
}
/*
* Perform process accounting functions.
*/
int
{
int error = 0;
if (secpolicy_acct(CRED()) != 0)
/*
* Close the file and stop accounting.
*/
if (vp) {
NULL);
}
}
/*
* Either (a) open a new file and begin accounting -or- (b)
* switch accounting from an old to a new file.
*
* (Open the file without holding aclock in case it
* sleeps (holding the lock prevents process exit).)
*/
/* SVID compliance */
}
} else {
} else {
/*
* close old acctvp, and point acct()
* at new file by swapping vp and acctvp
*/
} else {
/*
* no existing file, start accounting ..
*/
}
}
}
if (vp) {
}
}
/*
* Produce a pseudo-floating point representation
* with 3 bits base-8 exponent, 13 bits fraction.
*/
static comp_t
{
while (t >= 8192) {
exp++;
round = t & 04;
t >>= 3;
}
if (round) {
t++;
if (t >= 8192) {
t >>= 3;
exp++;
}
}
#ifdef _LP64
if (exp > 7) {
/* prevent wraparound */
t = 8191;
exp = 7;
}
#endif
return ((exp << 13) + t);
}
/*
* On exit, write a record on the accounting file.
*/
void
{
struct proc *p;
int error;
/*
* If sysacct module is loaded when zone is in down state then
* the following function can return NULL.
*/
return;
return;
}
/*
* This only gets called from exit after all lwp's have exited so no
* cred locking is needed.
*/
p = curproc;
/*
* Save the size. If the write fails, reset the size to avoid
* corrupted acct files.
*
* Large Files: We deliberately prevent accounting files from
* exceeding the 2GB limit as none of the accounting commands are
* currently large file aware.
*/
}
}