Changes in plans as discussed up to Sep 5 2007

This commit is contained in:
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);
if(ret<=0)
goto ex;
ret= isoburn_new(o, 0);
if(ret<=0)
goto ex;
(*o)->drive= d;
if(caps->start_adr) { /* set emulation to overwriteable */
ret= isoburn_new(o, 0);
if(ret<=0)
goto ex;
(*o)->emulation_mode= 1;
(*o)->drive= d;
ret= isoburn_start_emulation(*o, 0);
if(ret<=0)
if(ret<=0) {
(*o)->emulation_mode= -1;
goto ex;
}
} else {
/* >>> recognize unsuitable media */;
}
ret = isoburn_read_volset(*o);
if(ret<=0) {
(*o)->emulation_mode= -1;
goto ex;
}
ret= 1;
ex:
@@ -72,48 +83,69 @@ ex:
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;
char libburn_drive_adr[BURN_DRIVE_ADR_LEN];
char libburn_drive_adr[BURN_DRIVE_ADR_LEN], *adrpt, *stdio_adr= NULL;
struct isoburn *o= NULL;
ret= burn_drive_convert_fs_adr(adr, libburn_drive_adr);
if(ret<0)
return(ret);
if(ret==0) {
if(stat(adr,&stbuf)!=-1) {
adrpt= adr;
if(strncmp(adr, "grow:", 5)==0) {
treatment= 1;
adrpt+= 5;
if(stat(adrpt,&stbuf)!=-1)
if(S_ISREG(stbuf.st_mode) || S_ISBLK(stbuf.st_mode)) {
ret= burn_drive_grab_dummy(drive_infos, adr);
if(ret<=0)
return(ret);
o->emulation_mode= 2; /* standard i/o */
} else {
/* >>> unsuitable file type */;
return(0);
stdio_adr= calloc(strlen(adrpt)+6+1, 1);
if(stdio_adr==NULL)
{ret= -1; goto ex;}
sprintf(stdio_adr, "stdio:%s", adrpt); /* use pseudo-drive */
adrpt= stdio_adr;
}
} 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);
}
} else {
ret= burn_drive_scan_and_grab(drive_infos, adr, load);
ret= 0; goto ex;
}
o->treatment= treatment;
if(treatment==1) {
ret= burn_drive_scan_and_grab(drive_infos, adrpt, load);
if(ret<=0)
goto ex;
ret= isoburn_welcome_media(&o, (*drive_infos)[0].drive, 0);
if(ret<=0)
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;
ex:
if(ret<=0)
isoburn_destroy(&o,0);
if(stdio_adr!=NULL)
free(stdio_adr);
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)
{
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);
}
#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)
{
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);
ret= isoburn_find_emulator(&o, drive, 0);
if(ret<=0)
if(ret<=0) /* no emulation, no burn_write_opts_set_start_byte() */
goto ex;
ret= burn_disc_get_multi_caps(drive, BURN_WRITE_NONE, &caps, 0);
if(ret<=0)