This patch fixes a problem with the logread utility built into procd. It adds a function to look up the correct priority and facility text strings for output.
Tested on r37834. It fixes Ticket #14079. Signed-off-by: Mike Brady<mikebr...@eircom.net> Index: package/system/procd/patches/010-fix-facility-and-priority-output.patch =================================================================== --- package/system/procd/patches/010-fix-facility-and-priority-output.patch (revision 0) +++ package/system/procd/patches/010-fix-facility-and-priority-output.patch (revision 0) @@ -0,0 +1,51 @@ +--- a/logread.c ++++ b/logread.c +@@ -60,6 +60,8 @@ static const char *log_file, *log_ip, *l + static int log_type = LOG_STDOUT; + static int log_size, log_udp; + ++const char* getcodetext(int value, CODE *codetable); ++ + static void log_handle_reconnect(struct uloop_timeout *timeout) + { + sender.fd = usock((log_udp) ? (USOCK_UDP) : (USOCK_TCP), log_ip, log_port); +@@ -149,7 +151,7 @@ static int log_notify(struct ubus_contex + } + } else { + snprintf(buf, sizeof(buf), "%s %s.%s%s %s\n", +- c, facilitynames[LOG_FAC(p)].c_name, prioritynames[LOG_PRI(p)].c_name, ++ c, getcodetext(LOG_FAC(p)<<3,facilitynames), getcodetext(LOG_PRI(p),prioritynames), + (blobmsg_get_u32(tb[LOG_SOURCE])) ? ("") : (" kernel:"), + method); + write(sender.fd, buf, strlen(buf)); +@@ -217,6 +219,7 @@ enum { + __READ_MAX + }; + ++ + static const struct blobmsg_policy read_policy[] = { + [READ_LINE] = { .name = "lines", .type = BLOBMSG_TYPE_ARRAY }, + }; +@@ -252,7 +255,7 @@ static void read_cb(struct ubus_request + c[strlen(c) - 1] = '\0'; + + printf("%s %s.%s%s %s\n", +- c, facilitynames[LOG_FAC(p)].c_name, prioritynames[LOG_PRI(p)].c_name, ++ c, getcodetext(LOG_FAC(p)<<3,facilitynames), getcodetext(LOG_PRI(p),prioritynames), + (blobmsg_get_u32(tb[LOG_SOURCE])) ? ("") : (" kernel:"), + blobmsg_get_string(tb[LOG_MSG])); + } +@@ -339,3 +342,13 @@ int main(int argc, char **argv) + + return 0; + } ++ ++const char* getcodetext(int value, CODE *codetable) { ++ CODE *i; ++ if (value >= 0) ++ for (i = codetable; i->c_val != -1; i++) ++ if (i->c_val == value) ++ return (i->c_name); ++ return ("<unknown>"); ++}; ++ _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel