fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER START
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The contents of this file are subject to the terms of the
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian * Common Development and Distribution License (the "License").
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian * You may not use this file except in compliance with the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fa9e4066f08beec538e775443c5be79dd423fcabahrens * See the License for the specific language governing permissions
fa9e4066f08beec538e775443c5be79dd423fcabahrens * and limitations under the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * When distributing Covered Code, include this CDDL HEADER in each
fa9e4066f08beec538e775443c5be79dd423fcabahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If applicable, add the following below this CDDL HEADER, with the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * fields enclosed by brackets "[]" replaced with your own identifying
fa9e4066f08beec538e775443c5be79dd423fcabahrens * information: Portions Copyright [yyyy] [name of copyright owner]
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER END
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
33f5ff17089e3a43e6e730bf80384c233123dbd9Milan Jurik * Copyright 2012 Milan Jurik. All rights reserved.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Function prototypes
841f46eda88d9c4c4d56949ffedc55ed210ddc92talleystatic void set_uint64_prop(xmlNodePtr, const char *, uint64_t);
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Static functions
841f46eda88d9c4c4d56949ffedc55ed210ddc92talleyset_uint64_prop(xmlNodePtr node, const char *attr, uint64_t value)
186d582bd9dbcd38e0aeea49036d47d3426a3536Surya Prakki (void) xmlSetProp(node, (xmlChar *)attr, (xmlChar *)tmp);
186d582bd9dbcd38e0aeea49036d47d3426a3536Surya Prakki (void) xmlSetProp(disk, (xmlChar *)ATTR_DISK_INUSE, (xmlChar *)
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (0);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley if (nvlist_lookup_string(config, ZPOOL_CONFIG_POOL_NAME, &name) ||
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID, &guid) ||
a55b6846f87afedf14b3f9b64fbb8c0d0a3f2fe2cristian nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION, &version) ||
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_STATE, &state) ||
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, &devices) ||
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling devices, ZPOOL_CONFIG_VDEV_STATS, (uint64_t **)&vs, &n)) {
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley return (-1);
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley pool = xmlNewChild(importable, NULL, (xmlChar *)ELEMENT_POOL, NULL);
186d582bd9dbcd38e0aeea49036d47d3426a3536Surya Prakki (void) xmlSetProp(pool, (xmlChar *)ATTR_POOL_NAME, (xmlChar *)name);
841f46eda88d9c4c4d56949ffedc55ed210ddc92talley set_uint64_prop(pool, ATTR_POOL_REPLACEMENT_SIZE, vs->vs_rsize);
841f46eda88d9c4c4d56949ffedc55ed210ddc92talley set_uint64_prop(pool, ATTR_POOL_READ_ERRORS, vs->vs_read_errors);
841f46eda88d9c4c4d56949ffedc55ed210ddc92talley set_uint64_prop(pool, ATTR_POOL_WRITE_ERRORS, vs->vs_write_errors);
186d582bd9dbcd38e0aeea49036d47d3426a3536Surya Prakki (void) xmlSetProp(pool, (xmlChar *)ATTR_DEVICE_STATE,
186d582bd9dbcd38e0aeea49036d47d3426a3536Surya Prakki (void) xmlSetProp(pool, (xmlChar *)ATTR_DEVICE_STATUS,
186d582bd9dbcd38e0aeea49036d47d3426a3536Surya Prakki (void) xmlSetProp(pool, (xmlChar *)ATTR_POOL_STATE,
186d582bd9dbcd38e0aeea49036d47d3426a3536Surya Prakki (void) xmlSetProp(pool, (xmlChar *)ATTR_POOL_STATUS, (xmlChar *)
fbfd10ff571cfd0139aa5127460f1b8a53dac971talley zjni_pool_status_to_str(zpool_import_status(config, &c)));
c8e9ed14d97e244b9753db14caf8481f181f5750talley return (0);
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Create the XML document */
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* Create the root node */
186d582bd9dbcd38e0aeea49036d47d3426a3536Surya Prakki (void) xmlAddChild((xmlNodePtr) doc, (xmlNodePtr)root);
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Main entry to availdisks.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * @return 0 on successful exit, non-zero otherwise
c8e9ed14d97e244b9753db14caf8481f181f5750talley /* Examine first arg */
c8e9ed14d97e244b9753db14caf8481f181f5750talley switch (c) {
c8e9ed14d97e244b9753db14caf8481f181f5750talley return (1);
c8e9ed14d97e244b9753db14caf8481f181f5750talley /* Create the available node */
c8e9ed14d97e244b9753db14caf8481f181f5750talley /* libzfs_jni_diskmgt.o error handler */
c8e9ed14d97e244b9753db14caf8481f181f5750talley /* Create the importable node */
c8e9ed14d97e244b9753db14caf8481f181f5750talley /* Print out XML */
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (error != 0);