aboutsummaryrefslogtreecommitdiffstats
path: root/fs/seq_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/seq_file.c')
-rw-r--r--fs/seq_file.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/fs/seq_file.c b/fs/seq_file.c
index ce9e39fd5daf..263b125dbcf4 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -12,6 +12,7 @@
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/cred.h> 13#include <linux/cred.h>
14#include <linux/mm.h> 14#include <linux/mm.h>
15#include <linux/printk.h>
15 16
16#include <asm/uaccess.h> 17#include <asm/uaccess.h>
17#include <asm/page.h> 18#include <asm/page.h>
@@ -773,6 +774,47 @@ void seq_pad(struct seq_file *m, char c)
773} 774}
774EXPORT_SYMBOL(seq_pad); 775EXPORT_SYMBOL(seq_pad);
775 776
777/* A complete analogue of print_hex_dump() */
778void seq_hex_dump(struct seq_file *m, const char *prefix_str, int prefix_type,
779 int rowsize, int groupsize, const void *buf, size_t len,
780 bool ascii)
781{
782 const u8 *ptr = buf;
783 int i, linelen, remaining = len;
784 int ret;
785
786 if (rowsize != 16 && rowsize != 32)
787 rowsize = 16;
788
789 for (i = 0; i < len && !seq_has_overflowed(m); i += rowsize) {
790 linelen = min(remaining, rowsize);
791 remaining -= rowsize;
792
793 switch (prefix_type) {
794 case DUMP_PREFIX_ADDRESS:
795 seq_printf(m, "%s%p: ", prefix_str, ptr + i);
796 break;
797 case DUMP_PREFIX_OFFSET:
798 seq_printf(m, "%s%.8x: ", prefix_str, i);
799 break;
800 default:
801 seq_printf(m, "%s", prefix_str);
802 break;
803 }
804
805 ret = hex_dump_to_buffer(ptr + i, linelen, rowsize, groupsize,
806 m->buf + m->count, m->size - m->count,
807 ascii);
808 if (ret >= m->size - m->count) {
809 seq_set_overflow(m);
810 } else {
811 m->count += ret;
812 seq_putc(m, '\n');
813 }
814 }
815}
816EXPORT_SYMBOL(seq_hex_dump);
817
776struct list_head *seq_list_start(struct list_head *head, loff_t pos) 818struct list_head *seq_list_start(struct list_head *head, loff_t pos)
777{ 819{
778 struct list_head *lh; 820 struct list_head *lh;