@@ -2843,30 +2843,31 @@ static void __console_unlock(void)
2843
2843
#ifdef CONFIG_PRINTK
2844
2844
2845
2845
/*
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.
2849
2848
*
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.
2853
2851
*
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.
2856
2854
*
2857
2855
* If @pmsg->pbufs->outbuf is modified, @pmsg->outbuf_len is updated.
2858
2856
*/
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 , ...)
2860
2859
{
2861
2860
struct printk_buffers * pbufs = pmsg -> pbufs ;
2862
2861
const size_t scratchbuf_sz = sizeof (pbufs -> scratchbuf );
2863
2862
const size_t outbuf_sz = sizeof (pbufs -> outbuf );
2864
2863
char * scratchbuf = & pbufs -> scratchbuf [0 ];
2865
2864
char * outbuf = & pbufs -> outbuf [0 ];
2865
+ va_list args ;
2866
2866
size_t len ;
2867
2867
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 );
2870
2871
2871
2872
/*
2872
2873
* Make sure outbuf is sufficiently large before prepending.
@@ -2888,6 +2889,19 @@ void console_prepend_dropped(struct printk_message *pmsg, unsigned long dropped)
2888
2889
pmsg -> outbuf_len += len ;
2889
2890
}
2890
2891
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
+
2891
2905
/*
2892
2906
* Read and format the specified record (or a later record if the specified
2893
2907
* record is not available).
0 commit comments