1VSNPRINTF(9) Basic C Library Functions VSNPRINTF(9)
2
3
4
6 vsnprintf - Format a string and place it in a buffer
7
9 int vsnprintf(char * buf, size_t size, const char * fmt, va_list args);
10
12 buf
13 The buffer to place the result into
14
15 size
16 The size of the buffer, including the trailing null space
17
18 fmt
19 The format string to use
20
21 args
22 Arguments for the format string
23
25 This function follows C99 vsnprintf, but has some extensions: pS output
26 the name of a text symbol with offset ps output the name of a text
27 symbol without offset pF output the name of a function pointer with its
28 offset pf output the name of a function pointer without its offset pB
29 output the name of a backtrace symbol with its offset pR output the
30 address range in a struct resource with decoded flags pr output the
31 address range in a struct resource with raw flags pb output the bitmap
32 with field width as the number of bits pbl output the bitmap as range
33 list with field width as the number of bits pM output a 6-byte MAC
34 address with colons pMR output a 6-byte MAC address with colons in
35 reversed order pMF output a 6-byte MAC address with dashes pm output a
36 6-byte MAC address without colons pmR output a 6-byte MAC address
37 without colons in reversed order pI4 print an IPv4 address without
38 leading zeros pi4 print an IPv4 address with leading zeros pI6 print an
39 IPv6 address with colons pi6 print an IPv6 address without colons pI6c
40 print an IPv6 address as specified by RFC 5952 pIS depending on
41 sa_family of 'struct sockaddr *' print IPv4/IPv6 address piS depending
42 on sa_family of 'struct sockaddr *' print IPv4/IPv6 address pU[bBlL]
43 print a UUID/GUID in big or little endian using lower or upper case.
44 %*ph[CDN] a variable-length hex string with a separator (supports up to
45 64 bytes of the input) pc print a cpumask as comma-separated list n is
46 ignored
47
48 ** Please update Documentation/printk-formats.txt when making changes
49 **
50
51 The return value is the number of characters which would be generated
52 for the given input, excluding the trailing '\0', as per ISO C99. If
53 you want to have the exact number of characters written into buf as
54 return value (not including the trailing '\0'), use vscnprintf. If the
55 return is greater than or equal to size, the resulting string is
56 truncated.
57
58 If you're not already dealing with a va_list consider using snprintf.
59
61Kernel Hackers Manual 3.10 June 2019 VSNPRINTF(9)