proc file system

Christian Widmer (cwidmer@iiic.ethz.ch)
Mon, 27 Aug 2001 16:01:29 +0200


i need to report more then 4KB of data to the /proc and found a short
note in "linux device drivers 2" how to do. so i wrote some functions
that look like that one below.

static int my_read_proc(char *page, char **start, off_t offset,
int count, int *eof, void* data)

{
static int myIndex = 0, done = 0;
int en = 0, max = count - 256;

for(;myIndex < MAX_INDEX; myIndex++){
len += sprintf(page+len, "hier some info of dynamic length\n");
if(len > max){ // still data left
(*start) = page;
return len;
}
}
myIndex = 0; // all data out
*eof = 1
done = 1;
return len;
}

not all of my output gets printed. looks like the data from the last
call to my function disapiers. thats wy i thought to delay the eof
one call by:

static int my_read_proc(char *page, char **start, off_t offset,
int count, int *eof, void* data)

{
static int myIndex = 0, done = 0;
int len = 0, count = offset - 256;
if(done){ // now we say that we are done
*eof = 1;
done = 0;
return 0;
}
for(;myIndex < MAX_INDEX; myIndex++){
len += sprintf(page+len, "hier some info of dynamic length\n");
if(len > max){ //more data left
(*start) = page;
return len;
}
}
(*start) = page; //were done (but we dont say)
myIndex = 0;
done = 1;
return len;
}

it does not cut any more some of my data. but endlessly dumping my data to
the terminal. after delaying the reset of 'done' as long as offest dont get
back to 0 it seems to work.

if(done & offset){ // wait until linux seems to have the
// same view of the proc-files state
*eof = 1;
return 0;
}else done = 0;

can anybody tell me wats going on here - i'm confused what do i not know?

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/