mirror of
https://github.com/aaru-dps/aaruremote.git
synced 2025-12-16 19:24:37 +00:00
Implement OS read command for Linux.
This commit is contained in:
@@ -343,4 +343,24 @@ int32_t ReOpen(void* device_ctx, uint32_t* closeFailed)
|
||||
if((ctx->fd < 0) && (errno == EACCES || errno == EROFS)) ctx->fd = open(ctx->device_path, O_RDONLY | O_NONBLOCK);
|
||||
|
||||
return ctx->fd <= 0 ? errno : 0;
|
||||
}
|
||||
|
||||
int32_t OsRead(void* device_ctx, char* buffer, uint64_t offset, uint32_t length, uint32_t* duration)
|
||||
{
|
||||
DeviceContext* ctx = device_ctx;
|
||||
ssize_t ret;
|
||||
*duration = 0;
|
||||
off_t pos;
|
||||
|
||||
if(!ctx) return -1;
|
||||
|
||||
// TODO: Timing
|
||||
pos = lseek(ctx->fd, (off_t)offset, SEEK_SET);
|
||||
|
||||
if(pos < 0) return errno;
|
||||
|
||||
// TODO: Timing
|
||||
ret = read(ctx->fd, (void*)buffer, (size_t)length);
|
||||
|
||||
return ret < 0 ? errno : 0;
|
||||
}
|
||||
Reference in New Issue
Block a user