2005-11-17 06:44:44 +00:00
|
|
|
/*
|
|
|
|
*
|
2013-09-05 12:39:22 +00:00
|
|
|
* (c) 2004, 2005 Laurent Vivier <Laurent@Vivier.EU>
|
2005-11-17 06:44:44 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <macos/devices.h>
|
|
|
|
|
|
|
|
#include "libscsi.h"
|
|
|
|
|
2005-11-21 21:56:13 +00:00
|
|
|
#define ISO_BLOCKS(X) (((X) / device->sector_size) + (((X)%device->sector_size)?1:0))
|
2005-11-17 06:44:44 +00:00
|
|
|
|
|
|
|
/* offset is a block number
|
|
|
|
* size is the number of bytes to read
|
|
|
|
*/
|
|
|
|
|
2005-11-21 21:56:13 +00:00
|
|
|
int scsi_read_sector(scsi_device_t *device,
|
|
|
|
off_t offset, void* buffer, size_t size)
|
2005-11-17 06:44:44 +00:00
|
|
|
{
|
|
|
|
OSErr err;
|
|
|
|
|
2005-11-21 21:56:13 +00:00
|
|
|
err = scsi_READ(device->target, offset, ISO_BLOCKS(size), buffer, size);
|
2005-11-17 06:44:44 +00:00
|
|
|
if (err != noErr)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|