Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Attributes

df_Packer Class Reference
[IVD Data format.]

#include <df.h>

List of all members.

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_tWriteRecCmn (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_BlockProxyWriterm_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.

Detailed Description

Definition at line 919 of file df.h.


Constructor & Destructor Documentation

df_Packer::df_Packer ( UInt32_t  a_blkType,
bbt_BufType_t  a_bufType,
UInt32_t  a_blkSize,
UInt16_t  a_numCopies 
)

Definition at line 47 of file df_packer.cpp.

References log_FUNC_A_m.

    : m_blockProxyWriter(new df_Writer(a_blkType, a_bufType, a_blkSize)),
      m_prevRec(rec_NoRec_c),
      m_recNum(0),
      m_streamAlloc(0),
      m_numCopies(a_numCopies) {

    log_FUNC_A_m(df_Packer, "copies: " << a_numCopies);
}

df_Packer::df_Packer ( df_BlockProxyWriter a_blockProxyWriter_p  ) 

Definition at line 61 of file df_packer.cpp.

References log_FUNC_A_m, and m_blockProxyWriter.

    : m_blockProxyWriter(a_blockProxyWriter_p),
      m_prevRec(rec_NoRec_c),
      m_recNum(0),
      m_streamAlloc(0),
      m_numCopies(1) {

    log_FUNC_A_m(df_Packer, " Custom writer. block size "
                         << m_blockProxyWriter->GetRawBlockSize());
    // writer needs to be init before use
    // in non custom writer then user has to call Go()
    m_blockProxyWriter->Go();
}

df_Packer::~df_Packer (  )  [virtual]

Definition at line 75 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().

                      {
    log_FUNC_m(~df_Packer);

    try {

        if (uncaught_exception()) {
            log_DBG_m(dbg_LOW,
                "DTOR called because of an exception.");
        }

        if (!df_IsValidTerminator(m_prevRec)) {
            log_DBG_m(dbg_LOW,
                "Data stream not properly terminated. Terminating now.");

            // Teminate the output stream auto-magically

            if (m_prevRec == rec_FileHdr_c) {
                WriteRecFileEnd(df_FS_ABORTED);
            }
            else if (   m_prevRec == rec_BSStart_c
                     || m_prevRec == rec_EmbData_c
                     || m_prevRec == rec_Data_c) {
                WriteRecBSEnd(df_SS_ABORTED);
                WriteRecFileEnd(df_FS_ABORTED);
            }
            else if (m_prevRec == rec_NoRec_c) {
                // TODO: Anything?
            }
        }
    }
    catch (ivd_Exception &ie) {
        log_DBG_m(dbg_LOW,
            "Ignoring exception in DTOR." << endl <<
            "Error: " << ie);
    }
}

Here is the call graph for this function:


Member Function Documentation

void df_Packer::EndOfData (  )  [inline]

Definition at line 1142 of file df.h.

Referenced by Backup(), and i_HSM_i::DoMigrationJob().

                     {
        m_blockProxyWriter->EndOfData();
    };

Here is the caller graph for this function:

UInt32_t df_Packer::GetBlkNum (  )  [inline]

Definition at line 1164 of file df.h.

                         {
        return m_blockProxyWriter->GetBlkNum();
    };

void df_Packer::GetBSData ( UInt8_t *&  a_block,
UInt32_t a_size 
)

Request pointer to area, where raw data can be written.

Disallows other requests until WriteBSData() is used.

BS .. byte stream

Definition at line 846 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().

                                                             {
    log_FUNC_INT_m(GetBSData);

    if (m_streamOffset >= m_streamSize) {
        // This exception can be used by the user of df_Packer to
        // detect that more data than declared is attempted to be written.
        // Stream can be closed then.
        log_FUNC_m(GetBSData);
        throw ivd_Error(
            ie_DF_SSIZE,
            "Byte stream already filled up to the declared size.",
            "End of stream reached! s=" +
            cmn_Num2Str(m_streamSize) + string(" o=") +
            cmn_Num2Str(m_streamOffset));
    }

    if (m_streamAlloc != m_streamOffset) {
        log_FUNC_m(GetBSData);
        throw ivd_InternalError(
            ie_DF_INVSTATE,
            "BUG: Data was allocated for file stream by GetBSData, "
            "but not flushed by WriteBSData. FIX IT!");
    }

    UInt64_t streamLeft =  m_streamSize - m_streamOffset;

    MakeSpaceForData(streamLeft, a_block, a_size);

    // Store the amount of allocated data to this point.
    m_streamAlloc += a_size;

    log_DBG_INT_m(dbg_DETAIL, "Stream buffer size: " << a_size);

    m_prevRec = rec_Data_c;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void df_Packer::Go (  )  [inline]

Definition at line 1160 of file df.h.

Referenced by Backup(), and i_HSM_i::DoMigrationJob().

              {
        m_blockProxyWriter->Go();
    };

Here is the caller graph for this function:

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 736 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().

                                                                      {
    log_FUNC_INT_m(MakeSpaceForData);

    // We have the following options:
    //
    // 1. Space left in current block -> try to embed in record
    // 2. No space left -> we can use raw
        // 2.a ...but only if we can fill the whole block...
        // 2.b ...otherwise we need to embed in record

    UInt32_t freeSize   = m_blockProxyWriter->GetFreeSize();
    UInt32_t rawBlkSize = m_blockProxyWriter->GetRawBlockSize();

    // Embed if:
    // * space left in current -> try to use it or
    // * less left than RAW block size
    //
    if (freeSize > 0 || a_streamLeft < rawBlkSize) {

        log_DBG_INT_m(dbg_NORM,
                "Embed, freeSize: " << freeSize <<
                ", a_streamLeft: " << a_streamLeft);

        // we will try to embed

        UInt32_t recSize = sizeof(df_RecCmn_t) +
                           sizeof(df_RecEmbeddedData_t) +
                           m_streamName.length() + 1;

        UInt32_t embSize = 0;
        UInt32_t embOffset = recSize;   // TODO: add special alignment

        if (freeSize >= (recSize + a_streamLeft)
            || freeSize >= (recSize + df_MIN_EMBEDDED_SIZE)) {

            embSize = freeSize - embOffset;
            if (embSize > a_streamLeft)
                embSize = static_cast<UInt32_t>(a_streamLeft);
        }
        else if (a_streamLeft < rawBlkSize) {
            // will have to allocate new embedded record new block
            embSize = rawBlkSize - m_blockProxyWriter->GetBlockHeaderSize() - embOffset;
            if (embSize > a_streamLeft)
                embSize = static_cast<UInt32_t>(a_streamLeft);
        }

        // Embed data into a block (embSize == 0) --> use new raw block
        if (embSize > 0) {
            UInt8_t *wp = WriteRecCmn(rec_EmbData_c,
                                      df_ALIGN_m(embOffset + embSize));
            if (wp == NULL) {
                a_block = NULL, a_size = 0;
                return;
            }

            UInt8_t *recStart = wp - sizeof(df_RecCmn_t);

            df_RecEmbeddedData_t *eData_p =
                reinterpret_cast<df_RecEmbeddedData_t*>(wp);
            memset(eData_p, 0, sizeof(*eData_p));

            eData_p->idFile         = hton(m_idFile);
            eData_p->streamType     = hton(m_streamType);
            eData_p->streamOffset   = hton(m_streamOffset);
            eData_p->chunkOffset    = hton(m_fileOffset);

            eData_p->data.offset    = hton(embOffset);
            eData_p->data.size      = hton(embSize);

            wp = m_blockProxyWriter->Move(sizeof(*eData_p));

            eData_p->streamName.offset = hton(UInt32_t(wp - recStart));
            eData_p->streamName.size   = hton(UInt32_t(m_streamName.length() + 1));

            memcpy(
                wp,
                m_streamName.c_str(),
                m_streamName.length() + 1);

            wp = m_blockProxyWriter->Move(m_streamName.length() + 1);

            // skip pad for data alignment (if any)
            if (embOffset - recSize > 0) {
                wp = m_blockProxyWriter->Move(embOffset - recSize);
            }

            a_block = wp;
            a_size  = embSize;

            log_DBG_INT_m(dbg_DETAIL, "EmbData size: " << embSize <<
                                  " EmbData offset: " << embOffset);
            return;
        }
        // cannot use free space and more than RAW block size
    }

    a_block = m_blockProxyWriter->AllocateRawBlock();

    if (a_block == NULL) {
        log_FUNC_m(MakeSpaceForData);
        log_WRN_m("NULL block pointer from AllocateRawBlock(). No reader available.");
        a_block = NULL, a_size = 0;
        return;
    }

    a_size  = rawBlkSize;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void df_Packer::NewDiskBuffer ( const string &  a_id,
string &  a_diskBufferFS,
bool  a_append = false 
) [inline]

Definition at line 1146 of file df.h.

Referenced by i_HSM_i::DoMigrationJob().

                                               {
        m_blockProxyWriter->NewDiskBuffer(a_id, a_diskBufferFS, a_append);
    };

Here is the caller graph for this function:

void df_Packer::NewNetBuffer ( i_UploadAgent_ptr  a_uploadAgt  )  [inline]

Definition at line 1152 of file df.h.

Referenced by i_HSM_i::DoMigrationJob().

                                                    {
        m_blockProxyWriter->NewNetBuffer(a_uploadAgt);
    };

Here is the caller graph for this function:

void df_Packer::NewStdIOBuffer ( const string &  a_fName  )  [inline]

Definition at line 1156 of file df.h.

Referenced by Backup().

                                               {
        m_blockProxyWriter->NewStdIOBuffer(a_fName);
    };

Here is the caller graph for this function:

void df_Packer::WriteBSData ( bool  a_flushEmpty = false  ) 

Write previously allocated space using GetBSData();.

Updates the amount of data actually written.

Definition at line 883 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().

                                             {
    log_FUNC_INT_m(WriteBSData);

    // Mark the data that was requested by the previous
    // GetBSData() as used.

    UInt32_t reserved = static_cast<UInt32_t>(m_streamAlloc-m_streamOffset);

    m_blockProxyWriter->Move(reserved, a_flushEmpty);
    // use remaing space up to allocated size
    m_blockProxyWriter->Move(0, a_flushEmpty);

    m_streamOffset = m_streamAlloc;
}

Here is the caller graph for this function:

void df_Packer::WriteECMAVolHeader ( UInt32_t  a_partNumber,
UInt8_t a_volHdr 
) [static, protected]

Write ECMA compliant volume ID.

Definition at line 113 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, and df_ECMALblHdr_t::number.

Referenced by WriteRecMedVolHdr().

                           {

    log_FUNC_m(WriteECMAVolHeader);

    df_ECMAVolumeLabel_t *ecmaLabel_p =
        reinterpret_cast<df_ECMAVolumeLabel_t*>(a_volHdr);

    memset(ecmaLabel_p, ' ', sizeof(*ecmaLabel_p));

    memcpy(
        &(ecmaLabel_p->ecmaHdr.lblID),
        ecma_VolID_c,
        sizeof(ecmaLabel_p->ecmaHdr.lblID));

    ecmaLabel_p->ecmaHdr.number = static_cast<UInt8_t>(a_partNumber);

    if (a_partNumber == 1) {

        //ecmaLabel_p->first.volID = SHORT IVD MED ID ??
        //ecmaLabel_p->first.volAccess = // Filled with SPACE (No restrictions)
        //ecmaLabel_p->first.res1 = // Filled with SPACEs

        if (ecma_ImplID_c.length() > sizeof(ecmaLabel_p->first.implID)) {
            log_MARKLINE_m;
            throw ivd_InternalError(
                ie_INVALID_ARG,
                "Length of ecma_ImplID_c > 13 :" +
                cmn_Num2Str(ecma_ImplID_c.length()) );
        }
        memcpy(
            ecmaLabel_p->first.implID,
            ecma_ImplID_c.c_str(),
            ecma_ImplID_c.length());

        //ecmaLabel_p->first.ownerID = // Filled with SPACEs
        //ecmaLabel_p->first.res2 =  // Filled with SPACEs
        ecmaLabel_p->first.lblStdVer = ecma_LblStdVer_c;
    }
    else {
        // CONTENTS UNSPECIFIED by ECMA standard.
        //ecmaLabel_p->other.volID = SHORT IVD MED ID ??
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void df_Packer::WriteRecBSEnd ( UInt32_t  a_status  ) 

Definition at line 958 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_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().

                                               {

    log_FUNC_A_m(WriteRecBSEnd, "a_status: " << a_status);

    if (m_streamOffset != m_streamSize) {
        if (a_status != df_SS_COMPLETE) {

            log_DBG_m(dbg_LOW,
                "file status != df_SS_COMPLETE " <<
                "==> fill up to the size of the stream (remaining: " <<
                (m_streamSize - m_streamOffset) << ")");

            if (m_streamAlloc > m_streamOffset) {
                WriteBSData(true);
            };

            while (m_streamOffset < m_streamSize) {
                // Write empty blocks until the end of file.
                UInt8_t     *data;
                UInt32_t    size;
                GetBSData(data, size);
                memset(data, 0, size);
                WriteBSData(true);
            }
        }
        else {
            // This exception can be used by the user of df_Packer to
            // detect that less data than declared is attempted to be written, and the
            // status is marked as COMPLETE.
            log_MARKLINE_m;
            throw ivd_Error(
                ie_DF_SSIZE,
                "Byte stream not filled up to the declared size.",
                "size: " +
                cmn_Num2Str(m_streamSize) + string(", filled:") +
                cmn_Num2Str(m_streamOffset) );
        }
    }
    else {
        if (m_streamAlloc > m_streamOffset) {
            log_MARKLINE_m;
            throw ivd_InternalError(
                ie_DATA_CORRUPTION,
                "m_streamOffset == m_streamSize and m_reservedData != 0.");
        }
    };

    m_allStreamSize      += m_streamSize;
    UInt32_t recSize = df_ALIGN_m(sizeof(df_RecCmn_t) +
                                  sizeof(df_RecByteStreamEnd_t) +
                                  m_streamName.length() + 1);

    UInt8_t *wp = m_blockProxyWriter->Allocate(recSize);
    if (wp == NULL) {
        log_WRN_m("NULL block pointer from Allocate(). No reader available.");
        return;
    }
    WriteRecBSEndRaw(
        m_idFile,
        a_status, m_streamType, m_streamSize, m_allStreamSize, m_streamName,
        ++m_recNum, wp);

    m_prevRec = rec_BSEnd_c;

    m_blockProxyWriter->Move();
}

Here is the call graph for this function:

Here is the caller graph for this function:

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 1025 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().

                                  {

    UInt32_t recSize = df_ALIGN_m(sizeof(df_RecCmn_t) +
                            sizeof(df_RecByteStreamEnd_t) +
                            a_name.length() + 1);

    df_RecCmn_t* recCmn_p = reinterpret_cast<df_RecCmn_t*>(a_buffer);
    WriteRecCmnRaw(rec_BSEnd_c, recSize, 0, a_recNum, recCmn_p);

    UInt8_t *wp = a_buffer + sizeof(df_RecCmn_t);
    UInt8_t *recStart = a_buffer;

    df_RecByteStreamEnd_t *bse_p = reinterpret_cast<df_RecByteStreamEnd_t*>(wp);
    memset(bse_p, 0, sizeof(*bse_p));

    bse_p->idFile       = hton(a_idFile);
    bse_p->streamType   = hton(a_streamType);
    bse_p->streamSize   = hton(a_streamSize);
    bse_p->status       = hton(a_status);
    bse_p->allStreamSize= hton(a_allStreamSize);

    wp += sizeof(*bse_p);
    bse_p->streamName.offset = hton(UInt32_t(wp - recStart));
    bse_p->streamName.size   = hton(UInt32_t(a_name.length() + 1));

    memcpy(
        wp,
        a_name.c_str(),
        a_name.length() + 1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void df_Packer::WriteRecBSStart ( UInt32_t  a_type,
const string &  a_name,
UInt64_t  a_streamSize,
UInt64_t  a_fileOffset = 0 
)

Definition at line 898 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().

                                  {

    log_FUNC_m(WriteRecBSStart);

    log_DBG_m(dbg_DETAIL,
        "Stream: \'" << a_name <<
        "\' size/offset: " << a_streamSize << "/" << a_fileOffset);

    // Save current stream's parameters
    m_streamType = a_type;
    m_streamName = a_name;
    m_streamOffset = 0;
    m_streamSize = a_streamSize;
    m_fileOffset = a_fileOffset;

    m_streamAlloc = 0;

    UInt32_t recSize = df_ALIGN_m(sizeof(df_RecCmn_t) +
                                  sizeof(df_RecByteStreamStart_t) +
                                  a_name.length() + 1);

    UInt8_t *wp = WriteRecCmn(rec_BSStart_c, recSize);
    if (wp == NULL) {
        return;
    }

    UInt8_t *recStart = wp - sizeof(df_RecCmn_t);

    df_RecByteStreamStart_t *bss_p =
        reinterpret_cast<df_RecByteStreamStart_t*>(wp);
    memset(bss_p, 0, sizeof(*bss_p));

    bss_p->idFile       = hton(m_idFile);
    bss_p->chunkOffset  = hton(a_fileOffset);
    bss_p->streamType   = hton(a_type);
    bss_p->streamOffset = hton(m_streamOffset);
    bss_p->streamSize   = hton(a_streamSize);

    bss_p->allStreamSize= hton(m_allStreamSize);

    wp = m_blockProxyWriter->Move(sizeof(*bss_p));

    bss_p->streamName.offset = hton(UInt32_t(wp - recStart));
    bss_p->streamName.size   = hton(UInt32_t(a_name.length() + 1));

    memcpy(
        wp,
        a_name.c_str(),
        a_name.length() + 1);

    wp = m_blockProxyWriter->Move(a_name.length());

    m_blockProxyWriter->Move();   // use remaing space up to allocated size
}

Here is the call graph for this function:

Here is the caller graph for this function:

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 191 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().

                                                  {

    log_FUNC_m(WriteRecCmn);

    if (!df_IsValidPredecessor(blk_Data_c, m_prevRec, a_type)) {
        string prevStr =
            (m_prevRec == rec_NoRec_c)
            ? string("NULL REC")
            : string((char*)(&m_prevRec), sizeof(m_prevRec));

        string curStr =
            (a_type == rec_NoRec_c)
            ? string("NULL REC")
            : string((char*)(&a_type), sizeof(a_type));

        throw ivd_InternalError(ie_DF_INVSEQ,
            "Record " + prevStr + " can't be followed by " + curStr );
    }

    // Allocate space for record
    UInt8_t *wp = m_blockProxyWriter->Allocate(a_size);
    if (wp == NULL) {
        log_WRN_m("NULL block pointer from Allocate(). No reader available.");
        return NULL;
    }

    df_RecCmn_t *recCmn_p = reinterpret_cast<df_RecCmn_t*>(wp);

    WriteRecCmnRaw(a_type, a_size, a_flags, ++m_recNum, recCmn_p);

    m_prevRec = a_type;

    // Increasing position pointer
    return m_blockProxyWriter->Move(sizeof(*recCmn_p));
}

Here is the call graph for this function:

Here is the caller graph for this function:

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 160 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().

                             {

    log_FUNC_INT_m(WriteRecCmnRaw);

    memset(a_recCmn_p, 0, sizeof(*a_recCmn_p));

    log_DBG_INT_m(dbg_NORM, "RecCmn: " << string((char*)(&a_type), sizeof(a_type)) );

    // Setting data fields
    a_recCmn_p->size = hton(a_size);

    memcpy(&(a_recCmn_p->verMajor), df_verMaj_c, sizeof(a_recCmn_p->verMajor));
    memcpy(&(a_recCmn_p->verMinor), df_verMin_c, sizeof(a_recCmn_p->verMinor));

    memcpy(a_recCmn_p->magicCookie, df_recCookie_c,
           sizeof(a_recCmn_p->magicCookie));

    // NOTE: hton and ntoh are not used on record type, because its memory print
    // is the way we need it.
    a_recCmn_p->type   = a_type;

    a_recCmn_p->flags  = hton(a_flags);
    a_recCmn_p->seqNum = hton(a_recNum);
}

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Warning:
Make sure that this implementation is in-sync with the one that writes records for file system recovery.

Definition at line 462 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().

                                 {

    log_FUNC_m(WriteRecFile-full);

    log_DBG_m(dbg_NORM, endl <<
        "a_idFile:      " << a_idFile << endl <<
        "a_idParent:    " << a_idParent << endl <<
        "a_idParentOld: " << a_idParentOld << endl <<
        "a_idMig:       " << a_idMig << endl <<
        "a_chunkSize:   " << a_chunkSize);

    if (a_idFile == 0) {
        throw ivd_InternalError(ie_INVALID_ARG, "idFile is zero");
    }

    if (a_idMig == 0) {
        throw ivd_InternalError(ie_INVALID_ARG, "idMig is zero");
    }

    // Save some file attributes for future reference
    m_idFile    = a_idFile;
    m_idMig     = a_idMig;
    m_fileName  = a_name;
    m_chunkSize = a_chunkSize;

    m_allStreamSize = 0;

    string name(a_name), nameOld(a_nameOld);
    if (PATH_SEPARATOR == '\\') { // this OS use separator for DF
        cmn_BackSlashToSlash(name);
        cmn_BackSlashToSlash(nameOld);
    }

    UInt32_t recSize = df_ALIGN_m(sizeof(df_RecCmn_t) +
                                  sizeof(df_RecFile_t) +
                                  name.length() + 1 +
                                  nameOld.length() + 1);

    // Windows stores some fields in own format - flag record
#if TGT_OS_windows
    UInt8_t *wp = WriteRecCmn(rec_FileHdr_c, recSize, df_RF_WINDOWS);
#else
    UInt8_t *wp = WriteRecCmn(rec_FileHdr_c, recSize, 0);
#endif

    if (wp == NULL) {
        return;
    }

    UInt8_t *recStart = wp - sizeof(df_RecCmn_t);

    df_RecFile_t *file_p = reinterpret_cast<df_RecFile_t*>(wp);

    file_p->idFile      = hton(a_idFile);
    file_p->idMig       = hton(a_idMig);
    file_p->idParent    = hton(a_idParent);
    file_p->idParentOld = hton(a_idParentOld);

    file_p->chunkSize   = hton(a_chunkSize);
    file_p->reserved1   = 0;

    file_p->numCopies   = hton(m_numCopies);

    file_p->stdAttr.numLinks    = hton(a_info.numLinks);
    file_p->stdAttr.idOnFS      = hton(a_info.idOnFS);
    file_p->stdAttr.type        = hton(static_cast<UInt64_t>(a_info.type));
    file_p->stdAttr.size        = hton(static_cast<UInt64_t>(a_info.size));
    file_p->stdAttr.attr        = hton(a_info.attr);

    file_p->stdAttr.owner       = hton(a_info.owner);
    file_p->stdAttr.group       = hton(a_info.group);

    file_p->stdAttr.changeFlags = hton(a_changeFlags);
    file_p->stdAttr.flags       = hton(a_flags);

    file_p->stdAttr.timeCreate  = hton(a_info.timeCreate);
    file_p->stdAttr.timeAccess  = hton(a_info.timeAccess);
    file_p->stdAttr.timeModify  = hton(a_info.timeModify);
    file_p->stdAttr.timeChange  = hton(a_info.timeChange);

    file_p->reserved2[0] = 0,
    file_p->reserved2[1] = 0,
    file_p->reserved2[2] = 0,
    file_p->reserved2[3] = 0;

    // Write fixed size record
    wp = m_blockProxyWriter->Move(sizeof(*file_p));

    // Append variable length fields(s).

    // Offset from the beginning of record (including common part).
    file_p->name.offset = hton(UInt32_t(wp - recStart));
    file_p->name.size   = hton(UInt32_t(name.length() + 1));
    memcpy(
        wp,
        name.c_str(),
        name.length()+1);

    wp = m_blockProxyWriter->Move(name.length()+1);

    file_p->nameOld.offset = hton(UInt32_t(wp - recStart));
    file_p->nameOld.size   = hton(UInt32_t(nameOld.length() + 1));

    memcpy(
        wp,
        nameOld.c_str(),
        nameOld.length() + 1);

    wp = m_blockProxyWriter->Move(nameOld.length() + 1);

    m_blockProxyWriter->Move();   // use remaing space up to allocated size
}

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Warning:
Make sure that this implementation is in-sync with the one that writes records for media.

Definition at line 595 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().

                                      {

    log_FUNC_m(WriteRecFile-light);

    log_DBG_m(dbg_NORM, endl <<
        "a_idFile:      " << a_idFile << endl <<
        "a_idParent:    " << a_idParent << endl);

    if (a_idFile == 0) {
        throw ivd_InternalError(ie_INVALID_ARG, "idFile is zero");
    }

    // Save some file attributes for future reference
    m_idFile    = a_idFile;
    m_idMig     = 0;
    m_fileName  = a_name;
    m_chunkSize = 0;

    string nameOld; // just empty string

    UInt32_t recSize = df_ALIGN_m(sizeof(df_RecCmn_t) +
                                  sizeof(df_RecFile_t) +
                                  a_name.length() + 1 +
                                  nameOld.length() + 1);

    UInt8_t *wp = WriteRecCmn(rec_FileHdr_c, recSize);
    if (wp == NULL) {
        return;
    }

    UInt8_t *recStart = wp - sizeof(df_RecCmn_t);

    df_RecFile_t *file_p = reinterpret_cast<df_RecFile_t*>(wp);

    file_p->idFile      = hton(a_idFile);
    file_p->idMig       = 0;
    file_p->idParent    = hton(a_idParent);
    file_p->idParentOld = 0;

    file_p->chunkSize   = 0;
    file_p->reserved1   = 0;

    file_p->numCopies   = hton(m_numCopies);

    file_p->stdAttr = standAttr;

    file_p->reserved2[0] = 0,
    file_p->reserved2[1] = 0,
    file_p->reserved2[2] = 0,
    file_p->reserved2[3] = 0;

    // Write fixed size record
    wp = m_blockProxyWriter->Move(sizeof(*file_p));

    // Append variable length fields(s).

    // Offset from the beginning of record (including common part).
    file_p->name.offset = hton(UInt32_t(wp - recStart));
    file_p->name.size   = hton(UInt32_t(a_name.length() + 1));
    memcpy(
        wp,
        a_name.c_str(),
        a_name.length() + 1);

    wp = m_blockProxyWriter->Move(a_name.length() + 1);

    file_p->nameOld.offset = hton(UInt32_t(wp - recStart));
    file_p->nameOld.size   = hton(UInt32_t(nameOld.length() + 1));

    memcpy(
        wp,
        nameOld.c_str(),
        nameOld.length() + 1);

    wp = m_blockProxyWriter->Move(nameOld.length() + 1);

    m_blockProxyWriter->Move();   // use remaing space up to allocated size
}

Here is the call graph for this function:

void df_Packer::WriteRecFileEnd ( UInt32_t  a_status  ) 

Definition at line 707 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().

                              {

    log_FUNC_m(WriteRecFileEnd);

    log_DBG_m(dbg_NORM, endl << "a_status:      " << a_status);

    UInt32_t recSize = df_ALIGN_m(sizeof(df_RecCmn_t) +
                                  sizeof(df_RecFileEnd_t));

    UInt8_t *wp = WriteRecCmn(rec_FileEnd_c, recSize);
    if (wp == NULL) {
        return;
    }

    df_RecFileEnd_t *fEnd_p = reinterpret_cast<df_RecFileEnd_t*>(wp);
    memset(fEnd_p, 0, sizeof(*fEnd_p));

    fEnd_p->idFile      = hton(m_idFile);
    fEnd_p->idMig       = hton(m_idMig);

    fEnd_p->status      = hton(a_status);

    wp = m_blockProxyWriter->Move(sizeof(*fEnd_p));

    m_blockProxyWriter->Move();   // use remaing space up to allocated size
}

Here is the call graph for this function:

Here is the caller graph for this function:

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 679 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().

                             {

    log_FUNC_m(WriteRecFileEndRaw);

    UInt32_t recSize =
        df_ALIGN_m(sizeof(df_RecCmn_t) + sizeof(df_RecFileEnd_t));

    df_RecCmn_t  *recCmn_p = reinterpret_cast<df_RecCmn_t*>(a_buffer);
    WriteRecCmnRaw(rec_FileEnd_c, recSize, a_flags, a_recNum, recCmn_p);

    df_RecFileEnd_t *fe_p =
        reinterpret_cast<df_RecFileEnd_t*>(a_buffer + sizeof(df_RecCmn_t));

    memset(fe_p, 0, sizeof(*fe_p));

    fe_p->idFile      = hton(a_idFile);
    fe_p->idMig       = hton(a_idMig);
    fe_p->status      = hton(a_status);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void df_Packer::WriteRecFRIEnd (  ) 

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

Here is the caller graph for this function:

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.

Warning:
This function does not use internal block infrastructure. The header is written to the a_friBuf parameter.

Definition at line 363 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().

                                          {

    log_FUNC_m(WriteRecFRIEnd);

    log_DBG_m(dbg_DETAIL,
        endl <<
        "a_volID    = " << a_volID << endl <<
        "a_poolID   = " << a_poolID << endl <<
        "a_partID   = " << a_partID << endl <<
        "a_startPos = " << a_startPos << endl <<
        "a_endPos   = " << a_endPos << endl <<
        "a_status   = " << a_status);

    UInt32_t recSize = df_ALIGN_m(sizeof(df_RecCmn_t) +
                                  sizeof(df_RecFRIEnd_t));

    if (recSize > a_friBufSize) {
        throw ivd_Error(ie_DF_INV_BLK, "Block not large enough for FRIEnd.");
    };

    df_RecCmn_t  *recCmn_p = reinterpret_cast<df_RecCmn_t*>(a_friBuf);

    WriteRecCmnRaw(rec_FRIEnd_c, recSize, 0, a_recNum, recCmn_p);

    df_RecFRIEnd_t *friEnd_p =
        reinterpret_cast<df_RecFRIEnd_t*>(a_friBuf + sizeof(df_RecCmn_t));

    memset(friEnd_p, 0, sizeof(*friEnd_p));

    friEnd_p->volID         = a_volID;
    friEnd_p->poolID        = a_poolID;
    friEnd_p->partID        = a_partID;

    friEnd_p->startPos      = hton(a_startPos);
    friEnd_p->endPos        = hton(a_endPos);
    friEnd_p->status        = hton(a_status);
}

Here is the call graph for this function:

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.

Warning:
This function does not use internal block infrastructure. The header is written to the a_friBuf parameter.

Definition at line 411 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().

                                          {

    log_FUNC_m(WriteRecFRISplitInfo);

    log_DBG_m(dbg_NORM,
        endl <<
        "a_idFile    = " << a_idFile << endl <<
        "a_allStOff  = " << a_allStreamOffset << endl <<
        "a_allStSize = " << a_allStreamSize << endl <<
        "a_stType    = " << cmn_Num2Str(a_streamType, true) << endl <<
        "a_medBlkAddr= " << a_mediaBlockAddress );

    UInt32_t recSize = df_ALIGN_m(sizeof(df_RecCmn_t) +
                                  sizeof(df_RecFRISpInfo_t));

    if (recSize > a_friBufSize) {
        throw ivd_Error(ie_DF_INV_BLK, "Block not large enough for FRISpInfo.");
    }

    df_RecCmn_t  *recCmn_p = reinterpret_cast<df_RecCmn_t*>(a_friBuf);

    WriteRecCmnRaw(rec_FRISpInfo_c, recSize, 0, a_recNum, recCmn_p);

    df_RecFRISpInfo_t *friSpInfo_p =
        reinterpret_cast<df_RecFRISpInfo_t*>(a_friBuf + sizeof(df_RecCmn_t));

    memset(friSpInfo_p, 0, sizeof(*friSpInfo_p));

    friSpInfo_p->idFile             = hton(a_idFile);
    friSpInfo_p->allStreamOffset    = hton(a_allStreamOffset);
    friSpInfo_p->allStreamSize      = hton(a_allStreamSize);
    friSpInfo_p->streamType         = hton(a_streamType);

    // Data Format 01.01 change.
    friSpInfo_p->mediaBlockAddr     = hton(a_mediaBlockAddress);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void df_Packer::WriteRecFRIStart (  ) 

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

Here is the caller graph for this function:

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.

Warning:
This function does not use internal block infrastructure. The header is written to the a_friBuf parameter.

Definition at line 321 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().

                                          {

    log_FUNC_m(WriteRecFRIStart);

    log_DBG_m(dbg_DETAIL,
        endl <<
        "a_volID    = " << a_volID << endl <<
        "a_poolID   = " << a_poolID << endl <<
        "a_partID   = " << a_partID << endl <<
        "a_startPos = " << a_startPos);

    UInt32_t recSize = df_ALIGN_m(sizeof(df_RecCmn_t) +
                                  sizeof(df_RecFRIStart_t));

    if (recSize > a_friBufSize) {
        throw ivd_Error(ie_DF_INV_BLK, "Block not large enough for FRIStart.");
    }

    df_RecCmn_t  *recCmn_p = reinterpret_cast<df_RecCmn_t*>(a_friBuf);

    WriteRecCmnRaw(rec_FRIStart_c, recSize, 0, a_recNum, recCmn_p);

    df_RecFRIStart_t *friStart_p =
        reinterpret_cast<df_RecFRIStart_t*>(a_friBuf + sizeof(df_RecCmn_t));

    memset(friStart_p, 0, sizeof(*friStart_p));

    friStart_p->volID       = a_volID;
    friStart_p->poolID      = a_poolID;
    friStart_p->partID      = a_partID;

    friStart_p->startPos    = hton(a_startPos);
}

Here is the call graph for this function:

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.

Parameters:
a_partNumber ECMA part number (starts from 1!)
Warning:
This function does not use internal block infrastructure. The header is written to the a_volHdr parameter.

Definition at line 229 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().

                                          {

    log_FUNC_m(WriteRecMedVolHdr);

    log_DBG_m(dbg_NORM,
        endl <<
        "a_volID  = " << a_volID << endl <<
        "a_poolID = " << a_poolID << endl <<
        "a_partID = " << a_partID << endl <<
        "a_appID  = " << a_appID);

    UInt32_t recSize = df_ALIGN_m(sizeof(df_RecCmn_t) +
                                  sizeof(df_RecVolHdr_t) +
                                  a_appID.length()+1);

    if (sizeof(df_ECMAVolumeLabel_t) + recSize > a_volHdrSize) {
        throw ivd_Error(ie_DF_INV_BLK, "Block not large enough to hold VolHdr");
    }

    WriteECMAVolHeader(a_partNumber, a_volHdr);

    // ECMA volume label is not a part of IVD label record.

    df_RecCmn_t  *recCmn_p =
        reinterpret_cast<df_RecCmn_t*>(a_volHdr + sizeof(df_ECMAVolumeLabel_t));

    WriteRecCmnRaw(rec_VolHdr_c, recSize, 0, 0, recCmn_p);

    UInt8_t *recStart = reinterpret_cast<UInt8_t*>(recCmn_p);

    df_RecVolHdr_t *volHdr_p =
        reinterpret_cast<df_RecVolHdr_t*>(recStart + sizeof(*recCmn_p));

    memset(volHdr_p, 0, sizeof(*volHdr_p));

    volHdr_p->flags = a_volFlags;

    // Data Format version 01.01 change:
    volHdr_p->flags |= df_volFlagSysVolValid_c;

    volHdr_p->flags         = hton(volHdr_p->flags);
    volHdr_p->volID         = a_volID;
    volHdr_p->poolID        = a_poolID;
    volHdr_p->partID        = a_partID;
    volHdr_p->blockSize     = hton(a_blockSize);

    ivd_Time_t now = (UInt64_t)time(NULL);
    volHdr_p->timeInit      = hton(now);
    volHdr_p->timeAccess    = hton(a_timeAccess);
    volHdr_p->timeWrite     = hton(a_timeWrite);
    volHdr_p->timeOverwrite = hton(a_timeOverwrite);

    volHdr_p->numAccess     = hton(a_numAccess);
    volHdr_p->numAppends    = hton(a_numAppends);
    volHdr_p->numOverwrites = hton(a_numOverwrites);

    // Data Format 01.01 change
    volHdr_p->sysVolIndex   = a_sysVolIndex; // 8-bit, no hton needed

    // Append variable length fields(s).

    UInt8_t *wp = recStart + sizeof(*recCmn_p) + sizeof(*volHdr_p);

    // Offset from the beginning of record (including common part).
    volHdr_p->appID.offset  = hton(UInt32_t(wp - recStart));
    volHdr_p->appID.size    = hton(UInt32_t(a_appID.length()+1));

    memcpy(
        wp,
        a_appID.c_str(),
        a_appID.length()+1);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Macro to add class name member s_className.

Definition at line 933 of file df.h.

Size of all stream records of a file up to current position.

Definition at line 964 of file df.h.

Referenced by WriteRecBSEnd(), WriteRecBSStart(), and WriteRecFile().

Definition at line 948 of file df.h.

Referenced by WriteRecFile().

string df_Packer::m_fileName [protected]

Definition at line 947 of file df.h.

Referenced by WriteRecFile().

Definition at line 949 of file df.h.

Referenced by MakeSpaceForData(), and WriteRecBSStart().

Definition at line 945 of file df.h.

Referenced by MakeSpaceForData(), WriteRecBSEnd(), WriteRecBSStart(), WriteRecFile(), and WriteRecFileEnd().

Definition at line 946 of file df.h.

Referenced by WriteRecFile(), and WriteRecFileEnd().

Definition at line 969 of file df.h.

Referenced by WriteRecFile().

Which was the previous record type?

Definition at line 941 of file df.h.

Referenced by GetBSData(), WriteRecBSEnd(), WriteRecCmn(), and ~df_Packer().

Current record number.

Definition at line 943 of file df.h.

Referenced by WriteRecBSEnd(), and WriteRecCmn().

Helper to detect if a stream is filled properly.

Definition at line 967 of file df.h.

Referenced by GetBSData(), WriteBSData(), WriteRecBSEnd(), and WriteRecBSStart().

string df_Packer::m_streamName [protected]

Definition at line 952 of file df.h.

Referenced by MakeSpaceForData(), WriteRecBSEnd(), and WriteRecBSStart().

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 958 of file df.h.

Referenced by GetBSData(), MakeSpaceForData(), WriteBSData(), WriteRecBSEnd(), and WriteRecBSStart().

Definition at line 959 of file df.h.

Referenced by GetBSData(), WriteRecBSEnd(), and WriteRecBSStart().

Definition at line 951 of file df.h.

Referenced by MakeSpaceForData(), WriteRecBSEnd(), and WriteRecBSStart().


The documentation for this class was generated from the following files: