openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/util-linux/2.33.2-r0/util-linux-2.33.2/libblkid/src/probe.c
unsigned char* blkid_probe_get_buffer(blkid_probe pr, uint64_t off,
                                      uint64_t len)
{
    struct blkid_bufinfo* bf = NULL;
    uint64_t real_off = pr->off + off;

    /*
    DBG(BUFFER, ul_debug("\t>>>> off=%ju, real-off=%ju (probe <%ju..%ju>,
    len=%ju", off, real_off, pr->off, pr->off + pr->size, len));
    */

    if (pr->size == 0)
    {
        errno = EINVAL;
        return NULL;
    }

    if (len == 0 || (!S_ISCHR(pr->mode) && pr->off + pr->size < real_off + len))
    {
        DBG(BUFFER, ul_debug("\t  ignore: request out of probing area"));
        errno = 0;
        return NULL;
    }

    if (pr->parent && pr->parent->devno == pr->devno &&
        pr->parent->off <= pr->off &&
        pr->parent->off + pr->parent->size >= pr->off + pr->size)
    {
        /*
         * This is a cloned prober and points to the same area as
         * parent. Let's use parent's buffers.
         *
         * Note that pr->off (and pr->parent->off) is always from the
         * begin of the device.
         */
        return blkid_probe_get_buffer(pr->parent,
                                      pr->off + off - pr->parent->off, len);
    }

    /* try buffers we already have in memory or read from device */
    bf = get_cached_buffer(pr, off, len);
    if (!bf)
    {
        bf = read_buffer(pr, real_off, len);
        if (!bf)
            return NULL;

        list_add_tail(&bf->bufs, &pr->buffers);
    }

    assert(bf->off <= real_off);
    assert(bf->off + bf->len >= real_off + len);

    errno = 0;
    return real_off ? bf->data + (real_off - bf->off) : bf->data;
}
/*
 * Note that @off is offset within probing area, the probing area is defined by
 * pr->off and pr->size.
 */
Note that @off is offset within probing area, the probing area is defined by
pr->off and pr->size.
Note that @off is offset within probing area the probing area is defined by pr - > off and pr - > size .
unsigned char* blkid_probe_get_buffer(blkid_probe pr, uint64_t off,
                                      uint64_t len)
{
    struct blkid_bufinfo* bf = NULL;
    uint64_t real_off = pr->off + off;
    if (pr->size == 0)
    {
        errno = EINVAL;
        return NULL;
    }
    if (len == 0 || (!S_ISCHR(pr->mode) && pr->off + pr->size < real_off + len))
    {
        DBG(BUFFER, ul_debug("\t  ignore: request out of probing area"));
        errno = 0;
        return NULL;
    }
    if (pr->parent && pr->parent->devno == pr->devno &&
        pr->parent->off <= pr->off &&
        pr->parent->off + pr->parent->size >= pr->off + pr->size)
    {
        return blkid_probe_get_buffer(pr->parent,
                                      pr->off + off - pr->parent->off, len);
    }
    bf = get_cached_buffer(pr, off, len);
    if (!bf)
    {
        bf = read_buffer(pr, real_off, len);
        if (!bf)
            return NULL;
        list_add_tail(&bf->bufs, &pr->buffers);
    }
    assert(bf->off <= real_off);
    assert(bf->off + bf->len >= real_off + len);
    errno = 0;
    return real_off ? bf->data + (real_off - bf->off) : bf->data;
}
unsigned char * blkid_probe_get_buffer ( blkid_probe pr , uint64_t off , uint64_t len ) { struct blkid_bufinfo * bf = NULL ; uint64_t real_off = pr -> off + off ; if ( pr -> size == 0 ) { errno = EINVAL ; return NULL ; } if ( len == 0 || ( ! S_ISCHR ( pr -> mode ) && pr -> off + pr -> size < real_off + len ) ) { DBG ( BUFFER , ul_debug ( " \t " ) ) ; errno = 0 ; return NULL ; } if ( pr -> parent && pr -> parent -> devno == pr -> devno && pr -> parent -> off <= pr -> off && pr -> parent -> off + pr -> parent -> size >= pr -> off + pr -> size ) { return blkid_probe_get_buffer ( pr -> parent , pr -> off + off - pr -> parent -> off , len ) ; } bf = get_cached_buffer ( pr , off , len ) ; if ( ! bf ) { bf = read_buffer ( pr , real_off , len ) ; if ( ! bf ) return NULL ; list_add_tail ( & bf -> bufs , & pr -> buffers ) ; } assert ( bf -> off <= real_off ) ; assert ( bf -> off + bf -> len >= real_off + len ) ; errno = 0 ; return real_off ? bf -> data + ( real_off - bf -> off ) : bf -> data ; }
Note that @off is offset within probing area, the probing area is defined by
 pr->off and pr->size.
Note that @off is offset within probing area the probing area is defined by pr - > off and pr - > size .
/*
    DBG(BUFFER, ul_debug("\t>>>> off=%ju, real-off=%ju (probe <%ju..%ju>,
    len=%ju", off, real_off, pr->off, pr->off + pr->size, len));
    */ /*
         * This is a cloned prober and points to the same area as
         * parent. Let's use parent's buffers.
         *
         * Note that pr->off (and pr->parent->off) is always from the
         * begin of the device.
         */ /* try buffers we already have in memory or read from device */