?? cdrecord.c
字號:
break; } if ((*dp->cdr_next_wr_address)(trackno, &track[i], &startsec) < 0) { errs++; break; } track[i].trackstart = startsec; if (debug || lverbose) printf("Starting new track at sector: %ld\n", startsec); if (write_track_data(dp, trackno, &track[i]) < 0) { errs++; sleep(5); request_sense(); (*dp->cdr_close_track)(trackno, &track[i]); break; } if ((*dp->cdr_close_track)(trackno, &track[i]) < 0) { /* * Check for "Dummy blocks added" message first. */ if (scsi_sense_key() != SC_ILLEGAL_REQUEST || scsi_sense_code() != 0xB5) { errs++; break; } } }fix_it: if (gettimeofday(&stoptime, (struct timezone *)0) < 0) errmsg("Cannot get stop time\n"); if (lverbose) prtimediff("Writing time: ", &starttime, &stoptime); if ((flags & F_NOFIX) == 0) { if (lverbose) { printf("Fixating...\n"); flush(); } if ((*dp->cdr_fixate)(flags & F_MULTI, flags & F_DUMMY, toctype, tracks, track) < 0) errs++; if (gettimeofday(&fixtime, (struct timezone *)0) < 0) errmsg("Cannot get fix time\n"); if (lverbose) prtimediff("Fixating time: ", &stoptime, &fixtime); } if (old_secsize > 0) { /* * Try to restore the old sector size. */ silent++; select_secsize(old_secsize); silent--; } unload_media(dp, flags);#ifdef FIFO if (tracks > 0 && fs > 0L) { kill_faio(); wait(0); if (debug || lverbose) fifo_stats(); }#endif exit(errs?-2:0); return (0);}LOCAL void usage(excode) int excode;{ errmsgno(EX_BAD, "Usage: %s [options] track1...trackn\n", get_progname()); error("Options:\n"); error("\t-version print version information and exit\n"); error("\t-v increment general verbose level by one\n"); error("\t-V increment SCSI command transport verbose level by one\n"); error("\t-debug print additional debug messages\n"); error("\tdev=target SCSI target to use as CD/DVD-Recorder\n"); error("\ttimeout=# set the default SCSI command timeout to #.\n"); error("\tdriver=name user supplied driver name, use with extreme care\n"); error("\t-checkdrive check if a driver for the drive is present\n"); error("\t-prcap print drive capabilities for MMC compliant drives\n"); error("\t-inq do an inquiry for the drive end exit\n"); error("\t-scanbus scan the SCSI bus end exit\n"); error("\t-reset reset the SCSI bus with the cdrecorder (if possible)\n"); error("\t-ignsize ignore the known size of a medium (may cause problems)\n"); error("\tspeed=# set speed of drive\n"); error("\tblank=type blank a CD-RW disc (see blank=help)\n");#ifdef FIFO error("\tfs=# Set fifo size to # (0 to disable, default is %ld MB)\n", DEFAULT_FIFOSIZE/(1024*1024));#endif error("\t-load load the disk and exit (works only with tray loader)\n"); error("\t-eject eject the disk after doing the work\n"); error("\t-dummy do everything with laser turned off\n"); error("\t-msinfo retrieve multi-session info for mkisofs >= 1.10\n"); error("\t-toc retrieve and print TOC/PMA data\n"); error("\t-multi generate a TOC that allows multi session\n"); error("\t In this case default track type is CD-ROM XA2\n"); error("\t-fix fixate a corrupt or unfixated disk (generate a TOC)\n"); error("\t-nofix do not fixate disk after writing tracks\n"); error("\ttsize=# Length of valid data in next track\n"); error("\tpadsize=# Amount of padding for next track\n"); error("\tpregap=# Amount of pre-gap sectors before next track\n"); error("\tdefpregap=# Amount of pre-gap sectors for all but track #1\n"); error("\t-audio Subsequent tracks are CD-DA audio tracks\n"); error("\t-data Subsequent tracks are CD-ROM data mode 1 (default)\n"); error("\t-mode2 Subsequent tracks are CD-ROM data mode 2\n"); error("\t-xa1 Subsequent tracks are CD-ROM XA mode 1\n"); error("\t-xa2 Subsequent tracks are CD-ROM XA mode 2\n"); error("\t-cdi Subsequent tracks are CDI tracks\n"); error("\t-isosize Use iso9660 file system size for next data track\n"); error("\t-preemp Audio tracks are mastered with 50/15 祍 preemphasis\n"); error("\t-nopreemp Audio tracks are mastered with no preemphasis (default)\n"); error("\t-pad Pad data tracks with %d zeroed sectors\n", PAD_SECS); error("\t Pad audio tracks to a multiple of %d bytes\n", AUDIO_SEC_SIZE); error("\t-nopad Do not pad data tracks (default)\n"); error("\t-swab Audio data source is byte-swapped (little-endian/Intel)\n"); error("The type of the first track is used for the toc type.\n"); error("Currently only form 1 tracks are supported.\n"); exit(excode);}LOCAL voidblusage(ret) int ret;{ error("Blanking options:\n"); error("\tall\t\tblank the entire disk\n"); error("\tdisc\t\tblank the entire disk\n"); error("\tdisk\t\tblank the entire disk\n"); error("\tfast\t\tminimally blank the entire disk (PMA, TOC, pregap)\n"); error("\tminimal\t\tminimally blank the entire disk (PMA, TOC, pregap)\n"); error("\ttrack\t\tblank a track\n"); error("\tunreserve\tunreserve a track\n"); error("\ttrtail\t\tblank a track tail\n"); error("\tunclose\t\tunclose last session\n"); error("\tsession\t\tblank last session\n"); exit(ret); /* NOTREACHED */}EXPORT intread_buf(f, bp, size) int f; char *bp; int size;{ char *p = bp; int amount = 0; int n; do { do { n = read(f, p, size-amount); } while (n < 0 && (errno == EAGAIN || errno == EINTR)); if (n < 0) return (n); amount += n; p += n; } while (amount < size && n > 0); return (amount);}EXPORT intget_buf(f, bpp, size) int f; char **bpp; int size;{ if (fs > 0) {/* return (faio_read_buf(f, *bpp, size));*/ return (faio_get_buf(f, bpp, size)); } else { return (read_buf(f, *bpp, size)); }}LOCAL intwrite_track_data(dp, track, trackp) cdr_t *dp; int track; track_t *trackp;{ int f; int isaudio; long startsec; long bytes_read = 0; long bytes = 0; long savbytes = 0; int count; long tracksize; int secsize; int secspt; int bytespt; int bytes_to_read; long amount; int pad; int bswab; BOOL neednl = FALSE; BOOL islast = FALSE; char *bp = buf; if (is_packet(trackp)) /* XXX Ugly hack for now */ return (write_packet_data(dp, track, trackp)); f = trackp->f; isaudio = is_audio(trackp); tracksize = trackp->tracksize; startsec = trackp->trackstart; secsize = trackp->secsize; secspt = trackp->secspt; bytespt = secsize * secspt; pad = !isaudio && is_pad(trackp); /* Pad only data tracks */ bswab = isaudio && is_swab(trackp); /* Swab only audio tracks */ if (debug) { printf("secsize:%d secspt:%d bytespt:%d audio:%d pad:%d\n", secsize, secspt, bytespt, isaudio, pad); } if (lverbose) { if (tracksize > 0) printf("Track %02d: 0 of %3ld MB written.\r", track, tracksize >> 20); else printf("Track %02d: 0 MB written.\r", track); flush(); neednl = TRUE; } do { bytes_to_read = bytespt; if (tracksize > 0) { bytes_to_read = tracksize - bytes_read; if (bytes_to_read > bytespt) bytes_to_read = bytespt; } count = get_buf(f, &bp, bytes_to_read); if (count < 0) comerr("read error on input file\n"); if (count == 0) break; bytes_read += count; if (tracksize >= 0 && bytes_read >= tracksize) { count -= bytes_read - tracksize; if (trackp->padsize == 0 && (bytes_read/secsize) >= 300) islast = TRUE; } if (bswab) swabbytes(bp, count); if (count < bytespt) { if (debug) { printf("\nNOTICE: reducing block size for last record.\n"); neednl = FALSE; } if ((amount = count % secsize) != 0) { amount = secsize - amount; fillbytes(&bp[count], amount, '\0'); count += amount; printf("\nWARNING: padding up to secsize.\n"); neednl = FALSE; } bytespt = count; secspt = count / secsize; if (trackp->padsize == 0 && (bytes_read/secsize) >= 300) islast = TRUE; } amount = (*dp->cdr_write_trackdata)(bp, startsec, bytespt, secspt, islast); if (amount < 0) { printf("%swrite track data: error after %ld bytes\n", neednl?"\n":"", bytes); return (-1); } bytes += amount; startsec += amount / secsize; if (lverbose && (bytes >= (savbytes + 0x100000))) { int fper; printf("Track %02d: %3ld", track, bytes >> 20); if (tracksize > 0) printf(" of %3ld MB", tracksize >> 20); else printf(" MB"); printf(" written"); fper = fifo_percent(TRUE); if (fper >= 0) printf(" (fifo %3d%%)", fper); printf(".\r"); savbytes = (bytes >> 20) << 20; flush(); neednl = TRUE; } } while (tracksize < 0 || bytes_read < tracksize); if ((bytes / secsize) < 300) { amount = roundup(trackp->padsize, secsize); if (((bytes+amount) / secsize) < 300) trackp->padsize = 300 * secsize - bytes; } if (trackp->padsize) { if ((trackp->padsize >> 20) > 0) { if (neednl) printf("\n"); neednl = TRUE; } else if (lverbose) { printf("Track %02d: writing %3ld KB of pad data.\n", track, trackp->padsize >> 10); neednl = FALSE; } pad_track(dp, track, trackp, startsec, trackp->padsize, TRUE, &amount); bytes += amount; startsec += amount / secsize; } printf("%sTrack %02d: Total bytes read/written: %ld/%ld (%ld sectors).\n", neednl?"\n":"", track, bytes_read, bytes, bytes/secsize); return 0;}EXPORT intpad_track(dp, track, trackp, startsec, amt, dolast, bytesp) cdr_t *dp; int track; track_t *trackp; long startsec; long amt; BOOL dolast; long *bytesp;{ long bytes = 0; long savbytes = 0; int secsize; int secspt; int bytespt; int amount; BOOL neednl = FALSE; BOOL islast = FALSE; secsize = trackp->secsize; secspt = trackp->secspt; bytespt = secsize * secspt; fillbytes(buf, bytespt, '\0'); if ((amt >> 20) > 0) { printf("Track %02d: 0 of %3ld MB pad written.\r", track, amt >> 20); flush(); } do { if (amt < bytespt) { bytespt = roundup(amt, secsize); secspt = bytespt / secsize; } if (dolast && (amt - bytespt) <= 0) islast = TRUE; amount = (*dp->cdr_write_trackdata)(buf, startsec, bytespt, secspt, islast); if (amount < 0) { printf("%swrite track data: error after %ld bytes\n", neednl?"\n":"", bytes); if (bytesp) *bytesp = bytes; return (-1); } amt -= amount; bytes += amount; startsec += amount / secsize; if (lverbose && (bytes >= (savbytes + 0x100000))) { printf("Track %02d: %3ld\r", track, bytes >> 20); savbytes = (bytes >> 20) << 20; flush(); neednl = TRUE; } } while (amt > 0); if (bytesp) *bytesp = bytes; return (bytes);}LOCAL voidprintdata(track, trackp) int track; track_t *trackp;{ if (trackp->tracksize >= 0) { printf("Track %02d: data %3ld MB ", track, trackp->tracksize >> 20); } else { printf("Track %02d: data unknown length", track); } if (trackp->padsize > 0) { if ((trackp->padsize >> 20) > 0) printf(" padsize: %3ld MB", trackp->padsize >> 20); else printf(" padsize: %3ld KB", trackp->padsize >> 10); } if (trackp->pregapsize != 150) { printf(" pregapsize: %3ld", trackp->pregapsize); } printf("\n");}LOCAL voidprintaudio(track, trackp) int track; track_t *trackp;{ if (trackp->tracksize >= 0) { printf("Track %02d: audio %3ld MB (%02d:%02d.%02d) %spreemp%s%s", track, trackp->tracksize >> 20, minutes(trackp->tracksize), seconds(trackp->tracksize), hseconds(trackp->tracksize), is_preemp(trackp) ? "" : "no ", is_swab(trackp) ? " swab":"", ((trackp->tracksize < 300L*trackp->secsize) || (trackp->tracksize % trackp->secsize)) && is_pad(trackp) ? " pad" : ""); } else { printf("Track %02d: audio unknown length %spreemp%s%s", track, is_preemp(trackp) ? "" : "no ", is_swab(trackp) ? " swab":"", (trackp->tracksize % trackp->secsize) && is_pad(trackp) ? " pad" : ""); } if (trackp->padsize > 0) { if ((trackp->padsize >> 20) > 0) printf(" padsize: %3ld MB", trackp->padsize >> 20); else printf(" padsize: %3ld KB", trackp->padsize >> 10); printf(" (%02d:%02d.%02d)", minutes(trackp->padsize), seconds(trackp->padsize), hseconds(trackp->padsize)); } if (trackp->pregapsize != 150) { printf(" pregapsize: %3ld", trackp->pregapsize); } printf("\n");}LOCAL voidcheckfile(track, trackp) int track; track_t *trackp;{ if (trackp->tracksize > 0 && is_audio(trackp) && ((trackp->tracksize < 300L*trackp->secsize) || (trackp->tracksize % trackp->secsize)) && !is_pad(trackp)) { errmsgno(EX_BAD, "Bad audio track size %ld for track %02d.\n", trackp->tracksize, track); comerrno(EX_BAD, "Audio tracks must be at least %ld bytes and a multiple of %d.\n", 300L*trackp->secsize, trackp->secsize); } if (!lverbose) return; if (is_audio(trackp)) printaudio(track, trackp); else printdata(track, trackp);}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -