[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20141110140324.GD2160@pathway.suse.cz>
Date: Mon, 10 Nov 2014 15:03:25 +0100
From: Petr Mladek <pmladek@...e.cz>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Jiri Kosina <jkosina@...e.cz>,
"H. Peter Anvin" <hpa@...or.com>,
Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [RFC][PATCH 04/12 v3] tracing: Convert seq_buf_path() to be like
seq_path()
On Fri 2014-11-07 13:34:13, Steven Rostedt wrote:
>
> I made a few touch ups on this patch.
>
> -- Steve
>
> From 309e8ce4cc1605d3038b16b8e43219a2867f47b1 Mon Sep 17 00:00:00 2001
> From: "Steven Rostedt (Red Hat)" <rostedt@...dmis.org>
> Date: Wed, 29 Oct 2014 13:48:37 -0400
> Subject: [PATCH] tracing: Convert seq_buf_path() to be like seq_path()
>
> Rewrite seq_buf_path() like it is done in seq_path() and allow
> it to accept any escape character instead of just "\n".
>
> Making seq_buf_path() like seq_path() will help prevent problems
> when converting seq_file to use the seq_buf logic.
>
> Link: http://lkml.kernel.org/r/20141104160222.048795666@goodmis.org
>
> Tested-by: Jiri Kosina <jkosina@...e.cz>
> Acked-by: Jiri Kosina <jkosina@...e.cz>
> Signed-off-by: Steven Rostedt <rostedt@...dmis.org>
> ---
> include/linux/seq_buf.h | 2 +-
> kernel/trace/seq_buf.c | 26 +++++++++++++++-----------
> kernel/trace/trace_seq.c | 4 ++--
> 3 files changed, 18 insertions(+), 14 deletions(-)
>
> diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h
> index 64bf5a43411e..aec09b126082 100644
> --- a/include/linux/seq_buf.h
> +++ b/include/linux/seq_buf.h
> @@ -70,7 +70,7 @@ extern int seq_buf_putc(struct seq_buf *s, unsigned char c);
> extern int seq_buf_putmem(struct seq_buf *s, const void *mem, unsigned int len);
> extern int seq_buf_putmem_hex(struct seq_buf *s, const void *mem,
> unsigned int len);
> -extern int seq_buf_path(struct seq_buf *s, const struct path *path);
> +extern int seq_buf_path(struct seq_buf *s, const struct path *path, const char *esc);
>
> extern int seq_buf_bitmask(struct seq_buf *s, const unsigned long *maskp,
> int nmaskbits);
> diff --git a/kernel/trace/seq_buf.c b/kernel/trace/seq_buf.c
> index 88738b200bf3..ac6eb864c946 100644
> --- a/kernel/trace/seq_buf.c
> +++ b/kernel/trace/seq_buf.c
> @@ -272,28 +272,32 @@ int seq_buf_putmem_hex(struct seq_buf *s, const void *mem,
> * seq_buf_path - copy a path into the sequence buffer
> * @s: seq_buf descriptor
> * @path: path to write into the sequence buffer.
> + * @esc: set of characters to escape in the output
> *
> * Write a path name into the sequence buffer.
> *
> * Returns zero on success, -1 on overflow
This should be
* Returns the number of written bytes on success, -1 on overflow
This is just a minor issue. I believe the you would fix it. Feel free to add:
Reviewed-by: Petr Mladek <pmladek@...e.cz>
Best Regards,
Petr
> -int seq_buf_path(struct seq_buf *s, const struct path *path)
> +int seq_buf_path(struct seq_buf *s, const struct path *path, const char *esc)
> {
> - unsigned int len = seq_buf_buffer_left(s);
> - unsigned char *p;
> + char *buf = s->buffer + s->len;
> + size_t size = seq_buf_buffer_left(s);
> + int res = -1;
>
> WARN_ON(s->size == 0);
>
> - p = d_path(path, s->buffer + s->len, len);
> - if (!IS_ERR(p)) {
> - p = mangle_path(s->buffer + s->len, p, "\n");
> - if (p) {
> - s->len = p - s->buffer;
> - return 0;
> + if (size) {
> + char *p = d_path(path, buf, size);
> + if (!IS_ERR(p)) {
> + char *end = mangle_path(buf, p, esc);
> + if (end)
> + res = end - buf;
> }
> }
> - seq_buf_set_overflow(s);
> - return -1;
> + if (res > 0)
> + s->len += res;
> +
> + return res;
> }
>
> /**
> diff --git a/kernel/trace/trace_seq.c b/kernel/trace/trace_seq.c
> index 3ad8738aea19..64550ed28e76 100644
> --- a/kernel/trace/trace_seq.c
> +++ b/kernel/trace/trace_seq.c
> @@ -382,7 +382,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
> return 0;
> }
>
> - ret = seq_buf_path(&s->seq, path);
> + ret = seq_buf_path(&s->seq, path, "\n");
>
> if (unlikely(seq_buf_has_overflowed(&s->seq))) {
> s->seq.len = save_len;
> @@ -390,7 +390,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
> return 0;
> }
>
> - return ret;
> + return 1;
> }
> EXPORT_SYMBOL_GPL(trace_seq_path);
>
> --
> 2.1.1
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists