diff --git a/libisoburn/trunk/test/xorriso.c b/libisoburn/trunk/test/xorriso.c index f78bece7..6f0c724d 100644 --- a/libisoburn/trunk/test/xorriso.c +++ b/libisoburn/trunk/test/xorriso.c @@ -2188,10 +2188,18 @@ int Xorriso_info(struct XorrisO *xorriso, int flag) */ { int ret; + static int note_sev= 0; if(flag&2) if(xorriso->request_to_abort) return(1); + + if(note_sev==0) + Xorriso__text_to_sev("NOTE", ¬e_sev, 0); + if(note_sevreport_about_severity && + note_sevabort_on_severity) + return(1); + if(flag&1) { ret= Xorriso_pager(xorriso,xorriso->info_text,2); if(ret<=0) @@ -2953,13 +2961,21 @@ ex: } -int Xorriso__end_idx(int argc, char **argv, int idx, int flag) +int Xorriso_end_idx(struct XorrisO *xorriso, + int argc, char **argv, int idx, int flag) { - int i; + int i, warned= 0; - for(i= idx; iinfo_text, + "Xorriso does not support address wildcards '*' and '?'"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + warned= 1; + } + } return(i); } @@ -3106,7 +3122,7 @@ int Xorriso_option_add(struct XorrisO *xorriso, int argc, char **argv, int i, end_idx, ret; char target[SfileadrL], source[SfileadrL], *ept, eff_path[SfileadrL]; - end_idx= Xorriso__end_idx(argc, argv, *idx, 0); + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0); for(i= *idx; i>> XORRISO : decode timestring %s\n", timestring); fprintf(stderr, ">>> LIBISOFS : -alter_date %s %s ", @@ -3367,7 +3383,7 @@ int Xorriso_option_chgrpi(struct XorrisO *xorriso, char *gid, char *path, { int i, end_idx; - end_idx= Xorriso__end_idx(argc, argv, *idx, 0); + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0); fprintf(stderr, ">>> LIBISOFS : would perform -chgrpi %s %s ", gid, path); for(i= *idx; i>> LIBISOFS : would perform -chmodi %s %s ", mode, path); for(i= *idx; i>> LIBISOFS : would perform -chowni %s %s ", uid, path); for(i= *idx; i>> LIBISOFS : -cp_ri X: "); for(i= *idx; i>> LIBISOFS : -mkdiri "); for(i= *idx; iinfo_text, "-mvi: not enough arguments"); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); @@ -4140,7 +4157,7 @@ int Xorriso_option_mvi(struct XorrisO *xorriso, int argc, char **argv, } /* Perform movements */ for(i= *idx; iinfo_text, "Renamed in ISO image: %s to %s\n", + Text_shellsafe(eff_origin,sfe,0),Text_shellsafe(eff_dest,sfe2,0)); + Xorriso_info(xorriso, 0); + } } ret= !was_failure; ex:; @@ -4469,7 +4491,7 @@ int Xorriso_option_rmi(struct XorrisO *xorriso, int argc, char **argv, int i, end_idx, ret; char path[SfileadrL], eff_path[SfileadrL]; - end_idx= Xorriso__end_idx(argc, argv, *idx, 0); + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0); for(i= *idx; i>> LIBISOFS : -rmdiri "); for(i= *idx; iinfo_text, @@ -471,7 +474,8 @@ int Xorriso_normalize_img_path(struct XorrisO *xorriso, char *img_path, img_path); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FATAL", 0); return(-1); - } + } else if(path[1]==0) + return(2); /* root directory */ for(npt= apt; !done; apt= npt+1) { npt= strchr(apt, '/'); @@ -1259,7 +1263,6 @@ int Xorriso_ls(struct XorrisO *xorriso, int flag) static char months[12][4]= { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - rpt= xorriso->result_line; ret= Xorriso_get_volume(xorriso, &volume, 0); @@ -1394,28 +1397,58 @@ ex:; int Xorriso_rename(struct XorrisO *xorriso, char origin[], char dest[], int flag) { - int ret; + int ret, ol, dest_ret; char sfe[4*SfileadrL], eff_dest[SfileadrL], dir_adr[SfileadrL], *cpt; - char *leafname; + char *leafname, eff_origin[SfileadrL], sfe2[4*SfileadrL]; struct iso_volume *volume; struct iso_tree_node_dir *origin_dir, *dest_dir; struct iso_tree_node *node; - /* Check whether destination exists and may be not overwriteable */ - ret= Xorriso_normalize_img_path(xorriso, dest, eff_dest, 1); - if(ret<0) + ret= Xorriso_normalize_img_path(xorriso, origin, eff_origin, 0); + if(ret<=0) return(ret); - if(ret==2) { + dest_ret= Xorriso_normalize_img_path(xorriso, dest, eff_dest, 1); + if(dest_ret<0) + return(dest_ret); + if(dest_ret==0) { /* obtain eff_dest address despite it does not exist */ + ret= Xorriso_normalize_img_path(xorriso, dest, eff_dest, 2); + if(ret<=0) + return(ret); + } + + /* Prevent that destination is a subordinate of origin + (that would be a black hole plopping out of the universe) */ + ol= strlen(eff_origin); + if(ol==0) { + sprintf(xorriso->info_text, "May not rename root directory"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } else if(strcmp(eff_origin, eff_dest)==0) { + sprintf(xorriso->info_text, "Ignored attempt to rename %s to itself", + Text_shellsafe(eff_origin,sfe,0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + return(0); + } else if(strncmp(eff_origin, eff_dest, ol)==0 && + (eff_dest[ol]==0 || eff_dest[ol]=='/')) { + sprintf(xorriso->info_text, + "May not rename %s to its own sub address %s", + Text_shellsafe(eff_origin,sfe,0), Text_shellsafe(eff_dest,sfe2,0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + + /* Check whether destination exists and may be not overwriteable */ + if(dest_ret==2) { sprintf(xorriso->info_text, "Renaming refuses to unlink directory: %s", Text_shellsafe(eff_dest, sfe, 0)); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); return(0); - } else if (ret==1 && !xorriso->do_overwrite) { + } else if (dest_ret==1 && !xorriso->do_overwrite) { sprintf(xorriso->info_text, "Renaming may not overwite: %s", Text_shellsafe(eff_dest, sfe, 0)); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); return(0); - } else if(ret>0) { + } else if(dest_ret>0) { ret= Xorriso_rmi(xorriso, eff_dest, 0); if(ret<=0) return(0); @@ -1427,9 +1460,11 @@ int Xorriso_rename(struct XorrisO *xorriso, if(cpt==NULL) cpt= dir_adr+strlen(dir_adr); *cpt= 0; - ret= Xorriso_graft_in(xorriso, NULL, dir_adr, 1); - if(ret<=0) - return(ret); + if(dir_adr[0]!=0) { + ret= Xorriso_graft_in(xorriso, NULL, dir_adr, 1); + if(ret<=0) + return(ret); + } /* Move node */ ret= Xorriso_get_volume(xorriso, &volume, 0); @@ -1437,15 +1472,16 @@ int Xorriso_rename(struct XorrisO *xorriso, return(ret); dest_dir= (struct iso_tree_node_dir *) iso_tree_volume_path_to_node(volume,dir_adr); - strcpy(dir_adr, origin); + strcpy(dir_adr, eff_origin); cpt= strrchr(dir_adr, '/'); if(cpt==NULL) cpt= dir_adr+strlen(dir_adr); *cpt= 0; origin_dir= (struct iso_tree_node_dir *) iso_tree_volume_path_to_node(volume,dir_adr); - node= iso_tree_volume_path_to_node(volume,origin); + node= iso_tree_volume_path_to_node(volume,eff_origin); if(dest_dir==NULL || origin_dir==NULL || node==NULL) { + Xorriso_process_msg_queues(xorriso,0); sprintf(xorriso->info_text, "Internal error on rename: confirmed node turns out as NULL"); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); @@ -1453,6 +1489,7 @@ int Xorriso_rename(struct XorrisO *xorriso, } ret= iso_tree_node_take(origin_dir, node); if(ret==-1) { + Xorriso_process_msg_queues(xorriso,0); sprintf(xorriso->info_text, "Internal error on rename: failed to take node"); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); @@ -1465,6 +1502,8 @@ int Xorriso_rename(struct XorrisO *xorriso, else leafname++; iso_tree_node_set_name(node, leafname); + + Xorriso_process_msg_queues(xorriso,0); return(1); }