2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 2N/A * Allocate a handle structure 2N/A/* free handle structure */ 2N/A * Operations which require daemon processing 2N/A/* get registration and DR information from rcm_daemon */ 2N/A * rsrcname may be NULL if requesting dr operations or modinfo 2N/A/* get registration and DR information from rcm_daemon (list version) */ 2N/A /* Requesting the current DR operations with a *list() is invalid */ 2N/A/* request to offline a resource before DR removal */ 2N/A/* request to offline a resource before DR removal (list version) */ 2N/A/* cancel offline request and allow apps to use rsrcname */ 2N/A/* cancel offline and allow apps to use resources (list version) */ 2N/A/* notify that rsrcname has been removed */ 2N/A/* notify that resrouces have been removed (list form) */ 2N/A/* request for permission to suspend resource of interval time */ 2N/A/* request for permission to suspend resource of interval time (list form) */ 2N/A/* notify apps of the completion of resource suspension */ 2N/A/* notify apps of the completion of resource suspension (list form) */ 2N/A/* request a capacity change from apps */ 2N/A/* notify apps of a capacity change */ 2N/A/* notify apps of an event */ 2N/A /* No flags are defined yet for rcm_notify_event() */ 2N/A * Register to receive capacity changes. This requires a module to exist in 2N/A * module directory. It should be called prior to using a new resource. 2N/A/* unregister interest in capacity changes */ 2N/A * Register to receive events. This requires a module to exist in module 2N/A * directory. It should be called prior to using a new resource. 2N/A/* unregister interest in events */ 2N/A * Register interest in a resource. This requires a module to exist in module 2N/A * directory. It should be called prior to using a new resource. 2N/A * Registration may be denied if it is presently locked by a DR operation. 2N/A/* unregister interest in rsrcname */ 2N/A/* get the current state of a resource */ 2N/A * A successful result implies the presence of exactly one RCM info 2N/A * tuple containing the state of this resource (a combination of each 2N/A * client's resources). If that's not true, change the result to 2N/A * RCM helper functions exposed to librcm callers. 2N/A/* Free linked list of registration info */ 2N/A/* return the next tuple in the info structure */ 2N/A/* return resource name */ 2N/A/* return info string in the tuple */ 2N/A/* return client pid in the tuple */ 2N/A/* return client state in the tuple */ 2N/A/* return the generic properties in the tuple */ 2N/A * return operation sequence number 2N/A * This is private. Called by rcmctl only for testing purposes. 2N/A * The following interfaces are PRIVATE to the RCM framework. They are not 2N/A * declared static because they are called by rcm_daemon. 2N/A * Invoke shell to execute command in MT safe manner. 2N/A * Returns wait status or -1 on error. 2N/A/* Append info at the very end */ 2N/A/* get rcm module and rcm script directory names */ 2N/A * construct the module directory names 2N/A "invalid module or script directory for " 2N/A "invalid module or script directory for " 2N/A "invalid module or script generic directory\n"));
2N/A * Find the directory where the script is located. 2N/A * If the script is found return a pointer to the directory where the 2N/A * script was found otherwise return NULL. 2N/A * Returns 1 if the filename is an rcm script. 2N/A * Returns 0 if the filename is an rcm module. 2N/A/* Locate the module and call dlopen */ 2N/A * stub implementation of rcm_log_message allows dlopen of rcm modules 2N/A * to proceed in absence of rcm_daemon. 2N/A * This definition is interposed by the definition in rcm_daemon because of the 2N/A * default search order implemented by the linker and dlsym(). All RCM modules 2N/A * will see the daemon version when loaded by the rcm_daemon. 2N/A * Common routine for all rcm calls which require daemon processing 2N/A * Check if handle is allocated by rcm_daemon. If so, this call came 2N/A * from an RCM module, so we make a direct call into rcm_daemon. 2N/A * When not called from a RCM module (i.e. no recursion), zero the 2N/A * pointer just in case caller did not do so. For recursive calls, 2N/A * we want to append rcm_info_t after infop; zero it may cause 2N/A * Now call into the daemon. 2N/A * Caller is an RCM module, call directly into rcm_daemon. 2N/A * Call into rcm_daemon door to process the request 2N/A * Decide whether to start the daemon 2N/A * Generate a packed nvlist for the request 2N/A * Make the door call and get a return event. We go into a retry loop 2N/A * when RCM_ET_EAGAIN is returned. 2N/A * nvlist_lookup_* routines don't work because the returned nvlist 2N/A * was nvlist_alloc'ed without the NV_UNIQUE_NAME flag. Implement 2N/A * a sequential search manually, which is fine since there is only 2N/A * one RCM_RESULT value in the nvlist. 2N/A * The door call succeeded. Now extract info from returned event. 2N/A * Extract registration info from event data. 2N/A * Return 0 on success and -1 on failure. 2N/A/* Generate a packed nvlist for communicating with RCM daemon */ 2N/A /* Allocate an empty nvlist */ 2N/A /* Stuff in all the arguments for the daemon call */ 2N/A "failed (nvlist_add(CLIENT_MODNAME)=%s).\n",
2N/A "failed (nvlist_add(REQUEST_FLAG)=%s).\n",
2N/A "failed (nvlist_add(SUSPEND_INTERVAL)=%s).\n",
2N/A "failed (nvlist_pack(CHANGE_DATA)=%s).\n",
2N/A "failed (nvlist_add(CHANGE_DATA)=%s).\n",
2N/A "failed (nvlist_pack(CHANGE_DATA)=%s).\n",
2N/A "failed (nvlist_add(EVENT_DATA)=%s).\n",
2N/A /* Pack the nvlist */ 2N/A /* If an argument was packed intermediately, free the buffer */ 2N/A /* Free the unpacked version of the nvlist and return the packed list */ 2N/A/* check if rcm_daemon is up and running */ 2N/A /* generate a packed nvlist for the door knocking */ 2N/A * check the door and knock on it 2N/A return (
1);
/* daemon is alive */ 2N/A * Attempt to start the daemon. 2N/A * If caller has SIGCHLD set to SIG_IGN or its SA_NOCLDWAIT 2N/A * flag set, waitpid(2) (hence rcm_exec_cmd) will fail. 2N/A * get_event_service will determine if the rcm_daemon started. 2N/A * Wait for daemon to respond, timeout at 10 sec 2N/A * The policy is root only for now. Need to relax this when interface level 2N/A * Project private function - for use by RCM MSTC tests 2N/A * Get the client name (rcm module name or script name) corresponding to 2N/A * the given rcm handle.