Add ubus method to set the buffer size.
Example:
ubus call log reload "{\"log_buffer_size\":size}"
Signed-off-by: Dan Bugnar <[email protected]>
---
log/logd.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/log/logd.c b/log/logd.c
index 27d3cac..563c545 100644
--- a/log/logd.c
+++ b/log/logd.c
@@ -26,11 +26,16 @@
#include "syslog.h"
+#define LOG_DEFAULT_SIZE 16 * 1024
+
int debug = 0;
static struct blob_buf b;
static struct ubus_auto_conn conn;
static LIST_HEAD(clients);
+static const struct blobmsg_policy reload_policy =
+ { .name = "log_buffer_size", .type = BLOBMSG_TYPE_INT32 };
+
static const struct blobmsg_policy read_policy =
{ .name = "lines", .type = BLOBMSG_TYPE_INT32 };
@@ -124,9 +129,29 @@ write_log(struct ubus_context *ctx, struct ubus_object
*obj,
return 0;
}
+static int
+reload_log(struct ubus_context *ctx, struct ubus_object *obj,
+ struct ubus_request_data *req, const char *method,
+ struct blob_attr *msg)
+{
+ struct blob_attr *tb;
+ int size = 0;
+
+ if (msg) {
+ blobmsg_parse(&reload_policy, 1, &tb, blob_data(msg),
blob_len(msg));
+ if (tb) {
+ size = blobmsg_get_u32(tb);
+ log_buffer_reinit(size < 1 ? LOG_DEFAULT_SIZE : size *
1024);
+ }
+ }
+
+ return 0;
+}
+
static const struct ubus_method log_methods[] = {
{ .name = "read", .handler = read_log, .policy = &read_policy,
.n_policy = 1 },
{ .name = "write", .handler = write_log, .policy = &write_policy,
.n_policy = 1 },
+ { .name = "reload", .handler = reload_log, .policy = &reload_policy,
.n_policy = 1 },
};
static struct ubus_object_type log_object_type =
--
2.8.1
_______________________________________________
Lede-dev mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/lede-dev