|
|
|
@ -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
|
|
|
|
|
treatment= 2;
|
|
|
|
|
} else if(treatment==1 && ret<=0) {
|
|
|
|
|
treatment= 2;
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
ret= 0; goto ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sprintf(stdio_adr, "stdio:%s", adrpt); /* use pseudo-drive */
|
|
|
|
|
adrpt= stdio_adr;
|
|
|
|
|
} else {
|
|
|
|
|
if(stat(adrpt,&stbuf)!=-1)
|
|
|
|
|
if(! S_ISREG(stbuf.st_mode)) {
|
|
|
|
|
|
|
|
|
|
/* >>> unsuitable target for modify */;
|
|
|
|
|
/* >>> interpret "read:" , "write:" for modification on MMC drives */;
|
|
|
|
|
|
|
|
|
|
ret= 0; goto ex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 */
|
|
|
|
|
|
|
|
|
|
/* >>> welcome file for modfication treatment */;
|
|
|
|
|
/* >>> we need a gateway to the libisofs/libburn message system */;
|
|
|
|
|
fprintf(stderr, "LIBISOBURN: unsuitable drive address: '%s'\n", adrpt);
|
|
|
|
|
|
|
|
|
|
ret= 0; goto ex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
if(o!=NULL)
|
|
|
|
|
o->treatment= treatment;
|
|
|
|
|
|
|
|
|
|