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.
![]() ![]() |
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <string.h>
#include <sys/poll.h>
#include <camlib.h>
#include <cam/scsi/scsi_message.h>
#include <cam/scsi/scsi_pass.h>
#include <err.h>
#include <sys/statvfs.h>
#include "transport.h"
#include "drive.h"
#include "sg.h"
#include "spc.h"
#include "mmc.h"
#include "sbc.h"
#include "debug.h"
#include "toc.h"
#include "util.h"
#include "libdax_msgs.h"
Go to the source code of this file.
Functions | |
int | burn_drive_is_banned (char *device_address) |
static int | sg_init_enumerator (burn_drive_enumerator_t *idx) |
static int | sg_next_enumeration_buffer (burn_drive_enumerator_t *idx) |
static int | sg_close_drive (struct burn_drive *d) |
static void | enumerate_common (char *fname, int bus_no, int host_no, int channel_no, int target_no, int lun_no) |
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) |
int | sg_give_next_adr (burn_drive_enumerator_t *idx, char adr[], int adr_size, int initialize) |
int | scsi_enumerate_drives (void) |
int | sg_drive_is_open (struct burn_drive *d) |
int | sg_grab (struct burn_drive *d) |
int | sg_release (struct burn_drive *d) |
int | sg_issue_command (struct burn_drive *d, struct command *c) |
int | sg_obtain_scsi_adr (char *path, int *bus_no, int *host_no, int *channel_no, int *target_no, int *lun_no) |
int | sg_is_enumerable_adr (char *adr) |
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 | burn_os_open_track_src (char *path, int open_flags, int flag) |
void * | burn_os_alloc_buffer (size_t amount, int flag) |
int | burn_os_free_buffer (void *buffer, size_t amount, int flag) |
Variables | |
struct libdax_msgs * | libdax_messenger |
int burn_drive_is_banned | ( | char * | device_address | ) |
Definition at line 1723 of file drive.c.
Referenced by scsi_enumerate_drives().
void* burn_os_alloc_buffer | ( | size_t | amount, |
int | flag | ||
) |
Allocate a memory area that is suitable for reading with a file descriptor opened by burn_os_open_track_src().
amount | Number of bytes to allocate. This should be a multiple of the operating system's i/o block size. 32 KB is guaranteed by libburn to be safe. |
flag | Bitfield for control purposes (unused yet, submit 0). |
Definition at line 814 of file sg-freebsd-port.c.
int burn_os_free_buffer | ( | void * | buffer, |
size_t | amount, | ||
int | flag | ||
) |
Dispose a memory area which was obtained by burn_os_alloc_buffer(),
buffer | Memory address to be freed. |
amount | The number of bytes which was allocated at that address. |
flag | Bitfield for control purposes (unused yet, submit 0). |
Definition at line 823 of file sg-freebsd-port.c.
int burn_os_is_2k_seekrw | ( | char * | path, |
int | flag | ||
) |
Definition at line 678 of file sg-freebsd-port.c.
int burn_os_open_track_src | ( | char * | path, |
int | open_flags, | ||
int | flag | ||
) |
Opens a file with eventual acceleration preparations which may depend on the operating system and on compile time options of libburn. You may use this call instead of open(2) for opening file descriptors which shall be handed to burn_fd_source_new(). This should only be done for tracks with BURN_BLOCK_MODE1 (2048 bytes per block).
If you use this call then you MUST allocate the buffers which you use with read(2) by call burn_os_alloc_buffer(). Read sizes MUST be a multiple of a safe buffer amount. Else you risk that track data get altered during transmission. burn_disk_write() will allocate a suitable read/write buffer for its own operations. A fifo created by burn_fifo_source_new() will allocate suitable memory for its buffer if called with flag bit0 and a multiple of a safe buffer amount.
path | The file address to open |
open_flags | The flags as of man 2 open. Normally just O_RDONLY. |
flag | Bitfield for control purposes (unused yet, submit 0). |
Definition at line 805 of file sg-freebsd-port.c.
int burn_os_stdio_capacity | ( | char * | path, |
off_t | write_start, | ||
off_t * | bytes | ||
) |
Estimate the potential payload capacity of a file address.
path | The address of the file to be examined. If it does not exist yet, then the directory will be inquired. |
bytes | This value gets modified if an estimation is possible |
Definition at line 725 of file sg-freebsd-port.c.
References BURN_ALLOC_MEM, BURN_FREE_MEM, burn_sg_open_o_excl, and burn_sparse_file_addsize().
|
static |
Wraps a detected drive into libburn structures and hands it over to libburn drive list.
Definition at line 240 of file sg-freebsd-port.c.
References burn_drive_finish_enum(), burn_scsi_setup_drive(), burn_setup_drive(), burn_drive::bus_no, burn_drive::drive_is_open, burn_drive::grab, burn_drive::issue_command, burn_drive::release, sg_drive_is_open(), sg_grab(), sg_issue_command(), and sg_release().
Referenced by scsi_enumerate_drives().
int scsi_enumerate_drives | ( | void | ) |
Brings all available, not-whitelist-banned, and accessible drives into libburn's list of drives.
Definition at line 425 of file sg-freebsd-port.c.
References burn_drive_is_banned(), enumerate_common(), and sg_give_next_adr().
|
static |
Definition at line 219 of file sg-freebsd-port.c.
Referenced by sg_issue_command(), and sg_release().
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.
d | the drive to be finalized |
flag | unused yet, submit 0 |
Definition at line 329 of file sg-freebsd-port.c.
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 452 of file sg-freebsd-port.c.
Referenced by enumerate_common().
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 latter.)
idx | An opaque handle. Make no own theories about it. |
adr | Takes the reply |
adr_size | Gives maximum size of reply including final 0 |
initialize | 1 = start new, 0 = continue, use no other values for now -1 = finish |
Definition at line 350 of file sg-freebsd-port.c.
References sg_init_enumerator(), and sg_next_enumeration_buffer().
Referenced by scsi_enumerate_drives(), sg_is_enumerable_adr(), and sg_obtain_scsi_adr().
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 464 of file sg-freebsd-port.c.
References burn_drive::devname, burn_drive::global_index, libdax_messenger, LIBDAX_MSGS_PRIO_HIGH, LIBDAX_MSGS_SEV_SORRY, libdax_msgs_submit(), and burn_drive::released.
Referenced by enumerate_common().
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.
msg | returns id string |
flag | unused yet, submit 0 |
Definition at line 289 of file sg-freebsd-port.c.
Referenced by sg_initialize().
|
static |
Definition at line 157 of file sg-freebsd-port.c.
Referenced by sg_give_next_adr().
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.
msg | returns ids and/or error messages of eventual helpers |
flag | unused yet, submit 0 |
Definition at line 303 of file sg-freebsd-port.c.
References sg_id_string().
int sg_is_enumerable_adr | ( | char * | adr | ) |
Tells whether a text is a persistent address as listed by the enumeration functions.
Definition at line 653 of file sg-freebsd-port.c.
References sg_give_next_adr().
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.
Definition at line 512 of file sg-freebsd-port.c.
References BUFFER_SIZE, BURN_DRIVE_IDLE, burn_drive::busy, buffer::bytes, buffer::data, command::dir, command::dxfer_len, command::error, FAIL, FROM_DRIVE, burn_drive::global_index, libdax_messenger, LIBDAX_MSGS_PRIO_HIGH, LIBDAX_MSGS_SEV_FATAL, libdax_msgs_submit(), NO_TRANSFER, command::opcode, command::oplen, command::page, burn_drive::released, RETRY, command::retry, scsi_error(), command::sense, command::sense_len, sg_close_drive(), spc_register_retry(), and TO_DRIVE.
Referenced by enumerate_common().
|
static |
Definition at line 197 of file sg-freebsd-port.c.
Referenced by sg_give_next_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.
Definition at line 621 of file sg-freebsd-port.c.
References sg_give_next_adr().
int sg_release | ( | struct burn_drive * | d | ) |
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 494 of file sg-freebsd-port.c.
References sg_close_drive().
Referenced by enumerate_common().
int sg_shutdown | ( | int | flag | ) |
Performs global finalization of the SCSI transport adapter and eventually needed operating system facilities. Releases globally acquired resources.
flag | unused yet, submit 0 |
Definition at line 314 of file sg-freebsd-port.c.
|
extern |
PORTING : ----— OS dependent headers and definitions ---— PORTING : ---— libburn portable headers and definitions --—
Definition at line 42 of file init.c.
Referenced by sg_grab(), and sg_issue_command().