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-dummy.c File Reference
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <string.h>
#include <stdlib.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 "init.h"
#include "libdax_msgs.h"
Include dependency graph for sg-dummy.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define O_BINARY   0
 

Functions

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
 

Macro Definition Documentation

◆ O_BINARY

#define O_BINARY   0

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

Function Documentation

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

Parameters
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).
Returns
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().
Since
0.7.4

Definition at line 343 of file sg-dummy.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(),

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

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

◆ burn_os_is_2k_seekrw()

int burn_os_is_2k_seekrw ( char *  path,
int  flag 
)

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

Referenced by burn_drive__is_rdwr().

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

Parameters
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).
Returns
A file descriptor as of open(2). Finally to be disposed by close(2). -1 indicates failure.
Since
0.7.4

Definition at line 334 of file sg-dummy.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.

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

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

References BURN_ALLOC_MEM, burn_sparse_file_addsize(), 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.

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

References libdax_messenger, LIBDAX_MSGS_PRIO_HIGH, LIBDAX_MSGS_SEV_WARNING, and libdax_msgs_submit().

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

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

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

Referenced by burn_drive_convert_scsi_adr(), and burn_drive_find_devno().

◆ 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_drive::global_index, libdax_messenger, LIBDAX_MSGS_PRIO_HIGH, LIBDAX_MSGS_SEV_FAILURE, and libdax_msgs_submit().

◆ 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

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

References sg_id_string().

Referenced by burn_initialize().

◆ 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 219 of file sg-dummy.c.

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

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

References burn_drive::global_index, libdax_messenger, LIBDAX_MSGS_PRIO_HIGH, LIBDAX_MSGS_SEV_FAILURE, and libdax_msgs_submit().

◆ 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

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

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

Referenced by burn_drive_obtain_scsi_adr().

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

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

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

Variable Documentation

◆ libdax_messenger

struct libdax_msgs* libdax_messenger
extern

Definition at line 42 of file init.c.

Referenced by scsi_enumerate_drives(), sg_grab(), sg_issue_command(), and sg_obtain_scsi_adr().