openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/nbd/3.19-r0/nbd-3.19/nbd-server.c
int expwrite_zeroes(struct nbd_request* req, CLIENT* client, int fua)
{
    off_t a = req->from;
    size_t len = req->len;
    size_t maxsize = 64LL * 1024LL * 1024LL;
    /* use calloc() as sadly MAP_ANON is apparently not POSIX standard */
    char* buf = calloc(1, maxsize);
    int ret;
    while (len > 0)
    {
        size_t l = len;
        if (l > maxsize)
            l = maxsize;
        ret = expwrite(a, buf, l, client, fua);
        if (ret)
        {
            free(buf);
            return ret;
        }
        len -= l;
    }
    free(buf);
    return 0;
}
/**
 * Write an amount of zeroes at a given offset to the right file.
 * This routine could be optimised by not calling expwrite. However,
 * this is by far the simplest way to do it.
 *
 * @param req the request
 * @param client The client we're going to write for.
 * @return 0 on success, nonzero on failure
 **/
Write an amount of zeroes at a given offset to the right file.
This routine could be optimised by not calling expwrite. However,
this is by far the simplest way to do it.

@param req the request
@param client The client we're going to write for.
@return 0 on success, nonzero on failure
Write an amount of zeroes at a given offset to the right file . This routine could be optimised by not calling expwrite . However this is by far the simplest way to do it . @param req the request @param client The client we ' re going to write for . @return 0 on success nonzero on failure
int expwrite_zeroes(struct nbd_request* req, CLIENT* client, int fua)
{
    off_t a = req->from;
    size_t len = req->len;
    size_t maxsize = 64LL * 1024LL * 1024LL;
    char* buf = calloc(1, maxsize);
    int ret;
    while (len > 0)
    {
        size_t l = len;
        if (l > maxsize)
            l = maxsize;
        ret = expwrite(a, buf, l, client, fua);
        if (ret)
        {
            free(buf);
            return ret;
        }
        len -= l;
    }
    free(buf);
    return 0;
}
int expwrite_zeroes ( struct nbd_request * req , CLIENT * client , int fua ) { off_t a = req -> from ; size_t len = req -> len ; size_t maxsize = 64LL * 1024LL * 1024LL ; char * buf = calloc ( 1 , maxsize ) ; int ret ; while ( len > 0 ) { size_t l = len ; if ( l > maxsize ) l = maxsize ; ret = expwrite ( a , buf , l , client , fua ) ; if ( ret ) { free ( buf ) ; return ret ; } len -= l ; } free ( buf ) ; return 0 ; }
Write an amount of zeroes at a given offset to the right file.
Write an amount of zeroes at a given offset to the right file .
/* use calloc() as sadly MAP_ANON is apparently not POSIX standard */