From aace55b739f03f5e84c7dffc26b977ff7b86d6b5 Mon Sep 17 00:00:00 2001 From: kettenis Date: Sun, 14 Jul 2019 14:40:55 +0000 Subject: [PATCH] Add interface to set/update a data property. --- usr.sbin/ldomctl/mdesc.c | 17 ++++++++++++++++- usr.sbin/ldomctl/mdesc.h | 4 +++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/usr.sbin/ldomctl/mdesc.c b/usr.sbin/ldomctl/mdesc.c index 8f2dfbd55d8..ddad9483b3d 100644 --- a/usr.sbin/ldomctl/mdesc.c +++ b/usr.sbin/ldomctl/mdesc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdesc.c,v 1.11 2018/09/16 12:17:05 kettenis Exp $ */ +/* $OpenBSD: mdesc.c,v 1.12 2019/07/14 14:40:55 kettenis Exp $ */ /* * Copyright (c) 2012 Mark Kettenis @@ -301,6 +301,21 @@ md_get_prop_data(struct md *md, struct md_node *node, const char *name, return true; } +bool +md_set_prop_data(struct md *md, struct md_node *node, const char *name, + const uint8_t *data, size_t len) +{ + struct md_prop *prop; + + prop = md_find_prop(md, node, name); + if (prop == NULL || prop->tag != MD_PROP_DATA) + return false; + + md_free_data(md, prop->d.data); + prop->d.data = md_add_data(md, data, len); + return true; +} + void md_delete_node(struct md *md, struct md_node *node) { diff --git a/usr.sbin/ldomctl/mdesc.h b/usr.sbin/ldomctl/mdesc.h index 48972b2e5e3..acbe6cddab5 100644 --- a/usr.sbin/ldomctl/mdesc.h +++ b/usr.sbin/ldomctl/mdesc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mdesc.h,v 1.7 2018/09/16 12:17:05 kettenis Exp $ */ +/* $OpenBSD: mdesc.h,v 1.8 2019/07/14 14:40:55 kettenis Exp $ */ /* * Copyright (c) 2012 Mark Kettenis @@ -121,6 +121,8 @@ bool md_get_prop_val(struct md *, struct md_node *, const char *, uint64_t *); bool md_set_prop_val(struct md *, struct md_node *, const char *, uint64_t); bool md_get_prop_str(struct md *, struct md_node *, const char *, const char **); +bool md_set_prop_data(struct md *, struct md_node *, const char *, + const uint8_t *, size_t); bool md_get_prop_data(struct md *, struct md_node *, const char *, const void **, size_t *);