handle Linux 2.5.xx ABI

This commit is contained in:
albert 2002-10-06 17:13:29 +00:00
parent eeb598fd98
commit 26206213a8

View File

@ -87,30 +87,39 @@ static void getstat(jiff *cuse, jiff *cice, jiff *csys, jiff long *cide, jiff lo
unsigned *pin, unsigned *pout, unsigned *s_in, unsigned *sout, unsigned *pin, unsigned *pout, unsigned *s_in, unsigned *sout,
unsigned *itot, unsigned *i1, unsigned *ct) { unsigned *itot, unsigned *i1, unsigned *ct) {
static int Stat; static int Stat;
int need_extra_file = 0;
char* b;
buff[BUFFSIZE-1] = 0; /* ensure null termination in buffer */
if ((Stat=open("/proc/stat", O_RDONLY, 0)) != -1) { if(Stat){
char* b; lseek(Stat, 0L, SEEK_SET);
buff[BUFFSIZE-1] = 0; /* ensure null termination in buffer */ }else{
read(Stat,buff,BUFFSIZE-1); Stat = open("/proc/stat", O_RDONLY, 0);
close(Stat); if(Stat == -1) crash("/proc/stat");
*itot = 0;
*i1 = 1; /* ensure assert below will fail if the sscanf bombs */
*ciow = 0; /* not separated out until the 2.5.41 kernel */
b = strstr(buff, "cpu ");
if(b) sscanf(b, "cpu %lu %lu %lu %lu %lu", cuse, cice, csys, cide, ciow);
b = strstr(buff, "page ");
if(b) sscanf(b, "page %u %u", pin, pout);
b = strstr(buff, "swap ");
if(b) sscanf(b, "swap %u %u", s_in, sout);
b = strstr(buff, "intr ");
if(b) sscanf(b, "intr %u %u", itot, i1);
b = strstr(buff, "ctxt ");
if(b) sscanf(b, "ctxt %u", ct);
} }
else { read(Stat,buff,BUFFSIZE-1);
crash("/proc/stat"); *itot = 0;
} *i1 = 1; /* ensure assert below will fail if the sscanf bombs */
if(1){ *ciow = 0; /* not separated out until the 2.5.41 kernel */
b = strstr(buff, "cpu ");
if(b) sscanf(b, "cpu %lu %lu %lu %lu %lu", cuse, cice, csys, cide, ciow);
b = strstr(buff, "page ");
if(b) sscanf(b, "page %u %u", pin, pout);
else need_extra_file = 1;
b = strstr(buff, "swap ");
if(b) sscanf(b, "swap %u %u", s_in, sout);
else need_extra_file = 1;
b = strstr(buff, "intr ");
if(b) sscanf(b, "intr %u %u", itot, i1);
b = strstr(buff, "ctxt ");
if(b) sscanf(b, "ctxt %u", ct);
if(need_extra_file){ /* 2.5.40-bk4 and above */
vminfo(); vminfo();
*pin = vm_pgpgout; *pin = vm_pgpgout;
*pout = vm_pgpgin; *pout = vm_pgpgin;