Ticket #126 (assigned enhancement)
First results from using IsoStream for content reading
| Reported by: | scdbackup | Owned by: | vreixo |
|---|---|---|---|
| Priority: | minor | Milestone: | |
| Component: | libisofs | Version: | libisofs-0.6.3 |
| Keywords: | Cc: |
Description
I made use of the IsoStream? interface for data content reading. All in all it was able to fulfill my needs up to now. A first use case is the new xorriso option
-compare disk_path iso_rr_path
which mainly serves as test for correctness of reading. Comparison will have its more valuable use cases together with runs on complete subtrees.
But some pitfalls appeared.
1) iso_stream_read() returns failure if one requests a maximum buffer count which is larger than the number of remaining bytes in the IsoStream?. This drops any data which would be still available. I assume this is a consequence of the buffering loop which tries to do several reads to get the buffer full.
I would assume that this additional code in ifs_read() could provide a simple solution:
}
+ if(count > data->info.st_size - data->data.offset)
+ count = data->info.st_size - data->data.offset;
+ if (count <= 0)
+ return 0;
while (read < count && data->data.offset < data->info.st_size) {
If it is not possible to return the available number of bytes and delay the EOF return up to the next call of iso_stream_read(), then this behavior needs to be documented in the API. One can inquire the size before reading.
2) My xorriso adapter to data reading seems to become a parallel implementation of what is done at image generation time. I want to see the same content as is written into the new file object during a modificating run from old to new image. Regardless whether it comes from old image or from filesystem.
The problem becomes obvious by the fact that i need to explore or guess what libisofs will do in case of file size change between adding the image node and data reading. The same with read errors of any kind.
It would be helpful if libisofs would offer a level of data reading which is guaranteed to deliver the same byte string as would be copied during image generation. (If image generation would happen right now.)
It would nevertheless suffice if the exact behavior of image generation reading is published in the API description of iso_stream_read().
3) There is a grammatical typo widespread in libisofs. Past tense of "to open" is "opened", not "openned". This includes also ISO_FILE_NOT_OPENNED.
