xorriso  1.5.4.pl02
About: GNU xorriso creates, loads, manipulates and writes ISO 9660 filesystem images with Rock Ridge extensions. It is suitable for incremental data backup and for production of bootable ISO 9660 images. GNU xorriso is a statical compilation of the libraries libburn, libisofs, libisoburn, and libjte.
  Fossies Dox: xorriso-1.5.4.pl02.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

init.c File Reference
#include <unistd.h>
#include <stdio.h>
#include <signal.h>
#include <string.h>
#include <stdlib.h>
#include <pthread.h>
#include "sg.h"
#include "error.h"
#include "libburn.h"
#include "drive.h"
#include "transport.h"
#include "util.h"
#include "back_hacks.h"
#include "libdax_msgs.h"
#include "cleanup.h"
Include dependency graph for init.c:

Go to the source code of this file.


#define BURM_MSGS_MESSAGE_LEN   4096
#define Libburn_new_thread_signal_handleR   1


int burn_msgs_initialize (void)
int burn_initialize (void)
void burn_finish (void)
char * burn_scsi_transport_id (int flag)
void burn_preset_device_open (int exclusive, int blocking, int abort_on_busy)
int burn_msgs_set_severities (char *queue_severity, char *print_severity, char *print_id)
int burn_msgs_obtain (char *minimum_severity, int *error_code, char msg_text[], int *os_errno, char severity[])
int burn_msgs_submit (int error_code, char msg_text[], int os_errno, char severity[], struct burn_drive *d)
int burn_text_to_sev (char *severity_name, int *sevno, int flag)
int burn_sev_to_text (int severity_number, char **severity_name, int flag)
char * burn_list_sev_texts (int flag)
char * burn_util_thread_id (pid_t pid, pthread_t tid, char text[80])
int burn_abort_exit (int value)
int burn_builtin_abort_handler (void *handle, int signum, int flag)
void burn_set_signal_handling (void *handle, burn_abort_handler_t handler, int mode)
int burn_is_aborting (int flag)
int burn_init_catch_on_abort (int flag)
int burn_grab_prepare_sig_action (int *signal_action_mem, int flag)
int burn_grab_restore_sig_action (int signal_action_mem, int flag)
void burn_allow_untested_profiles (int yes)
int burn_set_messenger (void *messenger)
void burn_set_scsi_logging (int flag)
void burn_allow_drive_role_4 (int allowed)
void * burn_alloc_mem (size_t size, size_t count, int flag)


struct libdax_msgs * libdax_messenger = NULL
int burn_running = 0
double lib_start_time
int burn_sg_open_o_excl = 1
int burn_sg_fcntl_f_setlk = 1
int burn_sg_use_family = 0
int burn_sg_open_o_nonblock = 1
int burn_sg_open_abort_busy = 0
static char sg_initialize_msg [1024] = {""}
static char abort_message_prefix [81] = {"libburn : "}
static pid_t abort_control_pid = 0
static pthread_t abort_control_thread
volatile int burn_global_abort_level = 0
int burn_global_abort_signum = 0
void * burn_global_signal_handle = NULL
burn_abort_handler_t burn_global_signal_handler = NULL
int burn_builtin_signal_action = 0
volatile int burn_builtin_triggered_action = 0
int burn_support_untested_profiles = 0
int burn_sg_log_scsi = 0
int burn_drive_role_4_allowed = 0

Macro Definition Documentation


#define BURM_MSGS_MESSAGE_LEN   4096

Definition at line 251 of file init.c.



Definition at line 37 of file init.c.

◆ Libburn_new_thread_signal_handleR

#define Libburn_new_thread_signal_handleR   1

Function Documentation

◆ burn_abort_exit()

int burn_abort_exit ( int  value)

◆ burn_alloc_mem()

void* burn_alloc_mem ( size_t  size,
size_t  count,
int  flag 

◆ burn_allow_drive_role_4()

void burn_allow_drive_role_4 ( int  allowed)

Allow drive role 4 "random access read-only" and drive role 5 "random access write-only". By default a random access file assumes drive role 2 "read-write" regardless whether it is actually readable or writeable. If enabled, random-access file objects which recognizably permit no writing will be classified as role 4 and those which permit no reading will get role 5. Candidates are drive addresses of the form stdio:/dev/fd/# , where # is the integer number of an open file descriptor. If this descriptor was opened read-only or write-only, then it gets role 4 or role 5, respectively. Other paths may get tested by an attempt to open them for read-write (role 2) or read-only (role 4) or write-only (role 5). See bit1.

allowedBitfield for control purposes: bit0= Enable roles 4 and 5 for drives which get acquired after this call bit1= with bit0: Test whether the file can be opened for read-write, read-only, or write-only. Classify as roles 2, 4, 5. bit2= with bit0 and bit1: Classify files which cannot be opened at all as role 0 : useless dummy. Else classify as role 2. bit3= Classify non-empty role 5 drives as BURN_DISC_APPENDABLE with Next Writeable Address after the end of the file. It is nevertheless possible to change this address by call burn_write_opts_set_start_byte().

Definition at line 646 of file init.c.

References burn_drive_role_4_allowed.

Referenced by Xorriso_aquire_drive().

◆ burn_allow_untested_profiles()

void burn_allow_untested_profiles ( int  yes)

Allows the use of media types which are implemented in libburn but not yet tested. The list of those untested profiles is subject to change.

Definition at line 619 of file init.c.

References burn_support_untested_profiles.

◆ burn_builtin_abort_handler()

◆ burn_finish()

void burn_finish ( void  )

Shutdown the library. This should be called before exiting your application. Make sure that all drives you have grabbed are released before calling this.

Definition at line 161 of file init.c.

References abort_message_prefix, burn_abort(), burn_abort_pacifier(), burn_drive_clear_whitelist(), burn_drive_free_all(), burn_drives_are_clear(), burn_running, libdax_messenger, libdax_msgs_destroy(), LIBDAX_MSGS_PRIO_HIGH, LIBDAX_MSGS_SEV_WARNING, libdax_msgs_submit(), and sg_shutdown().

Referenced by burn_abort_5(), and isoburn_finish().

◆ burn_grab_prepare_sig_action()

int burn_grab_prepare_sig_action ( int *  signal_action_mem,
int  flag 

◆ burn_grab_restore_sig_action()

int burn_grab_restore_sig_action ( int  signal_action_mem,
int  flag 

◆ burn_init_catch_on_abort()

int burn_init_catch_on_abort ( int  flag)

◆ burn_initialize()

int burn_initialize ( void  )

Initialize the library. This must be called before using any other functions in the library. It may be called more than once with no effect. It is possible to 'restart' the library by shutting it down and re-initializing it. Once this was necessary if you follow the older and more general way of accessing a drive via burn_drive_scan() and burn_drive_grab(). See burn_drive_scan_and_grab() with its strong urges and its explanations.

Nonzero if the library was able to initialize; zero if initialization failed.

Definition at line 137 of file init.c.

References burn_get_time(), burn_msgs_initialize(), burn_running, burn_support_untested_profiles, lib_start_time, libdax_messenger, LIBDAX_MSGS_PRIO_HIGH, LIBDAX_MSGS_SEV_FATAL, libdax_msgs_submit(), sg_initialize(), and sg_initialize_msg.

Referenced by isoburn_initialize().

◆ burn_is_aborting()

◆ burn_list_sev_texts()

char* burn_list_sev_texts ( int  flag)

Return a blank separated list of severity names. Sorted from low to high severity.

flagBitfield for control purposes (unused yet, submit 0)
A constant string with the severity names

Definition at line 358 of file init.c.

References libdax_msgs__sev_to_text().

Referenced by Xorriso__severity_list().

◆ burn_msgs_initialize()

int burn_msgs_initialize ( void  )

Create the messenger object for libburn.

Definition at line 122 of file init.c.

References libdax_messenger, libdax_msgs_new(), libdax_msgs_set_severities(), LIBDAX_MSGS_SEV_FATAL, and LIBDAX_MSGS_SEV_NEVER.

Referenced by burn_initialize().

◆ burn_msgs_obtain()

int burn_msgs_obtain ( char *  minimum_severity,
int *  error_code,
char  msg_text[],
int *  os_errno,
char  severity[] 

Obtain the oldest pending libburn message from the queue which has at least the given minimum_severity. This message and any older message of lower severity will get discarded from the queue and is then lost forever. Severity may be one of "NEVER", "FATAL", "SORRY", "WARNING", "HINT", "NOTE", "UPDATE", "DEBUG", "ALL". To call with minimum_severity "NEVER" will discard the whole queue.

error_codeWill become a unique error code as liste in libburn/libdax_msgs.h
msg_textMust provide at least BURM_MSGS_MESSAGE_LEN bytes.
os_errnoWill become the eventual errno related to the message
severityWill become the severity related to the message and should provide at least 80 bytes.
1 if a matching item was found, 0 if not, <0 for severe errors

Definition at line 267 of file init.c.

References BURM_MSGS_MESSAGE_LEN, libdax_messenger, libdax_msgs__sev_to_text(), libdax_msgs__text_to_sev(), libdax_msgs_destroy_item(), libdax_msgs_item_get_msg(), libdax_msgs_item_get_rank(), libdax_msgs_obtain(), and LIBDAX_MSGS_PRIO_ZERO.

Referenced by Xorriso_process_msg_queues().

◆ burn_msgs_set_severities()

int burn_msgs_set_severities ( char *  queue_severity,
char *  print_severity,
char *  print_id 

Control queueing and stderr printing of messages from libburn. Severity may be one of "NEVER", "FATAL", "SORRY", "WARNING", "HINT", "NOTE", "UPDATE", "DEBUG", "ALL".

queue_severityGives the minimum limit for messages to be queued. Default: "NEVER". If you queue messages then you must consume them by burn_msgs_obtain().
print_severityDoes the same for messages to be printed directly to stderr.
print_idA text prefix to be printed before the message.
>0 for success, <=0 for error

Definition at line 231 of file init.c.

References libdax_messenger, libdax_msgs__text_to_sev(), and libdax_msgs_set_severities().

Referenced by Xorriso_startup_libraries().

◆ burn_msgs_submit()

int burn_msgs_submit ( int  error_code,
char  msg_text[],
int  os_errno,
char  severity[],
struct burn_drive d 

Submit a message to the libburn queueing system. It will be queued or printed as if it was generated by libburn itself.

error_codeThe unique error code of your message. Submit 0 if you do not have reserved error codes within the libburnia project.
msg_textNot more than BURN_MSGS_MESSAGE_LEN characters of message text.
os_errnoEventual errno related to the message. Submit 0 if the message is not related to a operating system error.
severityOne of "ABORT", "FATAL", "FAILURE", "SORRY", "WARNING", "HINT", "NOTE", "UPDATE", "DEBUG". Defaults to "FATAL".
dAn eventual drive to which the message shall be related. Submit NULL if the message is not specific to a particular drive object.
1 if message was delivered, <=0 if failure

Definition at line 308 of file init.c.


Referenced by isoburn_msgs_submit().

◆ burn_preset_device_open()

void burn_preset_device_open ( int  exclusive,
int  blocking,
int  abort_on_busy 

◆ burn_scsi_transport_id()

char* burn_scsi_transport_id ( int  flag)

API function. See libburn.h

Definition at line 194 of file init.c.

References burn_running, sg_id_string(), and sg_initialize_msg.

Referenced by Xorriso_report_lib_versions(), and Xorriso_startup_libraries().

◆ burn_set_messenger()

int burn_set_messenger ( void *  messenger)

Replace the messenger object handle of libburn by a compatible handle obtained from a related library. See also: libisofs, API function iso_get_messenger().

messengerThe foreign but compatible message handle.
1 : success, <=0 : failure

Definition at line 626 of file init.c.

References libdax_messenger, libdax_msgs_destroy(), and libdax_msgs_refer().

◆ burn_set_scsi_logging()

void burn_set_scsi_logging ( int  flag)

Enable or disable logging of SCSI commands. This call can be made at any time - even before burn_initialize(). It is in effect for all active drives and currently not very thread safe for multiple drives.

flagBitfield for control purposes. The default is 0. bit0= log to file /tmp/libburn_sg_command_log bit1= log to stderr bit2= flush output after each line

Definition at line 639 of file init.c.

References burn_sg_log_scsi.

Referenced by Xorriso_scsi_log().

◆ burn_set_signal_handling()

void burn_set_signal_handling ( void *  handle,
burn_abort_handler_t  handler,
int  mode 

Control built-in signal handling. Either by setting an own handler or by activating the built-in signal handler.

A function parameter handle of NULL activates the built-in abort handler. Depending on mode it may cancel all drive operations, wait for all drives to become idle, exit(1). It may also prepare function burn_drive_get_status() for waiting and performing exit(1). Parameter handle may be NULL or a text that shall be used as prefix for pacifier messages of burn_abort_pacifier(). Other than with an application provided handler, the prefix char array does not have to be kept existing until the eventual signal event. Before version 0.7.8 only action 0 was available. I.e. the built-in handler waited for the drives to become idle and then performed exit(1) directly. But during burn_disc_write() onto real CD or DVD, FreeBSD 8.0 pauses the other threads until the signal handler returns. The new actions try to avoid this deadlock. It is advised to use action 3 at least during burn_disc_write(), burn_disc_erase(), burn_disc_format(): burn_set_signal_handling(text, NULL, 0x30); and to call burn_is_aborting(0) when the drive is BURN_DRIVE_IDLE. If burn_is_aborting(0) returns 1, then call burn_abort() and exit(1).

handleOpaque handle eventually pointing to an application provided memory object
handlerA function to be called on signals, if the handling bits in parameter mode are set 0. It will get parameter handle as argument. flag will be 0. It should finally call burn_abort(). See there. If the handler function returns 2 or -2, then the wrapping signal handler of libburn will return and let the program continue its operations. Any other return value causes exit(1).
mode: bit0 - bit3: Handling of received signals: 0 Install libburn wrapping signal handler, which will call handler(handle, signum, 0) on nearly all signals 1 Enable system default reaction on all signals 2 Try to ignore nearly all signals 10 like mode 2 but handle SIGABRT like with mode 0 bit4 - bit7: With handler == NULL : Action of built-in handler. "control thread" is the one which called burn_set_signal_handling(). All actions activate receive mode 2 to ignore further signals. 0 Same as 1 (for pre-0.7.8 backward compatibility)
0.7.8 1 Catch the control thread in abort handler, call burn_abort() with a patience value > 0 and finally exit(1). Does not always work with FreeBSD. 2 Call burn_abort() with patience -1 and return from handler. When the control thread calls burn_drive_get_status(), then call burn_abort() with patience 1 instead, and finally exit(1). Does not always work with FreeBSD. 3 Call burn_abort() with patience -1, return from handler. It is duty of the application to detect a pending abort condition by calling burn_is_aborting() and to wait for all drives to become idle. E.g. by calling burn_abort() with patience >0. 4 Like 3, but without calling burn_abort() with -1. Only the indicator of burn_is_aborting() gets set. bit8:
1.3.2 try to ignore SIGPIPE (regardless of bit0 - bit3)

Definition at line 520 of file init.c.

References abort_control_pid, abort_control_thread, abort_message_prefix, burn_builtin_abort_handler(), burn_builtin_signal_action, burn_builtin_triggered_action, burn_global_signal_handle, burn_global_signal_handler, and Cleanup_set_handlers().

Referenced by Xorriso_set_signal_handling().

◆ burn_sev_to_text()

int burn_sev_to_text ( int  severity_number,
char **  severity_name,
int  flag 

Convert a severity number into a severity name

severity_numberThe rank number: the higher, the more severe.
severity_nameA name as with burn_msgs_submit(), e.g. "SORRY".
flagBitfield for control purposes (unused yet, submit 0)
>0 success, <=0 failure

Definition at line 348 of file init.c.

References libdax_msgs__sev_to_text().

Referenced by isoburn__sev_to_text(), and Xorriso__sev_to_text().

◆ burn_text_to_sev()

int burn_text_to_sev ( char *  severity_name,
int *  severity_number,
int  flag 

Convert a severity name into a severity number, which gives the severity rank of the name.

severity_nameA name as with burn_msgs_submit(), e.g. "SORRY".
severity_numberThe rank number: the higher, the more severe.
flagBitfield for control purposes (unused yet, submit 0)
>0 success, <=0 failure

Definition at line 338 of file init.c.

References libdax_msgs__text_to_sev().

Referenced by isoburn__text_to_sev(), and Xorriso__text_to_sev().

◆ burn_util_thread_id()

char* burn_util_thread_id ( pid_t  pid,
pthread_t  tid,
char  text[80] 

Definition at line 368 of file init.c.

Referenced by burn_builtin_abort_handler().

Variable Documentation

◆ abort_control_pid

pid_t abort_control_pid = 0

◆ abort_control_thread

pthread_t abort_control_thread

◆ abort_message_prefix

char abort_message_prefix[81] = {"libburn : "}

◆ burn_builtin_signal_action

int burn_builtin_signal_action = 0

◆ burn_builtin_triggered_action

volatile int burn_builtin_triggered_action = 0

◆ burn_drive_role_4_allowed

int burn_drive_role_4_allowed = 0

Definition at line 117 of file init.c.

Referenced by burn_allow_drive_role_4(), burn_drive_equals_adr(), and burn_drive_grab_dummy().

◆ burn_global_abort_level

volatile int burn_global_abort_level = 0

Indicator for burn_drive_get_status() whether a signal hit parts of the thread team. 0= all works well , 1 to 5 = waiting for eventual signal on control thread

5 = do abort now

-1 = control thread has been informed

Definition at line 93 of file init.c.

Referenced by burn_abort_exit(), and burn_builtin_abort_handler().

◆ burn_global_abort_signum

int burn_global_abort_signum = 0

Definition at line 94 of file init.c.

Referenced by burn_builtin_abort_handler().

◆ burn_global_signal_handle

void* burn_global_signal_handle = NULL

Definition at line 95 of file init.c.

Referenced by burn_set_signal_handling().

◆ burn_global_signal_handler

burn_abort_handler_t burn_global_signal_handler = NULL

◆ burn_running

int burn_running = 0

◆ burn_sg_fcntl_f_setlk

int burn_sg_fcntl_f_setlk = 1

Definition at line 57 of file init.c.

Referenced by burn_preset_device_open(), and sg_fcntl_lock().

◆ burn_sg_log_scsi

◆ burn_sg_open_abort_busy

int burn_sg_open_abort_busy = 0

Definition at line 77 of file init.c.

Referenced by burn_preset_device_open(), and sg_handle_busy_device().

◆ burn_sg_open_o_excl

int burn_sg_open_o_excl = 1

◆ burn_sg_open_o_nonblock

int burn_sg_open_o_nonblock = 1

Definition at line 72 of file init.c.

Referenced by burn_preset_device_open(), sg_grab(), sg_obtain_scsi_adr_fd(), and sg_open_drive_fd().

◆ burn_sg_use_family

int burn_sg_use_family = 0

◆ burn_support_untested_profiles

int burn_support_untested_profiles = 0

Definition at line 102 of file init.c.

Referenced by burn_allow_untested_profiles(), and burn_initialize().

◆ lib_start_time

double lib_start_time

Definition at line 47 of file init.c.

Referenced by burn_initialize(), and scsi_log_reply().

◆ libdax_messenger

struct libdax_msgs* libdax_messenger = NULL

PORTING : ----— OS dependent headers and definitions ---— PORTING : ---— libburn portable headers and definitions --—

Definition at line 42 of file init.c.

Referenced by burn_alloc_mem(), burn_builtin_abort_handler(), burn_cdtext_check_blockno(), burn_cdtext_from_packfile(), burn_cdtext_get(), burn_cdtext_set(), burn_create_new_pack(), burn_create_toc_entries(), burn_disc_cd_toc_extensions(), burn_disc_close_damaged(), burn_disc_close_session_dvd_minus_r(), burn_disc_close_track_dvd_minus_r(), burn_disc_close_track_dvd_plus_r(), burn_disc_erase(), burn_disc_erase_sync(), burn_disc_finalize_dvd_plus_r(), burn_disc_format(), burn_disc_format_sync(), burn_disc_get_msc1(), burn_disc_open_track_dvd_minus_r(), burn_disc_open_track_dvd_plus_r(), burn_disc_read_atip(), burn_disc_setup_dvd_minus_rw(), burn_disc_track_lba_nwa(), burn_disc_write(), burn_disc_write_is_ok(), burn_disc_write_sync(), burn_drive_adr_debug_msg(), burn_drive_cancel(), burn_drive_d_get_adr(), burn_drive_extract_audio(), burn_drive_extract_audio_track(), burn_drive_finish_enum(), burn_drive_grab(), burn_drive_grab_dummy(), burn_drive_re_assess(), burn_drive_release_fl(), burn_drive_reset_simulate(), burn_drive_scan(), burn_drive_scan_and_grab(), burn_drive_scan_sync(), burn_drive_set_stream_recording(), burn_dvd_write_session(), burn_dvd_write_sync(), burn_fifo_fill_data(), burn_fifo_inquire_status(), burn_fifo_source_new(), burn_fifo_source_shoveller(), burn_finish(), burn_initialize(), burn_make_v07t(), burn_msgs_initialize(), burn_msgs_obtain(), burn_msgs_set_severities(), burn_msgs_submit(), burn_offst_source_new(), burn_os_alloc_buffer(), burn_os_open_track_src(), burn_precheck_write(), burn_random_access_write(), burn_read_audio(), burn_read_data(), burn_scsi_setup_drive(), burn_session_by_cue_file(), burn_session_input_sheet_v07t(), burn_session_set_start_tno(), burn_set_messenger(), burn_stdio_mmc_write(), burn_stdio_open_write(), burn_stdio_read(), burn_stdio_seek(), burn_stdio_sync_cache(), burn_stdio_write(), burn_structure_print_disc(), burn_structure_print_session(), burn_structure_print_track(), burn_track_apply_fillup(), burn_track_define_data(), burn_track_set_index(), burn_track_set_isrc(), burn_track_set_isrc_string(), burn_write_close_session(), burn_write_close_track(), burn_write_leadin_cdtext(), burn_write_opts_clone(), burn_write_opts_new(), burn_write_opts_set_leadin_text(), burn_write_opts_set_write_type(), burn_write_track(), burn_write_track_minsize(), cue_attach_track(), cue_check_for_track(), cue_create_file_source(), cue_interpret_line(), cue_open_audioxtr(), cue_read_number(), cue_read_timepoint_lba(), cue_set_cdtext(), evaluate_transport_success(), fifo_free(), fifo_read(), fname_enumerate(), get_bytes(), libdax_audioxtr_open(), mmc_close(), mmc_close_disc(), mmc_close_session(), mmc_compose_mode_page_5(), mmc_eval_read_error(), mmc_fake_toc(), mmc_format_unit(), mmc_function_spy(), mmc_get_configuration_al(), mmc_get_nwa(), mmc_get_phys_format_info(), mmc_read_10(), mmc_read_disc_info_al(), mmc_read_disc_structure(), mmc_read_toc_al(), mmc_read_toc_fmt0_al(), mmc_reserve_track(), mmc_set_streaming(), mmc_sync_cache(), mmc_wait_for_buffer_free(), mmc_write(), new_cue(), next_enum_cXtYdZs2(), offst_auth(), proc_sys_dev_cdrom_info(), react_on_drive_loss(), remove_worker(), report_block(), scsi_enumerate_drives(), scsi_eval_cmd_outcome(), scsi_notify_error(), sector_headers(), sg_close_drive_fd(), sg_exchange_scd_for_sr(), sg_fcntl_lock(), sg_grab(), sg_handle_busy_device(), sg_initialize(), sg_issue_command(), sg_lock(), sg_obtain_scsi_adr(), sg_open_drive_fd(), sg_open_scsi_siblings(), sg_os_revalidate_disc(), sg_release_siblings(), sg_solaris_convert_devname(), sgio_inquiry_cd_drive(), single_enumerate(), spc_confirm_cd_drive(), spc_report_async_error(), spc_sense_caps_al(), spc_wait_unit_attention(), start_enum_cXtYdZs2(), v07t_cdtext_char_code(), v07t_cdtext_genre_code(), v07t_cdtext_lang_code(), and write_disc_worker_func().

◆ sg_initialize_msg

char sg_initialize_msg[1024] = {""}

Definition at line 82 of file init.c.

Referenced by burn_initialize(), and burn_scsi_transport_id().