Functions for extracting index metadata

You should add comment about that fact, that we really care about offset, about small size, about fact, that if offset+size is more than data size, but offset itself is less that size, its ok, and minimal value among data size - offset and requested size will be returned