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/syscall.c
int do_punch_hole(int fd, UNUSED(OFF_T pos), int len)
{
#ifdef HAVE_FALLOCATE
#ifdef HAVE_FALLOC_FL_PUNCH_HOLE
    if (fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, pos, len) ==
        0)
    {
        if (do_lseek(fd, len, SEEK_CUR) != pos + len)
            return -1;
        return 0;
    }
#endif
#ifdef HAVE_FALLOC_FL_ZERO_RANGE
    if (fallocate(fd, FALLOC_FL_ZERO_RANGE, pos, len) == 0)
    {
        if (do_lseek(fd, len, SEEK_CUR) != pos + len)
            return -1;
        return 0;
    }
#endif
#endif
    {
        char zeros[4096];
        memset(zeros, 0, sizeof zeros);
        while (len > 0)
        {
            int chunk = len > (int)sizeof zeros ? (int)sizeof zeros : len;
            int wrote = write(fd, zeros, chunk);
            if (wrote <= 0)
            {
                if (wrote < 0 && errno == EINTR)
                    continue;
                return -1;
            }
            len -= wrote;
        }
    }
    return 0;
}
/* Punch a hole at pos for len bytes. The current file position must be at pos
 * and will be changed to be at pos + len. */
Punch a hole at pos for len bytes. The current file position must be at pos
and will be changed to be at pos + len.
Punch a hole at pos for len bytes . The current file position must be at pos and will be changed to be at pos + len .
int do_punch_hole(int fd, UNUSED(OFF_T pos), int len)
{
#ifdef HAVE_FALLOCATE
#ifdef HAVE_FALLOC_FL_PUNCH_HOLE
    if (fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, pos, len) ==
        0)
    {
        if (do_lseek(fd, len, SEEK_CUR) != pos + len)
            return -1;
        return 0;
    }
#endif
#ifdef HAVE_FALLOC_FL_ZERO_RANGE
    if (fallocate(fd, FALLOC_FL_ZERO_RANGE, pos, len) == 0)
    {
        if (do_lseek(fd, len, SEEK_CUR) != pos + len)
            return -1;
        return 0;
    }
#endif
#endif
    {
        char zeros[4096];
        memset(zeros, 0, sizeof zeros);
        while (len > 0)
        {
            int chunk = len > (int)sizeof zeros ? (int)sizeof zeros : len;
            int wrote = write(fd, zeros, chunk);
            if (wrote <= 0)
            {
                if (wrote < 0 && errno == EINTR)
                    continue;
                return -1;
            }
            len -= wrote;
        }
    }
    return 0;
}
int do_punch_hole ( int fd , UNUSED ( OFF_T pos ) , int len ) { #ifdef HAVE_FALLOCATE #ifdef HAVE_FALLOC_FL_PUNCH_HOLE if ( fallocate ( fd , FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE , pos , len ) == 0 ) { if ( do_lseek ( fd , len , SEEK_CUR ) != pos + len ) return -1 ; return 0 ; } #endif #ifdef HAVE_FALLOC_FL_ZERO_RANGE if ( fallocate ( fd , FALLOC_FL_ZERO_RANGE , pos , len ) == 0 ) { if ( do_lseek ( fd , len , SEEK_CUR ) != pos + len ) return -1 ; return 0 ; } #endif #endif { char zeros [ 4096 ] ; memset ( zeros , 0 , sizeof zeros ) ; while ( len > 0 ) { int chunk = len > ( int ) sizeof zeros ? ( int ) sizeof zeros : len ; int wrote = write ( fd , zeros , chunk ) ; if ( wrote <= 0 ) { if ( wrote < 0 && errno == EINTR ) continue ; return -1 ; } len -= wrote ; } } return 0 ; }
Punch a hole at pos for len bytes.
Punch a hole at pos for len bytes .