summaryrefslogtreecommitdiff
path: root/usr.sbin/ldomctl/mdesc.h
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2012-10-15 20:28:51 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2012-10-15 20:28:51 +0000
commit40c9234ba53149b667a454da14175962636d3ec3 (patch)
treeaf7ef6b0757b2814adebb4f17803d2a08b2b6ca1 /usr.sbin/ldomctl/mdesc.h
parent550b7334d4aa2ab0a2cab5ccc92f07d8004d717b (diff)
Specify domains by name instead of by number.
Provide status of all domains if none specified.
Diffstat (limited to 'usr.sbin/ldomctl/mdesc.h')
-rw-r--r--usr.sbin/ldomctl/mdesc.h122
1 files changed, 122 insertions, 0 deletions
diff --git a/usr.sbin/ldomctl/mdesc.h b/usr.sbin/ldomctl/mdesc.h
new file mode 100644
index 00000000000..3c9bbcbf790
--- /dev/null
+++ b/usr.sbin/ldomctl/mdesc.h
@@ -0,0 +1,122 @@
+/* $OpenBSD: mdesc.h,v 1.1 2012/10/15 20:28:50 kettenis Exp $ */
+
+/*
+ * Copyright (c) 2012 Mark Kettenis
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <sys/queue.h>
+#include <stdbool.h>
+
+struct md_header {
+ uint32_t transport_version;
+ uint32_t node_blk_sz;
+ uint32_t name_blk_sz;
+ uint32_t data_blk_sz;
+};
+
+#define MD_TRANSPORT_VERSION 0x10000
+
+#define MD_ALIGNMENT_SIZE 0x10
+
+#define MD_LIST_END 0
+#define MD_NODE 'N'
+#define MD_NODE_END 'E'
+#define MD_NOOP ' '
+#define MD_PROP_ARC 'a'
+#define MD_PROP_VAL 'v'
+#define MD_PROP_STR 's'
+#define MD_PROP_DATA 'd'
+
+struct md_element {
+ uint8_t tag;
+ uint8_t name_len;
+ uint16_t _reserved_field;
+ uint32_t name_offset;
+ union {
+ struct {
+ uint32_t data_len;
+ uint32_t data_offset;
+ } y;
+ uint64_t val;
+ } d;
+};
+
+struct md {
+ TAILQ_HEAD(md_node_head, md_node) node_list;
+ TAILQ_HEAD(md_name_head, md_name) name_list;
+ TAILQ_HEAD(md_data_head, md_data) data_list;
+};
+
+struct md_node {
+ struct md_name *name;
+ TAILQ_HEAD(md_prop_head, md_prop) prop_list;
+
+ TAILQ_ENTRY(md_node) link;
+ uint64_t index;
+};
+
+struct md_prop {
+ struct md_name *name;
+ uint8_t tag;
+ union {
+ uint64_t val;
+ struct {
+ uint64_t index;
+ struct md_node *node;
+ } arc;
+ struct md_data *data;
+ } d;
+
+ TAILQ_ENTRY(md_prop) link;
+};
+
+struct md_name {
+ const char *str;
+
+ TAILQ_ENTRY(md_name) link;
+ uint32_t offset;
+ int refcnt;
+};
+
+struct md_data {
+ void *data;
+ size_t len;
+
+ TAILQ_ENTRY(md_data) link;
+ uint32_t offset;
+ int refcnt;
+};
+
+struct md_prop *md_add_prop(struct md *, struct md_node *, const char *);
+struct md_prop *md_add_prop_val(struct md *, struct md_node *,
+ const char *, uint64_t);
+struct md_prop *md_add_prop_str(struct md *, struct md_node *,
+ const char *, const char *);
+struct md_prop *md_add_prop_data(struct md *, struct md_node *,
+ const char *, const uint8_t *, size_t);
+struct md_prop *md_add_prop_arc(struct md *, struct md_node *,
+ const char *,struct md_node *);
+
+struct md_node *md_find_node(struct md *, const char *);
+struct md_prop *md_find_prop(struct md *, struct md_node *, const char *);
+
+bool md_get_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 **);
+
+struct md *md_ingest(void *, size_t);
+
+void *xmalloc(size_t);