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
ssize_t rawexpread(off_t a, char* buf, size_t len, CLIENT* client)
{
    int fhandle;
    off_t foffset;
    size_t maxbytes;
    ssize_t retval;

    if (get_filepos(client, a, &fhandle, &foffset, &maxbytes))
        return -1;
    if (maxbytes && len > maxbytes)
        len = maxbytes;

    DEBUG("(READ from fd %d offset %llu len %u), ", fhandle,
          (long long unsigned int)foffset, (unsigned int)len);

    retval = pread(fhandle, buf, len, foffset);
    if (client->server->flags & F_TREEFILES)
    {
        close(fhandle);
    }
    return retval;
}
/**
 * Read an amount of bytes at a given offset from the right file. This
 * abstracts the read-side of the multiple files option.
 *
 * @param a The offset where the read should start
 * @param buf A buffer to read into
 * @param len The size of buf
 * @param client The client we're serving for
 * @return The number of bytes actually read, or -1 in case of an
 * error.
 **/
Read an amount of bytes at a given offset from the right file. This
abstracts the read-side of the multiple files option.


Read an amount of bytes at a given offset from the right file . This abstracts the read - side of the multiple files option .
ssize_t rawexpread(off_t a, char* buf, size_t len, CLIENT* client)
{
    int fhandle;
    off_t foffset;
    size_t maxbytes;
    ssize_t retval;
    if (get_filepos(client, a, &fhandle, &foffset, &maxbytes))
        return -1;
    if (maxbytes && len > maxbytes)
        len = maxbytes;
    DEBUG("(READ from fd %d offset %llu len %u), ", fhandle,
          (long long unsigned int)foffset, (unsigned int)len);
    retval = pread(fhandle, buf, len, foffset);
    if (client->server->flags & F_TREEFILES)
    {
        close(fhandle);
    }
    return retval;
}
ssize_t rawexpread ( off_t a , char * buf , size_t len , CLIENT * client ) { int fhandle ; off_t foffset ; size_t maxbytes ; ssize_t retval ; if ( get_filepos ( client , a , & fhandle , & foffset , & maxbytes ) ) return -1 ; if ( maxbytes && len > maxbytes ) len = maxbytes ; DEBUG ( " " , fhandle , ( long long unsigned int ) foffset , ( unsigned int ) len ) ; retval = pread ( fhandle , buf , len , foffset ) ; if ( client -> server -> flags & F_TREEFILES ) { close ( fhandle ) ; } return retval ; }
Read an amount of bytes at a given offset from the right file.
Read an amount of bytes at a given offset from the right file .