diff --git a/freebsd/scsi.c b/freebsd/scsi.c index 1ae91d6..a2118b4 100644 --- a/freebsd/scsi.c +++ b/freebsd/scsi.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "../aaruremote.h" #include "freebsd.h" @@ -43,6 +44,10 @@ int32_t SendScsiCommand(void* device_ctx, union ccb* camccb; u_int32_t flags; int error; + int clock_error; + struct timespec start_tp; + struct timespec end_tp; + double start, end; switch(direction) { @@ -93,9 +98,23 @@ int32_t SendScsiCommand(void* device_ctx, camccb->ccb_h.flags |= CAM_DEV_QFRZDIS; - // TODO: Measure duration + clock_error = clock_gettime(CLOCK_REALTIME_PRECISE, &start_tp); + error = cam_send_ccb(ctx->device, camccb); + if(!clock_error) + clock_error = clock_gettime(CLOCK_REALTIME_PRECISE, &end_tp); + + if(!clock_error) + { + start = (double)start_tp.tv_sec * 1000.0; + start += (double)start_tp.tv_nsec / 1000000.0; + end = (double)end_tp.tv_sec * 1000.0; + end += (double)end_tp.tv_nsec / 1000000.0; + + *duration = (uint32_t)(end-start); + } + if(error < 0) error = errno;