New API call isoburn_attach_volset(), changes with isoburn_read_volset()

This commit is contained in:
Thomas Schmitt 2007-11-14 14:26:32 +00:00
parent b23b454de6
commit 1fd3c2b7f4
5 changed files with 81 additions and 39 deletions

View File

@ -220,7 +220,7 @@ int isoburn_find_by_drive(struct isoburn **pt, struct burn_drive *d, int flag)
struct isoburn *o;
*pt= NULL;
for(o= isoburn_list_start;o!=NULL;o= o->prev)
for(o= isoburn_list_start;o!=NULL;o= o->next)
if(o->drive==d) {
*pt= o;
return(1);

View File

@ -7,6 +7,7 @@
libisofs related functions of libisoburn.
Copyright 2007 Vreixo Formoso Lopes <metalpain2002@yahoo.es>
Thomas Schmitt <scdbackup@gmx.net>
*/
#include <stdlib.h>
@ -69,6 +70,7 @@ uint32_t iso_read_lsb(const uint8_t *buf, int bytes)
return ret;
}
/* API function. See libisoburn.h
*/
int isoburn_read_volset(struct burn_drive *d,
@ -77,26 +79,29 @@ int isoburn_read_volset(struct burn_drive *d,
{
int ret;
struct ecma119_read_opts ropts;
enum burn_disc_status status;
struct isoburn *o;
enum burn_disc_status status= BURN_DISC_BLANK;
struct isoburn *o= NULL;
if(d==NULL || read_opts==NULL || volset==NULL) {
if(read_opts==NULL || volset==NULL) {
/* >>> program error */;
return(-1);
}
ret = isoburn_find_emulator(&o, d, 0);
if (ret < 0)
return 0;
if (!o) {
return -1;
if(d != NULL) {
ret = isoburn_find_emulator(&o, d, 0);
if (ret < 0)
return 0;
if (o == NULL) {
return -1;
}
status = isoburn_disc_get_status(d);
if(o->target_volset != NULL)
iso_volset_free(o->target_volset);
o->target_volset= NULL;
}
status = isoburn_disc_get_status(d);
if (status == BURN_DISC_BLANK) {
if (d == NULL || status == BURN_DISC_BLANK || read_opts->pretend_blank) {
struct iso_volume *volume;
struct iso_tree_node_dir *root;
@ -116,8 +121,10 @@ int isoburn_read_volset(struct burn_drive *d,
if (!*volset)
return -1;
o->target_volset = *volset;
iso_volset_ref(o->target_volset); /* protects object from premature free */
if(o!=NULL) {
o->target_volset = *volset;
iso_volset_ref(o->target_volset); /*protects object from premature free*/
}
return 1;
}
@ -152,6 +159,27 @@ int isoburn_read_volset(struct burn_drive *d,
}
/* API function. See libisoburn.h
*/
int isoburn_attach_volset(struct burn_drive *d, struct iso_volset *volset)
{
int ret;
struct isoburn *o;
if (volset == NULL)
return -1;
ret = isoburn_find_emulator(&o, d, 0);
if (ret < 0)
return 0;
if (o == NULL)
return -1;
if(o->target_volset != NULL)
iso_volset_free(o->target_volset);
o->target_volset = volset;
return(1);
}
/* API function. See libisoburn.h
*/
int isoburn_activate_session(struct burn_drive *drive)
@ -170,7 +198,7 @@ int isoburn_activate_session(struct burn_drive *drive)
return 1;
ret = burn_random_access_write(drive, 0, (char*)o->target_iso_head,
64*2048, 1);
32*2048, 1);
return ret;
}

View File

@ -104,6 +104,7 @@ struct isoburn_read_opts {
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 */
};
/**
@ -189,21 +190,48 @@ struct isoburn_source_opts {
/** 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 is not publicly available.
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
@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 blacnk
it will have no files
@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,
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,
@ -348,19 +376,3 @@ void isoburn_finish(void);
int isoburn_needs_emulation(struct burn_drive *drive);
#ifdef Libburn_obsoleted_on_its_way_ouT
/** Caution: Use this with great care. It is not needed normally.
This call can set the nwa block number to an arbitrary value. If ever, do
this before preparing the session by libisofs. The drive must be grabbed,
though. This overrides the automated address computation. Call
isoburn_disc_track_lba_nwa() afterwards to learn the effective new
address which might be somewhat higher than set by parameter value.
Wrapper for: burn_write_opts_set_start_byte (if ever)
*/
void isoburn_write_opts_set_start_byte(struct burn_write_opts *opts,
off_t value);
#endif /* Libburn_obsoleted_on_its_way_ouT */

View File

@ -202,12 +202,14 @@ int main(int argc, char **argv)
}
/* fill read opts */
memset(&ropts, sizeof(ropts), 0);
ropts.norock = 0;
ropts.nojoliet = 0;
ropts.preferjoliet = 0;
ropts.uid = 0;
ropts.gid = 0;
ropts.mode = 0555;
ropts.pretend_blank= 0;
if (isoburn_read_volset(drive, &ropts, &volset) <= 0) {
fprintf(stderr, "Can't read volset\n");

View File

@ -1 +1 @@
#define Xorriso_timestamP "2007.11.11.154453"
#define Xorriso_timestamP "2007.11.14.142904"