10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 23*7044Smk117520 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 280Sstevel@tonic-gate 290Sstevel@tonic-gate /* 300Sstevel@tonic-gate * mediator status utility. 310Sstevel@tonic-gate */ 320Sstevel@tonic-gate 330Sstevel@tonic-gate #include <meta.h> 340Sstevel@tonic-gate #include <sdssc.h> 350Sstevel@tonic-gate 360Sstevel@tonic-gate static void 370Sstevel@tonic-gate usage( 380Sstevel@tonic-gate mdsetname_t *sp, 390Sstevel@tonic-gate char *string) 400Sstevel@tonic-gate { 410Sstevel@tonic-gate if ((string != NULL) && (*string != '\0')) 420Sstevel@tonic-gate md_eprintf("%s\n", string); 430Sstevel@tonic-gate (void) fprintf(stderr, gettext( 440Sstevel@tonic-gate "usage: %s [-q] -s setname\n"), 450Sstevel@tonic-gate myname); 460Sstevel@tonic-gate md_exit(sp, (string == NULL) ? 0 : 1); 470Sstevel@tonic-gate } 480Sstevel@tonic-gate 490Sstevel@tonic-gate /* 500Sstevel@tonic-gate * parse args and do it 510Sstevel@tonic-gate */ 520Sstevel@tonic-gate int 530Sstevel@tonic-gate main( 540Sstevel@tonic-gate int argc, 550Sstevel@tonic-gate char *argv[] 560Sstevel@tonic-gate ) 570Sstevel@tonic-gate { 580Sstevel@tonic-gate int c; 590Sstevel@tonic-gate char *sname = MD_LOCAL_NAME; 600Sstevel@tonic-gate md_error_t status = mdnullerror; 610Sstevel@tonic-gate md_error_t *ep = &status; 620Sstevel@tonic-gate mdsetname_t *sp = NULL; 630Sstevel@tonic-gate int verbose = 1; 640Sstevel@tonic-gate 650Sstevel@tonic-gate /* 660Sstevel@tonic-gate * Get the locale set up before calling any other routines 670Sstevel@tonic-gate * with messages to ouput. Just in case we're not in a build 680Sstevel@tonic-gate * environment, make sure that TEXT_DOMAIN gets set to 690Sstevel@tonic-gate * something. 700Sstevel@tonic-gate */ 710Sstevel@tonic-gate #if !defined(TEXT_DOMAIN) 720Sstevel@tonic-gate #define TEXT_DOMAIN "SYS_TEST" 730Sstevel@tonic-gate #endif 740Sstevel@tonic-gate (void) setlocale(LC_ALL, ""); 750Sstevel@tonic-gate (void) textdomain(TEXT_DOMAIN); 760Sstevel@tonic-gate 77*7044Smk117520 /* 78*7044Smk117520 * There is no need to proxy the command to owner of the set 79*7044Smk117520 * to get the mediator information as the /etc/lvm/meddb file 80*7044Smk117520 * contains the required information and so it can be used. 81*7044Smk117520 */ 82*7044Smk117520 if ((sdssc_bind_library() == SDSSC_ERROR)) { 83*7044Smk117520 (void) fprintf(stderr, 84*7044Smk117520 "Failed to initialised libscsds.so.1\n"); 85*7044Smk117520 exit(1); 86*7044Smk117520 } 87*7044Smk117520 880Sstevel@tonic-gate 890Sstevel@tonic-gate /* initialize */ 900Sstevel@tonic-gate if (md_init(argc, argv, 0, 1, ep) != 0) { 910Sstevel@tonic-gate mde_perror(ep, ""); 920Sstevel@tonic-gate md_exit(sp, 1); 930Sstevel@tonic-gate } 940Sstevel@tonic-gate 950Sstevel@tonic-gate optind = 1; 960Sstevel@tonic-gate opterr = 1; 970Sstevel@tonic-gate while ((c = getopt(argc, argv, "qs:?")) != -1) { 980Sstevel@tonic-gate switch (c) { 990Sstevel@tonic-gate case 'q': 1000Sstevel@tonic-gate verbose = 0; 1010Sstevel@tonic-gate break; 1020Sstevel@tonic-gate case 's': 1030Sstevel@tonic-gate sname = optarg; 1040Sstevel@tonic-gate break; 1050Sstevel@tonic-gate case '?': 1060Sstevel@tonic-gate if (optopt == '?') 107*7044Smk117520 usage(sp, NULL); 1080Sstevel@tonic-gate /*FALLTHROUGH*/ 1090Sstevel@tonic-gate default: 1100Sstevel@tonic-gate usage(sp, gettext("unknown command")); 1110Sstevel@tonic-gate } 1120Sstevel@tonic-gate } 1130Sstevel@tonic-gate /* must have set for everything else */ 1140Sstevel@tonic-gate if (strcmp(sname, MD_LOCAL_NAME) == 0) 1150Sstevel@tonic-gate usage(sp, gettext("setname must be specified")); 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate /* snarf MDDB */ 1180Sstevel@tonic-gate if (meta_setup_db_locations(ep) != 0) { 1190Sstevel@tonic-gate mde_perror(ep, ""); 1200Sstevel@tonic-gate md_exit(sp, 1); 1210Sstevel@tonic-gate } 1220Sstevel@tonic-gate 123*7044Smk117520 /* 124*7044Smk117520 * Get the mediator information from file 125*7044Smk117520 * /etc/lvm/meddb and print it. 126*7044Smk117520 */ 1270Sstevel@tonic-gate 128*7044Smk117520 if (meta_mediator_info_from_file(sname, verbose, ep)) { 1290Sstevel@tonic-gate md_exit(sp, 1); 1300Sstevel@tonic-gate } 1310Sstevel@tonic-gate 1320Sstevel@tonic-gate md_exit(sp, 0); 133*7044Smk117520 /* NOTREACHED */ 1340Sstevel@tonic-gate return (0); 1350Sstevel@tonic-gate } 136