From 8d5daf11d361ed3d9835553406b0bceaf479c3b6 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Sat, 22 Sep 2007 14:02:34 +0000 Subject: [PATCH] Enabled treatment==2 in isoburn_drive_scan_and_grab() --- libisoburn/trunk/src/burn_wrap.c | 84 +++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 28 deletions(-) diff --git a/libisoburn/trunk/src/burn_wrap.c b/libisoburn/trunk/src/burn_wrap.c index ea607e31..06d81a47 100644 --- a/libisoburn/trunk/src/burn_wrap.c +++ b/libisoburn/trunk/src/burn_wrap.c @@ -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) { - - /* >>> unsuitable drive address */; - - 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) + treatment= 2; + if(stat(adrpt,&stbuf)!=-1) { if(! S_ISREG(stbuf.st_mode)) { - /* >>> unsuitable target for modify */; + /* >>> 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 { - /* >>> welcome file for modfication treatment */; + /* >>> 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; + } + + 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;