version 1.30, 2015/01/16 06:40:06 |
version 1.31, 2017/12/23 20:04:23 |
|
|
*/ |
*/ |
|
|
#include <sys/limits.h> |
#include <sys/limits.h> |
|
#include <sys/time.h> |
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/scsiio.h> |
#include <sys/scsiio.h> |
#include <sys/param.h> /* setbit, isset */ |
#include <sys/param.h> /* setbit, isset */ |
|
|
#include <fcntl.h> |
#include <fcntl.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <string.h> |
#include <string.h> |
|
#include <time.h> |
#include <unistd.h> |
#include <unistd.h> |
#include "extern.h" |
#include "extern.h" |
|
|
|
|
int |
int |
writetrack(struct track_info *tr, int track) |
writetrack(struct track_info *tr, int track) |
{ |
{ |
struct timeval tv, otv, atv; |
struct timespec ts, ots, ats; |
u_char databuf[65536], nblk; |
u_char databuf[65536], nblk; |
u_int end_lba, lba, tmp; |
u_int end_lba, lba, tmp; |
scsireq_t scr; |
scsireq_t scr; |
|
|
scr.senselen = SENSEBUFLEN; |
scr.senselen = SENSEBUFLEN; |
scr.flags = SCCMD_ESCAPE|SCCMD_WRITE; |
scr.flags = SCCMD_ESCAPE|SCCMD_WRITE; |
|
|
timerclear(&otv); |
timespecclear(&ots); |
atv.tv_sec = 1; |
ats.tv_sec = 1; |
atv.tv_usec = 0; |
ats.tv_nsec = 0; |
|
|
if (get_nwa(&lba) != SCCMD_OK) { |
if (get_nwa(&lba) != SCCMD_OK) { |
warnx("cannot get next writable address"); |
warnx("cannot get next writable address"); |
|
|
} |
} |
lba += nblk; |
lba += nblk; |
|
|
gettimeofday(&tv, NULL); |
clock_gettime(CLOCK_MONOTONIC, &ts); |
if (lba == end_lba || timercmp(&tv, &otv, >)) { |
if (lba == end_lba || timespeccmp(&ts, &ots, >)) { |
fprintf(stderr, |
fprintf(stderr, |
"\rtrack %02d '%c' %08u/%08u %3d%%", |
"\rtrack %02d '%c' %08u/%08u %3d%%", |
track, tr->type, |
track, tr->type, |
lba, end_lba, 100 * lba / end_lba); |
lba, end_lba, 100 * lba / end_lba); |
timeradd(&tv, &atv, &otv); |
timespecadd(&ts, &ats, &ots); |
} |
} |
tmp = htobe32(lba); /* update lba in cdb */ |
tmp = htobe32(lba); /* update lba in cdb */ |
memcpy(&scr.cmd[2], &tmp, sizeof(tmp)); |
memcpy(&scr.cmd[2], &tmp, sizeof(tmp)); |