/* kern_acct.c 6.2 84/07/08 */
* SHOULD REPLACE THIS WITH A DRIVER THAT CAN BE READ TO SIMPLIFY.
* Perform process accounting functions.
register struct inode
*ip
;
} *uap
= (struct a
*)u
.u_ap
;
register struct nameidata
*ndp
= &u
.u_nd
;
ndp
->ni_nameiop
= LOOKUP
| FOLLOW
;
ndp
->ni_segflg
= UIO_USERSPACE
;
ndp
->ni_dirp
= uap
->fname
;
if((ip
->i_mode
& IFMT
) != IFREG
) {
if (acctp
&& (acctp
->i_number
!= ip
->i_number
||
acctp
->i_dev
!= ip
->i_dev
))
int acctsuspend
= 2; /* stop accounting when < 2% free space left */
int acctresume
= 4; /* resume when free space risen to > 4% */
* On exit, write a record on the accounting file.
register struct inode
*ip
;
register struct acct
*ap
= &acctbuf
;
if (freespace(fs
, fs
->fs_minfree
+ acctresume
) > 0) {
printf("Accounting resumed\n");
if ((ip
= acctp
) == NULL
)
if (freespace(fs
, fs
->fs_minfree
+ acctsuspend
) <= 0) {
printf("Accounting suspended\n");
for (i
= 0; i
< sizeof (ap
->ac_comm
); i
++)
ap
->ac_comm
[i
] = u
.u_comm
[i
];
ap
->ac_utime
= compress((long)u
.u_ru
.ru_utime
.tv_sec
);
ap
->ac_stime
= compress((long)u
.u_ru
.ru_stime
.tv_sec
);
ap
->ac_etime
= compress((long)time
.tv_sec
- u
.u_start
);
ap
->ac_btime
= u
.u_start
;
if (i
= u
.u_ru
.ru_utime
.tv_sec
+ u
.u_ru
.ru_stime
.tv_sec
)
(u
.u_ru
.ru_ixrss
+ u
.u_ru
.ru_idrss
+ u
.u_ru
.ru_isrss
) / i
;
ap
->ac_io
= compress((long)(u
.u_ru
.ru_inblock
+ u
.u_ru
.ru_oublock
));
ap
->ac_flag
= u
.u_acflag
;
rdwri(UIO_WRITE
, ip
, (caddr_t
)ap
, sizeof (acctbuf
), siz
,
* Produce a pseudo-floating point representation
* with 3 bits base-8 exponent, 13 bits fraction.
register exp
= 0, round
= 0;