[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Proc read function and long output
Hi,
I has the following problem with the proc filesystem/read function.
I know i can only write some amount of data at once to a proc
"listener", but i have to write more data as there is space available.
The example at bottom is non working, just for demonstration. At the
marked line i check if there is space left and snprintf in it... if not,
i dont write more ;) . But how can i write more data? My text is cut off
somewhere in the middle.... not good :(
This is my code right now:
int proc_read_tis(char *page, char **start,
off_t off, int count,
int *eof, void *data) {
int len;
char* out = page;
int idx;
int tcode;
out += snprintf(blablabla);
for (idx=0;idx<MAX_COUNT*2;idx++) {
out += snprintf(blabla);
for (tcode=0;tcode<16;tcode++) {
if (TCODE_NAMES[tcode]!=NULL) {
/*******************************
-> PROBLEM HERE, no more space available
********************************/
if (count - (out-page)>0) {
out += snprintf(out,count - (out-page),"blablabla....");
}
}
}
}
}
len = out - page - off;
if (len < count) {
*eof = 1;
if (len <= 0)
return 0;
} else {
len = count;
}
*start = page + off;
return len;
}
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/