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-freebsd-port.c File Reference
#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"
Include dependency graph for sg-freebsd-port.c:

Go to the source code of this file.


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)


struct libdax_msgs * libdax_messenger

Function Documentation

◆ burn_drive_is_banned()

int burn_drive_is_banned ( char *  device_address)

Definition at line 1723 of file drive.c.

Referenced by scsi_enumerate_drives().

◆ burn_os_alloc_buffer()

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().

amountNumber 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.
flagBitfield for control purposes (unused yet, submit 0).
The address of the allocated memory, or NULL on failure. A non-NULL return value has finally to be disposed via burn_os_free_buffer().

Definition at line 814 of file sg-freebsd-port.c.

◆ burn_os_free_buffer()

int burn_os_free_buffer ( void *  buffer,
size_t  amount,
int  flag 

Dispose a memory area which was obtained by burn_os_alloc_buffer(),

bufferMemory address to be freed.
amountThe number of bytes which was allocated at that address.
flagBitfield for control purposes (unused yet, submit 0).
1 success , <=0 failure

Definition at line 823 of file sg-freebsd-port.c.

◆ burn_os_is_2k_seekrw()

int burn_os_is_2k_seekrw ( char *  path,
int  flag 

Definition at line 678 of file sg-freebsd-port.c.

◆ burn_os_open_track_src()

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.

pathThe file address to open
open_flagsThe flags as of man 2 open. Normally just O_RDONLY.
flagBitfield for control purposes (unused yet, submit 0).
A file descriptor as of open(2). Finally to be disposed by close(2). -1 indicates failure.

Definition at line 805 of file sg-freebsd-port.c.

◆ 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.

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
-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 725 of file sg-freebsd-port.c.

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

◆ enumerate_common()

static void enumerate_common ( char *  fname,
int  bus_no,
int  host_no,
int  channel_no,
int  target_no,
int  lun_no 

◆ 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().

◆ sg_close_drive()

static int sg_close_drive ( struct burn_drive d)

Definition at line 219 of file sg-freebsd-port.c.

Referenced by sg_issue_command(), and sg_release().

◆ 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.

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

Definition at line 329 of file sg-freebsd-port.c.

◆ 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 452 of file sg-freebsd-port.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 latter.)

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
1 = reply is a valid address , 0 = no further address available -1 = severe error (e.g. adr_size too small)

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().

◆ 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 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().

◆ 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.

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

Definition at line 289 of file sg-freebsd-port.c.

Referenced by sg_initialize().

◆ sg_init_enumerator()

static int sg_init_enumerator ( burn_drive_enumerator_t idx)

Definition at line 157 of file sg-freebsd-port.c.

Referenced by sg_give_next_adr().

◆ 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.

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

Definition at line 303 of file sg-freebsd-port.c.

References sg_id_string().

◆ sg_is_enumerable_adr()

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().

◆ 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.

: 1 success , <=0 failure

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().

◆ sg_next_enumeration_buffer()

static int sg_next_enumeration_buffer ( burn_drive_enumerator_t idx)

Definition at line 197 of file sg-freebsd-port.c.

Referenced by sg_give_next_adr().

◆ 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.

1 is success , 0 is failure

Definition at line 621 of file sg-freebsd-port.c.

References sg_give_next_adr().

◆ sg_release()

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().

◆ 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.

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

Definition at line 314 of file sg-freebsd-port.c.

Variable Documentation

◆ libdax_messenger

struct libdax_msgs* libdax_messenger

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().