1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 /* 30 * mediator status utility. 31 */ 32 33 #include <meta.h> 34 #include <sdssc.h> 35 36 static void 37 usage( 38 mdsetname_t *sp, 39 char *string) 40 { 41 if ((string != NULL) && (*string != '\0')) 42 md_eprintf("%s\n", string); 43 (void) fprintf(stderr, gettext( 44 "usage: %s [-q] -s setname\n"), 45 myname); 46 md_exit(sp, (string == NULL) ? 0 : 1); 47 } 48 49 /* 50 * parse args and do it 51 */ 52 int 53 main( 54 int argc, 55 char *argv[] 56 ) 57 { 58 int c; 59 char *sname = MD_LOCAL_NAME; 60 md_error_t status = mdnullerror; 61 md_error_t *ep = &status; 62 mdsetname_t *sp = NULL; 63 int verbose = 1; 64 65 /* 66 * Get the locale set up before calling any other routines 67 * with messages to ouput. Just in case we're not in a build 68 * environment, make sure that TEXT_DOMAIN gets set to 69 * something. 70 */ 71 #if !defined(TEXT_DOMAIN) 72 #define TEXT_DOMAIN "SYS_TEST" 73 #endif 74 (void) setlocale(LC_ALL, ""); 75 (void) textdomain(TEXT_DOMAIN); 76 77 /* 78 * There is no need to proxy the command to owner of the set 79 * to get the mediator information as the /etc/lvm/meddb file 80 * contains the required information and so it can be used. 81 */ 82 if ((sdssc_bind_library() == SDSSC_ERROR)) { 83 (void) fprintf(stderr, 84 "Failed to initialised libscsds.so.1\n"); 85 exit(1); 86 } 87 88 89 /* initialize */ 90 if (md_init(argc, argv, 0, 1, ep) != 0) { 91 mde_perror(ep, ""); 92 md_exit(sp, 1); 93 } 94 95 optind = 1; 96 opterr = 1; 97 while ((c = getopt(argc, argv, "qs:?")) != -1) { 98 switch (c) { 99 case 'q': 100 verbose = 0; 101 break; 102 case 's': 103 sname = optarg; 104 break; 105 case '?': 106 if (optopt == '?') 107 usage(sp, NULL); 108 /*FALLTHROUGH*/ 109 default: 110 usage(sp, gettext("unknown command")); 111 } 112 } 113 /* must have set for everything else */ 114 if (strcmp(sname, MD_LOCAL_NAME) == 0) 115 usage(sp, gettext("setname must be specified")); 116 117 /* snarf MDDB */ 118 if (meta_setup_db_locations(ep) != 0) { 119 mde_perror(ep, ""); 120 md_exit(sp, 1); 121 } 122 123 /* 124 * Get the mediator information from file 125 * /etc/lvm/meddb and print it. 126 */ 127 128 if (meta_mediator_info_from_file(sname, verbose, ep)) { 129 md_exit(sp, 1); 130 } 131 132 md_exit(sp, 0); 133 /* NOTREACHED */ 134 return (0); 135 } 136