diff mbox series

[ubus] lua: add optional path filter to objects() method

Message ID 20220501215809.75993-1-champetier.etienne@gmail.com
State Accepted
Delegated to: Petr Štetiar
Headers show
Series [ubus] lua: add optional path filter to objects() method | expand

Commit Message

Etienne Champetier May 1, 2022, 9:58 p.m. UTC
'ubus list [<path>]' passes the path to ubusd,
this commit fix the lua bindings to do the same

Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
---
 lua/ubus.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lua/ubus.c b/lua/ubus.c
index e2bb081..07b816d 100644
--- a/lua/ubus.c
+++ b/lua/ubus.c
@@ -286,9 +286,10 @@  ubus_lua_objects(lua_State *L)
 {
 	int rv;
 	struct ubus_lua_connection *c = luaL_checkudata(L, 1, METANAME);
+	const char *path = (lua_gettop(L) >= 2) ? luaL_checkstring(L, 2) : NULL;
 
 	lua_newtable(L);
-	rv = ubus_lookup(c->ctx, NULL, ubus_lua_objects_cb, L);
+	rv = ubus_lookup(c->ctx, path, ubus_lua_objects_cb, L);
 
 	if (rv != UBUS_STATUS_OK)
 	{