File busybox.dmesg-size.patch of Package busybox

---
 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 UNUSED_PARAM, char **argv)
 {
@@ -31,7 +39,7 @@ int dmesg_main(int argc UNUSED_PARAM, ch
 		return EXIT_SUCCESS;
 	}
 
-	len = (flags & OPT_s) ? xatoul_range(size, 2, INT_MAX) : 16384;
+	len = (flags & OPT_s) ? xatoul_range(size, 2, INT_MAX) : kernel_ringbuffer_size();
 	buf = xmalloc(len);
 	len = klogctl(3 + (flags & OPT_c), buf, len);
 	if (len < 0)
openSUSE Build Service is sponsored by