TODO: acct is not compatible / all other procedures are
This commit is contained in:
parent
b31f9ab934
commit
8d8dafd919
|
|
@ -1,9 +1,31 @@
|
|||
#include "sys/param.h"
|
||||
#include "sys/systm.h"
|
||||
#include "sys/acct.h"
|
||||
#include "sys/dir.h"
|
||||
#include "sys/user.h"
|
||||
#include "sys/inode.h"
|
||||
/******************************************************************************
|
||||
*******************************************************************************
|
||||
|
||||
W E G A - Quelle
|
||||
|
||||
KERN 3.2 Modul: acct.c
|
||||
|
||||
|
||||
Bearbeiter: O. Lehmann
|
||||
Datum: 17.05.08
|
||||
Version: 1.0
|
||||
|
||||
*******************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
char acctwstr[] = "@[$]acct.c Rev : 4.1 08/27/83 11:53:34";
|
||||
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/inode.h>
|
||||
#include <sys/dir.h>
|
||||
#include <sys/acct.h>
|
||||
#include <sys/s.out.h>
|
||||
#include <sys/mmu.h>
|
||||
#include <sys/user.h>
|
||||
#include <sys/proc.h>
|
||||
|
||||
/*
|
||||
* Perform process accounting functions.
|
||||
|
|
@ -17,9 +39,9 @@ sysacct()
|
|||
} *uap;
|
||||
|
||||
uap = (struct a *)u.u_ap;
|
||||
if (!suser())
|
||||
return;
|
||||
if (uap->fname==NULL) {
|
||||
if (suser()) {
|
||||
if((!u.u_segmented && ((long)uap->fname==(USEGW << 16))) ||
|
||||
( u.u_segmented && (uap->fname==NULL))) {
|
||||
if (acctp) {
|
||||
plock(acctp);
|
||||
iput(acctp);
|
||||
|
|
@ -31,11 +53,7 @@ sysacct()
|
|||
u.u_error = EBUSY;
|
||||
return;
|
||||
}
|
||||
#ifndef PNETDFS
|
||||
ip = namei(uchar, 0);
|
||||
#else
|
||||
ip = namei(uchar, 0, NULL);
|
||||
#endif
|
||||
if(ip == NULL)
|
||||
return;
|
||||
if((ip->i_mode & IFMT) != IFREG) {
|
||||
|
|
@ -46,43 +64,43 @@ sysacct()
|
|||
acctp = ip;
|
||||
prele(ip);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* On exit, write a record on the accounting file.
|
||||
*/
|
||||
acct(st)
|
||||
acct()
|
||||
{
|
||||
register struct inode *ip;
|
||||
register int i;
|
||||
off_t siz;
|
||||
|
||||
if ((ip=acctp)==NULL)
|
||||
return;
|
||||
if ((ip=acctp)) {
|
||||
plock(ip);
|
||||
bcopy(u.u_comm,acctbuf.ac_comm,sizeof(acctbuf.ac_comm));
|
||||
acctbuf.ac_btime = u.u_start;
|
||||
for (i=0; i<sizeof(acctbuf.ac_comm); i++)
|
||||
acctbuf.ac_comm[i] = u.u_comm[i];
|
||||
acctbuf.ac_utime = compress(u.u_utime);
|
||||
acctbuf.ac_stime = compress(u.u_stime);
|
||||
acctbuf.ac_etime = compress(lbolt - u.u_ticks);
|
||||
acctbuf.ac_mem = compress(u.u_mem);
|
||||
acctbuf.ac_io = compress(u.u_ioch);
|
||||
acctbuf.ac_rw = compress(u.u_ior+u.u_iow);
|
||||
acctbuf.ac_etime = compress(time - u.u_start);
|
||||
acctbuf.ac_btime = u.u_start;
|
||||
acctbuf.ac_uid = u.u_ruid;
|
||||
acctbuf.ac_gid = u.u_rgid;
|
||||
acctbuf.ac_tty = u.u_ttyp ? u.u_ttyd : NODEV;
|
||||
acctbuf.ac_stat = st;
|
||||
acctbuf.ac_mem = 0;
|
||||
acctbuf.ac_io = 0;
|
||||
acctbuf.ac_tty = u.u_ttyd;
|
||||
acctbuf.ac_flag = u.u_acflag;
|
||||
siz = ip->i_size;
|
||||
u.u_offset = siz;
|
||||
u.u_base = (caddr_t)&acctbuf;
|
||||
u.u_base.l = (caddr_t)&acctbuf;
|
||||
u.u_count = sizeof(acctbuf);
|
||||
u.u_segflg = 1;
|
||||
u.u_error = 0;
|
||||
u.u_limit = (daddr_t)5000;
|
||||
writei(ip);
|
||||
if(u.u_error)
|
||||
ip->i_size = siz;
|
||||
prele(ip);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Produce a pseudo-floating point representation
|
||||
|
|
@ -107,3 +125,24 @@ register time_t t;
|
|||
}
|
||||
return((exp<<13) + t);
|
||||
}
|
||||
|
||||
/*
|
||||
* lock user into core as much
|
||||
* as possible. swapping may still
|
||||
* occur if core grows.
|
||||
*/
|
||||
syslock()
|
||||
{
|
||||
register struct proc *p;
|
||||
register struct a {
|
||||
int flag;
|
||||
} *uap;
|
||||
|
||||
uap = (struct a *)u.u_ap;
|
||||
if(suser()) {
|
||||
p = u.u_procp;
|
||||
p->p_flag &= ~SULOCK;
|
||||
if(uap->flag)
|
||||
p->p_flag |= SULOCK;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue