Browse code

kex: added pkg.info rpc command

- get details about pkg manager

Daniel-Constantin Mierla authored on 15/09/2020 19:22:09
Showing 1 changed files
... ...
@@ -259,11 +259,39 @@ static void rpc_pkg_stats(rpc_t* rpc, void* ctx)
259 259
 	}
260 260
 }
261 261
 
262
+/**
263
+ *
264
+ */
265
+static const char* rpc_pkg_info_doc[2] = {
266
+	"Private memory manager details",
267
+	0
268
+};
269
+
270
+/**
271
+ *
272
+ */
273
+static void rpc_pkg_info(rpc_t* rpc, void* ctx)
274
+{
275
+	void* th;
276
+
277
+	if (rpc->add(ctx, "{", &th) < 0) {
278
+		rpc->fault(ctx, 500, "Internal error creating rpc");
279
+		return;
280
+	}
281
+	if(rpc->struct_add(th, "su",
282
+			"name", (_pkg_root.mname)?_pkg_root.mname:"unknown",
283
+			"size", (unsigned int)pkg_mem_size) <0) {
284
+		rpc->fault(ctx, 500, "Internal error adding fields");
285
+		return;
286
+	}
287
+}
288
+
262 289
 /**
263 290
  *
264 291
  */
265 292
 rpc_export_t kex_pkg_rpc[] = {
266 293
 	{"pkg.stats", rpc_pkg_stats,  rpc_pkg_stats_doc,       RET_ARRAY},
294
+	{"pkg.info",  rpc_pkg_info,   rpc_pkg_info_doc,        0},
267 295
 	{0, 0, 0, 0}
268 296
 };
269 297