Changes in plans as discussed up to Sep 5 2007

This commit is contained in:
Thomas Schmitt 2007-09-05 19:56:30 +00:00
parent 9737650fae
commit 7d53b43a3a
4 changed files with 80 additions and 135 deletions

View File

@ -53,15 +53,26 @@ static int isoburn_welcome_media(struct isoburn **o, struct burn_drive *d,
ret= burn_disc_get_multi_caps(d, BURN_WRITE_NONE, &caps, 0); ret= burn_disc_get_multi_caps(d, BURN_WRITE_NONE, &caps, 0);
if(ret<=0) if(ret<=0)
goto ex; goto ex;
ret= isoburn_new(o, 0);
if(ret<=0)
goto ex;
(*o)->drive= d;
if(caps->start_adr) { /* set emulation to overwriteable */ if(caps->start_adr) { /* set emulation to overwriteable */
ret= isoburn_new(o, 0);
if(ret<=0)
goto ex;
(*o)->emulation_mode= 1; (*o)->emulation_mode= 1;
(*o)->drive= d;
ret= isoburn_start_emulation(*o, 0); ret= isoburn_start_emulation(*o, 0);
if(ret<=0) if(ret<=0) {
(*o)->emulation_mode= -1;
goto ex; goto ex;
}
} else {
/* >>> recognize unsuitable media */;
}
ret = isoburn_read_volset(*o);
if(ret<=0) {
(*o)->emulation_mode= -1;
goto ex;
} }
ret= 1; ret= 1;
ex: ex:
@ -72,48 +83,69 @@ ex:
int isoburn_drive_scan_and_grab(struct burn_drive_info *drive_infos[], int isoburn_drive_scan_and_grab(struct burn_drive_info *drive_infos[],
char* adr, int load) char *adr, int load)
{ {
int ret; int ret, treatment= 0;
struct stat stbuf; struct stat stbuf;
char libburn_drive_adr[BURN_DRIVE_ADR_LEN]; char libburn_drive_adr[BURN_DRIVE_ADR_LEN], *adrpt, *stdio_adr= NULL;
struct isoburn *o= NULL; struct isoburn *o= NULL;
ret= burn_drive_convert_fs_adr(adr, libburn_drive_adr); adrpt= adr;
if(ret<0) if(strncmp(adr, "grow:", 5)==0) {
return(ret); treatment= 1;
if(ret==0) { adrpt+= 5;
if(stat(adr,&stbuf)!=-1) { if(stat(adrpt,&stbuf)!=-1)
if(S_ISREG(stbuf.st_mode) || S_ISBLK(stbuf.st_mode)) { if(S_ISREG(stbuf.st_mode) || S_ISBLK(stbuf.st_mode)) {
ret= burn_drive_grab_dummy(drive_infos, adr); stdio_adr= calloc(strlen(adrpt)+6+1, 1);
if(ret<=0) if(stdio_adr==NULL)
return(ret); {ret= -1; goto ex;}
o->emulation_mode= 2; /* standard i/o */ sprintf(stdio_adr, "stdio:%s", adrpt); /* use pseudo-drive */
} else { adrpt= stdio_adr;
/* >>> unsuitable file type */;
return(0);
} }
} else { } else if(strncmp(adr, "modify:", 7)==0) {
treatment= 2;
adrpt+= 7;
}
ret= burn_drive_convert_fs_adr(adrpt, libburn_drive_adr);
if(treatment==0) {
if(ret>0)
treatment= 1;
else
treatment= 2;
} else if(treatment==1 && ret<=0) {
/* >>> file not found */; /* >>> unsuitable media */;
return(0); ret= 0; goto ex;
} }
} else { o->treatment= treatment;
ret= burn_drive_scan_and_grab(drive_infos, adr, load);
if(treatment==1) {
ret= burn_drive_scan_and_grab(drive_infos, adrpt, load);
if(ret<=0) if(ret<=0)
goto ex; goto ex;
ret= isoburn_welcome_media(&o, (*drive_infos)[0].drive, 0); ret= isoburn_welcome_media(&o, (*drive_infos)[0].drive, 0);
if(ret<=0) if(ret<=0)
goto ex; goto ex;
} else {
if(stat(adrpt,&stbuf)!=-1)
if(! S_ISREG(stbuf.st_mode)) {
/* >>> unsuitable target for modify */;
ret= 0; goto ex;
}
/* >>> welcome file for modfication treatment */;
} }
ret= 1; ret= 1;
ex: ex:
if(ret<=0) if(ret<=0)
isoburn_destroy(&o,0); isoburn_destroy(&o,0);
if(stdio_adr!=NULL)
free(stdio_adr);
return(ret); return(ret);
} }
@ -237,98 +269,22 @@ int isoburn_disc_track_lba_nwa(struct burn_drive *d,
void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc) void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
{ {
int ret, multi= 1;
struct isoburn *o;
struct burn_drive *drive;
drive= burn_write_opts_get_drive(opts);
ret= isoburn_find_emulator(&o, drive, 0);
if(ret<0)
return;
if(o!=NULL)
if(o->emulation_mode!=0)
multi= 0;
burn_write_opts_set_multi(opts, multi);
burn_disc_write(opts, disc); burn_disc_write(opts, disc);
} }
#ifdef NIX
int isoburn_random_access_write(struct burn_drive *d, off_t byte_address,
char *data, off_t data_count, int flag)
{
int ret, mode = O_RDWR | O_LARGEFILE | O_CREAT;
struct isoburn *o;
ret= isoburn_find_emulator(&o, d, 0);
if(ret<0)
return(0);
if(o->emulation_mode==2) {
if(flag&1)
mode|= O_SYNC;
o->stdio_fd= open(o->stdio_path, mode);
if(o->stdio_fd==-1) {
/* >>> cannot open stdio_path */;
return(0);
}
if(lseek(o->stdio_fd, byte_address, SEEK_SET)==-1) {
/* >>> cannot reach given byte_address */;
ret= 0; goto close_stdio;
}
if(write(o->stdio_fd, data, data_count) != data_count) {
/* >>> cannot write desired number of bytes */;
ret= 0; goto close_stdio;
}
ret= 1;
close_stdio:;
close(o->stdio_fd); o->stdio_fd= -1;
} else if(o->emulation_mode==-1)
ret= 0;
else
ret= burn_random_access_write(d, byte_address, data, data_count, flag);
return(ret);
}
int burn_read_data(struct burn_drive *d, off_t byte_address,
char data[], off_t data_size, off_t *data_count, int flag)
{
int ret, mode = O_RDONLY | O_LARGEFILE;
off_t count, todo;
struct isoburn *o;
ret= isoburn_find_emulator(&o, d, 0);
if(ret<0)
return(0);
if(o->emulation_mode==2) {
o->stdio_fd= open(o->stdio_path, mode);
if(o->stdio_fd==-1) {
/* >>> cannot open stdio_path */;
return(0);
}
if(lseek(o->stdio_fd, byte_address, SEEK_SET)==-1) {
/* >>> cannot reach given byte_address */;
ret= 0; goto close_stdio;
}
for(todo= data_size; todo>0; ) {
count= read(o->stdio_fd, data+(data_size-todo), todo);
if(count<=0)
break;
todo-= count;
}
if(todo>0) {
/* >>> cannot read desired number of bytes */;
ret= 0; goto close_stdio;
}
ret= 1;
close_stdio:;
close(o->stdio_fd); o->stdio_fd= -1;
} else if(o->emulation_mode==-1)
ret= 0;
else
ret= burn_read_data(d, byte_address, data, data_size, data_count, flag);
return(ret);
}
#endif /* NIX */
void isoburn_drive_release(struct burn_drive *drive, int eject) void isoburn_drive_release(struct burn_drive *drive, int eject)
{ {
int ret; int ret;
@ -380,7 +336,7 @@ void isoburn_write_opts_set_start_byte(struct burn_write_opts *opts,
drive= burn_write_opts_get_drive(opts); drive= burn_write_opts_get_drive(opts);
ret= isoburn_find_emulator(&o, drive, 0); ret= isoburn_find_emulator(&o, drive, 0);
if(ret<=0) if(ret<=0) /* no emulation, no burn_write_opts_set_start_byte() */
goto ex; goto ex;
ret= burn_disc_get_multi_caps(drive, BURN_WRITE_NONE, &caps, 0); ret= burn_disc_get_multi_caps(drive, BURN_WRITE_NONE, &caps, 0);
if(ret<=0) if(ret<=0)

View File

@ -49,12 +49,7 @@ int isoburn_new(struct isoburn **objpt, int flag)
o->emulation_mode= 0; o->emulation_mode= 0;
o->min_start_byte= 0; o->min_start_byte= 0;
o->nwa= 0; o->nwa= 0;
o->treatment= 1;
#ifdef NIX
o->stdio_path= NULL;
o->stdio_fd= -1;
#endif /* NIX */
o->target_ropts= NULL; o->target_ropts= NULL;
o->new_wopts= NULL; o->new_wopts= NULL;
for(i=0;i<65536;i++) for(i=0;i<65536;i++)

View File

@ -25,7 +25,6 @@ struct isoburn {
/* -1= inappropriate media state detected */ /* -1= inappropriate media state detected */
/* 0= libburn multi-session media, resp. undecided yet */ /* 0= libburn multi-session media, resp. undecided yet */
/* 1= random access media */ /* 1= random access media */
/* 2= standard i/o file */
int emulation_mode; int emulation_mode;
/* Although rarely used, libburn can operate on several */ /* Although rarely used, libburn can operate on several */
@ -44,18 +43,12 @@ struct isoburn {
/* Aligned start address to be used for processing (counted in blocks) */ /* Aligned start address to be used for processing (counted in blocks) */
int nwa; int nwa;
#ifdef NIX
/* Path for eventual stdandard i/o (see .emulation_mode) */
char *stdio_path;
/* File descriptor for stdandard i/o. Points to stdio_path object if not -1 */
int stdio_fd;
#endif /* NIX */
/* --- Vreixo's part --- */ /* --- Vreixo's part --- */
/* Expansion treatment strategy: 1= grow, 2= modify, (any use for 0 ?) */
int treatment;
/* The options for reading the old image. */ /* The options for reading the old image. */
/* target_ropts.size will contain the number of blocks of the image. */ /* target_ropts.size will contain the number of blocks of the image. */
struct ecma119_read_opts *target_ropts; struct ecma119_read_opts *target_ropts;
@ -101,6 +94,7 @@ int isoburn_start_emulation(struct isoburn *o, int flag);
int isoburn_new_rwopts(struct isoburn *o); int isoburn_new_rwopts(struct isoburn *o);
int isoburn_free_rwopts(struct isoburn *o); int isoburn_free_rwopts(struct isoburn *o);
int isoburn_invalidate_iso(struct isoburn *o, int flag); int isoburn_invalidate_iso(struct isoburn *o, int flag);
int isoburn_read_volset(struct isoburn *o);
#endif /* Isoburn_includeD */ #endif /* Isoburn_includeD */

View File

@ -104,7 +104,7 @@ int isoburn_disc_track_lba_nwa(struct burn_drive *d, struct burn_write_opts *o,
BURN_DRIVE_IDLE is returned. BURN_DRIVE_IDLE is returned.
Wrapper for: burn_disc_write() Wrapper for: burn_disc_write()
*/ */
int isoburn_disc_write(struct burn_write_opts *o, struct burn_disc *disc); void isoburn_disc_write(struct burn_write_opts *o, struct burn_disc *disc);
/** Call this after isoburn_disc_write has finished and burn_drive_wrote_well() /** Call this after isoburn_disc_write has finished and burn_drive_wrote_well()
@ -112,7 +112,7 @@ int isoburn_disc_write(struct burn_write_opts *o, struct burn_disc *disc);
multi-session functionality, if needed at all. Let libisoburn decide. multi-session functionality, if needed at all. Let libisoburn decide.
Not a wrapper, but peculiar to libburn. Not a wrapper, but peculiar to libburn.
*/ */
int isoburn_update_iso_descriptors(struct burn_drive *drive); int isoburn_activate_session(struct burn_drive *drive);
/** Release an aquired drive. /** Release an aquired drive.