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
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.
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]
24 * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
28 * Copyright (c) 1998 by Sun Microsystems, Inc.
29 * All rights reserved.
38 #include <sys/cladm.h>
40 #if !defined(TEXT_DOMAIN) /* should be defined by cc -D */
41 #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it wasn't */
46 static void errmsg(char *);
50 main(int argc
, char **argv
)
56 (void) setlocale(LC_ALL
, "");
57 (void) textdomain(TEXT_DOMAIN
);
59 cmdname
= argv
[0]; /* put actual command name in messages */
61 if (_cladm(CL_INITIALIZE
, CL_GET_BOOTFLAG
, &bootflags
) != 0) {
62 errmsg("_cladm(CL_INITIALIZE, CL_GET_BOOTFLAG)");
66 while ((c
= getopt(argc
, argv
, "bnh")) != EOF
) {
68 case 'b': /* print boot flags */
69 (void) printf("%s%u\n", cp
, bootflags
);
72 case 'n': /* print our node number */
73 if (_cladm(CL_CONFIG
, CL_NODEID
, &nid
) != 0) {
74 errmsg("node is not configured as part of a "
78 (void) printf("%s%u\n", cp
, nid
);
81 case 'h': /* print the highest node number */
82 if (_cladm(CL_CONFIG
, CL_HIGHEST_NODEID
, &hid
) != 0) {
83 errmsg("node is not booted as part of a "
87 (void) printf("%s%u\n", cp
, hid
);
98 * Return exit status of one (error) if not booted as a cluster.
100 return (bootflags
& CLUSTER_BOOTED
? 0 : 1);
108 save_error
= errno
; /* in case fprintf changes errno */
109 (void) fprintf(stderr
, "%s: ", cmdname
);
117 (void) fprintf(stderr
, "%s: %s -[bnh]\n", gettext("usage"), cmdname
);