153 if (strncmp(
drive_adr,
"stdio:/dev/fd/", 14) == 0 ||
155 fprintf(stderr,
"Will not work with pseudo-drive '%s'\n",
163 fprintf(stderr,
"Address does not lead to a CD burner: '%s'\n",
167 fprintf(stderr,
"Aquiring drive '%s' ...\n", libburn_drive_adr);
170 fprintf(stderr,
"FAILURE with persistent drive address '%s'\n",
173 fprintf(stderr,
"Done\n");
197 printf(
"Beginning to scan for devices ...\n");
201 printf(
"FAILED (no drives found)\n");
220 printf(
"\nOverview of accessible drives (%d found) :\n",
222 printf(
"-----------------------------------------------------------------------------\n");
225 strcpy(adr,
"-get_adr_failed-");
226 printf(
"%d --drive '%s' : '%s' '%s'\n",
229 printf(
"-----------------------------------------------------------------------------\n\n");
257 printf(
"Pseudo-drive \"-\" given : bus scanning done.\n");
262 "Found only %d drives. Number %d not available.\n",
273 fprintf(stderr,
"Cannot drop drive %d. Please report \"ret=%d\" to libburn-hackers@pykix.org\n",
276 printf(
"Dropped unwanted drive %d\n",i);
299 double percent = 1.0;
303 "Drive media status: %d (see libburn/libburn.h BURN_DISC_*)\n",
309 "IDLE: Blank media detected. Will leave it untouched\n");
315 fprintf(stderr,
"FATAL: No media detected in drive\n");
319 "FATAL: Unsuitable drive and media state\n");
324 "FATAL : Media is not of erasable type\n");
330 printf(
"Beginning to %s-blank media.\n", (blank_fast?
"fast":
"full"));
336 percent = 1.0 + ((double) p.
sector+1.0)
338 printf(
"Blanking ( %.1f%% done )\n", percent);
365 double percent = 1.0;
366 int ret, status, num_formats, format_flag= 0;
372 fprintf(stderr,
"IDLE: DVD-RW media is already formatted\n");
378 "FATAL: BD-R is not blank. Cannot format.\n");
385 "IDLE: BD media is already formatted\n");
391 size = 128 * 1024 * 1024;
394 fprintf(stderr,
"FATAL: Can only format DVD-RW or BD\n");
399 printf(
"Beginning to format media.\n");
405 percent = 1.0 + ((double) p.
sector+1.0)
407 printf(
"Formatting ( %.1f%% done )\n", percent);
416 printf(
"Media type now: %4.4xh \"%s\"\n",
420 "FATAL: Failed to change media profile to desired value\n");
443 struct burn_source *data_src = NULL, *fifo_src[99];
444 struct burn_disc *target_disc = NULL;
445 struct burn_session *session = NULL;
446 struct burn_write_opts *burn_options = NULL;
448 struct burn_track *track, *tracklist[99];
451 int last_sector = 0, padding = 0, trackno, unpredicted_size = 0, fd;
452 int fifo_chunksize = 2352, fifo_chunks = 1783;
459 fifo_src[trackno] = NULL;
460 tracklist[trackno] = NULL;
467 fifo_chunksize = 2048;
482 if (adr[0] ==
'-' && adr[1] == 0) {
485 fd = open(adr, O_RDONLY);
487 if (fstat(fd,&stbuf)!=-1)
488 if((stbuf.st_mode&S_IFMT)==S_IFREG)
489 fixed_size = stbuf.st_size;
492 unpredicted_size = 1;
498 if (data_src == NULL) {
500 "FATAL: Could not open data source '%s'.\n",adr);
502 fprintf(stderr,
"(Most recent system error: %s )\n",
508 fifo_chunksize, fifo_chunks, 0);
509 if (fifo_src[trackno] == NULL) {
511 "FATAL: Could not create fifo object of 4 MB\n");
519 "FATAL: Cannot attach source object to track object\n");
524 printf(
"Track %d : source is '%s'\n", trackno+1, adr);
537 fprintf(stderr,
"FATAL: Closed media with data detected. Need blank or appendable media.\n");
539 fprintf(stderr,
"HINT: Try --blank_fast\n\n");
541 fprintf(stderr,
"FATAL: No media detected in drive\n");
544 "FATAL: Cannot recognize state of drive and media\n");
552 printf(
"\n*** Will TRY to SIMULATE burning ***\n\n");
558 fprintf(stderr,
"FATAL: Failed to find a suitable write mode with this media.\n");
559 fprintf(stderr,
"Reasons given:\n%s\n", reasons);
564 printf(
"Burning starts. With e.g. 4x media expect up to a minute of zero progress.\n");
565 start_time = time(0);
573 !unpredicted_size) ||
574 (unpredicted_size && progress.
sector == last_sector))
576 "Thank you for being patient since %d seconds.",
577 (
int) (time(0) - start_time));
578 else if(unpredicted_size)
579 printf(
"Track %d : sector %d", progress.
track+1,
582 printf(
"Track %d : sector %d of %d",progress.
track+1,
584 last_sector = progress.
sector;
586 int size, free_bytes, ret;
590 fifo_src[progress.
track], &size, &free_bytes,
593 printf(
" [fifo %s, %2d%% fill]", status_text,
594 (
int) (100.0 - 100.0 *
595 ((
double) free_bytes) /
608 printf(
"NOTE: Media left appendable.\n");
610 printf(
"\n*** Did TRY to SIMULATE burning ***\n\n");
614 if (burn_options != NULL)
617 if (fifo_src[trackno] != NULL)
619 if (tracklist[trackno])
622 if (data_src != NULL)
626 if (target_disc != NULL)
647 int i, insuffient_parameters = 0, print_help = 0;
649 for (i = 1; i < argc; ++i) {
650 if (!strcmp(argv[i],
"--audio")) {
653 }
else if (!strcmp(argv[i],
"--blank_fast")) {
656 }
else if (!strcmp(argv[i],
"--blank_full")) {
659 }
else if (!strcmp(argv[i],
"--burn_for_real")) {
662 }
else if (!strcmp(argv[i],
"--drive")) {
665 fprintf(stderr,
"--drive requires an argument\n");
667 }
else if (strcmp(argv[i],
"-") == 0) {
670 }
else if (isdigit(argv[i][0])) {
675 fprintf(stderr,
"--drive address too long (max. %d)\n",
681 }
else if ((!strcmp(argv[i],
"--format_overwrite")) ||
682 (!strcmp(argv[i],
"--format"))) {
685 }
else if (!strcmp(argv[i],
"--multi")) {
688 }
else if (!strcmp(argv[i],
"--stdin_size")) {
691 }
else if (!strcmp(argv[i],
"--try_to_simulate")) {
694 }
else if (!strcmp(argv[i],
"--help")) {
697 }
else if (!strncmp(argv[i],
"--",2)) {
698 fprintf(stderr,
"Unidentified option: %s\n", argv[i]);
701 if(strlen(argv[i]) >= 4096) {
702 fprintf(stderr,
"Source address too long (max. %d)\n", 4096-1);
706 fprintf(stderr,
"Too many tracks (max. 99)\n");
713 insuffient_parameters = 1;
715 insuffient_parameters = 0;
717 insuffient_parameters = 0;
719 insuffient_parameters = 0;
720 if (print_help || insuffient_parameters ) {
721 printf(
"Usage: %s\n", argv[0]);
722 printf(
" [--drive <address>|<driveno>|\"-\"] [--audio]\n");
723 printf(
" [--blank_fast|--blank_full|--format] [--try_to_simulate]\n");
724 printf(
" [--multi] [<one or more imagefiles>|\"-\"]\n");
725 printf(
"Examples\n");
726 printf(
"A bus scan (needs rw-permissions to see a drive):\n");
727 printf(
" %s --drive -\n",argv[0]);
728 printf(
"Burn a file to drive chosen by number, leave appendable:\n");
729 printf(
" %s --drive 0 --multi my_image_file\n", argv[0]);
730 printf(
"Burn a file to drive chosen by persistent address, close:\n");
731 printf(
" %s --drive /dev/hdc my_image_file\n", argv[0]);
732 printf(
"Blank a used CD-RW (is combinable with burning in one run):\n");
733 printf(
" %s --drive /dev/hdc --blank_fast\n",argv[0]);
734 printf(
"Blank a used DVD-RW (is combinable with burning in one run):\n");
735 printf(
" %s --drive /dev/hdc --blank_full\n",argv[0]);
736 printf(
"Format a DVD-RW, BD-RE or BD-R:\n");
737 printf(
" %s --drive /dev/hdc --format\n", argv[0]);
738 printf(
"Burn two audio tracks (to CD only):\n");
739 printf(
" lame --decode -t /path/to/track1.mp3 track1.cd\n");
740 printf(
" test/dewav /path/to/track2.wav -o track2.cd\n");
741 printf(
" %s --drive /dev/hdc --audio track1.cd track2.cd\n", argv[0]);
742 printf(
"Burn a compressed afio archive on-the-fly:\n");
743 printf(
" ( cd my_directory ; find . -print | afio -oZ - ) | \\\n");
744 printf(
" %s --drive /dev/hdc -\n", argv[0]);
745 printf(
"To be read from *not mounted* media via: afio -tvZ /dev/hdc\n");
746 if (insuffient_parameters)
758 if (
sizeof(off_t) != 8) {
760 "\nFATAL: Compile time misconfiguration. off_t is not 64 bit.\n\n");
768 printf(
"Initializing libburnia-project.org ...\n");
773 fprintf(stderr,
"\nFATAL: Failed to initialize.\n");
787 fprintf(stderr,
"\nFATAL: Failed to acquire drive.\n");
788 { ret = 34;
goto finish_libburn; }
791 { ret = 0;
goto release_drive; }
799 { ret = 36;
goto release_drive; }
806 { ret = 38;
goto release_drive; }
816 fprintf(stderr,
"\nlibburner run aborted\n");
int burn_write_opts_set_simulate(struct burn_write_opts *opts, int sim)
Sets the simulate value for the write_opts struct .
void burn_track_free(struct burn_track *t)
Free a track.
#define BURN_REASONS_LEN
The length of a rejection reasons string for burn_precheck_write() and burn_write_opts_auto_write_typ...
void burn_write_opts_free(struct burn_write_opts *opts)
Frees a write_opts struct created with burn_write_opts_new.
int burn_disc_get_profile(struct burn_drive *d, int *pno, char name[80])
Tells the MMC Profile identifier of the loaded media.
void burn_source_free(struct burn_source *s)
Free a burn_source (decrease its refcount and maybe free it)
void burn_disc_format(struct burn_drive *drive, off_t size, int flag)
Format media for use with libburn.
int burn_drive_convert_fs_adr(char *path, char adr[])
Try to convert a given existing filesystem address into a drive device file address.
int burn_drive_get_adr(struct burn_drive_info *drive_info, char adr[])
Inquire the device file address of a drive via a given drive_info object.
int burn_session_add_track(struct burn_session *s, struct burn_track *t, unsigned int pos)
Add a track to a session at specified position.
void burn_session_free(struct burn_session *s)
Free a session (and decrease reference count on all tracks inside)
int burn_drive_scan(struct burn_drive_info *drive_infos[], unsigned int *n_drives)
Scan for drives.
enum burn_source_status burn_track_set_source(struct burn_track *t, struct burn_source *s)
Set the track's data source.
int burn_drive_grab(struct burn_drive *drive, int load)
Grab a drive.
@ BURN_DRIVE_SPAWNING
The library is spawning the processes to handle a pending operation (A read/write/etc is about to sta...
@ BURN_DRIVE_IDLE
The drive is not in an operation.
int burn_write_opts_set_underrun_proof(struct burn_write_opts *opts, int underrun_proof)
Controls buffer underrun prevention.
struct burn_disc * burn_disc_create(void)
Create a new disc.
void burn_set_signal_handling(void *handle, burn_abort_handler_t handler, int mode)
Control built-in signal handling.
#define BURN_DRIVE_ADR_LEN
Maximum length+1 to expect with a drive device file address string.
int burn_initialize(void)
Initialize the library.
void burn_drive_set_speed(struct burn_drive *d, int read, int write)
Sets drive read and write speed.
int burn_msgs_set_severities(char *queue_severity, char *print_severity, char *print_id)
Control queueing and stderr printing of messages from libburn.
void burn_disc_write(struct burn_write_opts *o, struct burn_disc *disc)
Write a disc in the drive.
void burn_drive_release(struct burn_drive *drive, int eject)
Release a drive.
int burn_disc_add_session(struct burn_disc *d, struct burn_session *s, unsigned int pos)
Add a session to a disc at a specific position, increasing the sessions's reference count.
int burn_disc_erasable(struct burn_drive *d)
Tells whether a disc can be erased or not.
#define BURN_FORMAT_IS_UNFORMATTED
Possible formatting status values.
struct burn_source * burn_fd_source_new(int datafd, int subfd, off_t size)
Creates a data source for an image file (a track) from an open readable filedescriptor,...
void burn_disc_erase(struct burn_drive *drive, int fast)
Erase a disc in the drive.
enum burn_write_types burn_write_opts_auto_write_type(struct burn_write_opts *opts, struct burn_disc *disc, char reasons[BURN_REASONS_LEN], int flag)
As an alternative to burn_write_opts_set_write_type() this function tries to find a suitable write ty...
void burn_write_opts_set_perform_opc(struct burn_write_opts *opts, int opc)
Sets whether to use opc or not with the write_opts struct.
@ BURN_WRITE_NONE
In replies this indicates that not any writing will work.
int burn_is_aborting(int flag)
enum burn_drive_status burn_drive_get_status(struct burn_drive *drive, struct burn_progress *p)
Returns the progress and status of a drive.
int burn_drive_info_forget(struct burn_drive_info *drive_info, int force)
Release memory about a single drive and any exclusive lock on it.
int burn_abort(int patience, int(*pacifier_func)(void *handle, int patience, int elapsed), void *handle)
Abort any running drive operation and eventually call burn_finish().
@ BURN_SOURCE_OK
The source is ok.
struct burn_source * burn_fifo_source_new(struct burn_source *inp, int chunksize, int chunks, int flag)
Creates a fifo which acts as proxy for an already existing data source.
struct burn_session * burn_session_create(void)
Create a new session.
void burn_finish(void)
Shutdown the library.
int burn_disc_get_formats(struct burn_drive *drive, int *status, off_t *size, unsigned *bl_sas, int *num_formats)
Inquire the formatting status, the associated sizes and the number of available formats.
enum burn_disc_status burn_disc_get_status(struct burn_drive *drive)
Returns what kind of disc a drive is holding.
void burn_disc_free(struct burn_disc *d)
Delete disc and decrease the reference count on all its sessions.
void burn_write_opts_set_multi(struct burn_write_opts *opts, int multi)
Sets the multi flag which eventually marks the emerging session as not being the last one and thus cr...
int burn_abort_pacifier(void *handle, int patience, int elapsed)
A pacifier function suitable for burn_abort.
burn_disc_status
Possible status of the drive in regard to the disc in it.
@ BURN_DISC_EMPTY
There is no disc at all in the drive.
@ BURN_DISC_BLANK
The drive holds a blank disc.
@ BURN_DISC_APPENDABLE
There is an incomplete disc in the drive.
@ BURN_DISC_FULL
There is a disc with data on it in the drive.
struct burn_write_opts * burn_write_opts_new(struct burn_drive *drive)
Creates a write_opts struct for burning to the specified drive.
struct burn_track * burn_track_create(void)
Create a track.
int burn_drive_scan_and_grab(struct burn_drive_info *drive_infos[], char *adr, int load)
Acquire a drive with known device file address.
void burn_track_define_data(struct burn_track *t, int offset, int tail, int pad, int mode)
Define the data in a track.
#define BURN_MODE1
Track mode - mode 1 data 2048 bytes user data, and all the LEC money can buy.
#define BURN_AUDIO
Track mode - audio 2352 bytes per sector.
int burn_fifo_inquire_status(struct burn_source *fifo, int *size, int *free_bytes, char **status_text)
Inquires state and fill parameters of a fifo burn_source which was created by burn_fifo_source_new() ...
int libburner_blank_disc(struct burn_drive *drive, int blank_fast)
Makes a previously used CD-RW or unformatted DVD-RW ready for thorough re-usal.
static char current_profile_name[80]
static char source_adr[99][4096]
static struct burn_drive_info * drive_list
Overview.
static unsigned int drive_count
If you start a long lasting operation with drive_count > 1 then you are not friendly to the users of ...
int main(int argc, char **argv)
int libburner_aquire_by_adr(char *drive_adr)
If the persistent drive address is known, then this approach is much more un-obtrusive to the systemw...
int libburner_format(struct burn_drive *drive)
Formats unformatted DVD-RW to profile 0013h "Restricted Overwrite" which needs no blanking for re-use...
int libburner_setup(int argc, char **argv)
Converts command line arguments into above setup parameters.
static int source_adr_count
static int current_profile
A number and a text describing the type of media in acquired drive.
int libburner_aquire_by_driveno(int *drive_no)
This method demonstrates how to use libburn without knowing a persistent drive address in advance.
static int drive_is_grabbed
This variable indicates wether the drive is grabbed and must be finally released.
int libburner_aquire_drive(char *drive_adr, int *driveno)
You need to acquire a drive before burning.
static int all_tracks_type
static char drive_adr[BURN_DRIVE_ADR_LEN]
The setup parameters of libburner.
int libburner_payload(struct burn_drive *drive, char source_adr[][4096], int source_adr_count, int multi, int simulate_burn, int all_tracks_type)
Brings preformatted track images (ISO 9660, audio, ...) onto media.
Information on a drive in the system.
char product[17]
Name of the drive.
struct burn_drive * drive
The value by which this drive can be indexed when using functions in the library.
char vendor[9]
Name of the vendor of the drive.
Operation progress report.
int sector
On write: The current sector being processed.
int sectors
On write: The number of sectors.
Data source interface for tracks.