Beispiel #1
0
void XMLReader::DebugNextElement(XMLElement aParent, const std::string& aChildName) const
{
	if (aParent->NextSiblingElement(aChildName.c_str()) == nullptr)
	{
		DL_DEBUG("Failed to [ForceFindNextElement]. Parent: [ %s ], Child: [ %s ], File: [ %s ]", aParent->Name(), aChildName.c_str(), myFilePath.c_str());
		DL_ASSERT("Failed to [ForceFindNextElement], check DebugLog for more info");
	}
}
Beispiel #2
0
void XMLReader::DebugFirstChild(XMLElement aParent) const
{
	if (aParent->FirstChildElement() == nullptr)
	{
		DL_DEBUG("Failed to [ForceFindFirstChild]. Parent: [ %s ], Child: [ First ], File:  [ %s ]", aParent->Name(), myFilePath.c_str());
		DL_ASSERT("Failed to [ForceFindFirstChild], check DebugLog for more info");
	}
}
Beispiel #3
0
void XMLReader::DebugFirstChild(const std::string& aChildName) const
{
	if (myDoc->FirstChildElement(aChildName.c_str()) == nullptr)
	{
		DL_DEBUG("Failed to [ForceFindFirstChild]. Parent: [ Document ], Child: [ %s ], File: [ %s ]", aChildName.c_str(), myFilePath.c_str());
		DL_ASSERT("Failed to [ForceFindFirstChild], check DebugLog for more info");
	}
}
Beispiel #4
0
XMLWriter::~XMLWriter()
{
	if (myHasUnsavedChanges == true)
	{
		DL_DEBUG("[XMLWriter]: Destructor got called before everything was saved. File being edited was: %s", mySavePath.c_str());
		DL_ASSERT("[XMLSave]: Dint save all changes to a document");
	}
}
Beispiel #5
0
void XMLWriter::SetAttribute(XMLElement aElement, const std::string& aAttributeName, const int aValue)
{
	if (myHasCreatedDoc == false)
	{
		DL_DEBUG("[XMLWriter]: Tried to [InsertElement] before Creating an document");
		DL_ASSERT("[XMLWriter]: Failed to SaveDocument");
	}

	if (aElement == nullptr)
	{
		DL_DEBUG("[XMLWriter]: Tried to [SetAttribute] to a Element that dint exist. Attribute: %s, Value: %i", aAttributeName.c_str(), aValue);
		DL_ASSERT("[XMLWriter]: Failed to SetAttribute");
	}

	aElement->SetAttribute(aAttributeName.c_str(), aValue);
	myHasUnsavedChanges = true;
}
Beispiel #6
0
void XMLWriter::ResetDocument()
{
	if (myHasCreatedDoc == false)
	{
		DL_DEBUG("[XMLWriter]: Tried to [ResetDocument] before Creating an document");
		DL_ASSERT("[XMLWriter]: Failed to SaveDocument");
	}

	myDoc.DeleteChildren();
}
Beispiel #7
0
XMLElement XMLWriter::InsertElement(XMLElement aParentElement, const std::string& aElementName)
{
	if (myHasCreatedDoc == false)
	{
		DL_DEBUG("[XMLWriter]: Tried to [InsertElement] before Creating an document");
		DL_ASSERT("[XMLWriter]: Failed to SaveDocument");
	}

	if (aParentElement == nullptr)
	{
		DL_DEBUG("[XMLWriter]: Tried to [InsertElement ( %s )] to a parentelement that dint exist.", aElementName.c_str());
		DL_ASSERT("[XMLWriter]: Failed to InsertElement");
	}

	XMLElement newElem = myDoc.NewElement(aElementName.c_str());
	aParentElement->InsertEndChild(newElem);
	myHasUnsavedChanges = true;

	return newElem;
}
Beispiel #8
0
bool XMLReader::ForceReadAttribute(const XMLElement aElementToReadFrom, const std::string& aAttributeToRead, bool* aTargetVariable) const
{
	if (myHasOpenedDoc == false)
		DL_ASSERT("[XMLReader]: Tried to [ReadAttribute(bool)] before Opening the document");

	if (aElementToReadFrom->QueryBoolAttribute(aAttributeToRead.c_str(), aTargetVariable) == tinyxml2::XML_NO_ERROR)
		return true;

	DL_DEBUG("Failed to read Attribute: [ %s ], from Element: [ %s ], in Document: [ %s ]", aAttributeToRead.c_str(), aElementToReadFrom->Name(), myFilePath.c_str());
	DL_ASSERT("Failed to [ForceReadAttribute(bool)], check DebugLog for more info");
	return false;
}
void QuadTreeNode::RemoveFromNode(QuadTreeDweller* aDweller)
{
	int index = Find(aDweller);
	if(index != -1)
	{
		myTreeDwellers.RemoveCyclicAtIndex(index);
	}
	else
	{
		DL_DEBUG("TreeDweller RemoveFromNode did not find the associated node to remove (QuadTree)");
	}
}
Beispiel #10
0
XMLElement XMLWriter::InsertElement(const std::string& aElementName)
{
	if (myHasCreatedDoc == false)
	{
		DL_DEBUG("[XMLWriter]: Tried to [InsertElement] before Creating an document");
		DL_ASSERT("[XMLWriter]: Failed to SaveDocument");
	}

	XMLElement newElem = myDoc.NewElement(aElementName.c_str());
	myDoc.InsertEndChild(newElem);
	myHasUnsavedChanges = true;

	return newElem;
}
Beispiel #11
0
bool XMLReader::ForceReadAttribute(const XMLElement aElementToReadFrom, const std::string& aAttributeToRead, std::string& aTargetVariable) const
{
	if (myHasOpenedDoc == false)
		DL_ASSERT("[XMLReader]: Tried to [ForceReadAttribute(string)] before Opening the document");

	if (aElementToReadFrom->FindAttribute(aAttributeToRead.c_str()) != 0)
	{
		aTargetVariable = aElementToReadFrom->Attribute(aAttributeToRead.c_str());
		return true;
	}

	DL_DEBUG("Failed to read Attribute: [ %s ], from Element: [ %s ], in Document: [ %s ]", aAttributeToRead.c_str(), aElementToReadFrom->Name(), myFilePath.c_str());
	DL_ASSERT("Failed to [ForceReadAttribute(string)], check DebugLog for more info");
	return false;
}
ObjectData* Event::GetGameObject(const std::string& aName) const
{
    if (myRoom == nullptr || myGameWorld == nullptr)
    {
        return nullptr;
    }
    if (aName == "Self")
    {
        return myObjectData;
    }
    else if (aName == "None")
    {
        return nullptr;
    }
    CommonUtilities::GrowingArray<ObjectData*, unsigned int>* objects = myRoom->GetObjectList();
    for (unsigned int i = 0; i < objects->Size(); ++i)
    {
        if ((*objects)[i]->myName == aName)
        {
            return (*objects)[i];
        }

        if ((*objects)[i]->myChilds.GetIsInitialized() == true)
        {
            for (unsigned int j = 0; j < (*objects)[i]->myChilds.Size(); ++j)
            {
                ObjectData* data = GetGameObject(aName, (*objects)[i]);
                if (data != nullptr)
                {
                    return data;
                }
            }
        }
    }
    DL_DEBUG(("Couldn't find object named: " + aName).c_str());
    return nullptr;
}
Beispiel #13
0
/*
 * -- tapealert - tapealert log sense page 0x2e processing
 * Process media changer or tape drive request for tapealert log sense
 * page 0x2e.  An active tapealert never interferes with data
 * transfers.  Active tapealert flags are written to the device log and
 * real-time notification is by a posted tapealert sysevent.  See
 * www.t10.org SSC-2 and SMC-2 for additional tapealert information.
 */
int			/* 0 successful */
tapealert(
	char *src_fn,		/* source filename */
	int src_ln,		/* source file line number */
	int fd,			/* device file descriptor */
	dev_ent_t *un,		/* device */
	uchar_t *logpage,	/* existing tapealert log sense page */
	int logpage_len)	/* existing tapealert log sense page length */
{
#define	CLEAN_NOW		0x80000
#define	CLEAN_PERIODIC		0x100000
#define	EXPIRED_CLEANING_MEDIA	0x200000
#define	INVALID_CLEANING_MEDIA	0x400000
#define	STK_CLEAN_REQUESTED	0x800000
	int			rtn = 1;
	uchar_t			*page;
	uchar_t			*log_param;
#define		PAGE_LEN 256
	uchar_t			tmp_page [PAGE_LEN];
	int 			resid;
	int 			i;
	int			j;
	int			page_len;
	int			param_len;
	int			param_code;
	int 			add_page_len;
	sam_extended_sense_t	*sense;
	sam_extended_sense_t	saved_sense;
	uchar_t			saved_cdb [16];
#define		FLAGS_LEN 64
	int			flags_len;
	uint64_t		flags;
	uchar_t			val;
	int			save_errno = errno;
	uint64_t		seq_no = 0;
	int			supported;
	int			enabled;
	int			init_query;
	int			required;
	int 			requested;
	int			expired;
	int			invalid;


	supported = un->tapealert & TAPEALERT_SUPPORTED;
	enabled = un->tapealert & TAPEALERT_ENABLED;
	init_query = un->tapealert & TAPEALERT_INIT_QUERY;
	if (!(supported && (enabled || init_query))) {
		return (0);
	}

	/*
	 * get device sense pointer.
	 */
	sense = (sam_extended_sense_t *)SHM_REF_ADDR(un->sense);

	/*
	 * Second, process tapealert log sense page.
	 */
	if (logpage == NULL || logpage_len < 4) {
		/* save callers previous cdb and sense */
		memcpy(saved_cdb, un->cdb, SAM_CDB_LENGTH);
		memcpy(&saved_sense, sense, sizeof (sam_extended_sense_t));
		if (scsi_cmd(fd, un, SCMD_LOG_SENSE, 0, tmp_page, 0,
		    0x2e, 0, PAGE_LEN, &resid) < 0) {
			DevLog(DL_DEBUG(12002), sense->es_key,
			    sense->es_add_code, sense->es_qual_code);
			memcpy(un->cdb, saved_cdb, SAM_CDB_LENGTH);
			memcpy(sense, &saved_sense,
			    sizeof (sam_extended_sense_t));
			goto cleanup;
		}
		/* restore callers previous cdb and sense */
		memcpy(un->cdb, saved_cdb, SAM_CDB_LENGTH);
		memcpy(sense, &saved_sense, sizeof (sam_extended_sense_t));

		page = tmp_page;
		page_len = PAGE_LEN - resid;
	} else {
		page = logpage;
		page_len = logpage_len;
	}

	if (page_len < 4) {
		DevLog(DL_DEBUG(12003), page_len);
		goto cleanup;
	}

	if (page [0] != 0x2e) {
		DevLog(DL_DEBUG(12004), page [0]);
		goto cleanup;
	}

	add_page_len = (page [2] << 8) | page [3];
	add_page_len &= 0xffff;
	log_param = page + 4;

	flags = 0;
	flags_len = 0;
	for (i = 0, j = 0; i < FLAGS_LEN && j < add_page_len; i++, j += 5) {

		param_code = (log_param [j] << 8) | log_param [j + 1];
		if (param_code != (i + 1)) {
			if (flags != 0) break;
			goto cleanup;
		}

		param_len = log_param [j + 3];
		param_len &= 0xff;
		if (param_len == 1) {
			val = log_param [j + 4];
			if (i < 64 && val != 0) {
				flags |= ((uint64_t)1 << i);
			}
		} else {
			/*
			 * vendor unique flag length value, quit
			 * processing flags
			 */
			break;
		}

		/*
		 * increment number of valid TapeAlert flags
		 * contained in the 64 bit wide flags variable
		 */
		flags_len++;
	}

	/* check for in-active or already seen */
	if (flags == 0 || (flags == un->tapealert_flags &&
	    strcmp(un->tapealert_vsn, un->vsn) == 0)) {
		rtn = 0;
		goto cleanup;
	}

	/* build active flags filter by vsn */
	if (strcmp(un->tapealert_vsn, un->vsn) == 0) {
		/* check for already seen */
		if ((flags & ~un->tapealert_flags) == 0) {
			rtn = 0;
			goto cleanup;
		}
		/* current vsn, add active flag(s) to filter */
		un->tapealert_flags |= flags;
	} else {
		/* new vsn, initialize flags filter */
		un->tapealert_flags = flags;
	}
	strcpy(un->tapealert_vsn, un->vsn);

	/*
	 * send tapealert sysevent
	 */
	rtn = tapealert_sysevent(src_fn, src_ln, un, flags_len, flags, &seq_no);

	/*
	 * log active flags
	 *
	 * seq_no is zero when sysevent not sent.
	 */
	if (strlen(un->vsn) > 0) {
		DevLog(DL_ALL(12007), un->version, un->eq, un->scsi_type,
		    seq_no, flags_len, flags, un->vsn);
	} else {
		DevLog(DL_ALL(12006), un->version, un->eq, un->scsi_type,
		    seq_no, flags_len, flags);
	}

	if ((un->tapeclean & TAPECLEAN_AUTOCLEAN) &&
	    (un->tapeclean & TAPECLEAN_LOGSENSE)) {
		required = (flags & CLEAN_NOW) ? 1 : 0;
		requested = (flags & CLEAN_PERIODIC) ? 1 : 0;
		expired = (flags & EXPIRED_CLEANING_MEDIA) ? 1 : 0;
		invalid = (flags & INVALID_CLEANING_MEDIA) ? 1 : 0;
		if (un->equ_type == DT_9840 ||
		    un->equ_type == DT_9940 || un->equ_type == DT_TITAN) {
			requested = (flags & STK_CLEAN_REQUESTED) ? 1 : 0;
		}

		/* Map active TapeAlert flags onto SAM-FS status. */
		tapeclean_active(un, required, requested, expired, invalid);
	}

cleanup:

	/*
	 * restore callers errno state
	 */
	errno = save_errno;
	return (rtn);
}
Beispiel #14
0
void XMLWriter::CreateCopyOfDocument(const std::string& aNewFilePath, const std::string& aSourceFilePath)
{
	mySavePath = aNewFilePath;

	tinyxml2::XMLError error = myDoc.LoadFile(aSourceFilePath.c_str());
	if (error == 0)
	{
		myDoc.SaveFile(mySavePath.c_str());
		myHasCreatedDoc = true;
	}
	else
	{
#pragma region Error-Codes
		switch (error)
		{
		case tinyxml2::XML_NO_ATTRIBUTE:
			DL_DEBUG("Failed to Open XML File. File: %s, Error: XML_NO_ATTRIBUTE", aSourceFilePath.c_str());
			break;
		case tinyxml2::XML_WRONG_ATTRIBUTE_TYPE:
			DL_DEBUG("Failed to Open XML File. File: %s, Error: XML_WRONG_ATTRIBUTE_TYPE", aSourceFilePath.c_str());
			break;
		case tinyxml2::XML_ERROR_FILE_NOT_FOUND:
			DL_DEBUG("Failed to Open XML File. File: %s, Error: XML_ERROR_FILE_NOT_FOUND", aSourceFilePath.c_str());
			break;
		case tinyxml2::XML_ERROR_FILE_COULD_NOT_BE_OPENED:
			DL_DEBUG("Failed to Open XML File. File: %s, Error: XML_ERROR_FILE_COULD_NOT_BE_OPENED", aSourceFilePath.c_str());
			break;
		case tinyxml2::XML_ERROR_FILE_READ_ERROR:
			DL_DEBUG("Failed to Open XML File. File: %s, Error: XML_ERROR_FILE_READ_ERROR", aSourceFilePath.c_str());
			break;
		case tinyxml2::XML_ERROR_ELEMENT_MISMATCH:
			DL_DEBUG("Failed to Open XML File. File: %s, Error: XML_ERROR_ELEMENT_MISMATCH", aSourceFilePath.c_str());
			break;
		case tinyxml2::XML_ERROR_PARSING_ELEMENT:
			DL_DEBUG("Failed to Open XML File. File: %s, Error: XML_ERROR_PARSING_ELEMENT", aSourceFilePath.c_str());
			break;
		case tinyxml2::XML_ERROR_PARSING_ATTRIBUTE:
			DL_DEBUG("Failed to Open XML File. File: %s, Error: XML_ERROR_PARSING_ATTRIBUTE", aSourceFilePath.c_str());
			break;
		case tinyxml2::XML_ERROR_IDENTIFYING_TAG:
			DL_DEBUG("Failed to Open XML File. File: %s, Error: XML_ERROR_IDENTIFYING_TAG", aSourceFilePath.c_str());
			break;
		case tinyxml2::XML_ERROR_PARSING_TEXT:
			DL_DEBUG("Failed to Open XML File. File: %s, Error: XML_ERROR_PARSING_TEXT", aSourceFilePath.c_str());
			break;
		case tinyxml2::XML_ERROR_PARSING_CDATA:
			DL_DEBUG("Failed to Open XML File. File: %s, Error: XML_ERROR_PARSING_CDATA", aSourceFilePath.c_str());
			break;
		case tinyxml2::XML_ERROR_PARSING_COMMENT:
			DL_DEBUG("Failed to Open XML File. File: %s, Error: XML_ERROR_PARSING_COMMENT", aSourceFilePath.c_str());
			break;
		case tinyxml2::XML_ERROR_PARSING_DECLARATION:
			DL_DEBUG("Failed to Open XML File. File: %s, Error: XML_ERROR_PARSING_DECLARATION", aSourceFilePath.c_str());
			break;
		case tinyxml2::XML_ERROR_PARSING_UNKNOWN:
			DL_DEBUG("Failed to Open XML File. File: %s, Error: XML_ERROR_PARSING_UNKNOWN", aSourceFilePath.c_str());
			break;
		case tinyxml2::XML_ERROR_EMPTY_DOCUMENT:
			DL_DEBUG("Failed to Open XML File. File: %s, Error: XML_ERROR_EMPTY_DOCUMENT", aSourceFilePath.c_str());
			break;
		case tinyxml2::XML_ERROR_MISMATCHED_ELEMENT:
			DL_DEBUG("Failed to Open XML File. File: %s, Error: XML_ERROR_MISMATCHED_ELEMENT", aSourceFilePath.c_str());
			break;
		case tinyxml2::XML_ERROR_PARSING:
			DL_DEBUG("Failed to Open XML File. File: %s, Error: XML_ERROR_PARSING", aSourceFilePath.c_str());
			break;
		case tinyxml2::XML_CAN_NOT_CONVERT_TEXT:
			DL_DEBUG("Failed to Open XML File. File: %s, Error: XML_CAN_NOT_CONVERT_TEXT", aSourceFilePath.c_str());
			break;
		case tinyxml2::XML_NO_TEXT_NODE:
			DL_DEBUG("Failed to Open XML File. File: %s, Error: XML_NO_TEXT_NODE", aSourceFilePath.c_str());
			break;
		case tinyxml2::XML_ERROR_COUNT:
			DL_DEBUG("Failed to Open XML File. File: %s, Error: XML_ERROR_COUNT", aSourceFilePath.c_str());
			break;
		default:
			DL_DEBUG("Failed to Open XML File. File: %s, Error: Unknown, non of tinyxml's error codes caught it :(", aSourceFilePath.c_str());
			break;
		}
#pragma endregion

		DL_ASSERT("[XMLWriter]: Failed to Open XML File. Check Debuglog for error");
	}
}
Beispiel #15
0
/*
 * clean - clean the drive.
 *
 */
void
clean(
	drive_state_t *drive,
	robo_event_t *event)
{
	dev_ent_t	*un;
	int		err, retry;
	uint32_t	access_count, status = 0;
	char	   *d_mess;
	char	   *l_mess;
	struct CatalogEntry ced;
	struct CatalogEntry *ce = &ced;
	library_t	*library;
	move_flags_t    move_flags;

	SANITY_CHECK(drive != (drive_state_t *)0);
	un = drive->un;
	SANITY_CHECK(un != (dev_ent_t *)0);
	library = (library_t *)drive->library;
	SANITY_CHECK(library != (library_t *)0);
	d_mess = drive->un->dis_mes[DIS_MES_NORM];
	l_mess = library->un->dis_mes[DIS_MES_NORM];
	mutex_lock(&drive->mutex);
	if (clear_drive(drive)) {
		mutex_lock(&drive->un->mutex);
		drive->un->status.bits |= DVST_CLEANING;
		mutex_unlock(&drive->un->mutex);
		drive->status.b.cln_inprog = FALSE;
		mutex_unlock(&drive->mutex);
		disp_of_event(library, event, ENOENT);
		return;
	}
	mutex_lock(&drive->un->mutex);
	drive->un->status.bits |= (DVST_REQUESTED | DVST_CLEANING);
	if (drive->un->open_count) {
		clear_driver_idle(drive, drive->open_fd);
		close_unit(drive->un, &drive->open_fd);
		DEC_OPEN(un);
	}
	mutex_unlock(&drive->un->mutex);
	mutex_unlock(&drive->mutex);

	DevLog(DL_ALL(5075));

	memccpy(d_mess, catgets(catfd, SET, 9025, "needs cleaning"),
	    '\0', DIS_MES_LEN);

	ce = CatalogGetCleaningVolume(library->un->eq, &ced);

	if (ce == NULL) {
		memccpy(l_mess,
		    catgets(catfd, SET, 9026,
	    "no cleaning cartridge available"),
		    '\0', DIS_MES_LEN);
		DevLog(DL_ERR(5141));
		SendCustMsg(HERE, 9347);
		mutex_lock(&drive->mutex);
		drive->status.b.cln_inprog = FALSE;
		down_drive(drive, SAM_STATE_CHANGE);
		mutex_lock(&drive->un->mutex);
		drive->un->status.bits &= ~DVST_REQUESTED;
		mutex_unlock(&drive->un->mutex);
		mutex_unlock(&drive->mutex);
		disp_of_event(library, event, EAGAIN);
		return;
	} else {

		status &= ~CES_occupied;
		(void) CatalogSetFieldByLoc(ce->CeEq, ce->CeSlot, ce->CePart,
		    CEF_Status, status, CES_occupied);


	}


	if (library->un->equ_type == DT_3570C) {
		clean_3570(drive, event, ce);
		return;
	}
	mutex_lock(&drive->mutex);

	if (IS_GENERIC_API(library->un->type)) {
		int		local_retry, d_errno, last_derrno = -1;
		api_errs_t	ret;
		char	   *tag = "load on clean";

		local_retry = 3;
		ret = API_ERR_TR;

		while (local_retry > 0) {
			if (aci_load_media(library, drive, ce, &d_errno) == 0)
				break;
			else {
				/* Error return on api call */
				if (d_errno == 0) {
					/*
					 * if call did not happen - error
					 * return but no error
					 */
					local_retry = -1;
					d_errno = EAMUCOMM;
				} else if ((last_derrno == -1) ||
				    (last_derrno != d_errno)) {
					/* Save error if repeated */
					last_derrno = d_errno;
					if (api_valid_error(library->un->type,
					    d_errno, library->un)) {
				/* Indentation for cstyle */
				if (library->un->slot != ROBOT_NO_SLOT) {
					DevLog(DL_DEBUG(6001),
					    library->un->slot, tag, d_errno,
					    d_errno, api_return_message(
					    library->un->type, d_errno));
				} else {
					DevLog(DL_DEBUG(6043), tag, d_errno,
					    d_errno, api_return_message(
					    library->un->type, d_errno));
				}

				local_retry = api_return_retry(
				    library->un->type, d_errno);
				ret = api_return_degree(
				    library->un->type, d_errno);
					} else {
						local_retry = -2;
					}
				}
				if (local_retry > 0) {
					/* delay before retrying */
					local_retry--;
					if (local_retry > 0)
						sleep(api_return_sleep(
						    library->un->type,
						    d_errno));
				}
			}
		}
		if (d_errno != EOK) {
			DevLog(DL_ERR(6036), ce->CeBarCode);
			memccpy(drive->un->dis_mes[DIS_MES_CRIT],
			    catgets(catfd, SET, 9029,
			"unable to load cleaning cartridge, move failed"),
			    '\0', DIS_MES_LEN);

			if (local_retry == -1) {
				/* The call didn't happen */
				DevLog(DL_ERR(6040), tag);
			} else if (local_retry == 0) {
				/* retries exceeded */
				DevLog(DL_ERR(6039), tag);
			} else {
				if (api_valid_error(drive->library->un->type,
				    d_errno, drive->library->un)) {
					if (drive->library->un->slot !=
					    ROBOT_NO_SLOT) {
						DevLog(DL_ERR(6001),
						    drive->library->un->slot,
						    tag, d_errno, d_errno,
						    api_return_message(
						    library->un->type,
						    d_errno));
					} else {
						DevLog(DL_ERR(6043), tag,
						    d_errno, d_errno,
						    api_return_message(
						    library->un->type,
						    d_errno));
					}
				}
			}

			if (ret == API_ERR_DD)
				down_drive(drive, SAM_STATE_CHANGE);
			else if (ret == API_ERR_DM)
				set_bad_media(un);
			else if (ret == API_ERR_DL)
				down_library(library, SAM_STATE_CHANGE);

			drive->status.b.cln_inprog = FALSE;
			mutex_lock(&drive->un->mutex);
			drive->un->status.bits &= ~(DVST_CLEANING |
			    DVST_REQUESTED);
			mutex_unlock(&drive->un->mutex);
			mutex_unlock(&drive->mutex);
			disp_of_event(library, event, EIO);
			return;
		}
	} else {
		move_flags.bits = 0;
		memccpy(d_mess,
		    catgets(catfd, SET, 9009, "waiting for media changer"),
		    '\0', DIS_MES_LEN);
		/*
		 * SPECTRA LOGIC NOTE:  In 3.3.1, the invert argument on this
		 * move was set to one.  This apparently was done for the
		 * spectra-logic robot which overloaded the invert argument
		 * to be the clean argument (See scsi_command case
		 * SCMD_MOVE_MEDIUM).  Unfortunately, the Qualstar robot,
		 * which is mapped to the spectra-logic, implements the
		 * mailbox control for the same bit that spectra-logic uses
		 * as clean.  Confused? Yep.
		 *
		 * Now to add to the confusion. Somewhere in the catalog
		 * rewrite, for reasons lost in the mists of time, the invert
		 * argument was set to zero.  This is inadverentately half
		 * the fix for snap 4966.  It simplifies things, ignoring any
		 * "special" cleaning logic and treating the cleaning tape as
		 * an ordinary load/unload. It seems to work.
		 *
		 * See #ifdef UNKNOWN_SPECTRA_LOGIC below for the other half of
		 * the fix.
		 */
		if (move_media(library, 0, ELEMENT_ADDRESS(library, ce->CeSlot),
		    drive->element, 0, move_flags)) {
			memccpy(drive->un->dis_mes[DIS_MES_CRIT],
			    catgets(catfd, SET, 9029,
			"unable to load cleaning cartridge, move failed"),
			    '\0', DIS_MES_LEN);

			DevLog(DL_ERR(5143));
			down_drive(drive, SAM_STATE_CHANGE);
			drive->status.b.cln_inprog = FALSE;
			mutex_unlock(&drive->mutex);
			disp_of_event(library, event, EIO);
			return;
		}
	}

	mutex_unlock(&drive->mutex);

	/*
	 * Log successful mount of cleaning tape
	 */
	DevLog(DL_ALL(10042), drive->un->eq);
	tapeclean_media(drive->un);

	/*
	 * move_media does not set up the un, so UpdateCatalog can't be
	 * called from here. Using generic_get_media instead of move_media
	 * leaves the drive hung up.
	 */
	status &= ~CES_occupied;
	(void) CatalogSetFieldByLoc(ce->CeEq, ce->CeSlot, ce->CePart,
	    CEF_Status, status, CES_occupied);
	access_count = ce->CeAccess;
	access_count--;
	(void) CatalogSetFieldByLoc(ce->CeEq, ce->CeSlot, ce->CePart,
	    CEF_Access, access_count, 0);
	(void) CatalogSetFieldByLoc(ce->CeEq, ce->CeSlot, ce->CePart,
	    CEF_MountTime, time(NULL), 0);

	retry = 7;
	err = 0;

	if (IS_GENERIC_API(library->un->equ_type)) {
		char	   *tag = "unload for clean";
		int		local_retry, d_errno, last_derrno;
		api_errs_t	ret;
		do {
			memccpy(d_mess,
			    catgets(catfd, SET, 9030,
			    "waiting for cleaning cycle"),
			    '\0', DIS_MES_LEN);
			sleep(3 * 60);	/* wait 3 minutes */
			tapeclean_media(drive->un);
			mutex_lock(&drive->mutex);
			memccpy(d_mess,
			    catgets(catfd, SET, 9031,
			    "attempt to unload cleaning cartridge"),
			    '\0', DIS_MES_LEN);

			local_retry = 3;
			ret = API_ERR_TR;
			last_derrno = -1;

			while (local_retry > 0) {
				/*
				 * vsn is not set, use aci_force_media()
				 * instead of aci_dismount_media()
				 */
				if (aci_force_media(library, drive,
				    &d_errno) == 0)
					break;
				else {
					/* Error return on api call */
					if (d_errno == 0) {
						/*
						 * if call did not happen -
						 * error return but no error
						 */
						local_retry = -1;
						d_errno = EAMUCOMM;
					} else if ((last_derrno == -1) ||
					    (last_derrno != d_errno)) {
						/* Save error if repeated */
						last_derrno = d_errno;
						if (api_valid_error(
						    drive->library->un->type,
						    d_errno,
						    drive->library->un)) {

						if (drive->library->un->slot !=
						    ROBOT_NO_SLOT) {
						DevLog(DL_DEBUG(6001),
						    drive->library->un->slot,
						    tag, d_errno, d_errno,
						    api_return_message(
						    library->un->type,
						    d_errno));
							} else {
						DevLog(DL_DEBUG(6043),
						    tag, d_errno, d_errno,
						    api_return_message(
						    library->un->type,
						    d_errno));
						}

						local_retry = api_return_retry(
						    library->un->type, d_errno);
						ret = api_return_degree(
						    library->un->type, d_errno);
						} else {
							local_retry = -2;
						}
					}
					if (local_retry > 0) {
						/* delay before retrying */
						local_retry--;
						if (local_retry > 0)
							sleep(api_return_sleep(
							    library->un->type,
							    d_errno));
					}
				}
			}
			if (d_errno != EOK) {
				DevLog(DL_ERR(6033), ce->CeBarCode);

				if (local_retry == -1) {
					/* The call didn't happen */
					DevLog(DL_ERR(6040), tag);
				} else if (local_retry == 0) {
					/* retries exceeded */
					DevLog(DL_ERR(6039), tag);
				} else {
					if (api_valid_error(
					    drive->library->un->type,
					    d_errno, drive->library->un))
						if (drive->library->un->slot !=
						    ROBOT_NO_SLOT) {
						DevLog(DL_ERR(6001),
						    drive->library->un->slot,
						    tag, d_errno, d_errno,
						    api_return_message(
						    library->un->type,
						    d_errno));
						} else {
						DevLog(DL_ERR(6043),
						    d_errno, d_errno,
						    api_return_message(
						    library->un->type,
						    d_errno));
						}
				}
				if (ret == API_ERR_DL)
					down_library(library, SAM_STATE_CHANGE);
				else if (ret == API_ERR_DD)
					down_drive(drive, SAM_STATE_CHANGE);
			}
			mutex_unlock(&drive->mutex);
		} while (err != 0 && retry-- != 0);
	} else {
		/*
		 * SPECTRA LOGIC NOTE:  Due to the removal of "special"
		 * cleaning code, we must unload the cleaning tape for all
		 * robot types.
		 *
		 * See the previous SPECTRA LOGIC NOTE:
		 */
#ifdef UNKNOWN_SPECTRA_LOGIC
		if (library->un->equ_type != DT_SPECLOG)
#endif
			do {
				memccpy(d_mess,
				    catgets(catfd, SET, 9030,
				    "wait for cleaning cycle"),
				    '\0', DIS_MES_LEN);
				sleep(3 * 60);	/* wait 3 minutes */
				tapeclean_media(drive->un);
				mutex_lock(&drive->mutex);
				DevLog(DL_DETAIL(5077));
				memccpy(d_mess,
				    catgets(catfd, SET, 9031,
				    "attempt to unload cleaning cartridge"),
				    '\0', DIS_MES_LEN);
				err = move_media(library, 0, drive->element,
				    ELEMENT_ADDRESS(library, ce->CeSlot),
				    0, move_flags);
				if (err) {
					DevLog(DL_ERR(5078), retry);
				} else {
					DevLog(DL_DETAIL(5079));
				}
				mutex_unlock(&drive->mutex);
			} while (err != 0 && retry-- != 0);
	}

	tapeclean_media(drive->un);

	if (err != 0) {
		DevLog(DL_ERR(5080));
		memccpy(drive->un->dis_mes[DIS_MES_CRIT],
		    catgets(catfd, SET, 9032,
		    "unable to unload cleaning cartridge"),
		    '\0', DIS_MES_LEN);
		mutex_lock(&drive->mutex);
		drive->status.b.cln_inprog = FALSE;
		down_drive(drive, SAM_STATE_CHANGE);
		mutex_unlock(&drive->mutex);
		disp_of_event(library, event, EIO);
		return;
	}
	status = CES_occupied;
	if (drive->un->status.b.bad_media) {
		/* cleaning media marked in catalog as bad */
		status |= CES_bad_media;

		/* reset bad media flag */
		drive->un->status.b.bad_media = 0;
	}
	(void) CatalogSetFieldByLoc(library->un->eq, ce->CeSlot, 0,
	    CEF_Status, status, 0);

	DevLog(DL_ALL(5334), access_count);

	if ((status & CES_bad_media) == 0) {
		memccpy(d_mess,
		    catgets(catfd, SET, 9034, "drive has been cleaned"),
		    '\0', DIS_MES_LEN);
	}
	mutex_lock(&drive->mutex);
	drive->status.b.cln_inprog = FALSE;
	mutex_lock(&drive->un->mutex);
	if ((status & CES_bad_media) == 0) {
		/* drive was cleaned */
		drive->un->status.bits &= ~(DVST_CLEANING | DVST_REQUESTED);
	} else {
		/* drive was not cleaned, it needs to still be cleaned */
		drive->un->status.bits &= ~(DVST_REQUESTED);
	}
	mutex_unlock(&drive->un->mutex);
	mutex_unlock(&drive->mutex);
	if (ce->CeAccess == 0 || (status & CES_bad_media)) {
		char	   *MES_9035 = catgets(catfd, SET, 9035,
		    "cleaning cartridge in slot %d has expired");

		char *mess = (char *)malloc_wait(
		    strlen(MES_9035) + 15, 2, 0);
		sprintf(mess, MES_9035, ce->CeSlot);
		memccpy(l_mess, mess, '\0', DIS_MES_LEN);
		free(mess);
		switch (library->un->type) {
		case DT_METD28:
		case DT_DLT2700:
		case DT_GRAUACI:
			DevLog(DL_ERR(5144), ce->CeSlot);
			break;

		default:
			schedule_export(library, ce->CeSlot);
			DevLog(DL_ERR(5145), ce->CeSlot);
			break;
		}
	} else if (tapeclean_drive(drive->un)) {
		memccpy(l_mess,
		    catgets(catfd, SET, 2983, "clean failed"),
		    '\0', DIS_MES_LEN);
		DevLog(DL_ERR(5364));
		mutex_lock(&drive->mutex);
		down_drive(drive, SAM_STATE_CHANGE);
		mutex_unlock(&drive->mutex);
		disp_of_event(library, event, EIO);
		return;
	}
	disp_of_event(library, event, 0);
}
Beispiel #16
0
void SetCubeMap(const char* aCubeMapFile) 
{
	DL_DEBUG("Stuff happend here first!");
	locDLLApplication->SetCubeMap(aCubeMapFile);
}
Beispiel #17
0
void XMLWriter::SaveDocument()
{
	if (myHasCreatedDoc == false)
	{
		DL_DEBUG("[XMLWriter]: Tried to [SaveDocument] before Creating an document");
		DL_ASSERT("[XMLWriter]: Failed to SaveDocument");
	}

	tinyxml2::XMLError error = myDoc.SaveFile(mySavePath.c_str());

	if (error != 0)
	{
#pragma region Error-Codes
		switch (error)
		{
		case tinyxml2::XML_NO_ATTRIBUTE:
			DL_DEBUG("Failed to Save XML File. File: %s, Error: XML_NO_ATTRIBUTE", mySavePath.c_str());
			break;
		case tinyxml2::XML_WRONG_ATTRIBUTE_TYPE:
			DL_DEBUG("Failed to Save XML File. File: %s, Error: XML_WRONG_ATTRIBUTE_TYPE", mySavePath.c_str());
			break;
		case tinyxml2::XML_ERROR_FILE_NOT_FOUND:
			DL_DEBUG("Failed to Save XML File. File: %s, Error: XML_ERROR_FILE_NOT_FOUND", mySavePath.c_str());
			break;
		case tinyxml2::XML_ERROR_FILE_COULD_NOT_BE_OPENED:
			DL_DEBUG("Failed to Save XML File. File: %s, Error: XML_ERROR_FILE_COULD_NOT_BE_OPENED", mySavePath.c_str());
			break;
		case tinyxml2::XML_ERROR_FILE_READ_ERROR:
			DL_DEBUG("Failed to Save XML File. File: %s, Error: XML_ERROR_FILE_READ_ERROR", mySavePath.c_str());
			break;
		case tinyxml2::XML_ERROR_ELEMENT_MISMATCH:
			DL_DEBUG("Failed to Save XML File. File: %s, Error: XML_ERROR_ELEMENT_MISMATCH", mySavePath.c_str());
			break;
		case tinyxml2::XML_ERROR_PARSING_ELEMENT:
			DL_DEBUG("Failed to Save XML File. File: %s, Error: XML_ERROR_PARSING_ELEMENT", mySavePath.c_str());
			break;
		case tinyxml2::XML_ERROR_PARSING_ATTRIBUTE:
			DL_DEBUG("Failed to Save XML File. File: %s, Error: XML_ERROR_PARSING_ATTRIBUTE", mySavePath.c_str());
			break;
		case tinyxml2::XML_ERROR_IDENTIFYING_TAG:
			DL_DEBUG("Failed to Save XML File. File: %s, Error: XML_ERROR_IDENTIFYING_TAG", mySavePath.c_str());
			break;
		case tinyxml2::XML_ERROR_PARSING_TEXT:
			DL_DEBUG("Failed to Save XML File. File: %s, Error: XML_ERROR_PARSING_TEXT", mySavePath.c_str());
			break;
		case tinyxml2::XML_ERROR_PARSING_CDATA:
			DL_DEBUG("Failed to Save XML File. File: %s, Error: XML_ERROR_PARSING_CDATA", mySavePath.c_str());
			break;
		case tinyxml2::XML_ERROR_PARSING_COMMENT:
			DL_DEBUG("Failed to Save XML File. File: %s, Error: XML_ERROR_PARSING_COMMENT", mySavePath.c_str());
			break;
		case tinyxml2::XML_ERROR_PARSING_DECLARATION:
			DL_DEBUG("Failed to Save XML File. File: %s, Error: XML_ERROR_PARSING_DECLARATION", mySavePath.c_str());
			break;
		case tinyxml2::XML_ERROR_PARSING_UNKNOWN:
			DL_DEBUG("Failed to Save XML File. File: %s, Error: XML_ERROR_PARSING_UNKNOWN", mySavePath.c_str());
			break;
		case tinyxml2::XML_ERROR_EMPTY_DOCUMENT:
			DL_DEBUG("Failed to Save XML File. File: %s, Error: XML_ERROR_EMPTY_DOCUMENT", mySavePath.c_str());
			break;
		case tinyxml2::XML_ERROR_MISMATCHED_ELEMENT:
			DL_DEBUG("Failed to Save XML File. File: %s, Error: XML_ERROR_MISMATCHED_ELEMENT", mySavePath.c_str());
			break;
		case tinyxml2::XML_ERROR_PARSING:
			DL_DEBUG("Failed to Save XML File. File: %s, Error: XML_ERROR_PARSING", mySavePath.c_str());
			break;
		case tinyxml2::XML_CAN_NOT_CONVERT_TEXT:
			DL_DEBUG("Failed to Save XML File. File: %s, Error: XML_CAN_NOT_CONVERT_TEXT", mySavePath.c_str());
			break;
		case tinyxml2::XML_NO_TEXT_NODE:
			DL_DEBUG("Failed to Save XML File. File: %s, Error: XML_NO_TEXT_NODE", mySavePath.c_str());
			break;
		case tinyxml2::XML_ERROR_COUNT:
			DL_DEBUG("Failed to Save XML File. File: %s, Error: XML_ERROR_COUNT", mySavePath.c_str());
			break;
		default:
			DL_DEBUG("Failed to Save XML File. File: %s, Error: Unknown, non of tinyxml's error codes caught it :(", mySavePath.c_str());
			break;
		}
#pragma endregion

		DL_ASSERT("[XMLWriter]: Failed to Save XML File. Check Debuglog for error");
	}
	else
	{
		myHasUnsavedChanges = false;
	}
}
Beispiel #18
0
/*
 * -- setup_tapealert - Setup TapeAlert in polling mode.  Disable
 * recovered error check condition mode.  Disable test mode. Set
 * all other flags to the default values listed in the TapeAlert
 * Specification v3.
 */
static void
setup_tapealert(dev_ent_t *un, int fd)
{
	int		resid;		/* bytes not xfered */
#define	LEN 255				/* max page len */
	uchar_t		page[LEN];	/* current page */
	int		i, len, offset; /* page variables */
#define	PERF 0x80			/* performance */
#define	EBF 0x20			/* enable background funcs */
#define	EWASC 0x10			/* excpt warn chk cond */
#define	DEXCPT 0x08			/* polling mode */
#define	TEST 0x04			/* test mode */
#define	LOGERR 0x01			/* logging of errors */
#define	MIRE 0x03			/* tapealert mode */
#define	MIRE_MASK 0x0f			/* mire field */
	sam_extended_sense_t    *sense; /* device sense data ptr */
	uchar_t		 pagechg[LEN];	/* changable page */
	int		 offsetchg;	/* chg page variables */
	uchar_t		 cdb[SAM_CDB_LENGTH];    /* custom cdb */


	/*
	 * Setup TapeAlert mode page in polling mode.
	 */


	memset(page, 0, LEN);
	memset(pagechg, 0, LEN);
	sense = (sam_extended_sense_t *)SHM_REF_ADDR(un->sense);

	/* get current page */
	if (scsi_cmd(fd, un, SCMD_MODE_SENSE, 30, page, LEN, 0x1c,
	    &resid) < 0) {
		DevLog(DL_DEBUG(12009), sense->es_key, sense->es_add_code,
		    sense->es_qual_code);
		goto done;
	}
	len = page[0]+1;
	page[0] = 0;
	offset = page[3];
	page[4+offset] &= 0x7f;


	/* get changeable page */
	memset(cdb, 0, SAM_CDB_LENGTH);
	cdb[0] = SCMD_MODE_SENSE;
	if (IS_ROBOT(un)) {
		cdb[1] = 0x08;
	}
	cdb[2] = 0x40 | 0x1c;
	cdb[4] = LEN;
	if (scsi_cmd(fd, un, SCMD_ISSUE_CDB, 30, cdb, 6, pagechg, LEN,
	    USCSI_READ, &resid) < 0) {
		DevLog(DL_DEBUG(12010), sense->es_key, sense->es_add_code,
		    sense->es_qual_code);
		goto done;
	}
	offsetchg = pagechg[3];


	/*
	 * Change current TapeAlert page settings to polling mode.
	 */


	/* performance */
	if ((pagechg[6+offsetchg] & PERF) == PERF) {
		page[6+offset] &= ~PERF;
	}

	/* enable background functions */
	if ((pagechg[6+offsetchg] & EBF) == EBF) {
		page[6+offset] &= ~EBF;
	}

	/* exception warning reporting */
	if ((pagechg[6+offsetchg] & EWASC) == EWASC) {
		page[6+offset] &= ~EWASC;
	}

	/* disable exception control */
	if ((pagechg[6+offsetchg] & DEXCPT) == DEXCPT) {
		page[6+offset] |= DEXCPT;
	}

	/* test mode */
	if ((pagechg[6+offsetchg] & TEST) == TEST) {
		page[6+offset] &= ~TEST;
	}

	/* log err */
	if ((pagechg[6+offsetchg] & LOGERR) == LOGERR) {
		page[6+offset] &= ~LOGERR;
	}

	/* MIRE - field ignored if DEXCPT is set */
	if ((pagechg[7+offsetchg] & MIRE_MASK) != 0) {
		page[7+offset] &= ~(pagechg[7+offsetchg] & MIRE_MASK);
		page[7+offset] |= (MIRE & pagechg[7+offsetchg]);
		if ((page[7+offset] & MIRE_MASK) != MIRE) {
			page[7+offset] &= ~MIRE_MASK;
		}
	}

	/* interval timer */
	for (i = 0; i < 4; i++) {
		if (pagechg[i+8+offset] != 0) {
			page[i+8+offset] &= ~(pagechg[i+8+offset]);
		}
	}

	/* report count / test flag number */
	for (i = 0; i < 4; i++) {
		if (pagechg[i+12+offset] != 0) {
			page[i+12+offset] &= ~(pagechg[i+12+offset]);
		}
	}

	/* set polling mode and defaults */
	memset(cdb, 0, SAM_CDB_LENGTH);
	cdb[0] = SCMD_MODE_SELECT;
	cdb[1] = 0x10; /* pf bit */
	cdb[4] = len;
	if (scsi_cmd(fd, un, SCMD_ISSUE_CDB, 30, cdb, 6, page, len,
	    USCSI_WRITE, &resid) < 0) {
		DevLog(DL_DEBUG(12011), sense->es_key, sense->es_add_code,
		    sense->es_qual_code);
		goto done;
	}

done:
	/* log run-time settings from current mode page query */
	memset(page, 0, LEN);
	if (scsi_cmd(fd, un, SCMD_MODE_SENSE, 30, page, LEN, 0x1c,
	    &resid) < 0) {
		DevLog(DL_DEBUG(12012), sense->es_key, sense->es_add_code,
		    sense->es_qual_code);
		return;
	}
	offset = page[3];
	if (page[6+offset] != 8 || page[7+offset] != 3) {
		DevLog(DL_DEBUG(12013), page[6+offset], page[7+offset]);
	}
}
Beispiel #19
0
/*
 * --- get_supports_tapealert - determine if the robot or tape drive supports
 * TapeAlert.
 */
void
get_supports_tapealert(dev_ent_t *un, int fd)
{
	int			local_open = 0;
	int			open_fd;
	sam_extended_sense_t    *sense;
#define	PAGE_LEN 256
	char			page[PAGE_LEN], *page_ptr;
	int			i, page_len, resid;
	boolean_t		unlock_needed = B_FALSE;


	/* Feature check. */
	if ((un->tapealert & TAPEALERT_ENABLED) == 0) {
		return;
	}

	/* Clear previous success flag. */
	un->tapealert &= ~TAPEALERT_SUPPORTED;

	/* Only tape drives and robots. */
	if (un->scsi_type != 1 && un->scsi_type != 8) {
		return;
	}

	/* Local file descriptor open used by fifo command message. */
	if (fd < 0) {
		if ((open_fd = open(un->name, O_RDONLY | O_NONBLOCK)) < 0) {
			if (IS_TAPE(un)) {
					char	*open_name;
					if ((open_fd = open((open_name =
					    samst_devname(un)),
					    O_RDONLY | O_NONBLOCK)) < 0) {
						if (open_name != (char *)
						    un->dt.tp.samst_name)
							free(open_name);
						return;
					} else {
						INC_OPEN(un);
						if (open_name != (char *)
						    un->dt.tp.samst_name)
							free(open_name);
						local_open = TRUE;
					}
			} else {
				DevLog(DL_DEBUG(12014));
				return;
			}
		} else {
			INC_OPEN(un);
			local_open = TRUE;
		}
	} else {
		open_fd = fd;
	}

	/* Look for log sense tapealert page 0x2e */
	sense = (sam_extended_sense_t *)SHM_REF_ADDR(un->sense);
	(void) memset(sense, 0, sizeof (sam_extended_sense_t));

	if (mutex_trylock(&un->io_mutex) == 0) {
		unlock_needed = B_TRUE;
	}

	memset(page, 0, PAGE_LEN);
	if (scsi_cmd(open_fd, un, SCMD_LOG_SENSE, 0, page, 0, 0, 0,
	    PAGE_LEN, &resid) >= 0) {

		page_len = ((PAGE_LEN - resid) >= 4 ? (PAGE_LEN - resid) : 0);
		if (page_len >= 4) {
			page_len = (page[2] << 8) | page[3];
			page_ptr = page + 4;
		}

		for (i = 0; i < page_len; i++) {
			if (page_ptr[i] == 0x2e) {
				/* initialize tapealert data */
				un->tapealert |= TAPEALERT_SUPPORTED;
				un->tapealert_flags = 0;
				un->tapealert_vsn[0] = '\0';
				DevLog(DL_ALL(12001));
				setup_tapealert(un, open_fd);
				break;
			}
		}
	}

	/* query, clear, and report active flags at setup */
	un->tapealert |= TAPEALERT_INIT_QUERY;
	TAPEALERT(open_fd, un);
	un->tapealert &= ~TAPEALERT_INIT_QUERY;

	if (unlock_needed == B_TRUE) {
		mutex_unlock(&un->io_mutex);
	}
	if (local_open) {
		(void) close(open_fd);
		DEC_OPEN(un);
	}
}
Beispiel #20
0
/* --- tapealert_sysevent - send a tapealert sysevent to n event handlers */
static int		/* 0 successful */
tapealert_sysevent(
	char *src_fn,		/* source filename */
	int src_ln,		/* source file line number */
	dev_ent_t *un,		/* device */
	int flags_len,		/* num valid tapealert flags */
	uint64_t flags,		/* tapealert flags */
	uint64_t *seq_no)	/* sysevent sequence number */
{
	int			rtn = 1;
	time_t			tm;
	nvlist_t		*attr_list = NULL;
	sysevent_id_t		eid;
	boolean_t		free_attr_list = B_FALSE;
	char			*str;

	*seq_no = 0;


	/*
	 * build and send sysevent with active tapealert flags
	 */
	if (nvlist_alloc(&attr_list, 0, 0)) {
		DevLog(DL_DEBUG(12008), "alloc", strerror(errno));
		goto done;
	}
	free_attr_list = B_TRUE;

#ifdef DEBUG
	if (nvlist_add_string(attr_list, TAPEALERT_SRC_FILE, src_fn)) {
		DevLog(DL_DEBUG(12008), TAPEALERT_SRC_FILE, strerror(errno));
		goto done;
	}
	if (nvlist_add_int32(attr_list, TAPEALERT_SRC_LINE, src_ln)) {
		DevLog(DL_DEBUG(12008), TAPEALERT_SRC_LINE, strerror(errno));
		goto done;
	}
#endif /* DEBUG */
	if (nvlist_add_string(attr_list, TAPEALERT_VENDOR,
	    (char *)un->vendor_id)) {
		DevLog(DL_DEBUG(12008), TAPEALERT_VENDOR, strerror(errno));
		goto done;
	}
	if (nvlist_add_string(attr_list, TAPEALERT_PRODUCT,
	    (char *)un->product_id)) {
		DevLog(DL_DEBUG(12008), TAPEALERT_PRODUCT, strerror(errno));
		goto done;
	}
	if (nvlist_add_string(attr_list, TAPEALERT_USN, (char *)un->serial)) {
		DevLog(DL_DEBUG(12008), TAPEALERT_USN, strerror(errno));
		goto done;
	}
	if (nvlist_add_string(attr_list, TAPEALERT_REV, (char *)un->revision)) {
		DevLog(DL_DEBUG(12008), TAPEALERT_REV, strerror(errno));
		goto done;
	}
	time(&tm);
	if (nvlist_add_int32(attr_list, TAPEALERT_TOD, tm)) {
		DevLog(DL_DEBUG(12008), TAPEALERT_TOD, strerror(errno));
		goto done;
	}
	if (nvlist_add_int16(attr_list, TAPEALERT_EQ_ORD, un->eq)) {
		DevLog(DL_DEBUG(12008), TAPEALERT_EQ_ORD, strerror(errno));
		goto done;
	}
	if (nvlist_add_string(attr_list, TAPEALERT_NAME, un->name)) {
		DevLog(DL_DEBUG(12008), TAPEALERT_NAME, strerror(errno));
		goto done;
	}
	if (nvlist_add_byte(attr_list, TAPEALERT_VERSION, un->version)) {
		DevLog(DL_DEBUG(12008), TAPEALERT_VERSION, strerror(errno));
		goto done;
	}
	if (nvlist_add_byte(attr_list, TAPEALERT_INQ_TYPE, un->scsi_type)) {
		DevLog(DL_DEBUG(12008), TAPEALERT_INQ_TYPE, strerror(errno));
		goto done;
	}
	if (strlen(str = (char *)un->set) < 1) {
		str = TAPEALERT_EMPTY_STR;
	}
	if (nvlist_add_string(attr_list, TAPEALERT_SET, str)) {
		DevLog(DL_DEBUG(12008), TAPEALERT_SET, strerror(errno));
		goto done;
	}
	if (nvlist_add_int16(attr_list, TAPEALERT_FSEQ, un->fseq)) {
		DevLog(DL_DEBUG(12008), TAPEALERT_FSEQ, strerror(errno));
		goto done;
	}
	if (strlen(str = (char *)un->vsn) < 1) {
		str = TAPEALERT_EMPTY_STR;
	}
	if (nvlist_add_string(attr_list, TAPEALERT_VSN, str)) {
		DevLog(DL_DEBUG(12008), TAPEALERT_VSN, strerror(errno));
		goto done;
	}
	if (nvlist_add_int16(attr_list, TAPEALERT_FLAGS_LEN, flags_len)) {
		DevLog(DL_DEBUG(12008), TAPEALERT_FLAGS_LEN, strerror(errno));
		goto done;
	}
	if (nvlist_add_uint64(attr_list, TAPEALERT_FLAGS, flags)) {
		DevLog(DL_DEBUG(12008), TAPEALERT_FLAGS,
		    strerror(errno));
		goto done;
	}

	/* class, subclass, vendor, publisher, attribute list, event id */
	if (sysevent_post_event(TAPEALERT_SE_CLASS, TAPEALERT_SE_SUBCLASS,
	    TAPEALERT_SE_VENDOR, TAPEALERT_SE_PUBLISHER, attr_list, &eid)
	    != 0) {
		DevLog(DL_DEBUG(12008), TAPEALERT_SE_PUBLISHER,
		    strerror(errno));
		goto done;
	}
	*seq_no = eid.eid_seq;

	/*
	 * tapealert sysevent successfully sent.
	 */
	rtn = 0;

done:
	if (free_attr_list == B_TRUE) {
		nvlist_free(attr_list);
	}

	return (rtn);
}
Beispiel #21
0
	void LineRenderer::LineSetup()
	{

		std::wstring path = WF::WideStringConvertion("Data\\Shaders\\Line.fso");
		HRESULT result = D3DX11CreateEffectFromFile(path.c_str(), NULL, myEngine->GetDevice().Get(), &myLineEffect);

		if (FAILED(result) == true)
		{
			std::string errorMessage = "Failed to create effect from file with path: Data\\Shaders\\Line.fso";
			WF::AssertComAndWindowsError(result, errorMessage.c_str());
		}

		myLineTechnique = myLineEffect->GetTechniqueByIndex(0);

		if (myLineTechnique->IsValid() == false)
		{
			DL_DEBUG("Technique in effect not valid");
		}

		COMObjectPointer<ID3DX11EffectPass> effectPass = myLineTechnique->GetPassByIndex(0);
		if (effectPass->IsValid() == false)
		{
			DL_DEBUG("EffectPass in effect not valid");
		}

		myLineProjectionMatrix = myLineEffect->GetVariableByName("Projection")->AsMatrix();
		myLineCameraMatrix = myLineEffect->GetVariableByName("Camera")->AsMatrix();

		D3DX11_PASS_SHADER_DESC effectVsDesc;
		effectPass->GetVertexShaderDesc(&effectVsDesc);
		D3DX11_EFFECT_SHADER_DESC effectVsDesc2;
		effectVsDesc.pShaderVariable->GetShaderDesc(effectVsDesc.ShaderIndex, &effectVsDesc2);
		const void *vsCodePtr = effectVsDesc2.pBytecode;
		unsigned vsCodeLen = effectVsDesc2.BytecodeLength;

		CU::GrowingArray<D3D11_INPUT_ELEMENT_DESC> inputDescription(4);

		inputDescription.Add({ "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 });


		result = myEngine->GetDevice()->CreateInputLayout(&inputDescription[0], inputDescription.Size(), vsCodePtr, vsCodeLen, &myLineInputLayout);

		if (FAILED(result) == true)
		{
			WF::AssertComAndWindowsError(result, "Input layout error");
		}

		VertexDataWrapper vertexData;

		vertexData.myNumberOfVertexes = 10000;
		vertexData.mySize = sizeof(float) * 4 * vertexData.myNumberOfVertexes;
		vertexData.myVertexData = new char[vertexData.mySize];

		vertexData.myStride = 16;

		myLineDummyBuffer.CreateDynamic(myEngine->GetDevice(), &vertexData);


		if (FAILED(result) == true)
		{
			WF::AssertComAndWindowsError(result, "Failed to create input layout for effect.");
		}
	}