1 /* 2 * CDDL HEADER START 3 * 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. 7 * 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. 12 * 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] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. 23 */ 24 25 26 #include <sys/stat.h> 27 #include <fcntl.h> 28 #include <errno.h> 29 30 #include "mp_utils.h" 31 32 33 /* 34 * Global Variables 35 */ 36 37 MP_UINT32 g_pluginOwnerID = 0; 38 int g_scsi_vhci_fd = -1; 39 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]; 42 43 sysevent_handle_t *g_SysEventHandle = NULL; 44 45 pthread_mutex_t g_visa_mutex = PTHREAD_MUTEX_INITIALIZER; 46 pthread_mutex_t g_prop_mutex = PTHREAD_MUTEX_INITIALIZER; 47 48 /* 49 * Called by the common layer to request the plugin to initialize 50 * itself. 51 */ 52 53 MP_STATUS 54 Initialize(MP_UINT32 pluginOwnerID) 55 { 56 log(LOG_INFO, "Initialize()", " - enter"); 57 58 59 (void) memset(&g_Property_Callback_List, 0, 60 sizeof (PROPERTY_CALLBACK_NODE) * (MP_OBJECT_TYPE_MAX + 1)); 61 62 (void) memset(&g_Visibility_Callback_List, 0, 63 sizeof (VISIBILITY_CALLBACK_NODE) * (MP_OBJECT_TYPE_MAX + 1)); 64 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); 68 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); 75 } 76 77 g_pluginOwnerID = pluginOwnerID; 78 79 log(LOG_INFO, "Initialize()", " - exit"); 80 81 return (MP_STATUS_SUCCESS); 82 } 83