Skip to content

Commit

Permalink
mods: ucmd: replace sid_ucmd_kv_get{,_foreign_mod,foreign_dev,foreign…
Browse files Browse the repository at this point in the history
…_devmod} with sid_ucmd_kv_va_get
  • Loading branch information
prajnoha committed Nov 7, 2024
1 parent 7c53239 commit 5b44837
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/modules/ucmd/block/dm_mpath/dm_mpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static int _dm_mpath_scan_next(sid_res_t *mod_res, struct sid_ucmd_ctx *ucmd_ctx
char *p;
int old_valid;

old_valid_str = sid_ucmd_kv_get(mod_res, ucmd_ctx, SID_KV_NS_DEVMOD, X_VALID, NULL, NULL, 0);
old_valid_str = sid_ucmd_kv_va_get(mod_res, ucmd_ctx, .ns = SID_KV_NS_DEVMOD, .key = X_VALID);
if (old_valid_str && old_valid_str[0]) {
errno = 0;
old_valid = strtol(old_valid_str, &p, 10);
Expand Down
10 changes: 5 additions & 5 deletions src/modules/ucmd/type/dm/dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ static int _get_cookie_props(sid_res_t *mod_res, struct sid_ucmd_ctx *ucmd_ctx,
dm_cookie_flags_t flags;
char *p;

if (!(str = sid_ucmd_kv_get(mod_res, ucmd_ctx, SID_KV_NS_UDEV, DM_U_COOKIE, NULL, NULL, 0))) {
if (!(str = sid_ucmd_kv_va_get(mod_res, ucmd_ctx, .ns = SID_KV_NS_UDEV, .key = DM_U_COOKIE))) {
if (sid_ucmd_kv_va_set(mod_res,
ucmd_ctx,
.ns = SID_KV_NS_DEVMOD,
Expand Down Expand Up @@ -537,7 +537,7 @@ static int _dm_submod_common_scan_init(sid_res_t *mod_res, struct sid_ucmd_ctx *
const char *submod_name = NULL;

dm_mod = sid_mod_get_data(mod_res);
submod_name = sid_ucmd_kv_get(mod_res, ucmd_ctx, SID_KV_NS_DEVICE, DM_SUBMODULES_ID, NULL, NULL, 0);
submod_name = sid_ucmd_kv_va_get(mod_res, ucmd_ctx, .ns = SID_KV_NS_DEVICE, .key = DM_SUBMODULES_ID);

if (submod_name) {
if (strcmp(submod_name, DM_SUBMODULE_ID_NONE) != 0) {
Expand Down Expand Up @@ -691,7 +691,7 @@ static int _dm_scan_pre(sid_res_t *mod_res, struct sid_ucmd_ctx *ucmd_ctx)
goto out;
}

if (!(val = sid_ucmd_kv_get(mod_res, ucmd_ctx, SID_KV_NS_UDEV, DM_U_SUSPENDED, NULL, NULL, 0))) {
if (!(val = sid_ucmd_kv_va_get(mod_res, ucmd_ctx, .ns = SID_KV_NS_UDEV, .key = DM_U_SUSPENDED))) {
sid_res_log_error(mod_res, _failed_to_get_msg, DM_U_SUSPENDED);
r = -1;
goto out;
Expand Down Expand Up @@ -909,7 +909,7 @@ static int _dm_scan_a_exit(sid_res_t *mod_res, struct sid_ucmd_ctx *ucmd_ctx)
}
}

if (!(flags = sid_ucmd_kv_get(mod_res, ucmd_ctx, SID_KV_NS_DEVMOD, DM_X_COOKIE_FLAGS, NULL, NULL, 0)))
if (!(flags = sid_ucmd_kv_va_get(mod_res, ucmd_ctx, .ns = SID_KV_NS_DEVMOD, .key = DM_X_COOKIE_FLAGS)))
return 0;

for (i = 0; i < COOKIE_FLAGS_SHIFT; i++) {
Expand Down Expand Up @@ -1051,7 +1051,7 @@ static int _dm_scan_action_current(sid_res_t *mod_res, struct sid_ucmd_ctx *ucmd
sid_res_log_debug(mod_res, "scan-action-current");

if ((cookie_base_p =
(dm_cookie_base_t *) sid_ucmd_kv_get(mod_res, ucmd_ctx, SID_KV_NS_DEVMOD, DM_X_COOKIE_BASE, NULL, NULL, 0))) {
(dm_cookie_base_t *) sid_ucmd_kv_va_get(mod_res, ucmd_ctx, .ns = SID_KV_NS_DEVMOD, .key = DM_X_COOKIE_BASE))) {
if (_udevcomplete(mod_res, *cookie_base_p) < 0)
return -1;
}
Expand Down
18 changes: 13 additions & 5 deletions src/modules/ucmd/type/dm/lvm/lvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ static int _store_component_names(sid_res_t *mod_res, struct sid_ucmd_ctx *ucmd_
char *vg_name = NULL, *lv_name, *lv_layer;
int r = -1;

if (!(dm_name = sid_ucmd_kv_get_foreign_mod(mod_res, ucmd_ctx, "/type/dm", SID_KV_NS_DEVMOD, DM_X_NAME, NULL, NULL, 0)))
if (!(dm_name = sid_ucmd_kv_va_get(mod_res,
ucmd_ctx,
.foreign_mod_name = "/type/dm",
.ns = SID_KV_NS_DEVMOD,
.key = DM_X_NAME)))
goto out;

if (!(vg_name = strdup(dm_name)))
Expand Down Expand Up @@ -244,7 +248,7 @@ static int _lvm_subsys_match_current(sid_res_t *mod_res, struct sid_ucmd_ctx *uc

sid_res_log_debug(mod_res, "scan-dm-subsys-match");

if (!(uuid = sid_ucmd_kv_get_foreign_mod(mod_res, ucmd_ctx, "/type/dm", SID_KV_NS_DEVMOD, "uuid", NULL, NULL, 0)))
if (!(uuid = sid_ucmd_kv_va_get(mod_res, ucmd_ctx, .foreign_mod_name = "/type/dm", .ns = SID_KV_NS_DEVMOD, .key = "uuid")))
return 0;

return !strncmp(uuid, LVM_DM_UUID_PREFIX, sizeof(LVM_DM_UUID_PREFIX) - 1);
Expand All @@ -257,7 +261,7 @@ static int _lvm_subsys_match_next(sid_res_t *mod_res, struct sid_ucmd_ctx *ucmd_

sid_res_log_debug(mod_res, "scan-dm-subsys-match-next");

if (!(type = sid_ucmd_kv_get(mod_res, ucmd_ctx, SID_KV_NS_UDEV, "ID_FS_TYPE", NULL, NULL, 0)))
if (!(type = sid_ucmd_kv_va_get(mod_res, ucmd_ctx, .ns = SID_KV_NS_UDEV, .key = "ID_FS_TYPE")))
return 0;

return !strcmp(type, "LVM2_member");
Expand Down Expand Up @@ -289,7 +293,11 @@ static int _lvm_scan_pre(sid_res_t *mod_res, struct sid_ucmd_ctx *ucmd_ctx)
if (ready < _SID_DEV_RDY)
return 0;

flags = sid_ucmd_kv_get_foreign_mod(mod_res, ucmd_ctx, "/type/dm", SID_KV_NS_DEVMOD, DM_X_COOKIE_FLAGS, NULL, NULL, 0);
flags = sid_ucmd_kv_va_get(mod_res,
ucmd_ctx,
.foreign_mod_name = "/type/dm",
.ns = SID_KV_NS_DEVMOD,
.key = DM_X_COOKIE_FLAGS);

switch (ready) {
case SID_DEV_RDY_PUBLIC:
Expand Down Expand Up @@ -358,7 +366,7 @@ static int _lvm_scan_action_next(sid_res_t *mod_res, struct sid_ucmd_ctx *ucmd_c

sid_res_log_debug(mod_res, "scan-action-next");

if ((val = sid_ucmd_kv_get(mod_res, ucmd_ctx, SID_KV_NS_DEVMOD, LVM_VG_NAME_COMPLETE, NULL, NULL, 0))) {
if ((val = sid_ucmd_kv_va_get(mod_res, ucmd_ctx, .ns = SID_KV_NS_DEVMOD, .key = LVM_VG_NAME_COMPLETE))) {
runner_res = sid_mod_get_data(mod_res);

if (!(cmd_line = util_str_comb_to_str(NULL, NULL, "vgchange -aay --autoactivation event ", val)))
Expand Down

0 comments on commit 5b44837

Please sign in to comment.