summaryrefslogtreecommitdiffhomepage
path: root/src/cmds/pe_cmd_ar.c
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2025-06-03 16:05:56 +0000
committermidipix <writeonce@midipix.org>2025-06-03 23:30:15 +0000
commit013ff30dc561fbfbd714d063bbf6d38119554f12 (patch)
tree84184862fc216925ed0d163161fbf49370b3fbc7 /src/cmds/pe_cmd_ar.c
parent157740c5ad2d9a93010a434c9f46e2119cf274df (diff)
downloadperk-013ff30dc561fbfbd714d063bbf6d38119554f12.tar.bz2
perk-013ff30dc561fbfbd714d063bbf6d38119554f12.tar.xz
ar: pe_ar_list_members(): utility and driver integration.
Diffstat (limited to 'src/cmds/pe_cmd_ar.c')
-rw-r--r--src/cmds/pe_cmd_ar.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/src/cmds/pe_cmd_ar.c b/src/cmds/pe_cmd_ar.c
index 4b4f284..feb579c 100644
--- a/src/cmds/pe_cmd_ar.c
+++ b/src/cmds/pe_cmd_ar.c
@@ -9,12 +9,38 @@
#include "perk_errinfo_impl.h"
#include "perk_ar_impl.h"
+int pe_ar_list_members(const struct pe_archive_meta *, const char **);
+
+static int pe_cmd_ar_list_members(
+ const struct pe_driver_ctx * dctx,
+ const char * arname,
+ const char ** members)
+{
+ struct pe_unit_ctx * arctx = 0;
+
+ if (pe_lib_get_unit_ctx(dctx,arname,&arctx) < 0)
+ return PERK_NESTED_ERROR(dctx);
+
+ if (arctx->armeta == 0)
+ return PERK_CUSTOM_ERROR(dctx,
+ PERK_ERR_AR_NON_ARCHIVE_IMAGE);
+
+ if (pe_ar_list_members(arctx->armeta,members) < 0) {
+ pe_lib_free_unit_ctx(arctx);
+ return PERK_NESTED_ERROR(dctx);
+ }
+
+ pe_lib_free_unit_ctx(arctx);
+
+ return 0;
+}
+
static int pe_cmd_ar_verify_cmdline(
const struct pe_driver_ctx * dctx,
uint64_t flags,
const char * posname,
const char * arname,
- const char ** units)
+ const char ** members)
{
uint64_t action;
uint64_t poscmd;
@@ -24,7 +50,7 @@ static int pe_cmd_ar_verify_cmdline(
poscmd = (flags & AR_POSNAME_MASK);
vercmd = (flags & PERK_DRIVER_VERSION);
- if (vercmd && !posname && !arname && !units)
+ if (vercmd && !posname && !arname && !members)
return 0;
switch (action) {
@@ -82,10 +108,17 @@ int pe_cmd_ar(
uint64_t flags,
const char * posname,
const char * arname,
- const char ** units)
+ const char ** members)
{
- if (pe_cmd_ar_verify_cmdline(dctx,flags,posname,arname,units) < 0)
+ if (pe_cmd_ar_verify_cmdline(dctx,flags,posname,arname,members) < 0)
return PERK_NESTED_ERROR(dctx);
+ switch (flags & AR_ACTION_MASK) {
+ case PERK_DRIVER_AR_LIST_MEMBERS:
+ return pe_cmd_ar_list_members(
+ dctx,arname,members);
+
+ }
+
return 0;
}