@@ -623,13 +623,14 @@ u64 iso_file_encrypted::read_at(u64 offset, void* buffer, u64 size)
623623 // ' ' ' '
624624 // | first sec | inner sec(s) | last sec |
625625
626- const u64 max_size = std::min (size, local_extent_remaining (offset));
626+ u64 max_size = std::min (size, local_extent_remaining (offset));
627627
628628 if (max_size == 0 )
629629 {
630630 return 0 ;
631631 }
632632
633+ const u64 total_size = this ->size ();
633634 const u64 archive_first_offset = file_offset (offset);
634635 const u64 archive_last_offset = archive_first_offset + max_size - 1 ;
635636 iso_sector first_sec, last_sec;
@@ -678,10 +679,19 @@ u64 iso_file_encrypted::read_at(u64 offset, void* buffer, u64 size)
678679 {
679680 if (total_read != first_sec.size_aligned )
680681 {
681- iso_log.error (" read_at: %s: Error reading from file (%llu/%llu)" , m_meta.name , total_read, first_sec.size_aligned );
682+ iso_log.error (" read_at: %s: Error reading from file - O: %llu (%llu), S: %llu/%llu/%llu (%llu), TR: %llu" , m_meta.name ,
683+ offset, first_sec.address_aligned , first_sec.size_aligned , max_size, size, total_size, total_read);
684+
682685 return 0 ;
683686 }
684687
688+ // If present, read the remaining chunk of data on next extent
689+ if (size > max_size && (offset + max_size) < total_size)
690+ {
691+ iso_log.warning (" read_at: %s: Extent limit reached reading from file (%llu/%llu)" , m_meta.name , max_size, size);
692+ max_size += read_at (offset + max_size, &reinterpret_cast <u8 *>(buffer)[max_size], size - max_size);
693+ }
694+
685695 return max_size;
686696 }
687697
@@ -739,12 +749,20 @@ u64 iso_file_encrypted::read_at(u64 offset, void* buffer, u64 size)
739749
740750 if (total_read != first_sec.size_aligned + last_sec.size_aligned + (sector_count - 2 ) * ISO_SECTOR_SIZE )
741751 {
742- iso_log.error (" read_at: %s: Error reading from file (%llu/%llu)" , m_meta.name ,
752+ iso_log.error (" read_at: %s: Error reading from file - O: %llu (%llu), S: %llu/%llu/%llu (%llu), TR: %llu/%llu" , m_meta.name ,
753+ offset, first_sec.address_aligned , last_sec.size_aligned , max_size, size, total_size,
743754 total_read, ISO_SECTOR_SIZE + ISO_SECTOR_SIZE + (sector_count - 2 ) * ISO_SECTOR_SIZE );
744755
745756 return 0 ;
746757 }
747758
759+ // If present, read the remaining chunk of data on next extent
760+ if (size > max_size && (offset + max_size) < total_size)
761+ {
762+ iso_log.warning (" read_at: %s: Extent limit reached reading from file (%llu/%llu)" , m_meta.name , max_size, size);
763+ max_size += read_at (offset + max_size, &reinterpret_cast <u8 *>(buffer)[max_size], size - max_size);
764+ }
765+
748766 return max_size;
749767}
750768
@@ -1250,13 +1268,14 @@ u64 iso_file::read(void* buffer, u64 size)
12501268
12511269u64 iso_file::read_at (u64 offset, void * buffer, u64 size)
12521270{
1253- const u64 max_size = std::min (size, local_extent_remaining (offset));
1271+ u64 max_size = std::min (size, local_extent_remaining (offset));
12541272
12551273 if (max_size == 0 )
12561274 {
12571275 return 0 ;
12581276 }
12591277
1278+ const u64 total_size = this ->size ();
12601279 const u64 archive_first_offset = file_offset (offset);
12611280
12621281 // If it's not a raw device
@@ -1266,10 +1285,19 @@ u64 iso_file::read_at(u64 offset, void* buffer, u64 size)
12661285
12671286 if (total_read != max_size)
12681287 {
1269- iso_log.error (" read_at: %s: Error reading from file (%llu/%llu)" , m_meta.name , total_read, max_size);
1288+ iso_log.error (" read_at: %s: Error reading from file - O: %llu (%llu), S: %llu/%llu (%llu), TR: %llu" , m_meta.name ,
1289+ offset, archive_first_offset, max_size, size, total_size, total_read);
1290+
12701291 return 0 ;
12711292 }
12721293
1294+ // If present, read the remaining chunk of data on next extent
1295+ if (size > max_size && (offset + max_size) < total_size)
1296+ {
1297+ iso_log.warning (" read_at: %s: Extent limit reached reading from file (%llu/%llu)" , m_meta.name , max_size, size);
1298+ max_size += read_at (offset + max_size, &reinterpret_cast <u8 *>(buffer)[max_size], size - max_size);
1299+ }
1300+
12731301 return max_size;
12741302 }
12751303
@@ -1320,10 +1348,19 @@ u64 iso_file::read_at(u64 offset, void* buffer, u64 size)
13201348 {
13211349 if (total_read != ISO_SECTOR_SIZE )
13221350 {
1323- iso_log.error (" read_at: %s: Error reading from file (%llu/%llu)" , m_meta.name , total_read, ISO_SECTOR_SIZE );
1351+ iso_log.error (" read_at: %s: Error reading from file - O: %llu (%llu), S: %llu/%llu/%llu (%llu), TR: %llu" , m_meta.name ,
1352+ offset, first_sec.lba_address , ISO_SECTOR_SIZE , max_size, size, total_size, total_read);
1353+
13241354 return 0 ;
13251355 }
13261356
1357+ // If present, read the remaining chunk of data on next extent
1358+ if (size > max_size && (offset + max_size) < total_size)
1359+ {
1360+ iso_log.warning (" read_at: %s: Extent limit reached reading from file (%llu/%llu)" , m_meta.name , max_size, size);
1361+ max_size += read_at (offset + max_size, &reinterpret_cast <u8 *>(buffer)[max_size], size - max_size);
1362+ }
1363+
13271364 return max_size;
13281365 }
13291366
@@ -1357,12 +1394,20 @@ u64 iso_file::read_at(u64 offset, void* buffer, u64 size)
13571394
13581395 if (total_read != ISO_SECTOR_SIZE + ISO_SECTOR_SIZE + (sector_count - 2 ) * ISO_SECTOR_SIZE )
13591396 {
1360- iso_log.error (" read_at: %s: Error reading from file (%llu/%llu)" , m_meta.name ,
1361- total_read, ISO_SECTOR_SIZE + ISO_SECTOR_SIZE + (sector_count - 2 ) * ISO_SECTOR_SIZE );
1397+ iso_log.error (" read_at: %s: Error reading from file - O: %llu (%llu), S: %llu/%llu/%llu (%llu), TR: %llu/%llu" , m_meta.name ,
1398+ offset, first_sec.lba_address , ISO_SECTOR_SIZE , max_size, size, total_size,
1399+ total_read, ISO_SECTOR_SIZE + ISO_SECTOR_SIZE + (sector_count - 2 ) * ISO_SECTOR_SIZE );
13621400
13631401 return 0 ;
13641402 }
13651403
1404+ // If present, read the remaining chunk of data on next extent
1405+ if (size > max_size && (offset + max_size) < total_size)
1406+ {
1407+ iso_log.warning (" read_at: %s: Extent limit reached reading from file (%llu/%llu)" , m_meta.name , max_size, size);
1408+ max_size += read_at (offset + max_size, &reinterpret_cast <u8 *>(buffer)[max_size], size - max_size);
1409+ }
1410+
13661411 return max_size;
13671412}
13681413
0 commit comments