zabbix-agent2/src/zabbix_agent/logfiles/persistent_state.c
/******************************************************************************
 *                                                                            *
 * Function: zbx_create_persistent_server_directory                           *
 *                                                                            *
 * Purpose: create directory if it does not exist or check access if it       *
 *          exists. Directory name is derived from host and port.             *
 *                                                                            *
 * Parameters:                                                                *
 *          base_path - [IN] initial part of pathname, must consist of only   *
 *                           ASCII characters                                 *
 *          host      - [IN] host string                                      *
 *          port      - [IN] port number                                      *
 *          error     - [OUT] error message                                   *
 *                                                                            *
 * Return value: on success - dynamically allocated string with the name of   *
 *                            directory,                                      *
 *               on error   - NULL (with dynamically allocated 'error')       *
 *                                                                            *
 ******************************************************************************/
zbx_create_persistent_server_directory

Purpose: create directory if it does not exist or check access if it
exists. Directory name is derived from host and port.
zbx_create_persistent_server_directory Purpose : create directory if it does not exist or check access if it exists . Directory name is derived from host and port .
char	*zbx_create_persistent_server_directory(const char *base_path, const char *host, unsigned short port,
		char **error)
{
	char	*server_dir_name, *err_msg = NULL;
	if (SUCCEED != create_base_path_directories(base_path, error))
		return NULL;
	server_dir_name = make_persistent_server_directory_name(base_path, host, port);
	if (SUCCEED != create_persistent_directory(server_dir_name, &err_msg))
	{
		*error = zbx_dsprintf(*error, "cannot create directory \"%s\": %s", server_dir_name, err_msg);
		zbx_free(server_dir_name);
		zbx_free(err_msg);
		return NULL;
	}
	if (0 != access(server_dir_name, R_OK | W_OK | X_OK))
	{
		if (NULL != server_dir_name)	
		{
			*error = zbx_dsprintf(*error, "insufficient access rights to directory \"%s\"",
					server_dir_name);
		}
		else
			THIS_SHOULD_NEVER_HAPPEN;
		zbx_free(server_dir_name);
		return NULL;
	}
	return server_dir_name;
}
char * zbx_create_persistent_server_directory ( const char * base_path , const char * host , unsigned short port , char * * error ) { char * server_dir_name , * err_msg = NULL ; if ( SUCCEED != create_base_path_directories ( base_path , error ) ) return NULL ; server_dir_name = make_persistent_server_directory_name ( base_path , host , port ) ; if ( SUCCEED != create_persistent_directory ( server_dir_name , & err_msg ) ) { * error = zbx_dsprintf ( * error , " \" \" " , server_dir_name , err_msg ) ; zbx_free ( server_dir_name ) ; zbx_free ( err_msg ) ; return NULL ; } if ( 0 != access ( server_dir_name , R_OK | W_OK | X_OK ) ) { if ( NULL != server_dir_name ) { * error = zbx_dsprintf ( * error , " \" \" " , server_dir_name ) ; } else THIS_SHOULD_NEVER_HAPPEN ; zbx_free ( server_dir_name ) ; return NULL ; } return server_dir_name ; }
Function: zbx_create_persistent_server_directory                           
                                                                            
 Purpose: create directory if it does not exist or check access if it       
          exists.
Function : zbx_create_persistent_server_directory Purpose : create directory if it does not exist or check access if it exists .
/* persistent storage top-level directory */ /* directory for server/proxy where the current active check process will be sending data */ /* only to silence GCC warning "directive argument is null" */