EMILE/libscsi/scsi_read_sector.c
Laurent Vivier 9bd9755dbb Update email address
Signed-off-by: Laurent Vivier <Laurent@Vivier.EU>
2013-09-05 14:45:27 +02:00

31 lines
549 B
C

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