SHA256
1
0
forked from pool/busybox
busybox/busybox.dmesg-size.patch

31 lines
785 B
Diff

---
util-linux/dmesg.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
--- a/util-linux/dmesg.c
+++ b/util-linux/dmesg.c
@@ -12,6 +12,14 @@
#include <sys/klog.h>
#include "libbb.h"
+static int kernel_ringbuffer_size(void)
+{
+ int len = klogctl(10, NULL, 0);
+ if (len > 0)
+ return len;
+ return 16384;
+}
+
int dmesg_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int dmesg_main(int argc, char **argv)
{
@@ -25,7 +33,7 @@ int dmesg_main(int argc, char **argv)
int len;
char *buf;
- len = (flags & 2) ? xatoul_range(size, 2, INT_MAX) : 16384;
+ len = (flags & 2) ? xatoul_range(size, 2, INT_MAX) : kernel_ringbuffer_size();
buf = xmalloc(len);
if (0 > (len = klogctl(3 + (flags & 1), buf, len)))
bb_perror_msg_and_die("klogctl");