int WriteSplitData(struct ipmi_intf *intf, char *Buffer, char Sector, uint32_t NumBytes, uint32_t timeout) { uint32_t BytesWritten = 0; int retVal; if (NumBytes == 0) { return 0; } while (BytesWritten < NumBytes) { if ((retVal = WriteCD(intf->fd, Sector, (Buffer + BytesWritten), timeout, NumBytes)) != 0) { return retVal; } BytesWritten += NumBytes; } return 0; }
bool VFSHandle_ZIP::Close(void) { m_cd.offset = m_stream.tellg(); for(unsigned int a=0;a<m_fh.size();a++) WriteFH(m_fh[a]); WriteCD(); bool r1 = VFSHandle_file::Close(); bool r2 = fusion->vfs->Close(m_handle); DeleteCache(); delete[] m_file; delete[] m_archive; m_handle = NULL; m_fileid = 0; if(r1 == true && r2 == true) return true; return false; }
int SendDataToUSBDriver(struct ipmi_intf *intf, char *ReqBuffer, unsigned int ReqBuffLen, unsigned char *ResBuffer, int *ResBuffLen, unsigned int timeout) { char CmdHeaderBuffer[sizeof(CONFIG_CMD)]; int retVal; int waitretval = 0; unsigned int to = 0; uint32_t DataLen = 0; CONFIG_CMD *pG2CDCmdHeader = (CONFIG_CMD *)CmdHeaderBuffer; /* FillHeader */ InitCmdHeader(pG2CDCmdHeader); /* Set command number */ pG2CDCmdHeader->Command = CMD_RESERVED; /* Fill Lengths */ pG2CDCmdHeader->DataOutLen = *ResBuffLen; pG2CDCmdHeader->DataInLen = ReqBuffLen; if (!timeout) { to = 3000; } DataLen = sizeof(CONFIG_CMD); if (WriteCD(intf->fd, SCSI_AMIDEF_CMD_SECTOR, (char *)(pG2CDCmdHeader), to, DataLen) == (-1)) { lprintf(LOG_ERR, "Error in Write CD of SCSI_AMIDEF_CMD_SECTOR"); return (-1); } /* Write the data to hard disk */ if ((retVal = WriteSplitData(intf, ReqBuffer, SCSI_AMIDEF_DATA_SECTOR, ReqBuffLen, timeout)) != 0) { lprintf(LOG_ERR, "Error in WriteSplitData of SCSI_AMIDEF_DATA_SECTOR"); return (-1); } if (!timeout) { return 0; } /* Read Status now */ waitretval = WaitForCommandCompletion(intf, pG2CDCmdHeader, timeout, DataLen); if (waitretval != 0) { lprintf(LOG_ERR, "WaitForCommandComplete failed"); return (0 - waitretval); } else { lprintf(LOG_DEBUG, "WaitForCommandCompletion SUCCESS"); } switch (pG2CDCmdHeader->Status) { case ERR_SUCCESS: *ResBuffLen = pG2CDCmdHeader->DataOutLen; lprintf(LOG_DEBUG, "Before ReadSplitData %x", *ResBuffLen); if (ReadSplitData(intf, (char *)ResBuffer, SCSI_AMIDEF_DATA_SECTOR, pG2CDCmdHeader->DataOutLen) != 0) { lprintf(LOG_ERR, "Err ReadSplitData SCSI_AMIDEF_DATA_SCTR"); return (-1); } /* Additional read to see verify there was not problem * with the previous read */ DataLen = sizeof(CONFIG_CMD); ReadCD(intf->fd, SCSI_AMIDEF_CMD_SECTOR, (char *)(pG2CDCmdHeader), DataLen); break; case ERR_BIG_DATA: lprintf(LOG_ERR, "Too much data"); break; case ERR_NO_DATA: lprintf(LOG_ERR, "Too little data"); break; case ERR_UNSUPPORTED: lprintf(LOG_ERR, "Unsupported command"); break; default: lprintf(LOG_ERR, "Unknown status"); } return pG2CDCmdHeader->Status; }