9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * CDDL HEADER START
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * The contents of this file are subject to the terms of the
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Common Development and Distribution License (the "License").
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * You may not use this file except in compliance with the License.
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * See the License for the specific language governing permissions
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * and limitations under the License.
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * When distributing Covered Code, include this CDDL HEADER in each
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * If applicable, add the following below this CDDL HEADER, with the
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * fields enclosed by brackets "[]" replaced with your own identifying
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * information: Portions Copyright [yyyy] [name of copyright owner]
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * CDDL HEADER END
a20ee4162885a4dc8273c6b6903dcb7e0e525704Glenn Faden * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
c6596baec58ade84b0609c78e64fc3f89447c7d1Patrick Mooney * Copyright (c) 2015, Joyent, Inc.
3c7284bd3243d42a710edac3a15f6019b4c849beAlexander Eremin * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek#define DTD_ELEM_ATTACH ((const xmlChar *) "attach")
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek#define DTD_ELEM_DETACH ((const xmlChar *) "detach")
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn#define DTD_ELEM_GLOBAL_MOUNT ((const xmlChar *) "global_mount")
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn#define DTD_ELEM_INSTALLOPTS ((const xmlChar *) "installopts")
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn#define DTD_ELEM_LOGIN_CMD ((const xmlChar *) "login_cmd")
cb8a054b1ab30d5caa746e6c44f29d4c9d3071c1Glenn Faden#define DTD_ELEM_FORCELOGIN_CMD ((const xmlChar *) "forcedlogin_cmd")
bafd1f1462c49949e0251d74b4fbfa24d29bc79aJerry Jelinek#define DTD_ELEM_RESTARTINIT ((const xmlChar *) "restartinit")
37774979c2601819ef2cdb4ae1469d9111ccf52bgjelinek#define DTD_ELEM_POSTATTACH ((const xmlChar *) "postattach")
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn#define DTD_ELEM_POSTCLONE ((const xmlChar *) "postclone")
1100f00d5652de2808b73c61bcfdb3fc87ef1fc8gjelinek#define DTD_ELEM_POSTINSTALL ((const xmlChar *) "postinstall")
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek#define DTD_ELEM_POSTSNAP ((const xmlChar *) "postsnap")
c5cd6260c3d6c06a9359df595ad9dddbfd00a80e#define DTD_ELEM_POSTSTATECHG ((const xmlChar *) "poststatechange")
37774979c2601819ef2cdb4ae1469d9111ccf52bgjelinek#define DTD_ELEM_PREDETACH ((const xmlChar *) "predetach")
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek#define DTD_ELEM_PRESNAP ((const xmlChar *) "presnap")
c5cd6260c3d6c06a9359df595ad9dddbfd00a80e#define DTD_ELEM_PRESTATECHG ((const xmlChar *) "prestatechange")
37774979c2601819ef2cdb4ae1469d9111ccf52bgjelinek#define DTD_ELEM_PREUNINSTALL ((const xmlChar *) "preuninstall")
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn#define DTD_ELEM_PRIVILEGE ((const xmlChar *) "privilege")
3c7284bd3243d42a710edac3a15f6019b4c849beAlexander Eremin#define DTD_ELEM_SHUTDOWN ((const xmlChar *) "shutdown")
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek#define DTD_ELEM_UNINSTALL ((const xmlChar *) "uninstall")
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek#define DTD_ELEM_VALIDSNAP ((const xmlChar *) "validatesnap")
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn#define DTD_ELEM_VERIFY_CFG ((const xmlChar *) "verify_cfg")
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn#define DTD_ELEM_VERIFY_ADM ((const xmlChar *) "verify_adm")
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh#define DTD_ATTR_ALLOWEXCL ((const xmlChar *) "allow-exclusive-ip")
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn#define DTD_ATTR_DIRECTORY ((const xmlChar *) "directory")
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn/*ARGSUSED*/
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnnstatic void
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Ignore error messages from libxml
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn if (sysinfo(SI_ARCHITECTURE, i_curr_arch, sizeof (i_curr_arch)) < 0) {
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn sizeof (i_curr_zone)) < 0) {
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Note that here we're initializing per-process libxml2
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * state. By doing so we're implicitly assuming that
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * no other code in this process is also trying to
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * use libxml2. But in most case we know this not to
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * be true since we're almost always used in conjunction
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * with libzonecfg, which also uses libxml2. Lucky for
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * us, libzonecfg initializes libxml2 to essentially
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * the same defaults as we're using below.
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnnstatic const char *
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnnstatic const char *
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Internal function to open an XML file
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Returns the XML doc pointer, or NULL on failure. It will validate the
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * document, as well as removing any comments from the document structure.
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Parse the file
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Validate the file
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn if (valid == 0) {
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Open a handle to the named brand.
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Returns a handle to the named brand, which is used for all subsequent brand
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * interaction, or NULL if unable to open or initialize the brand.
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Make sure brand name isn't too long
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Check that the brand exists
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn (void) snprintf(path, sizeof (path), "%s/%s", BRAND_DIR, name);
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Allocate brand handle
123807fb8274cf8e22f09732e34303ba6baf55a5edp if ((bhp = malloc(sizeof (struct brand_handle))) == NULL)
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Open the configuration file
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn (void) snprintf(path, sizeof (path), "%s/%s/%s", BRAND_DIR, name,
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Verify that the name of the brand matches the directory in which it
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * is installed.
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn if ((node = xmlDocGetRootElement(bhp->bh_config)) == NULL) {
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn if ((property = xmlGetProp(node, DTD_ATTR_NAME)) == NULL) {
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Open handle to platform configuration file.
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn (void) snprintf(path, sizeof (path), "%s/%s/%s", BRAND_DIR, name,
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Closes the given brand handle
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnni_substitute_tokens(const char *sbuf, char *dbuf, int dbuf_size,
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek const char *zonename, const char *zonepath, const char *username,
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Walk through the characters, substituting values as needed.
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn for (src = 0; src < strlen((char *)sbuf) && dst < dbuf_size; src++) {
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek dst += strlcpy(dbuf + dst, zonepath, dbuf_size - dst);
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn /* name of the zone we're running in */
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn /* name of the zone we're operating on */
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (-1);
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (0);
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Retrieve the given tag from the brand.
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Perform the following substitutions as necessary:
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * %u Username
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * %z Name of target zone
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * %Z Name of current zone
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek * %R Zonepath of zone
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Returns 0 on success, -1 on failure.
123807fb8274cf8e22f09732e34303ba6baf55a5edpbrand_get_value(struct brand_handle *bhp, const char *zonename,
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek const char *zonepath, const char *username, const char *curr_zone,
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Retrieve the specified value from the XML doc
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn if ((node = xmlDocGetRootElement(bhp->bh_config)) == NULL)
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (-1);
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (-1);
db52f3aed012d3e73f2a8a861d7eee8d87ac71bcgjelinek return (0);
db52f3aed012d3e73f2a8a861d7eee8d87ac71bcgjelinek return (-1);
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (-1);
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * If the entry in the config file is empty, check to see
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * whether this is an optional field. If so, we return the
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * empty buffer. If not, we return an error.
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn /* Substitute token values as needed. */
ff17c8bf86c3e567734be83f90267edee20f580fgjelinekbrand_get_attach(brand_handle_t bh, const char *zonename,
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek struct brand_handle *bhp = (struct brand_handle *)bh;
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
123807fb8274cf8e22f09732e34303ba6baf55a5edpbrand_get_brandname(brand_handle_t bh, char *buf, size_t len)
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (-1);
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (0);
ff17c8bf86c3e567734be83f90267edee20f580fgjelinekbrand_get_clone(brand_handle_t bh, const char *zonename,
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek struct brand_handle *bhp = (struct brand_handle *)bh;
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
ff17c8bf86c3e567734be83f90267edee20f580fgjelinekbrand_get_detach(brand_handle_t bh, const char *zonename,
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek struct brand_handle *bhp = (struct brand_handle *)bh;
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
3c7284bd3243d42a710edac3a15f6019b4c849beAlexander Ereminbrand_get_shutdown(brand_handle_t bh, const char *zonename,
3c7284bd3243d42a710edac3a15f6019b4c849beAlexander Eremin const char *zonepath, char *buf, size_t len)
3c7284bd3243d42a710edac3a15f6019b4c849beAlexander Eremin struct brand_handle *bhp = (struct brand_handle *)bh;
3c7284bd3243d42a710edac3a15f6019b4c849beAlexander Eremin return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
3c7284bd3243d42a710edac3a15f6019b4c849beAlexander Eremin buf, len, DTD_ELEM_SHUTDOWN, B_TRUE, B_TRUE));
123807fb8274cf8e22f09732e34303ba6baf55a5edpbrand_get_initname(brand_handle_t bh, char *buf, size_t len)
bafd1f1462c49949e0251d74b4fbfa24d29bc79aJerry Jelinek struct brand_handle *bhp = (struct brand_handle *)bh;
bafd1f1462c49949e0251d74b4fbfa24d29bc79aJerry Jelinek if (brand_get_value(bhp, NULL, NULL, NULL, NULL,
bafd1f1462c49949e0251d74b4fbfa24d29bc79aJerry Jelinek val, sizeof (val), DTD_ELEM_RESTARTINIT, B_FALSE, B_FALSE) != 0)
123807fb8274cf8e22f09732e34303ba6baf55a5edpbrand_get_login_cmd(brand_handle_t bh, const char *username,
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (brand_get_value(bhp, NULL, NULL, username, curr_zone,
cb8a054b1ab30d5caa746e6c44f29d4c9d3071c1Glenn Fadenbrand_get_forcedlogin_cmd(brand_handle_t bh, const char *username,
cb8a054b1ab30d5caa746e6c44f29d4c9d3071c1Glenn Faden struct brand_handle *bhp = (struct brand_handle *)bh;
cb8a054b1ab30d5caa746e6c44f29d4c9d3071c1Glenn Faden return (brand_get_value(bhp, NULL, NULL, username, curr_zone,
cb8a054b1ab30d5caa746e6c44f29d4c9d3071c1Glenn Faden buf, len, DTD_ELEM_FORCELOGIN_CMD, B_TRUE, B_FALSE));
858a4b9997a29c40b725e606eb9bc3ac0a8c765bslbrand_get_user_cmd(brand_handle_t bh, const char *username,
123807fb8274cf8e22f09732e34303ba6baf55a5edpbrand_get_install(brand_handle_t bh, const char *zonename,
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
123807fb8274cf8e22f09732e34303ba6baf55a5edpbrand_get_installopts(brand_handle_t bh, char *buf, size_t len)
123807fb8274cf8e22f09732e34303ba6baf55a5edpbrand_get_modname(brand_handle_t bh, char *buf, size_t len)
37774979c2601819ef2cdb4ae1469d9111ccf52bgjelinekbrand_get_postattach(brand_handle_t bh, const char *zonename,
37774979c2601819ef2cdb4ae1469d9111ccf52bgjelinek struct brand_handle *bhp = (struct brand_handle *)bh;
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
123807fb8274cf8e22f09732e34303ba6baf55a5edpbrand_get_postclone(brand_handle_t bh, const char *zonename,
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
1100f00d5652de2808b73c61bcfdb3fc87ef1fc8gjelinekbrand_get_postinstall(brand_handle_t bh, const char *zonename,
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek struct brand_handle *bhp = (struct brand_handle *)bh;
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
ff17c8bf86c3e567734be83f90267edee20f580fgjelinekbrand_get_postsnap(brand_handle_t bh, const char *zonename,
1100f00d5652de2808b73c61bcfdb3fc87ef1fc8gjelinek struct brand_handle *bhp = (struct brand_handle *)bh;
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
c5cd6260c3d6c06a9359df595ad9dddbfd00a80ebrand_get_poststatechange(brand_handle_t bh, const char *zonename,
c5cd6260c3d6c06a9359df595ad9dddbfd00a80e return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
37774979c2601819ef2cdb4ae1469d9111ccf52bgjelinekbrand_get_predetach(brand_handle_t bh, const char *zonename,
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek struct brand_handle *bhp = (struct brand_handle *)bh;
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
ff17c8bf86c3e567734be83f90267edee20f580fgjelinekbrand_get_presnap(brand_handle_t bh, const char *zonename,
37774979c2601819ef2cdb4ae1469d9111ccf52bgjelinek struct brand_handle *bhp = (struct brand_handle *)bh;
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
c5cd6260c3d6c06a9359df595ad9dddbfd00a80ebrand_get_prestatechange(brand_handle_t bh, const char *zonename,
c5cd6260c3d6c06a9359df595ad9dddbfd00a80e return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
37774979c2601819ef2cdb4ae1469d9111ccf52bgjelinekbrand_get_preuninstall(brand_handle_t bh, const char *zonename,
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek struct brand_handle *bhp = (struct brand_handle *)bh;
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
c5cd6260c3d6c06a9359df595ad9dddbfd00a80e return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
ff17c8bf86c3e567734be83f90267edee20f580fgjelinekbrand_get_uninstall(brand_handle_t bh, const char *zonename,
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek struct brand_handle *bhp = (struct brand_handle *)bh;
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
ff17c8bf86c3e567734be83f90267edee20f580fgjelinekbrand_get_validatesnap(brand_handle_t bh, const char *zonename,
37774979c2601819ef2cdb4ae1469d9111ccf52bgjelinek struct brand_handle *bhp = (struct brand_handle *)bh;
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
123807fb8274cf8e22f09732e34303ba6baf55a5edpbrand_get_verify_cfg(brand_handle_t bh, char *buf, size_t len)
123807fb8274cf8e22f09732e34303ba6baf55a5edpbrand_get_verify_adm(brand_handle_t bh, const char *zonename,
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
fbbfbc6ee66f60ad88ebd18c6c030797335354f4jvbrand_get_sysboot(brand_handle_t bh, const char *zonename,
fbbfbc6ee66f60ad88ebd18c6c030797335354f4jv return (brand_get_value(bhp, zonename, zonepath, NULL, NULL,
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh if ((node = xmlDocGetRootElement(bhp->bh_platform)) == NULL)
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh /* Note: only return B_TRUE if it's "true" */
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Iterate over brand privileges
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Walks the brand config, searching for <privilege> elements, calling the
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * specified callback for each. Returns 0 on success, or -1 on failure.
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn if ((node = xmlDocGetRootElement(bhp->bh_config)) == NULL)
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (-1);
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn for (node = node->xmlChildrenNode; node != NULL; node = node->next) {
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (-1);
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (-1);
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (0);
c6596baec58ade84b0609c78e64fc3f89447c7d1Patrick Mooneyi_brand_platform_iter_mounts(struct brand_handle *bhp, const char *zonename,
c6596baec58ade84b0609c78e64fc3f89447c7d1Patrick Mooney const char *zonepath, int (*func)(void *, const char *, const char *,
c6596baec58ade84b0609c78e64fc3f89447c7d1Patrick Mooney const char *, const char *), void *data, const xmlChar *mount_type)
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn if ((node = xmlDocGetRootElement(bhp->bh_platform)) == NULL)
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (-1);
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn for (node = node->xmlChildrenNode; node != NULL; node = node->next) {
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn if ((special == NULL) || (dir == NULL) || (type == NULL) ||
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn /* Substitute token values as needed. */
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn /* opt might not be defined */
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (-1);
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (0);
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Iterate over global platform filesystems
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Walks the platform, searching for <global_mount> elements, calling the
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * specified callback for each. Returns 0 on success, or -1 on failure.
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Perform the following substitutions as necessary:
ff17c8bf86c3e567734be83f90267edee20f580fgjelinek * %R Zonepath of zone
c6596baec58ade84b0609c78e64fc3f89447c7d1Patrick Mooneybrand_platform_iter_gmounts(brand_handle_t bh, const char *zonename,
c6596baec58ade84b0609c78e64fc3f89447c7d1Patrick Mooney const char *zonepath, int (*func)(void *, const char *, const char *,
c6596baec58ade84b0609c78e64fc3f89447c7d1Patrick Mooney const char *, const char *), void *data)
c6596baec58ade84b0609c78e64fc3f89447c7d1Patrick Mooney return (i_brand_platform_iter_mounts(bhp, zonename, zonepath, func,
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Iterate over non-global zone platform filesystems
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Walks the platform, searching for <mount> elements, calling the
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * specified callback for each. Returns 0 on success, or -1 on failure.
123807fb8274cf8e22f09732e34303ba6baf55a5edpbrand_platform_iter_mounts(brand_handle_t bh, int (*func)(void *,
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn const char *, const char *, const char *, const char *), void *data)
c6596baec58ade84b0609c78e64fc3f89447c7d1Patrick Mooney return (i_brand_platform_iter_mounts(bhp, NULL, NULL, func, data,
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Iterate over platform symlinks
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Walks the platform, searching for <symlink> elements, calling the
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * specified callback for each. Returns 0 on success, or -1 on failure.
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn int (*func)(void *, const char *, const char *), void *data)
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn if ((node = xmlDocGetRootElement(bhp->bh_platform)) == NULL)
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (-1);
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn for (node = node->xmlChildrenNode; node != NULL; node = node->next) {
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (-1);
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (-1);
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (0);
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Iterate over platform devices
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * Walks the platform, searching for <device> elements, calling the
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn * specified callback for each. Returns 0 on success, or -1 on failure.
123807fb8274cf8e22f09732e34303ba6baf55a5edpbrand_platform_iter_devices(brand_handle_t bh, const char *zonename,
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh int (*func)(void *, const char *, const char *), void *data,
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh const char *curr_iptype)
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn if ((node = xmlDocGetRootElement(bhp->bh_platform)) == NULL)
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (-1);
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn for (node = node->xmlChildrenNode; node != NULL; node = node->next) {
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh if ((match == NULL) || (name == NULL) || (arch == NULL) ||
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn /* check if the arch matches */
f4b3ec61df05330d25f55a36b975b4d7519fdeb1dh /* check if the iptype matches */
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn /* Substitute token values as needed. */
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn /* name might not be defined */
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn /* invoke the callback */
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn ret = func(data, (const char *)match_exp, (const char *)name);
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (-1);
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (-1);
9acbbeaf2a1ffe5c14b244867d427714fab43c5cnn return (0);