4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
28 #include <sys/types.h>
35 #include <libscf.h> /* for SMF error exit codes */
37 #include <srpt_ioctl.h>
41 char cmdName
[] = "svc-srpt";
44 main(int argc
, char *argv
[])
47 boolean_t do_enable
= B_FALSE
;
54 (void) setlocale(LC_ALL
, "");
56 if (argc
< 2 || argc
> 2) {
60 if (strcasecmp(argv
[1], "start") == 0) {
62 srpt_ioctl
= SRPT_IOC_ENABLE_SVC
;
63 } else if (strcasecmp(argv
[1], "stop") == 0) {
64 srpt_ioctl
= SRPT_IOC_DISABLE_SVC
;
69 fd
= open(SRPT_NODE
, O_RDONLY
);
73 (void) fprintf(stderr
, "%s: %s (%s): %s\n", cmdName
,
74 gettext("Could not open SRP Target pseudodevice"),
75 SRPT_NODE
, strerror(saverr
));
77 if (saverr
== ENOENT
) {
78 /* avoid having the service go into maintenance */
79 if ((stat("/devices/ib", &statbuf
)) != 0) {
80 (void) fprintf(stderr
, "%s: %s\n", cmdName
,
82 "No InfiniBand devices on this system."));
87 ret
= SMF_EXIT_ERR_FATAL
; /* avoid retries */
90 (void) fprintf(stderr
, "%s: %s\n", cmdName
,
91 gettext("SRPT Driver may not be loaded."));
96 ret
= ioctl(fd
, srpt_ioctl
, NULL
);
99 txt
= gettext("Could not enable SRP Target");
101 txt
= gettext("Could not disable SRP Target");
104 (void) fprintf(stderr
, "%s: %d", txt
, ret
);
105 ret
= SMF_EXIT_ERR_FATAL
;
113 (void) fprintf(stderr
, gettext("Usage: %s start|stop"), cmdName
);
114 (void) fprintf(stderr
, "\n");