2011-04-27 00:54:10

by Jidong Xiao

[permalink] [raw]
Subject: How to export information larger than PROC_BLOCK_SIZE via /proc file system?

Hi,

I am tracing some data inside the kernel, and I plan to export the
tracing data through /proc file system. I created a file under /proc
file system, and I use cat to display the tracing data. However, every
time there is only 3072 bytes data displayed, which is the size
defined by PROC_BLOCK_SIZE. And I wonder that how to export
information more than that limit? Judging from the function
fs/proc/generic.c/proc_file_read(), if the size returned by my
read_proc function is large than a PAGE_SIZE, then I will get a
KERN_ERR message which says "proc_file_read: Apparent buffer
overflow!". Any help would be appreciated!

Regards
Jidong


2011-04-27 03:00:34

by Cong Wang

[permalink] [raw]
Subject: Re: How to export information larger than PROC_BLOCK_SIZE via /proc file system?

On Wed, Apr 27, 2011 at 8:54 AM, Jidong Xiao <[email protected]> wrote:
> Hi,
>
> I am tracing some data inside the kernel, and I plan to export the
> tracing data through /proc file system. I created a file under /proc
> file system, and I use cat to display the tracing data. However, every
> time there is only 3072 bytes data displayed, which is the size
> defined by PROC_BLOCK_SIZE. And I wonder that how to export
> information more than that limit? Judging from the function
> fs/proc/generic.c/proc_file_read(), if the size returned by my
> read_proc function is large than a PAGE_SIZE, then I will get a
> KERN_ERR message which says "proc_file_read: Apparent buffer
> overflow!". Any help would be appreciated!
>

Why not switch to use debugfs?

2011-04-27 03:18:52

by Alexey Dobriyan

[permalink] [raw]
Subject: Re: How to export information larger than PROC_BLOCK_SIZE via /proc file system?

On Wed, Apr 27, 2011 at 11:00:32AM +0800, Am??rico Wang wrote:
> On Wed, Apr 27, 2011 at 8:54 AM, Jidong Xiao <[email protected]> wrote:
> > Hi,
> >
> > I am tracing some data inside the kernel, and I plan to export the
> > tracing data through /proc file system. I created a file under /proc
> > file system, and I use cat to display the tracing data. However, every
> > time there is only 3072 bytes data displayed, which is the size
> > defined by PROC_BLOCK_SIZE. And I wonder that how to export
> > information more than that limit? Judging from the function
> > fs/proc/generic.c/proc_file_read(), if the size returned by my
> > read_proc function is large than a PAGE_SIZE, then I will get a
> > KERN_ERR message which says "proc_file_read: Apparent buffer
> > overflow!". Any help would be appreciated!
> >
>
> Why not switch to use debugfs?

Or use seq_file/proc_create.

2011-04-27 04:16:38

by Jidong Xiao

[permalink] [raw]
Subject: Re: How to export information larger than PROC_BLOCK_SIZE via /proc file system?

On Tue, Apr 26, 2011 at 11:18 PM, Alexey Dobriyan <[email protected]> wrote:
> On Wed, Apr 27, 2011 at 11:00:32AM +0800, Am??rico Wang wrote:
>> On Wed, Apr 27, 2011 at 8:54 AM, Jidong Xiao <[email protected]> wrote:
>> > Hi,
>> >
>> > I am tracing some data inside the kernel, and I plan to export the
>> > tracing data through /proc file system. I created a file under /proc
>> > file system, and I use cat to display the tracing data. However, every
>> > time there is only 3072 bytes data displayed, which is the size
>> > defined by PROC_BLOCK_SIZE. And I wonder that how to export
>> > information more than that limit? Judging from the function
>> > fs/proc/generic.c/proc_file_read(), if the size returned by my
>> > read_proc function is large than a PAGE_SIZE, then I will get a
>> > KERN_ERR message which says "proc_file_read: Apparent buffer
>> > overflow!". Any help would be appreciated!
>> >
>>
>> Why not switch to use debugfs?
>
> Or use seq_file/proc_create.
>

Oh, thank you two very much. After reading the related document, I
feel seq_file is exactly what I am looking for.

Regards
Jidong