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 (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
29 * Called by the common layer to request the plugin to call
30 * a client application's callback (pClientFn) when a visibility change
31 * is detected for the given object type.
35 MP_RegisterForObjectVisibilityChangesPlugin(MP_OBJECT_VISIBILITY_FN pClientFn
,
36 MP_OBJECT_TYPE objectType
,
39 MP_BOOL hasFunc
= MP_FALSE
;
42 log(LOG_INFO
, "MP_RegisterForObjectVisibilityChangesPlugin()",
46 /* Validate the object type passes in within range */
47 if (objectType
> MP_OBJECT_TYPE_MAX
) {
49 log(LOG_INFO
, "MP_RegisterForObjectVisibilityChangesPlugin()",
50 " - objectType is invalid");
52 log(LOG_INFO
, "MP_RegisterForObjectVisibilityChangesPlugin()",
55 return (MP_STATUS_INVALID_PARAMETER
);
60 log(LOG_INFO
, "MP_RegisterForObjectVisibilityChangesPlugin()",
61 " - objectType is invalid");
63 log(LOG_INFO
, "MP_RegisterForObjectVisibilityChangesPlugin()",
66 return (MP_STATUS_INVALID_PARAMETER
);
69 /* Init sysevents if they have not been initialized yet */
70 if (g_SysEventHandle
== NULL
) {
71 if (init_sysevents() != MP_STATUS_SUCCESS
)
72 return (MP_STATUS_FAILED
);
75 /* Check to see if we are going to be replacing */
76 (void) pthread_mutex_lock(&g_visa_mutex
);
77 if (g_Visibility_Callback_List
[objectType
].pClientFn
!= NULL
) {
82 /* Add the registration */
83 g_Visibility_Callback_List
[objectType
].pClientFn
= pClientFn
;
84 g_Visibility_Callback_List
[objectType
].pCallerData
= pCallerData
;
85 (void) pthread_mutex_unlock(&g_visa_mutex
);
89 log(LOG_INFO
, "MP_RegisterForObjectVisibilityChangesPlugin()",
90 " - returning MP_STATUS_FN_REPLACED");
92 return (MP_STATUS_FN_REPLACED
);
96 log(LOG_INFO
, "MP_RegisterForObjectVisibilityChangesPlugin()",
99 return (MP_STATUS_SUCCESS
);