dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / mpapi / libmpscsi_vhci / common / Initialize.c
blobd2a4b3900aa4b07eb5f44572ea6f07165ef845a3
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 (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
26 #include <sys/stat.h>
27 #include <fcntl.h>
28 #include <errno.h>
30 #include "mp_utils.h"
34 * Global Variables
37 MP_UINT32 g_pluginOwnerID = 0;
38 int g_scsi_vhci_fd = -1;
40 PROPERTY_CALLBACK_NODE g_Property_Callback_List[MP_OBJECT_TYPE_MAX + 1];
41 VISIBILITY_CALLBACK_NODE g_Visibility_Callback_List[MP_OBJECT_TYPE_MAX + 1];
43 sysevent_handle_t *g_SysEventHandle = NULL;
45 pthread_mutex_t g_visa_mutex = PTHREAD_MUTEX_INITIALIZER;
46 pthread_mutex_t g_prop_mutex = PTHREAD_MUTEX_INITIALIZER;
49 * Called by the common layer to request the plugin to initialize
50 * itself.
53 MP_STATUS
54 Initialize(MP_UINT32 pluginOwnerID)
56 log(LOG_INFO, "Initialize()", " - enter");
59 (void) memset(&g_Property_Callback_List, 0,
60 sizeof (PROPERTY_CALLBACK_NODE) * (MP_OBJECT_TYPE_MAX + 1));
62 (void) memset(&g_Visibility_Callback_List, 0,
63 sizeof (VISIBILITY_CALLBACK_NODE) * (MP_OBJECT_TYPE_MAX + 1));
65 /* Attempt to open the driver that this plugin will make request of. */
66 g_scsi_vhci_fd = open("/devices/scsi_vhci:devctl",
67 O_NDELAY | O_RDONLY);
69 if (g_scsi_vhci_fd < 0) {
70 log(LOG_INFO, "Initialize()",
71 " - failed to open driver. error is : %s",
72 strerror(errno));
73 log(LOG_INFO, "Initialize()", " - error exit");
74 return (MP_STATUS_FAILED);
77 g_pluginOwnerID = pluginOwnerID;
79 log(LOG_INFO, "Initialize()", " - exit");
81 return (MP_STATUS_SUCCESS);