Find the answer to your Linux question:
Results 1 to 4 of 4
Hello, I use the seq_file interface to interact with my module. My entries are located in /proc/ip_vs_sip/ (/proc/ip_vs_sip/context_table, /proc/ip_vs_sip/provider_table, ...). So far so good. But when I read from user ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2011
    Posts
    5

    seq_file output buffer size


    Hello,

    I use the seq_file interface to interact with my module. My entries are located in /proc/ip_vs_sip/ (/proc/ip_vs_sip/context_table, /proc/ip_vs_sip/provider_table, ...). So far so good. But when I read from user space, and the output reaches 4095 bytes, seq_printf returns -1.

    What's the solution to get around that limit ?

    Looking at the ip_conntrack module source code, the only main difference I see with my module are :
    - the entries are in /proc/net
    - the use of proc_net_fops_create before create_proc_entry

    Any idea ?

    Thanks in advance

    Christian

  2. #2
    Just Joined!
    Join Date
    May 2011
    Posts
    5
    I've just tried to create my entries in /proc/net/ (instead of /proc/ip_vs_sip/), and I get to the same point ...

  3. #3
    Just Joined!
    Join Date
    May 2011
    Posts
    5
    Anyone ?

    It's really related to the seq_file structure, cause when I printk instead of using seq_printf, all the buffer (~15k) is logged to /var/log/messages.

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    May 2011
    Posts
    5
    Quote Originally Posted by greg42 View Post
    Anyone ?

    It's really related to the seq_file structure, cause when I printk instead of using seq_printf, all the buffer (~15k) is logged to /var/log/messages.
    OK, I got all sorted out. I had started writing my module from this seq_start sample code, without really understanding it by then :

    static void *my_seq_start(struct seq_file *s, loff_t *pos)
    {
    if ( *pos == 0 )
    {
    return myPointer;
    }
    else
    {
    *pos = 0;
    return NULL;
    }
    }

    Given the data to be output is greater than the page size, the first iteration stopped when it reached 4k, and when the my_seq_start function got called again, *pos being greater than zero, it stopped.

    My function should have been something like :

    static void *my_seq_start(struct seq_file *s, loff_t *pos)
    {
    if ( *pos == 0 )
    return ptr;
    else if (*pos < dataToBeOutputLength )
    return ptr+dataOutputSoFarLength);
    else {
    *pos = 0;
    return NULL;
    }
    }

    And it now works like a charm !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •