#include <df.h>
Definition at line 905 of file df.h.
Public Member Functions | |
| df_Packer (UInt32_t a_blkType, bbt_BufType_t a_bufType, UInt32_t a_blkSize, UInt16_t a_numCopies) | |
| df_Packer (df_BlockProxyWriter *a_blockProxyWriter_p) | |
| virtual | ~df_Packer () |
| void | WriteRecFile (UInt64_t a_idFile, UInt64_t a_idMig, UInt64_t a_idParent, UInt64_t a_idParentOld, const string &a_name, const string &a_nameOld, ivd_FileInfo_t &a_info, UInt32_t a_changeFlags, UInt32_t a_flags=0, UInt64_t a_chunkSize=0) |
| This implementation is used to prepare data to be written to media. | |
| void | WriteRecFile (UInt64_t a_idFile, UInt64_t a_idParent, const string &a_name, df_StandardAttr_t &standAttr) |
| used by NSC to fill data need for recovery NOTE standard attributes in NSC are already in network format, so don't convert them. | |
| void | WriteRecFileEnd (UInt32_t a_status) |
| void | WriteRecBSStart (UInt32_t a_type, const string &a_name, UInt64_t a_streamSize, UInt64_t a_fileOffset=0) |
| void | GetBSData (UInt8_t *&a_block, UInt32_t &a_size) |
| Request pointer to area, where raw data can be written. | |
| void | WriteBSData (bool a_flushEmpty=false) |
| Write previously allocated space using GetBSData();. | |
| void | WriteRecBSEnd (UInt32_t a_status) |
| void | WriteRecFRIStart () |
| void | WriteRecFRIEnd () |
| void | EndOfData () |
| void | NewDiskBuffer (const string &a_id, string &a_diskBufferFS, bool a_append=false) |
| void | NewNetBuffer (i_UploadAgent_ptr a_uploadAgt) |
| void | NewStdIOBuffer (const string &a_fName) |
| void | Go () |
| UInt32_t | GetBlkNum () |
Static Public Member Functions | |
| static void | WriteRecCmnRaw (UInt32_t a_type, UInt32_t a_size, UInt32_t a_flags, UInt32_t a_recNum, df_RecCmn_t *a_recCmn_p) |
| static void | WriteRecMedVolHdr (const cmn_UUID_t &a_volID, const cmn_UUID_t &a_poolID, const cmn_UUID_t &a_partID, UInt32_t a_partNumber, UInt32_t a_blockSize, UInt32_t a_numAccess, UInt32_t a_numAppends, UInt32_t a_numOverwrites, ivd_Time_t a_timeAccess, ivd_Time_t a_timeWrite, ivd_Time_t a_timeOverwrite, string a_appID, UInt32_t a_volFlags, UInt8_t a_sysVolIndex, UInt8_t *a_volHdr, UInt32_t a_volHdrSize) |
| ECMA volume header and IVD specific headers are written with this function. | |
| static void | WriteRecFRIStart (const cmn_UUID_t &a_volID, const cmn_UUID_t &a_poolID, const cmn_UUID_t &a_partID, UInt32_t a_startPos, UInt32_t a_recNum, UInt8_t *a_friBuf, UInt32_t a_friBufSize) |
| FRI Start record is written with this function. | |
| static void | WriteRecFRIEnd (const cmn_UUID_t &a_volID, const cmn_UUID_t &a_poolID, const cmn_UUID_t &a_partID, UInt32_t a_startPos, UInt32_t a_endPos, UInt32_t a_status, UInt32_t a_recNum, UInt8_t *a_friBuf, UInt32_t a_friBufSize) |
| FRI End record is written with this function. | |
| static void | WriteRecFRISplitInfo (UInt64_t a_idFile, UInt64_t a_allStreamOffset, UInt64_t a_allStreamSize, UInt32_t a_streamType, UInt32_t a_recNum, UInt32_t a_mediaBlockAddress, UInt8_t *a_friBuf, UInt32_t a_friBufSize) |
| FRI Split Info record is written with this function. | |
| static void | WriteRecFileEndRaw (UInt64_t a_idFile, UInt64_t a_idMig, UInt32_t a_status, UInt32_t a_recNum, UInt8_t *a_buffer, UInt32_t a_flags=0) |
| static void | WriteRecBSEndRaw (UInt64_t a_idFile, UInt32_t a_status, UInt32_t a_streamType, UInt64_t a_streamSize, UInt64_t a_allStreamSize, const string &a_name, UInt32_t a_recNum, UInt8_t *a_buffer) |
Protected Member Functions | |
| UInt8_t * | WriteRecCmn (UInt32_t a_type, UInt32_t a_size, UInt32_t a_flags=0) |
| Write common part of all records (except ECMA Volume Header). | |
| void | MakeSpaceForData (const UInt64_t &a_streamLeft, UInt8_t *&a_block, UInt32_t &a_size) |
| Checks whether data can fit in current record (writes df_RecEmbeddedData_t) or new block must be requested. | |
Static Protected Member Functions | |
| static void | WriteECMAVolHeader (UInt32_t a_partNumber, UInt8_t *a_volHdr) |
| Write ECMA compliant volume ID. | |
Protected Attributes | |
| auto_ptr< df_BlockProxyWriter > | m_blockProxyWriter |
| UInt32_t | m_prevRec |
| Which was the previous record type? | |
| UInt32_t | m_recNum |
| Current record number. | |
| UInt64_t | m_idFile |
| UInt64_t | m_idMig |
| string | m_fileName |
| UInt64_t | m_chunkSize |
| UInt64_t | m_fileOffset |
| UInt32_t | m_streamType |
| string | m_streamName |
| UInt64_t | m_streamOffset |
| Reset to 0 at the beginning of each stream. | |
| UInt64_t | m_streamSize |
| UInt64_t | m_allStreamSize |
| Size of all stream records of a file up to current position. | |
| UInt64_t | m_streamAlloc |
| Helper to detect if a stream is filled properly. | |
| UInt16_t | m_numCopies |
Private Attributes | |
| log_CLASSID_m | |
| Macro to add class name member s_className. | |
| df_Packer::df_Packer | ( | UInt32_t | a_blkType, | |
| bbt_BufType_t | a_bufType, | |||
| UInt32_t | a_blkSize, | |||
| UInt16_t | a_numCopies | |||
| ) |
Definition at line 33 of file df_packer.cpp.
References log_FUNC_A_m.
00038 : m_blockProxyWriter(new df_Writer(a_blkType, a_bufType, a_blkSize)), 00039 m_prevRec(rec_NoRec_c), 00040 m_recNum(0), 00041 m_streamAlloc(0), 00042 m_numCopies(a_numCopies) { 00043 00044 log_FUNC_A_m(df_Packer, "copies: " << a_numCopies); 00045 }
| df_Packer::df_Packer | ( | df_BlockProxyWriter * | a_blockProxyWriter_p | ) |
Definition at line 47 of file df_packer.cpp.
References log_FUNC_A_m, and m_blockProxyWriter.
00048 : m_blockProxyWriter(a_blockProxyWriter_p), 00049 m_prevRec(rec_NoRec_c), 00050 m_recNum(0), 00051 m_streamAlloc(0), 00052 m_numCopies(1) { 00053 00054 log_FUNC_A_m(df_Packer, " Custom writer. block size " 00055 << m_blockProxyWriter->GetRawBlockSize()); 00056 // writer needs to be init before use 00057 // in non custom writer then user has to call Go() 00058 m_blockProxyWriter->Go(); 00059 }
| df_Packer::~df_Packer | ( | ) | [virtual] |
Definition at line 61 of file df_packer.cpp.
References dbg_LOW, df_FS_ABORTED, df_IsValidTerminator(), df_SS_ABORTED, log_DBG_m, log_FUNC_m, m_prevRec, rec_BSStart_c, rec_Data_c, rec_EmbData_c, rec_FileHdr_c, rec_NoRec_c, WriteRecBSEnd(), and WriteRecFileEnd().
00061 { 00062 log_FUNC_m(~df_Packer); 00063 00064 try { 00065 00066 if (uncaught_exception()) { 00067 log_DBG_m(dbg_LOW, 00068 "DTOR called because of an exception."); 00069 } 00070 00071 if (!df_IsValidTerminator(m_prevRec)) { 00072 log_DBG_m(dbg_LOW, 00073 "Data stream not properly terminated. Terminating now."); 00074 00075 // Teminate the output stream auto-magically 00076 00077 if (m_prevRec == rec_FileHdr_c) { 00078 WriteRecFileEnd(df_FS_ABORTED); 00079 } 00080 else if ( m_prevRec == rec_BSStart_c 00081 || m_prevRec == rec_EmbData_c 00082 || m_prevRec == rec_Data_c) { 00083 WriteRecBSEnd(df_SS_ABORTED); 00084 WriteRecFileEnd(df_FS_ABORTED); 00085 } 00086 else if (m_prevRec == rec_NoRec_c) { 00087 // TODO: Anything? 00088 } 00089 } 00090 } 00091 catch (ivd_Exception &ie) { 00092 log_DBG_m(dbg_LOW, 00093 "Ignoring exception in DTOR." << endl << 00094 "Error: " << ie); 00095 } 00096 }

| void df_Packer::WriteECMAVolHeader | ( | UInt32_t | a_partNumber, | |
| UInt8_t * | a_volHdr | |||
| ) | [static, protected] |
Write ECMA compliant volume ID.
Definition at line 99 of file df_packer.cpp.
References cmn_Num2Str(), ecma_ImplID_c, ecma_LblStdVer_c, ecma_VolID_c, df_ECMAVolumeLabel_t::ecmaHdr, df_ECMAVolumeLabel_t::first, ie_INVALID_ARG, df_ECMAFirstVolumeLabel_t::implID, df_ECMALblHdr_t::lblID, df_ECMAFirstVolumeLabel_t::lblStdVer, log_FUNC_m, log_MARKLINE_m, and df_ECMALblHdr_t::number.
Referenced by WriteRecMedVolHdr().
00101 { 00102 00103 log_FUNC_m(WriteECMAVolHeader); 00104 00105 df_ECMAVolumeLabel_t *ecmaLabel_p = 00106 reinterpret_cast<df_ECMAVolumeLabel_t*>(a_volHdr); 00107 00108 memset(ecmaLabel_p, ' ', sizeof(*ecmaLabel_p)); 00109 00110 memcpy( 00111 &(ecmaLabel_p->ecmaHdr.lblID), 00112 ecma_VolID_c, 00113 sizeof(ecmaLabel_p->ecmaHdr.lblID)); 00114 00115 ecmaLabel_p->ecmaHdr.number = static_cast<UInt8_t>(a_partNumber); 00116 00117 if (a_partNumber == 1) { 00118 00119 //ecmaLabel_p->first.volID = SHORT IVD MED ID ?? 00120 //ecmaLabel_p->first.volAccess = // Filled with SPACE (No restrictions) 00121 //ecmaLabel_p->first.res1 = // Filled with SPACEs 00122 00123 if (ecma_ImplID_c.length() > sizeof(ecmaLabel_p->first.implID)) { 00124 log_MARKLINE_m; 00125 throw ivd_InternalError( 00126 ie_INVALID_ARG, 00127 "Length of ecma_ImplID_c > 13 :" + 00128 cmn_Num2Str(ecma_ImplID_c.length()) ); 00129 } 00130 memcpy( 00131 ecmaLabel_p->first.implID, 00132 ecma_ImplID_c.c_str(), 00133 ecma_ImplID_c.length()); 00134 00135 //ecmaLabel_p->first.ownerID = // Filled with SPACEs 00136 //ecmaLabel_p->first.res2 = // Filled with SPACEs 00137 ecmaLabel_p->first.lblStdVer = ecma_LblStdVer_c; 00138 } 00139 else { 00140 // CONTENTS UNSPECIFIED by ECMA standard. 00141 //ecmaLabel_p->other.volID = SHORT IVD MED ID ?? 00142 } 00143 }


| void df_Packer::WriteRecCmnRaw | ( | UInt32_t | a_type, | |
| UInt32_t | a_size, | |||
| UInt32_t | a_flags, | |||
| UInt32_t | a_recNum, | |||
| df_RecCmn_t * | a_recCmn_p | |||
| ) | [static] |
Definition at line 146 of file df_packer.cpp.
References dbg_NORM, df_recCookie_c, df_verMaj_c, df_verMin_c, df_RecCmn_t::flags, hton(), log_DBG_INT_m, log_FUNC_INT_m, df_RecCmn_t::magicCookie, df_RecCmn_t::seqNum, df_RecCmn_t::size, df_RecCmn_t::type, df_RecCmn_t::verMajor, and df_RecCmn_t::verMinor.
Referenced by WriteRecBSEndRaw(), WriteRecCmn(), WriteRecFileEndRaw(), WriteRecFRIEnd(), WriteRecFRISplitInfo(), WriteRecFRIStart(), and WriteRecMedVolHdr().
00151 { 00152 00153 log_FUNC_INT_m(WriteRecCmnRaw); 00154 00155 memset(a_recCmn_p, 0, sizeof(*a_recCmn_p)); 00156 00157 log_DBG_INT_m(dbg_NORM, "RecCmn: " << string((char*)(&a_type), sizeof(a_type)) ); 00158 00159 // Setting data fields 00160 a_recCmn_p->size = hton(a_size); 00161 00162 memcpy(&(a_recCmn_p->verMajor), df_verMaj_c, sizeof(a_recCmn_p->verMajor)); 00163 memcpy(&(a_recCmn_p->verMinor), df_verMin_c, sizeof(a_recCmn_p->verMinor)); 00164 00165 memcpy(a_recCmn_p->magicCookie, df_recCookie_c, 00166 sizeof(a_recCmn_p->magicCookie)); 00167 00168 // NOTE: hton and ntoh are not used on record type, because its memory print 00169 // is the way we need it. 00170 a_recCmn_p->type = a_type; 00171 00172 a_recCmn_p->flags = hton(a_flags); 00173 a_recCmn_p->seqNum = hton(a_recNum); 00174 }


| UInt8_t * df_Packer::WriteRecCmn | ( | UInt32_t | a_type, | |
| UInt32_t | a_size, | |||
| UInt32_t | a_flags = 0 | |||
| ) | [protected] |
Write common part of all records (except ECMA Volume Header).
Definition at line 177 of file df_packer.cpp.
References blk_Data_c, df_IsValidPredecessor(), ie_DF_INVSEQ, log_FUNC_m, log_WRN_m, m_blockProxyWriter, m_prevRec, m_recNum, NULL, rec_NoRec_c, and WriteRecCmnRaw().
Referenced by MakeSpaceForData(), WriteRecBSStart(), WriteRecFile(), and WriteRecFileEnd().
00178 { 00179 00180 log_FUNC_m(WriteRecCmn); 00181 00182 if (!df_IsValidPredecessor(blk_Data_c, m_prevRec, a_type)) { 00183 string prevStr = 00184 (m_prevRec == rec_NoRec_c) 00185 ? string("NULL REC") 00186 : string((char*)(&m_prevRec), sizeof(m_prevRec)); 00187 00188 string curStr = 00189 (a_type == rec_NoRec_c) 00190 ? string("NULL REC") 00191 : string((char*)(&a_type), sizeof(a_type)); 00192 00193 throw ivd_InternalError(ie_DF_INVSEQ, 00194 "Record " + prevStr + " can't be followed by " + curStr ); 00195 } 00196 00197 // Allocate space for record 00198 UInt8_t *wp = m_blockProxyWriter->Allocate(a_size); 00199 if (wp == NULL) { 00200 log_WRN_m("NULL block pointer from Allocate(). No reader available."); 00201 return NULL; 00202 } 00203 00204 df_RecCmn_t *recCmn_p = reinterpret_cast<df_RecCmn_t*>(wp); 00205 00206 WriteRecCmnRaw(a_type, a_size, a_flags, ++m_recNum, recCmn_p); 00207 00208 m_prevRec = a_type; 00209 00210 // Increasing position pointer 00211 return m_blockProxyWriter->Move(sizeof(*recCmn_p)); 00212 }


| void df_Packer::MakeSpaceForData | ( | const UInt64_t & | a_streamLeft, | |
| UInt8_t *& | a_block, | |||
| UInt32_t & | a_size | |||
| ) | [protected] |
Checks whether data can fit in current record (writes df_RecEmbeddedData_t) or new block must be requested.
Definition at line 722 of file df_packer.cpp.
References dbg_DETAIL, dbg_NORM, df_ALIGN_m, df_MIN_EMBEDDED_SIZE, hton(), log_DBG_INT_m, log_FUNC_INT_m, log_FUNC_m, log_WRN_m, m_blockProxyWriter, m_fileOffset, m_idFile, m_streamName, m_streamOffset, m_streamType, NULL, rec_EmbData_c, and WriteRecCmn().
Referenced by GetBSData().
00723 { 00724 log_FUNC_INT_m(MakeSpaceForData); 00725 00726 // We have the following options: 00727 // 00728 // 1. Space left in current block -> try to embed in record 00729 // 2. No space left -> we can use raw 00730 // 2.a ...but only if we can fill the whole block... 00731 // 2.b ...otherwise we need to embed in record 00732 00733 UInt32_t freeSize = m_blockProxyWriter->GetFreeSize(); 00734 UInt32_t rawBlkSize = m_blockProxyWriter->GetRawBlockSize(); 00735 00736 // Embed if: 00737 // * space left in current -> try to use it or 00738 // * less left than RAW block size 00739 // 00740 if (freeSize > 0 || a_streamLeft < rawBlkSize) { 00741 00742 log_DBG_INT_m(dbg_NORM, 00743 "Embed, freeSize: " << freeSize << 00744 ", a_streamLeft: " << a_streamLeft); 00745 00746 // we will try to embed 00747 00748 UInt32_t recSize = sizeof(df_RecCmn_t) + 00749 sizeof(df_RecEmbeddedData_t) + 00750 m_streamName.length() + 1; 00751 00752 UInt32_t embSize = 0; 00753 UInt32_t embOffset = recSize; // TODO: add special alignment 00754 00755 if (freeSize >= (recSize + a_streamLeft) 00756 || freeSize >= (recSize + df_MIN_EMBEDDED_SIZE)) { 00757 00758 embSize = freeSize - embOffset; 00759 if (embSize > a_streamLeft) 00760 embSize = static_cast<UInt32_t>(a_streamLeft); 00761 } 00762 else if (a_streamLeft < rawBlkSize) { 00763 // will have to allocate new embedded record new block 00764 embSize = rawBlkSize - m_blockProxyWriter->GetBlockHeaderSize() - embOffset; 00765 if (embSize > a_streamLeft) 00766 embSize = static_cast<UInt32_t>(a_streamLeft); 00767 } 00768 00769 // Embed data into a block (embSize == 0) --> use new raw block 00770 if (embSize > 0) { 00771 UInt8_t *wp = WriteRecCmn(rec_EmbData_c, 00772 df_ALIGN_m(embOffset + embSize)); 00773 if (wp == NULL) { 00774 a_block = NULL, a_size = 0; 00775 return; 00776 } 00777 00778 UInt8_t *recStart = wp - sizeof(df_RecCmn_t); 00779 00780 df_RecEmbeddedData_t *eData_p = 00781 reinterpret_cast<df_RecEmbeddedData_t*>(wp); 00782 memset(eData_p, 0, sizeof(*eData_p)); 00783 00784 eData_p->idFile = hton(m_idFile); 00785 eData_p->streamType = hton(m_streamType); 00786 eData_p->streamOffset = hton(m_streamOffset); 00787 eData_p->chunkOffset = hton(m_fileOffset); 00788 00789 eData_p->data.offset = hton(embOffset); 00790 eData_p->data.size = hton(embSize); 00791 00792 wp = m_blockProxyWriter->Move(sizeof(*eData_p)); 00793 00794 eData_p->streamName.offset = hton(UInt32_t(wp - recStart)); 00795 eData_p->streamName.size = hton(UInt32_t(m_streamName.length() + 1)); 00796 00797 memcpy( 00798 wp, 00799 m_streamName.c_str(), 00800 m_streamName.length() + 1); 00801 00802 wp = m_blockProxyWriter->Move(m_streamName.length() + 1); 00803 00804 // skip pad for data alignment (if any) 00805 if (embOffset - recSize > 0) { 00806 wp = m_blockProxyWriter->Move(embOffset - recSize); 00807 } 00808 00809 a_block = wp; 00810 a_size = embSize; 00811 00812 log_DBG_INT_m(dbg_DETAIL, "EmbData size: " << embSize << 00813 " EmbData offset: " << embOffset); 00814 return; 00815 } 00816 // cannot use free space and more than RAW block size 00817 } 00818 00819 a_block = m_blockProxyWriter->AllocateRawBlock(); 00820 00821 if (a_block == NULL) { 00822 log_FUNC_m(MakeSpaceForData); 00823 log_WRN_m("NULL block pointer from AllocateRawBlock(). No reader available."); 00824 a_block = NULL, a_size = 0; 00825 return; 00826 } 00827 00828 a_size = rawBlkSize; 00829 }


| void df_Packer::WriteRecMedVolHdr | ( | const cmn_UUID_t & | a_volID, | |
| const cmn_UUID_t & | a_poolID, | |||
| const cmn_UUID_t & | a_partID, | |||
| UInt32_t | a_partNumber, | |||
| UInt32_t | a_blockSize, | |||
| UInt32_t | a_numAccess, | |||
| UInt32_t | a_numAppends, | |||
| UInt32_t | a_numOverwrites, | |||
| ivd_Time_t | a_timeAccess, | |||
| ivd_Time_t | a_timeWrite, | |||
| ivd_Time_t | a_timeOverwrite, | |||
| string | a_appID, | |||
| UInt32_t | a_volFlags, | |||
| UInt8_t | a_sysVolIndex, | |||
| UInt8_t * | a_volHdr, | |||
| UInt32_t | a_volHdrSize | |||
| ) | [static] |
ECMA volume header and IVD specific headers are written with this function.
| a_partNumber | ECMA part number (starts from 1!) |
Definition at line 215 of file df_packer.cpp.
References df_RecVolHdr_t::blockSize, dbg_NORM, df_ALIGN_m, df_volFlagSysVolValid_c, df_RecVolHdr_t::flags, hton(), ie_DF_INV_BLK, ivd_Error, log_DBG_m, log_FUNC_m, NULL, df_RecVolHdr_t::numAccess, df_RecVolHdr_t::numAppends, df_RecVolHdr_t::numOverwrites, df_RecVolHdr_t::partID, df_RecVolHdr_t::poolID, rec_VolHdr_c, df_RecVolHdr_t::sysVolIndex, df_RecVolHdr_t::timeAccess, df_RecVolHdr_t::timeInit, df_RecVolHdr_t::timeOverwrite, df_RecVolHdr_t::timeWrite, df_RecVolHdr_t::volID, WriteECMAVolHeader(), and WriteRecCmnRaw().
Referenced by bea_Volume::Init().
00233 { 00234 00235 log_FUNC_m(WriteRecMedVolHdr); 00236 00237 log_DBG_m(dbg_NORM, 00238 endl << 00239 "a_volID = " << a_volID << endl << 00240 "a_poolID = " << a_poolID << endl << 00241 "a_partID = " << a_partID << endl << 00242 "a_appID = " << a_appID); 00243 00244 UInt32_t recSize = df_ALIGN_m(sizeof(df_RecCmn_t) + 00245 sizeof(df_RecVolHdr_t) + 00246 a_appID.length()+1); 00247 00248 if (sizeof(df_ECMAVolumeLabel_t) + recSize > a_volHdrSize) { 00249 throw ivd_Error(ie_DF_INV_BLK, "Block not large enough to hold VolHdr"); 00250 } 00251 00252 WriteECMAVolHeader(a_partNumber, a_volHdr); 00253 00254 // ECMA volume label is not a part of IVD label record. 00255 00256 df_RecCmn_t *recCmn_p = 00257 reinterpret_cast<df_RecCmn_t*>(a_volHdr + sizeof(df_ECMAVolumeLabel_t)); 00258 00259 WriteRecCmnRaw(rec_VolHdr_c, recSize, 0, 0, recCmn_p); 00260 00261 UInt8_t *recStart = reinterpret_cast<UInt8_t*>(recCmn_p); 00262 00263 df_RecVolHdr_t *volHdr_p = 00264 reinterpret_cast<df_RecVolHdr_t*>(recStart + sizeof(*recCmn_p)); 00265 00266 memset(volHdr_p, 0, sizeof(*volHdr_p)); 00267 00268 volHdr_p->flags = a_volFlags; 00269 00270 // Data Format version 01.01 change: 00271 volHdr_p->flags |= df_volFlagSysVolValid_c; 00272 00273 volHdr_p->flags = hton(volHdr_p->flags); 00274 volHdr_p->volID = a_volID; 00275 volHdr_p->poolID = a_poolID; 00276 volHdr_p->partID = a_partID; 00277 volHdr_p->blockSize = hton(a_blockSize); 00278 00279 ivd_Time_t now = (UInt64_t)time(NULL); 00280 volHdr_p->timeInit = hton(now); 00281 volHdr_p->timeAccess = hton(a_timeAccess); 00282 volHdr_p->timeWrite = hton(a_timeWrite); 00283 volHdr_p->timeOverwrite = hton(a_timeOverwrite); 00284 00285 volHdr_p->numAccess = hton(a_numAccess); 00286 volHdr_p->numAppends = hton(a_numAppends); 00287 volHdr_p->numOverwrites = hton(a_numOverwrites); 00288 00289 // Data Format 01.01 change 00290 volHdr_p->sysVolIndex = a_sysVolIndex; // 8-bit, no hton needed 00291 00292 // Append variable length fields(s). 00293 00294 UInt8_t *wp = recStart + sizeof(*recCmn_p) + sizeof(*volHdr_p); 00295 00296 // Offset from the beginning of record (including common part). 00297 volHdr_p->appID.offset = hton(UInt32_t(wp - recStart)); 00298 volHdr_p->appID.size = hton(UInt32_t(a_appID.length()+1)); 00299 00300 memcpy( 00301 wp, 00302 a_appID.c_str(), 00303 a_appID.length()+1); 00304 }


| void df_Packer::WriteRecFRIStart | ( | const cmn_UUID_t & | a_volID, | |
| const cmn_UUID_t & | a_poolID, | |||
| const cmn_UUID_t & | a_partID, | |||
| UInt32_t | a_startPos, | |||
| UInt32_t | a_recNum, | |||
| UInt8_t * | a_friBuf, | |||
| UInt32_t | a_friBufSize | |||
| ) | [static] |
FRI Start record is written with this function.
Definition at line 307 of file df_packer.cpp.
References dbg_DETAIL, df_ALIGN_m, hton(), ie_DF_INV_BLK, ivd_Error, log_DBG_m, log_FUNC_m, df_RecFRIStart_t::partID, df_RecFRIStart_t::poolID, rec_FRIStart_c, df_RecFRIStart_t::startPos, df_RecFRIStart_t::volID, WriteRecCmnRaw(), and WriteRecFRIStart().
00314 { 00315 00316 log_FUNC_m(WriteRecFRIStart); 00317 00318 log_DBG_m(dbg_DETAIL, 00319 endl << 00320 "a_volID = " << a_volID << endl << 00321 "a_poolID = " << a_poolID << endl << 00322 "a_partID = " << a_partID << endl << 00323 "a_startPos = " << a_startPos); 00324 00325 UInt32_t recSize = df_ALIGN_m(sizeof(df_RecCmn_t) + 00326 sizeof(df_RecFRIStart_t)); 00327 00328 if (recSize > a_friBufSize) { 00329 throw ivd_Error(ie_DF_INV_BLK, "Block not large enough for FRIStart."); 00330 } 00331 00332 df_RecCmn_t *recCmn_p = reinterpret_cast<df_RecCmn_t*>(a_friBuf); 00333 00334 WriteRecCmnRaw(rec_FRIStart_c, recSize, 0, a_recNum, recCmn_p); 00335 00336 df_RecFRIStart_t *friStart_p = 00337 reinterpret_cast<df_RecFRIStart_t*>(a_friBuf + sizeof(df_RecCmn_t)); 00338 00339 memset(friStart_p, 0, sizeof(*friStart_p)); 00340 00341 friStart_p->volID = a_volID; 00342 friStart_p->poolID = a_poolID; 00343 friStart_p->partID = a_partID; 00344 00345 friStart_p->startPos = hton(a_startPos); 00346 }

| void df_Packer::WriteRecFRIEnd | ( | const cmn_UUID_t & | a_volID, | |
| const cmn_UUID_t & | a_poolID, | |||
| const cmn_UUID_t & | a_partID, | |||
| UInt32_t | a_startPos, | |||
| UInt32_t | a_endPos, | |||
| UInt32_t | a_status, | |||
| UInt32_t | a_recNum, | |||
| UInt8_t * | a_friBuf, | |||
| UInt32_t | a_friBufSize | |||
| ) | [static] |
FRI End record is written with this function.
Definition at line 349 of file df_packer.cpp.
References dbg_DETAIL, df_ALIGN_m, df_RecFRIEnd_t::endPos, hton(), ie_DF_INV_BLK, ivd_Error, log_DBG_m, log_FUNC_m, df_RecFRIEnd_t::partID, df_RecFRIEnd_t::poolID, rec_FRIEnd_c, df_RecFRIEnd_t::startPos, df_RecFRIEnd_t::status, df_RecFRIEnd_t::volID, WriteRecCmnRaw(), and WriteRecFRIEnd().
00358 { 00359 00360 log_FUNC_m(WriteRecFRIEnd); 00361 00362 log_DBG_m(dbg_DETAIL, 00363 endl << 00364 "a_volID = " << a_volID << endl << 00365 "a_poolID = " << a_poolID << endl << 00366 "a_partID = " << a_partID << endl << 00367 "a_startPos = " << a_startPos << endl << 00368 "a_endPos = " << a_endPos << endl << 00369 "a_status = " << a_status); 00370 00371 UInt32_t recSize = df_ALIGN_m(sizeof(df_RecCmn_t) + 00372 sizeof(df_RecFRIEnd_t)); 00373 00374 if (recSize > a_friBufSize) { 00375 throw ivd_Error(ie_DF_INV_BLK, "Block not large enough for FRIEnd."); 00376 }; 00377 00378 df_RecCmn_t *recCmn_p = reinterpret_cast<df_RecCmn_t*>(a_friBuf); 00379 00380 WriteRecCmnRaw(rec_FRIEnd_c, recSize, 0, a_recNum, recCmn_p); 00381 00382 df_RecFRIEnd_t *friEnd_p = 00383 reinterpret_cast<df_RecFRIEnd_t*>(a_friBuf + sizeof(df_RecCmn_t)); 00384 00385 memset(friEnd_p, 0, sizeof(*friEnd_p)); 00386 00387 friEnd_p->volID = a_volID; 00388 friEnd_p->poolID = a_poolID; 00389 friEnd_p->partID = a_partID; 00390 00391 friEnd_p->startPos = hton(a_startPos); 00392 friEnd_p->endPos = hton(a_endPos); 00393 friEnd_p->status = hton(a_status); 00394 }

| void df_Packer::WriteRecFRISplitInfo | ( | UInt64_t | a_idFile, | |
| UInt64_t | a_allStreamOffset, | |||
| UInt64_t | a_allStreamSize, | |||
| UInt32_t | a_streamType, | |||
| UInt32_t | a_recNum, | |||
| UInt32_t | a_mediaBlockAddress, | |||
| UInt8_t * | a_friBuf, | |||
| UInt32_t | a_friBufSize | |||
| ) | [static] |
FRI Split Info record is written with this function.
Definition at line 397 of file df_packer.cpp.
References df_RecFRISpInfo_t::allStreamOffset, df_RecFRISpInfo_t::allStreamSize, cmn_Num2Str(), dbg_NORM, df_ALIGN_m, hton(), df_RecFRISpInfo_t::idFile, ie_DF_INV_BLK, ivd_Error, log_DBG_m, log_FUNC_m, df_RecFRISpInfo_t::mediaBlockAddr, rec_FRISpInfo_c, df_RecFRISpInfo_t::streamType, and WriteRecCmnRaw().
Referenced by df_FRI::FlushCurrentSplit(), and df_FRIDistiller::WriteSplitInfo().
00405 { 00406 00407 log_FUNC_m(WriteRecFRISplitInfo); 00408 00409 log_DBG_m(dbg_NORM, 00410 endl << 00411 "a_idFile = " << a_idFile << endl << 00412 "a_allStOff = " << a_allStreamOffset << endl << 00413 "a_allStSize = " << a_allStreamSize << endl << 00414 "a_stType = " << cmn_Num2Str(a_streamType, true) << endl << 00415 "a_medBlkAddr= " << a_mediaBlockAddress ); 00416 00417 UInt32_t recSize = df_ALIGN_m(sizeof(df_RecCmn_t) + 00418 sizeof(df_RecFRISpInfo_t)); 00419 00420 if (recSize > a_friBufSize) { 00421 throw ivd_Error(ie_DF_INV_BLK, "Block not large enough for FRISpInfo."); 00422 } 00423 00424 df_RecCmn_t *recCmn_p = reinterpret_cast<df_RecCmn_t*>(a_friBuf); 00425 00426 WriteRecCmnRaw(rec_FRISpInfo_c, recSize, 0, a_recNum, recCmn_p); 00427 00428 df_RecFRISpInfo_t *friSpInfo_p = 00429 reinterpret_cast<df_RecFRISpInfo_t*>(a_friBuf + sizeof(df_RecCmn_t)); 00430 00431 memset(friSpInfo_p, 0, sizeof(*friSpInfo_p)); 00432 00433 friSpInfo_p->idFile = hton(a_idFile); 00434 friSpInfo_p->allStreamOffset = hton(a_allStreamOffset); 00435 friSpInfo_p->allStreamSize = hton(a_allStreamSize); 00436 friSpInfo_p->streamType = hton(a_streamType); 00437 00438 // Data Format 01.01 change. 00439 friSpInfo_p->mediaBlockAddr = hton(a_mediaBlockAddress); 00440 }


| void df_Packer::WriteRecFile | ( | UInt64_t | a_idFile, | |
| UInt64_t | a_idMig, | |||
| UInt64_t | a_idParent, | |||
| UInt64_t | a_idParentOld, | |||
| const string & | a_name, | |||
| const string & | a_nameOld, | |||
| ivd_FileInfo_t & | a_info, | |||
| UInt32_t | a_changeFlags, | |||
| UInt32_t | a_flags = 0, |
|||
| UInt64_t | a_chunkSize = 0 | |||
| ) |
This implementation is used to prepare data to be written to media.
Definition at line 448 of file df_packer.cpp.
References cmn_BackSlashToSlash(), dbg_NORM, df_ALIGN_m, df_RF_WINDOWS, hton(), ie_INVALID_ARG, log_DBG_m, log_FUNC_m, m_allStreamSize, m_blockProxyWriter, m_chunkSize, m_fileName, m_idFile, m_idMig, m_numCopies, NULL, PATH_SEPARATOR, rec_FileHdr_c, and WriteRecCmn().
Referenced by fsc_nsElement::Pack(), i_HSM_i::PackFile(), PackFile(), and WriteRecFile().
00462 { 00463 00464 log_FUNC_m(WriteRecFile-full); 00465 00466 log_DBG_m(dbg_NORM, endl << 00467 "a_idFile: " << a_idFile << endl << 00468 "a_idParent: " << a_idParent << endl << 00469 "a_idParentOld: " << a_idParentOld << endl << 00470 "a_idMig: " << a_idMig << endl << 00471 "a_chunkSize: " << a_chunkSize); 00472 00473 if (a_idFile == 0) { 00474 throw ivd_InternalError(ie_INVALID_ARG, "idFile is zero"); 00475 } 00476 00477 if (a_idMig == 0) { 00478 throw ivd_InternalError(ie_INVALID_ARG, "idMig is zero"); 00479 } 00480 00481 // Save some file attributes for future reference 00482 m_idFile = a_idFile; 00483 m_idMig = a_idMig; 00484 m_fileName = a_name; 00485 m_chunkSize = a_chunkSize; 00486 00487 m_allStreamSize = 0; 00488 00489 string name(a_name), nameOld(a_nameOld); 00490 if (PATH_SEPARATOR == '\\') { // this OS use separator for DF 00491 cmn_BackSlashToSlash(name); 00492 cmn_BackSlashToSlash(nameOld); 00493 } 00494 00495 UInt32_t recSize = df_ALIGN_m(sizeof(df_RecCmn_t) + 00496 sizeof(df_RecFile_t) + 00497 name.length() + 1 + 00498 nameOld.length() + 1); 00499 00500 // Windows stores some fields in own format - flag record 00501 #if TGT_OS_windows 00502 UInt8_t *wp = WriteRecCmn(rec_FileHdr_c, recSize, df_RF_WINDOWS); 00503 #else 00504 UInt8_t *wp = WriteRecCmn(rec_FileHdr_c, recSize, 0); 00505 #endif 00506 00507 if (wp == NULL) { 00508 return; 00509 } 00510 00511 UInt8_t *recStart = wp - sizeof(df_RecCmn_t); 00512 00513 df_RecFile_t *file_p = reinterpret_cast<df_RecFile_t*>(wp); 00514 00515 file_p->idFile = hton(a_idFile); 00516 file_p->idMig = hton(a_idMig); 00517 file_p->idParent = hton(a_idParent); 00518 file_p->idParentOld = hton(a_idParentOld); 00519 00520 file_p->chunkSize = hton(a_chunkSize); 00521 file_p->reserved1 = 0; 00522 00523 file_p->numCopies = hton(m_numCopies); 00524 00525 file_p->stdAttr.numLinks = hton(a_info.numLinks); 00526 file_p->stdAttr.idOnFS = hton(a_info.idOnFS); 00527 file_p->stdAttr.type = hton(static_cast<UInt64_t>(a_info.type)); 00528 file_p->stdAttr.size = hton(static_cast<UInt64_t>(a_info.size)); 00529 file_p->stdAttr.attr = hton(a_info.attr); 00530 00531 file_p->stdAttr.owner = hton(a_info.owner); 00532 file_p->stdAttr.group = hton(a_info.group); 00533 00534 file_p->stdAttr.changeFlags = hton(a_changeFlags); 00535 file_p->stdAttr.flags = hton(a_flags); 00536 00537 file_p->stdAttr.timeCreate = hton(a_info.timeCreate); 00538 file_p->stdAttr.timeAccess = hton(a_info.timeAccess); 00539 file_p->stdAttr.timeModify = hton(a_info.timeModify); 00540 file_p->stdAttr.timeChange = hton(a_info.timeChange); 00541 00542 file_p->reserved2[0] = 0, 00543 file_p->reserved2[1] = 0, 00544 file_p->reserved2[2] = 0, 00545 file_p->reserved2[3] = 0; 00546 00547 // Write fixed size record 00548 wp = m_blockProxyWriter->Move(sizeof(*file_p)); 00549 00550 // Append variable length fields(s). 00551 00552 // Offset from the beginning of record (including common part). 00553 file_p->name.offset = hton(UInt32_t(wp - recStart)); 00554 file_p->name.size = hton(UInt32_t(name.length() + 1)); 00555 memcpy( 00556 wp, 00557 name.c_str(), 00558 name.length()+1); 00559 00560 wp = m_blockProxyWriter->Move(name.length()+1); 00561 00562 file_p->nameOld.offset = hton(UInt32_t(wp - recStart)); 00563 file_p->nameOld.size = hton(UInt32_t(nameOld.length() + 1)); 00564 00565 memcpy( 00566 wp, 00567 nameOld.c_str(), 00568 nameOld.length() + 1); 00569 00570 wp = m_blockProxyWriter->Move(nameOld.length() + 1); 00571 00572 m_blockProxyWriter->Move(); // use remaing space up to allocated size 00573 }


| void df_Packer::WriteRecFile | ( | UInt64_t | a_idFile, | |
| UInt64_t | a_idParent, | |||
| const string & | a_name, | |||
| df_StandardAttr_t & | standAttr | |||
| ) |
used by NSC to fill data need for recovery NOTE standard attributes in NSC are already in network format, so don't convert them.
This implementation is used to prepare data for file system recovery.
Definition at line 581 of file df_packer.cpp.
References dbg_NORM, df_ALIGN_m, hton(), ie_INVALID_ARG, log_DBG_m, log_FUNC_m, m_blockProxyWriter, m_chunkSize, m_fileName, m_idFile, m_idMig, m_numCopies, NULL, rec_FileHdr_c, WriteRecCmn(), and WriteRecFile().
00585 { 00586 00587 log_FUNC_m(WriteRecFile-light); 00588 00589 log_DBG_m(dbg_NORM, endl << 00590 "a_idFile: " << a_idFile << endl << 00591 "a_idParent: " << a_idParent << endl); 00592 00593 if (a_idFile == 0) { 00594 throw ivd_InternalError(ie_INVALID_ARG, "idFile is zero"); 00595 } 00596 00597 // Save some file attributes for future reference 00598 m_idFile = a_idFile; 00599 m_idMig = 0; 00600 m_fileName = a_name; 00601 m_chunkSize = 0; 00602 00603 string nameOld; // just empty string 00604 00605 UInt32_t recSize = df_ALIGN_m(sizeof(df_RecCmn_t) + 00606 sizeof(df_RecFile_t) + 00607 a_name.length() + 1 + 00608 nameOld.length() + 1); 00609 00610 UInt8_t *wp = WriteRecCmn(rec_FileHdr_c, recSize); 00611 if (wp == NULL) { 00612 return; 00613 } 00614 00615 UInt8_t *recStart = wp - sizeof(df_RecCmn_t); 00616 00617 df_RecFile_t *file_p = reinterpret_cast<df_RecFile_t*>(wp); 00618 00619 file_p->idFile = hton(a_idFile); 00620 file_p->idMig = 0; 00621 file_p->idParent = hton(a_idParent); 00622 file_p->idParentOld = 0; 00623 00624 file_p->chunkSize = 0; 00625 file_p->reserved1 = 0; 00626 00627 file_p->numCopies = hton(m_numCopies); 00628 00629 file_p->stdAttr = standAttr; 00630 00631 file_p->reserved2[0] = 0, 00632 file_p->reserved2[1] = 0, 00633 file_p->reserved2[2] = 0, 00634 file_p->reserved2[3] = 0; 00635 00636 // Write fixed size record 00637 wp = m_blockProxyWriter->Move(sizeof(*file_p)); 00638 00639 // Append variable length fields(s). 00640 00641 // Offset from the beginning of record (including common part). 00642 file_p->name.offset = hton(UInt32_t(wp - recStart)); 00643 file_p->name.size = hton(UInt32_t(a_name.length() + 1)); 00644 memcpy( 00645 wp, 00646 a_name.c_str(), 00647 a_name.length() + 1); 00648 00649 wp = m_blockProxyWriter->Move(a_name.length() + 1); 00650 00651 file_p->nameOld.offset = hton(UInt32_t(wp - recStart)); 00652 file_p->nameOld.size = hton(UInt32_t(nameOld.length() + 1)); 00653 00654 memcpy( 00655 wp, 00656 nameOld.c_str(), 00657 nameOld.length() + 1); 00658 00659 wp = m_blockProxyWriter->Move(nameOld.length() + 1); 00660 00661 m_blockProxyWriter->Move(); // use remaing space up to allocated size 00662 }

| void df_Packer::WriteRecFileEndRaw | ( | UInt64_t | a_idFile, | |
| UInt64_t | a_idMig, | |||
| UInt32_t | a_status, | |||
| UInt32_t | a_recNum, | |||
| UInt8_t * | a_buffer, | |||
| UInt32_t | a_flags = 0 | |||
| ) | [static] |
Definition at line 665 of file df_packer.cpp.
References df_ALIGN_m, hton(), df_RecFileEnd_t::idFile, df_RecFileEnd_t::idMig, log_FUNC_m, rec_FileEnd_c, df_RecFileEnd_t::status, and WriteRecCmnRaw().
Referenced by df_Filter::CloseCopiedSplit(), df_FRIDistiller::CompleteStream(), and df_FRI::MediumVolumeEnd().
00671 { 00672 00673 log_FUNC_m(WriteRecFileEndRaw); 00674 00675 UInt32_t recSize = 00676 df_ALIGN_m(sizeof(df_RecCmn_t) + sizeof(df_RecFileEnd_t)); 00677 00678 df_RecCmn_t *recCmn_p = reinterpret_cast<df_RecCmn_t*>(a_buffer); 00679 WriteRecCmnRaw(rec_FileEnd_c, recSize, a_flags, a_recNum, recCmn_p); 00680 00681 df_RecFileEnd_t *fe_p = 00682 reinterpret_cast<df_RecFileEnd_t*>(a_buffer + sizeof(df_RecCmn_t)); 00683 00684 memset(fe_p, 0, sizeof(*fe_p)); 00685 00686 fe_p->idFile = hton(a_idFile); 00687 fe_p->idMig = hton(a_idMig); 00688 fe_p->status = hton(a_status); 00689 }


| void df_Packer::WriteRecFileEnd | ( | UInt32_t | a_status | ) |
Definition at line 693 of file df_packer.cpp.
References dbg_NORM, df_ALIGN_m, hton(), df_RecFileEnd_t::idFile, df_RecFileEnd_t::idMig, log_DBG_m, log_FUNC_m, m_blockProxyWriter, m_idFile, m_idMig, NULL, rec_FileEnd_c, df_RecFileEnd_t::status, and WriteRecCmn().
Referenced by fsc_nsElement::Pack(), i_HSM_i::PackFile(), PackFile(), and ~df_Packer().
00694 { 00695 00696 log_FUNC_m(WriteRecFileEnd); 00697 00698 log_DBG_m(dbg_NORM, endl << "a_status: " << a_status); 00699 00700 UInt32_t recSize = df_ALIGN_m(sizeof(df_RecCmn_t) + 00701 sizeof(df_RecFileEnd_t)); 00702 00703 UInt8_t *wp = WriteRecCmn(rec_FileEnd_c, recSize); 00704 if (wp == NULL) { 00705 return; 00706 } 00707 00708 df_RecFileEnd_t *fEnd_p = reinterpret_cast<df_RecFileEnd_t*>(wp); 00709 memset(fEnd_p, 0, sizeof(*fEnd_p)); 00710 00711 fEnd_p->idFile = hton(m_idFile); 00712 fEnd_p->idMig = hton(m_idMig); 00713 00714 fEnd_p->status = hton(a_status); 00715 00716 wp = m_blockProxyWriter->Move(sizeof(*fEnd_p)); 00717 00718 m_blockProxyWriter->Move(); // use remaing space up to allocated size 00719 }


| void df_Packer::WriteRecBSStart | ( | UInt32_t | a_type, | |
| const string & | a_name, | |||
| UInt64_t | a_streamSize, | |||
| UInt64_t | a_fileOffset = 0 | |||
| ) |
Definition at line 884 of file df_packer.cpp.
References dbg_DETAIL, df_ALIGN_m, hton(), log_DBG_m, log_FUNC_m, m_allStreamSize, m_blockProxyWriter, m_fileOffset, m_idFile, m_streamAlloc, m_streamName, m_streamOffset, m_streamSize, m_streamType, NULL, rec_BSStart_c, and WriteRecCmn().
Referenced by fsc_SplitStream_t::Pack(), i_HSM_i::PackFile(), and PackFile().
00888 { 00889 00890 log_FUNC_m(WriteRecBSStart); 00891 00892 log_DBG_m(dbg_DETAIL, 00893 "Stream: \'" << a_name << 00894 "\' size/offset: " << a_streamSize << "/" << a_fileOffset); 00895 00896 // Save current stream's parameters 00897 m_streamType = a_type; 00898 m_streamName = a_name; 00899 m_streamOffset = 0; 00900 m_streamSize = a_streamSize; 00901 m_fileOffset = a_fileOffset; 00902 00903 m_streamAlloc = 0; 00904 00905 UInt32_t recSize = df_ALIGN_m(sizeof(df_RecCmn_t) + 00906 sizeof(df_RecByteStreamStart_t) + 00907 a_name.length() + 1); 00908 00909 UInt8_t *wp = WriteRecCmn(rec_BSStart_c, recSize); 00910 if (wp == NULL) { 00911 return; 00912 } 00913 00914 UInt8_t *recStart = wp - sizeof(df_RecCmn_t); 00915 00916 df_RecByteStreamStart_t *bss_p = 00917 reinterpret_cast<df_RecByteStreamStart_t*>(wp); 00918 memset(bss_p, 0, sizeof(*bss_p)); 00919 00920 bss_p->idFile = hton(m_idFile); 00921 bss_p->chunkOffset = hton(a_fileOffset); 00922 bss_p->streamType = hton(a_type); 00923 bss_p->streamOffset = hton(m_streamOffset); 00924 bss_p->streamSize = hton(a_streamSize); 00925 00926 bss_p->allStreamSize= hton(m_allStreamSize); 00927 00928 wp = m_blockProxyWriter->Move(sizeof(*bss_p)); 00929 00930 bss_p->streamName.offset = hton(UInt32_t(wp - recStart)); 00931 bss_p->streamName.size = hton(UInt32_t(a_name.length() + 1)); 00932 00933 memcpy( 00934 wp, 00935 a_name.c_str(), 00936 a_name.length() + 1); 00937 00938 wp = m_blockProxyWriter->Move(a_name.length()); 00939 00940 m_blockProxyWriter->Move(); // use remaing space up to allocated size 00941 }


Request pointer to area, where raw data can be written.
Disallows other requests until WriteBSData() is used.
BS .. byte stream
Definition at line 832 of file df_packer.cpp.
References cmn_Num2Str(), dbg_DETAIL, ie_DF_INVSTATE, ie_DF_SSIZE, ivd_Error, log_DBG_INT_m, log_FUNC_INT_m, log_FUNC_m, m_prevRec, m_streamAlloc, m_streamOffset, m_streamSize, MakeSpaceForData(), and rec_Data_c.
Referenced by fsc_SplitStream_t::Pack(), i_HSM_i::PackFile(), PackFile(), and WriteRecBSEnd().
00832 { 00833 log_FUNC_INT_m(GetBSData); 00834 00835 if (m_streamOffset >= m_streamSize) { 00836 // This exception can be used by the user of df_Packer to 00837 // detect that more data than declared is attempted to be written. 00838 // Stream can be closed then. 00839 log_FUNC_m(GetBSData); 00840 throw ivd_Error( 00841 ie_DF_SSIZE, 00842 "Byte stream already filled up to the declared size.", 00843 "End of stream reached! s=" + 00844 cmn_Num2Str(m_streamSize) + string(" o=") + 00845 cmn_Num2Str(m_streamOffset)); 00846 } 00847 00848 if (m_streamAlloc != m_streamOffset) { 00849 log_FUNC_m(GetBSData); 00850 throw ivd_InternalError( 00851 ie_DF_INVSTATE, 00852 "BUG: Data was allocated for file stream by GetBSData, " 00853 "but not flushed by WriteBSData. FIX IT!"); 00854 } 00855 00856 UInt64_t streamLeft = m_streamSize - m_streamOffset; 00857 00858 MakeSpaceForData(streamLeft, a_block, a_size); 00859 00860 // Store the amount of allocated data to this point. 00861 m_streamAlloc += a_size; 00862 00863 log_DBG_INT_m(dbg_DETAIL, "Stream buffer size: " << a_size); 00864 00865 m_prevRec = rec_Data_c; 00866 }


| void df_Packer::WriteBSData | ( | bool | a_flushEmpty = false |
) |
Write previously allocated space using GetBSData();.
Updates the amount of data actually written.
Definition at line 869 of file df_packer.cpp.
References log_FUNC_INT_m, m_blockProxyWriter, m_streamAlloc, and m_streamOffset.
Referenced by fsc_SplitStream_t::Pack(), i_HSM_i::PackFile(), PackFile(), and WriteRecBSEnd().
00869 { 00870 log_FUNC_INT_m(WriteBSData); 00871 00872 // Mark the data that was requested by the previous 00873 // GetBSData() as used. 00874 00875 UInt32_t reserved = static_cast<UInt32_t>(m_streamAlloc-m_streamOffset); 00876 00877 m_blockProxyWriter->Move(reserved, a_flushEmpty); 00878 // use remaing space up to allocated size 00879 m_blockProxyWriter->Move(0, a_flushEmpty); 00880 00881 m_streamOffset = m_streamAlloc; 00882 }

| void df_Packer::WriteRecBSEnd | ( | UInt32_t | a_status | ) |
Definition at line 944 of file df_packer.cpp.
References cmn_Num2Str(), dbg_LOW, df_ALIGN_m, df_SS_COMPLETE, GetBSData(), ie_DATA_CORRUPTION, ie_DF_SSIZE, ivd_Error, log_DBG_m, log_FUNC_A_m, log_MARKLINE_m, log_WRN_m, m_allStreamSize, m_blockProxyWriter, m_idFile, m_prevRec, m_recNum, m_streamAlloc, m_streamName, m_streamOffset, m_streamSize, m_streamType, NULL, rec_BSEnd_c, size, WriteBSData(), and WriteRecBSEndRaw().
Referenced by fsc_SplitStream_t::Pack(), i_HSM_i::PackFile(), PackFile(), and ~df_Packer().
00944 { 00945 00946 log_FUNC_A_m(WriteRecBSEnd, "a_status: " << a_status); 00947 00948 if (m_streamOffset != m_streamSize) { 00949 if (a_status != df_SS_COMPLETE) { 00950 00951 log_DBG_m(dbg_LOW, 00952 "file status != df_SS_COMPLETE " << 00953 "==> fill up to the size of the stream (remaining: " << 00954 (m_streamSize - m_streamOffset) << ")"); 00955 00956 if (m_streamAlloc > m_streamOffset) { 00957 WriteBSData(true); 00958 }; 00959 00960 while (m_streamOffset < m_streamSize) { 00961 // Write empty blocks until the end of file. 00962 UInt8_t *data; 00963 UInt32_t size; 00964 GetBSData(data, size); 00965 memset(data, 0, size); 00966 WriteBSData(true); 00967 } 00968 } 00969 else { 00970 // This exception can be used by the user of df_Packer to 00971 // detect that less data than declared is attempted to be written, and the 00972 // status is marked as COMPLETE. 00973 log_MARKLINE_m; 00974 throw ivd_Error( 00975 ie_DF_SSIZE, 00976 "Byte stream not filled up to the declared size.", 00977 "size: " + 00978 cmn_Num2Str(m_streamSize) + string(", filled:") + 00979 cmn_Num2Str(m_streamOffset) ); 00980 } 00981 } 00982 else { 00983 if (m_streamAlloc > m_streamOffset) { 00984 log_MARKLINE_m; 00985 throw ivd_InternalError( 00986 ie_DATA_CORRUPTION, 00987 "m_streamOffset == m_streamSize and m_reservedData != 0."); 00988 } 00989 }; 00990 00991 m_allStreamSize += m_streamSize; 00992 UInt32_t recSize = df_ALIGN_m(sizeof(df_RecCmn_t) + 00993 sizeof(df_RecByteStreamEnd_t) + 00994 m_streamName.length() + 1); 00995 00996 UInt8_t *wp = m_blockProxyWriter->Allocate(recSize); 00997 if (wp == NULL) { 00998 log_WRN_m("NULL block pointer from Allocate(). No reader available."); 00999 return; 01000 } 01001 WriteRecBSEndRaw( 01002 m_idFile, 01003 a_status, m_streamType, m_streamSize, m_allStreamSize, m_streamName, 01004 ++m_recNum, wp); 01005 01006 m_prevRec = rec_BSEnd_c; 01007 01008 m_blockProxyWriter->Move(); 01009 }


| void df_Packer::WriteRecBSEndRaw | ( | UInt64_t | a_idFile, | |
| UInt32_t | a_status, | |||
| UInt32_t | a_streamType, | |||
| UInt64_t | a_streamSize, | |||
| UInt64_t | a_allStreamSize, | |||
| const string & | a_name, | |||
| UInt32_t | a_recNum, | |||
| UInt8_t * | a_buffer | |||
| ) | [static] |
Definition at line 1011 of file df_packer.cpp.
References df_RecByteStreamEnd_t::allStreamSize, df_ALIGN_m, hton(), df_RecByteStreamEnd_t::idFile, ivd_VarData_t::offset, rec_BSEnd_c, ivd_VarData_t::size, df_RecByteStreamEnd_t::status, df_RecByteStreamEnd_t::streamName, df_RecByteStreamEnd_t::streamSize, df_RecByteStreamEnd_t::streamType, and WriteRecCmnRaw().
Referenced by df_Filter::CloseCopiedSplit(), df_FRIDistiller::CompleteStream(), df_FRI::MediumVolumeEnd(), and WriteRecBSEnd().
01019 { 01020 01021 UInt32_t recSize = df_ALIGN_m(sizeof(df_RecCmn_t) + 01022 sizeof(df_RecByteStreamEnd_t) + 01023 a_name.length() + 1); 01024 01025 df_RecCmn_t* recCmn_p = reinterpret_cast<df_RecCmn_t*>(a_buffer); 01026 WriteRecCmnRaw(rec_BSEnd_c, recSize, 0, a_recNum, recCmn_p); 01027 01028 UInt8_t *wp = a_buffer + sizeof(df_RecCmn_t); 01029 UInt8_t *recStart = a_buffer; 01030 01031 df_RecByteStreamEnd_t *bse_p = reinterpret_cast<df_RecByteStreamEnd_t*>(wp); 01032 memset(bse_p, 0, sizeof(*bse_p)); 01033 01034 bse_p->idFile = hton(a_idFile); 01035 bse_p->streamType = hton(a_streamType); 01036 bse_p->streamSize = hton(a_streamSize); 01037 bse_p->status = hton(a_status); 01038 bse_p->allStreamSize= hton(a_allStreamSize); 01039 01040 wp += sizeof(*bse_p); 01041 bse_p->streamName.offset = hton(UInt32_t(wp - recStart)); 01042 bse_p->streamName.size = hton(UInt32_t(a_name.length() + 1)); 01043 01044 memcpy( 01045 wp, 01046 a_name.c_str(), 01047 a_name.length() + 1); 01048 }


| void df_Packer::WriteRecFRIStart | ( | ) |
Referenced by df_FRI::MediumVolumeStart(), df_FRIDistiller::WriteFRIStart(), and WriteRecFRIStart().

| void df_Packer::WriteRecFRIEnd | ( | ) |
Referenced by df_FRI::MediumVolumeEnd(), df_FRIDistiller::WriteFRIEnd(), and WriteRecFRIEnd().

| void df_Packer::EndOfData | ( | ) | [inline] |
Definition at line 1128 of file df.h.
Referenced by Backup(), and i_HSM_i::DoMigrationJob().
01128 { 01129 m_blockProxyWriter->EndOfData(); 01130 };

| void df_Packer::NewDiskBuffer | ( | const string & | a_id, | |
| string & | a_diskBufferFS, | |||
| bool | a_append = false | |||
| ) | [inline] |
Definition at line 1132 of file df.h.
Referenced by i_HSM_i::DoMigrationJob().
01134 { 01135 m_blockProxyWriter->NewDiskBuffer(a_id, a_diskBufferFS, a_append); 01136 };

| void df_Packer::NewNetBuffer | ( | i_UploadAgent_ptr | a_uploadAgt | ) | [inline] |
Definition at line 1138 of file df.h.
Referenced by i_HSM_i::DoMigrationJob().
01138 { 01139 m_blockProxyWriter->NewNetBuffer(a_uploadAgt); 01140 };

| void df_Packer::NewStdIOBuffer | ( | const string & | a_fName | ) | [inline] |
Definition at line 1142 of file df.h.
Referenced by Backup().
01142 { 01143 m_blockProxyWriter->NewStdIOBuffer(a_fName); 01144 };

| void df_Packer::Go | ( | ) | [inline] |
Definition at line 1146 of file df.h.
Referenced by Backup(), and i_HSM_i::DoMigrationJob().
01146 { 01147 m_blockProxyWriter->Go(); 01148 };

| UInt32_t df_Packer::GetBlkNum | ( | ) | [inline] |
Definition at line 1150 of file df.h.
01150 { 01151 return m_blockProxyWriter->GetBlkNum(); 01152 };
df_Packer::log_CLASSID_m [private] |
auto_ptr<df_BlockProxyWriter> df_Packer::m_blockProxyWriter [protected] |
Definition at line 922 of file df.h.
Referenced by df_Packer(), MakeSpaceForData(), WriteBSData(), WriteRecBSEnd(), WriteRecBSStart(), WriteRecCmn(), WriteRecFile(), and WriteRecFileEnd().
UInt32_t df_Packer::m_prevRec [protected] |
Which was the previous record type?
Definition at line 927 of file df.h.
Referenced by GetBSData(), WriteRecBSEnd(), WriteRecCmn(), and ~df_Packer().
UInt32_t df_Packer::m_recNum [protected] |
Current record number.
Definition at line 929 of file df.h.
Referenced by WriteRecBSEnd(), and WriteRecCmn().
UInt64_t df_Packer::m_idFile [protected] |
Definition at line 931 of file df.h.
Referenced by MakeSpaceForData(), WriteRecBSEnd(), WriteRecBSStart(), WriteRecFile(), and WriteRecFileEnd().
UInt64_t df_Packer::m_idMig [protected] |
string df_Packer::m_fileName [protected] |
UInt64_t df_Packer::m_chunkSize [protected] |
UInt64_t df_Packer::m_fileOffset [protected] |
UInt32_t df_Packer::m_streamType [protected] |
Definition at line 937 of file df.h.
Referenced by MakeSpaceForData(), WriteRecBSEnd(), and WriteRecBSStart().
string df_Packer::m_streamName [protected] |
Definition at line 938 of file df.h.
Referenced by MakeSpaceForData(), WriteRecBSEnd(), and WriteRecBSStart().
UInt64_t df_Packer::m_streamOffset [protected] |
Reset to 0 at the beginning of each stream.
Increased at each data write and used when writing subsequent embedded data records.
Definition at line 944 of file df.h.
Referenced by GetBSData(), MakeSpaceForData(), WriteBSData(), WriteRecBSEnd(), and WriteRecBSStart().
UInt64_t df_Packer::m_streamSize [protected] |
Definition at line 945 of file df.h.
Referenced by GetBSData(), WriteRecBSEnd(), and WriteRecBSStart().
UInt64_t df_Packer::m_allStreamSize [protected] |
Size of all stream records of a file up to current position.
Definition at line 950 of file df.h.
Referenced by WriteRecBSEnd(), WriteRecBSStart(), and WriteRecFile().
UInt64_t df_Packer::m_streamAlloc [protected] |
Helper to detect if a stream is filled properly.
Definition at line 953 of file df.h.
Referenced by GetBSData(), WriteBSData(), WriteRecBSEnd(), and WriteRecBSStart().
UInt16_t df_Packer::m_numCopies [protected] |
1.5.6