Enabled treatment==2 in isoburn_drive_scan_and_grab()

This commit is contained in:
Thomas Schmitt 2007-09-22 14:02:34 +00:00
parent 30176ed372
commit 2461231664

View File

@ -89,16 +89,26 @@ ex:
int isoburn_drive_scan_and_grab(struct burn_drive_info *drive_infos[],
char *adr, int load)
{
int ret, treatment= 0;
int ret, treatment= 0, conv_ret;
struct stat stbuf;
char libburn_drive_adr[BURN_DRIVE_ADR_LEN], *adrpt, *stdio_adr= NULL;
struct isoburn *o= NULL;
/* Treatment decision criteria
Prefixes "grow:" leads to: treatment 1, image growing
Prefix "modify:" leads to: treatment 2, image modification
Anything else is decided automatically
If suitable as libburn drive address: treatment 1 ("stdio:" fits here)
else if non-existent or regular file: treatment 2
else if block device : treatment 1
else : unsuitable target
*/
adrpt= adr;
if(strncmp(adr, "grow:", 5)==0) {
treatment= 1;
adrpt+= 5;
if(stat(adrpt,&stbuf)!=-1)
if(stat(adrpt,&stbuf)!=-1) {
if(S_ISREG(stbuf.st_mode) || S_ISBLK(stbuf.st_mode)) {
stdio_adr= calloc(strlen(adrpt)+6+1, 1);
if(stdio_adr==NULL)
@ -106,42 +116,60 @@ int isoburn_drive_scan_and_grab(struct burn_drive_info *drive_infos[],
sprintf(stdio_adr, "stdio:%s", adrpt); /* use pseudo-drive */
adrpt= stdio_adr;
}
} 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
} else if(strncmp(adr, "modify:", 7)==0) {
adrpt+= 7;
treatment= 2;
} else if(treatment==1 && ret<=0) {
if(stat(adrpt,&stbuf)!=-1) {
if(! S_ISREG(stbuf.st_mode)) {
/* >>> unsuitable drive address */;
/* >>> we need a gateway to the libisofs/libburn message system */;
fprintf(stderr, "LIBISOBURN: unsuitable target for modify: '%s'\n",adr);
ret= 0; goto ex;
}
}
sprintf(stdio_adr, "stdio:%s", adrpt); /* use pseudo-drive */
adrpt= stdio_adr;
} else {
/* >>> interpret "read:" , "write:" for modification on MMC drives */;
}
conv_ret= burn_drive_convert_fs_adr(adrpt, libburn_drive_adr);
if(treatment==0) { /* undecided yet, make a decision or declare failure */
if(conv_ret>0)
treatment= 1; /* Device file leading to MMC drive or "stdio:" address */
else {
if(stat(adrpt,&stbuf)==-1) {
/* burn_drive_scan_and_grab() will check whether the directory exists */
treatment= 2;
} else if(S_ISREG(stbuf.st_mode))
treatment= 2;
else if(S_ISBLK(stbuf.st_mode))
treatment= 1;
if(treatment>=0) {
sprintf(stdio_adr, "stdio:%s", adrpt); /* use pseudo-drive */
adrpt= stdio_adr;
conv_ret= 1; /* All "stdio:" addresses are ok for now */
}
}
}
if(conv_ret<=0 || treatment<=0) { /* Failure */
/* >>> we need a gateway to the libisofs/libburn message system */;
fprintf(stderr, "LIBISOBURN: unsuitable drive address: '%s'\n", adrpt);
ret= 0; goto ex;
}
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 */;
}
if(o!=NULL)
o->treatment= treatment;