openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/rsyslog/8.1903.0-r0/rsyslog-8.1903.0/runtime/stream.c
rsRetVal strmMultiFileSeek(strm_t* pThis, unsigned int FNum, off64_t offs,
                           off64_t* bytesDel)
{
    struct stat statBuf;
    DEFiRet;

    ISOBJ_TYPE_assert(pThis, strm);

    if (FNum == 0 && offs == 0)
    { /* happens during queue init */
        *bytesDel = 0;
        FINALIZE;
    }

    if (pThis->iCurrFNum != FNum)
    {
        /* Note: we assume that no more than one file is skipped - an
         * assumption that is being used also by the whole rest of the
         * code and most notably the queue subsystem.
         */
        CHKiRet(genFileName(&pThis->pszCurrFName, pThis->pszDir, pThis->lenDir,
                            pThis->pszFName, pThis->lenFName, pThis->iCurrFNum,
                            pThis->iFileNumDigits));
        if (stat((char*)pThis->pszCurrFName, &statBuf) != 0)
        {
            LogError(errno, RS_RET_IO_ERROR,
                     "unexpected error doing a stat() "
                     "on file %s - further malfunctions may happen",
                     pThis->pszCurrFName);
            ABORT_FINALIZE(RS_RET_IO_ERROR);
        }
        *bytesDel = statBuf.st_size;
        DBGPRINTF("strmMultiFileSeek: detected new filenum, was %u, new %u, "
                  "deleting '%s' (%lld bytes)\n",
                  pThis->iCurrFNum, FNum, pThis->pszCurrFName,
                  (long long)*bytesDel);
        unlink((char*)pThis->pszCurrFName);
        if (pThis->cryprov != NULL)
            pThis->cryprov->DeleteStateFiles(pThis->pszCurrFName);
        free(pThis->pszCurrFName);
        pThis->pszCurrFName = NULL;
        pThis->iCurrFNum = FNum;
    }
    else
    {
        *bytesDel = 0;
    }
    pThis->strtOffs = pThis->iCurrOffs = offs;

finalize_it:
    RETiRet;
}
/* multi-file seek, seeks to file number & offset within file. This
 * is a support function for the queue, in circular mode. DO NOT USE
 * IT FOR OTHER NEEDS - it may not work as expected. It will
 * seek to the new position and delete interim files, as it skips them.
 * Note: this code can be removed when the queue gets a new disk store
 * handler (if and when it does ;)).
 * The output parameter bytesDel receives the number of bytes that have
 * been deleted (if a file is deleted) or 0 if nothing was deleted.
 * rgerhards, 2012-11-07
 */
multi-file seek, seeks to file number & offset within file. This
is a support function for the queue, in circular mode.
multi - file seek seeks to file number & offset within file . This is a support function for the queue in circular mode .
rsRetVal strmMultiFileSeek(strm_t* pThis, unsigned int FNum, off64_t offs,
                           off64_t* bytesDel)
{
    struct stat statBuf;
    DEFiRet;
    ISOBJ_TYPE_assert(pThis, strm);
    if (FNum == 0 && offs == 0)
    { 
        *bytesDel = 0;
        FINALIZE;
    }
    if (pThis->iCurrFNum != FNum)
    {
        CHKiRet(genFileName(&pThis->pszCurrFName, pThis->pszDir, pThis->lenDir,
                            pThis->pszFName, pThis->lenFName, pThis->iCurrFNum,
                            pThis->iFileNumDigits));
        if (stat((char*)pThis->pszCurrFName, &statBuf) != 0)
        {
            LogError(errno, RS_RET_IO_ERROR,
                     "unexpected error doing a stat() "
                     "on file %s - further malfunctions may happen",
                     pThis->pszCurrFName);
            ABORT_FINALIZE(RS_RET_IO_ERROR);
        }
        *bytesDel = statBuf.st_size;
        DBGPRINTF("strmMultiFileSeek: detected new filenum, was %u, new %u, "
                  "deleting '%s' (%lld bytes)\n",
                  pThis->iCurrFNum, FNum, pThis->pszCurrFName,
                  (long long)*bytesDel);
        unlink((char*)pThis->pszCurrFName);
        if (pThis->cryprov != NULL)
            pThis->cryprov->DeleteStateFiles(pThis->pszCurrFName);
        free(pThis->pszCurrFName);
        pThis->pszCurrFName = NULL;
        pThis->iCurrFNum = FNum;
    }
    else
    {
        *bytesDel = 0;
    }
    pThis->strtOffs = pThis->iCurrOffs = offs;
finalize_it:
    RETiRet;
}
rsRetVal strmMultiFileSeek ( strm_t * pThis , unsigned int FNum , off64_t offs , off64_t * bytesDel ) { struct stat statBuf ; DEFiRet ; ISOBJ_TYPE_assert ( pThis , strm ) ; if ( FNum == 0 && offs == 0 ) { * bytesDel = 0 ; FINALIZE ; } if ( pThis -> iCurrFNum != FNum ) { CHKiRet ( genFileName ( & pThis -> pszCurrFName , pThis -> pszDir , pThis -> lenDir , pThis -> pszFName , pThis -> lenFName , pThis -> iCurrFNum , pThis -> iFileNumDigits ) ) ; if ( stat ( ( char * ) pThis -> pszCurrFName , & statBuf ) != 0 ) { LogError ( errno , RS_RET_IO_ERROR , " " " " , pThis -> pszCurrFName ) ; ABORT_FINALIZE ( RS_RET_IO_ERROR ) ; } * bytesDel = statBuf . st_size ; DBGPRINTF ( " " " \n " , pThis -> iCurrFNum , FNum , pThis -> pszCurrFName , ( long long ) * bytesDel ) ; unlink ( ( char * ) pThis -> pszCurrFName ) ; if ( pThis -> cryprov != NULL ) pThis -> cryprov -> DeleteStateFiles ( pThis -> pszCurrFName ) ; free ( pThis -> pszCurrFName ) ; pThis -> pszCurrFName = NULL ; pThis -> iCurrFNum = FNum ; } else { * bytesDel = 0 ; } pThis -> strtOffs = pThis -> iCurrOffs = offs ; finalize_it : RETiRet ; }
multi-file seek, seeks to file number & offset within file.
multi - file seek seeks to file number & offset within file .
/* happens during queue init */ /* Note: we assume that no more than one file is skipped - an
         * assumption that is being used also by the whole rest of the
         * code and most notably the queue subsystem.
         */