|
12 | 12 | #include <linux/slab.h>
|
13 | 13 | #include <linux/cred.h>
|
14 | 14 | #include <linux/mm.h>
|
| 15 | +#include <linux/printk.h> |
15 | 16 |
|
16 | 17 | #include <asm/uaccess.h>
|
17 | 18 | #include <asm/page.h>
|
@@ -773,6 +774,47 @@ void seq_pad(struct seq_file *m, char c)
|
773 | 774 | }
|
774 | 775 | EXPORT_SYMBOL(seq_pad);
|
775 | 776 |
|
| 777 | +/* A complete analogue of print_hex_dump() */ |
| 778 | +void 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 | +} |
| 816 | +EXPORT_SYMBOL(seq_hex_dump); |
| 817 | + |
776 | 818 | struct list_head *seq_list_start(struct list_head *head, loff_t pos)
|
777 | 819 | {
|
778 | 820 | struct list_head *lh;
|
|
0 commit comments