1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/***************************************************************/
/* perk: PE Resource Kit */
/* Copyright (C) 2015--2025 SysDeer Technologies, LLC */
/* Released under GPLv2 and GPLv3; see COPYING.PERK. */
/***************************************************************/
#include <perk/perk.h>
#include "perk_driver_impl.h"
#include "perk_errinfo_impl.h"
#include "perk_ar_impl.h"
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)
{
uint64_t action;
uint64_t poscmd;
uint64_t vercmd;
action = (flags & AR_ACTION_MASK);
poscmd = (flags & AR_POSNAME_MASK);
vercmd = (flags & PERK_DRIVER_VERSION);
if (vercmd && !posname && !arname && !units)
return 0;
switch (action) {
case 0:
return PERK_CUSTOM_ERROR(dctx,
PERK_ERR_AR_MISSING_ACTION);
case PERK_DRIVER_AR_LIST_MEMBERS:
case PERK_DRIVER_AR_DELETE_MEMBERS:
case PERK_DRIVER_AR_APPEND_MEMBERS:
case PERK_DRIVER_AR_EXTRACT_MEMBERS:
case PERK_DRIVER_AR_PRINT_ARCHIVE:
if (poscmd || posname)
return PERK_CUSTOM_ERROR(dctx,
PERK_ERR_AR_INVALID_ANCHORS);
break;
case AR_UPDATE_MASK:
case PERK_DRIVER_AR_REPLACE_MEMBERS:
case PERK_DRIVER_AR_MOVE_MEMBERS:
switch (poscmd) {
case 0:
if (posname)
return PERK_CUSTOM_ERROR(dctx,
PERK_ERR_AR_MISSING_ANCHOR);
break;
case PERK_DRIVER_AR_POSITION_AFTER:
case PERK_DRIVER_AR_POSITION_BEFORE:
if (!posname)
return PERK_CUSTOM_ERROR(dctx,
PERK_ERR_AR_NULL_POSNAME);
break;
default:
return PERK_CUSTOM_ERROR(dctx,
PERK_ERR_AR_MULTIPLE_ANCHORS);
}
default:
return PERK_CUSTOM_ERROR(dctx,
PERK_ERR_AR_MULTIPLE_ACTIONS);
}
if (!arname)
return PERK_CUSTOM_ERROR(dctx,
PERK_ERR_AR_NULL_ARNAME);
return 0;
}
int pe_cmd_ar(
const struct pe_driver_ctx * dctx,
uint64_t flags,
const char * posname,
const char * arname,
const char ** units)
{
if (pe_cmd_ar_verify_cmdline(dctx,flags,posname,arname,units) < 0)
return PERK_NESTED_ERROR(dctx);
return 0;
}
|