summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2015-01-15 11:51:52 +0100
committerJo-Philipp Wich <jow@openwrt.org>2015-01-15 12:19:36 +0100
commit510c2ddc147649811d39c6ba3758b768cfab7b6d (patch)
tree13a96eeccf43ec4f2e225e879c00933c742ed368
parente10fca6b88a8b57fe5a9e80dfd941ae6d98cb970 (diff)
downloadunitd-510c2ddc147649811d39c6ba3758b768cfab7b6d.tar
unitd-510c2ddc147649811d39c6ba3758b768cfab7b6d.zip
system: improve system name detection
Skip entries like "Processor: 0" which are common on x86, otherwise an "ubus call system board" will just return "system: 0". Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
-rw-r--r--system.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/system.c b/system.c
index 4b3b82c..1e88b5d 100644
--- a/system.c
+++ b/system.c
@@ -20,6 +20,7 @@
#include <fcntl.h>
#include <signal.h>
#include <unistd.h>
+#include <stdlib.h>
#include <libubox/uloop.h>
@@ -64,8 +65,13 @@ static int system_board(struct ubus_context *ctx, struct ubus_object *obj,
!strcasecmp(key, "processor") ||
!strcasecmp(key, "model name"))
{
- blobmsg_add_string(&b, "system", val + 2);
- break;
+ strtoul(val + 2, &key, 0);
+
+ if (key == (val + 2) || *key != 0)
+ {
+ blobmsg_add_string(&b, "system", val + 2);
+ break;
+ }
}
}