Re: Increasing the size of seq_file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

On 11/17/06, Bithika Khargharia <bithika@xxxxxxxxx> wrote:
Hi,

I am trying to increase the size of the seqfile buffer from PAGE_SIZE to 2*PAGE_SIZE to read the file zoneinfo in /proc. I created the seq_file structure in zoneinfo_open (code snippet attached) and kmalloc'ked the buffer as

activePages->buf = kmalloc(activePages->size = 2*PAGE_SIZE, GFP_KERNEL);

Then file->private_data field points to the created seq_file. Finally seq_open is called with the file.

However, when I print out the size of the seq_file "zoneinfo" it always return 4096 Bytes which is the PAGE_SIZE in my system. It is not set to 2*PAGE_SIZE as desired.

What am I doing wrong?

Let's look at the seq_open() implementation at
http://lxr.linux.no/source/fs/seq_file.c#L29
Notice the memset(p, 0, (*p)) at line 39.

This has two consequences. The first one is memory leak.
Your previously allocated buf of 2*PAGE_SIZE size is lost.

The second one is that the buf gets set to PAGE_SIZE size
in the the seq_read() ( http://lxr.linux.no/source/fs/seq_file.c#L65).
The line 89 is executed because the buf member
of the struct seq_file is zero.

My conclusion therefore is that the size of the buf in the seq_file
API implementation is always PAGE_SIZE.

What exacly are you trying to accomplish?
Maybe there's another way.


BlackHole


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux