libisoburn/og_src/libisoburn.h

379 lines
16 KiB
C

/*
API definition of libisoburn.
Copyright 2007 Vreixo Formoso Lopes <metalpain2002@yahoo.es>
and Thomas Schmitt <scdbackup@gmx.net>
*/
/**
libisoburn is a frontend for libraries libburn and libisofs which enables
creation and expansion of ISO-9660 filesystems on all CD/DVD media supported
by libburn. This includes media like DVD+RW, which do not support multi-session
management on media level and even plain disk files or block devices.
The price for that is thorough specialization on data files in ISO-9660
filesystem images. So libisoburn is not suitable for audio (CD-DA) or any
other CD layout which does not entirely consist of ISO-9660 sessions.
The priciple of this frontend is that you may use any call of libisofs or
libburn unless it has a isoburn_*() wrapper listed in the following function
documentation.
E.g. call isoburn_initialize() rather than iso_init(); burn_initialize()
and call isoburn_drive_scan_and_grab() rather than burn_drive_scan_and_grab().
But you may call burn_disc_get_profile() directly if you want to display
the media type.
>>>
>>> Take into respect Vreixo's (mandatory ?) shortcuts which are to come
>>>
The usage model is like with libburn: the target is a "media" in a "drive".
The wrappers will transparently provide the necessary emulations which
are appropriate for particular target "drives".
*/
/* API functions */
/** Initialize libisoburn, libisofs and libburn.
Wrapper for : iso_init() and burn_initialize()
@return 1 indicates success, 0 is failure
*/
int isoburn_initialize(void);
/** Aquire a target drive by its filesystem path resp. libburn persistent
address.
Wrapper for: burn_drive_scan_and_grab()
*/
int isoburn_drive_scan_and_grab(struct burn_drive_info *drive_infos[],
char* adr, int load);
/** Aquire a drive from the burn_drive_info[] array which was obtained by
a previous call of burn_drive_scan().
Wrapper for: burn_drive_grab()
*/
int isoburn_drive_grab(struct burn_drive *drive, int load);
/** Inquire the media status. Expect the whole spectrum of libburn BURN_DISC_*
with multi-session media. Emulated states with random access media are
BURN_DISC_BLANK and BURN_DISC_APPENDABLE.
Wrapper for: burn_disc_get_status()
*/
enum burn_disc_status isoburn_disc_get_status(struct burn_drive *drive);
/** Tells whether the media can be treated by isoburn_disc_erase().
Wrapper for: burn_disc_erasable()
*/
int isoburn_disc_erasable(struct burn_drive *d);
/** Mark the media as blank. With multi-session media this will call
burn_disc_erase(). With random access media, an eventual ISO-9660
filesystem will get invalidated by altering its start blocks on media.
In case of success, the media is in status BURN_DISC_BLANK afterwards.
Wrapper for: burn_disc_erase()
*/
void isoburn_disc_erase(struct burn_drive *drive, int fast);
/**
* Options for image reading.
*/
struct isoburn_read_opts {
unsigned int norock:1; /*< Do not read Rock Ridge extensions */
unsigned int nojoliet:1; /*< Do not read Joliet extensions */
unsigned int preferjoliet:1;
/*< When both Joliet and RR extensions are present, the RR
* tree is used. If you prefer using Joliet, set this to 1. */
uid_t uid; /**< Default uid when no RR */
gid_t gid; /**< Default uid when no RR */
mode_t mode; /**< Default mode when no RR (only permissions) */
/* modified by the function isoburn_read_volset */
unsigned int hasRR:1; /*< It will be set to 1 if RR extensions are present,
to 0 if not. */
unsigned int hasJoliet:1; /*< It will be set to 1 if Joliet extensions are
present, to 0 if not. */
uint32_t size; /**< Will be filled with the size (in 2048 byte block) of
* the image, as reported in the PVM. */
unsigned int pretend_blank:1; /* always create empty image */
};
/**
* Options for image generation by libisofs and image transport to libburn.
*/
struct isoburn_source_opts {
/* Options for image generation */
int level; /**< ISO level to write at. */
int flags; /**< Which extensions to support. */
int relaxed_constraints; /**< see ecma119_relaxed_constraints_flag */
unsigned int copy_eltorito:1;
/**<
* In multisession discs, select whether to copy el-torito catalog
* and boot image. Copy is needed for isolinux images, that need to
* be patched. However, it can lead to problems when the image is
* not present in the iso filesystem, because we can't figure out
* its size. In those cases, we only copy 1 block of data.
*/
unsigned int no_cache_inodes:1;
/**< If use inode caching or not. Set it to 1 to prevent
* inode caching.
* Usage of inode caching allows detection of hard-links,
* which contents are only written once to disc this way.
* Don't use inode caching in systems with non unique inodes
* per device.
*/
unsigned int sort_files:1;
/**< If files should be sorted based on their weight. */
unsigned int default_mode:1;
/**<
* The default values for files and directory permissions,
* gid and uid. This option can be overwritten when set
* one of the following.
* 0 to use useful values, 1 to use node modes (this are
* the same as filesystem ones if not changed after added
* to tree).
*/
unsigned int replace_dir_mode:1;
/**<
* When 1, permissions for all dirs will be replaced by the
* specified in dir_mode field.
*/
unsigned int replace_file_mode:1;
/**<
* When 1, permissions for all files will be replaced by the
* specified in file_mode field.
*/
unsigned int replace_uid:1;
/**<
* When 1, uid of all nodes (both files and dirs) will be
* replaced by the specified in uid field.
*/
unsigned int replace_gid:1;
/**<
* When 1, gid of all nodes (both files and dirs) will be
* replaced by the specified in gid field.
*/
mode_t dir_mode; /**< Mode to use on dirs when replace_dir_mode is set. */
mode_t file_mode; /**< Mode to use on files when replace_file_mode is set. */
gid_t gid; /**< gid to use when replace_gid is set. */
uid_t uid; /**< uid to use when replace_uid is set. */
char *input_charset; /**< NULL to use default charset */
char *ouput_charset; /**< NULL to use default charset */
/* Options for image transport */
/** The number of bytes to be used for the fifo which decouples libisofs
and libburn for better throughput and for reducing the risk of
interrupting signals hitting the libburn thread which operates the
MMC drive.
The size will be rounded up to the next full 2048.
Minimum is 64kiB, maximum is 1 GiB (but that is too much anyway).
*/
int fifo_size;
};
/** Load the ISO filesystem directory tree from the media in the given drive.
This will give libisoburn the base on which it can let libisofs perform
image growing or image modification. The loaded volset gets attached
to the drive object and handed out to the application.
Not a wrapper, but peculiar to libisoburn.
@param d The drive which holds an existing ISO filesystem or blank media.
d is allowed to be NULL which produces an empty ISO image. In
this case one has to call before writing isoburn_attach_volset()
with the volset from this call and with the intended output
drive.
@param read_opts The read options which can be chosen by the application
@param volset the volset that represents the image, if the disc is blank
it will have no files.
This reference needs to be released via iso_volset_free() when
it is not longer needed. The drive, if not NULL, will hold an
own reference which it will release when it gets a new volset
or when it gets released via isoburn_drive_release().
@return <=0 error , 1 = success
>>>>> error means damaged or unsupported image
error code is stored in ecma119_read_opts in libisofs
also error msgs are enqueued. Any need to pass them to usr? <<<<<<
*/
int isoburn_read_volset(struct burn_drive *d,
struct isoburn_read_opts *read_opts,
struct iso_volset **volset);
/** Attach a ISO filesystem directory tree to a drive. This eventually releases
the reference to the old volset attached to the drive.
Caution: Use with care. It hardly makes sense to replace a volset that
reflects a valid ISO image on media.
This call is rather intended for writing a newly created and populated
image to blank media. The use case in xorriso is to let a volset survive
the change or demise of the outdev target drive.
@param d The drive which shall be write target of the volset.
@param volset The volset that represents the image to be written.
This volset pointer MUST already be a valid reference suitable
for iso_volset_free().
It may have been obtained by appropriate libisofs calls or by
isoburn_read_volset() with d==NULL.
@return <=0 error , 1 = success
*/
int isoburn_attach_volset(struct burn_drive *d, struct iso_volset *volset);
/** Obtain the start block number of the most recent session on media. In
case of random access media this will always be 0. Succesfull return is
not a guarantee that there is a ISO-9660 image at all. The call will fail,
nevertheless,if isoburn_disc_get_status() returns not BURN_DISC_APPENDABLE.
Wrapper for: burn_disc_get_msc1()
*/
int isoburn_disc_get_msc1(struct burn_drive *d, int *start_lba);
/** Use this with trackno==0 to obtain the predicted start block number of the
new session. The interesting number is returned in parameter nwa.
Wrapper for: burn_disc_track_lba_nwa()
*/
int isoburn_disc_track_lba_nwa(struct burn_drive *d, struct burn_write_opts *o,
int trackno, int *lba, int *nwa);
/** Obtain the size which was attributed to an emulated appendable on actually
overwriteable media. This value is supposed to be <= 2048 * nwa as of
isoburn_disc_track_lba_nwa().
@param drive The drive holding the media.
@param start_byte The reply value counted in bytes, not in sectors.
@param flag Unused yet. Submit 0.
@return 1=stat_byte is valid, 0=not an emulated appendable, -1=error
*/
int isoburn_get_min_start_byte(struct burn_drive *d, off_t *start_byte,
int flag);
/** Create a disc object for writing the new session from the created or loaded
iso_volset which has been manipulated via libisofs, to the same media from
where the image was eventually loaded. This struct burn_disc is ready for
use by a subsequent call to isoburn_disc_write().
After this asynchronous writing has ended and the drive is BURN_DRIVE_IDLE
again, the burn_disc object has to be disposed by burn_disc_free().
@param drive The combined source and target drive, grabbed with
isoburn_drive_scan_and_grab(). .
@param disc Returns the newly created burn_disc object.
@return <=0 error , 1 = success
*/
int isoburn_prepare_disc(struct burn_drive *d, struct burn_disc **disc,
struct isoburn_source_opts *opts);
/** Create a disc object for producing a new image from a previous image
plus the changes made by user. The generated burn_disc is suitable
to be written to any other libburn drive. You must not use the same drive
for writing as you are using here as source, because data will be
read from the source drive while the target drive gets written to.
The resulting burn_disc object has to be disposed when all its writing
is done and the drive is BURN_DRIVE_IDLE again after asynchronous
burn_disc_write().
@param d The source drive, grabbed with isoburn_drive_scan_and_grab().
@param disc Returns the newly created burn_disc object.
@return <=0 error , 1 = success
*/
int isoburn_prepare_new_image(struct burn_drive *d, struct burn_disc **disc,
struct isoburn_source_opts *opts);
/** Start writing of the new session.
This call is asynchrounous. I.e. it returns quite soon and the progress has
to be watched by a loop with call burn_drive_get_status() until
BURN_DRIVE_IDLE is returned.
Wrapper for: burn_disc_write()
*/
void isoburn_disc_write(struct burn_write_opts *o, struct burn_disc *disc);
/** Inquire state and fill parameters of the fifo which is attached to
the emerging track. This should be done in the pacifier loop while
isoburn_disc_write() or burn_disc_write() are active.
Hint: If only burn_write_opts and not burn_drive is known, then the drive
can be obtained by burn_write_opts_get_drive().
@parm d The drive to which the track with the fifo gets burned.
@param size The total size of the fifo
@param free_bytes The current free capacity of the fifo
@param status_text Returns a pointer to a constant text, see below
@return <0 reply invalid, >=0 fifo status code:
bit0+1=input status, bit2=consumption status, i.e:
0="standby" : data processing not started yet
1="active" : input and consumption are active
2="ending" : input has ended without error
3="failing" : input had error and ended,
4="unused" : ( consumption has ended before processing start )
5="abandoned" : consumption has ended prematurely
6="ended" : consumption has ended without input error
7="aborted" : consumption has ended after input error
*/
int isoburn_get_fifo_status(struct burn_drive *d, int *size, int *free_bytes,
char **status_text);
/** Inquire whether the most recent write run was successful.
Wrapper for: burn_drive_wrote_well()
*/
int isoburn_drive_wrote_well(struct burn_drive *d);
/** Call this after isoburn_disc_write has finished and burn_drive_wrote_well()
indicates success. It will eventually complete the emulation of
multi-session functionality, if needed at all. Let libisoburn decide.
Not a wrapper, but peculiar to libisoburn.
*/
int isoburn_activate_session(struct burn_drive *drive);
/** Write a new session to a disc.
This is a synchronous call equivalent to isoburn_prepare_disc +
isoburn_disc_write + isoburn_activate_session
@param pacifier_func If not NULL: a function to produce appeasing messages.
See burn_abort_pacifier() in libburn.h for an example.
*/
/* TODO implement this */
int isoburn_perform_write(struct burn_write_opts *o,
int (*pacifier_func)(void *handle, int patience,
int elapsed));
/** Release an aquired drive.
Wrapper for: burn_drive_release()
*/
void isoburn_drive_release(struct burn_drive *drive, int eject);
/** Shutdown all three libraries.
Wrapper for : iso_finish() and burn_finish().
*/
void isoburn_finish(void);
/*
The following two calls are for expert applications only.
An application should have a special reason to use them.
*/
/** Inquire wether the media needs emulation or would be suitable for
generic multi-session via libburn.
@return 0 is generic multi-session
1 is emulated multi-session
-1 is not suitable for isoburn
*/
int isoburn_needs_emulation(struct burn_drive *drive);