lkml.org 
[lkml]   [2007]   [Aug]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH] Sort module list - use ppos instead of m->private
    Sort modules list - use ppos instead of m->private

    When reading the data by small chunks (i.e. byte by byte), the index (ppos) is
    incremented by seq_read() directly and no "next" callback is called when going
    to the next module.

    Therefore, use ppos instead of m->private to deal with the fact that this index
    is incremented directly to pass to the next module in seq_read() after the
    buffer has been emptied.

    Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
    ---
    fs/seq_file.c | 17 +++++++++--------
    include/linux/seq_file.h | 4 ++--
    kernel/module.c | 6 ++----
    3 files changed, 13 insertions(+), 14 deletions(-)

    Index: linux-2.6-lttng/kernel/module.c
    ===================================================================
    --- linux-2.6-lttng.orig/kernel/module.c 2007-08-24 11:34:36.000000000 -0400
    +++ linux-2.6-lttng/kernel/module.c 2007-08-24 11:35:40.000000000 -0400
    @@ -2418,14 +2418,12 @@ unsigned long module_kallsyms_lookup_nam
    static void *m_start(struct seq_file *m, loff_t *pos)
    {
    mutex_lock(&module_mutex);
    - if (!*pos)
    - m->private = NULL;
    - return seq_sorted_list_start(&modules, m->private);
    + return seq_sorted_list_start(&modules, (void*)(long)pos);
    }

    static void *m_next(struct seq_file *m, void *p, loff_t *pos)
    {
    - return seq_sorted_list_next(p, &modules, &m->private);
    + return seq_sorted_list_next(p, &modules, (void**)pos);
    }

    static void m_stop(struct seq_file *m, void *p)
    Index: linux-2.6-lttng/include/linux/seq_file.h
    ===================================================================
    --- linux-2.6-lttng.orig/include/linux/seq_file.h 2007-08-24 11:34:01.000000000 -0400
    +++ linux-2.6-lttng/include/linux/seq_file.h 2007-08-24 11:34:59.000000000 -0400
    @@ -73,9 +73,9 @@ extern struct list_head *seq_list_next(v
    * seq_sorted_list_start_head().
    */
    extern struct list_head *seq_sorted_list_start(struct list_head *head,
    - void *pos);
    + void **ppos);
    extern struct list_head *seq_sorted_list_start_head(struct list_head *head,
    - void *pos);
    + void **ppos);
    /*
    * next must be called with an existing p node
    */
    Index: linux-2.6-lttng/fs/seq_file.c
    ===================================================================
    --- linux-2.6-lttng.orig/fs/seq_file.c 2007-08-24 11:34:01.000000000 -0400
    +++ linux-2.6-lttng/fs/seq_file.c 2007-08-24 11:34:59.000000000 -0400
    @@ -501,27 +501,28 @@ struct list_head *seq_list_next(void *v,

    EXPORT_SYMBOL(seq_list_next);

    -struct list_head *seq_sorted_list_start(struct list_head *head, void *pos)
    +struct list_head *seq_sorted_list_start(struct list_head *head, void **ppos)
    {
    struct list_head *lh;

    list_for_each(lh, head)
    - if ((void*)lh >= pos)
    - return lh;
    + if ((void*)lh >= *ppos)
    + return *ppos = lh;
    return NULL;
    }

    EXPORT_SYMBOL(seq_sorted_list_start);

    -struct list_head *seq_sorted_list_start_head(struct list_head *head, void *pos)
    +struct list_head *seq_sorted_list_start_head(struct list_head *head,
    + void **ppos)
    {
    struct list_head *lh;

    - if (!pos)
    - return head;
    + if (!ppos)
    + return *ppos = head;
    list_for_each(lh, head)
    - if ((void*)lh >= pos)
    - return lh->prev;
    + if ((void*)lh >= *ppos)
    + return *ppos = lh->prev;
    return NULL;
    }

    --
    Mathieu Desnoyers
    Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
    OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/
    \
     
     \ /
      Last update: 2007-08-24 17:43    [W:0.030 / U:66.332 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site