hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/Documentation/ABI/testing/dev-kmsg
....@@ -6,13 +6,14 @@
66 to the kernel's printk buffer.
77
88 Injecting messages:
9
+
910 Every write() to the opened device node places a log entry in
1011 the kernel's printk buffer.
1112
1213 The logged line can be prefixed with a <N> syslog prefix, which
1314 carries the syslog priority and facility. The single decimal
1415 prefix number is composed of the 3 lowest bits being the syslog
15
- priority and the higher bits the syslog facility number.
16
+ priority and the next 8 bits the syslog facility number.
1617
1718 If no prefix is given, the priority number is the default kernel
1819 log priority and the facility number is set to LOG_USER (1). It
....@@ -21,6 +22,7 @@
2122 the messages can always be reliably determined.
2223
2324 Accessing the buffer:
25
+
2426 Every read() from the opened device node receives one record
2527 of the kernel's printk buffer.
2628
....@@ -48,6 +50,7 @@
4850 if needed, without limiting the interface to a single reader.
4951
5052 The device supports seek with the following parameters:
53
+
5154 SEEK_SET, 0
5255 seek to the first entry in the buffer
5356 SEEK_END, 0
....@@ -55,6 +58,17 @@
5558 SEEK_DATA, 0
5659 seek after the last record available at the time
5760 the last SYSLOG_ACTION_CLEAR was issued.
61
+
62
+ Other seek operations or offsets are not supported because of
63
+ the special behavior this device has. The device allows to read
64
+ or write only whole variable length messages (records) that are
65
+ stored in a ring buffer.
66
+
67
+ Because of the non-standard behavior also the error values are
68
+ non-standard. -ESPIPE is returned for non-zero offset. -EINVAL
69
+ is returned for other operations, e.g. SEEK_CUR. This behavior
70
+ and values are historical and could not be modified without the
71
+ risk of breaking userspace.
5872
5973 The output format consists of a prefix carrying the syslog
6074 prefix including priority and facility, the 64 bit message
....@@ -76,27 +90,30 @@
7690 readable context of the message, for reliable processing in
7791 userspace.
7892
79
- Example:
80
- 7,160,424069,-;pci_root PNP0A03:00: host bridge window [io 0x0000-0x0cf7] (ignored)
81
- SUBSYSTEM=acpi
82
- DEVICE=+acpi:PNP0A03:00
83
- 6,339,5140900,-;NET: Registered protocol family 10
84
- 30,340,5690716,-;udevd[80]: starting version 181
93
+ Example::
94
+
95
+ 7,160,424069,-;pci_root PNP0A03:00: host bridge window [io 0x0000-0x0cf7] (ignored)
96
+ SUBSYSTEM=acpi
97
+ DEVICE=+acpi:PNP0A03:00
98
+ 6,339,5140900,-;NET: Registered protocol family 10
99
+ 30,340,5690716,-;udevd[80]: starting version 181
85100
86101 The DEVICE= key uniquely identifies devices the following way:
87
- b12:8 - block dev_t
88
- c127:3 - char dev_t
89
- n8 - netdev ifindex
90
- +sound:card0 - subsystem:devname
102
+
103
+ ============ =================
104
+ b12:8 block dev_t
105
+ c127:3 char dev_t
106
+ n8 netdev ifindex
107
+ +sound:card0 subsystem:devname
108
+ ============ =================
91109
92110 The flags field carries '-' by default. A 'c' indicates a
93
- fragment of a line. All following fragments are flagged with
94
- '+'. Note, that these hints about continuation lines are not
95
- necessarily correct, and the stream could be interleaved with
96
- unrelated messages, but merging the lines in the output
97
- usually produces better human readable results. A similar
98
- logic is used internally when messages are printed to the
99
- console, /proc/kmsg or the syslog() syscall.
111
+ fragment of a line. Note, that these hints about continuation
112
+ lines are not necessarily correct, and the stream could be
113
+ interleaved with unrelated messages, but merging the lines in
114
+ the output usually produces better human readable results. A
115
+ similar logic is used internally when messages are printed to
116
+ the console, /proc/kmsg or the syslog() syscall.
100117
101118 By default, kernel tries to avoid fragments by concatenating
102119 when it can and fragments are rare; however, when extended