+/* Parse a filename to dump debug info */
+uword
+unformat_vlib_tmpfile (unformat_input_t * input, va_list * args)
+{
+ u8 **chroot_filename = va_arg (*args, u8 **);
+ u8 *filename;
+
+ if (!unformat (input, "%s", &filename))
+ return 0;
+
+ /* Brain-police user path input */
+ if (strstr ((char *) filename, "..") || index ((char *) filename, '/'))
+ {
+ vec_free (filename);
+ return 0;
+ }
+
+ *chroot_filename = format (0, "/tmp/%s%c", filename, 0);
+ vec_free (filename);
+
+ return 1;
+}
+
+u8 *
+format_vlib_thread_name (u8 * s, va_list * args)
+{
+ u32 thread_index = va_arg (*args, u32);
+
+ if (thread_index == 0)
+ return format (s, "main");
+
+ if (thread_index < vec_len (vlib_worker_threads))
+ return format (s, "%s", vlib_worker_threads[thread_index].name);
+ return s;
+}
+
+u8 *
+format_vlib_thread_name_and_index (u8 * s, va_list * args)
+{
+ u32 thread_index = va_arg (*args, u32);
+
+ return format (s, "%U (%u)", format_vlib_thread_name, thread_index,
+ thread_index);
+}
+