libisoburn  1.5.4
About: libisoburn is a frontend for the libraries libburn and libisofs which enables creation and expansion of ISO-9660 filesystems on all media and file types supported by libburn. It implements the API and command interpreter of program xorriso, and installs this program as small dynamically linked binary. xorriso is suitable for incremental data backup and for production of bootable ISO 9660 images. A statically linked version is available as GNU xorriso.
  Fossies Dox: libisoburn-1.5.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

iso_manip.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define Xorriso_pvt_iso_manip_includeD   yes
 

Functions

int Xorriso_transfer_properties (struct XorrisO *xorriso, struct stat *stbuf, char *disk_path, IsoNode *node, int flag)
 
int Xorriso_graft_split (struct XorrisO *xorriso, IsoImage *volume, IsoDir *dir, char *disk_path, char *img_name, char *nominal_source, char *nominal_target, off_t size, IsoNode **node, int flag)
 
int Xorriso_tree_graft_node (struct XorrisO *xorriso, IsoImage *volume, IsoDir *dir, char *disk_path, char *img_name, char *nominal_source, char *nominal_target, off_t offset, off_t cut_size, IsoNode **node, int flag)
 
int Xorriso_add_tree (struct XorrisO *xorriso, IsoDir *dir, char *img_dir_path, char *disk_dir_path, struct LinkiteM *link_stack, int flag)
 
int Xorriso_copy_implicit_properties (struct XorrisO *xorriso, IsoDir *dir, char *full_img_path, char *img_path, char *full_disk_path, int flag)
 
int Xorriso_mkisofs_lower_r (struct XorrisO *xorriso, IsoNode *node, int flag)
 
int Xorriso_widen_hardlink (struct XorrisO *xorriso, void *boss_iter, IsoNode *node, char *abs_path, char *iso_prefix, char *disk_prefix, int flag)
 
int Xorriso_cannot_create_iter (struct XorrisO *xorriso, int iso_error, int flag)
 
int Xorriso_findi_iter (struct XorrisO *xorriso, IsoDir *dir_node, off_t *mem, IsoDirIter **iter, IsoNode ***node_array, int *node_count, int *node_idx, IsoNode **iterated_node, int flag)
 
int Xorriso_findi_action (struct XorrisO *xorriso, struct FindjoB *job, IsoDirIter *boss_iter, off_t boss_mem, char *abs_path, char *show_path, IsoNode *node, int depth, int flag)
 
int Xorriso_findi_headline (struct XorrisO *xorriso, struct FindjoB *job, int flag)
 
int Xorriso_findi_sorted (struct XorrisO *xorriso, struct FindjoB *job, off_t boss_mem, int filec, char **filev, int flag)
 
int Xorriso_all_node_array (struct XorrisO *xorriso, int addon_nodes, int flag)
 
int Xorriso__file_start_lba (IsoNode *node, int *lba, int flag)
 
int Xorriso__mark_update_xinfo (void *data, int flag)
 
int Xorriso__mark_update_cloner (void *old_data, void **new_data, int flag)
 
int Xorriso_get_blessing (struct XorrisO *xorriso, IsoNode *node, int *bless_idx, char bless_code[17], int flag)
 
int Xorriso_truncate_uniquely (struct XorrisO *xorriso, int length, IsoNode *node, char *abs_path, char *show_path, int flag)
 

Macro Definition Documentation

◆ Xorriso_pvt_iso_manip_includeD

#define Xorriso_pvt_iso_manip_includeD   yes

Definition at line 14 of file iso_manip.h.

Function Documentation

◆ Xorriso__file_start_lba()

int Xorriso__file_start_lba ( IsoNode *  node,
int *  lba,
int  flag 
)

Definition at line 2259 of file iso_tree.c.

2261 {
2262  int *start_lbas= NULL, *end_lbas= NULL, lba_count= 0, i, ret;
2263  off_t size, *section_sizes= NULL;
2264 
2265  *lba= -1;
2266  ret= Xorriso__start_end_lbas(node, &lba_count, &start_lbas, &end_lbas,
2267  &section_sizes, &size, 0);
2268  if(ret <= 0)
2269  return(ret);
2270  for(i= 0; i < lba_count; i++) {
2271  if(*lba < 0 || start_lbas[i] < *lba)
2272  *lba= start_lbas[i];
2273  }
2274  if(start_lbas != NULL)
2275  free((char *) start_lbas);
2276  if(end_lbas != NULL)
2277  free((char *) end_lbas);
2278  if(section_sizes != NULL)
2279  free((char *) section_sizes);
2280  if(*lba < 0)
2281  return(0);
2282  return(1);
2283 }
int Xorriso__start_end_lbas(IsoNode *node, int *lba_count, int **start_lbas, int **end_lbas, off_t **section_sizes, off_t *size, int flag)
Definition: iso_tree.c:2210

References Xorriso__start_end_lbas().

Referenced by Exprtest_match(), Xorriso__node_lba_cmp(), Xorriso_record_boot_info(), Xorriso_restore_is_identical(), and Xorriso_set_system_area().

◆ Xorriso__mark_update_cloner()

int Xorriso__mark_update_cloner ( void *  old_data,
void **  new_data,
int  flag 
)

Definition at line 3897 of file iso_manip.c.

3898 {
3899  *new_data= NULL;
3900  if(flag)
3901  return(ISO_XINFO_NO_CLONE);
3902  if(old_data == NULL)
3903  return(0);
3904  /* data is an int disguised as pointer. It does not point to memory. */
3905  *new_data= old_data;
3906  return(0);
3907 }

Referenced by Xorriso_startup_libraries().

◆ Xorriso__mark_update_xinfo()

int Xorriso__mark_update_xinfo ( void *  data,
int  flag 
)

Definition at line 3890 of file iso_manip.c.

3891 {
3892  /* data is an int disguised as pointer. It does not point to memory. */
3893  return(1);
3894 }

Referenced by Xorriso_mark_update_merge(), and Xorriso_startup_libraries().

◆ Xorriso_add_tree()

int Xorriso_add_tree ( struct XorrisO xorriso,
IsoDir *  dir,
char *  img_dir_path,
char *  disk_dir_path,
struct LinkiteM link_stack,
int  flag 
)

Definition at line 356 of file iso_manip.c.

359 {
360  IsoImage *volume;
361  IsoNode *node;
362  int ret, source_is_dir, source_is_link, fret, was_failure= 0;
363  int do_not_dive, hide_attrs;
364  struct DirseQ *dirseq= NULL;
365  char *name, *img_name, *srcpt, *stbuf_src= "";
366  struct stat stbuf, hstbuf;
367  dev_t dir_dev;
368  struct LinkiteM *own_link_stack = NULL;
369  char *sfe= NULL, *sfe2= NULL;
370  char *disk_path= NULL, *img_path= NULL, *link_target= NULL;
371 
372 #define Xorriso_add_handle_collisioN 1
373 #define Xorriso_optimistic_add_treE 1
374 
375 #ifndef Xorriso_optimistic_add_treE
376 #ifndef Xorriso_add_handle_collisioN
377  int target_is_split= 0, target_is_dir;
378 #endif
379 #endif
380 
381  /* Avoiding large local memory objects in order to save stack space */
382  sfe= malloc(5*SfileadrL);
383  sfe2= malloc(5*SfileadrL);
384  disk_path= malloc(2*SfileadrL);
385  img_path= malloc(2*SfileadrL);
386  link_target= calloc(SfileadrL, 1);
387  if(sfe==NULL || sfe2==NULL || disk_path==NULL || img_path==NULL ||
388  link_target==NULL) {
389  Xorriso_no_malloc_memory(xorriso, &sfe, 0);
390  {ret= -1; goto ex;}
391  }
392 
393  own_link_stack= link_stack;
394 
395  ret= Xorriso_get_volume(xorriso, &volume, 0);
396  if(ret<=0)
397  goto ex;
398 
399  stbuf_src= disk_dir_path;
400  if(lstat(disk_dir_path, &stbuf)==-1)
401  goto cannot_open_dir;
402  dir_dev= stbuf.st_dev;
403  if(S_ISLNK(stbuf.st_mode)) {
404  if(!(xorriso->do_follow_links || (xorriso->do_follow_param && !(flag&1))))
405  {ret= 2; goto ex;}
406  stbuf_src= disk_dir_path;
407  if(stat(disk_dir_path, &stbuf)==-1)
408  goto cannot_open_dir;
409  if(dir_dev != stbuf.st_dev &&
410  !(xorriso->do_follow_mount || (xorriso->do_follow_param && !(flag&1))))
411  {ret= 2; goto ex;}
412  }
413  ret= Dirseq_new(&dirseq, disk_dir_path, 1);
414  if(ret<0) {
415  sprintf(xorriso->info_text,"Failed to create source filesystem iterator");
416  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
417  {ret= -1; goto ex;}
418  }
419  if(ret==0) {
420 cannot_open_dir:;
421  Xorriso_msgs_submit(xorriso, 0, disk_dir_path, 0, "ERRFILE", 0);
422  sprintf(xorriso->info_text,"Cannot open as source directory: %s",
423  Text_shellsafe(disk_dir_path, sfe, 0));
424  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
425  {ret= 0; goto ex;}
426  }
427 
428  if(Sfile_str(disk_path, disk_dir_path,0)<=0)
429  {ret= -1; goto ex;}
430  if(disk_path[0]==0 || disk_path[strlen(disk_path)-1]!='/')
431  strcat(disk_path,"/");
432  name= disk_path+strlen(disk_path);
433  if(Sfile_str(img_path, img_dir_path, 0)<=0)
434  {ret= -1; goto ex;}
435  if(img_path[0] == 0)
436  strcat(img_path, "/");
437  else if(img_path[strlen(img_path) - 1] != '/')
438  strcat(img_path, "/");
439  img_name= img_path+strlen(img_path);
440 
441  while(1) { /* loop over directory content */
442  stbuf_src= "";
443  Linkitem_reset_stack(&own_link_stack, link_stack, 0);
444  srcpt= disk_path;
445  Xorriso_process_msg_queues(xorriso,0);
446  ret= Dirseq_next_adr(dirseq,name,0); /* name is a pointer into disk_path */
447  if(ret==0)
448  break;
449  if(ret<0) {
450  sprintf(xorriso->info_text,"Failed to obtain next directory entry");
451  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
452  {ret= -1; goto ex;}
453  }
454 
455  /* Compare exclusions against disk_path resp. name */
456  ret= Xorriso_path_is_excluded(xorriso, disk_path, 0); /* (is never param) */
457  if(ret<0)
458  {ret= -1; goto ex;}
459  if(ret>0)
460  continue;
461  /* Check for mkisofs-style hidings */
462  hide_attrs= (flag >> 8) & 3;
463  if(hide_attrs != 3) {
464  ret= Xorriso_path_is_hidden(xorriso, disk_path, 0);
465  if(ret<0)
466  goto ex;
467  if(ret>=0)
468  hide_attrs|= ret;
469  }
470 
471  strcpy(img_name, name);
472  if(Xorriso_much_too_long(xorriso, strlen(img_path), 0)<=0)
473  {ret= 0; goto was_problem;}
474  if(Xorriso_much_too_long(xorriso, strlen(srcpt), 0)<=0)
475  {ret= 0; goto was_problem;}
476  stbuf_src= srcpt;
477  if(lstat(srcpt, &stbuf)==-1) {
478 cannot_lstat:;
479  Xorriso_msgs_submit(xorriso, 0, srcpt, 0, "ERRFILE", 0);
480  sprintf(xorriso->info_text,
481  "Cannot determine attributes of source file %s",
482  Text_shellsafe(srcpt, sfe, 0));
483  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
484  ret= 0; goto was_problem;
485  }
486  source_is_dir= 0;
487  source_is_link= S_ISLNK(stbuf.st_mode);
488  if(xorriso->do_follow_links && source_is_link) {
489  /* Xorriso_hop_link checks for wide link loops */
490  ret= Xorriso_hop_link(xorriso, srcpt, &own_link_stack, &hstbuf, 0);
491  if(ret<0)
492  goto was_problem;
493  if(ret==1) {
494  ret= Xorriso_resolve_link(xorriso, srcpt, link_target, 0);
495  if(ret<=0)
496  goto was_problem;
497  srcpt= link_target;
498  stbuf_src= srcpt;
499  if(lstat(srcpt, &stbuf)==-1)
500  goto cannot_lstat;
501  } else {
502  if(Xorriso_eval_problem_status(xorriso, 0, 1|2)<0)
503  {ret= 0; goto was_problem;}
504  ret= Xorriso_resolve_link(xorriso, srcpt, link_target, 1);
505  if(ret<=0)
506  goto was_problem;
507  }
508  } else if (S_ISLNK(stbuf.st_mode)) {
509  ret= Xorriso_resolve_link(xorriso, srcpt, link_target, 1);
510  if(ret<=0)
511  goto was_problem;
512  }
513  do_not_dive= 0;
514  if(S_ISDIR(stbuf.st_mode)) {
515  source_is_dir= 1;
516  if(dir_dev != stbuf.st_dev && !xorriso->do_follow_mount)
517  do_not_dive= 1;
518  }
519 
520 #ifdef Xorriso_optimistic_add_treE
521 
522  ret= Xorriso_tree_graft_node(xorriso, volume, dir, srcpt, img_name,
523  "", img_path, (off_t) 0, (off_t) 0,
524  &node, 1 | (hide_attrs << 8));
525  if(ret == (int) ISO_NODE_NAME_NOT_UNIQUE) {
526  ret= Xoriso_handle_collision(xorriso, NULL, &node, img_path, img_path,
527  srcpt, img_path,
528  (!!source_is_dir) | (flag & (64 | 128)));
529  if(ret <= 0)
530  goto was_problem;
531  if(node == NULL) {
532  ret= Xorriso_tree_graft_node(xorriso, volume, dir, srcpt, img_name,
533  "", img_path, (off_t) 0, (off_t) 0,
534  &node, (hide_attrs << 8));
535  if(ret <= 0)
536  node= NULL;
537  }
538  }
539 
540 #else /* Xorriso_optimistic_add_treE */
541 
542  /* does a node exist with this name ? */
543  node= NULL;
544  if(dir != NULL) {
545  ret= iso_image_get_dir_node(volume, dir, img_name, &node);
546  } else {
547  ret= Xorriso_node_from_path(xorriso, volume, img_path, &node, 1);
548  }
549  if(ret>0) {
550  target_is_dir= LIBISO_ISDIR(node);
551  target_is_split= 0;
552  if(target_is_dir && !(flag & 128))
553  target_is_split= Xorriso_is_split(xorriso, "", (void *) node, 1 | 2);
554 
555  if(!((target_is_dir && !target_is_split) && source_is_dir)) {
556  Xorriso_process_msg_queues(xorriso,0);
557 
558  /* handle overwrite situation */;
559  if(xorriso->do_overwrite==1 ||
560  (xorriso->do_overwrite==2 && !(target_is_dir && !target_is_split))) {
561  ret= Xorriso_rmi(xorriso, NULL, (off_t) 0, img_path,
562  1 | 8 | (flag & 64));
563  if(ret<=0)
564  goto was_problem;
565  if(ret==3) {
566  sprintf(xorriso->info_text, "User revoked adding of: %s",
567  Text_shellsafe(img_path, sfe, 0));
568  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
569  ret= 0; goto was_problem;
570  }
571  node= NULL;
572  } else {
573  Xorriso_msgs_submit(xorriso, 0, srcpt, 0, "ERRFILE", 0);
574  sprintf(xorriso->info_text,
575  "While grafting %s : file object exists and may not be overwritten by %s",
576  Text_shellsafe(img_path,sfe,0), Text_shellsafe(stbuf_src,sfe2,0));
577  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
578  ret= 0; goto was_problem;
579  }
580  }
581  }
582 
583  if(node==NULL) {
584  ret= Xorriso_tree_graft_node(xorriso, volume, dir, srcpt, img_name,
585  "", img_path, (off_t) 0, (off_t) 0,
586  &node, (hide_attrs << 8));
587  }
588 
589 #endif /* Xorriso_optimistic_add_treE */
590 
591  if(node==NULL) {
592  Xorriso_process_msg_queues(xorriso,0);
593  Xorriso_msgs_submit(xorriso, 0, stbuf_src, 0, "ERRFILE", 0);
594  sprintf(xorriso->info_text, "Grafting failed: %s = %s",
595  Text_shellsafe(img_path,sfe,0), Text_shellsafe(stbuf_src,sfe2,0));
596  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
597  ret= 0; goto was_problem;
598  }
599 
600  xorriso->pacifier_count++;
601  if((xorriso->pacifier_count%100)==0)
602  Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count,
603  xorriso->pacifier_total, "", 0);
604 
605  Xorriso_set_change_pending(xorriso, 0);
606  if(source_is_dir) {
607  if(do_not_dive) {
608  sprintf(xorriso->info_text, "Did not follow mount point : %s",
609  Text_shellsafe(disk_path, sfe, 0));
610  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
611  } else {
612  ret= Xorriso_add_tree(xorriso, (IsoDir *) node,
613  img_path, disk_path, own_link_stack,
614  1 | (flag & (2 | 64 | 128)));
615  }
616  if(ret<=0)
617  goto was_problem;
618  }
619 
620  continue; /* regular bottom of loop */
621 was_problem:;
622  was_failure= 1;
623  fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
624  if(fret<0)
625  goto ex;
626  }
627 
628  ret= 1;
629 ex:
630  if(sfe!=NULL)
631  free(sfe);
632  if(sfe2!=NULL)
633  free(sfe2);
634  if(disk_path!=NULL)
635  free(disk_path);
636  if(img_path!=NULL)
637  free(img_path);
638  if(link_target!=NULL)
639  free(link_target);
640  Xorriso_process_msg_queues(xorriso,0);
641  Linkitem_reset_stack(&own_link_stack, link_stack, 0);
642  Dirseq_destroy(&dirseq, 0);
643  if(ret<=0)
644  return(ret);
645  return(!was_failure);
646 }
int Dirseq_destroy(struct DirseQ **o, int flag)
Definition: aux_objects.c:336
int Linkitem_reset_stack(struct LinkiteM **o, struct LinkiteM *to, int flag)
Definition: aux_objects.c:895
int Dirseq_next_adr(struct DirseQ *o, char reply[4096], int flag)
Definition: aux_objects.c:384
int Dirseq_new(struct DirseQ **o, char *adr, int flag)
Definition: aux_objects.c:291
int Xorriso_resolve_link(struct XorrisO *xorriso, char *link_path, char result_path[4096], int flag)
Definition: disk_ops.c:45
int Xorriso_hop_link(struct XorrisO *xorriso, char *link_path, struct LinkiteM **link_stack, struct stat *stbuf, int flag)
Definition: disk_ops.c:304
#define SfileadrL
int Xorriso_set_change_pending(struct XorrisO *xorriso, int flag)
Definition: iso_img.c:1004
int Xorriso_get_volume(struct XorrisO *xorriso, IsoImage **volume, int flag)
Definition: iso_img.c:966
int Xorriso_rmi(struct XorrisO *xorriso, void *boss_iter, off_t boss_mem, char *path, int flag)
Definition: iso_manip.c:1359
int Xorriso_tree_graft_node(struct XorrisO *xorriso, IsoImage *volume, IsoDir *dir, char *disk_path, char *img_name, char *nominal_source, char *nominal_target, off_t offset, off_t cut_size, IsoNode **node, int flag)
Definition: iso_manip.c:175
int Xorriso_add_tree(struct XorrisO *xorriso, IsoDir *dir, char *img_dir_path, char *disk_dir_path, struct LinkiteM *link_stack, int flag)
Definition: iso_manip.c:356
int Xoriso_handle_collision(struct XorrisO *xorriso, void *boss_iter, IsoNode **node, char *img_path, char *full_img_path, char *disk_path, char *show_path, int flag)
Definition: iso_manip.c:298
int Xorriso_node_from_path(struct XorrisO *xorriso, IsoImage *volume, char *path, IsoNode **node, int flag)
Definition: iso_tree.c:2650
int Xorriso_is_split(struct XorrisO *xorriso, char *path, void *node, int flag)
Definition: iso_tree.c:633
#define LIBISO_ISDIR(node)
Definition: iso_tree.h:17
int Xorriso_process_msg_queues(struct XorrisO *xorriso, int flag)
Forward any pending messages from the library message queues to the xorriso message system which puts...
Definition: lib_mgt.c:519
char * Text_shellsafe(char *in_text, char *out_text, int flag)
Definition: misc_funct.c:1044
int Xorriso_eval_problem_status(struct XorrisO *xorriso, int ret, int flag)
Evaluate an advise whether to abort or whether to go on with option processing.
Definition: parse_exec.c:307
int Xorriso_path_is_excluded(struct XorrisO *xorriso, char *path, int flag)
Definition: parse_exec.c:3130
int Xorriso_path_is_hidden(struct XorrisO *xorriso, char *path, int flag)
Definition: parse_exec.c:3155
int Sfile_str(char target[4096], char *source, int flag)
Definition: sfile.c:836
off_t pacifier_count
int do_follow_mount
int do_follow_links
int do_overwrite
char info_text[10 *4096]
int do_follow_param
off_t pacifier_total
int Xorriso_msgs_submit(struct XorrisO *xorriso, int error_code, char msg_text[], int os_errno, char severity[], int flag)
Submit a problem message to the xorriso problem reporting and handling system.
Definition: text_io.c:2504
int Xorriso_pacifier_callback(struct XorrisO *xorriso, char *what_done, off_t count, off_t todo, char *current_object, int flag)
Definition: text_io.c:3969
int Xorriso_no_malloc_memory(struct XorrisO *xorriso, char **to_free, int flag)
Definition: text_io.c:4077
int Xorriso_much_too_long(struct XorrisO *xorriso, int len, int flag)
Definition: text_io.c:4097

References Dirseq_destroy(), Dirseq_new(), Dirseq_next_adr(), XorrisO::do_follow_links, XorrisO::do_follow_mount, XorrisO::do_follow_param, XorrisO::do_overwrite, XorrisO::info_text, LIBISO_ISDIR, Linkitem_reset_stack(), XorrisO::pacifier_count, XorrisO::pacifier_total, Sfile_str(), SfileadrL, Text_shellsafe(), Xoriso_handle_collision(), Xorriso_eval_problem_status(), Xorriso_get_volume(), Xorriso_hop_link(), Xorriso_is_split(), Xorriso_msgs_submit(), Xorriso_much_too_long(), Xorriso_no_malloc_memory(), Xorriso_node_from_path(), Xorriso_pacifier_callback(), Xorriso_path_is_excluded(), Xorriso_path_is_hidden(), Xorriso_process_msg_queues(), Xorriso_resolve_link(), Xorriso_rmi(), Xorriso_set_change_pending(), and Xorriso_tree_graft_node().

Referenced by Xorriso_graft_in().

◆ Xorriso_all_node_array()

int Xorriso_all_node_array ( struct XorrisO xorriso,
int  addon_nodes,
int  flag 
)

Definition at line 3709 of file iso_manip.c.

3710 {
3711  int ret;
3712  struct FindjoB *job= NULL;
3713  struct stat dir_stbuf;
3714 
3715  ret= Findjob_new(&job, "/", 0);
3716  if(ret<=0) {
3717  Xorriso_no_findjob(xorriso, "xorriso", 0);
3718  {ret= -1; goto ex;}
3719  }
3720  Findjob_set_action_target(job, 30, NULL, 0);
3721  Xorriso_destroy_node_array(xorriso, 0);
3722  ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0, NULL, "/",
3723  &dir_stbuf, 0, 0);
3724  if(ret <= 0)
3725  goto ex;
3726  ret= Xorriso_new_node_array(xorriso, xorriso->temp_mem_limit, addon_nodes, 0);
3727  if(ret <= 0)
3728  goto ex;
3729  Findjob_set_action_target(job, 31, NULL, 0);
3730  ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0, NULL, "/",
3731  &dir_stbuf, 0, 0);
3732  if(ret <= 0)
3733  goto ex;
3734  ret= 1;
3735 ex:;
3736  Findjob_destroy(&job, 0);
3737  return(ret);
3738 }
int Xorriso_destroy_node_array(struct XorrisO *xorriso, int flag)
Definition: base_obj.c:656
int Xorriso_new_node_array(struct XorrisO *xorriso, off_t mem_limit, int addon_nodes, int flag)
Definition: base_obj.c:728
int Findjob_set_action_target(struct FindjoB *o, int action, char *target, int flag)
Definition: findjob.c:1163
int Findjob_destroy(struct FindjoB **o, int flag)
Definition: findjob.c:401
int Findjob_new(struct FindjoB **o, char *start_path, int flag)
Definition: findjob.c:355
int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job, void *boss_iter, off_t boss_mem, void *dir_node_generic, char *dir_path, struct stat *dir_stbuf, int depth, int flag)
Definition: iso_manip.c:3355
int temp_mem_limit
int Xorriso_no_findjob(struct XorrisO *xorriso, char *cmd, int flag)
Definition: text_io.c:4110

References Findjob_destroy(), Findjob_new(), Findjob_set_action_target(), XorrisO::temp_mem_limit, Xorriso_destroy_node_array(), Xorriso_findi(), Xorriso_new_node_array(), and Xorriso_no_findjob().

Referenced by Xorriso_make_di_array(), Xorriso_make_hln_array(), and Xorriso_remake_hln_array().

◆ Xorriso_cannot_create_iter()

int Xorriso_cannot_create_iter ( struct XorrisO xorriso,
int  iso_error,
int  flag 
)

Definition at line 2509 of file iso_manip.c.

2510 {
2511  Xorriso_process_msg_queues(xorriso,0);
2512  Xorriso_report_iso_error(xorriso, "", iso_error, "Cannot create iter", 0,
2513  "FATAL", 1);
2514  sprintf(xorriso->info_text, "Cannot create IsoDirIter object");
2515  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
2516  return(1);
2517 }
int Xorriso_report_iso_error(struct XorrisO *xorriso, char *victim, int iso_error_code, char msg_text[], int os_errno, char min_severity[], int flag)
Definition: lib_mgt.c:430

References XorrisO::info_text, Xorriso_msgs_submit(), Xorriso_process_msg_queues(), and Xorriso_report_iso_error().

Referenced by Xorriso_clone_under(), Xorriso_dir_disk_path(), Xorriso_findi_iter(), Xorriso_identify_split(), Xorriso_ls(), Xorriso_obtain_pattern_files_i(), Xorriso_rmi(), Xorriso_rmx(), Xorriso_show_du_subs(), Xorriso_sorted_dir_i(), and Xorriso_sorted_node_array().

◆ Xorriso_copy_implicit_properties()

int Xorriso_copy_implicit_properties ( struct XorrisO xorriso,
IsoDir *  dir,
char *  full_img_path,
char *  img_path,
char *  full_disk_path,
int  flag 
)

Definition at line 652 of file iso_manip.c.

654 {
655  int ret, nfic, nic, nfdc, d, i;
656  char *nfi= NULL, *ni= NULL, *nfd= NULL, *cpt;
657  struct stat stbuf;
658 
659  Xorriso_alloc_meM(nfi, char, SfileadrL);
660  Xorriso_alloc_meM(ni, char, SfileadrL);
661  Xorriso_alloc_meM(nfd, char, SfileadrL);
662 
663  ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, full_img_path, nfi,
664  1|2);
665  if(ret<=0)
666  goto ex;
667  ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, img_path, ni, 1|2);
668  if(ret<=0)
669  goto ex;
670  ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, full_disk_path, nfd,
671  1|2|4);
672  if(ret<=0)
673  goto ex;
674  nfic= Sfile_count_components(nfi, 0);
675  nic= Sfile_count_components(ni, 0);
676  nfdc= Sfile_count_components(nfd, 0);
677  d= nfic-(flag&1)-nic;
678  if(d<0)
679  {ret= -1; goto ex;}
680  if(d>nfdc)
681  {ret= 0; goto ex;}
682  for(i= 0; i<d; i++) {
683  cpt= strrchr(nfd, '/');
684  if(cpt==NULL)
685  {ret= -1; goto ex;} /* should not happen */
686  *cpt= 0;
687  }
688  if(nfd[0]==0)
689  strcpy(nfd, "/");
690  if(stat(nfd, &stbuf)==-1)
691  {ret= 0; goto ex;}
692  Xorriso_transfer_properties(xorriso, &stbuf, nfd, (IsoNode *) dir,
693  ((8 | 1) * ((flag&1) && d==0)) | 4 | 32);
694  sprintf(xorriso->info_text, "Copied properties for ");
695  Text_shellsafe(ni, xorriso->info_text, 1);
696  sprintf(xorriso->info_text+strlen(xorriso->info_text), " from ");
697  Text_shellsafe(nfd, xorriso->info_text, 1);
698  if(!((flag&1) && d==0))
699  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
700 
701  if(!(flag & 2)) {
702  /* Check for mkisofs-style hidings */
703  ret= Xorriso_path_is_hidden(xorriso, nfd, 0);
704  if(ret<0)
705  goto ex;
706  if(ret>=0) {
707  /* Hide dir */
708  ret= Xorriso_set_hidden(xorriso, (void *) dir, "", ret, 0);
709  if(ret <= 0)
710  goto ex;
711  }
712  }
713  ret= 1;
714 ex:
715  Xorriso_free_meM(nfi);
716  Xorriso_free_meM(ni);
717  Xorriso_free_meM(nfd);
718  return(ret);
719 }
int Xorriso_set_hidden(struct XorrisO *xorriso, void *in_node, char *path, int hide_state, int flag)
Definition: iso_manip.c:2362
int Xorriso_transfer_properties(struct XorrisO *xorriso, struct stat *stbuf, char *disk_path, IsoNode *node, int flag)
Definition: iso_manip.c:48
int Xorriso_normalize_img_path(struct XorrisO *xorriso, char *wd, char *img_path, char eff_path[], int flag)
Definition: iso_tree.c:55
int Sfile_count_components(char *path, int flag)
Definition: sfile.c:61
#define Xorriso_free_meM(pt)
Definition: sfile.h:27
#define Xorriso_alloc_meM(pt, typ, count)
Definition: sfile.h:19
char wdx[4096]
char wdi[4096]

References XorrisO::info_text, Sfile_count_components(), SfileadrL, Text_shellsafe(), XorrisO::wdi, XorrisO::wdx, Xorriso_alloc_meM, Xorriso_free_meM, Xorriso_msgs_submit(), Xorriso_normalize_img_path(), Xorriso_path_is_hidden(), Xorriso_set_hidden(), and Xorriso_transfer_properties().

Referenced by Xorriso_graft_in().

◆ Xorriso_findi_action()

int Xorriso_findi_action ( struct XorrisO xorriso,
struct FindjoB job,
IsoDirIter *  boss_iter,
off_t  boss_mem,
char *  abs_path,
char *  show_path,
IsoNode *  node,
int  depth,
int  flag 
)

Definition at line 2635 of file iso_manip.c.

2639 {
2640  int ret= 0, type, action= 0, hflag, deleted= 0, no_dive= 0, i, bless_idx;
2641  int unbless= 0;
2642  uid_t user= 0;
2643  gid_t group= 0;
2644  time_t date= 0;
2645  mode_t mode_or= 0, mode_and= ~1;
2646  char *target, *text_2, *iso_prefix, md5[16], *basename, bless_code[17];
2647  char crtp[10];
2648  struct FindjoB *subjob;
2649  struct stat dir_stbuf, stbuf;
2650  void *xinfo;
2651  struct iso_hfsplus_xinfo_data *hfsplus_xinfo;
2652  size_t value_length;
2653  char *value;
2654 
2655  action= Findjob_get_action_parms(job, &target, &text_2, &user, &group,
2656  &mode_and, &mode_or, &type, &date, &subjob, 0);
2657  if(action<0)
2658  action= 0;
2659  job->match_count++;
2660 
2661  hflag= 16*!(flag&2);
2662  ret= 1;
2663  if(action==1) { /* rm (including rmdir) */
2664  ret= Xorriso_fake_stbuf(xorriso, abs_path, &dir_stbuf, &node, 1);
2665  if(ret>0) {
2666  if(S_ISDIR(dir_stbuf.st_mode))
2667  hflag= 2;
2668  ret= Xorriso_rmi(xorriso, boss_iter, boss_mem, abs_path, hflag);
2669  deleted= 1;
2670  }
2671  } else if(action==2) { /* rm_r */
2672  ret= Xorriso_rmi(xorriso, boss_iter, boss_mem, abs_path, 1|hflag);
2673  deleted= 1;
2674  } else if(action==3) {
2675 
2676  /* >>> mv target */;
2677 
2678  } else if(action==4) { /* chown */
2679  ret= Xorriso_set_uid(xorriso, abs_path, user, 0);
2680  } else if(action==5) { /* chgrp */
2681  ret= Xorriso_set_gid(xorriso, abs_path, group, 0);
2682  } else if(action==6) { /* chmod */
2683  ret= Xorriso_set_st_mode(xorriso, abs_path, mode_and, mode_or, 0);
2684  } else if(action==7) { /* alter_date */
2685  ret= Xorriso_set_time(xorriso, abs_path, date, type&7);
2686  } else if(action==8) { /* lsdl */
2687  ret= Xorriso_ls_filev(xorriso, "", 1, &abs_path, (off_t) 0, 1|2|8);
2688  } else if(action>=9 && action<=13) { /* actions which have own findjobs */
2689  Findjob_set_start_path(subjob, abs_path, 0);
2690  ret= Xorriso_findi(xorriso, subjob, boss_iter, boss_mem, NULL,
2691  abs_path, &dir_stbuf, depth, 1);
2692  } else if(action==14 || action==17 || action == 41) {
2693  /* compare , update , update_merge */
2694  Findjob_get_start_path(job, &iso_prefix, 0);
2695  ret= Xorriso_find_compare(xorriso, (void *) boss_iter, (void *) node,
2696  abs_path, iso_prefix, target,
2697  (action == 17 || action == 41)
2698  | ((flag&1)<<1) | ((action == 41) << 2));
2699  if(ret==2)
2700  deleted= 1;
2701  if(ret==3)
2702  no_dive= 1;
2703  if(ret>=0)
2704  ret= 1;
2705  } else if(action==16 || action==18) { /* not_in_iso , add_missing */
2706  ;
2707  } else if(action == 21) { /* report_damage */
2708  ret= Xorriso_report_damage(xorriso, show_path, node, 0);
2709  } else if(action == 22) {
2710  ret= Xorriso_report_lba(xorriso, show_path, node,
2711  &job->last_data_file_block, 0);
2712  } else if(action == 23) { /* internal: memorize path of last matching node */
2713  ret= Findjob_set_found_path(job, show_path, 0);
2714  } else if(action == 24) {
2715  ret= Xorriso_getfacl(xorriso, (void *) node, show_path, NULL, 0);
2716  } else if(action == 25) {
2717  if(target == NULL || target[0] || text_2 == NULL || text_2[0])
2718  ret= Xorriso_setfacl(xorriso, (void *) node, show_path, target, text_2,0);
2719  } else if(action == 26) {
2720  ret= Xorriso_getfattr(xorriso, (void *) node, show_path, NULL, 0);
2721  } else if(action == 27) {
2722  ret= Xorriso_path_setfattr(xorriso, (void *) node, show_path,
2723  target, strlen(text_2), text_2, 0);
2724  } else if(action == 28) { /* set_filter */
2725  ret= Xorriso_set_filter(xorriso, (void *) node, show_path, target, 1 | 2);
2726  } else if(action == 29 || action == 52) { /* show_stream , show_stream_id */
2727  ret= Xorriso_show_stream(xorriso, (void *) node, show_path, (action == 52));
2728  } else if(action == 30) { /* internal: count */
2729  xorriso->node_counter++;
2730  } else if(action == 31) { /* internal: register */
2731  if(xorriso->node_counter < xorriso->node_array_size) {
2732  xorriso->node_array[xorriso->node_counter++]= (void *) node;
2733  iso_node_ref(node); /* In case node gets deleted from tree during
2734  the lifetime of xorriso->node_array */
2735  }
2736  } else if(action == 32) { /* internal: widen_hardlinks disk_equiv */
2737  Findjob_get_start_path(job, &iso_prefix, 0);
2738  ret= Xorriso_widen_hardlink(xorriso, (void *) boss_iter, node, abs_path,
2739  iso_prefix, target, 0);
2740  if(ret==2)
2741  deleted= 1;
2742  } else if(action == 33) { /* get_any_xattr */
2743  ret= Xorriso_getfattr(xorriso, (void *) node, show_path, NULL, 8);
2744  } else if(action == 34) { /* get_md5 */
2745  ret= Xorriso_get_md5(xorriso, (void *) node, show_path, md5, 0);
2746  if(ret >= 0)
2747  ret= 1;
2748  } else if(action == 35) { /* check_md5 */
2749  ret= Xorriso_check_md5(xorriso, (void *) node, show_path, 2);
2750  if(ret == 0)
2751  xorriso->find_check_md5_result|= 1;
2752  else if(ret < 0)
2753  xorriso->find_check_md5_result|= 2;
2754  else if(ret == 1)
2755  xorriso->find_check_md5_result|= 8;
2756  else if(ret == 2)
2757  xorriso->find_check_md5_result|= 4;
2758  if(ret >= 0)
2759  ret= 1;
2760  } else if(action == 36) { /* make_md5 */
2761  ret= Xorriso_make_md5(xorriso, (void *) node, show_path, 0);
2762  if(ret >= 0)
2763  ret= 1;
2764  } else if(action == 37) { /* mkisofs_r */
2765  ret= Xorriso_mkisofs_lower_r(xorriso, node, 0);
2766  } else if(action == 38) { /* sort_weight */
2767  iso_node_set_sort_weight(node, type);
2768  Xorriso_set_change_pending(xorriso, 0);
2769  } else if(action == 39) { /* hide */
2770  Xorriso_set_hidden(xorriso, node, NULL, type, 0);
2771  } else if(action == 40) { /* estimate_size */
2772  basename= strrchr(abs_path, '/');
2773  if(basename != NULL)
2774  basename++;
2775  else
2776  basename= abs_path;
2777  ret= Xorriso_fake_stbuf(xorriso, "", &stbuf, &node, 1);
2778  if(ret > 0)
2779  ret= Xorriso_estimate_file_size(xorriso, job, basename, stbuf.st_mode,
2780  stbuf.st_size, 0);
2781  } else if(action == 42) { /* rm_merge */
2782  ret= Xorriso_mark_update_merge(xorriso, show_path, node, 2 | 4);
2783  if(ret == 2) {
2784  ret= Xorriso_rmi(xorriso, boss_iter, boss_mem, abs_path, 1|hflag);
2785  sprintf(xorriso->info_text, "Deleted ");
2786  Text_shellsafe(show_path, xorriso->info_text, 1);
2787  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0);
2788  deleted= 1;
2789  }
2790  } else if(action == 43) { /* clear_merge */
2791  ret= Xorriso_mark_update_merge(xorriso, show_path, node, 2 | 4);
2792  } else if(action == 44) { /* list_extattr */
2793  ret= Xorriso_list_extattr(xorriso, (void *) node, show_path, show_path,
2794  target, 0);
2795  } else if(action == 45) { /* set_hfs_crtp */
2796  ret= Xorriso_hfsplus_file_creator_type(xorriso, show_path, (void *) node,
2797  target, text_2, 0);
2798 
2799  } else if(action == 46) { /* get_hfs_crtp */
2800  ret= iso_node_get_xinfo(node, iso_hfsplus_xinfo_func, &xinfo);
2801  if(ret < 0) {
2802  Xorriso_process_msg_queues(xorriso, 0);
2803  ret= 0;
2804  } else if(ret == 1) {
2805  hfsplus_xinfo= (struct iso_hfsplus_xinfo_data *) xinfo;
2806  for(i= 0; i < 4; i++)
2807  xorriso->result_line[i]= hfsplus_xinfo->creator_code[i];
2808  xorriso->result_line[4]= ' ';
2809  for(i= 0; i < 4; i++)
2810  xorriso->result_line[5 + i]= hfsplus_xinfo->type_code[i];
2811  xorriso->result_line[9]= ' ';
2812  xorriso->result_line[10]= 0;
2813  Text_shellsafe(show_path, xorriso->result_line, 1);
2814  strcat(xorriso->result_line, "\n");
2815  Xorriso_result(xorriso, 0);
2816  }
2817  ret= 1;
2818  } else if(action == 47) { /* set_hfs_bless */
2819  if(strcmp(target, "none") == 0 ||
2820  strcmp(target, "n") == 0 || strcmp(target, "N") == 0) {
2821  ret= Xorriso_get_blessing(xorriso, node, &bless_idx, bless_code, 0);
2822  if(ret < 0)
2823  return(ret);
2824  if(ret == 0)
2825  return(1);
2826  unbless= 1;
2827  }
2828  ret= Xorriso_hfsplus_bless(xorriso, show_path, (void *) node, target, 0);
2829  /* If successful, end -find run gracefully */
2830  if(ret > 0) {
2831  if(unbless) {
2832  sprintf(xorriso->info_text, "HFS blessing '%s' revoked from ",
2833  bless_code);
2834  } else {
2835  sprintf(xorriso->info_text, "HFS blessing '%s' issued to ", target);
2836  }
2837  Text_shellsafe(show_path, xorriso->info_text, 1);
2838  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
2839  }
2840  if(!unbless)
2841  return(4);
2842  } else if(action == 48) { /* get_hfs_bless */
2843  ret= Xorriso_get_blessing(xorriso, node, &bless_idx, bless_code, 0);
2844  if (ret > 0) {
2845  sprintf(xorriso->result_line, "%-16.16s ", bless_code);
2846  Text_shellsafe(show_path, xorriso->result_line, 1);
2847  strcat(xorriso->result_line, "\n");
2848  Xorriso_result(xorriso, 0);
2849  } else if(ret == 0)
2850  ret= 1;
2851  } else if(action == 49) {
2852  /* internal: update creator, type, and blessings from persistent isofs.* */
2853  ret= Xorriso_get_attr_value(xorriso, node, show_path, "isofs.hx",
2854  &value_length, &value, 0);
2855  if(ret < 0)
2856  return(ret);
2857  if(ret > 0) {
2858  if(value_length >= 10) {
2859  ret= Xorriso_hfsplus_file_creator_type(xorriso, show_path,
2860  (void *) node,
2861  value + 2, value + 6, 4);
2862  } else
2863  ret= 1;
2864  free(value);
2865  if(ret <= 0)
2866  return(ret);
2867  }
2868  ret= Xorriso_get_attr_value(xorriso, node, show_path, "isofs.hb",
2869  &value_length, &value, 0);
2870  if(ret < 0)
2871  return(ret);
2872  if(ret > 0) {
2873  if(value_length >= 1) {
2874  bless_code[0]= value[0];
2875  bless_code[1]= 0;
2876  ret= Xorriso_hfsplus_bless(xorriso, show_path, (void *) node,
2877  bless_code, 0);
2878  } else
2879  ret= 1;
2880  free(value);
2881  if(ret <= 0)
2882  return(ret);
2883  }
2884  ret= 1;
2885 
2886  } else if(action == 50) { /* print_outname */
2887  ret= Xorriso_test_outchar(xorriso, (void *) node, type, 1);
2888  if(ret <= 0)
2889  return(ret);
2890 
2891  } else if(action == 51) { /* report_sections */
2892  ret= Xorriso_report_lba(xorriso, show_path, node,
2893  &job->last_data_file_block, 1);
2894 
2895  } else if(action == 53) { /* internal: show_hfs_cmd */
2896  ret= Xorriso_get_blessing(xorriso, node, &bless_idx, bless_code, 0);
2897  if (ret > 0) {
2898  if(xorriso->show_hfs_cmd_flag & 2) {
2899  sprintf(xorriso->result_line, "-hfs-bless-by %s ", bless_code);
2900  Text_shellsafe(show_path, xorriso->result_line, 1);
2901  } else {
2902  sprintf(xorriso->result_line, "-find ");
2903  Text_shellsafe(show_path, xorriso->result_line, 1);
2904  sprintf(xorriso->result_line + strlen(xorriso->result_line),
2905  " -exec set_hfs_bless %s --", bless_code);
2906  }
2907  ret= Xorriso_record_cmd_line(xorriso, xorriso->result_line,
2908  xorriso->show_hfs_cmds,
2909  &xorriso->show_hfs_cmd_count,
2910  (xorriso->show_hfs_cmd_flag & 1));
2911  if(ret <= 0)
2912  return(ret);
2913  }
2914  ret= iso_node_get_xinfo(node, iso_hfsplus_xinfo_func, &xinfo);
2915  if(ret < 0) {
2916  Xorriso_process_msg_queues(xorriso, 0);
2917  ret= 0;
2918  } else if(ret == 1) {
2919  hfsplus_xinfo= (struct iso_hfsplus_xinfo_data *) xinfo;
2920  for(i= 0; i < 4; i++)
2921  crtp[i]= hfsplus_xinfo->creator_code[i];
2922  crtp[4]= ' ';
2923  for(i= 0; i < 4; i++)
2924  crtp[5 + i]= hfsplus_xinfo->type_code[i];
2925  crtp[9]= 0;
2926  if(xorriso->show_hfs_cmd_flag & 2) {
2927  sprintf(xorriso->result_line, "-hfsplus-file-creator-type %s ", crtp);
2928  Text_shellsafe(show_path, xorriso->result_line, 1);
2929  } else {
2930  sprintf(xorriso->result_line, "-find ");
2931  Text_shellsafe(show_path, xorriso->result_line, 1);
2932  sprintf(xorriso->result_line + strlen(xorriso->result_line),
2933  " -exec set_hfs_crtp %s --", crtp);
2934  }
2935  ret= Xorriso_record_cmd_line(xorriso, xorriso->result_line,
2936  xorriso->show_hfs_cmds,
2937  &xorriso->show_hfs_cmd_count,
2938  (xorriso->show_hfs_cmd_flag & 1));
2939  if(ret <= 0)
2940  return(ret);
2941  }
2942  ret= 1;
2943 
2944  } else if(action == 54 || action == 56) { /* internal: truncate_name */
2945  ret= Xorriso_truncate_uniquely(xorriso, xorriso->file_name_limit,
2946  node, abs_path, show_path,
2947  2 * (action == 56));
2948 
2949  } else if(action == 55 || action == 57) {
2950  /* internal: unique_trunc_test length (in type) */
2951  ret= Xorriso_truncate_uniquely(xorriso, type, node, abs_path, show_path,
2952  1 | (2 * (action == 57)));
2953 
2954  } else if(action == 58) { /* internal: last_data_file_block */
2955  ret= Xorriso_report_lba(xorriso, show_path, node,
2956  &job->last_data_file_block, 2);
2957 
2958  } else if(action == 59) { /* set_to_mtime */
2959  ret= Xorriso_set_to_mtime(xorriso, show_path, node, 0);
2960 
2961  } else { /* includes : 15 in_iso */
2962  Xorriso_esc_filepath(xorriso, show_path, xorriso->result_line, 0);
2963  strcat(xorriso->result_line, "\n");
2964  Xorriso_result(xorriso, 0);
2965  ret= 1;
2966  }
2967  if(ret<=0)
2968  return(ret);
2969  if(deleted)
2970  return(2);
2971  if(no_dive)
2972  return(3);
2973  return(1);
2974 }
int Xorriso_find_compare(struct XorrisO *xorriso, void *boss_iter, void *node, char *iso_path, char *iso_prefix, char *disk_prefix, int flag)
Definition: cmp_update.c:721
int Xorriso_set_filter(struct XorrisO *xorriso, void *in_node, char *path, char *filter_name, int flag)
Definition: filters.c:265
int Findjob_set_found_path(struct FindjoB *o, char *path, int flag)
Definition: findjob.c:1091
int Findjob_get_start_path(struct FindjoB *o, char **start_path, int flag)
Definition: findjob.c:434
int Findjob_set_start_path(struct FindjoB *o, char *start_path, int flag)
Definition: findjob.c:420
int Findjob_get_action_parms(struct FindjoB *o, char **target, char **text_2, uid_t *user, gid_t *group, mode_t *mode_and, mode_t *mode_or, int *type, time_t *date, struct FindjoB **subjob, int flag)
Definition: findjob.c:1128
int Xorriso_record_cmd_line(struct XorrisO *xorriso, char *buf, char **cmds, int *cmd_count, int flag)
Definition: iso_img.c:1492
int Xorriso_set_to_mtime(struct XorrisO *xorriso, char *show_path, IsoNode *node, int flag)
Definition: iso_manip.c:2496
int Xorriso_get_blessing(struct XorrisO *xorriso, IsoNode *node, int *bless_idx, char bless_code[17], int flag)
Definition: iso_manip.c:4256
int Xorriso_mark_update_merge(struct XorrisO *xorriso, char *path, void *in_node, int flag)
Definition: iso_manip.c:3915
int Xorriso_estimate_file_size(struct XorrisO *xorriso, struct FindjoB *job, char *basename, mode_t st_mode, off_t st_size, int flag)
Definition: iso_manip.c:2390
int Xorriso_set_uid(struct XorrisO *xorriso, char *in_path, uid_t uid, int flag)
Definition: iso_manip.c:2008
int Xorriso_setfacl(struct XorrisO *xorriso, void *in_node, char *path, char *access_text, char *default_text, int flag)
Definition: iso_manip.c:2094
int Xorriso_set_st_mode(struct XorrisO *xorriso, char *in_path, mode_t mode_and, mode_t mode_or, int flag)
Definition: iso_manip.c:1979
int Xorriso_truncate_uniquely(struct XorrisO *xorriso, int length, IsoNode *node, char *abs_path, char *show_path, int flag)
Definition: iso_manip.c:4447
int Xorriso_mkisofs_lower_r(struct XorrisO *xorriso, IsoNode *node, int flag)
Definition: iso_manip.c:2069
int Xorriso_test_outchar(struct XorrisO *xorriso, void *node_pt, int name_space, int flag)
Definition: iso_manip.c:2413
int Xorriso_set_time(struct XorrisO *xorriso, char *in_path, time_t t, int flag)
Definition: iso_manip.c:2043
int Xorriso_path_setfattr(struct XorrisO *xorriso, void *in_node, char *path, char *name, size_t value_length, char *value, int flag)
Definition: iso_manip.c:3775
int Xorriso_hfsplus_bless(struct XorrisO *xorriso, char *path, void *in_node, char *blessing, int flag)
Definition: iso_manip.c:4140
int Xorriso_hfsplus_file_creator_type(struct XorrisO *xorriso, char *path, void *in_node, char *creator, char *hfs_type, int flag)
Definition: iso_manip.c:4066
int Xorriso_set_gid(struct XorrisO *xorriso, char *in_path, gid_t gid, int flag)
Definition: iso_manip.c:2025
int Xorriso_widen_hardlink(struct XorrisO *xorriso, void *boss_iter, IsoNode *node, char *abs_path, char *iso_prefix, char *disk_prefix, int flag)
Definition: iso_manip.c:2315
int Xorriso_get_md5(struct XorrisO *xorriso, void *in_node, char *path, char md5[16], int flag)
Definition: iso_tree.c:1339
int Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf, IsoNode **node, int flag)
Definition: iso_tree.c:245
int Xorriso_report_lba(struct XorrisO *xorriso, char *show_path, IsoNode *node, uint32_t *last_block, int flag)
Definition: iso_tree.c:2529
int Xorriso_get_attr_value(struct XorrisO *xorriso, void *in_node, char *path, char *name, size_t *value_length, char **value, int flag)
Definition: iso_tree.c:1263
int Xorriso_list_extattr(struct XorrisO *xorriso, void *in_node, char *path, char *show_path, char *mode, int flag)
Definition: iso_tree.c:991
int Xorriso_make_md5(struct XorrisO *xorriso, void *in_node, char *path, int flag)
Definition: iso_tree.c:1379
int Xorriso_report_damage(struct XorrisO *xorriso, char *show_path, IsoNode *node, int flag)
Definition: iso_tree.c:2570
int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd, int filec, char **filev, off_t boss_mem, int flag)
Definition: iso_tree.c:1724
int Xorriso_getfacl(struct XorrisO *xorriso, void *in_node, char *path, char **acl_text, int flag)
Definition: iso_tree.c:665
int Xorriso_show_stream(struct XorrisO *xorriso, void *in_node, char *path, int flag)
Definition: iso_tree.c:2394
int Xorriso_getfattr(struct XorrisO *xorriso, void *in_node, char *path, char **attr_text, int flag)
Definition: iso_tree.c:824
int Xorriso_check_md5(struct XorrisO *xorriso, void *in_node, char *path, int flag)
Definition: read_run.c:2595
unsigned long match_count
Definition: findjob.h:220
uint32_t last_data_file_block
Definition: findjob.h:206
struct FindjoB * subjob
Definition: findjob.h:205
int show_hfs_cmd_count
int find_check_md5_result
char result_line[10 *4096]
int file_name_limit
int show_hfs_cmd_flag
void ** node_array
char ** show_hfs_cmds
int node_counter
int node_array_size
char * Xorriso_esc_filepath(struct XorrisO *xorriso, char *in_text, char *out_text, int flag)
Definition: text_io.c:4742
int Xorriso_result(struct XorrisO *xorriso, int flag)
Definition: text_io.c:2337

References XorrisO::file_name_limit, XorrisO::find_check_md5_result, Findjob_get_action_parms(), Findjob_get_start_path(), Findjob_set_found_path(), Findjob_set_start_path(), XorrisO::info_text, FindjoB::last_data_file_block, FindjoB::match_count, XorrisO::node_array, XorrisO::node_array_size, XorrisO::node_counter, XorrisO::result_line, XorrisO::show_hfs_cmd_count, XorrisO::show_hfs_cmd_flag, XorrisO::show_hfs_cmds, FindjoB::subjob, Text_shellsafe(), Xorriso_check_md5(), Xorriso_esc_filepath(), Xorriso_estimate_file_size(), Xorriso_fake_stbuf(), Xorriso_find_compare(), Xorriso_findi(), Xorriso_get_attr_value(), Xorriso_get_blessing(), Xorriso_get_md5(), Xorriso_getfacl(), Xorriso_getfattr(), Xorriso_hfsplus_bless(), Xorriso_hfsplus_file_creator_type(), Xorriso_list_extattr(), Xorriso_ls_filev(), Xorriso_make_md5(), Xorriso_mark_update_merge(), Xorriso_mkisofs_lower_r(), Xorriso_msgs_submit(), Xorriso_path_setfattr(), Xorriso_process_msg_queues(), Xorriso_record_cmd_line(), Xorriso_report_damage(), Xorriso_report_lba(), Xorriso_result(), Xorriso_rmi(), Xorriso_set_change_pending(), Xorriso_set_filter(), Xorriso_set_gid(), Xorriso_set_hidden(), Xorriso_set_st_mode(), Xorriso_set_time(), Xorriso_set_to_mtime(), Xorriso_set_uid(), Xorriso_setfacl(), Xorriso_show_stream(), Xorriso_test_outchar(), Xorriso_truncate_uniquely(), and Xorriso_widen_hardlink().

Referenced by Xorriso_findi(), and Xorriso_findi_sorted().

◆ Xorriso_findi_headline()

int Xorriso_findi_headline ( struct XorrisO xorriso,
struct FindjoB job,
int  flag 
)

Definition at line 3327 of file iso_manip.c.

3329 {
3330  int action;
3331 
3332  action= Findjob_get_action(job, 0);
3333  if(action == 21) { /* report_damage */
3334  sprintf(xorriso->result_line, "Report layout: %8s , %8s , %8s , %s\n",
3335  "at byte", "Range", "Filesize", "ISO image path");
3336  Xorriso_result(xorriso, 0);
3337  } else if(action == 22 || action == 51) { /* report_lba, report_sections */
3338  sprintf(xorriso->result_line,
3339  "Report layout: %2s , %8s , %8s , %8s , %s\n",
3340  "xt", "Startlba", "Blocks", action == 22 ? "Filesize" : "Sectsize",
3341  "ISO image path");
3342  Xorriso_result(xorriso, 0);
3343  }
3344  return(1);
3345 }
int Findjob_get_action(struct FindjoB *o, int flag)
Definition: findjob.c:1120

References Findjob_get_action(), XorrisO::result_line, and Xorriso_result().

Referenced by Xorriso_findi(), and Xorriso_findi_sorted().

◆ Xorriso_findi_iter()

int Xorriso_findi_iter ( struct XorrisO xorriso,
IsoDir *  dir_node,
off_t *  mem,
IsoDirIter **  iter,
IsoNode ***  node_array,
int *  node_count,
int *  node_idx,
IsoNode **  iterated_node,
int  flag 
)

Definition at line 2528 of file iso_manip.c.

2532 {
2533  int ret, i;
2534  IsoNode *node;
2535  off_t new_mem= 0;
2536  char mem_text[80], limit_text[80];
2537 
2538  if(flag&1) {
2539  *node_array= NULL;
2540  *node_count= -1;
2541  *node_idx= 0;
2542  *iter= NULL;
2543  ret= iso_dir_get_children(dir_node, iter);
2544  if(ret<0) {
2545 cannot_iter:;
2546  Xorriso_cannot_create_iter(xorriso, ret, 0);
2547  return(-1);
2548  }
2549  if((flag&2)|(flag&4)) {
2550  /* copy list of nodes and prepare soft iterator */
2551  *node_count= 0;
2552  while(iso_dir_iter_next(*iter, &node) == 1)
2553  (*node_count)++;
2554  iso_dir_iter_free(*iter);
2555  *iter= NULL;
2556 
2557  new_mem= ((*node_count)+1) * sizeof(IsoNode *);
2558  if(new_mem > xorriso->temp_mem_limit) {
2559  Sfile_scale((double) new_mem, mem_text, 5,1e4, 0);
2560  Sfile_scale((double) xorriso->temp_mem_limit, limit_text, 5,1e4, 0);
2561  sprintf(xorriso->info_text,
2562  "Stacked directory snapshots exceed -temp_mem_limit (%s > %s)",
2563  mem_text, limit_text);
2564  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
2565  *node_count= -1;
2566  return(-1);
2567  }
2568  (*node_array)= (IsoNode **) calloc((*node_count)+1, sizeof(IsoNode *));
2569  if(*node_array == NULL) {
2570  sprintf(xorriso->info_text,
2571  "Could not allocate inode list of %.f bytes",
2572  ((double) (*node_count)+1) * (double) sizeof(IsoNode *));
2573  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
2574  *node_count= -1;
2575  return(-1);
2576  }
2577  *mem= new_mem;
2578  ret= iso_dir_get_children(dir_node, iter);
2579  if(ret<0)
2580  goto cannot_iter;
2581  while(iso_dir_iter_next(*iter, &node) == 1 && *node_idx < *node_count) {
2582  (*node_array)[*node_idx]= node;
2583  iso_node_ref(node);
2584  (*node_idx)++;
2585  }
2586  iso_dir_iter_free(*iter);
2587  *iter= NULL;
2588  *node_count= *node_idx;
2589  *node_idx= 0;
2590  if((flag&4) && *node_count>1)
2591  qsort(*node_array, *node_count, sizeof(IsoNode *),
2593  }
2594  }
2595 
2596  if(flag&(1u<<31)) {
2597  if(*node_count>=0 && *node_array!=NULL) {
2598  for(i= 0; i<*node_count; i++)
2599  iso_node_unref((*node_array)[i]);
2600  free(*node_array);
2601  *node_array= NULL;
2602  *node_count= -1;
2603  *node_idx= 0;
2604  } else {
2605  if(*iter!=NULL)
2606  iso_dir_iter_free(*iter);
2607  *iter= NULL;
2608  }
2609  }
2610 
2611  if(flag&(1|(1u<<31)))
2612  return(1);
2613  if(*node_count>=0) {
2614  /* return next node_array element */
2615  if(*node_idx>=*node_count)
2616  return(0);
2617  *iterated_node= (*node_array)[*node_idx];
2618  (*node_idx)++;
2619  } else {
2620  ret= iso_dir_iter_next(*iter, iterated_node);
2621  return(ret == 1);
2622  }
2623  return(1);
2624 }
int Xorriso_cannot_create_iter(struct XorrisO *xorriso, int iso_error, int flag)
Definition: iso_manip.c:2509
int Sfile_scale(double value, char *result, int siz, double thresh, int flag)
Definition: sfile.c:331
int Xorriso__node_lba_cmp(const void *node1, const void *node2)
Definition: sort_cmp.c:308

References XorrisO::info_text, Sfile_scale(), XorrisO::temp_mem_limit, Xorriso__node_lba_cmp(), Xorriso_cannot_create_iter(), and Xorriso_msgs_submit().

Referenced by Xorriso_findi(), Xorriso_restore_tree(), Xorriso_rmi(), and Xorriso_rmx().

◆ Xorriso_findi_sorted()

int Xorriso_findi_sorted ( struct XorrisO xorriso,
struct FindjoB job,
off_t  boss_mem,
int  filec,
char **  filev,
int  flag 
)

Definition at line 3572 of file iso_manip.c.

3574 {
3575  int i, ret, find_flag= 0;
3576  struct FindjoB array_job, *proxy_job= NULL, *hindmost= NULL, *hmboss= NULL;
3577  struct stat dir_stbuf;
3578  IsoNode *node;
3579  char *abs_path= NULL;
3580  off_t mem_needed= 0;
3581 
3582  array_job.start_path= NULL;
3583 
3584  Xorriso_alloc_meM(abs_path, char, SfileadrL);
3585 
3586  if(job->action == 14 || job->action == 17)
3587  find_flag|= 4;
3588  if(job->action>=9 && job->action<=13) { /* actions which have own findjobs */
3589  /* array_job replaces the hindmost job in the chain */
3590  for(hindmost= job; hindmost->subjob != NULL; hindmost= hindmost->subjob)
3591  hmboss= hindmost;
3592  if(hmboss == NULL)
3593  {ret= -1; goto ex;}
3594  memcpy(&array_job, hindmost, sizeof(struct FindjoB));
3595  hmboss->subjob= &array_job;
3596  proxy_job= job;
3597  } else {
3598  memcpy(&array_job, job, sizeof(struct FindjoB));
3599  proxy_job= &array_job;
3600  hindmost= job;
3601  }
3602  array_job.start_path= NULL; /* is owned by the original, not by array_job */
3603 
3604  /* Count matching nodes */
3605  Xorriso_destroy_node_array(xorriso, 0);
3606  array_job.action= 30; /* internal: count */
3607  for(i= 0; i < filec; i++) {
3608  if(flag & 1) {
3609  xorriso->node_counter++;
3610  continue;
3611  }
3612  ret= Findjob_set_start_path(proxy_job, filev[i], 0);
3613  if(ret <= 0)
3614  goto ex;
3615  ret= Xorriso_findi(xorriso, proxy_job, NULL, boss_mem, NULL,
3616  filev[i], &dir_stbuf, 0, find_flag);
3617  if(ret <= 0)
3618  goto ex;
3619  }
3620  if(xorriso->node_counter <= 0)
3621  {ret= 1; goto ex;}
3622 
3623  mem_needed= boss_mem + xorriso->node_counter * sizeof(IsoNode *);
3624  if(!(flag &1)) {
3625  ret= Xorriso_check_temp_mem_limit(xorriso, mem_needed, 0);
3626  if(ret <= 0) {
3627  /* Memory curbed : Perform unsorted find jobs */
3628  if(hmboss != NULL)
3629  hmboss->subjob= hindmost;
3630  for(i= 0; i < filec; i++) {
3631  ret= Findjob_set_start_path(job, filev[i], 0);
3632  if(ret <= 0)
3633  goto ex;
3634  ret= Xorriso_findi(xorriso, job, NULL, boss_mem, NULL,
3635  filev[i], &dir_stbuf, 0, find_flag);
3636  if(ret <= 0)
3637  if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)
3638  goto ex;
3639  }
3640  {ret= 1; goto ex;}
3641  }
3642  }
3643 
3644  /* Copy matching nodes into allocated array */
3645  ret= Xorriso_new_node_array(xorriso, xorriso->temp_mem_limit, 0, 0);
3646  if(ret <= 0)
3647  goto ex;
3648  array_job.action= 31; /* internal: register */
3649  xorriso->node_counter= 0;
3650  for(i= 0; i < filec; i++) {
3651  if(flag & 1) {
3652  ret= Xorriso_get_node_by_path(xorriso, filev[i], NULL, &node, 0);
3653  if(ret <= 0)
3654  goto ex;
3655  if(xorriso->node_counter < xorriso->node_array_size) {
3656  xorriso->node_array[xorriso->node_counter++]= (void *) node;
3657  iso_node_ref(node);
3658  }
3659  continue;
3660  }
3661  ret= Findjob_set_start_path(proxy_job, filev[i], 0);
3662  if(ret <= 0)
3663  goto ex;
3664  ret= Xorriso_findi(xorriso, proxy_job, NULL, mem_needed, NULL,
3665  filev[i], &dir_stbuf, 0, find_flag);
3666  if(ret <= 0)
3667  goto ex;
3668  }
3669 
3670  Xorriso_sort_node_array(xorriso, 0);
3671  if(flag & 2)
3672  {ret= 1; goto ex;}
3673 
3674  /* Perform job->action on xorriso->node_array */
3675 
3676  /* Headlines of actions report_damage , report_lba */;
3677  Xorriso_findi_headline(xorriso, job, 0);
3678 
3679  for(i= 0; i < xorriso->node_counter; i++) {
3680  node= xorriso->node_array[i];
3681  ret= Xorriso_path_from_node(xorriso, node, abs_path, 0);
3682  if(ret < 0)
3683  goto ex;
3684  if(ret == 0)
3685  continue; /* node is deleted from tree meanwhile */
3686 
3687  ret= Xorriso_findi_action(xorriso, hindmost, NULL, (off_t) 0,
3688  abs_path, abs_path, node, 0, 1);
3689  if(ret <= 0 || xorriso->request_to_abort)
3690  if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)
3691  goto ex;
3692  if(ret == 4) /* end gracefully */
3693  break;
3694  }
3695 
3696  ret= 1;
3697 ex:;
3698  if(!(flag & (2 | 4)))
3699  Xorriso_destroy_node_array(xorriso, 0);
3700  if(hmboss != NULL)
3701  hmboss->subjob= hindmost;
3702  if(array_job.start_path != NULL)
3703  free(array_job.start_path);
3704  Xorriso_free_meM(abs_path);
3705  return(ret);
3706 }
int Xorriso_findi_headline(struct XorrisO *xorriso, struct FindjoB *job, int flag)
Definition: iso_manip.c:3327
int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job, IsoDirIter *boss_iter, off_t boss_mem, char *abs_path, char *show_path, IsoNode *node, int depth, int flag)
Definition: iso_manip.c:2635
int Xorriso_path_from_node(struct XorrisO *xorriso, IsoNode *in_node, char path[4096], int flag)
Definition: iso_tree.c:399
int Xorriso_get_node_by_path(struct XorrisO *xorriso, char *in_path, char *eff_path, IsoNode **node, int flag)
Definition: iso_tree.c:199
int Xorriso_check_temp_mem_limit(struct XorrisO *xorriso, off_t mem, int flag)
Definition: parse_exec.c:2896
int Xorriso_sort_node_array(struct XorrisO *xorriso, int flag)
Definition: sort_cmp.c:82
int action
Definition: findjob.h:189
char * start_path
Definition: findjob.h:118

◆ Xorriso_get_blessing()

int Xorriso_get_blessing ( struct XorrisO xorriso,
IsoNode *  node,
int *  bless_idx,
char  bless_code[17],
int  flag 
)

Definition at line 4256 of file iso_manip.c.

4258 {
4259  IsoNode **blessed_nodes;
4260  int bless_max, ret, i;
4261 
4262  if(xorriso->in_volset_handle == NULL)
4263  return(0);
4264 
4265  ret= iso_image_hfsplus_get_blessed((IsoImage *) xorriso->in_volset_handle,
4266  &blessed_nodes, &bless_max, 0);
4267  Xorriso_process_msg_queues(xorriso, 0);
4268  if(ret < 0) {
4269  Xorriso_report_iso_error(xorriso, "", ret,
4270  "Error when trying to inquire HFS+ file blessings",
4271  0, "FAILURE", 1);
4272  return(-1);
4273  }
4274  for(i= 0; i < bless_max; i++) {
4275  if(blessed_nodes[i] == node) {
4276  switch (i) {
4277  case ISO_HFSPLUS_BLESS_PPC_BOOTDIR:
4278  strcpy(bless_code, "ppc_bootdir");
4279  break; case ISO_HFSPLUS_BLESS_INTEL_BOOTFILE:
4280  strcpy(bless_code, "intel_bootfile");
4281  break; case ISO_HFSPLUS_BLESS_SHOWFOLDER:
4282  strcpy(bless_code, "show_folder");
4283  break; case ISO_HFSPLUS_BLESS_OS9_FOLDER:
4284  strcpy(bless_code, "os9_folder");
4285  break; case ISO_HFSPLUS_BLESS_OSX_FOLDER:
4286  strcpy(bless_code, "osx_folder");
4287  break; default:
4288  strcpy(bless_code, "unknown_blessing");
4289  }
4290  *bless_idx= i;
4291  return(1);
4292  }
4293  }
4294  return(0);
4295 }
void * in_volset_handle

References XorrisO::in_volset_handle, Xorriso_process_msg_queues(), and Xorriso_report_iso_error().

Referenced by Exprtest_match(), and Xorriso_findi_action().

◆ Xorriso_graft_split()

int Xorriso_graft_split ( struct XorrisO xorriso,
IsoImage *  volume,
IsoDir *  dir,
char *  disk_path,
char *  img_name,
char *  nominal_source,
char *  nominal_target,
off_t  size,
IsoNode **  node,
int  flag 
)

Definition at line 118 of file iso_manip.c.

122 {
123  int ret;
124  IsoDir *new_dir= NULL;
125  IsoNode *part_node;
126  int partno, total_parts;
127  off_t offset;
128  char *part_name= NULL;
129 
130  Xorriso_alloc_meM(part_name, char, SfileadrL);
131 
132  ret= iso_image_add_new_dir(volume, dir, img_name, &new_dir);
133  if(ret < 0)
134  goto ex;
135  *node= (IsoNode *) new_dir;
136  if(xorriso->update_flags & 1) {
137  ret= Xorriso_mark_update_merge(xorriso, img_name, node, 1);
138  if(ret <= 0)
139  {ret= 0; goto ex;}
140  }
141  total_parts= size / xorriso->split_size;
142  if(size % xorriso->split_size)
143  total_parts++;
144  for(partno= 1; partno<=total_parts; partno++) {
145  offset = xorriso->split_size * (off_t) (partno-1);
146  Splitpart__compose(part_name, partno, total_parts, offset,
147  xorriso->split_size, size, 0);
148  ret= Xorriso_tree_graft_node(xorriso, volume,
149  new_dir, disk_path, part_name,
150  nominal_source, nominal_target,
151  offset, xorriso->split_size,
152  &part_node, 8);
153  if(ret<=0)
154  goto ex;
155  }
156  sprintf(xorriso->info_text, "Split into %d parts: ", total_parts);
157  Text_shellsafe(nominal_target, xorriso->info_text, 1);
158  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
159  ret= 1;
160 ex:;
161  Xorriso_free_meM(part_name);
162  return(ret);
163 }
int Splitpart__compose(char *adr, int partno, int total_parts, off_t offset, off_t bytes, off_t total_bytes, int flag)
Definition: aux_objects.c:218
off_t split_size
int update_flags

References XorrisO::info_text, SfileadrL, XorrisO::split_size, Splitpart__compose(), Text_shellsafe(), XorrisO::update_flags, Xorriso_alloc_meM, Xorriso_free_meM, Xorriso_mark_update_merge(), Xorriso_msgs_submit(), and Xorriso_tree_graft_node().

Referenced by Xorriso_tree_graft_node().

◆ Xorriso_mkisofs_lower_r()

int Xorriso_mkisofs_lower_r ( struct XorrisO xorriso,
IsoNode *  node,
int  flag 
)

Definition at line 2069 of file iso_manip.c.

2070 {
2071  mode_t perms;
2072 
2073  perms= iso_node_get_permissions(node);
2074  iso_node_set_uid(node, (uid_t) 0);
2075  iso_node_set_gid(node, (gid_t) 0);
2076  perms|= S_IRUSR | S_IRGRP | S_IROTH;
2077  perms&= ~(S_IWUSR | S_IWGRP | S_IWOTH);
2078  if(perms & (S_IXUSR | S_IXGRP | S_IXOTH))
2079  perms|= (S_IXUSR | S_IXGRP | S_IXOTH);
2080  perms&= ~(S_ISUID | S_ISGID | S_ISVTX);
2081  iso_node_set_permissions(node, perms);
2082  return(1);
2083 }

Referenced by Xorriso_findi_action().

◆ Xorriso_transfer_properties()

int Xorriso_transfer_properties ( struct XorrisO xorriso,
struct stat *  stbuf,
char *  disk_path,
IsoNode *  node,
int  flag 
)

Definition at line 48 of file iso_manip.c.

50 {
51  mode_t mode;
52  int ret= 1;
53  size_t num_attrs= 0, *value_lengths= NULL;
54  char **names= NULL, **values= NULL;
55 
56  mode= stbuf->st_mode;
57 
58  if((!(flag & 2)) && !(xorriso->do_aaip & 1))
59  /* Will drop ACL. Update mode S_IRWXG by eventual group:: ACL entry */
60  iso_local_get_perms_wo_acl(disk_path, &mode, flag & 32);
61 
62  if((flag & 1) && ((flag & 8) || S_ISDIR(mode))) {
63  if(mode&S_IRUSR)
64  mode|= S_IXUSR;
65  if(mode&S_IRGRP)
66  mode|= S_IXGRP;
67  if(mode&S_IROTH)
68  mode|= S_IXOTH;
69  }
70  iso_node_set_permissions(node, mode & 07777);
71  iso_node_set_uid(node, stbuf->st_uid);
72  iso_node_set_gid(node, stbuf->st_gid);
73  iso_node_set_atime(node, stbuf->st_atime);
74  iso_node_set_mtime(node, stbuf->st_mtime);
75  iso_node_set_ctime(node, stbuf->st_ctime);
76 
77  if((xorriso->do_aaip & 5) && !(flag & 2)) {
78  ret= iso_local_get_attrs(disk_path, &num_attrs, &names, &value_lengths,
79  &values, ((xorriso->do_aaip & 1) && !(flag & 2))
80  | ((!(xorriso->do_aaip & 4)) << 2)
81  | (flag & 32));
82  if(ret < 0) {
83  Xorriso_process_msg_queues(xorriso,0);
84  Xorriso_report_iso_error(xorriso, disk_path, ret,
85  "Error when obtaining local ACL and xattr", 0,
86  "FAILURE", 1 | 2);
87  ret= 0; goto ex;
88  }
89 
90  /* Preserve namespace isofs, but not ACL or system xattr */
91  ret= iso_node_set_attrs(node, num_attrs, names, value_lengths, values,
92  1 | 8 | 16);
93  if(ret < 0) {
94  Xorriso_process_msg_queues(xorriso,0);
95  Xorriso_report_iso_error(xorriso, "", ret,
96  "Error when setting ACL and xattr to image node",
97  0, "FAILURE", 1);
98  ret= 0; goto ex;
99  }
100  }
101 
102  if((flag & 4) && ((xorriso->do_aaip & 16) || !(xorriso->ino_behavior & 2))) {
103  ret= Xorriso_record_dev_inode(xorriso, disk_path, (dev_t) 0, (ino_t) 0,
104  (void *) node, "", flag & 32);
105  if(ret <= 0)
106  goto ex;
107  }
108 
109  ret= 1;
110 ex:;
111  Xorriso_process_msg_queues(xorriso,0);
112  iso_local_get_attrs(disk_path, &num_attrs, &names, &value_lengths,
113  &values, 1 << 15); /* free memory */
114  return(ret);
115 }
int Xorriso_record_dev_inode(struct XorrisO *xorriso, char *disk_path, dev_t dev, ino_t ino, void *in_node, char *iso_path, int flag)
Definition: iso_manip.c:2235
int ino_behavior

References XorrisO::do_aaip, XorrisO::ino_behavior, Xorriso_process_msg_queues(), Xorriso_record_dev_inode(), and Xorriso_report_iso_error().

Referenced by Xorriso_copy_implicit_properties(), Xorriso_copy_properties(), and Xorriso_graft_in().

◆ Xorriso_tree_graft_node()

int Xorriso_tree_graft_node ( struct XorrisO xorriso,
IsoImage *  volume,
IsoDir *  dir,
char *  disk_path,
char *  img_name,
char *  nominal_source,
char *  nominal_target,
off_t  offset,
off_t  cut_size,
IsoNode **  node,
int  flag 
)

Definition at line 175 of file iso_manip.c.

180 {
181  int ret, stbuf_valid= 0;
182  struct stat stbuf;
183  char *namept, *eff_name, *trunc_name= NULL;
184  off_t size= 0;
185 
186  eff_name= img_name;
187  if(lstat(disk_path, &stbuf) != -1) {
188  stbuf_valid= 1;
189  if(S_ISREG(stbuf.st_mode))
190  size= stbuf.st_size;
191  }
192  if((int) strlen(eff_name) > xorriso->file_name_limit) {
193  Xorriso_alloc_meM(trunc_name, char, SfileadrL);
194  strncpy(trunc_name, eff_name, SfileadrL - 1);
195  trunc_name[SfileadrL - 1]= 0;
196  ret= iso_truncate_leaf_name(1, xorriso->file_name_limit, trunc_name, 0);
197  if(ret < 0)
198  goto ex;
199  strcpy(xorriso->info_text, "File name had to be truncated and MD5 marked: ");
200  Text_shellsafe(eff_name, xorriso->info_text, 1);
201  strcat(xorriso->info_text, " -> ");
202  Text_shellsafe(trunc_name, xorriso->info_text, 1);
203  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
204  eff_name= trunc_name;
205  if(flag & 2)
206  strcpy(img_name, trunc_name);
207  }
208  if(flag&8) {
209  if(cut_size > xorriso->file_size_limit && xorriso->file_size_limit > 0) {
210  sprintf(xorriso->info_text,
211  "File piece exceeds size limit of %.f bytes: %.f from ",
212  (double) xorriso->file_size_limit, (double) cut_size);
213  Text_shellsafe(disk_path, xorriso->info_text, 1);
214  strcat(xorriso->info_text, "\n");
215  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
216  return(0);
217  }
218  ret= iso_tree_add_new_cut_out_node(volume, dir, eff_name, disk_path,
219  offset, cut_size, node);
220  if(ret<0)
221  goto ex;
222  } else {
223  if(xorriso->split_size > 0 && size > xorriso->split_size) {
224  ret= Xorriso_graft_split(xorriso, volume, dir, disk_path, eff_name,
225  nominal_source, nominal_target, size,
226  node, 0);
227  if(ret<=0)
228  goto ex;
229  } else if(size > xorriso->file_size_limit && xorriso->file_size_limit > 0) {
230  sprintf(xorriso->info_text,
231  "File exceeds size limit of %.f bytes: ",
232  (double) xorriso->file_size_limit);
233  Text_shellsafe(disk_path, xorriso->info_text, 1);
234  strcat(xorriso->info_text, "\n");
235  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
236  return(0);
237  } else {
238  ret= iso_tree_add_new_node(volume, dir, eff_name, disk_path, node);
239  if(ret<0)
240  goto ex;
241  }
242  }
243  if(flag & (256 | 512 | 1024)) {
244  ret= Xorriso_set_hidden(xorriso, (void *) *node, "", (flag >> 8) & 7, 0);
245  if(ret <= 0)
246  goto ex;
247  }
248  if(stbuf_valid && ((xorriso->do_aaip & 16) || !(xorriso->ino_behavior & 2))) {
249  ret= Xorriso_record_dev_inode(xorriso, disk_path,
250  stbuf.st_dev, stbuf.st_ino, (void *) *node, "", 1);
251  if(ret <= 0)
252  goto ex;
253  }
254  if(xorriso->update_flags & 1) {
255  ret= Xorriso_mark_update_merge(xorriso, eff_name, *node, 1);
256  if(ret <= 0)
257  goto ex;
258  }
259 
260 ex:;
261  if(ret<0) {
262  if(ret == (int) ISO_NODE_NAME_NOT_UNIQUE && (flag & 1)) {
263  iso_image_dir_get_node(volume, dir, eff_name, node, 0);
264  } else {
265  Xorriso_process_msg_queues(xorriso,0);
266  if(ret == (int) ISO_RR_NAME_TOO_LONG ||
267  ret == (int) ISO_RR_NAME_RESERVED ||
268  ret == (int) ISO_RR_PATH_TOO_LONG)
269  namept= nominal_target;
270  else
271  namept= nominal_source;
272  Xorriso_report_iso_error(xorriso, namept, ret,
273  "Cannot add node to tree", 0, "FAILURE", 1|2);
274  }
275  } else {
276  if(LIBISO_ISREG(*node))
277  xorriso->pacifier_byte_count+= iso_file_get_size((IsoFile *) *node);
278  ret= 1;
279  }
280  Xorriso_free_meM(trunc_name);
281  return(ret);
282 }
int Xorriso_graft_split(struct XorrisO *xorriso, IsoImage *volume, IsoDir *dir, char *disk_path, char *img_name, char *nominal_source, char *nominal_target, off_t size, IsoNode **node, int flag)
Definition: iso_manip.c:118
#define LIBISO_ISREG(node)
Definition: iso_tree.h:18
off_t file_size_limit
off_t pacifier_byte_count

References XorrisO::do_aaip, XorrisO::file_name_limit, XorrisO::file_size_limit, XorrisO::info_text, XorrisO::ino_behavior, LIBISO_ISREG, XorrisO::pacifier_byte_count, SfileadrL, XorrisO::split_size, Text_shellsafe(), XorrisO::update_flags, Xorriso_alloc_meM, Xorriso_free_meM, Xorriso_graft_split(), Xorriso_mark_update_merge(), Xorriso_msgs_submit(), Xorriso_process_msg_queues(), Xorriso_record_dev_inode(), Xorriso_report_iso_error(), and Xorriso_set_hidden().

Referenced by Xorriso_add_tree(), Xorriso_graft_in(), and Xorriso_graft_split().

◆ Xorriso_truncate_uniquely()

int Xorriso_truncate_uniquely ( struct XorrisO xorriso,
int  length,
IsoNode *  node,
char *  abs_path,
char *  show_path,
int  flag 
)

Definition at line 4447 of file iso_manip.c.

4450 {
4451  int ret, l, i;
4452  unsigned int mangleno;
4453  char *name, *trunc= NULL, *old_name= NULL;
4454  IsoDir *dir;
4455  IsoNode *collider;
4456  IsoImage *volume= NULL;
4457 
4458  name= (char *) iso_node_get_name(node);
4459  l= strlen(name);
4460 
4461  /* Check for truncated name */
4462  if(l == xorriso->file_name_limit && l != length && !(flag & 2)) {
4463  i= 0;
4464  if(name[l - 33] == ':') {
4465  for(i= l - 32; i < l; i++)
4466  if((name[i] < '0' || name[i] > '9') &&
4467  (name[i] < 'a' || name[i] > 'f'))
4468  break;
4469  }
4470  if(i == l) {
4471  if(!(flag & 4)) {
4472  sprintf(xorriso->info_text, "Truncated name of current limit found: ");
4473  Text_shellsafe(name, xorriso->info_text, 1);
4474  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
4475  }
4476  xorriso->find_unique_trunc_result= 0;
4477  {ret= 0; goto ex;}
4478  }
4479  }
4480 
4481  /* Check for need to truncate */
4482  if(l <= length)
4483  {ret= 1; goto ex;}
4484 
4485  if(xorriso->find_unique_trunc_result > 1)
4486  xorriso->find_unique_trunc_result= 1;
4487  trunc= strdup(name);
4488  old_name= strdup(name);
4489  if(trunc == NULL || old_name == NULL) {
4490  Xorriso_no_malloc_memory(xorriso, NULL, 0);
4491  ret= -1; goto ex;
4492  }
4493  ret= iso_truncate_leaf_name(1, length, trunc, 0);
4494  if(ret < 0) {
4495  Xorriso_process_msg_queues(xorriso, 0);
4496  Xorriso_report_iso_error(xorriso, "", ret,
4497  "Error when truncating file name", 0, "SORRY", 1);
4498  xorriso->find_unique_trunc_result= 0;
4499  {ret= 0; goto ex;}
4500  }
4501 
4502  dir= iso_node_get_parent(node);
4503  if(dir != NULL) {
4504  /* (intentionally using deprecated call which does not truncate by itself)*/
4505  ret= iso_dir_get_node(dir, trunc, &collider);
4506  if(ret == 1) {
4507  if((flag & 1) && !(flag & 2)) {
4508  if(!(flag & 4)) {
4509  sprintf(xorriso->info_text,
4510  "Truncated name collides with existing name: ");
4511  Text_shellsafe(name, xorriso->info_text, 1);
4512  strcat(xorriso->info_text, " -> ");
4513  Text_shellsafe(trunc, xorriso->info_text, 1);
4514  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
4515  }
4516  xorriso->find_unique_trunc_result= 0;
4517  {ret= 0; goto ex;}
4518  } else {
4519  /* Mangle */
4520  for(mangleno= 0; mangleno < 0xffffffff; mangleno++) {
4521  Sfile_flatten_utf8_heads(trunc, length - 33 - 9, 0);
4522  sprintf(trunc + length - 33 - 9, ":%-8.8X", mangleno);
4523  trunc [length - 33] = ':';
4524  ret= iso_dir_get_node(dir, trunc, &collider);
4525  if(ret == 0)
4526  break;
4527  }
4528  }
4529  }
4530  }
4531 
4532  /* If only for testing: done now */
4533  if(flag & 1)
4534  {ret= 1; goto ex;}
4535  if(xorriso->file_name_limit != length)
4536  {ret= -1; goto ex;} /* Programming error */
4537  ret= Xorriso_get_volume(xorriso, &volume, 1);
4538  if(ret < 0)
4539  {ret= -1; goto ex;} /* Programming error */
4540 
4541  /* Set truncated name */
4542  ret= iso_image_set_node_name(volume, node, trunc, 0);
4543  if(ret < 0) {
4544  Xorriso_process_msg_queues(xorriso, 0);
4545  xorriso->find_unique_trunc_result= 0;
4546  {ret= 0; goto ex;}
4547  }
4548  Xorriso_set_change_pending(xorriso, 0);
4549  sprintf(xorriso->info_text, "Truncated: ");
4550  Text_shellsafe(old_name, xorriso->info_text, 1);
4551  strcat(xorriso->info_text, " -> ");
4552  Text_shellsafe(trunc, xorriso->info_text, 1);
4553  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
4554 
4555  ret= 1;
4556 ex:;
4557  if(ret == 0 && (flag & 1) && !(flag & 4))
4558  xorriso->request_to_abort= 1;
4559  Xorriso_free_meM(old_name);
4560  Xorriso_free_meM(trunc);
4561  return(ret);
4562 }
int Sfile_flatten_utf8_heads(char *name, int idx, int flag)
Definition: sfile.c:971
int find_unique_trunc_result
int request_to_abort

References XorrisO::file_name_limit, XorrisO::find_unique_trunc_result, XorrisO::info_text, XorrisO::request_to_abort, Sfile_flatten_utf8_heads(), Text_shellsafe(), Xorriso_free_meM, Xorriso_get_volume(), Xorriso_msgs_submit(), Xorriso_no_malloc_memory(), Xorriso_process_msg_queues(), Xorriso_report_iso_error(), and Xorriso_set_change_pending().

Referenced by Exprtest_match(), and Xorriso_findi_action().

◆ Xorriso_widen_hardlink()

int Xorriso_widen_hardlink ( struct XorrisO xorriso,
void *  boss_iter,
IsoNode *  node,
char *  abs_path,
char *  iso_prefix,
char *  disk_prefix,
int  flag 
)

Definition at line 2315 of file iso_manip.c.

2319 {
2320  int ret= 0, idx, low, high, i, do_widen= 0, compare_result= 0;
2321  char *disk_path;
2322 
2323  Xorriso_alloc_meM(disk_path, char, SfileadrL);
2324 
2325  /* Lookup all di_array instances of node */
2326  if(LIBISO_ISDIR(node))
2327  {ret= 3; goto ex;}
2328  ret= Xorriso_search_di_range(xorriso, node, &idx, &low, &high, 2);
2329  if(ret <= 0)
2330  {ret= 3; goto ex;}
2331  /* Check and reset di_do_widen bits */
2332  for(i= low; i <= high; i++) {
2333  if(node != xorriso->di_array[i]) /* might be NULL */
2334  continue;
2335  if(xorriso->di_do_widen[i / 8] & (1 << (i % 8)))
2336  do_widen= 1;
2337  xorriso->di_do_widen[i / 8]&= ~(1 << (i % 8));
2338  }
2339  if(idx < 0 || !do_widen)
2340  {ret= 3; goto ex;}
2341 
2342  ret= Xorriso_pfx_disk_path(xorriso, abs_path, iso_prefix, disk_prefix,
2343  disk_path, 0);
2344  if(ret <= 0)
2345  goto ex;
2346  ret= Sfile_type(disk_path, 1);
2347  if(ret < 0)
2348  {ret= 3; goto ex;} /* does not exist on disk */
2349 
2350  /* >>> compare_result bit17 = is_split */;
2351 
2352  ret= Xorriso_update_interpreter(xorriso, boss_iter, NULL,
2353  compare_result, disk_path, abs_path, 1);
2354  if(ret <= 0)
2355  goto ex;
2356 ex:;
2357  Xorriso_free_meM(disk_path);
2358  return(ret);
2359 }
int Xorriso_pfx_disk_path(struct XorrisO *xorriso, char *iso_path, char *iso_prefix, char *disk_prefix, char disk_path[4096], int flag)
Definition: cmp_update.c:686
int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter, void *node, int compare_result, char *disk_path, char *iso_rr_path, int flag)
Definition: cmp_update.c:792
int Sfile_type(char *filename, int flag)
Definition: sfile.c:225
int Xorriso_search_di_range(struct XorrisO *xorriso, IsoNode *node, int *idx, int *low, int *high, int flag)
Definition: sort_cmp.c:272
void ** di_array
char * di_do_widen

References XorrisO::di_array, XorrisO::di_do_widen, LIBISO_ISDIR, Sfile_type(), SfileadrL, Xorriso_alloc_meM, Xorriso_free_meM, Xorriso_pfx_disk_path(), Xorriso_search_di_range(), and Xorriso_update_interpreter().

Referenced by Xorriso_findi_action().