2007/5/31, Greg Donald <gdonald@xxxxxxxxx>:
> When I use create_proc_info_entry thusly:
>
> create_proc_info_entry( "foo/bar", 0, 0, show_foo_bar );
>
> The signature of the show_foo_bar function seems required to be:
>
> static int show_foo_bar( char *buffer, char **start, off_t offset, int length )
>
> If I change that whatsoever I get this warning: function declaration
> isn't a prototype, when it is called. Ok, but what if I just want my
> proc info entry to display something really static, like say, the
> integer 17?
>
> static int show_foo_bar( char *buffer, char **start, off_t offset, int length )
> {
> int size;
> size = 17;
> return size;
> }
>
> And then I do:
>
> > cat /proc/foo/bar
> ?UU0
>
> But that's not the integer 17.
>
IIRC (didn't look this up recently and it's been a while), the return
value should be the number of characters actually written, so the
caller (the reader of your proc entry) knows whether an error occurs,
or how long the buffer is.
In order to write 17, you should use something like
int len;
int size = 17;
len = snprintf(buffer, sizeof(int), "%d", size)
return len;