Bluetooth: 6lowpan: Rename confusing 'pchan' variables
[cascardo/linux.git] / fs / seq_file.c
index 1d9c1cb..263b125 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/slab.h>
 #include <linux/cred.h>
 #include <linux/mm.h>
+#include <linux/printk.h>
 
 #include <asm/uaccess.h>
 #include <asm/page.h>
@@ -490,6 +491,20 @@ int seq_path(struct seq_file *m, const struct path *path, const char *esc)
 }
 EXPORT_SYMBOL(seq_path);
 
+/**
+ * seq_file_path - seq_file interface to print a pathname of a file
+ * @m: the seq_file handle
+ * @file: the struct file to print
+ * @esc: set of characters to escape in the output
+ *
+ * return the absolute path to the file.
+ */
+int seq_file_path(struct seq_file *m, struct file *file, const char *esc)
+{
+       return seq_path(m, &file->f_path, esc);
+}
+EXPORT_SYMBOL(seq_file_path);
+
 /*
  * Same as seq_path, but relative to supplied root.
  */
@@ -759,6 +774,47 @@ void seq_pad(struct seq_file *m, char c)
 }
 EXPORT_SYMBOL(seq_pad);
 
+/* A complete analogue of print_hex_dump() */
+void seq_hex_dump(struct seq_file *m, const char *prefix_str, int prefix_type,
+                 int rowsize, int groupsize, const void *buf, size_t len,
+                 bool ascii)
+{
+       const u8 *ptr = buf;
+       int i, linelen, remaining = len;
+       int ret;
+
+       if (rowsize != 16 && rowsize != 32)
+               rowsize = 16;
+
+       for (i = 0; i < len && !seq_has_overflowed(m); i += rowsize) {
+               linelen = min(remaining, rowsize);
+               remaining -= rowsize;
+
+               switch (prefix_type) {
+               case DUMP_PREFIX_ADDRESS:
+                       seq_printf(m, "%s%p: ", prefix_str, ptr + i);
+                       break;
+               case DUMP_PREFIX_OFFSET:
+                       seq_printf(m, "%s%.8x: ", prefix_str, i);
+                       break;
+               default:
+                       seq_printf(m, "%s", prefix_str);
+                       break;
+               }
+
+               ret = hex_dump_to_buffer(ptr + i, linelen, rowsize, groupsize,
+                                        m->buf + m->count, m->size - m->count,
+                                        ascii);
+               if (ret >= m->size - m->count) {
+                       seq_set_overflow(m);
+               } else {
+                       m->count += ret;
+                       seq_putc(m, '\n');
+               }
+       }
+}
+EXPORT_SYMBOL(seq_hex_dump);
+
 struct list_head *seq_list_start(struct list_head *head, loff_t pos)
 {
        struct list_head *lh;