@@ -2843,30 +2843,31 @@ static void __console_unlock(void)
28432843#ifdef CONFIG_PRINTK
28442844
28452845/*
2846- * Prepend the message in @pmsg->pbufs->outbuf with a "dropped message". This
2847- * is achieved by shifting the existing message over and inserting the dropped
2848- * message.
2846+ * Prepend the message in @pmsg->pbufs->outbuf. This is achieved by shifting
2847+ * the existing message over and inserting the scratchbuf message.
28492848 *
2850- * @pmsg is the printk message to prepend.
2851- *
2852- * @dropped is the dropped count to report in the dropped message.
2849+ * @pmsg is the original printk message.
2850+ * @fmt is the printf format of the message which will prepend the existing one.
28532851 *
2854- * If the message text in @pmsg->pbufs->outbuf does not have enough space for
2855- * the dropped message, the message text will be sufficiently truncated.
2852+ * If there is not enough space in @pmsg->pbufs->outbuf, the existing
2853+ * message text will be sufficiently truncated.
28562854 *
28572855 * If @pmsg->pbufs->outbuf is modified, @pmsg->outbuf_len is updated.
28582856 */
2859- void console_prepend_dropped (struct printk_message * pmsg , unsigned long dropped )
2857+ __printf (2 , 3 )
2858+ static void console_prepend_message (struct printk_message * pmsg , const char * fmt , ...)
28602859{
28612860 struct printk_buffers * pbufs = pmsg -> pbufs ;
28622861 const size_t scratchbuf_sz = sizeof (pbufs -> scratchbuf );
28632862 const size_t outbuf_sz = sizeof (pbufs -> outbuf );
28642863 char * scratchbuf = & pbufs -> scratchbuf [0 ];
28652864 char * outbuf = & pbufs -> outbuf [0 ];
2865+ va_list args ;
28662866 size_t len ;
28672867
2868- len = scnprintf (scratchbuf , scratchbuf_sz ,
2869- "** %lu printk messages dropped **\n" , dropped );
2868+ va_start (args , fmt );
2869+ len = vscnprintf (scratchbuf , scratchbuf_sz , fmt , args );
2870+ va_end (args );
28702871
28712872 /*
28722873 * Make sure outbuf is sufficiently large before prepending.
@@ -2888,6 +2889,19 @@ void console_prepend_dropped(struct printk_message *pmsg, unsigned long dropped)
28882889 pmsg -> outbuf_len += len ;
28892890}
28902891
2892+ /*
2893+ * Prepend the message in @pmsg->pbufs->outbuf with a "dropped message".
2894+ * @pmsg->outbuf_len is updated appropriately.
2895+ *
2896+ * @pmsg is the printk message to prepend.
2897+ *
2898+ * @dropped is the dropped count to report in the dropped message.
2899+ */
2900+ void console_prepend_dropped (struct printk_message * pmsg , unsigned long dropped )
2901+ {
2902+ console_prepend_message (pmsg , "** %lu printk messages dropped **\n" , dropped );
2903+ }
2904+
28912905/*
28922906 * Read and format the specified record (or a later record if the specified
28932907 * record is not available).
0 commit comments