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)  

sg.h File Reference
#include "os.h"
Include dependency graph for sg.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct burn_drive_enumerator_struct burn_drive_enumerator_t
 

Functions

int sg_give_next_adr (burn_drive_enumerator_t *enm_context, char adr[], int adr_size, int initialize)
 
int sg_is_enumerable_adr (char *adr)
 
int sg_obtain_scsi_adr (char *path, int *bus_no, int *host_no, int *channel_no, int *target_no, int *lun_no)
 
int sg_grab (struct burn_drive *)
 
int sg_release (struct burn_drive *)
 
int sg_issue_command (struct burn_drive *, struct command *)
 
int scsi_enumerate_drives (void)
 
int sg_drive_is_open (struct burn_drive *d)
 
int burn_os_is_2k_seekrw (char *path, int flag)
 
int burn_os_stdio_capacity (char *path, off_t write_start, off_t *bytes)
 
int sg_id_string (char msg[1024], int flag)
 
int sg_initialize (char msg[1024], int flag)
 
int sg_shutdown (int flag)
 
int sg_dispose_drive (struct burn_drive *d, int flag)
 

Typedef Documentation

◆ burn_drive_enumerator_t

Definition at line 1 of file sg.h.

Function Documentation

◆ burn_os_is_2k_seekrw()

int burn_os_is_2k_seekrw ( char *  path,
int  flag 
)

Definition at line 228 of file sg-dummy.c.

References Libburn_netbsd_max_cdnuM.

Referenced by burn_drive__is_rdwr().

◆ burn_os_stdio_capacity()

int burn_os_stdio_capacity ( char *  path,
off_t  write_start,
off_t *  bytes 
)

Estimate the potential payload capacity of a file address.

Parameters
pathThe address of the file to be examined. If it does not exist yet, then the directory will be inquired.
bytesThe pointed value gets modified, but only if an estimation is possible.
Returns
-2 = cannot perform necessary operations on file object -1 = neither path nor dirname of path exist 0 = could not estimate size capacity of file object 1 = estimation has been made, bytes was set

Estimate the potential payload capacity of a file address.

Parameters
pathThe address of the file to be examined. If it does not exist yet, then the directory will be inquired.
bytesThis value gets modified if an estimation is possible
Returns
-2 = cannot perform necessary operations on file object -1 = neither path nor dirname of path exist 0 = could not estimate size capacity of file object 1 = estimation has been made, bytes was set

Definition at line 252 of file sg-dummy.c.

References BURN_ALLOC_MEM, BURN_FREE_MEM, burn_sg_open_o_excl, burn_sparse_file_addsize(), guess_size_by_seek_set(), and O_BINARY.

Referenced by burn_disc_available_space(), burn_disc_get_multi_caps(), burn_drive__is_rdwr(), burn_drive_grab_dummy(), and burn_drive_grab_stdio().

◆ scsi_enumerate_drives()

int scsi_enumerate_drives ( void  )

Brings all available, not-whitelist-banned, and accessible drives into libburn's list of drives.

Brings all available, not-whitelist-banned, and accessible drives into libburn's list of drives. PORTING: If not stricken with an incompletely unified situation like in GNU/Linux one would rather implement this by a loop calling sg_give_next_adr(). If needed with your sg_give_next_adr() results, do a test for existence and accessability. If burn activities are prone to external interference on your system it is also necessary to obtain exclusive access locks on the drives. Hand over each accepted drive to enumerate_common() or its replacement within your port.

See FreeBSD port sketch sg-freebsd-port.c for such an implementation.

Definition at line 137 of file sg-dummy.c.

References add_proc_info_drives(), ata_enumerate(), BURN_ALLOC_MEM, burn_drive_is_banned(), burn_drive_resolve_link(), BURN_FREE_MEM, enumerate_common(), libdax_messenger, LIBDAX_MSGS_PRIO_HIGH, LIBDAX_MSGS_SEV_WARNING, libdax_msgs_submit(), sg_destroy_enumerator(), sg_enumerate(), sg_give_next_adr(), sg_give_next_adr_raw(), sg_init_enumerator(), sg_obtain_scsi_adr(), and single_enumerate().

Referenced by burn_drive_scan_sync().

◆ sg_dispose_drive()

int sg_dispose_drive ( struct burn_drive d,
int  flag 
)

Finalizes BURN_OS_TRANSPORT_DRIVE_ELEMENTS, the components of struct burn_drive which are defined in os-*.h. The eventual initialization of those components was made underneath scsi_enumerate_drives(). This will be called when a burn_drive gets disposed.

Parameters
dthe drive to be finalized
flagunused yet, submit 0
Returns
1 = success, <=0 = failure

Finalizes BURN_OS_TRANSPORT_DRIVE_ELEMENTS, the components of struct burn_drive which are defined in os-*.h. This will be called when a burn_drive gets disposed.

Parameters
dthe drive to be finalized
flagunused yet, submit 0
Returns
1 = success, <=0 = failure

Definition at line 105 of file sg-dummy.c.

Referenced by burn_drive_free_subs().

◆ sg_drive_is_open()

int sg_drive_is_open ( struct burn_drive d)

Tells whether libburn has the given drive in use or exclusively reserved. If it is "open" then libburn will eventually call sg_release() on it when it is time to give up usage and reservation. Published as burn_drive.drive_is_open()

Definition at line 152 of file sg-dummy.c.

Referenced by enumerate_common().

◆ sg_give_next_adr()

int sg_give_next_adr ( burn_drive_enumerator_t idx,
char  adr[],
int  adr_size,
int  initialize 
)

Returns the next index number and the next enumerated drive address. The enumeration has to cover all available and accessible drives. It is allowed to return addresses of drives which are not available but under some (even exotic) circumstances could be available. It is on the other hand allowed, only to hand out addresses which can really be used right in the moment of this call. (This implementation chooses the former.)

Parameters
idxAn opaque handle. Make no own theories about it.
adrTakes the reply
adr_sizeGives maximum size of reply including final 0
initialize1 = start new, 0 = continue, use no other values for now -1 = finish
Returns
1 = reply is a valid address , 0 = no further address available -1 = severe error (e.g. adr_size too small)

Returns the next index number and the next enumerated drive address. The enumeration has to cover all available and accessible drives. It is allowed to return addresses of drives which are not available but under some (even exotic) circumstances could be available. It is on the other hand allowed, only to hand out addresses which can really be used right in the moment of this call. (This implementation chooses the latter.)

Parameters
idxAn opaque handle. Make no own theories about it.
adrTakes the reply
adr_sizeGives maximum size of reply including final 0
initialize1 = start new, 0 = continue, use no other values for now -1 = finish
Returns
1 = reply is a valid address , 0 = no further address available -1 = severe error (e.g. adr_size too small)

Returns the next index object state and the next enumerated drive address.

Parameters
idxAn opaque handle. Make no own theories about it.
adrTakes the reply
adr_sizeGives maximum size of reply including final 0
initialize1 = start new, 0 = continue, use no other values for now -1 = finish
Returns
1 = reply is a valid address , 0 = no further address available -1 = severe error (e.g. adr_size too small)

PORTING: In this GNU/Linux implementation, this function mirrors the enumeration done in sg_enumerate and ata_enumerate(). It would be better to base those functions on this sg_give_next_adr() but the situation is not inviting. Returns the next index number and the next enumerated drive address. The enumeration has to cover all available and accessible drives. It is allowed to return addresses of drives which are not available but under some (even exotic) circumstances could be available. It is on the other hand allowed, only to hand out addresses which can really be used right in the moment of this call. (This implementation chooses the former.)

Parameters
idxAn opaque handle. Make no own theories about it.
adrTakes the reply
adr_sizeGives maximum size of reply including final 0
initialize1 = start new, 0 = continue, use no other values for now -1 = finish
Returns
1 = reply is a valid address , 0 = no further address available -1 = severe error (e.g. adr_size too small)

Definition at line 126 of file sg-dummy.c.

References BURN_ALLOC_MEM, burn_drive_resolve_link(), BURN_FREE_MEM, burn_sg_use_family, burn_drive_enumeration_state::ccb, end_enum_cXtYdZs2(), fname_other_name(), burn_drive_enumeration_state::i, burn_drive_enumerator_struct::info_count, burn_drive_enumerator_struct::info_list, linux_ata_device_family, linux_sg_device_family, next_enum_cXtYdZs2(), next_enum_rcdNx(), burn_drive_enumerator_struct::pos, proc_sys_dev_cdrom_info(), sg_destroy_enumerator(), sg_exchange_scd_for_sr(), sg_give_next_adr_raw(), sg_init_enumerator(), sg_next_enumeration_buffer(), sg_select_device_family(), burn_drive_enumeration_state::skip_device, start_enum_cXtYdZs2(), and start_enum_rcdNx().

Referenced by burn_drive_convert_scsi_adr(), burn_drive_find_devno(), scsi_enumerate_drives(), sg_is_enumerable_adr(), and sg_obtain_scsi_adr().

◆ sg_grab()

int sg_grab ( struct burn_drive d)

Opens the drive for SCSI commands and - if burn activities are prone to external interference on your system - obtains an exclusive access lock on the drive. (Note: this is not physical tray locking.) A drive that has been opened with sg_grab() will eventually be handed over to sg_release() for closing and unreserving.

Definition at line 164 of file sg-dummy.c.

References BURN_ALLOC_MEM, burn_drive_is_open(), BURN_FREE_MEM, burn_sg_open_o_excl, burn_sg_open_o_nonblock, burn_drive::channel, burn_drive::devname, burn_drive::global_index, burn_drive::host, burn_drive::id, Libburn_udev_wait_useC, libdax_messenger, LIBDAX_MSGS_PRIO_HIGH, LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_SEV_FAILURE, LIBDAX_MSGS_SEV_SORRY, libdax_msgs_submit(), burn_drive::lun, mmc_function_spy(), burn_drive::released, sg_close_drive(), sg_fcntl_lock(), sg_lock(), sg_open_scsi_siblings(), sg_solaris_convert_devname(), and spc_confirm_cd_drive().

Referenced by enumerate_common().

◆ sg_id_string()

int sg_id_string ( char  msg[1024],
int  flag 
)

Returns the id string of the SCSI transport adapter and eventually needed operating system facilities. This call is usable even if sg_initialize() was not called yet. In that case a preliminary constant message might be issued if detailed info is not available yet.

Parameters
msgreturns id string
flagunused yet, submit 0
Returns
1 = success, <=0 = failure

Definition at line 67 of file sg-dummy.c.

Referenced by burn_scsi_transport_id(), and sg_initialize().

◆ sg_initialize()

int sg_initialize ( char  msg[1024],
int  flag 
)

Performs global initialization of the SCSI transport adapter and eventually needed operating system facilities. Checks for compatibility supporting software components.

Parameters
msgreturns ids and/or error messages of eventual helpers
flagunused yet, submit 0
Returns
1 = success, <=0 = failure

Performs global initialization of the SCSI transport adapter and eventually needed operating system facilities. Checks for compatibility of supporting software components.

Parameters
msgreturns ids and/or error messages of eventual helpers
flagunused yet, submit 0
Returns
1 = success, <=0 = failure

Definition at line 81 of file sg-dummy.c.

References libdax_messenger, LIBDAX_MSGS_PRIO_HIGH, LIBDAX_MSGS_SEV_DEBUG, libdax_msgs_submit(), and sg_id_string().

Referenced by burn_initialize().

◆ sg_is_enumerable_adr()

int sg_is_enumerable_adr ( char *  path)

Tells whether a text is a persistent address as listed by the enumeration functions.

Definition at line 219 of file sg-dummy.c.

References BURN_ALLOC_MEM, BURN_FREE_MEM, decode_btl_solaris(), sg_destroy_enumerator(), sg_give_next_adr(), and sg_init_enumerator().

Referenced by burn_drive_is_enumerable_adr().

◆ sg_issue_command()

int sg_issue_command ( struct burn_drive d,
struct command c 
)

Sends a SCSI command to the drive, receives reply and evaluates whether the command succeeded or shall be retried or finally failed. Returned SCSI errors shall not lead to a return value indicating failure. The callers get notified by c->error. An SCSI failure which leads not to a retry shall be notified via scsi_notify_error(). The Libburn_log_sg_commandS facility might be of help when problems with a drive have to be examined. It shall stay disabled for normal use.

Returns
: 1 success , <=0 failure

Sends a SCSI command to the drive, receives reply and evaluates whether the command succeeded or shall be retried or finally failed. Returned SCSI errors shall not lead to a return value indicating failure. The callers get notified by c->error. An SCSI failure which leads not to a retry shall be notified via scsi_notify_error().

Returns
: 1 success , <=0 failure

Definition at line 192 of file sg-dummy.c.

References BUFFER_SIZE, BURN_ALLOC_MEM, BURN_DRIVE_IDLE, BURN_FREE_MEM, burn_get_time(), burn_sg_log_scsi, burn_drive::busy, buffer::bytes, burn_drive::cancel, buffer::data, command::dir, command::dxfer_len, command::end_time, command::error, evaluate_transport_success(), FAIL, FROM_DRIVE, burn_drive::global_index, Libburn_scsi_default_timeouT, libdax_messenger, LIBDAX_MSGS_PRIO_HIGH, LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_SEV_FAILURE, LIBDAX_MSGS_SEV_FATAL, libdax_msgs_submit(), mmc_function_spy(), NO_TRANSFER, command::opcode, command::oplen, command::page, react_on_drive_loss(), burn_drive::released, RETRY, command::retry, scsi_error(), scsi_eval_cmd_outcome(), scsi_log_cmd(), scsi_log_message(), scsi_log_text(), command::sense, command::sense_len, sg_close_drive(), spc_decode_sense(), spc_human_readable_cmd(), spc_register_retry(), command::start_time, command::timeout, and TO_DRIVE.

Referenced by enumerate_common().

◆ sg_obtain_scsi_adr()

int sg_obtain_scsi_adr ( char *  path,
int *  bus_no,
int *  host_no,
int *  channel_no,
int *  target_no,
int *  lun_no 
)

Tries to obtain SCSI address parameters.

Returns
1 is success , 0 is failure

Try to obtain SCSI address parameters.

Returns
1 is success , 0 is failure

Definition at line 205 of file sg-dummy.c.

References burn_drive::bus_no, decode_btl_solaris(), libdax_messenger, LIBDAX_MSGS_PRIO_HIGH, LIBDAX_MSGS_SEV_DEBUG, libdax_msgs_submit(), sg_destroy_enumerator(), sg_give_next_adr(), sg_init_enumerator(), and sg_obtain_scsi_adr_fd().

Referenced by burn_drive_obtain_scsi_adr(), scsi_enumerate_drives(), and sg_open_scsi_siblings().

◆ sg_release()

int sg_release ( struct burn_drive d)

Gives up the drive for SCSI commands and releases eventual access locks. (Note: this is not physical tray locking.)

PORTING: Is mainly about the call to sg_close_drive() and whether it implements the demanded functionality. Gives up the drive for SCSI commands and releases eventual access locks. (Note: this is not physical tray locking.)

Definition at line 177 of file sg-dummy.c.

References mmc_function_spy(), burn_drive::released, and sg_close_drive().

Referenced by enumerate_common().

◆ sg_shutdown()

int sg_shutdown ( int  flag)

Performs global finalization of the SCSI transport adapter and eventually needed operating system facilities. Releases globally acquired resources.

Parameters
flagunused yet, submit 0
Returns
1 = success, <=0 = failure

Definition at line 92 of file sg-dummy.c.

Referenced by burn_finish().