diff options
author | Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> | 2013-11-14 17:31:56 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-11-14 19:32:20 -0500 |
commit | 839cc2a94cc3665bafe32203c2f095f4dd470a80 (patch) | |
tree | c48aa0e5bcd3f09ad5b7354396a50928c9211155 /fs | |
parent | 57f4257eae33e036125973858934730250d464e3 (diff) |
seq_file: introduce seq_setwidth() and seq_pad()
There are several users who want to know bytes written by seq_*() for
alignment purpose. Currently they are using %n format for knowing it
because seq_*() returns 0 on success.
This patch introduces seq_setwidth() and seq_pad() for allowing them to
align without using %n format.
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Joe Perches <joe@perches.com>
Cc: David Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/seq_file.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/fs/seq_file.c b/fs/seq_file.c index a290157265ef..1cd2388ca5bd 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c | |||
@@ -766,6 +766,21 @@ int seq_write(struct seq_file *seq, const void *data, size_t len) | |||
766 | } | 766 | } |
767 | EXPORT_SYMBOL(seq_write); | 767 | EXPORT_SYMBOL(seq_write); |
768 | 768 | ||
769 | /** | ||
770 | * seq_pad - write padding spaces to buffer | ||
771 | * @m: seq_file identifying the buffer to which data should be written | ||
772 | * @c: the byte to append after padding if non-zero | ||
773 | */ | ||
774 | void seq_pad(struct seq_file *m, char c) | ||
775 | { | ||
776 | int size = m->pad_until - m->count; | ||
777 | if (size > 0) | ||
778 | seq_printf(m, "%*s", size, ""); | ||
779 | if (c) | ||
780 | seq_putc(m, c); | ||
781 | } | ||
782 | EXPORT_SYMBOL(seq_pad); | ||
783 | |||
769 | struct list_head *seq_list_start(struct list_head *head, loff_t pos) | 784 | struct list_head *seq_list_start(struct list_head *head, loff_t pos) |
770 | { | 785 | { |
771 | struct list_head *lh; | 786 | struct list_head *lh; |