fsw_status_t fsw_efi_read_block(struct fsw_volume *vol, fsw_u32 phys_bno, void *buffer) { EFI_STATUS Status; FSW_VOLUME_DATA *Volume = (FSW_VOLUME_DATA *)vol->host_data; FSW_MSG_DEBUGV((FSW_MSGSTR("fsw_efi_read_block: %d (%d)\n"), phys_bno, vol->phys_blocksize)); // read from disk Status = Volume->DiskIo->ReadDisk(Volume->DiskIo, Volume->MediaId, (UINT64)phys_bno * vol->phys_blocksize, vol->phys_blocksize, buffer); Volume->LastIOStatus = Status; if (EFI_ERROR(Status)) return FSW_IO_ERROR; return FSW_SUCCESS; }
fsw_status_t fsw_posix_read_block(struct fsw_volume *vol, fsw_u32 phys_bno, void *buffer) { struct fsw_posix_volume *pvol = (struct fsw_posix_volume *)vol->host_data; off_t block_offset, seek_result; ssize_t read_result; FSW_MSG_DEBUGV((FSW_MSGSTR("fsw_posix_read_block: %d (%d)\n"), phys_bno, vol->phys_blocksize)); // read from disk block_offset = (off_t)phys_bno * vol->phys_blocksize; seek_result = lseek(pvol->fd, block_offset, SEEK_SET); if (seek_result != block_offset) return FSW_IO_ERROR; read_result = read(pvol->fd, buffer, vol->phys_blocksize); if (read_result != vol->phys_blocksize) return FSW_IO_ERROR; return FSW_SUCCESS; }