+ int len, level;
+ char *buf;
+ unsigned opts;
+ enum {
+ OPT_c = 1 << 0,
+ OPT_s = 1 << 1,
+ OPT_n = 1 << 2
+ };
+
+ opt_complementary = "s+:n+"; /* numeric */
+ opts = getopt32(argv, "cs:n:", &len, &level);
+ if (opts & OPT_n) {
+ if (klogctl(8, NULL, (long) level))
+ bb_perror_msg_and_die("klogctl");
+ return EXIT_SUCCESS;
+ }
+
+ if (!(opts & OPT_s))
+ len = klogctl(10, NULL, 0); /* read ring buffer size */
+ if (len < 16*1024)
+ len = 16*1024;
+ if (len > 16*1024*1024)
+ len = 16*1024*1024;
+
+ buf = xmalloc(len);
+ len = klogctl(3 + (opts & OPT_c), buf, len); /* read ring buffer */
+ if (len < 0)
+ bb_perror_msg_and_die("klogctl");
+ if (len == 0)
+ return EXIT_SUCCESS;