watcher.c revision cee0fb94c0d4227de0a00efc162fb2739844b641
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <limits.h>
#include <sys/resource.h>
#include <syslog.h>
#include <signal.h>
#include <unistd.h>
#include <stropts.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <dmd_impl.h>
#include <mms_list.h>
#include <mms_network.h>
#include "mms_parser.h"
#include <mms_trace.h>
#include <netdb.h>
#include <watcher_impl.h>
#include <dirent.h>
#include <procfs.h>
#include <libscf.h>
#include <libcontract.h>
#include <host_ident.h>
#include <mms_cores.h>
#include <mms_cfg.h>
#include <net_cfg_service.h>
#include <mms_strapp.h>
int wcr_debug = MMS_SEV_DEVP;
/*
* wcr_free_DM_LM
*
* Parameters:
* - DM_LM : ptr to wcr_DM_LM_t
*
* Free's memory inside a wcr_DM_LM_t
* sets ptrs = NULL
* caller should free struct itself if desired
*
* Return Values:
* none
*/
void
{
if (DM_LM_dev->
wcr_DM_name != NULL) {
wcr_DM_name = NULL;
}
if (DM_LM_dev->
wcr_drive_name != NULL) {
}
if (DM_LM_dev->
wcr_host_name != NULL) {
}
if (DM_LM_dev->
wcr_dev_tar_path != NULL) {
}
if (DM_LM_dev->
wcr_disabled != NULL) {
wcr_disabled = NULL;
}
if (DM_LM_dev->
wcr_LM_name != NULL) {
wcr_LM_name = NULL;
}
if (DM_LM_dev->
wcr_library_name != NULL) {
}
if (DM_LM_dev->
wcr_dev_mgr_path != NULL) {
}
}
/*
* wcr_alloc_DM_LM
*
* Parameters:
* none
*
* allocate a new wcr_DM_LM_t struct
* initialize all pointers
*
* Return Values:
* NULL : if alloc failed
* ptr to new wcr_DM_LM_t : if alloc is successful
*
*/
{
"Unable to mallor wcr_DM_LM_t: %s",
return (NULL);
}
/* Initialize pointers */
wcr_DM_name = NULL;
wcr_disabled = NULL;
wcr_LM_name = NULL;
return (DM_LM_dev);
}
/*
* wcr_ssi_is_running()
* checks to see if ssi process (prog) with owner (user) is running
* returns true if the process is running, false if it is not.
* passes back the pid of the running process
*/
int
{
int psdata;
psinfo_t p;
char *fullpath;
char *ssiarg;
char *argcpy;
int i;
"wcr_ssi_is_running: "
"check if %s is running on port %d",
return (0);
}
/* Look for the ssi process psinfo file */
continue;
else {
fullpath =
/* ssi found, get the ssi's port */
for (i = 0; i < 2; i++)
return (1);
}
}
}
}
/* ssi wasn't found running on the port */
"didn't find a ssi running");
return (0);
}
/*
* Initialize message logging.
*/
static void
{
}
}
/*
* wcr_init_wka()
* -Initializes the watcher's work area.
* -Creates 2 lists, 1 list of wcr_dev type
* and 1 list of wcr_wka_DM_LM type
* -Saves the first device ordinal
* -Saves the host name of this watcher's host
*/
void
{
}
void
{
}
}
}
/*
* Read watcher network configuration file
*/
int
{
char *p = NULL;
char *q = NULL;
return (1);
}
while (p != NULL) {
if (q = strchr(p, ',')) {
*q = '\0';
}
p = q;
if (p != NULL) {
p++;
}
}
return (0);
}
/*
* Initialize the watcher
* This requires that the driver dmd must have been properly installed.
* The config file dmd.conf has only one entry for instance 0.
* -Makes call to initialize the watcher's workarea
* -Fork and exit from parent to become daemon
* -Fill in wka_net_cfg struct with values from watcher's
* network config file
* -Open the watcher device
*/
int
{
int fd;
int mms_trace_fd;
int i;
char ebuf[MMS_EBUF_LEN];
char *corename;
/*
* Init work area
*/
/*
* Init message logging
*/
wcr_init_log();
/*
* Cores dir
*/
}
/* Check to see how many core files exist */
"wcr_init_watcher: mms_man_cores failed %s",
}
/*
* Read config before becoming smf daemon
*/
}
/*
* Become a smf daemon
*/
/*
* Parent process
*/
exit(1);
} else {
/* Successfully forked, parent exits */
exit(0);
}
}
/*
* In child.
*/
/*
* Close all opened files except mms_trace
*/
for (i = 0; i < OPEN_MAX; i++) {
if (i != mms_trace_fd)
close(i);
}
/*
* Become session leader
*/
setsid();
/*
* Clear file mode create mask
*/
umask(0);
/*
* Open the watcher device
*/
if (fd < 0) {
return (1);
} else {
return (1);
}
}
#ifdef MMS_OPENSSL
return (1);
}
#endif /* MMS_OPENSSL */
return (0);
}
/*
* Initiate a session with MMS
* -Use mms_mmconnect to connect a mm from a mm list
* -Store the file descriptor
*/
int
{
int err;
/* Get first mm from list */
exit(1);
}
/* Connect to MM */
wka->wcr_connected = 0;
while (!wka->wcr_connected) {
if (wka->wcr_wka_sighup) {
return (1);
}
"to %s MM: (%d) %s",
err,
wka->wcr_mms_ebuf);
/* Get next mm from list */
/* Reached end of mm list, start over */
}
sleep(2);
} else {
}
}
return (0);
}
void
/* LINTED: wka may be used in the future */
{
value) {
if (strcmp("DMName",
/* mms_trace(MMS_NOTICE,"*SET DMName*\n"); */
1;
}
if (strcmp("DriveName",
/* mms_trace(MMS_NOTICE, "*SET DriveName*\n"); */
}
if (strcmp("DMTargetHost",
/* mms_trace(MMS_NOTICE, "*SET Hostname*\n"); */
}
if (strcmp("DMTargetPath",
/* mms_trace(MMS_NOTICE, "*SET Path*\n"); */
}
if (strcmp("DMDisabled",
/* mms_trace(MMS_NOTICE, "*SET DMDisabled*\n"); */
}
if (strcmp("LMName",
/* mms_trace(MMS_NOTICE, "*SET LMName*\n"); */
0;
}
if (strcmp("LMTargetHost",
/* mms_trace(MMS_NOTICE, "*SET Hostname*\n"); */
}
if (strcmp("LibraryName",
/* mms_trace(MMS_NOTICE, "*SET LibraryName*\n"); */
}
if (strcmp("LMDisabled",
/* mms_trace(MMS_NOTICE, "*SET LMDisabled*\n"); */
}
}
}
/*
* wcr_attrlist()
* -This function takes a parsed node tree of the attrlist portion of a
* resonse from MM and adds the correct struct obj to the
* wcr_wka_DM_LM_list in the watcher work area
*/
void
{
tw = 0;
MMS_PN_CLAUSE, &work);
MMS_PN_CLAUSE, &work)) {
/* Create a new list node */
#if 1
DM_LM_dev = wcr_alloc_DM_LM();
"Unable to mallor wcr_DM_LM_t: %s",
return;
}
#else
"Unable to mallor wcr_DM_LM_t: %s",
}
#endif
/* end of list create */
} else {
DM_LM_dev->wcr_del_pending = 0;
}
}
}
}
/*
* wcr_create_list
* -takes in a "success" response in xml, creates a parse node tree
* and passes the tree to wcr_attrlist to perform the actall list creation
*/
int
{
int rc;
"line %d, col %d, near token \"%s\", err code %d, %s\n",
}
if (rc) {
return (MMS_ERROR);
}
}
MMS_PN_KEYWORD, 0) != NULL) {
rc = UNACCEPTABLE;
MMS_PN_KEYWORD, 0) != NULL) {
} else {
}
return (rc);
}
/*
* wcr_indent
* -subroutine used to add "level" number of tabs to the file pointed at
* by fp
*/
void
{
int i;
for (i = 0; i < level; i++) {
}
}
/*
* wcr_write_DM_cfg
* -this function performs the actual writing of a DM's config file
* -It takes in a single DM_LM_dev object, opens a file and writes the
* config information
* -files are named by the instance name followed by "_cfg.xml"
* (ex. dm1_cfg.xml)
*/
void
{
char *cfg_file_name = NULL;
}
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n");
"<!-- DM Configuration -->\n");
if (welcome) {
}
}
}
}
}
}
}
} else {
}
}
/*
* wcr_write_LM_cfg
* -this function performs the actual writing of a LM's config file
* -It takes in a single DM_LM_dev object, opens a file and writes the
* config information
* -files are named by the instance name followed by "_cfg.xml"
* (ex. lm1_cfg.xml)
*/
void
{
char *cfg_file_name = NULL;
}
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n");
"<!-- LM Configuration -->\n");
if (welcome) {
}
}
}
}
}
}
}
} else {
}
}
/*
* wcr_write_cfg
* -takes in the watcher's workarea
* -calls the approperate config write function
*/
int
{
if (DM_LM_dev->wcr_DM_flag) {
} else {
}
}
return (0);
}
void
char *old_inst_name = NULL;
char *new_inst_name = NULL;
int debug = 0;
MMS_PN_CMD, 0) != NULL) {
if (debug) {
MMS_PN_CLAUSE, 0);
if (arg) {
if (debug) {
}
&work))) {
if (debug) {
}
NULL,
&work))) {
if (debug) {
}
== 0) {
&work)) {
if (debug) {
" new instance %s",
}
NULL,
&work))) {
if (debug) {
" old instance %s",
}
&work))) {
if (debug) {
}
}
if (event_struct == NULL) {
"Unable to malloc wcr_event_t: %s",
}
if (old_inst_name != NULL) {
sizeof (event_struct->wcr_old_inst_name)); }
if (new_inst_name != NULL) {
sizeof (event_struct->wcr_new_inst_name)); }
sizeof (event_struct->wcr_type)); }
sizeof (event_struct->wcr_object)); }
sizeof (event_struct->wcr_inst_name)); }
event_struct->wcr_done = 0;
}
/*
* wcr_send_cmd
* -Takes a command string to send to MM and the watcher's work area
* -Coverts the command to xml
* -sends the command to MM using MM's filedescriptor and mms_writer
* -reads the response from MM using mms_reader
* -returns the second protion of the response ("success" half)
*/
char *
{
int len;
int go = 1;
int rc;
"Write cmd failed: %s, %s",
return (NULL);
}
while (go) {
" Read cmd response failed: %s, %s",
return (NULL);
}
"line %d, col %d, near token \"%s\", "\
"err code %d, %s\n",
}
if (rc) {
return (NULL);
}
MMS_PN_CMD, 0) != NULL) {
continue;
}
if (mms_pn_lookup(cmd,
"response", MMS_PN_CMD, 0)
== NULL) {
"Error- no command response to show: %s",
return (NULL);
}
if (mms_pn_lookup(cmd,
} else if (mms_pn_lookup(cmd,
go = 0;
}
}
return (rsp);
}
/*
* wcr_get_config
* -takes in the watcher's workarea
* -creates a linked list of all DM and LM that are to be running
* on this watcher's host
*/
int
{
int num_dev = 0;
/* generate show command for current WD host */
/* For DM's */
"Error sending show command");
return (1);
}
"wcr_get_config: "
"internal error creating wka list");
}
num_dev ++;
}
/* For LM's */
return (1);
}
"wcr_get_config: "
"internal error creating wka list");
}
return (0);
}
/* Free a single net lm */
/* caller needs to free net_lm itself */
void
if (net_LM->wcr_lm_name)
}
/* Free all net_LM in the list */
void
cur_net_LM != NULL;
cur_net_LM = next_net_LM) {
cur_net_LM = NULL;
}
}
/*
* wcr_set_ssi:
* either insert this net_LM in the list
* or set an existing net_LM in the list
* to the values in the new net_LM
*/
int
/* Check list to see if there is already a */
/* net_LM for this lm */
/* If so, set the ssi info on that and free net_LM */
cur_net_LM) {
net_LM->wcr_lm_name) == 0) {
/* already have this LM */
return (1);
}
}
net_LM);
return (0);
}
/*
* wcr_check_ssi
* looks at the current ssi list,
* if 2 lm's are set to use the same
* ssi port, but have different libraryip's
* send a message and return error
*/
int
if ((cur_net_LM->wcr_ssi_port ==
net_LM->wcr_ssi_port) &&
net_LM->wcr_ssi_host) != 0)) {
/* same ssi port and different hosts */
"wcr_check_ssi: "
"Conflicting ssi configuration, "
"same ssi port but different hosts: "
"%s %d %s , %s %d %s",
/* Send message 8000 */
/* generate show command for current WD host */
/* Send MMP command to MM */
== NULL) {
"Error sending ssi error message");
} else {
}
return (1);
}
}
return (0);
}
/*
* wcr_get_ssi
* -takes in the watcher's workarea
* -obtains the acsls's servers hostname from MM
* -if lm_name is NULL get ssi for the whole host
* -else get ssi info for just that lm
*/
/* ARGSUSED */
int
{
/* Get SSI infor for this host */
/* There may be more than one LM */
int rc;
char *cur_lmname = NULL;
char *cur_libraryip = NULL;
char *cur_acslsport = NULL;
char *cur_ssiport = NULL;
/* generate show command for current WD host */
/* Get SSI for all LM's */
/* delete the SSI list */
wka->wcr_host_name);
} else {
}
/* Send MMP command to MM */
"Error sending lm ssi show command");
return (1);
}
/* Parse the response */
"line %d, col %d, near token \"%s\", err code %d, %s\n",
}
if (rc) {
return (1);
}
/* Check for success */
return (1);
}
/* For each text returned, create a wcr_net_LM struct */
/* If there is already an existing wcr_net_LM with the same info */
/* Don't make a duplicate */
if (cur_lmname)
if (cur_libraryip)
if (cur_acslsport)
if (cur_ssiport)
cur_lmname = NULL;
cur_ssiport = NULL;
/* Get LMName */
"wcr_get_ssi: "
"unable to find LMName in response");
continue;
}
"wcr_get_ssi: "
"unable to find LMName in response");
continue;
}
/* Get LibraryIP */
"wcr_get_ssi: "
"unable to find LibraryIP in response");
continue;
}
"wcr_get_ssi: "
"unable to find LibraryIP in response");
continue;
}
/* Get LibraryACSLSPort */
"wcr_get_ssi: "
"unable to find LibraryACSLSPort in response");
continue;
}
"wcr_get_ssi: "
"unable to find LibraryACSLSPort in response");
continue;
}
/* Get LMSSIPort */
"wcr_get_ssi: "
"unable to find LMSSIPort in response");
continue;
}
"wcr_get_ssi: "
"unable to find LMSSIPort in response");
continue;
}
if ((cur_lmname == NULL) ||
(cur_libraryip == NULL) ||
(cur_acslsport == NULL) ||
(cur_ssiport == NULL)) {
"wcr_get_ssi: "
"info from MM");
continue;
}
"wcr_get_ssi:"
"ssi needed for %s, acsls ip=%s, acsls port=%s,"
" ssi port=%s",
/* Allocate a new struct for this ssi info */
"wcr_get_ssi: "
"unable to calloc net_LM");
continue;
}
/* Set values in net_LM */
} else {
}
cur_lmname = NULL;
/* insert net_LM into the list */
/* Before insert check if this host already has an */
/* ssi setup to run on cur_ssiport */
/* If yes, send a message to MM indicating an incorrect */
/* configuration */
"wcr_get_ssi: "
"incorrect ssi configuration, "
"do not attempt to start this ssi");
} else {
/* already had this net_LM */
}
}
}
/* Clean up memory */
if (cur_lmname)
if (cur_libraryip)
if (cur_acslsport)
if (cur_ssiport)
cur_lmname = NULL;
cur_ssiport = NULL;
"wcr_get_ssi:"
"finished getting ssi info");
return (0);
}
/*
* Configure drive and library managers
* wcr_config()
* -Takes in the a watcher's workarea
* -creates a list of wcr_dev type that will be used to start DMs
* -writes config files for every DM and LM that is to be running
* on this watcher 's host
*/
int
{
/*
* Configure devices
*/
if (DM_LM_dev->wcr_DM_flag) {
/*
* Verify the target device exists
*/
wka->wcr_wka_next_ordinal) < 0) {
"Unable to add device %s, ordinal %d",
}
/* dv->wcr_dev_flags |= WCR_DEV_START; */
}
}
/* Write the DM and LM config info to file */
if (wcr_write_cfg(wka)) {
exit(1);
}
return (0);
}
void
{
int rc;
/*
* Setup separate contract for forked process
*/
return;
}
goto prefork_error;
}
CT_PR_EV_HWERR)) {
goto prefork_error;
}
goto prefork_error;
}
goto prefork_error;
}
}
goto prefork_error;
}
return;
}
void
{
int rc;
/*
* Clear contract
*/
return;
}
}
}
void
{
int rc;
int fd;
/*
* Abandon forked process contract
*/
return;
}
}
if (pid == -1) {
return;
}
return;
}
return;
}
return;
}
}
}
/*
* wcr_exec_dm
* -This perfoms the fork and exec operations necessary to start a DM
* -It takes in the watcher work area and a wcr_dev_t dv on the DM to
* start
*/
void
{
/* Fork error */
return;
} else {
/* In parent. Save dm's pid */
}
} else {
/*
* In child process.
* Close the watcher device.
*/
/*
*/
WCR_DEV_MGR_PROG, "mmsdm");
cfg_name, (char *)0)) {
cmd_name);
exit(-1);
}
}
}
void
{
/* Fork error */
return;
} else {
/* In parent. Save lm's pid */
}
} else {
/*
* In child process.
* Close the watcher device.
*/
/*
*/
WCR_DEV_MGR_PROG, "mmslm");
cfg_name, (char *)0)) {
cmd_name);
exit(-1);
}
}
}
void
{
char *env_acs_hostname = NULL;
char *env_ssi_port = NULL;
char *env_acsls_port = NULL;
char *env_ssi_path = NULL;
int proc;
int ssi_port = 0;
/* Get SSI path from smf */
/* report service configuration repoistory scf_error() */
}
"wcr_exec_ssi: "
"ssi for %s, acsls ip=%s, acsls port=%d,"
" ssi port=%d, ssi path=%s",
ssi_path);
wka->wcr_host_name);
return;
}
net_LM->wcr_ssi_port)) {
"already running from previous start: "
"pid = %d, port=%d", proc,
} else {
"but is already running: "
"pid = %d, port=%d",
}
return;
}
/* Set ACSLS Server Host */
"CSI_HOSTNAME = %s",
"CSI_HOSTNAME=%s",
/* Set ACSLS Server port */
"CSI_HOSTPORT = %d",
"CSI_HOSTPORT=%d",
} else {
"ACSLS server port not set, "
"ssi will use default "
"from portmapper");
}
/* Get the ACLS port number from MM */
/* Pass the port number as an argument to t_ssi.sh */
if (ssi_port == 0) {
"wcr_exec_ssi: "
"unable to get acsls port number from MM, "
"trying default port, 50004");
ssi_port = 50004;
}
/* Set the SSI port */
"ACSAPI_SSI_SOCKET = %d", ssi_port);
"ACSAPI_SSI_SOCKET=%d", ssi_port);
/* Set path to ssi binary */
"MMS_SSI_PATH = %s",
ssi_path);
"MMS_SSI_PATH=%s",
ssi_path);
if (env_ssi_path != NULL)
if (env_ssi_port != NULL)
if (env_acsls_port != NULL)
if (env_acs_hostname != NULL)
/* Fork error */
return;
} else {
/* In parent. Save ssi's pid */
}
} else {
/*
* In child process.
* Close the watcher device.
*/
/*
* Exec the SSI daemon
*/
/* Can't exec the ssi manager */
cmd_name);
if (env_ssi_path != NULL)
if (env_ssi_port != NULL)
if (env_acsls_port != NULL)
if (env_acs_hostname != NULL)
exit(-1);
}
if (env_ssi_path != NULL)
if (env_ssi_port != NULL)
if (env_acsls_port != NULL)
if (env_acs_hostname != NULL)
}
}
void
}
}
void
net_LM->wcr_lm_name) == 0) {
return;
}
}
"wcr_exec_one_ssi: "
"coudln't find SSI info for %s"
" check configuration",
lm_name);
}
void
{
if (DM_LM_dev->wcr_DM_flag) {
} else {
}
}
void
{
}
}
/*
* wcr_sigchld
* -Counts the number of SIGCHILD signals caught
*/
void
/* LINTED: may be used in future */
{
/*
*/
}
/*
* wcr_sighup
* -Counts the number of SIGHUP signals caught
*/
void
/* LINTED: may be used in future */
{
/*
* Service configuration change
*/
}
/* ARGSUSED */
void
{
/*
* Service configuration change
*/
exit(0);
}
/*
* wcr_signal
* -signal handler function
*/
void
{
/*
* Setup to catch signals
*/
/*
* Allow alarm signal to interrupt
*/
}
exit(1);
}
}
/*
* wcr_setup_sig_handler
* -sets up the signal handler function
*/
void
{
/*
* Setup SIG_CHLD and SIGHUP handlers
*/
}
void
break;
}
}
if (DM_LM_dev->wcr_DM_flag) {
} else {
}
}
int
{
if (DM_LM_dev->wcr_DM_flag) {
wcr_DM.wcr_DM_name) == 0) {
return (1);
}
wcr_LM.wcr_LM_name) == 0) {
return (1);
}
}
return (0);
}
void
{
char *libraryname = NULL;
int printone = 0;
printone = 1;
if (DM_LM_dev->wcr_DM_flag) {
" DM, %s %s",
} else {
" LM, %s %s",
}
}
if (!printone) {
}
}
/*
* wcr_get_dev_number()
* returns the next available device number, used for DM
* (pigeon hole problem)
*/
int
{
int number_of_dev = 0;
int match = 0;
int use = 0;
int i;
number_of_dev ++;
}
match = 0;
if (i == LM_DM->
match = 1;
}
}
if (!match) {
use = i;
return (use);
}
}
return (-1);
}
/*
* wcr-is_LM_DM_disabled()
*/
int
{
int rc;
int found;
int disabled;
if (rc) {
return (0);
}
found = 0;
MMS_PN_CLAUSE, &work);
MMS_PN_CLAUSE, &work)) {
disabled = 0;
value) {
if (strcmp("DMName",
found = 1;
}
} else if (strcmp("LMName",
found = 1;
}
} else if (strcmp("DMDisabled",
} else if (strcmp("LMDisabled",
}
}
}
}
return (1);
}
return (0);
}
/*
* wcr-new_event()
* -Need to start process for the new object
*/
void
{
int num_dev = 1;
int rc;
/* make sure object is not already in the list */
return;
}
/* Generate the correct show command */
wka->wcr_host_name);
}
wka->wcr_host_name);
} else {
"Unknown type of New Event %s - %s not added",
return;
}
/* send the show command and add the new dev to the list */
"Error sending command");
return;
}
/* mms_trace(MMS_NOTICE, "response- %s", response); */
/* select the new device and exec its binary */
return;
}
return;
}
/*
* Check if new dev is LM or DM,
* If LM, write cfg file and exec
* If DM, set up dev path, write cfg, and exec
*/
if (!cur_LM_DM->wcr_DM_flag) {
/* check to see if SSI needs to be started */
"Error getting ssi hostname");
} else {
}
/* It is an LM */
return;
}
if (cur_LM_DM->
wcr_dev_mgr_path != NULL) {
}
num_dev) < 0) {
num_dev);
}
/* dv->wcr_dev_flags |= WCR_DEV_START; */
= num_dev;
}
void
break;
}
}
if (DM_LM_dev->wcr_DM_flag) {
type = "DM";
} else {
type = "LM";
}
/* mms_list_remove(&wka->wcr_wka_DM_LM_list, DM_LM_dev); */
}
/*
* wcr_del_event()
*/
void
/* LINTED: type may be used later */
{
return;
}
}
/*
* wcr_disable_event()
*/
void
/* LINTED: type may be used later */
{
return;
}
}
/*
* wcr_compare()
*/
int
{
int changed = 0;
if (LM_DM_1->wcr_DM_flag) {
/* Compare DM attributes */
wcr_DM.wcr_DM_name) != 0) {
changed = 1;
wcr_DM.wcr_dev_tar_path) != 0) {
changed = 1;
wcr_DM.wcr_drive_name) != 0) {
changed = 1;
}
} else {
/* Compare LM attributes */
wcr_LM.wcr_LM_name) != 0) {
changed = 1;
wcr_LM.wcr_library_name) != 0) {
changed = 1;
}
}
return (changed);
}
/*
* wcr_change_event()
* -Need to write a new config file
*/
void
{
int rc;
int changed = 0;
/*
* and has been removed from the active list
* this is likley due to an inncorrect user configuration
* call new event with the new name to re-config and start
*/
" to change in active list",
old_name);
return;
}
wka->wcr_host_name);
wka->wcr_host_name);
} else {
"Unknown type of change Event %s - %s not added",
return;
}
/* send the show command and add the new dev to the list */
"Error sending command");
return;
}
/* mms_trace(MMS_NOTICE, "response is %s", response); */
/* Malloc memory for temporary LM DM */
#if 1
if (temp_LM_DM == NULL) {
"Unable to mallor wcr_DM_LM_t: %s",
return;
}
#else
if (temp_LM_DM == NULL) {
"Unable to mallor wcr_DM_LM_t: %s",
}
#endif
/* parse response */
"line %d, col %d, near token \"%s\", err code %d, %s\n",
}
if (rc) {
return;
}
MMS_PN_CLAUSE, NULL)) {
tw = 0;
MMS_PN_CLAUSE, &tw);
MMS_PN_CLAUSE, &tw)) {
&work);
&work)) {
temp_LM_DM, wka);
}
}
}
} else {
"successful response: %s",
}
/* compare temp to existing LM DM */
/* if changed set flage to true */
if (changed) {
} else {
}
/* test - print the names of all LM DM with change pending */
if (LM_DM->wcr_change_pending) {
if (LM_DM->wcr_DM_flag) {
} else {
}
}
}
}
void
{
/* int status; */
DM_LM_dev = next_DM_LM_dev) {
break;
}
}
if (DM_LM_dev) {
} else {
}
}
int
wcr_cmd_status(char *response)
{
int rc;
"line %d, col %d, near token \"%s\", err code %d, %s\n",
}
if (rc) {
return (MMS_ERROR);
}
MMS_PN_KEYWORD, 0) != NULL) {
rc = UNACCEPTABLE;
MMS_PN_KEYWORD, 0) != NULL) {
} else {
}
return (rc);
}
void
{
int rc;
"Error sending %s privilege change",
level);
return;
}
"Error %d response for %s privilege change",
}
}
void
{
int rc;
wka->wcr_host_name);
"Error sending DM %s broken attribute change",
return;
}
"Error %d response for DM %s broken attribute change",
}
}
void
{
int rc;
wka->wcr_host_name);
"Error sending LM %s broken attribute change",
return;
}
"Error %d response for LM %s broken attribute change",
}
}
void
{
if (DM_LM_dev->wcr_DM_flag) {
} else {
}
}
/*
* wcr_chk_child_death
* -checks for death of children
*/
void
{
int status;
do {
/* Wait interrupted, will restart wait */
continue;
} else {
return;
}
} else if (pid == 0) {
/* No more sigchld */
wka->wcr_wka_sigchld = 0;
break;
}
break;
}
}
"SSI exited with status - %d",
} else {
}
}
continue;
}
if (DM_LM_dev->wcr_del_pending) {
if (DM_LM_dev->wcr_DM_flag) {
"%s Exited with status %d -"\
" Del Pending",
} else {
"%s Exited with status %d -"\
" Del Pending",
}
} else if (DM_LM_dev->wcr_change_pending) {
if (DM_LM_dev->wcr_DM_flag) {
"%s Exited with status %d"\
" - Change Pending",
} else {
"%s Exited with status %d"\
" - Change Pending",
}
DM_LM_dev->wcr_starts = 0;
(WEXITSTATUS(status) == 0))) {
if (DM_LM_dev->wcr_DM_flag) {
"%s Exited with status %d -"\
" No Restart",
} else {
"%s Exited with status %d -"\
" No Restart",
}
/*
* DM or LM
* Exited with status == 1 or == 0
* Do not restart
*/
} else if (wka->wcr_connected == 0) {
/*
* Watcher not connected to MM
*/
if (DM_LM_dev->wcr_DM_flag) {
"%s Exited with status %d -"
" Watcher not connected to MM",
} else {
"%s Exited with status %d -"
" Watcher not connected to MM",
}
} else {
if (DM_LM_dev->wcr_DM_flag) {
"%s Exited with status %d - Restart",
} else {
"%s Exited with status %d - Restart",
}
/*
* Count number of restarts in a time period.
*/
DM_LM_dev->wcr_starts == 0 ||
} else {
DM_LM_dev->wcr_starts++;
}
/*
* DM or LM
* Restarted n times in s seconds.
* Set broken and remove from list.
*/
"%s restarting too quickly, "
"setting broken state.",
} else {
/*
* DM or LM
* Was aborted or exited w/ status != 1 or != 0
* Restart
*/
}
}
/* LINTED: */
} while (1);
}
void
{
if (new_LM_DM->
wcr_dev_mgr_path != NULL) {
}
}
}
}
int
"Error setting watcher notification ");
return (1);
} else {
}
return (0);
}
void
/* LINTED: sig_mask may be used later */
{
int rc;
return;
}
"line %d, col %d, near token \"%s\", "\
"err code %d, %s\n",
}
if (rc) {
}
MMS_PN_CMD, 0) != NULL) {
}
}
void
{
char *old_inst_name = NULL;
char *new_inst_name = NULL;
/* mms_trace(MMS_NOTICE, */
/* "Found NEW event"); */
/* mms_trace(MMS_NOTICE, */
/* "Found ENABLE event"); */
/* mms_trace(MMS_NOTICE, */
/* "Found DELETE event"); */
/* mms_trace(MMS_NOTICE, */
/* "Found DISABLE event"); */
/* mms_trace(MMS_NOTICE, */
/* "Found CHANGE event"); */
object);
} else {
}
}
}
}
int
{
int found_not_done = 0;
int remove;
int go = 1;
while (go) {
remove = 0;
remove = 1;
break;
} else {
found_not_done = 1;
}
}
if (remove) {
} else { go = 0; }
}
return (found_not_done);
}
/*
* wcr_refresh()
* -Read network configure file.
* -Check for mm host change.
*/
void
{
/* read network config */
}
/* determine if mm host changed */
char *ok[2];
/* compare host names and ip addresses */
/* validate connection */
F_GETFD, 0) != -1) {
}
break;
}
}
}
/* replace network config */
sizeof (mms_network_cfg_t));
/* handle mm host */
if (wcr_write_cfg(wka)) {
"Unable to write cfg file");
}
} else {
}
}
}
void
{
int rc;
"Error sending system settings show command");
return;
}
"line %d, col %d, near token \"%s\", err code %d, %s\n",
}
if (rc) {
goto cleanup;
}
"response");
goto cleanup;
}
}
}
}
}
}
/*
* wcr_reconnect()
* -Connect to network configuration mm host.
*/
int
{
int found;
int rc;
char prev_mm_host[MAXHOSTNAMELEN];
int mm_changed;
event = next_event) {
}
if (wcr_init_session(wka)) {
return (1);
}
if (wcr_set_notify(wka)) {
return (1);
}
if (wcr_write_cfg(wka)) {
"Unable to write cfg file");
}
LM_DM = next_LM_DM) {
}
if (wcr_get_config(wka)) {
rc = 1;
goto cleanup;
}
devmgr = next_devmgr) {
found = 0;
LM_DM = next_LM_DM) {
LM_DM);
wcr_DM.wcr_DM_name) == 0) {
found = 1;
break;
}
}
/* not found or different type */
/* found, change */
} else {
/* found, no change */
if (mm_changed) {
/* point children at new mm host */
}
}
}
if (wcr_config(wka)) {
rc = 1;
goto cleanup;
}
rc = 1;
goto cleanup;
} else {
}
rc = 0;
devmgr = next_devmgr) {
}
return (rc);
}
/*
* wcr_connection()
* -Handle service SIGHUP refresh
* -Establish mm connection
*/
void
{
int rc = 0;
do {
if (wka->wcr_wka_sighup) {
wka->wcr_wka_sighup = 0;
}
}
} while (rc);
}
int
/* LINTED: may be used later */
{
int go = 1;
int rc;
/*
* Init the watcher
* -Initializes the watcher work area and device list
* -Becomes daemon
* -Reads cfg
* -Opens watcher device
*/
if (wcr_init_watcher(&wka)) {
exit(1);
}
/*
* Setup signal handlers
*/
/*
* Setup singals to block
*/
/* Block SIGCHLD which checking child death */
while (go) {
/* mms_trace(MMS_NOTICE, "Waiting for Event Notification\n"); */
}
mms_trace_flush(); /* flush mms_trace buffer */
/* mms_trace(MMS_NOTICE, "Pselect returned %d error " */
/* "code %d ", c, errno); */
/* Process MMP commands. */
/* mms_trace(MMS_NOTICE, "Do work"); */
if (rc > 0) {
}
}
#ifdef MMS_OPENSSL
#endif /* MMS_OPENSSL */
return (0);
}