openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/rsync/3.1.3-r0/rsync-3.1.3/fileio.c
int write_file(int f, int use_seek, OFF_T offset, const char* buf, int len)
{
    int ret = 0;

    while (len > 0)
    {
        int r1;
        if (sparse_files > 0)
        {
            int len1 = MIN(len, SPARSE_WRITE_SIZE);
            r1 = write_sparse(f, use_seek, offset, buf, len1);
            offset += r1;
        }
        else
        {
            if (!wf_writeBuf)
            {
                wf_writeBufSize = WRITE_SIZE * 8;
                wf_writeBufCnt = 0;
                wf_writeBuf = new_array(char, wf_writeBufSize);
                if (!wf_writeBuf)
                    out_of_memory("write_file");
            }
            r1 = (int)MIN((size_t)len, wf_writeBufSize - wf_writeBufCnt);
            if (r1)
            {
                memcpy(wf_writeBuf + wf_writeBufCnt, buf, r1);
                wf_writeBufCnt += r1;
            }
            if (wf_writeBufCnt == wf_writeBufSize)
            {
                if (flush_write_file(f) < 0)
                    return -1;
                if (!r1 && len)
                    continue;
            }
        }
        if (r1 <= 0)
        {
            if (ret > 0)
                return ret;
            return r1;
        }
        len -= r1;
        buf += r1;
        ret += r1;
    }
    return ret;
}
/* write_file does not allow incomplete writes.  It loops internally
 * until len bytes are written or errno is set.  Note that use_seek and
 * offset are only used in sparse processing (see write_sparse()). */
write_file does not allow incomplete writes.  It loops internally
until len bytes are written or errno is set.  Note that use_seek and
offset are only used in sparse processing ).
write_file does not allow incomplete writes . It loops internally until len bytes are written or errno is set . Note that use_seek and offset are only used in sparse processing ) .
int write_file(int f, int use_seek, OFF_T offset, const char* buf, int len)
{
    int ret = 0;
    while (len > 0)
    {
        int r1;
        if (sparse_files > 0)
        {
            int len1 = MIN(len, SPARSE_WRITE_SIZE);
            r1 = write_sparse(f, use_seek, offset, buf, len1);
            offset += r1;
        }
        else
        {
            if (!wf_writeBuf)
            {
                wf_writeBufSize = WRITE_SIZE * 8;
                wf_writeBufCnt = 0;
                wf_writeBuf = new_array(char, wf_writeBufSize);
                if (!wf_writeBuf)
                    out_of_memory("write_file");
            }
            r1 = (int)MIN((size_t)len, wf_writeBufSize - wf_writeBufCnt);
            if (r1)
            {
                memcpy(wf_writeBuf + wf_writeBufCnt, buf, r1);
                wf_writeBufCnt += r1;
            }
            if (wf_writeBufCnt == wf_writeBufSize)
            {
                if (flush_write_file(f) < 0)
                    return -1;
                if (!r1 && len)
                    continue;
            }
        }
        if (r1 <= 0)
        {
            if (ret > 0)
                return ret;
            return r1;
        }
        len -= r1;
        buf += r1;
        ret += r1;
    }
    return ret;
}
int write_file ( int f , int use_seek , OFF_T offset , const char * buf , int len ) { int ret = 0 ; while ( len > 0 ) { int r1 ; if ( sparse_files > 0 ) { int len1 = MIN ( len , SPARSE_WRITE_SIZE ) ; r1 = write_sparse ( f , use_seek , offset , buf , len1 ) ; offset += r1 ; } else { if ( ! wf_writeBuf ) { wf_writeBufSize = WRITE_SIZE * 8 ; wf_writeBufCnt = 0 ; wf_writeBuf = new_array ( char , wf_writeBufSize ) ; if ( ! wf_writeBuf ) out_of_memory ( " " ) ; } r1 = ( int ) MIN ( ( size_t ) len , wf_writeBufSize - wf_writeBufCnt ) ; if ( r1 ) { memcpy ( wf_writeBuf + wf_writeBufCnt , buf , r1 ) ; wf_writeBufCnt += r1 ; } if ( wf_writeBufCnt == wf_writeBufSize ) { if ( flush_write_file ( f ) < 0 ) return -1 ; if ( ! r1 && len ) continue ; } } if ( r1 <= 0 ) { if ( ret > 0 ) return ret ; return r1 ; } len -= r1 ; buf += r1 ; ret += r1 ; } return ret ; }
write_file does not allow incomplete writes.
write_file does not allow incomplete writes .