diff options
author | Daniel Golle <daniel@makrotopia.org> | 2017-06-19 00:53:00 +0200 |
---|---|---|
committer | Daniel Golle <daniel@makrotopia.org> | 2017-06-19 01:00:11 +0200 |
commit | 453116e08e6a9349374bbff427b75f57ce5387c9 (patch) | |
tree | a2aeec6f943c3349fb555c0d51a799048090dd67 /system.c | |
parent | e5b963a1f0b40a9b0880785d428d7462532c4611 (diff) | |
download | procd-453116e08e6a9349374bbff427b75f57ce5387c9.tar.gz |
system: introduce new attribute board_name
Instead of modifying the already defined 'model' attribute rather
introduce a new attribute board_name to return either
/tmp/sysinfo/board_name or /proc/device-tree/compatible.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'system.c')
-rw-r--r-- | system.c | 36 |
1 files changed, 35 insertions, 1 deletions
@@ -80,7 +80,7 @@ static int system_board(struct ubus_context *ctx, struct ubus_object *obj, fclose(f); } - if ((f = fopen("/tmp/sysinfo/board_name", "r")) != NULL || + if ((f = fopen("/tmp/sysinfo/model", "r")) != NULL || (f = fopen("/proc/device-tree/model", "r")) != NULL) { if (fgets(line, sizeof(line), f)) @@ -114,6 +114,40 @@ static int system_board(struct ubus_context *ctx, struct ubus_object *obj, fclose(f); } + if ((f = fopen("/tmp/sysinfo/board_name", "r")) != NULL) + { + if (fgets(line, sizeof(line), f)) + { + val = strtok(line, "\t\n"); + + if (val) + blobmsg_add_string(&b, "board_name", val); + } + + fclose(f); + } + else if ((f = fopen("/proc/device-tree/compatible", "r")) != NULL) + { + if (fgets(line, sizeof(line), f)) + { + val = strtok(line, "\t\n"); + + if (val) + { + next = val; + while ((next = strchr(next, ',')) != NULL) + { + *next = '-'; + next++; + } + + blobmsg_add_string(&b, "board_name", val); + } + } + + fclose(f); + } + if ((f = fopen("/etc/openwrt_release", "r")) != NULL) { c = blobmsg_open_table(&b, "release"); |