diff options
author | Felix Fietkau <nbd@openwrt.org> | 2014-07-02 19:00:11 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2014-07-02 19:00:11 +0200 |
commit | 562223169e7277237951f590ca0a2f32b112dcb1 (patch) | |
tree | 48eac5c6da553cdcc29b4b6099e193b36a99e221 /service | |
parent | 8e12022c3d00f8acca4471016d71794988113c34 (diff) | |
download | unitd-562223169e7277237951f590ca0a2f32b112dcb1.tar unitd-562223169e7277237951f590ca0a2f32b112dcb1.zip |
instance: allow filling "data" with fields of arbitrary type
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'service')
-rw-r--r-- | service/instance.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/service/instance.c b/service/instance.c index a01a35a..1f85914 100644 --- a/service/instance.c +++ b/service/instance.c @@ -359,6 +359,15 @@ instance_file_update(struct blobmsg_list_node *l) close(fd); } +static void +instance_fill_any(struct blobmsg_list *l, struct blob_attr *cur) +{ + if (!cur) + return; + + blobmsg_list_fill(l, blobmsg_data(cur), blobmsg_data_len(cur), false); +} + static bool instance_fill_array(struct blobmsg_list *l, struct blob_attr *cur, blobmsg_update_cb cb, bool array) { @@ -443,10 +452,9 @@ instance_config_parse(struct service_instance *in) return false; } - if (!instance_fill_array(&in->env, tb[INSTANCE_ATTR_ENV], NULL, false)) - return false; + instance_fill_any(&in->data, tb[INSTANCE_ATTR_DATA]); - if (!instance_fill_array(&in->data, tb[INSTANCE_ATTR_DATA], NULL, false)) + if (!instance_fill_array(&in->env, tb[INSTANCE_ATTR_ENV], NULL, false)) return false; if (!instance_fill_array(&in->netdev, tb[INSTANCE_ATTR_NETDEV], instance_netdev_update, true)) |