dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / mpapi / libmpscsi_vhci / common / MP_EnablePath.c
blob41e66a77ee14e4e4a7328aca7e8add33053b1181
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
27 #include <syslog.h>
28 #include <errno.h>
29 #include <unistd.h>
30 #include <stropts.h>
32 #include "mp_utils.h"
36 * Called by the common layer to request to enable a path
39 MP_STATUS
40 MP_EnablePath(MP_OID oid)
42 mp_iocdata_t mp_ioctl;
44 int ioctlStatus = 0;
46 MP_STATUS mpStatus = MP_STATUS_SUCCESS;
50 log(LOG_INFO, "MP_EnablePath()", " - enter");
53 log(LOG_INFO, "MP_EnablePath()",
54 "oid.objectSequenceNumber = %llx",
55 oid.objectSequenceNumber);
57 if (g_scsi_vhci_fd < 0) {
58 log(LOG_INFO, "MP_EnablePath()",
59 "invalid driver file handle");
60 log(LOG_INFO, "MP_EnablePath()", " - error exit");
61 return (MP_STATUS_FAILED);
64 (void) memset(&mp_ioctl, 0, sizeof (mp_iocdata_t));
66 mp_ioctl.mp_cmd = MP_ENABLE_PATH;
67 mp_ioctl.mp_ibuf = (caddr_t)&oid.objectSequenceNumber;
68 mp_ioctl.mp_ilen = sizeof (oid.objectSequenceNumber);
69 mp_ioctl.mp_xfer = MP_XFER_WRITE;
71 log(LOG_INFO, "MP_EnablePath()",
72 "mp_ioctl.mp_cmd (MP_ENABLE_PATH) : %d",
73 mp_ioctl.mp_cmd);
75 ioctlStatus = ioctl(g_scsi_vhci_fd, MP_CMD, &mp_ioctl);
77 log(LOG_INFO, "MP_EnablePath()",
78 " IOCTL call returned: %d", ioctlStatus);
80 if (ioctlStatus < 0) {
81 ioctlStatus = errno;
84 if (ioctlStatus != 0) {
85 log(LOG_INFO, "MP_EnablePath()",
86 "IOCTL call failed. IOCTL error is: %d",
87 ioctlStatus);
88 log(LOG_INFO, "MP_EnablePath()",
89 "IOCTL call failed. IOCTL error is: %s",
90 strerror(ioctlStatus));
91 log(LOG_INFO, "MP_EnablePath()",
92 "IOCTL call failed. mp_ioctl.mp_errno: %x",
93 mp_ioctl.mp_errno);
95 if (ENOTSUP == ioctlStatus) {
96 mpStatus = MP_STATUS_UNSUPPORTED;
97 } else if (0 == mp_ioctl.mp_errno) {
98 mpStatus = MP_STATUS_FAILED;
99 } else {
100 mpStatus = getStatus4ErrorCode(mp_ioctl.mp_errno);
103 log(LOG_INFO, "MP_EnablePath()",
104 " - error exit");
106 return (mpStatus);
110 log(LOG_INFO, "MP_EnablePath()", " - exit");
112 return (MP_STATUS_SUCCESS);