[BACK]Return to mmc.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / cdio

Diff for /src/usr.bin/cdio/mmc.c between version 1.14 and 1.15

version 1.14, 2006/06/27 02:43:18 version 1.15, 2006/08/26 03:48:50
Line 125 
Line 125 
 int  int
 writetao(struct track_head *thp)  writetao(struct track_head *thp)
 {  {
         u_char modebuf[70];          u_char modebuf[70], bdlen;
         struct track_info *tr;          struct track_info *tr;
         u_char bdlen;          int r, track = 0;
         int r;  
   
         if ((r = mode_sense_write(modebuf)) != SCCMD_OK) {          if ((r = mode_sense_write(modebuf)) != SCCMD_OK) {
                 warnx("mode sense failed: %d", r);                  warnx("mode sense failed: %d", r);
Line 139 
Line 138 
         modebuf[2+8+bdlen] |= 0x01; /* change write type to TAO */          modebuf[2+8+bdlen] |= 0x01; /* change write type to TAO */
   
         SLIST_FOREACH(tr, thp, track_list) {          SLIST_FOREACH(tr, thp, track_list) {
                   track++;
                 switch (tr->type) {                  switch (tr->type) {
                 case 'd':                  case 'd':
                         modebuf[3+8+bdlen] = 0x04; /* track mode = data */                          modebuf[3+8+bdlen] = 0x04; /* track mode = data */
Line 157 
Line 157 
                 while (unit_ready() != SCCMD_OK)                  while (unit_ready() != SCCMD_OK)
                         continue;                          continue;
                 if ((r = mode_select_write(modebuf)) != SCCMD_OK) {                  if ((r = mode_select_write(modebuf)) != SCCMD_OK) {
                         warnx("mode select failed: %d",r);                          warnx("mode select failed: %d", r);
                         return (r);                          return (r);
                 }                  }
                 writetrack(tr);                  writetrack(tr, track);
                 synchronize_cache();                  synchronize_cache();
         }          }
         fprintf(stderr,"Closing session.\n");          fprintf(stderr, "Closing session.\n");
         close_session();          close_session();
         return (0);          return (0);
 }  }
   
 int  int
 writetrack(struct track_info *tr)  writetrack(struct track_info *tr, int track)
 {  {
         u_char databuf[65536];          struct timeval tv, otv, atv;
           u_char databuf[65536], nblk;
           u_int end_lba, lba, tmp;
         scsireq_t scr;          scsireq_t scr;
         u_int end_lba, lba;  
         u_int tmp;  
         int r;          int r;
         u_char nblk;  
   
         nblk = 65535/tr->blklen;          nblk = 65535/tr->blklen;
         bzero(&scr, sizeof(scr));          bzero(&scr, sizeof(scr));
Line 190 
Line 189 
         scr.senselen = SENSEBUFLEN;          scr.senselen = SENSEBUFLEN;
         scr.flags = SCCMD_ESCAPE|SCCMD_WRITE;          scr.flags = SCCMD_ESCAPE|SCCMD_WRITE;
   
           timerclear(&otv);
           atv.tv_sec = 1;
           atv.tv_usec = 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");
                 return (-1);                  return (-1);
Line 198 
Line 201 
         memcpy(&scr.cmd[2], &tmp, sizeof(tmp));          memcpy(&scr.cmd[2], &tmp, sizeof(tmp));
   
         if (tr->sz / tr->blklen + 1 > UINT_MAX || tr->sz < tr->blklen) {          if (tr->sz / tr->blklen + 1 > UINT_MAX || tr->sz < tr->blklen) {
                 warnx("file %s has invalid size",tr->file);                  warnx("file %s has invalid size", tr->file);
                 return (-1);                  return (-1);
         }          }
         if (tr->sz % tr->blklen) {          if (tr->sz % tr->blklen) {
Line 220 
Line 223 
 again:  again:
                         r = ioctl(fd, SCIOCCOMMAND, &scr);                          r = ioctl(fd, SCIOCCOMMAND, &scr);
                         if (r != 0) {                          if (r != 0) {
                                 printf("\r");                                  printf("%60s\r", "");
                                 warn("ioctl failed while attempting to write");                                  warn("ioctl failed while attempting to write");
                                 return (-1);                                  return (-1);
                         }                          }
Line 229 
Line 232 
                                 goto again;                                  goto again;
                         }                          }
                         if (scr.retsts != SCCMD_OK) {                          if (scr.retsts != SCCMD_OK) {
                                 printf("\r");                                  printf("%60s\r", "");
                                 warnx("ioctl returned bad status while "                                  warnx("ioctl returned bad status while "
                                     "attempting to write: %d",                                      "attempting to write: %d",
                                     scr.retsts);                                      scr.retsts);
                                 return (r);                                  return (r);
                         }                          }
                         lba += nblk;                          lba += nblk;
                         fprintf(stderr,"\rLBA: %08u/%08u",  
                             lba, end_lba);                          gettimeofday(&tv, NULL);
                           if (lba == end_lba || timercmp(&tv, &otv, >)) {
                                   fprintf(stderr,
                                       "track %02d '%c' %08u/%08u %3d%%\r",
                                       track, tr->type,
                                       lba, end_lba, 100 * lba / end_lba);
                                   timeradd(&tv, &atv, &otv);
                           }
                         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));
                 }                  }
Line 307 
Line 317 
         u_char databuf[28];          u_char databuf[28];
         struct scsi_read_track_info *scb;          struct scsi_read_track_info *scb;
         scsireq_t scr;          scsireq_t scr;
         int r,tmp;          int r, tmp;
   
         bzero(&scr, sizeof(scr));          bzero(&scr, sizeof(scr));
         scb = (struct scsi_read_track_info *)scr.cmd;          scb = (struct scsi_read_track_info *)scr.cmd;
Line 333 
Line 343 
 {  {
         u_char databuf[28];          u_char databuf[28];
         scsireq_t scr;          scsireq_t scr;
         int r,tmp;          int r, tmp;
   
         bzero(&scr, sizeof(scr));          bzero(&scr, sizeof(scr));
         scr.timeout = 4000;          scr.timeout = 4000;

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15