dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / mpapi / libmpapi / common / mpapi-sun.c
blob52ac002e85e4a4b8836112e8131b084d8df2dee4
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 * Description
28 * mpapi-sun.c - Implements the Sun Extension to the Multipath Management
29 * API Version 1.0
32 #include <dlfcn.h>
33 #include <pthread.h>
34 #include "mpapi.h"
35 #include "mpapi-sun.h"
36 #include "mpapi-plugin.h"
38 extern MPPLUGININFO_T plugintable[MP_MAX_NUM_PLUGINS];
40 extern pthread_mutex_t mp_lib_mutex;
41 extern MP_STATUS validate_object(MP_OID obj, MP_OBJECT_TYPE objType,
42 MP_UINT32 flag);
44 MP_STATUS Sun_MP_SendScsiCmd(
45 MP_OID pathOid, struct uscsi_cmd *cmd)
47 Sun_MP_SendScsiCmdFn PassFunc;
48 MP_UINT32 index;
49 MP_STATUS status;
51 if ((status = validate_object(pathOid, MP_OBJECT_TYPE_PATH_LU,
52 MP_OBJECT_TYPE_MATCH)) != MP_STATUS_SUCCESS) {
53 return (status);
56 (void) pthread_mutex_lock(&mp_lib_mutex);
58 index = pathOid.ownerId - 1;
59 if (plugintable[index].hdlPlugin != NULL) {
60 PassFunc = (Sun_MP_SendScsiCmdFn)
61 dlsym(plugintable[index].hdlPlugin,
62 "Sun_MP_SendScsiCmd");
64 if (PassFunc != NULL) {
65 status = PassFunc(pathOid, cmd);
66 } else {
67 status = MP_STATUS_UNSUPPORTED;
69 } else {
70 status = MP_STATUS_FAILED;
73 (void) pthread_mutex_unlock(&mp_lib_mutex);
74 return (status);