2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#include <ctype.h>
2N/A#include <errno.h>
2N/A#include <fcntl.h>
2N/A#include <libgen.h>
2N/A#include <limits.h>
2N/A#include <stdarg.h>
2N/A#include <stdio.h>
2N/A#include <stdlib.h>
2N/A#include <string.h>
2N/A#include <strings.h>
2N/A#include <stropts.h>
2N/A#include <sys/ioccom.h>
2N/A#include <sys/stat.h>
2N/A#include <sys/systeminfo.h>
2N/A#include <sys/types.h>
2N/A#include <sys/varargs.h>
2N/A#include <unistd.h>
2N/A#include <libintl.h>
2N/A#include <locale.h>
2N/A
2N/A#include <libzonecfg.h>
2N/A
2N/Astatic void usage_err(void) __NORETURN;
2N/Astatic void usage(char *msg, ...) __NORETURN;
2N/A
2N/Astatic char *bname = NULL;
2N/A
2N/A#if !defined(TEXT_DOMAIN) /* should be defined by cc -D */
2N/A#define TEXT_DOMAIN "SYS_TEST" /* Use this only if it wasn't */
2N/A#endif
2N/A
2N/Astatic void
2N/Ausage_err(void)
2N/A{
2N/A (void) printf(gettext("%s solaris brand error: invalid usage\n"),
2N/A bname);
2N/A (void) fprintf(stderr,
2N/A gettext("usage:\t%s verify <xml file>\n\n"), bname);
2N/A
2N/A exit(1);
2N/A}
2N/A
2N/Astatic void
2N/Aerr(char *msg, ...)
2N/A{
2N/A char buf[1024];
2N/A va_list ap;
2N/A
2N/A va_start(ap, msg);
2N/A /*LINTED*/
2N/A (void) vsnprintf(buf, sizeof (buf), msg, ap);
2N/A va_end(ap);
2N/A
2N/A (void) printf(gettext("%s solaris brand error: %s\n"), bname, buf);
2N/A
2N/A exit(1);
2N/A /*NOTREACHED*/
2N/A}
2N/A
2N/Astatic int
2N/Ado_verify(char *xmlfile)
2N/A{
2N/A zone_dochandle_t handle;
2N/A struct zone_fstab fstab;
2N/A struct zone_dstab dstab;
2N/A
2N/A if ((handle = zonecfg_init_handle()) == NULL)
2N/A err(gettext("internal libzonecfg.so.1 error"), 0);
2N/A
2N/A if (zonecfg_get_xml_handle(xmlfile, handle) != Z_OK) {
2N/A zonecfg_fini_handle(handle);
2N/A err(gettext("zonecfg provided an invalid XML file"));
2N/A }
2N/A
2N/A zonecfg_fini_handle(handle);
2N/A return (0);
2N/A}
2N/A
2N/Aint
2N/Amain(int argc, char *argv[])
2N/A{
2N/A (void) setlocale(LC_ALL, "");
2N/A (void) textdomain(TEXT_DOMAIN);
2N/A
2N/A bname = basename(argv[0]);
2N/A
2N/A if (argc < 3)
2N/A usage_err();
2N/A
2N/A if (strcmp(argv[1], "verify") == 0) {
2N/A if (argc != 3)
2N/A usage_err();
2N/A return (do_verify(argv[2]));
2N/A }
2N/A
2N/A usage_err();
2N/A /*NOTREACHED*/
2N/A}