Results 1 to 2 of 2
Hi, I can`t understand the create_proc_entry.read_proc function parameters.In function read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data),the off_set parameter is how to get it`s value? also ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 06-02-2006 #1Just Joined!
- Join Date
- May 2006
- Posts
- 7
in proc function ,the offset is how to determine it value?
Hi, I can`t understand the create_proc_entry.read_proc function parameters.In function read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data),the off_set parameter is how to get it`s value? also in the function I can`t understand the sentences "if(offset >0) return 0;" .why if offset>0,the funtion is over?
int aaa_proc_read(char *buffer, char **start, off_t offset, int length, int *eof, void *data)
{
off_t pos=0;
off_t begin=0;
int len=0;
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
goto done;
}
*eof = 1;
done:
*start = buffer + (offset - begin);
len -= (offset - begin);
if (len > length)
len=length;
if(len<0)
len=0;
return len;
}
this function is too hard to understand ,do you know it`s procession and can you give me some explaination??
thank you very much .
- 06-04-2006 #2
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).
Best regards


Reply With Quote
