version 1.16, 2015/08/20 22:32:41 |
version 1.17, 2017/12/23 20:04:23 |
|
|
#include <sys/ioctl.h> |
#include <sys/ioctl.h> |
#include <sys/scsiio.h> |
#include <sys/scsiio.h> |
#include <sys/stat.h> |
#include <sys/stat.h> |
|
#include <sys/time.h> |
|
|
#include <scsi/scsi_all.h> |
#include <scsi/scsi_all.h> |
#include <scsi/scsi_disk.h> |
#include <scsi/scsi_disk.h> |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
#include <time.h> |
#include <unistd.h> |
#include <unistd.h> |
|
|
#include "extern.h" |
#include "extern.h" |
|
|
int |
int |
read_track(struct track *ti) |
read_track(struct track *ti) |
{ |
{ |
struct timeval tv, otv, atv; |
struct timespec ts, ots, ats; |
u_int32_t i, blksize, n_sec; |
u_int32_t i, blksize, n_sec; |
u_char *sec; |
u_char *sec; |
int error; |
int error; |
|
|
if (sec == NULL) |
if (sec == NULL) |
return (-1); |
return (-1); |
|
|
timerclear(&otv); |
timespecclear(&ots); |
atv.tv_sec = 1; |
ats.tv_sec = 1; |
atv.tv_usec = 0; |
ats.tv_nsec = 0; |
|
|
for (i = 0; i < n_sec; ) { |
for (i = 0; i < n_sec; ) { |
gettimeofday(&tv, NULL); |
clock_gettime(CLOCK_MONOTONIC, &ts); |
if (timercmp(&tv, &otv, >)) { |
if (timespeccmp(&ts, &ots, >)) { |
fprintf(stderr, "\rtrack %u '%c' %08u/%08u %3u%%", |
fprintf(stderr, "\rtrack %u '%c' %08u/%08u %3u%%", |
ti->track, |
ti->track, |
(ti->isaudio) ? 'a' : 'd', i, n_sec, |
(ti->isaudio) ? 'a' : 'd', i, n_sec, |
100 * i / n_sec); |
100 * i / n_sec); |
timeradd(&tv, &atv, &otv); |
timespecadd(&ts, &ats, &ots); |
} |
} |
|
|
error = read_data_sector(i + ti->start_lba, sec, blksize); |
error = read_data_sector(i + ti->start_lba, sec, blksize); |