67 #include "../libburn/libburn.h"
72 #include <sys/types.h>
127 if(drive_adr != NULL && drive_adr[0] != 0)
131 if (ret <= 0 || *driveno <= 0)
151 if (strncmp(drive_adr,
"stdio:/dev/fd/", 14) == 0 ||
152 strcmp(drive_adr,
"stdio:-") == 0) {
153 fprintf(stderr,
"Will not work with pseudo-drive '%s'\n",
161 fprintf(stderr,
"Address does not lead to a CD burner: '%s'\n",
165 fprintf(stderr,
"Aquiring drive '%s' ...\n", libburn_drive_adr);
168 fprintf(stderr,
"FAILURE with persistent drive address '%s'\n",
171 fprintf(stderr,
"Done\n");
195 printf(
"Beginning to scan for devices ...\n");
198 if (drive_count <= 0 && *driveno >= 0) {
199 printf(
"FAILED (no drives found)\n");
218 printf(
"\nOverview of accessible drives (%d found) :\n",
220 printf(
"-----------------------------------------------------------------------------\n");
223 strcpy(adr,
"-get_adr_failed-");
224 printf(
"%d --drive '%s' : '%s' '%s'\n",
227 printf(
"-----------------------------------------------------------------------------\n\n");
255 printf(
"Pseudo-drive \"-\" given : bus scanning done.\n");
260 "Found only %d drives. Number %d not available.\n",
271 fprintf(stderr,
"Cannot drop drive %d. Please report \"ret=%d\" to libburn-hackers@pykix.org\n",
274 printf(
"Dropped unwanted drive %d\n",i);
297 double percent = 1.0;
301 "Drive media status: %d (see libburn/libburn.h BURN_DISC_*)\n",
307 "IDLE: Blank media detected. Will leave it untouched\n");
313 fprintf(stderr,
"FATAL: No media detected in drive\n");
317 "FATAL: Unsuitable drive and media state\n");
322 "FATAL : Media is not of erasable type\n");
328 printf(
"Beginning to %s-blank media.\n", (blank_fast?
"fast":
"full"));
334 percent = 1.0 + ((double) p.
sector+1.0)
336 printf(
"Blanking ( %.1f%% done )\n", percent);
363 double percent = 1.0;
364 int ret, status, num_formats, format_flag= 0;
370 fprintf(stderr,
"IDLE: DVD-RW media is already formatted\n");
376 "FATAL: BD-R is not blank. Cannot format.\n");
383 "IDLE: BD media is already formatted\n");
389 size = 128 * 1024 * 1024;
392 fprintf(stderr,
"FATAL: Can only format DVD-RW or BD\n");
397 printf(
"Beginning to format media.\n");
403 percent = 1.0 + ((double) p.
sector+1.0)
405 printf(
"Formatting ( %.1f%% done )\n", percent);
414 printf(
"Media type now: %4.4xh \"%s\"\n",
418 "FATAL: Failed to change media profile to desired value\n");
445 struct burn_disc *target_disc;
446 struct burn_session *session;
447 struct burn_write_opts *burn_options;
449 struct burn_track *track, *tracklist[99];
452 int last_sector = 0, padding = 0, trackno, unpredicted_size = 0, fd;
453 int fifo_chunksize = 2352, fifo_chunks = 1783;
462 fifo_chunksize = 2048;
475 adr = source_adr[trackno];
477 if (adr[0] ==
'-' && adr[1] == 0) {
480 fd = open(adr, O_RDONLY);
482 if (fstat(fd,&stbuf)!=-1)
483 if((stbuf.st_mode&S_IFMT)==S_IFREG)
484 fixed_size = stbuf.st_size;
487 unpredicted_size = 1;
493 if (data_src == NULL) {
495 "FATAL: Could not open data source '%s'.\n",adr);
497 fprintf(stderr,
"(Most recent system error: %s )\n",
503 fifo_chunksize, fifo_chunks, 0);
504 if (fifo_src[trackno] == NULL) {
506 "FATAL: Could not create fifo object of 4 MB\n");
514 "FATAL: Cannot attach source object to track object\n");
519 printf(
"Track %d : source is '%s'\n", trackno+1, adr);
531 fprintf(stderr,
"FATAL: Closed media with data detected. Need blank or appendable media.\n");
533 fprintf(stderr,
"HINT: Try --blank_fast\n\n");
535 fprintf(stderr,
"FATAL: No media detected in drive\n");
538 "FATAL: Cannot recognize state of drive and media\n");
546 printf(
"\n*** Will TRY to SIMULATE burning ***\n\n");
552 fprintf(stderr,
"FATAL: Failed to find a suitable write mode with this media.\n");
553 fprintf(stderr,
"Reasons given:\n%s\n", reasons);
558 printf(
"Burning starts. With e.g. 4x media expect up to a minute of zero progress.\n");
559 start_time = time(0);
568 !unpredicted_size) ||
569 (unpredicted_size && progress.
sector == last_sector))
571 "Thank you for being patient since %d seconds.",
572 (
int) (time(0) - start_time));
573 else if(unpredicted_size)
574 printf(
"Track %d : sector %d", progress.
track+1,
577 printf(
"Track %d : sector %d of %d",progress.
track+1,
579 last_sector = progress.
sector;
580 if (progress.
track >= 0 && progress.
track < source_adr_count) {
581 int size, free_bytes, ret;
585 fifo_src[progress.
track], &size, &free_bytes,
588 printf(
" [fifo %s, %2d%% fill]", status_text,
589 (
int) (100.0 - 100.0 *
590 ((
double) free_bytes) /
609 printf(
"NOTE: Media left appendable.\n");
611 printf(
"\n*** Did TRY to SIMULATE burning ***\n\n");
631 int i, insuffient_parameters = 0, print_help = 0;
633 for (i = 1; i < argc; ++i) {
634 if (!strcmp(argv[i],
"--audio")) {
637 }
else if (!strcmp(argv[i],
"--blank_fast")) {
640 }
else if (!strcmp(argv[i],
"--blank_full")) {
643 }
else if (!strcmp(argv[i],
"--burn_for_real")) {
646 }
else if (!strcmp(argv[i],
"--drive")) {
649 fprintf(stderr,
"--drive requires an argument\n");
651 }
else if (strcmp(argv[i],
"-") == 0) {
654 }
else if (isdigit(argv[i][0])) {
659 fprintf(stderr,
"--drive address too long (max. %d)\n",
665 }
else if ((!strcmp(argv[i],
"--format_overwrite")) ||
666 (!strcmp(argv[i],
"--format"))) {
669 }
else if (!strcmp(argv[i],
"--multi")) {
672 }
else if (!strcmp(argv[i],
"--stdin_size")) {
675 }
else if (!strcmp(argv[i],
"--try_to_simulate")) {
678 }
else if (!strcmp(argv[i],
"--help")) {
681 }
else if (!strncmp(argv[i],
"--",2)) {
682 fprintf(stderr,
"Unidentified option: %s\n", argv[i]);
685 if(strlen(argv[i]) >= 4096) {
686 fprintf(stderr,
"Source address too long (max. %d)\n", 4096-1);
690 fprintf(stderr,
"Too many tracks (max. 99)\n");
697 insuffient_parameters = 1;
699 insuffient_parameters = 0;
701 insuffient_parameters = 0;
703 insuffient_parameters = 0;
704 if (print_help || insuffient_parameters ) {
705 printf(
"Usage: %s\n", argv[0]);
706 printf(
" [--drive <address>|<driveno>|\"-\"] [--audio]\n");
707 printf(
" [--blank_fast|--blank_full|--format] [--try_to_simulate]\n");
708 printf(
" [--multi] [<one or more imagefiles>|\"-\"]\n");
709 printf(
"Examples\n");
710 printf(
"A bus scan (needs rw-permissions to see a drive):\n");
711 printf(
" %s --drive -\n",argv[0]);
712 printf(
"Burn a file to drive chosen by number, leave appendable:\n");
713 printf(
" %s --drive 0 --multi my_image_file\n", argv[0]);
714 printf(
"Burn a file to drive chosen by persistent address, close:\n");
715 printf(
" %s --drive /dev/hdc my_image_file\n", argv[0]);
716 printf(
"Blank a used CD-RW (is combinable with burning in one run):\n");
717 printf(
" %s --drive /dev/hdc --blank_fast\n",argv[0]);
718 printf(
"Blank a used DVD-RW (is combinable with burning in one run):\n");
719 printf(
" %s --drive /dev/hdc --blank_full\n",argv[0]);
720 printf(
"Format a DVD-RW, BD-RE or BD-R:\n");
721 printf(
" %s --drive /dev/hdc --format\n", argv[0]);
722 printf(
"Burn two audio tracks (to CD only):\n");
723 printf(
" lame --decode -t /path/to/track1.mp3 track1.cd\n");
724 printf(
" test/dewav /path/to/track2.wav -o track2.cd\n");
725 printf(
" %s --drive /dev/hdc --audio track1.cd track2.cd\n", argv[0]);
726 printf(
"Burn a compressed afio archive on-the-fly:\n");
727 printf(
" ( cd my_directory ; find . -print | afio -oZ - ) | \\\n");
728 printf(
" %s --drive /dev/hdc -\n", argv[0]);
729 printf(
"To be read from *not mounted* media via: afio -tvZ /dev/hdc\n");
730 if (insuffient_parameters)
737 int main(
int argc,
char **argv)
742 if (
sizeof(off_t) != 8) {
744 "\nFATAL: Compile time misconfiguration. off_t is not 64 bit.\n\n");
752 printf(
"Initializing libburnia-project.org ...\n");
757 fprintf(stderr,
"\nFATAL: Failed to initialize.\n");
771 fprintf(stderr,
"\nFATAL: Failed to aquire drive.\n");
772 { ret = 34;
goto finish_libburn; }
775 { ret = 0;
goto release_drive; }
783 { ret = 36;
goto release_drive; }
790 { ret = 38;
goto release_drive; }
800 fprintf(stderr,
"\nlibburner run aborted\n");