summaryrefslogtreecommitdiff
path: root/usr/src/lib/libzonecfg
diff options
context:
space:
mode:
authorahrens <none@none>2005-10-31 11:33:35 -0800
committerahrens <none@none>2005-10-31 11:33:35 -0800
commitfa9e4066f08beec538e775443c5be79dd423fcab (patch)
tree576d99665e57bb7cb70584431adb08c14d47e3ce /usr/src/lib/libzonecfg
parentf1b64740276f67fc6914c1d855f2af601efe99ac (diff)
downloadillumos-joyent-fa9e4066f08beec538e775443c5be79dd423fcab.tar.gz
PSARC 2002/240 ZFS
6338653 Integrate ZFS PSARC 2004/652 - DKIOCFLUSH 5096886 Write caching disks need mechanism to flush cache to physical media
Diffstat (limited to 'usr/src/lib/libzonecfg')
-rw-r--r--usr/src/lib/libzonecfg/common/libzonecfg.c175
-rw-r--r--usr/src/lib/libzonecfg/dtd/zonecfg.dtd.112
-rw-r--r--usr/src/lib/libzonecfg/spec/libzonecfg.spec42
3 files changed, 225 insertions, 4 deletions
diff --git a/usr/src/lib/libzonecfg/common/libzonecfg.c b/usr/src/lib/libzonecfg/common/libzonecfg.c
index b6a6a59cee..416be740e3 100644
--- a/usr/src/lib/libzonecfg/common/libzonecfg.c
+++ b/usr/src/lib/libzonecfg/common/libzonecfg.c
@@ -67,6 +67,7 @@
#define DTD_ELEM_RCTL (const xmlChar *) "rctl"
#define DTD_ELEM_RCTLVALUE (const xmlChar *) "rctl-value"
#define DTD_ELEM_ZONE (const xmlChar *) "zone"
+#define DTD_ELEM_DATASET (const xmlChar *) "dataset"
#define DTD_ATTR_ACTION (const xmlChar *) "action"
#define DTD_ATTR_ADDRESS (const xmlChar *) "address"
@@ -1907,6 +1908,7 @@ static const char *standard_devs[] = {
#endif
"cpu/self/cpuid",
"dtrace/helper",
+ "zfs",
NULL
};
@@ -3518,3 +3520,176 @@ zonecfg_valid_rctl(const char *name, const rctlblk_t *rctlblk)
return (B_TRUE);
}
+
+static int
+zonecfg_add_ds_core(zone_dochandle_t handle, struct zone_dstab *tabptr)
+{
+ xmlNodePtr newnode, cur = handle->zone_dh_cur;
+ int err;
+
+ newnode = xmlNewTextChild(cur, NULL, DTD_ELEM_DATASET, NULL);
+ if ((err = newprop(newnode, DTD_ATTR_NAME,
+ tabptr->zone_dataset_name)) != Z_OK)
+ return (err);
+ return (Z_OK);
+}
+
+int
+zonecfg_add_ds(zone_dochandle_t handle, struct zone_dstab *tabptr)
+{
+ int err;
+
+ if (tabptr == NULL)
+ return (Z_INVAL);
+
+ if ((err = operation_prep(handle)) != Z_OK)
+ return (err);
+
+ if ((err = zonecfg_add_ds_core(handle, tabptr)) != Z_OK)
+ return (err);
+
+ return (Z_OK);
+}
+
+static int
+zonecfg_delete_ds_core(zone_dochandle_t handle, struct zone_dstab *tabptr)
+{
+ xmlNodePtr cur = handle->zone_dh_cur;
+
+ for (cur = cur->xmlChildrenNode; cur != NULL; cur = cur->next) {
+ if (xmlStrcmp(cur->name, DTD_ELEM_DATASET))
+ continue;
+
+ if (match_prop(cur, DTD_ATTR_NAME,
+ tabptr->zone_dataset_name)) {
+ xmlUnlinkNode(cur);
+ xmlFreeNode(cur);
+ return (Z_OK);
+ }
+ }
+ return (Z_NO_RESOURCE_ID);
+}
+
+int
+zonecfg_delete_ds(zone_dochandle_t handle, struct zone_dstab *tabptr)
+{
+ int err;
+
+ if (tabptr == NULL)
+ return (Z_INVAL);
+
+ if ((err = operation_prep(handle)) != Z_OK)
+ return (err);
+
+ if ((err = zonecfg_delete_ds_core(handle, tabptr)) != Z_OK)
+ return (err);
+
+ return (Z_OK);
+}
+
+int
+zonecfg_modify_ds(
+ zone_dochandle_t handle,
+ struct zone_dstab *oldtabptr,
+ struct zone_dstab *newtabptr)
+{
+ int err;
+
+ if (oldtabptr == NULL || newtabptr == NULL)
+ return (Z_INVAL);
+
+ if ((err = operation_prep(handle)) != Z_OK)
+ return (err);
+
+ if ((err = zonecfg_delete_ds_core(handle, oldtabptr)) != Z_OK)
+ return (err);
+
+ if ((err = zonecfg_add_ds_core(handle, newtabptr)) != Z_OK)
+ return (err);
+
+ return (Z_OK);
+}
+
+int
+zonecfg_lookup_ds(zone_dochandle_t handle, struct zone_dstab *tabptr)
+{
+ xmlNodePtr cur, firstmatch;
+ int err;
+ char dataset[MAXNAMELEN];
+
+ if (tabptr == NULL)
+ return (Z_INVAL);
+
+ if ((err = operation_prep(handle)) != Z_OK)
+ return (err);
+
+ cur = handle->zone_dh_cur;
+ firstmatch = NULL;
+ for (cur = cur->xmlChildrenNode; cur != NULL; cur = cur->next) {
+ if (xmlStrcmp(cur->name, DTD_ELEM_DATASET))
+ continue;
+ if (strlen(tabptr->zone_dataset_name) > 0) {
+ if ((fetchprop(cur, DTD_ATTR_NAME, dataset,
+ sizeof (dataset)) == Z_OK) &&
+ (strcmp(tabptr->zone_dataset_name,
+ dataset) == 0)) {
+ if (firstmatch == NULL)
+ firstmatch = cur;
+ else
+ return (Z_INSUFFICIENT_SPEC);
+ }
+ }
+ }
+ if (firstmatch == NULL)
+ return (Z_NO_RESOURCE_ID);
+
+ cur = firstmatch;
+
+ if ((err = fetchprop(cur, DTD_ATTR_NAME, tabptr->zone_dataset_name,
+ sizeof (tabptr->zone_dataset_name))) != Z_OK)
+ return (err);
+
+ return (Z_OK);
+}
+
+int
+zonecfg_setdsent(zone_dochandle_t handle)
+{
+ return (zonecfg_setent(handle));
+}
+
+int
+zonecfg_getdsent(zone_dochandle_t handle, struct zone_dstab *tabptr)
+{
+ xmlNodePtr cur;
+ int err;
+
+ if (handle == NULL)
+ return (Z_INVAL);
+
+ if ((cur = handle->zone_dh_cur) == NULL)
+ return (Z_NO_ENTRY);
+
+ for (; cur != NULL; cur = cur->next)
+ if (!xmlStrcmp(cur->name, DTD_ELEM_DATASET))
+ break;
+ if (cur == NULL) {
+ handle->zone_dh_cur = handle->zone_dh_top;
+ return (Z_NO_ENTRY);
+ }
+
+ if ((err = fetchprop(cur, DTD_ATTR_NAME, tabptr->zone_dataset_name,
+ sizeof (tabptr->zone_dataset_name))) != Z_OK) {
+ handle->zone_dh_cur = handle->zone_dh_top;
+ return (err);
+ }
+
+ handle->zone_dh_cur = cur->next;
+ return (Z_OK);
+}
+
+int
+zonecfg_enddsent(zone_dochandle_t handle)
+{
+ return (zonecfg_endent(handle));
+}
diff --git a/usr/src/lib/libzonecfg/dtd/zonecfg.dtd.1 b/usr/src/lib/libzonecfg/dtd/zonecfg.dtd.1
index d10bb5283d..d15fe65fcd 100644
--- a/usr/src/lib/libzonecfg/dtd/zonecfg.dtd.1
+++ b/usr/src/lib/libzonecfg/dtd/zonecfg.dtd.1
@@ -1,9 +1,6 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!--
- Copyright 2005 Sun Microsystems, Inc. All rights reserved.
- Use is subject to license terms.
-
CDDL HEADER START
The contents of this file are subject to the terms of the
@@ -24,6 +21,9 @@
CDDL HEADER END
+ Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ Use is subject to license terms.
+
ident "%Z%%M% %I% %E% SMI"
-->
@@ -69,7 +69,11 @@
#REQUIRED
value CDATA #REQUIRED>
-<!ELEMENT zone (filesystem | inherited-pkg-dir | network | device | rctl | attr)*>
+<!ELEMENT dataset EMPTY>
+
+<!ATTLIST dataset name CDATA #REQUIRED>
+
+<!ELEMENT zone (filesystem | inherited-pkg-dir | network | device | rctl | attr | dataset)*>
<!ATTLIST zone name CDATA #REQUIRED
zonepath CDATA #REQUIRED
diff --git a/usr/src/lib/libzonecfg/spec/libzonecfg.spec b/usr/src/lib/libzonecfg/spec/libzonecfg.spec
index dbc9f5da9a..a0cdb3db98 100644
--- a/usr/src/lib/libzonecfg/spec/libzonecfg.spec
+++ b/usr/src/lib/libzonecfg/spec/libzonecfg.spec
@@ -279,6 +279,30 @@ declaration int zonecfg_lookup_attr(zone_dochandle_t, struct zone_attrtab *)
version SUNWprivate_1.1
end
+function zonecfg_add_ds
+include <libzonecfg.h>
+declaration int zonecfg_add_ds(zone_dochandle_t, struct zone_dstab *)
+version SUNWprivate_1.1
+end
+
+function zonecfg_delete_ds
+include <libzonecfg.h>
+declaration int zonecfg_delete_ds(zone_dochandle_t, struct zone_dstab *)
+version SUNWprivate_1.1
+end
+
+function zonecfg_modify_ds
+include <libzonecfg.h>
+declaration int zonecfg_modify_ds(zone_dochandle_t, struct zone_dstab *, struct zone_dstab *)
+version SUNWprivate_1.1
+end
+
+function zonecfg_lookup_ds
+include <libzonecfg.h>
+declaration int zonecfg_lookup_ds(zone_dochandle_t, struct zone_dstab *)
+version SUNWprivate_1.1
+end
+
function zonecfg_get_attr_boolean
include <libzonecfg.h>
declaration int zonecfg_get_attr_boolean(const struct zone_attrtab *, boolean_t *)
@@ -459,6 +483,24 @@ declaration int zonecfg_endrctlent(zone_dochandle_t)
version SUNWprivate_1.1
end
+function zonecfg_setdsent
+include <libzonecfg.h>
+declaration int zonecfg_setdsent(zone_dochandle_t);
+version SUNWprivate_1.1
+end
+
+function zonecfg_getdsent
+include <libzonecfg.h>
+declaration int zonecfg_getdsent(zone_dochandle_t, struct zone_dstab *)
+version SUNWprivate_1.1
+end
+
+function zonecfg_enddsent
+include <libzonecfg.h>
+declaration int zonecfg_enddsent(zone_dochandle_t)
+version SUNWprivate_1.1
+end
+
function zonecfg_destroy
include <libzonecfg.h>
declaration int zonecfg_destroy(const char *, boolean_t)