Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
- Join Date
- May 2006
in proc function ,the offset is how to determine it value?
int aaa_proc_read(char *buffer, char **start, off_t offset, int length, int *eof, void *data)
struct aaa_dev *p = aaa_dev_list;
len += sprintf(buffer,"aaa statics:\n");
for(;p;p = p->next)
len += sprintf(buffer+len, "===========================\nEthernet Interface : %s\n", p->dev->name);
len += sprintf(buffer+len, "aaa_enable : %d\n",p->aaa_enable);
len += sprintf(buffer+len, "total receive bytes: %ld\n total send bytes: %ld\n", p->stats.total_receive_bytes,p->stats.total_send_bytes);
len += sprintf(buffer+len, "total compressed bytes: %ld\n total decompressed bytes: %ld\n", p->stats.total_cm_bytes,p->stats.total_dc_bytes);
len += sprintf(buffer+len, "total compressed packet number:%ld\t total decompressed packet number:%ld\n",p->stats.total_cm_number,p->stats.total_dc_number);
pos = begin + len;
if ( pos < offset)
len = 0;
begin = pos;
if (pos > (offset + length)) //pass the permitted length
*eof = 1;
*start = buffer + (offset - begin);
len -= (offset - begin);
if (len > length)
this function is too hard to understand ,do you know it`s procession and can you give me some explaination??
thank you very much .
The good use of this is to write at most len characters in page from an specific offset
AFAIK the start parameter is not used anywhere in the kernel.
You can use this function without that checks for lengths and page sizes if you are sure that your output is not long. But if you are not sure and you don't make this checks, you can break pagers like less or more (but cat will work).