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)  

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

Go to the source code of this file.

Macros

#define Xorrisoburn_includeD   yes
 
#define xorriso_libisoburn_req_major   1
 
#define xorriso_libisoburn_req_minor   5
 
#define xorriso_libisoburn_req_micro   4
 
#define Xorriso_IFBOOT   S_IFMT
 

Functions

int Xorriso_startup_libraries (struct XorrisO *xorriso, int flag)
 
int Xorriso_detach_libraries (struct XorrisO *xorriso, int flag)
 
int Xorriso_create_empty_iso (struct XorrisO *xorriso, int flag)
 
int Xorriso_aquire_drive (struct XorrisO *xorriso, char *adr, char *show_adr, int flag)
 
int Xorriso_give_up_drive (struct XorrisO *xorriso, int flag)
 
int Xorriso_write_session (struct XorrisO *xorriso, int flag)
 
int Xorriso_retry_write_session (struct XorrisO *xorriso, int flag)
 
int Xorriso_graft_in (struct XorrisO *xorriso, void *boss_iter, char *disk_path, char *img_path, off_t offset, off_t cut_size, int flag)
 
int Xorriso__text_to_sev (char *severity_name, int *severity_number, int flag)
 
int Xorriso__sev_to_text (int severity, char **severity_name, int flag)
 
int Xorriso_toc (struct XorrisO *xorriso, int flag)
 
int Xorriso_show_boot_info (struct XorrisO *xorriso, int flag)
 
int Xorriso_show_devices (struct XorrisO *xorriso, int flag)
 
int Xorriso_tell_media_space (struct XorrisO *xorriso, int *media_space, int *free_space, int flag)
 
int Xorriso_blank_media (struct XorrisO *xorriso, int flag)
 
int Xorriso_format_media (struct XorrisO *xorriso, off_t size, int flag)
 
int Xorriso_list_formats (struct XorrisO *xorriso, int flag)
 
int Xorriso_list_speeds (struct XorrisO *xorriso, int flag)
 
int Xorriso_list_profiles (struct XorrisO *xorriso, int flag)
 
int Xorriso_blank_as_needed (struct XorrisO *xorriso, int flag)
 
int Xorriso_rmi (struct XorrisO *xorriso, void *boss_iter, off_t boss_mem, char *path, int flag)
 
int Xorriso_ls_filev (struct XorrisO *xorriso, char *wd, int filec, char **filev, off_t boss_mem, int flag)
 
int Xorriso_ls (struct XorrisO *xorriso, int flag)
 
int Xorriso_get_dus (struct XorrisO *xorriso, char *iso_rr_path, off_t *size, off_t boss_mem, int flag)
 
int Xorriso_normalize_img_path (struct XorrisO *xorriso, char *wd, char *img_path, char eff_path[], int flag)
 
int Xorriso_rename (struct XorrisO *xorriso, void *boss_iter, char *origin, char *dest, int flag)
 
int Xorriso_mkdir (struct XorrisO *xorriso, char *img_path, int flag)
 
int Xorriso_expand_pattern (struct XorrisO *xorriso, int num_patterns, char **patterns, int extra_filec, int *filec, char ***filev, off_t *mem, int flag)
 
int Xorriso_set_st_mode (struct XorrisO *xorriso, char *path, mode_t mode_and, mode_t mode_or, int flag)
 
int Xorriso_set_uid (struct XorrisO *xorriso, char *in_path, uid_t uid, int flag)
 
int Xorriso_set_gid (struct XorrisO *xorriso, char *in_path, gid_t gid, int flag)
 
int Xorriso_set_time (struct XorrisO *xorriso, char *in_path, time_t t, int flag)
 
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)
 
int Xorriso_findi_sorted (struct XorrisO *xorriso, struct FindjoB *job, off_t boss_mem, int filec, char **filev, int flag)
 
int Xorriso_set_volid (struct XorrisO *xorriso, char *volid, int flag)
 
int Xorriso_get_volid (struct XorrisO *xorriso, char volid[33], int flag)
 
int Xorriso_set_abort_severity (struct XorrisO *xorriso, int flag)
 
int Xorriso_report_lib_versions (struct XorrisO *xorriso, int flag)
 
int Xorriso_iso_lstat (struct XorrisO *xorriso, char *path, struct stat *stbuf, int flag)
 
int Xorriso_atip (struct XorrisO *xorriso, int flag)
 
int Xorriso_burn_track (struct XorrisO *xorriso, off_t write_start_address, char *track_source, off_t tsize, int flag)
 
int Xorriso_retry_burn_track (struct XorrisO *xorriso, off_t write_start_address, char *track_source, off_t tsize, int flag)
 
int Xorriso_get_profile (struct XorrisO *xorriso, int *profile_number, char profile_name[80], int flag)
 
int Xorriso_iso_file_open (struct XorrisO *xorriso, char *pathname, void *node_pt, void **stream, int flag)
 
int Xorriso_iso_file_read (struct XorrisO *xorriso, void *stream, char *buf, int count, int flag)
 
int Xorriso_iso_file_close (struct XorrisO *xorriso, void **stream, int flag)
 
int Xorriso_iso_file_to_fd (struct XorrisO *xorriso, char *path, int fd, int flag)
 
int Xorriso_copy_properties (struct XorrisO *xorriso, char *disk_path, char *img_path, int flag)
 
int Xorriso_cut_out (struct XorrisO *xorriso, char *disk_path, off_t startbyte, off_t bytecount, char *iso_rr_path, int flag)
 
int Xorriso_paste_in (struct XorrisO *xorriso, char *disk_path, off_t startbyte, off_t bytecount, char *iso_rr_path, int flag)
 
int Xorriso_identify_split (struct XorrisO *xorriso, char *iso_adr, void *in_node, struct SplitparT **parts, int *count, struct stat *total_stbuf, int flag)
 
int Xorriso_is_split (struct XorrisO *xorriso, char *path, void *node, int flag)
 
int Xorriso_restore (struct XorrisO *xorriso, char *img_path, char *disk_path, off_t offset, off_t cut_size, int flag)
 
int Xorriso_restore_is_identical (struct XorrisO *xorriso, void *in_node, char *img_path, char *disk_path, char type_text[5], int flag)
 
int Xorriso_libburn_adr (struct XorrisO *xorriso, char *address_string, char official_adr[], int flag)
 
int Xorriso_msinfo (struct XorrisO *xorriso, int *msc1, int *msc2, int flag)
 
int Xorriso_update_iso_lba0 (struct XorrisO *xorriso, int iso_lba, int isosize, char *head_buffer, struct CheckmediajoB *job, int flag)
 
int Xorriso_truncate_overwritable (struct XorrisO *xorriso, char *adr_mode, char *adr_value, char *adjust, int flag)
 
int Xorriso_get_local_charset (struct XorrisO *xorriso, char **name, int flag)
 
int Xorriso_set_local_charset (struct XorrisO *xorriso, char *name, int flag)
 
int Xorriso_destroy_node_array (struct XorrisO *xorriso, int flag)
 
int Xorriso_destroy_hln_array (struct XorrisO *xorriso, int flag)
 
int Xorriso_destroy_di_array (struct XorrisO *xorriso, int flag)
 
int Xorriso_new_node_array (struct XorrisO *xorriso, off_t mem_limit, int addon_nodes, int flag)
 
int Xorriso_sort_node_array (struct XorrisO *xorriso, int flag)
 
int Xorriso_new_hln_array (struct XorrisO *xorriso, off_t mem_limit, int flag)
 
int Xorriso_restore_node_array (struct XorrisO *xorriso, int flag)
 
int Xorriso_check_md5 (struct XorrisO *xorriso, void *in_node, char *path, int flag)
 
int Xorriso_check_session_md5 (struct XorrisO *xorriso, char *severity, int flag)
 
int Xorriso_image_has_md5 (struct XorrisO *xorriso, int flag)
 
int Xorriso_check_media (struct XorrisO *xorriso, struct SpotlisT **spotlist, struct CheckmediajoB *job, int flag)
 
int Xorriso_extract_cut (struct XorrisO *xorriso, char *img_path, char *disk_path, off_t img_offset, off_t bytes, int flag)
 
int Xorriso_extract_boot_images (struct XorrisO *xorriso, char *disk_dir_path, int flag)
 
int Xorriso_relax_compliance (struct XorrisO *xorriso, char *mode, int flag)
 
int Xorriso_get_relax_text (struct XorrisO *xorriso, char mode[1024], int flag)
 
int Xorriso_mount (struct XorrisO *xorriso, char *dev, int adr_mode, char *adr_value, char *cmd, int flag)
 
int Xorriso_auto_driveadr (struct XorrisO *xorriso, char *adr, char *result, int flag)
 
int Xorriso_getfacl (struct XorrisO *xorriso, void *node, char *path, char **acl_text, int flag)
 
int Xorriso_getfattr (struct XorrisO *xorriso, void *in_node, char *path, char **attr_text, int flag)
 
int Xorriso_list_extattr (struct XorrisO *xorriso, void *in_node, char *path, char *show_path, char *mode, int flag)
 
int Xorriso_append_extattr_comp (struct XorrisO *xorriso, char *comp, size_t comp_len, char *mode, int flag)
 
int Xorriso_set_ignore_aclea (struct XorrisO *xorriso, int flag)
 
int Xorriso_setfacl (struct XorrisO *xorriso, void *in_node, char *path, char *access_text, char *default_text, int flag)
 
int Xorriso_get_attrs (struct XorrisO *xorriso, void *in_node, char *path, size_t *num_attrs, char ***names, size_t **value_lengths, char ***values, int flag)
 
int Xorriso_setfattr (struct XorrisO *xorriso, void *in_node, char *path, size_t num_attrs, char **names, size_t *value_lengths, char **values, int flag)
 
int Xorriso_perform_attr_from_list (struct XorrisO *xorriso, char *path, struct Xorriso_lsT *lst_start, int flag)
 
int Xorriso_path_setfattr (struct XorrisO *xorriso, void *in_node, char *path, char *name, size_t value_length, char *value, int flag)
 
int Xorriso_perform_acl_from_list (struct XorrisO *xorriso, char *file_path, char *uid, char *gid, char *acl, int flag)
 
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)
 
int Xorriso_local_getfacl (struct XorrisO *xorriso, char *disk_path, char **text, int flag)
 
int Xorriso_set_filter (struct XorrisO *xorriso, void *in_node, char *path, char *filter_name, int flag)
 
int Xorriso_external_filter (struct XorrisO *xorriso, char *name, char *options, char *path, int argc, char **argv, int flag)
 
int Xorriso_status_extf (struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
 
int Xorriso_destroy_all_extf (struct XorrisO *xorriso, int flag)
 
int Xorriso_show_stream (struct XorrisO *xorriso, void *in_node, char *path, int flag)
 
int Xorriso_set_zisofs_params (struct XorrisO *xorriso, int flag)
 
int Xorriso_status_zisofs (struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
 
int Xorriso_make_di_array (struct XorrisO *xorriso, int flag)
 
int Xorriso_make_hln_array (struct XorrisO *xorriso, int flag)
 
int Xorriso_hardlink_update (struct XorrisO *xorriso, int *compare_result, char *disk_path, char *iso_rr_path, int flag)
 
int Xorriso_finish_hl_update (struct XorrisO *xorriso, int flag)
 
int Xorriso_get_md5 (struct XorrisO *xorriso, void *in_node, char *path, char md5[16], int flag)
 
int Xorriso_make_md5 (struct XorrisO *xorriso, void *in_node, char *path, int flag)
 
int Xorriso_md5_start (struct XorrisO *xorriso, void **ctx, int flag)
 
int Xorriso_md5_compute (struct XorrisO *xorriso, void *ctx, char *data, int datalen, int flag)
 
int Xorriso_md5_end (struct XorrisO *xorriso, void **ctx, char md5[16], int flag)
 
int Xorriso_drive_snooze (struct XorrisO *xorriso, int flag)
 
int Xorriso_is_plain_image_file (struct XorrisO *xorriso, void *in_node, char *path, int flag)
 
int Xorriso_pvd_info (struct XorrisO *xorriso, int flag)
 
int Xorriso_set_change_pending (struct XorrisO *xorriso, int flag)
 
int Xorriso_scsi_log (struct XorrisO *xorriso, int flag)
 
int Xorriso_attach_boot_image (struct XorrisO *xorriso, int flag)
 
int Xorriso_boot_image_status (struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
 
int Xorriso_add_mips_boot_file (struct XorrisO *xorriso, char *path, int flag)
 
int Xorriso_set_hppa_boot_parm (struct XorrisO *xorriso, char *text, char *what, int flag)
 
int Xorriso_set_alpha_boot (struct XorrisO *xorriso, char *path, int flag)
 
int Xorriso_coordinate_system_area (struct XorrisO *xorriso, int sa_type, int options, char *cmd, int flag)
 
int Exprtest_match (struct XorrisO *xorriso, struct ExprtesT *ftest, void *node_pt, char *name, char *path, struct stat *boss_stbuf, struct stat *stbuf, int flag)
 
int Xorriso_toc_to_string (struct XorrisO *xorriso, char **toc_text, int flag)
 
int Xorriso_reaquire_outdev (struct XorrisO *xorriso, int flag)
 
int Xorriso_set_system_area_path (struct XorrisO *xorriso, char *path, int flag)
 
int Xorriso_set_hidden (struct XorrisO *xorriso, void *in_node, char *path, int hide_state, int flag)
 
int Xorriso_preparer_string (struct XorrisO *xorriso, char xorriso_id[129], int flag)
 
int Xorriso_jigdo_interpreter (struct XorrisO *xorriso, char *aspect, char *arg, int flag)
 
int Xorriso_estimate_file_size (struct XorrisO *xorriso, struct FindjoB *job, char *basename, mode_t st_mode, off_t st_size, int flag)
 
int Xorriso_clone_tree (struct XorrisO *xorriso, void *boss_iter, char *origin, char *dest, int flag)
 
int Xorriso_clone_under (struct XorrisO *xorriso, char *origin, char *dest, int flag)
 
int Xorriso_mark_update_merge (struct XorrisO *xorriso, char *path, void *node, int flag)
 
int Xorriso_set_signal_handling (struct XorrisO *xorriso, int flag)
 
int Xorriso_close_damaged (struct XorrisO *xorriso, int flag)
 
int Xorriso_list_extras (struct XorrisO *xorriso, char *mode, int flag)
 
int Xorriso_set_data_cache (struct XorrisO *xorriso, void *ropts, int num_tiles, int tile_blocks, int flag)
 
int Xorriso_hfsplus_file_creator_type (struct XorrisO *xorriso, char *path, void *in_node, char *creator, char *hfs_type, int flag)
 
int Xorriso_hfsplus_bless (struct XorrisO *xorriso, char *path, void *in_node, char *blessing, int flag)
 
int Xorriso_pretend_full_disc (struct XorrisO *xorriso, int flag)
 
int Xorriso_scsi_dev_family (struct XorrisO *xorriso, int flag)
 
int Xorriso_use_immed_bit (struct XorrisO *xorriso, int flag)
 
int Xorriso_apply_sort_file (struct XorrisO *xorriso, char *path, int flag)
 
int Xorriso_report_system_area (struct XorrisO *xorriso, char *form, int flag)
 
int Xorriso_list_boot_images (struct XorrisO *xorriso, char ***imgs, int *img_count, int flag)
 
int Xorriso_external_filter_banned (struct XorrisO *xorriso, char *purpose, int flag)
 
int Xorriso_set_file_name_limit (struct XorrisO *xorriso, int value, int flag)
 
int Xorriso_truncate_path_comps (struct XorrisO *xorriso, char *path, char *buffer, char **resultpt, int flag)
 
int Xorriso_graftable_pathspec (struct XorrisO *xorriso, char *in_pathspec, char *pathspec, int flag)
 
int Xorriso_parse_guid (struct XorrisO *xorriso, char *text, uint8_t guid[16], int flag)
 
int Xorriso_parse_gpt_guid (struct XorrisO *xorriso, char *text, int flag)
 
int Xorriso_parse_type_guid (struct XorrisO *xorriso, char *text, uint8_t guid[16], int *mbr_type, int flag)
 
int Xorriso_format_guid (struct XorrisO *xorriso, uint8_t guid[16], char *line, int flag)
 
int Xorriso_make_guid (struct XorrisO *xorriso, char *line, int flag)
 
int Xorriso_set_libisofs_now (struct XorrisO *xorriso, int flag)
 
int Xorriso_obtain_indev_readsize (struct XorrisO *xorriso, uint32_t *blocks, int flag)
 

Macro Definition Documentation

◆ Xorriso_IFBOOT

#define Xorriso_IFBOOT   S_IFMT

Definition at line 573 of file xorrisoburn.h.

◆ xorriso_libisoburn_req_major

#define xorriso_libisoburn_req_major   1

Definition at line 20 of file xorrisoburn.h.

◆ xorriso_libisoburn_req_micro

#define xorriso_libisoburn_req_micro   4

Definition at line 22 of file xorrisoburn.h.

◆ xorriso_libisoburn_req_minor

#define xorriso_libisoburn_req_minor   5

Definition at line 21 of file xorrisoburn.h.

◆ Xorrisoburn_includeD

#define Xorrisoburn_includeD   yes

Definition at line 15 of file xorrisoburn.h.

Function Documentation

◆ Exprtest_match()

int Exprtest_match ( struct XorrisO xorriso,
struct ExprtesT ftest,
void *  node_pt,
char *  name,
char *  path,
struct stat *  boss_stbuf,
struct stat *  stbuf,
int  flag 
)

Definition at line 3018 of file iso_manip.c.

3029 {
3030  int value=0, ret, start_lba, end_lba, bless_idx;
3031  int lba_count, *file_end_lbas= NULL, *file_start_lbas= NULL, i, mask;
3032  void *arg1, *arg2;
3033  char ft, *decision, md5[16], bless_code[17];
3034  regmatch_t name_match;
3035  off_t damage_start, damage_end, size, *section_sizes= NULL;
3036  void *xinfo_dummy;
3037  IsoNode *node;
3038  IsoStream *stream;
3039  struct iso_hfsplus_xinfo_data *hfsplus_xinfo;
3040 
3041  if(ftest == NULL)
3042  return(1);
3043 
3044  node= (IsoNode *) node_pt;
3045  arg1= ftest->arg1;
3046  arg2= ftest->arg2;
3047 
3048  if(node == NULL) {
3049  switch(ftest->test_type) {
3050  case 0: case 1: case 2: case 4: case 11: case 12: case 13:
3051  case 22: case 23: case 25: case 26:
3052  /* Tests which need no node parameter */
3053  break;
3054  default:
3055  value= 0;
3056  goto ex;
3057  }
3058  }
3059 
3060  switch(ftest->test_type) {
3061  case 0: /* -false */
3062  value= 0;
3063 
3064  break; case 1: /* -name *arg1 (regex in *arg2) */
3065  if (ftest->boss->use_pattern) {
3066  ret= regexec(arg2, name, 1, &name_match, 0);
3067  value= !ret;
3068  } else {
3069  value= (strcmp((char *) arg1, name) == 0);
3070  }
3071 
3072  break; case 2: /* -type *arg1 */
3073  value= 1;
3074  ft= *((char *) arg1);
3075  if(ft!=0) {
3076  if(S_ISBLK(stbuf->st_mode)) {
3077  if(ft!='b')
3078  value= 0;
3079  } else if(S_ISCHR(stbuf->st_mode)) {
3080  if(ft!='c')
3081  value= 0;
3082  } else if(S_ISDIR(stbuf->st_mode)) {
3083  if(ft=='m') {
3084  if(node != NULL)
3085  value= 0;
3086  else if(boss_stbuf==NULL)
3087  value= 0;
3088  else if(boss_stbuf->st_dev == stbuf->st_dev)
3089  value= 0;
3090  } else if(ft!='d')
3091  value= 0;
3092  } else if(S_ISFIFO(stbuf->st_mode)) {
3093  if(ft!='p')
3094  value= 0;
3095  } else if(S_ISREG(stbuf->st_mode)) {
3096  if(ft!='f' && ft!='-')
3097  value= 0;
3098  } else if(((stbuf->st_mode)&S_IFMT)==S_IFLNK) {
3099  if(ft!='l')
3100  value= 0;
3101  } else if(((stbuf->st_mode)&S_IFMT)==S_IFSOCK) {
3102  if(ft!='s')
3103  value= 0;
3104  } else if((flag & 1) && ((stbuf->st_mode) & S_IFMT) == Xorriso_IFBOOT) {
3105  if(ft!='e' || node == NULL)
3106  value= 0;
3107  } else {
3108  if(ft!='X')
3109  value= 0;
3110  }
3111  }
3112 
3113  break; case 3: /* -damaged */;
3114  value= Xorriso_file_eval_damage(xorriso, node, &damage_start, &damage_end,
3115  0);
3116  if(value > 0)
3117  value= 1;
3118 
3119  break; case 4: /* -lba_range *arg1 *arg2 */
3120  value= 1;
3121  start_lba= *((int *) ftest->arg1);
3122  end_lba= *((int *) ftest->arg2);
3123  if(node == NULL) {
3124  value= !(start_lba >= 0);
3125  goto ex;
3126  }
3127  ret= Xorriso__start_end_lbas(node, &lba_count, &file_start_lbas,
3128  &file_end_lbas, &section_sizes, &size, 0);
3129  if(ret <= 0) {
3130  if(ret < 0)
3131  Xorriso_process_msg_queues(xorriso, 0);
3132  if(start_lba >= 0)
3133  value= 0;
3134  } else {
3135  for(i= 0; i < lba_count; i++) {
3136  if(start_lba >= 0) {
3137  if(file_end_lbas[i] < start_lba || file_start_lbas[i] > end_lba)
3138  value= 0;
3139  } else {
3140  if(file_end_lbas[i] >= -start_lba && file_start_lbas[i] <= -end_lba)
3141  value= 0;
3142  }
3143  }
3144  }
3145 
3146  break; case 5: /* -has_acl */
3147  ret = Xorriso_getfacl(xorriso, (void *) node, "", NULL, 2);
3148  if(ret <= 0) {
3149  value= -1;
3150  Xorriso_process_msg_queues(xorriso, 0);
3151  goto ex;
3152  }
3153  value= (ret == 1);
3154 
3155  break; case 6: /* -has_xattr */
3156  case 14: /* -has_any_xattr */
3157  ret = Xorriso_getfattr(xorriso, (void *) node, "", NULL,
3158  64 | (8 * (ftest->test_type == 14)));
3159  if(ret < 0) {
3160  value= -1;
3161  Xorriso_process_msg_queues(xorriso, 0);
3162  goto ex;
3163  }
3164  value= (ret > 0);
3165 
3166  break; case 7: /* -has_aaip */
3167  ret= iso_node_get_xinfo(node, aaip_xinfo_func, &xinfo_dummy);
3168  if(ret < 0) {
3169  value= -1;
3170  Xorriso_process_msg_queues(xorriso, 0);
3171  goto ex;
3172  }
3173  value= (ret > 0);
3174 
3175  break; case 8: /* -has_filter */
3176  value= 0;
3177  if(LIBISO_ISREG(node)) {
3178  stream= iso_file_get_stream((IsoFile *) node);
3179  if(iso_stream_get_input_stream(stream, 0) != NULL)
3180  value= 1;
3181  }
3182 
3183  break; case 9: /* -wanted_node arg1 (for internal use) */
3184  value= (((IsoNode *) arg1) == node);
3185 
3186  break; case 10: /* -pending_data */
3187  value= 1;
3188  if(!LIBISO_ISREG(node)) {
3189  value= 0;
3190  } else {
3191  ret= Xorriso__file_start_lba(node, &start_lba, 0);
3192  if(ret > 0 && start_lba >= 0)
3193  value= 0;
3194  }
3195 
3196  break; case 11: /* -decision */
3197  value= 2;
3198  decision= (char *) arg1;
3199  if(strcmp(decision, "yes") == 0 || strcmp(decision, "true") == 0)
3200  value= 3;
3201 
3202  break; case 12: /* -prune */
3203  value= 1;
3204  ftest->boss->prune= 1;
3205 
3206  break; case 13: /* -wholename *arg1 (regex in *arg2) */
3207  if (ftest->boss->use_pattern) {
3208  ret= regexec(arg2, path, 1, &name_match, 0);
3209  value= !ret;
3210  } else {
3211  value= (strcmp(arg1, path) == 0);
3212  }
3213 
3214  break; case 15: /* -has_md5 */
3215  ret= Xorriso_get_md5(xorriso, node, path, md5, 1);
3216  value= (ret > 0);
3217 
3218  break; case 16: /* -disk_name *arg1 (regex in *arg2) */
3219  value= !! Exprtest_match_disk_name(xorriso, ftest, node,
3220  2 * (ftest->boss->use_pattern));
3221 
3222  break; case 17: /* -hidden int *arg1 */
3223  value= 1;
3224  ret= iso_node_get_hidden(node);
3225  mask= *((int *) arg1) & 3;
3226  if((!!(mask & 1)) ^ (!!(ret & LIBISO_HIDE_ON_RR)))
3227  value= 0;
3228  if((!!(mask & 2)) ^ (!!(ret & LIBISO_HIDE_ON_JOLIET)))
3229  value= 0;
3230  if((!!(mask & 3)) ^ (!!(ret & LIBISO_HIDE_ON_HFSPLUS)))
3231  value= 0;
3232 
3233  break; case 18: /* -has_hfs_crtp char *creator char *type */
3234  ret= iso_node_get_xinfo(node, iso_hfsplus_xinfo_func, &xinfo_dummy);
3235  value= 0;
3236  if(ret < 0) {
3237  Xorriso_process_msg_queues(xorriso, 0);
3238  ret= 0;
3239  } else if(ret == 1) {
3240  hfsplus_xinfo= (struct iso_hfsplus_xinfo_data *) xinfo_dummy;
3241  if((strlen(arg1) == 1 ||
3242  (strncmp(arg1, (char *) hfsplus_xinfo->creator_code, 4) == 0 &&
3243  strlen(arg1) == 4)) &&
3244  (strlen(arg2) == 1 ||
3245  (strncmp(arg2, (char *) hfsplus_xinfo->type_code, 4) == 0 &&
3246  strlen(arg2) == 4)))
3247  value= 1;
3248  }
3249 
3250  break; case 19: /* -has_hfs_bless int bless_index */
3251  value= 0;
3252  ret= Xorriso_get_blessing(xorriso, node, &bless_idx, bless_code, 0);
3253  if (ret > 0) {
3254  if(*((int *) arg1) == (int) ISO_HFSPLUS_BLESS_MAX ||
3255  *((int *) arg1) == bless_idx)
3256  value= 1;
3257  }
3258 
3259  break; case 20: /* -disk_path */
3260  value= !! Exprtest_match_disk_name(xorriso, ftest, node,
3261  1 | 2 * (ftest->boss->use_pattern));
3262 
3263  break; case 21: /* -bad_outname */
3264  ret= Xorriso_test_outchar(xorriso, node, *((int *) arg1), 0);
3265  if(ret < 0) {
3266  value= -1;
3267  goto ex;
3268  }
3269  value= !ret; /* Xorriso_test_outchar() returns 1 for good and 0 for bad */
3270 
3271  break; case 22: /* -use_pattern */
3272  ftest->boss->use_pattern= (strcmp(arg1, "off") != 0);
3273  value= 1;
3274 
3275  break; case 23: /* -or_use_pattern */
3276  ftest->boss->use_pattern= (strcmp(arg1, "off") != 0);
3277  value= 0;
3278 
3279  break; case 24: /* -name_limit_blocker */
3280  ret= Xorriso_truncate_uniquely(xorriso, *((int *) arg1), node, path, path,
3281  1 | 4);
3282  value= (ret == 0);
3283 
3284  break; case 25: /* -maxdepth */
3285  value= (ftest->boss->depth <= *((int *) arg1));
3286 
3287  break; case 26: /* -mindepth */
3288  value= (ftest->boss->depth >= *((int *) arg1));
3289 
3290  break; default:
3291 
3292  /* >>> complain about unknown test type */;
3293 
3294  value= -1;
3295 
3296  }
3297 
3298 ex:;
3299  if(ftest->invert && value<=1 && value>=0)
3300  value= !value;
3301  if(file_start_lbas != NULL)
3302  free((char *) file_start_lbas);
3303  if(file_end_lbas != NULL)
3304  free((char *) file_end_lbas);
3305  if(section_sizes != NULL)
3306  free((char *) section_sizes);
3307  return(value);
3308 }
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_truncate_uniquely(struct XorrisO *xorriso, int length, IsoNode *node, char *abs_path, char *show_path, int flag)
Definition: iso_manip.c:4447
int Xorriso_test_outchar(struct XorrisO *xorriso, void *node_pt, int name_space, int flag)
Definition: iso_manip.c:2413
int Exprtest_match_disk_name(struct XorrisO *xorriso, struct ExprtesT *ftest, IsoNode *node, int flag)
Definition: iso_manip.c:2980
int Xorriso__file_start_lba(IsoNode *node, int *lba, int flag)
Definition: iso_tree.c:2259
int Xorriso_get_md5(struct XorrisO *xorriso, void *in_node, char *path, char md5[16], int flag)
Definition: iso_tree.c:1339
int Xorriso_getfacl(struct XorrisO *xorriso, void *in_node, char *path, char **acl_text, int flag)
Definition: iso_tree.c:665
int Xorriso_getfattr(struct XorrisO *xorriso, void *in_node, char *path, char **attr_text, int flag)
Definition: iso_tree.c:824
int Xorriso_file_eval_damage(struct XorrisO *xorriso, IsoNode *node, off_t *damage_start, off_t *damage_end, int flag)
Definition: iso_tree.c:2477
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
#define LIBISO_ISREG(node)
Definition: iso_tree.h:18
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
struct FindjoB * boss
Definition: findjob.h:26
void * arg2
Definition: findjob.h:62
void * arg1
Definition: findjob.h:61
int invert
Definition: findjob.h:28
int test_type
Definition: findjob.h:59
int use_pattern
Definition: findjob.h:191
int prune
Definition: findjob.h:190
int depth
Definition: findjob.h:223
#define Xorriso_IFBOOT
Definition: xorrisoburn.h:573

References ExprtesT::arg1, ExprtesT::arg2, ExprtesT::boss, FindjoB::depth, Exprtest_match_disk_name(), ExprtesT::invert, LIBISO_ISREG, FindjoB::prune, ExprtesT::test_type, FindjoB::use_pattern, Xorriso__file_start_lba(), Xorriso__start_end_lbas(), Xorriso_file_eval_damage(), Xorriso_get_blessing(), Xorriso_get_md5(), Xorriso_getfacl(), Xorriso_getfattr(), Xorriso_IFBOOT, Xorriso_process_msg_queues(), Xorriso_test_outchar(), and Xorriso_truncate_uniquely().

Referenced by Exprnode_own_value().

◆ Xorriso__sev_to_text()

int Xorriso__sev_to_text ( int  severity,
char **  severity_name,
int  flag 
)

Definition at line 371 of file lib_mgt.c.

373 {
374  int ret;
375 
376  ret= iso_sev_to_text(severity, severity_name);
377  if(ret>0)
378  return(ret);
379  ret= burn_sev_to_text(severity, severity_name, 0);
380  if(ret>0)
381  return(ret);
382  *severity_name= "";
383  return(0);
384 }

Referenced by Xorriso_option_abort_on(), Xorriso_option_report_about(), Xorriso_option_return_with(), and Xorriso_report_iso_error().

◆ Xorriso__text_to_sev()

int Xorriso__text_to_sev ( char *  severity_name,
int *  severity_number,
int  flag 
)

Definition at line 387 of file lib_mgt.c.

388 {
389  int ret= 1;
390  char severity[20];
391 
392  Xorriso__to_upper(severity_name, severity, (int) sizeof(severity), 0);
393  ret= iso_text_to_sev(severity, severity_number);
394  if(ret>0)
395  return(ret);
396  ret= burn_text_to_sev(severity, severity_number, 0);
397  return(ret);
398 }
int Xorriso__to_upper(char *in, char *out, int out_size, int flag)
Definition: misc_funct.c:1301

References Xorriso__to_upper().

Referenced by Xorriso__severity_cmp(), Xorriso_check_media_setup_job(), Xorriso_eval_problem_status(), Xorriso_info(), Xorriso_msg_watcher(), Xorriso_msgs_submit(), Xorriso_new(), Xorriso_option_abort_on(), Xorriso_option_assert_volid(), Xorriso_option_check_md5(), Xorriso_option_report_about(), Xorriso_option_return_with(), Xorriso_report_iso_error(), Xorriso_set_abort_severity(), and Xorriso_set_problem_status().

◆ Xorriso_add_mips_boot_file()

int Xorriso_add_mips_boot_file ( struct XorrisO xorriso,
char *  path,
int  flag 
)

Definition at line 1227 of file iso_img.c.

1228 {
1229  int ret;
1230  IsoImage *image;
1231  char *paths[15];
1232 
1233  ret= Xorriso_get_volume(xorriso, &image, 0);
1234  if(ret <= 0)
1235  return ret;
1236  if(flag & 1) {
1237  iso_image_give_up_mips_boot(image, 0);
1238  Xorriso_process_msg_queues(xorriso,0);
1239  return(1);
1240  }
1241  if(flag & 2) {
1242  ret= iso_image_get_mips_boot_files(image, paths, 0);
1243  Xorriso_process_msg_queues(xorriso,0);
1244  if(ret < 0)
1245  goto report_error;
1246  if(ret > 0) {
1247  Xorriso_msgs_submit(xorriso, 0,
1248  "There is already a boot image file registered.",
1249  0, "FAILURE", 0);
1250  return(0);
1251  }
1252  }
1253  ret = iso_image_add_mips_boot_file(image, path, 0);
1254  Xorriso_process_msg_queues(xorriso,0);
1255  if (ret < 0) {
1256 report_error:;
1257  Xorriso_report_iso_error(xorriso, "", ret,
1258  "Error when adding MIPS boot file",
1259  0, "FAILURE", 1);
1260  return(0);
1261  }
1262  return(1);
1263 }
int Xorriso_get_volume(struct XorrisO *xorriso, IsoImage **volume, int flag)
Definition: iso_img.c:966
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
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

References Xorriso_get_volume(), Xorriso_msgs_submit(), Xorriso_process_msg_queues(), and Xorriso_report_iso_error().

Referenced by Xorriso_option_boot_image().

◆ Xorriso_append_extattr_comp()

int Xorriso_append_extattr_comp ( struct XorrisO xorriso,
char *  comp,
size_t  comp_len,
char *  mode,
int  flag 
)

Definition at line 916 of file iso_tree.c.

919 {
920  int ret;
921  size_t line_limit;
922  char *line, *wpt, *bsl = NULL;
923  unsigned char *upt, *uval;
924 
925  line= xorriso->result_line;
926  line_limit= sizeof(xorriso->result_line);
927  uval= (unsigned char *) comp;
928 
929  if(*mode == 'q') {
930  Text_shellsafe(comp, line, 1);
931  } else if(*mode == 'e' || mode[0] == 0) {
932  for(upt= uval; (size_t) (upt - uval) < comp_len; upt++)
933  if(*upt <= 037 || *upt >= 0177)
934  break;
935  if((size_t) (upt - uval) < comp_len || (flag & 1)) {
936  /* Use "$(echo -e '\0xyz')" */;
937  if(!(flag & 1))
938  strcat(line, "\"$(echo -e '");
939  wpt= line + strlen(line);
940  for(upt= uval; (size_t) (upt - uval) < comp_len; upt++) {
941  if(wpt - line + 5 + 3 + 1 > (ssize_t) line_limit)
942  /* "\\0xyz" + "')\"" + 0 */
943  goto too_much;
944  if(*upt <= 037 || *upt >= 0177 || *upt == '\\' || *upt == '\'') {
945  if(flag & 1)
946  *(wpt++)= '\\';
947  sprintf((char *) wpt, "\\0%-3.3o", *upt);
948  wpt+= strlen(wpt);
949  } else {
950  *(wpt++)= *upt;
951  }
952  }
953  *wpt= 0;
954  if(!(flag & 1))
955  strcpy(wpt, "')\"");
956  } else {
957  Text_shellsafe(comp, line, 1);
958  }
959  } else if(*mode == 'b') {
960  ret= Sfile_bsl_encoder(&bsl, comp, comp_len, 8);
961  if(ret <= 0)
962  {ret= -1; goto ex;}
963  if(strlen(line) + strlen(bsl) + 1 > line_limit)
964  goto too_much;
965  strcat(line, bsl);
966  free(bsl);
967  bsl= NULL;
968  } else if(*mode == 'r') {
969  if(strlen(line) + strlen(comp) + 1 > line_limit)
970  goto too_much;
971  strcat(line, comp);
972  }
973  ret= 1;
974 ex:;
975  if(bsl != NULL)
976  free(bsl);
977  return(ret);
978 too_much:;
979  Xorriso_msgs_submit(xorriso, 0, "Oversized BSD-style file attribute",
980  0, "FAILURE", 0);
981  ret= -1;
982  goto ex;
983 }
char * Text_shellsafe(char *in_text, char *out_text, int flag)
Definition: misc_funct.c:1044
int Sfile_bsl_encoder(char **result, char *text, size_t text_len, int flag)
Definition: sfile.c:562
char result_line[10 *4096]

References XorrisO::result_line, Sfile_bsl_encoder(), Text_shellsafe(), and Xorriso_msgs_submit().

Referenced by Xorriso_list_extattr(), and Xorriso_option_find().

◆ Xorriso_apply_sort_file()

int Xorriso_apply_sort_file ( struct XorrisO xorriso,
char *  path,
int  flag 
)

Definition at line 4300 of file iso_manip.c.

4301 {
4302  int ret, linecount= 0, filec= 0, zero, i;
4303  FILE *fp= NULL;
4304  char *sret, *line= NULL, *spt, *tpt, *patterns[1], **filev= NULL;
4305  char *sort_weight_args[4];
4306  off_t mem= 0;
4307  IsoImage *volume;
4308 
4309  Xorriso_alloc_meM(line, char, SfileadrL);
4310 
4311  ret= Xorriso_get_volume(xorriso, &volume, 0);
4312  if(ret<=0)
4313  goto ex;
4314 
4315  ret= Xorriso_afile_fopen(xorriso, path, "rb", &fp, 2);
4316  if(ret <= 0)
4317  {ret= 0; goto ex;}
4318  while(1) {
4319  sret= Sfile_fgets_n(line, SfileadrL - 1, fp, 0);
4320  if(sret == NULL) {
4321  if(ferror(fp))
4322  {ret= 0; goto ex;}
4323  break;
4324  }
4325  linecount++;
4326 
4327  /* Find first space or tab */
4328  spt= strchr(line, ' ');
4329  tpt= strchr(line, '\t');
4330  if(spt == NULL || (tpt != NULL && tpt < spt))
4331  spt= tpt;
4332  if(spt == NULL) {
4333  sprintf(xorriso->info_text,
4334  "No space or tab character found in line %d of sort weight file ",
4335  linecount);
4336  Text_shellsafe(path, xorriso->info_text, 1);
4337  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
4338  ret= 0; goto ex;
4339  }
4340  *spt= 0;
4341 
4342  patterns[0]= spt + 1;
4343  if(flag & 1) {
4344  /* Obtain list of matching files */
4345  ret= Xorriso_expand_pattern(xorriso, 1, patterns, 0,
4346  &filec, &filev, &mem, 4);
4347  if(ret <= 0)
4348  {ret= 0; goto ex;}
4349  } else {
4350  filec= 1;
4351  }
4352 
4353  /* Apply weight to file or directory tree */
4354  for(i= 0; i < filec; i++) {
4355  zero= 0;
4356  if(flag & 1) {
4357  sort_weight_args[0]= filev[i];
4358  } else {
4359  sort_weight_args[0]= patterns[0];
4360  }
4361  sort_weight_args[1]= "-exec";
4362  sort_weight_args[2]= "sort_weight";
4363  sort_weight_args[3]= line;
4364  ret= Xorriso_option_find(xorriso, 4, sort_weight_args, &zero, 2);
4365  if(ret <= 0)
4366  {ret= 0; goto ex;}
4367  }
4368  if(flag & 1)
4369  Sfile_destroy_argv(&filec, &filev, 0);
4370  }
4371  ret= 1;
4372 ex:
4373  if(fp != NULL)
4374  fclose(fp);
4375  Xorriso_free_meM(line);
4376  Sfile_destroy_argv(&filec, &filev, 0);
4377  return(ret);
4378 }
int Xorriso_afile_fopen(struct XorrisO *xorriso, char *filename, char *mode, FILE **ret_fp, int flag)
Definition: disk_ops.c:1780
static int Sfile_destroy_argv(int *argc, char ***argv, int flag)
#define SfileadrL
int Xorriso_expand_pattern(struct XorrisO *xorriso, int num_patterns, char **patterns, int extra_filec, int *filec, char ***filev, off_t *mem, int flag)
Definition: iso_tree.c:2091
int Xorriso_option_find(struct XorrisO *xorriso, int argc, char **argv, int *idx, int flag)
Definition: opts_d_h.c:818
char * Sfile_fgets_n(char *line, int maxl, FILE *fp, int flag)
Definition: sfile.c:33
#define Xorriso_free_meM(pt)
Definition: sfile.h:27
#define Xorriso_alloc_meM(pt, typ, count)
Definition: sfile.h:19
char info_text[10 *4096]

References XorrisO::info_text, Sfile_destroy_argv(), Sfile_fgets_n(), SfileadrL, Text_shellsafe(), Xorriso_afile_fopen(), Xorriso_alloc_meM, Xorriso_expand_pattern(), Xorriso_free_meM, Xorriso_get_volume(), Xorriso_msgs_submit(), and Xorriso_option_find().

Referenced by Xorriso_genisofs().

◆ Xorriso_aquire_drive()

int Xorriso_aquire_drive ( struct XorrisO xorriso,
char *  adr,
char *  show_adr,
int  flag 
)

Definition at line 257 of file drive_mgt.c.

259 {
260  int ret, hret, not_writeable= 0, has_what, aquire_flag, load_lba, ext;
261  int lba, track, session, params_flag, adr_mode, read_ret, start_lba;
262  int truncate_mode;
263  uint32_t size, offst;
264  struct burn_drive_info *dinfo= NULL, *out_dinfo= NULL, *in_dinfo= NULL;
265  struct burn_drive *drive= NULL, *out_drive= NULL, *in_drive= NULL;
266  enum burn_disc_status state;
267  IsoImage *volset = NULL;
268  struct isoburn_read_opts *ropts= NULL;
269  char *libburn_adr= NULL, *off_adr= NULL, *boot_fate, *sev;
270  char volid[33], *adr_data= NULL, *adr_pt;
271 
272  Xorriso_alloc_meM(libburn_adr, char, SfileadrL);
273  Xorriso_alloc_meM(off_adr, char, SfileadrL);
274  Xorriso_alloc_meM(adr_data, char, 163);
275 
276  if(show_adr == NULL) {
277  show_adr= adr;
278  ret= burn_drive_convert_fs_adr(adr, off_adr);
279  if(ret > 0)
280  adr= off_adr;
281  }
282 
283  if((flag&3)==0) {
284  sprintf(xorriso->info_text,
285  "XORRISOBURN program error : Xorriso_aquire_drive bit0+bit1 not set");
286  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
287  {ret= -1; goto ex;}
288  }
289  if(!(flag & 128)) {
290  ret= Xorriso_give_up_drive(xorriso, (flag&3)|8);
291  if(ret<=0)
292  goto ex;
293  }
294  if(flag & 1)
295  xorriso->isofs_st_out= time(0) - 1;
296 
297  ret= Xorriso_auto_driveadr(xorriso, adr, libburn_adr, 0);
298  if(ret <= 0)
299  goto ex;
300  if(strcmp(libburn_adr,"stdio:/dev/fd/1")==0) {
301  if(xorriso->dev_fd_1<0) {
302  sprintf(xorriso->info_text,
303  "-*dev \"stdio:/dev/fd/1\" was not a start argument. Cannot use it now.");
304  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
305  {ret= 0; goto ex;}
306  } else {
307  sprintf(libburn_adr, "stdio:/dev/fd/%d", xorriso->dev_fd_1);
308  }
309  }
310 
311  if(flag & 128) {
312  if(flag & 1)
313  Xorriso_get_drive_handles(xorriso, &in_dinfo, &in_drive, "", 16);
314  if(flag & 2)
315  Xorriso_get_drive_handles(xorriso, &out_dinfo, &out_drive, "", 2 | 16);
316  if(in_dinfo != NULL && (out_dinfo == NULL || out_dinfo == in_dinfo)) {
317  dinfo= in_dinfo;
318  if(flag & 2) {
319  xorriso->outdev_is_exclusive= xorriso->indev_is_exclusive;
320  xorriso->outdev_access= xorriso->indev_access;
321  }
322  } else if(out_dinfo != NULL && in_dinfo == NULL) {
323  dinfo= out_dinfo;
324  if(flag & 1) {
325  xorriso->indev_is_exclusive= xorriso->outdev_is_exclusive;
326  xorriso->indev_access= xorriso->outdev_access;
327  }
328  } else if(out_dinfo != NULL || in_dinfo != NULL) {
329  sprintf(xorriso->info_text,
330  "Two different drives shall be re-assed in one call");
331  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
332  {ret= 0; goto ex;}
333  } else {
334  sprintf(xorriso->info_text, "No drive acquired on re-assessment");
335  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
336  {ret= 0; goto ex;}
337  }
338  } else if((flag&3)==1 && xorriso->out_drive_handle!=NULL) {
339  ret= Xorriso_get_drive_handles(xorriso, &out_dinfo, &out_drive,
340  "on attempt to compare new indev with outdev", 2);
341  if(ret<=0)
342  goto ex;
343  ret= burn_drive_equals_adr(out_drive, libburn_adr, 1);
344  if(ret==1) {
345  dinfo= out_dinfo;
346  xorriso->indev_is_exclusive= xorriso->outdev_is_exclusive;
347  xorriso->indev_access= xorriso->outdev_access;
348  }
349  } else if((flag&3)==2 && xorriso->in_drive_handle!=NULL) {
350  ret= Xorriso_get_drive_handles(xorriso, &in_dinfo, &in_drive,
351  "on attempt to compare new outdev with indev", 0);
352  if(ret<=0)
353  goto ex;
354  ret= burn_drive_equals_adr(in_drive, libburn_adr, 1);
355  if(ret==1) {
356  dinfo= in_dinfo;
357  xorriso->outdev_is_exclusive= xorriso->indev_is_exclusive;
358  xorriso->outdev_access= xorriso->indev_access;
359  }
360  }
361 
362  if(dinfo == NULL || (flag & 128)) {
363  aquire_flag= 1 | ((flag&(8|4))>>1) | ((xorriso->toc_emulation_flag & 3)<<3);
364  if(xorriso->toc_emulation_flag & 4)
365  aquire_flag|= 128;
366  if(xorriso->toc_emulation_flag & 8)
367  aquire_flag|= 512;
368  if(!(xorriso->do_aaip & 1))
369  aquire_flag|= 32;
370  if((xorriso->ino_behavior & (1 | 2)) && !(xorriso->do_aaip & (4 | 32))) {
371  aquire_flag|= 64;
372  } else if(xorriso->do_aaip & 1024) {
373  aquire_flag|= 1024;
374  }
375  if(flag & 128)
376  aquire_flag|= 256;
377  burn_preset_device_open(xorriso->drives_exclusive |
378  (xorriso->linux_scsi_dev_family << 2), 0, 0);
379  burn_allow_drive_role_4(1 | (xorriso->early_stdio_test & 14));
380  ret= isoburn_drive_aquire(&dinfo, libburn_adr, aquire_flag);
381  burn_preset_device_open(1 | (xorriso->linux_scsi_dev_family << 2), 0, 0);
382  Xorriso_process_msg_queues(xorriso,0);
383  if(ret<=0) {
384  if(flag & 128)
385  sprintf(xorriso->info_text,"Cannot re-assess drive '%s'", adr);
386  else
387  sprintf(xorriso->info_text,"Cannot acquire drive '%s'", adr);
388  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
389  ret= 0; goto ex;
390  }
391  xorriso->use_immed_bit_default= burn_drive_get_immed(dinfo[0].drive) > 0 ?
392  1 : -1;
393  if(xorriso->use_immed_bit != 0)
394  burn_drive_set_immed(dinfo[0].drive, xorriso->use_immed_bit > 0);
395  state= isoburn_disc_get_status(dinfo[0].drive);
396  ret= isoburn_get_img_partition_offset(dinfo[0].drive, &offst);
397  if((state == BURN_DISC_APPENDABLE || state == BURN_DISC_FULL) && ret == 1) {
398  sprintf(xorriso->info_text,
399  "ISO image bears MBR with -boot_image any partition_offset=%lu",
400  (unsigned long) offst);
401  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
402  }
403 
404  if(flag&1)
405  if(xorriso->image_start_mode&(1u<<31)) /* used up setting */
406  xorriso->image_start_mode= 0; /* no need to perform auto setting */
407  if(flag & 1) {
408  xorriso->indev_is_exclusive= xorriso->drives_exclusive;
409  xorriso->indev_access= xorriso->drives_access;
410  }
411  if(flag & 2) {
412  xorriso->outdev_is_exclusive= xorriso->drives_exclusive;
413  xorriso->outdev_access= xorriso->drives_access;
414  }
415  }
416  drive= dinfo[0].drive;
417  volset= isoburn_get_attached_image(drive);
418  if(volset != NULL) {
419  ret= iso_image_set_truncate_mode(volset, 1, xorriso->file_name_limit);
420  iso_image_unref(volset);
421  volset= NULL;
422  Xorriso_process_msg_queues(xorriso,0);
423  if(ret < 0)
424  {ret= 0; goto ex;}
425  }
426  state= isoburn_disc_get_status(drive);
427  Xorriso_process_msg_queues(xorriso,0);
428  if(flag&1) {
429  if(xorriso->image_start_mode&(1u<<31)) /* used up setting */
430  xorriso->image_start_mode&= ~0xffff; /* perform auto setting */
431  if((xorriso->image_start_mode&(1<<30))) { /* if enabled at all */
432  adr_pt= xorriso->image_start_value;
433  adr_mode= xorriso->image_start_mode & 0xffff;
434  if(adr_mode == 4 && strlen(adr_pt) <= 80) {
435  /* Convert volid search expression into lba */
436  params_flag= 0;
437  ret= Xorriso__bourne_to_reg(xorriso->image_start_value, adr_data, 0);
438  if(ret == 1)
439  params_flag|= 4;
440  ret= isoburn_get_mount_params(drive, 4, adr_data, &lba, &track,
441  &session, volid, params_flag);
442  Xorriso_process_msg_queues(xorriso,0);
443  if(ret <= 0)
444  goto ex;
445  if(session <= 0 || track <= 0 || ret == 2) {
446  Xorriso_msgs_submit(xorriso, 0,
447  "-load : Given address does not point to an ISO 9660 session",
448  0, "FAILURE", 0);
449  ret= 0; goto ex;
450  }
451  sprintf(volid, "%d", lba);
452  adr_pt= volid;
453  adr_mode= 3;
454  }
455  ret= isoburn_set_msc1(drive, adr_mode, adr_pt,
456  !!(xorriso->image_start_mode & (1<<16)));
457  if(ret<=0)
458  goto ex;
459  if(xorriso->image_start_mode&(1u<<31))
460  xorriso->image_start_mode= 0; /* disable msc1 setting completely */
461  else
462  xorriso->image_start_mode|= (1u<<31); /* mark as used up */
463  }
464  }
465  if(flag&1) {
466  volset= isoburn_get_attached_image(drive);
467  if(volset != NULL) { /* The image object is already created */
468  iso_image_unref(volset);
469  volset= NULL;
470  }
471  }
472 
473  if(flag&2) {
474  xorriso->out_drive_handle= dinfo;
475  if(Sfile_str(xorriso->outdev, show_adr, 0)<=0)
476  {ret= -1; goto ex;}
477  ret= burn_drive_convert_fs_adr(adr, xorriso->outdev_off_adr);
478  if(ret <= 0)
479  xorriso->outdev_off_adr[0]= 0;
480  if(state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE) {
481  sprintf(xorriso->info_text, "Disc status unsuitable for writing");
482  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
483  not_writeable= 1;
484  }
485  }
486  if(flag&1) {
487  xorriso->in_drive_handle= dinfo;
488  if(Sfile_str(xorriso->indev, show_adr, 0)<=0)
489  {ret= -1; goto ex;}
490  ret= burn_drive_convert_fs_adr(adr, xorriso->indev_off_adr);
491  if(ret <= 0)
492  xorriso->indev_off_adr[0]= 0;
493  } else if(flag&2) {
494  if(xorriso->in_volset_handle==NULL) {
495  /* No volume loaded: create empty one */
496  ret= Xorriso_create_empty_iso(xorriso, 0);
497  if(ret<=0)
498  goto ex;
499  } else {
500  iso_image_ref((IsoImage *) xorriso->in_volset_handle);
501  start_lba= -1;
502  ret= Xorriso_get_drive_handles(xorriso, &in_dinfo, &in_drive,
503  "on attempt to attach ISO image object to outdev", 16);
504  if(ret > 0)
505  start_lba= isoburn_get_attached_start_lba(in_drive);
506  ret= isoburn_attach_image(drive, (IsoImage *) xorriso->in_volset_handle);
507  if(ret<=0) {
508  sprintf(xorriso->info_text,
509  "Failed to attach ISO image object to outdev");
510  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
511  {ret= -1; goto ex;}
512  }
513  if(start_lba >= 0)
514  isoburn_attach_start_lba(drive, lba, 0);
515  }
516  if(!(flag&32))
517  Xorriso_toc(xorriso, 1 | 2 | 8);
518  {ret= 1+not_writeable; goto ex;}
519  }
520 
521  if(xorriso->in_volset_handle!=NULL)
522  iso_image_unref((IsoImage *) xorriso->in_volset_handle);
523  xorriso->in_volset_handle= NULL;
524  Sectorbitmap_destroy(&(xorriso->in_sector_map), 0);
525  Xorriso_destroy_hln_array(xorriso, 0);
526  Xorriso_destroy_di_array(xorriso, 0);
527  xorriso->boot_count= 0;
528  xorriso->system_area_clear_loaded=
529  (strcmp(xorriso->system_area_disk_path, "/dev/zero") == 0);
530 
531  /* check for invalid state */
532  if(state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE &&
533  state != BURN_DISC_FULL) {
534  sprintf(xorriso->info_text,
535  "Disc status not blank and unsuitable for reading");
536  sev= "FAILURE";
537  if(xorriso->img_read_error_mode==2)
538  sev= "FATAL";
539  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, sev, 0);
540  Xorriso_give_up_drive(xorriso, 1|((flag&32)>>2));
541  ret= 3; goto ex;
542  }
543  /* fill read opts */
544  ret= isoburn_ropt_new(&ropts, 0);
545  if(ret<=0)
546  goto ex;
547 
548  ret= Xorriso_set_data_cache(xorriso, ropts, xorriso->cache_num_tiles,
549  xorriso->cache_tile_blocks,
550  xorriso->cache_default);
551  if(ret<=0)
552  goto ex;
553 
555  if(xorriso->read_fs & 1)
556  ext|= isoburn_ropt_norock;
557  if(xorriso->read_fs & 2)
558  ext|= isoburn_ropt_nojoliet;
559  if((xorriso->ino_behavior & (1 | 2)) && !(xorriso->do_aaip & (1 | 4 | 32))
560  && !(xorriso->do_md5 & 1) && !(xorriso->do_hfsplus))
561  ext|= isoburn_ropt_noaaip;
562  if(!(xorriso->do_aaip & 1))
563  ext|= isoburn_ropt_noacl;
564  if(!(xorriso->do_aaip & 4))
565  ext|= isoburn_ropt_noea;
566  if(xorriso->ino_behavior & 1)
567  ext|= isoburn_ropt_noino;
568  if(!(xorriso->do_md5 & 1))
569  ext|= isoburn_ropt_nomd5;
570  if(xorriso->do_md5 & 32)
571  ext|= isoburn_ropt_nomd5tag;
572  if(xorriso->ecma119_map == 0)
574  else if(xorriso->ecma119_map == 2)
576  else if(xorriso->ecma119_map == 3)
578  else
580  if(xorriso->joliet_map == 0)
582  else
584 
585  isoburn_ropt_set_extensions(ropts, ext);
586 
587  isoburn_ropt_set_default_perms(ropts, (uid_t) 0, (gid_t) 0, (mode_t) 0555);
589  isoburn_ropt_set_auto_incharset(ropts, !!(xorriso->do_aaip & 512));
591  xorriso->displacement_sign);
593 
594  Xorriso_set_image_severities(xorriso, 1); /* No DEBUG messages */
595  Xorriso_pacifier_reset(xorriso, 0);
596  isoburn_set_read_pacifier(drive, Xorriso__read_pacifier, (void *) xorriso);
597 
598  /* <<< Trying to work around too much tolerance on bad image trees.
599  Better would be a chance to instruct libisofs what to do in
600  case of image read errors. There is a risk to mistake other SORRYs.
601  */
602  if(xorriso->img_read_error_mode>0)
603  iso_set_abort_severity("SORRY");
604 
605  if(state != BURN_DISC_BLANK) {
606  ret= isoburn_disc_get_msc1(drive, &load_lba);
607  if(ret > 0) {
608  sprintf(xorriso->info_text,
609  "Loading ISO image tree from LBA %d", load_lba);
610  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
611  }
612  ret= Xorriso_assert_volid(xorriso, load_lba, 0);
613  if(ret <= 0)
614  goto ex;
615  }
616  Xorriso_set_speed(xorriso, drive, xorriso->read_speed, 0, 1);
617  read_ret= ret= isoburn_read_image(drive, ropts, &volset);
618 
619  /* <<< Resetting to normal thresholds */
620  if(xorriso->img_read_error_mode>0)
621  Xorriso_set_abort_severity(xorriso, 0);
622 
623  if(ret<=0) {
624  Xorriso_process_msg_queues(xorriso,0);
625  Xorriso_set_image_severities(xorriso, 0);
626  Xorriso_give_up_drive(xorriso, 1|((flag&32)>>2));
627  sprintf(xorriso->info_text,"Cannot read ISO image tree");
628  sev= "FAILURE";
629  if(xorriso->img_read_error_mode==2)
630  sev= "FATAL";
631  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, sev, 0);
632  if(read_ret == (int) ISO_SB_TREE_CORRUPTED && (xorriso->do_md5 & 1)) {
633  Xorriso_msgs_submit(xorriso, 0,
634 "This might be false MD5 alarm if an add-on session was written by growisofs.",
635  0, "HINT", 0);
636  Xorriso_msgs_submit(xorriso, 0,
637  "In this case you get an ISO image tree by option -md5 'load_check_off'",
638  0, "HINT", 0);
639  } else if(xorriso->img_read_error_mode!=0) {
640  Xorriso_msgs_submit(xorriso, 0, "You might get a partial or altered ISO image tree by option -error_behavior 'image_loading' 'best_effort' if -abort_on is set to be tolerant enough.",
641  0, "HINT", 0);
642  }
643 
644 
645  ret= 3; goto ex;
646  }
647  Xorriso_pacifier_callback(xorriso, "nodes read", xorriso->pacifier_count, 0,
648  "", 1); /* report end count */
649  xorriso->in_volset_handle= (void *) volset;
650  xorriso->in_sector_map= NULL;
651  Xorriso_set_image_severities(xorriso, 0);
652 
653  /* Might have changed due to isofs.nt */
654  iso_image_get_truncate_mode(volset, &truncate_mode,
655  &(xorriso->file_name_limit));
656  Xorriso_process_msg_queues(xorriso,0);
657 
658  Xorriso_update_volid(xorriso, 0);
659  strncpy(xorriso->application_id,
660  un0(iso_image_get_application_id(volset)), 128);
661  xorriso->application_id[128]= 0;
662  strncpy(xorriso->publisher, un0(iso_image_get_publisher_id(volset)), 128);
663  xorriso->publisher[128]= 0;
664  strncpy(xorriso->system_id, un0(iso_image_get_system_id(volset)), 32);
665  xorriso->system_id[32]= 0;
666  strncpy(xorriso->volset_id, un0(iso_image_get_volset_id(volset)), 128);
667  xorriso->volset_id[128]= 0;
668  strncpy(xorriso->copyright_file,
669  un0(iso_image_get_copyright_file_id(volset)), 37);
670  xorriso->copyright_file[37]= 0;
671  strncpy(xorriso->biblio_file, un0(iso_image_get_biblio_file_id(volset)), 37);
672  xorriso->biblio_file[37]= 0;
673  strncpy(xorriso->abstract_file,
674  un0(iso_image_get_abstract_file_id(volset)), 37);
675  xorriso->abstract_file[37]= 0;
676 
677  if(xorriso->out_drive_handle != NULL &&
678  xorriso->out_drive_handle != xorriso->in_drive_handle) {
679  start_lba= -1;
680  ret= Xorriso_get_drive_handles(xorriso, &in_dinfo, &in_drive,
681  "on attempt to attach ISO image volset to outdev", 16);
682  if(ret > 0)
683  start_lba= isoburn_get_attached_start_lba(in_drive);
684  ret= Xorriso_get_drive_handles(xorriso, &out_dinfo, &out_drive,
685  "on attempt to attach ISO image volset to outdev", 2);
686  if(ret<=0)
687  goto ex;
688  iso_image_ref((IsoImage *) xorriso->in_volset_handle);
689  isoburn_attach_image(out_drive, xorriso->in_volset_handle);
690  if(start_lba >= 0)
691  isoburn_attach_start_lba(out_drive, ret, 0);
692  }
693  Xorriso_process_msg_queues(xorriso,0);
694  isoburn_ropt_get_size_what(ropts, &size, &has_what);
695  xorriso->isofs_size= size;
696  xorriso->isofs_has_what= has_what;
697  isoburn_ropt_get_tree_loaded(ropts, &(xorriso->tree_loaded),
698  &(xorriso->rr_loaded));
699 
700  if(has_what & isoburn_ropt_has_el_torito) {
701  if(xorriso->boot_image_bin_path[0])
702  boot_fate= "replaced by new boot image";
703  else if(xorriso->patch_isolinux_image & 1)
704  boot_fate= "patched at boot info table";
705  else if(xorriso->keep_boot_image)
706  boot_fate= "kept unchanged";
707  else
708  boot_fate= "discarded";
709  sprintf(xorriso->info_text,
710  "Detected El-Torito boot information which currently is set to be %s",
711  boot_fate);
712  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
713  Xorriso_record_boot_info(xorriso, 0);
714  }
715 
716  if(flag & 1) {
717  ret= Xorriso_grasp_loaded_aaip(xorriso, volset, 0);
718  if(ret <= 0)
719  goto ex;
720  }
721 
722  if(!(flag&32)) {
723  Xorriso_toc(xorriso, 1 | 8);
724  if(xorriso->loaded_volid[0] != 0 &&
725  (state == BURN_DISC_APPENDABLE || state == BURN_DISC_FULL)) {
726  sprintf(xorriso->info_text,"Volume id : '%s'\n",
727  xorriso->loaded_volid);
728  Xorriso_info(xorriso, 0);
729  }
730  if(strcmp(xorriso->loaded_volid, xorriso->volid) != 0 &&
731  !xorriso->volid_default) {
732  sprintf(xorriso->info_text, "New volume id: '%s'\n", xorriso->volid);
733  Xorriso_info(xorriso, 0);
734  }
735  }
736 
737  ret= 1+not_writeable;
738 ex:
739  Xorriso_process_msg_queues(xorriso,0);
740  if(ret<=0) {
741  hret= Xorriso_give_up_drive(xorriso, (flag&3)|((flag&32)>>2));
742  if(hret<ret)
743  ret= hret;
744  } else {
745  if(drive != NULL && (xorriso->do_calm_drive & 1) && !(flag & 64))
746  burn_drive_snooze(drive, 0); /* No need to make noise from start */
747  }
748  if(ropts!=NULL)
749  isoburn_ropt_destroy(&ropts, 0);
750  Xorriso_free_meM(off_adr);
751  Xorriso_free_meM(libburn_adr);
752  Xorriso_free_meM(adr_data);
753  return(ret);
754 }
int Xorriso_destroy_di_array(struct XorrisO *xorriso, int flag)
Definition: base_obj.c:699
int Xorriso_destroy_hln_array(struct XorrisO *xorriso, int flag)
Definition: base_obj.c:675
int isoburn_drive_aquire(struct burn_drive_info *drive_infos[], char *adr, int flag)
Acquire a target drive by its filesystem path or libburn persistent address.
Definition: burn_wrap.c:545
int isoburn_get_mount_params(struct burn_drive *d, int adr_mode, char *adr_value, int *lba, int *track, int *session, char volid[33], int flag)
Try to convert the given entity address into various entity addresses which would describe it.
Definition: burn_wrap.c:2105
enum burn_disc_status isoburn_disc_get_status(struct burn_drive *drive)
Inquire the medium status.
Definition: burn_wrap.c:646
int isoburn_disc_get_msc1(struct burn_drive *d, int *start_lba)
Obtain the start block number of the most recent session on the medium.
Definition: burn_wrap.c:799
int isoburn_set_msc1(struct burn_drive *d, int adr_mode, char *adr_value, int flag)
Set up isoburn_disc_get_msc1() to return a fabricated value.
Definition: burn_wrap.c:1938
int Sectorbitmap_destroy(struct SectorbitmaP **o, int flag)
Definition: check_media.c:276
int Xorriso_auto_driveadr(struct XorrisO *xorriso, char *adr, char *result, int flag)
Definition: drive_mgt.c:49
static int Xorriso_grasp_loaded_aaip(struct XorrisO *xorriso, IsoImage *volset, int flag)
Definition: drive_mgt.c:157
int Xorriso_get_drive_handles(struct XorrisO *xorriso, struct burn_drive_info **dinfo, struct burn_drive **drive, char *attempt, int flag)
Definition: drive_mgt.c:3511
int Xorriso_toc(struct XorrisO *xorriso, int flag)
Definition: drive_mgt.c:1033
int Xorriso_give_up_drive(struct XorrisO *xorriso, int flag)
Definition: drive_mgt.c:762
static const char * un0(const char *text)
Definition: drive_mgt.c:39
int Xorriso_set_speed(struct XorrisO *xorriso, struct burn_drive *drive, int read_speed, int write_speed, int flag)
Definition: drive_mgt.c:210
int Xorriso_update_volid(struct XorrisO *xorriso, int flag)
Definition: iso_img.c:57
int Xorriso_create_empty_iso(struct XorrisO *xorriso, int flag)
Definition: iso_img.c:68
int Xorriso_assert_volid(struct XorrisO *xorriso, int msc1, int flag)
Definition: iso_img.c:159
int Xorriso_record_boot_info(struct XorrisO *xorriso, int flag)
Definition: iso_img.c:125
int isoburn_ropt_destroy(struct isoburn_read_opts **o, int flag)
Deletes an option set which was created by isoburn_ropt_new().
Definition: isoburn.c:886
int isoburn_ropt_set_displacement(struct isoburn_read_opts *o, uint32_t displacement, int displacement_sign)
Control an offset to be applied to all block address pointers in the ISO image in order to compensate...
Definition: isoburn.c:1057
int isoburn_ropt_get_size_what(struct isoburn_read_opts *o, uint32_t *size, int *has_what)
Definition: isoburn.c:1099
int isoburn_ropt_new(struct isoburn_read_opts **new_o, int flag)
Produces a set of image read options, initialized with default values.
Definition: isoburn.c:842
int isoburn_ropt_set_auto_incharset(struct isoburn_read_opts *o, int mode)
Enable or disable methods to automatically choose an input charset.
Definition: isoburn.c:1043
int isoburn_ropt_set_default_perms(struct isoburn_read_opts *o, uid_t uid, gid_t gid, mode_t mode)
Default attributes to use if no RockRidge extension gets loaded.
Definition: isoburn.c:981
int isoburn_ropt_get_tree_loaded(struct isoburn_read_opts *o, int *tree, int *rr)
After calling function isoburn_read_image() there are information available in the option set about w...
Definition: isoburn.c:1109
int isoburn_ropt_set_extensions(struct isoburn_read_opts *o, int ext)
Definition: isoburn.c:949
int isoburn_ropt_set_input_charset(struct isoburn_read_opts *o, char *input_charset)
Set the character set for reading RR file names from ISO images.
Definition: isoburn.c:1027
int isoburn_ropt_set_truncate_mode(struct isoburn_read_opts *o, int mode, int length)
Set the name truncation mode and the maximum name length for imported file objects.
Definition: isoburn.c:1075
int isoburn_attach_image(struct burn_drive *d, IsoImage *image)
Set the IsoImage to be used with a drive.
Definition: isofs_wrap.c:351
int isoburn_get_img_partition_offset(struct burn_drive *drive, uint32_t *block_offset_2k)
API.
Definition: isofs_wrap.c:424
int isoburn_set_read_pacifier(struct burn_drive *drive, int(*read_pacifier)(IsoImage *, IsoFileSource *), void *read_handle)
Set a callback function for producing pacifier messages during the lengthy process of image reading.
Definition: isofs_wrap.c:706
int isoburn_get_attached_start_lba(struct burn_drive *d)
Get the start address of the image that is attached to the drive, if any.
Definition: isofs_wrap.c:109
int isoburn_read_image(struct burn_drive *d, struct isoburn_read_opts *read_opts, IsoImage **image)
Load the ISO filesystem directory tree from the medium in the given drive.
Definition: isofs_wrap.c:142
int isoburn_attach_start_lba(struct burn_drive *d, int lba, int flag)
Set the start address of the image that is attached to the drive, if any.
Definition: isofs_wrap.c:374
IsoImage * isoburn_get_attached_image(struct burn_drive *d)
Get the image attached to a drive, if any.
Definition: isofs_wrap.c:92
int Xorriso_set_image_severities(struct XorrisO *xorriso, int flag)
Definition: lib_mgt.c:286
int Xorriso_set_data_cache(struct XorrisO *xorriso, void *o, int num_tiles, int tile_blocks, int flag)
Definition: lib_mgt.c:990
int Xorriso_set_abort_severity(struct XorrisO *xorriso, int flag)
Definition: lib_mgt.c:306
#define isoburn_ropt_noaaip
Definition: libisoburn.h:931
#define isoburn_ropt_map_unmapped
Definition: libisoburn.h:937
#define isoburn_ropt_noea
Definition: libisoburn.h:933
#define isoburn_ropt_norock
Which existing ISO 9660 extensions in the image to read or not to read.
Definition: libisoburn.h:926
#define isoburn_ropt_map_lowercase
Definition: libisoburn.h:940
#define isoburn_ropt_nomd5tag
Definition: libisoburn.h:936
#define isoburn_ropt_noino
Definition: libisoburn.h:934
#define isoburn_ropt_has_el_torito
Definition: libisoburn.h:1089
#define isoburn_ropt_joliet_unmapped
Definition: libisoburn.h:941
#define isoburn_ropt_map_uppercase
Definition: libisoburn.h:939
#define isoburn_ropt_nomd5
Definition: libisoburn.h:935
#define isoburn_ropt_noiso1999
Definition: libisoburn.h:928
#define isoburn_ropt_noacl
Definition: libisoburn.h:932
#define isoburn_ropt_joliet_stripped
Definition: libisoburn.h:942
#define isoburn_ropt_map_stripped
Definition: libisoburn.h:938
#define isoburn_ropt_nojoliet
Definition: libisoburn.h:927
int Xorriso__bourne_to_reg(char bourne_expr[], char reg_expr[], int flag)
Definition: misc_funct.c:1162
int Xorriso__read_pacifier(IsoImage *image, IsoFileSource *filesource)
Definition: read_run.c:46
int Sfile_str(char target[4096], char *source, int flag)
Definition: sfile.c:836
char publisher[129]
char volset_id[129]
off_t pacifier_count
int linux_scsi_dev_family
int outdev_is_exclusive
int displacement_sign
int keep_boot_image
uint32_t isofs_size
char abstract_file[38]
char indev_off_adr[4096]
time_t isofs_st_out
char indev[4096]
int early_stdio_test
int do_calm_drive
int isofs_has_what
int img_read_error_mode
int cache_tile_blocks
int use_immed_bit
char system_id[33]
int ino_behavior
int image_start_mode
int cache_num_tiles
int drives_access
char volid[33]
struct SectorbitmaP * in_sector_map
int drives_exclusive
int cache_default
char system_area_disk_path[4096]
uint32_t displacement
int file_name_limit
int volid_default
void * in_volset_handle
char * in_charset
char image_start_value[81]
int system_area_clear_loaded
int outdev_access
char boot_image_bin_path[4096]
void * out_drive_handle
char loaded_volid[33]
void * in_drive_handle
char outdev[4096]
char copyright_file[38]
int indev_access
char application_id[129]
int patch_isolinux_image
char outdev_off_adr[4096]
int use_immed_bit_default
int toc_emulation_flag
char biblio_file[38]
int indev_is_exclusive
Options for image reading.
Definition: isoburn.h:318
int truncate_mode
What to do in case of name longer than truncate_length: 0= throw FAILURE 1= truncate to truncate_leng...
Definition: isoburn.h:371
uint32_t size
Will be filled with the size (in 2048 byte block) of the image, as reported in the PVM.
Definition: isoburn.h:389
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_info(struct XorrisO *xorriso, int flag)
Definition: text_io.c:2367
int Xorriso_pacifier_reset(struct XorrisO *xorriso, int flag)
Definition: text_io.c:3937

References XorrisO::abstract_file, XorrisO::application_id, XorrisO::biblio_file, XorrisO::boot_count, XorrisO::boot_image_bin_path, XorrisO::cache_default, XorrisO::cache_num_tiles, XorrisO::cache_tile_blocks, XorrisO::copyright_file, XorrisO::dev_fd_1, XorrisO::displacement, XorrisO::displacement_sign, XorrisO::do_aaip, XorrisO::do_calm_drive, XorrisO::do_hfsplus, XorrisO::do_md5, XorrisO::drives_access, XorrisO::drives_exclusive, XorrisO::early_stdio_test, XorrisO::ecma119_map, XorrisO::file_name_limit, XorrisO::image_start_mode, XorrisO::image_start_value, XorrisO::img_read_error_mode, XorrisO::in_charset, XorrisO::in_drive_handle, XorrisO::in_sector_map, XorrisO::in_volset_handle, XorrisO::indev, XorrisO::indev_access, XorrisO::indev_is_exclusive, XorrisO::indev_off_adr, XorrisO::info_text, XorrisO::ino_behavior, isoburn_attach_image(), isoburn_attach_start_lba(), isoburn_disc_get_msc1(), isoburn_disc_get_status(), isoburn_drive_aquire(), isoburn_get_attached_image(), isoburn_get_attached_start_lba(), isoburn_get_img_partition_offset(), isoburn_get_mount_params(), isoburn_read_image(), isoburn_ropt_destroy(), isoburn_ropt_get_size_what(), isoburn_ropt_get_tree_loaded(), isoburn_ropt_has_el_torito, isoburn_ropt_joliet_stripped, isoburn_ropt_joliet_unmapped, isoburn_ropt_map_lowercase, isoburn_ropt_map_stripped, isoburn_ropt_map_unmapped, isoburn_ropt_map_uppercase, isoburn_ropt_new(), isoburn_ropt_noaaip, isoburn_ropt_noacl, isoburn_ropt_noea, isoburn_ropt_noino, isoburn_ropt_noiso1999, isoburn_ropt_nojoliet, isoburn_ropt_nomd5, isoburn_ropt_nomd5tag, isoburn_ropt_norock, isoburn_ropt_set_auto_incharset(), isoburn_ropt_set_default_perms(), isoburn_ropt_set_displacement(), isoburn_ropt_set_extensions(), isoburn_ropt_set_input_charset(), isoburn_ropt_set_truncate_mode(), isoburn_set_msc1(), isoburn_set_read_pacifier(), XorrisO::isofs_has_what, XorrisO::isofs_size, XorrisO::isofs_st_out, XorrisO::joliet_map, XorrisO::keep_boot_image, XorrisO::linux_scsi_dev_family, XorrisO::loaded_volid, XorrisO::out_drive_handle, XorrisO::outdev, XorrisO::outdev_access, XorrisO::outdev_is_exclusive, XorrisO::outdev_off_adr, XorrisO::pacifier_count, XorrisO::patch_isolinux_image, XorrisO::publisher, XorrisO::read_fs, XorrisO::read_speed, XorrisO::rr_loaded, Sectorbitmap_destroy(), Sfile_str(), SfileadrL, isoburn_read_opts::size, XorrisO::system_area_clear_loaded, XorrisO::system_area_disk_path, XorrisO::system_id, XorrisO::toc_emulation_flag, XorrisO::tree_loaded, isoburn_read_opts::truncate_mode, un0(), XorrisO::use_immed_bit, XorrisO::use_immed_bit_default, XorrisO::volid, XorrisO::volid_default, XorrisO::volset_id, Xorriso__bourne_to_reg(), Xorriso__read_pacifier(), Xorriso_alloc_meM, Xorriso_assert_volid(), Xorriso_auto_driveadr(), Xorriso_create_empty_iso(), Xorriso_destroy_di_array(), Xorriso_destroy_hln_array(), Xorriso_free_meM, Xorriso_get_drive_handles(), Xorriso_give_up_drive(), Xorriso_grasp_loaded_aaip(), Xorriso_info(), Xorriso_msgs_submit(), Xorriso_pacifier_callback(), Xorriso_pacifier_reset(), Xorriso_process_msg_queues(), Xorriso_record_boot_info(), Xorriso_set_abort_severity(), Xorriso_set_data_cache(), Xorriso_set_image_severities(), Xorriso_set_speed(), Xorriso_toc(), and Xorriso_update_volid().

Referenced by Xorriso_option_dev(), and Xorriso_reaquire_outdev().

◆ Xorriso_atip()

int Xorriso_atip ( struct XorrisO xorriso,
int  flag 
)

Definition at line 2049 of file drive_mgt.c.

2050 {
2051  int ret, profile_number= 0, is_bdr_pow= 0;
2052  int num_profiles= 0, profiles[64], i, can_write= 0, pf, no_medium= 0;
2053  char is_current[64];
2054  char *respt, profile_name[80];
2055  double x_speed_max, x_speed_min= -1.0;
2056  struct burn_drive_info *dinfo;
2057  struct burn_drive *drive;
2058  enum burn_disc_status s;
2059  char *manuf= NULL, *media_code1= NULL, *media_code2= NULL;
2060  char *book_type= NULL, *product_id= NULL;
2061 
2062  ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
2063  "on attempt to print drive and media info", 2);
2064  if(ret<=0)
2065  return(0);
2066  respt= xorriso->result_line;
2067  sprintf(respt, "Device type : ");
2068  ret= burn_drive_get_drive_role(drive);
2069  if(ret==0)
2070  sprintf(respt+strlen(respt), "%s\n", "Emulated (null-drive)");
2071  else if(ret==2)
2072  sprintf(respt+strlen(respt), "%s\n",
2073  "Emulated (stdio-drive, 2k random read-write)");
2074  else if(ret==3)
2075  sprintf(respt+strlen(respt), "%s\n",
2076  "Emulated (stdio-drive, sequential write-only)");
2077  else if(ret == 4)
2078  sprintf(respt+strlen(respt), "%s\n",
2079  "Emulated (stdio-drive, 2k random read-only)");
2080  else if(ret == 5)
2081  sprintf(respt+strlen(respt), "%s\n",
2082  "Emulated (stdio-drive, 2k random write-only)");
2083  else if(ret!=1)
2084  sprintf(respt+strlen(respt), "%s\n","Emulated (stdio-drive)");
2085  else
2086  sprintf(respt+strlen(respt), "%s\n","Removable CD-ROM");
2087  sprintf(respt+strlen(respt), "Vendor_info : '%s'\n",dinfo->vendor);
2088  sprintf(respt+strlen(respt), "Identifikation : '%s'\n",dinfo->product);
2089  sprintf(respt+strlen(respt), "Revision : '%s'\n",dinfo->revision);
2090  Xorriso_result(xorriso,1);
2091  if(flag&1)
2092  return(1);
2093 
2094  /* Do not report "Supported modes: SAO TAO" with -ROM drives */
2095  burn_drive_get_all_profiles(drive, &num_profiles, profiles, is_current);
2096  if(num_profiles > 0) {
2097  for(i= 0; i < num_profiles; i++) {
2098  pf= profiles[i];
2099  if(pf == 0x09 || pf == 0x0a || pf == 0x11 || pf == 0x12 || pf == 0x13 ||
2100  pf == 0x14 || pf == 0x15 || pf == 0x1a || pf == 0x1b || pf == 0x2b ||
2101  pf == 0x41 || pf == 0x43 || pf == 0xffff) {
2102  can_write= 1;
2103  break;
2104  }
2105  }
2106  } else
2107  can_write= 1;
2108  if(can_write) {
2109  sprintf(respt, "Driver flags : BURNFREE\n");
2110  sprintf(respt+strlen(respt), "Supported modes: SAO TAO\n");
2111  Xorriso_result(xorriso,1);
2112  } else if(flag & 2) {
2113  sprintf(xorriso->info_text, "Not a CD/DVD/BD recorder");
2114  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
2115  }
2116  if(flag&2)
2117  return(1);
2118 
2119  is_bdr_pow= burn_drive_get_bd_r_pow(drive);
2120  s= burn_disc_get_status(drive);
2121  ret= burn_disc_get_profile(drive,&profile_number,profile_name);
2122  if(ret<=0) {
2123  profile_number= 0;
2124  strcpy(profile_name, "-unidentified-");
2125  }
2126  if(s != BURN_DISC_UNSUITABLE) {
2127  ret= burn_disc_read_atip(drive);
2128  if(ret>0) {
2129  ret= burn_drive_get_min_write_speed(drive);
2130  x_speed_min= ((double) ret)/176.4;
2131  }
2132  }
2133  if(s==BURN_DISC_EMPTY) {
2134  sprintf(respt, "Current: none\n");
2135  Xorriso_result(xorriso,1);
2136  sprintf(xorriso->info_text, "No recognizable medium found in drive");
2137  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
2138  no_medium= 1;
2139  } else
2140  sprintf(respt, "Current: %s%s\n",profile_name,
2141  is_bdr_pow ? ", Pseudo Overwrite formatted" : "");
2142  Xorriso_result(xorriso,1);
2143  Xorriso_list_profiles(xorriso, 1 | 2);
2144  if(no_medium)
2145  return(1);
2146  if(strstr(profile_name,"BD")==profile_name) {
2147  printf("Mounted Media: %2.2Xh, %s\n", profile_number, profile_name);
2148  } else if(strstr(profile_name,"DVD")==profile_name) {
2149  sprintf(respt, "book type: %s (emulated booktype)\n", profile_name);
2150  Xorriso_result(xorriso,1);
2151  if(profile_number == 0x13) {
2152  sprintf(respt, "xorriso: message for sdvdbackup: \"(growisofs mode Restricted Overwrite)\"\n");
2153  Xorriso_result(xorriso,1);
2154  }
2155  } else {
2156  sprintf(respt, "ATIP info from disk:\n");
2157  Xorriso_result(xorriso,1);
2158  if(burn_disc_erasable(drive))
2159  sprintf(respt, " Is erasable\n");
2160  else
2161  sprintf(respt, " Is not erasable\n");
2162  Xorriso_result(xorriso,1);
2163  { int start_lba,end_lba,min,sec,fr;
2164  ret= burn_drive_get_start_end_lba(drive,&start_lba,&end_lba,0);
2165  if(ret>0) {
2166  burn_lba_to_msf(start_lba,&min,&sec,&fr);
2167  sprintf(respt, " ATIP start of lead in: %d (%-2.2d:%-2.2d/%-2.2d)\n",
2168  start_lba,min,sec,fr);
2169  Xorriso_result(xorriso,1);
2170  burn_lba_to_msf(end_lba,&min,&sec,&fr);
2171  sprintf(respt, " ATIP start of lead out: %d (%-2.2d:%-2.2d/%-2.2d)\n",
2172  end_lba,min,sec,fr);
2173  Xorriso_result(xorriso,1);
2174  }
2175  }
2176  ret= burn_drive_get_write_speed(drive);
2177  x_speed_max= ((double) ret)/176.4;
2178  if(x_speed_min<0)
2179  x_speed_min= x_speed_max;
2180  sprintf(respt,
2181  " 1T speed low: %.f 1T speed high: %.f\n",x_speed_min,x_speed_max);
2182  Xorriso_result(xorriso,1);
2183  }
2184 
2185  ret= burn_disc_get_media_id(drive, &product_id, &media_code1, &media_code2,
2186  &book_type, 0);
2187  if(ret > 0 && media_code1 != NULL && media_code2 != NULL)
2188  manuf= burn_guess_manufacturer(profile_number, media_code1, media_code2, 0);
2189  if(product_id != NULL) {
2190  sprintf(respt, "Product Id: %s\n", product_id);
2191  Xorriso_result(xorriso,1);
2192  }
2193  if(manuf != NULL) {
2194  sprintf(respt, "Producer: %s\n", manuf);
2195  Xorriso_result(xorriso, 1);
2196  }
2197  if(profile_number == 0x09 || profile_number == 0x0a) {
2198  sprintf(respt, "Manufacturer: %s\n", manuf);
2199  Xorriso_result(xorriso, 1);
2200  } else if(product_id != NULL && media_code1 != NULL && media_code2 != NULL){
2201  free(product_id);
2202  free(media_code1);
2203  free(media_code2);
2204  if(book_type != NULL)
2205  free(book_type);
2206  product_id= media_code1= media_code2= book_type= NULL;
2207  ret= burn_disc_get_media_id(drive, &product_id, &media_code1, &media_code2,
2208  &book_type, 1);
2209  if(ret > 0) {
2210  sprintf(respt, "Manufacturer: '%s'\n", media_code1);
2211  Xorriso_result(xorriso, 1);
2212  if(media_code2[0]) {
2213  sprintf(respt, "Media type: '%s'\n", media_code2);
2214  Xorriso_result(xorriso, 1);
2215  }
2216  }
2217  }
2218  if(manuf != NULL)
2219  free(manuf);
2220  if(media_code1 != NULL)
2221  free(media_code1);
2222  if(media_code2 != NULL)
2223  free(media_code2);
2224  if(book_type != NULL)
2225  free(book_type);
2226  if(product_id != NULL)
2227  free(product_id);
2228  return(1);
2229 }
int Xorriso_list_profiles(struct XorrisO *xorriso, int flag)
Definition: drive_mgt.c:2017
int Xorriso_result(struct XorrisO *xorriso, int flag)
Definition: text_io.c:2337

References XorrisO::info_text, XorrisO::result_line, Xorriso_get_drive_handles(), Xorriso_list_profiles(), Xorriso_msgs_submit(), and Xorriso_result().

Referenced by Xorriso_cdrskin().

◆ Xorriso_attach_boot_image()

int Xorriso_attach_boot_image ( struct XorrisO xorriso,
int  flag 
)

Definition at line 604 of file write_run.c.

605 {
606  int ret;
607  char *cpt;
608  struct burn_drive_info *source_dinfo;
609  struct burn_drive *source_drive;
610  IsoImage *image= NULL;
611  IsoNode *node= NULL;
612  ElToritoBootImage *bootimg;
613  enum eltorito_boot_media_type emul_type= ELTORITO_NO_EMUL;
614  char *bin_path;
615  int emul, platform_id;
616  off_t load_size;
617  struct stat stbuf;
618  int hflag= 0, is_interval= 0;
619 
620  if(xorriso->boot_image_bin_path[0] == 0 && !(flag & 2)) {
621 
622  /* >>> no boot image path given : no op */;
623 
624  ret= 2; goto ex;
625  }
626 
627  if(xorriso->in_drive_handle == NULL)
628  hflag= 2;
629  ret= Xorriso_get_drive_handles(xorriso, &source_dinfo, &source_drive,
630  "on attempt to attach boot image", hflag);
631  if(ret<=0)
632  goto ex;
633  image= isoburn_get_attached_image(source_drive);
634  if(image == NULL) {
635  /* (should not happen) */
636  sprintf(xorriso->info_text,
637  "No ISO image present on attempt to attach boot image");
638  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
639  ret= 0; goto ex;
640  }
641  if(flag & 2) {
642  iso_image_remove_boot_image(image);
643  xorriso->boot_count= 0;
644  ret= 1; goto ex;
645  }
646 
647  bin_path= xorriso->boot_image_bin_path;
648  emul= xorriso->boot_image_emul;
649  platform_id= xorriso->boot_platform_id;
650  load_size= xorriso->boot_image_load_size;
651  if(strncmp(bin_path, "--interval:appended_partition_", 30) == 0) {
652  is_interval= 1;
653  if(load_size <= 0)
654  load_size= 512;
655  }
656 
657  if(xorriso->boot_efi_default) {
658  emul= 0;
659  platform_id= 0xef;
660  xorriso->patch_isolinux_image= (xorriso->patch_isolinux_image & ~3) | 0;
661  }
662  if((platform_id == 0xef || load_size < 0) && !is_interval) {
663  ret= Xorriso_iso_lstat(xorriso, bin_path, &stbuf, 2 | 4);
664  if(ret != 0)
665  {ret= 0; goto ex;}
666  load_size= ((stbuf.st_size / (off_t) 512) +
667  !!(stbuf.st_size % (off_t) 512)) * 512;
668  }
669  sprintf(xorriso->info_text, "Adding boot image ");
670  Text_shellsafe(bin_path, xorriso->info_text, 1);
671  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
672 
673  if(emul == 0)
674  emul_type= ELTORITO_NO_EMUL;
675  else if(emul == 1)
676  emul_type= ELTORITO_HARD_DISC_EMUL;
677  else if(emul == 2)
678  emul_type= ELTORITO_FLOPPY_EMUL;
679 
680  if (!is_interval) {
681  ret= Xorriso_node_from_path(xorriso, image, bin_path, &node, 1);
682  if(ret <= 0) {
683  sprintf(xorriso->info_text,
684  "Cannot find in ISO image: -boot_image ... bin_path=");
685  Text_shellsafe(bin_path, xorriso->info_text, 1);
686  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
687  {ret= 0; goto ex;}
688  }
689  }
690 
691  if(xorriso->boot_count == 0) {
692  if(xorriso->boot_image_cat_path[0] == 0) {
693  strcpy(xorriso->boot_image_cat_path, bin_path);
694  cpt= strrchr(xorriso->boot_image_cat_path, '/');
695  if(cpt == NULL) {
696  strcpy(xorriso->boot_image_cat_path, "/");
697  cpt= xorriso->boot_image_cat_path + 1;
698  } else {
699  cpt++;
700  }
701  strcpy(cpt, "boot.cat");
702  }
703  ret= Xorriso_node_from_path(xorriso, image, xorriso->boot_image_cat_path,
704  &node, 1);
705  if(ret > 0) {
706  if(!xorriso->do_overwrite) {
707  sprintf(xorriso->info_text,
708  "May not overwrite existing -boot_image ... cat_path=");
709  Text_shellsafe(xorriso->boot_image_cat_path, xorriso->info_text, 1);
710  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
711  {ret= 0; goto ex;}
712  }
713  ret= Xorriso_rmi(xorriso, NULL, (off_t) 0, xorriso->boot_image_cat_path,
714  8 | (xorriso->do_overwrite == 1));
715  if(ret != 1) {
716  sprintf(xorriso->info_text,
717  "Could not remove existing -boot_image cat_path=");
718  Text_shellsafe(xorriso->boot_image_cat_path, xorriso->info_text, 1);
719  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
720  {ret= 0; goto ex;}
721  }
722  }
723 
724  /* Discard old boot image, set new one */
725  ret= iso_image_get_boot_image(image, &bootimg, NULL, NULL);
726  if(ret == 1)
727  iso_image_remove_boot_image(image);
728  ret= iso_image_set_boot_image(image, bin_path, emul_type,
729  xorriso->boot_image_cat_path, &bootimg);
730  if(ret > 0)
731  iso_image_set_boot_catalog_weight(image, 1000000000);
732  } else {
733  ret= iso_image_add_boot_image(image, bin_path, emul_type, 0, &bootimg);
734  }
735  if(ret < 0) {
736  Xorriso_process_msg_queues(xorriso,0);
737  Xorriso_report_iso_error(xorriso, "", ret,
738  "Error when attaching El-Torito boot image to ISO 9660 image",
739  0, "FAILURE", 1);
740  sprintf(xorriso->info_text,
741  "Could not attach El-Torito boot image to ISO 9660 image");
742  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
743  {ret= 0; goto ex;}
744  }
745  el_torito_set_boot_platform_id(bootimg, (uint8_t) platform_id);
746  if(load_size / 512 > 65535) {
747  sprintf(xorriso->info_text,
748  "Boot image load size exceeds 65535 blocks of 512 bytes. ");
749  if(platform_id == 0xef) {
750  strcat(xorriso->info_text,
751  "Will record 0 in El Torito to extend ESP to end-of-medium.");
752  load_size= 0;
753  } else {
754  strcat(xorriso->info_text, "Will record 65535 in El Torito.");
755  load_size= 65535 * 512;
756  }
757  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
758  }
759 
760  if(xorriso->boot_img_full_size) {
761  el_torito_set_full_load(bootimg, 1);
762  } else {
763  /* The function will understand negative short as positive unsigned */
764  el_torito_set_load_size(bootimg, (short) (load_size / 512));
765  }
766 
767  el_torito_set_id_string(bootimg, xorriso->boot_id_string);
768  el_torito_set_selection_crit(bootimg, xorriso->boot_selection_crit);
769  ret= Xorriso_set_isolinux_options(xorriso, image, 1);
770  if(!(flag & 1)) {
771  /* Register attachment and reset even in case of error return */
772  xorriso->boot_count++;
773  xorriso->boot_platform_id= 0;
774  xorriso->patch_isolinux_image= 0;
775  xorriso->boot_image_bin_path[0]= 0;
776  xorriso->boot_image_bin_form[0]= 0;
777  xorriso->boot_image_emul= 0;
778  xorriso->boot_emul_default= 1;
779  xorriso->boot_image_load_size= 4 * 512;
780  xorriso->boot_img_size_default= 1;
781  xorriso->boot_img_full_size= 0;
782  memset(xorriso->boot_id_string, 0, sizeof(xorriso->boot_id_string));
783  memset(xorriso->boot_selection_crit, 0,
784  sizeof(xorriso->boot_selection_crit));
785  xorriso->boot_efi_default= 0;
786  }
787  if(ret <= 0)
788  goto ex;
789 
790  ret= 1;
791 ex:;
792  if(image != NULL)
793  iso_image_unref(image);
794  return(ret);
795 }
int Xorriso_rmi(struct XorrisO *xorriso, void *boss_iter, off_t boss_mem, char *path, int flag)
Definition: iso_manip.c:1359
int Xorriso_iso_lstat(struct XorrisO *xorriso, char *path, struct stat *stbuf, int flag)
Definition: iso_tree.c:363
int Xorriso_node_from_path(struct XorrisO *xorriso, IsoImage *volume, char *path, IsoNode **node, int flag)
Definition: iso_tree.c:2650
unsigned char boot_id_string[29]
char boot_image_bin_form[16]
char boot_image_cat_path[4096]
int boot_platform_id
int boot_image_emul
int boot_efi_default
int do_overwrite
int boot_img_full_size
int boot_emul_default
unsigned char boot_selection_crit[21]
int boot_img_size_default
off_t boot_image_load_size
int Xorriso_set_isolinux_options(struct XorrisO *xorriso, IsoImage *image, int flag)
Definition: write_run.c:2787

References XorrisO::boot_count, XorrisO::boot_efi_default, XorrisO::boot_emul_default, XorrisO::boot_id_string, XorrisO::boot_image_bin_form, XorrisO::boot_image_bin_path, XorrisO::boot_image_cat_path, XorrisO::boot_image_emul, XorrisO::boot_image_load_size, XorrisO::boot_img_full_size, XorrisO::boot_img_size_default, XorrisO::boot_platform_id, XorrisO::boot_selection_crit, XorrisO::do_overwrite, XorrisO::in_drive_handle, XorrisO::info_text, isoburn_get_attached_image(), XorrisO::patch_isolinux_image, Text_shellsafe(), Xorriso_get_drive_handles(), Xorriso_iso_lstat(), Xorriso_msgs_submit(), Xorriso_node_from_path(), Xorriso_process_msg_queues(), Xorriso_report_iso_error(), Xorriso_rmi(), and Xorriso_set_isolinux_options().

Referenced by Xorriso_genisofs_add_boot(), Xorriso_option_boot_image(), and Xorriso_write_session().

◆ Xorriso_auto_driveadr()

int Xorriso_auto_driveadr ( struct XorrisO xorriso,
char *  adr,
char *  result,
int  flag 
)

Definition at line 49 of file drive_mgt.c.

51 {
52  int ret, is_known_mmc= 0, does_exist= 0;
53  char *path_pt, *libburn_adr= NULL;
54  char *abs_pt, *abs_adr= NULL;
55  struct stat stbuf;
56 
57  Xorriso_alloc_meM(libburn_adr, char, BURN_DRIVE_ADR_LEN + SfileadrL);
58  Xorriso_alloc_meM(abs_adr, char, SfileadrL);
59  path_pt= adr;
60  if(strncmp(adr, "stdio:", 6) == 0)
61  path_pt= adr + 6;
62  else if(strncmp(adr, "mmc:", 4) == 0)
63  path_pt= adr + 4;
64 
65 
66  /* <<< replace by Xorriso_normalize_img_path() ? */;
67 
68  if(path_pt[0] != '/') {
69  abs_pt= getcwd(abs_adr, SfileadrL - 1);
70  if(abs_pt == NULL) {
71  Xorriso_msgs_submit(xorriso, 0,
72  "Relative drive path given. Cannot determine working directory.",
73  errno, "FAILURE", 0);
74  {ret= -1; goto ex;}
75  }
76  ret= Sfile_add_to_path(abs_adr, path_pt, 0);
77  if(ret <= 0)
78  {ret= -1; goto ex;}
79  }
80 
81  is_known_mmc= burn_drive_convert_fs_adr(path_pt, libburn_adr);
82  does_exist= (stat(path_pt, &stbuf) != -1);
83  Xorriso_process_msg_queues(xorriso,0);
84 
85  ret= Xorriso_is_in_patternlist(xorriso, xorriso->drive_whitelist, path_pt, 0);
86  if(ret > 0)
87  goto ok;
88  ret= Xorriso_is_in_patternlist(xorriso, xorriso->drive_blacklist, path_pt, 0);
89  if(ret < 0)
90  goto ex;
91  if(ret) {
92  strcpy(xorriso->info_text, "Drive address ");
93  Text_shellsafe(adr, xorriso->info_text, 1);
94  strcat(xorriso->info_text,
95  " rejected because: -drive_class 'banned' ");
97  ret - 1, 0),
98  xorriso->info_text, 1);
99  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
100  {ret= 0; goto ex;}
101  }
102  /* if in greylist and not MMC and not stdio prefix: reject */
103  if(is_known_mmc < 0)
104  goto ex;
105  if(adr == path_pt && !is_known_mmc) { /* no prefix, no MMC */
106  ret= Xorriso_is_in_patternlist(xorriso, xorriso->drive_greylist, path_pt,0);
107  if(ret < 0)
108  goto ex;
109  if(ret) {
110  strcpy(xorriso->info_text, "Drive address ");
111  Text_shellsafe(adr, xorriso->info_text, 1);
112  strcat(xorriso->info_text, " rejected because: ");
113  if(does_exist)
114  strcat(xorriso->info_text, "not MMC");
115  else
116  strcat(xorriso->info_text, "not existing");
117  strcat(xorriso->info_text, " and -drive_class 'caution' ");
119  ret - 1, 0),
120  xorriso->info_text, 1);
121  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
122  sprintf(xorriso->info_text,
123  "If the address is a legitimate %s, prepend \"stdio:\"",
124  does_exist ? "target" : "address for a new regular file");
125  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0);
126  {ret= 0; goto ex;}
127  }
128  }
129 ok:;
130  if(strncmp(adr, "mmc:", 4) == 0) {
131  if(Sfile_str(result, path_pt, 0) <= 0)
132  {ret= 0; goto ex;}
133  } else if(adr == path_pt && is_known_mmc <= 0) {
134  Sfile_str(result, "stdio:", 0);
135  if(Sfile_str(result, adr, 1) <= 0)
136  {ret= 0; goto ex;}
137  } else {
138  if(Sfile_str(result, adr, 0) <= 0)
139  {ret= 0; goto ex;}
140  }
141  if(strncmp(result, "stdio:", 6)==0) {
142  if(xorriso->ban_stdio_write) {
143  strcpy(xorriso->info_text, "Drive address banned by -ban_stdio_write : ");
144  Text_shellsafe(result, xorriso->info_text, 1);
145  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
146  {ret= 0; goto ex;}
147  }
148  }
149  ret= 1;
150 ex:;
151  Xorriso_free_meM(libburn_adr);
152  Xorriso_free_meM(abs_adr);
153  return(ret);
154 }
char * Xorriso_get_pattern(struct XorrisO *xorriso, struct Xorriso_lsT *patternlist, int index, int flag)
Definition: match.c:321
int Xorriso_is_in_patternlist(struct XorrisO *xorriso, struct Xorriso_lsT *patternlist, char *path, int flag)
Definition: match.c:297
int Sfile_add_to_path(char path[4096], char *addon, int flag)
Definition: sfile.c:137
int ban_stdio_write
struct Xorriso_lsT * drive_blacklist
struct Xorriso_lsT * drive_whitelist
struct Xorriso_lsT * drive_greylist

References XorrisO::ban_stdio_write, XorrisO::drive_blacklist, XorrisO::drive_greylist, XorrisO::drive_whitelist, XorrisO::info_text, Sfile_add_to_path(), Sfile_str(), SfileadrL, Text_shellsafe(), Xorriso_alloc_meM, Xorriso_free_meM, Xorriso_get_pattern(), Xorriso_is_in_patternlist(), Xorriso_msgs_submit(), and Xorriso_process_msg_queues().

Referenced by Xorriso_aquire_drive().

◆ Xorriso_blank_as_needed()

int Xorriso_blank_as_needed ( struct XorrisO xorriso,
int  flag 
)

Definition at line 2071 of file write_run.c.

2072 {
2073  int ret, is_formatted= -1, status, num_formats, did_work= 0;
2074  struct burn_drive_info *dinfo;
2075  struct burn_drive *drive;
2076  enum burn_disc_status disc_state;
2077  unsigned dummy;
2078  int current_profile;
2079  char current_profile_name[80];
2080  off_t size;
2081 
2082  ret= Xorriso_may_burn(xorriso, 0);
2083  if(ret <= 0)
2084  return(0);
2085  ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
2086  "on attempt to blank or format", 2);
2087  if(ret<=0)
2088  return(0);
2089 
2090  burn_disc_get_profile(drive, &current_profile, current_profile_name);
2091 
2092  ret= burn_disc_get_formats(drive, &status, &size, &dummy, &num_formats);
2093  if(ret>0) {
2094  if(status==BURN_FORMAT_IS_FORMATTED)
2095  is_formatted= 1;
2096  else if(status == BURN_FORMAT_IS_UNFORMATTED)
2097  is_formatted= 0;
2098  }
2099  if(current_profile == 0x12 || current_profile == 0x43) { /* DVD+RAM , BD-RE */
2100  if(is_formatted<0) {
2101  sprintf(xorriso->info_text,
2102  "-blank or -format: Unclear formatting status of %s",
2103  current_profile_name);
2104  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
2105  return(0);
2106  }
2107  if(!is_formatted) {
2108  ret= Xorriso_format_media(xorriso, (off_t) 0, (current_profile == 0x43));
2109  if(ret <= 0)
2110  return(ret);
2111  did_work= (ret == 1);
2112  }
2113  } else if(current_profile == 0x14 && (flag&4)) { /* DVD-RW sequential */
2114  ret= Xorriso_format_media(xorriso, (off_t) 0, 0);
2115  if(ret <= 0)
2116  return(ret);
2117  did_work= (ret == 1);
2118  } else if(current_profile == 0x41) { /* BD-R SRM */
2119  if((flag & 4) && !is_formatted) {
2120  ret= Xorriso_format_media(xorriso, (off_t) 0, 1);
2121  if(ret <= 0)
2122  return(ret);
2123  did_work= (ret == 1);
2124  }
2125  }
2126 
2127  disc_state = isoburn_disc_get_status(drive);
2128  if(disc_state != BURN_DISC_BLANK && !(flag&4)) {
2129  ret= Xorriso_blank_media(xorriso, 1);
2130  return(ret);
2131  }
2132  if(did_work)
2133  return(1);
2134  sprintf(xorriso->info_text, "%s as_needed: no need for action detected",
2135  (flag&4) ? "-format" : "-blank");
2136  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
2137  return(2);
2138 }
int Xorriso_may_burn(struct XorrisO *xorriso, int flag)
Definition: drive_mgt.c:849
int Xorriso_blank_media(struct XorrisO *xorriso, int flag)
Definition: write_run.c:1763
int Xorriso_format_media(struct XorrisO *xorriso, off_t in_size, int flag)
Definition: write_run.c:1895

References XorrisO::info_text, isoburn_disc_get_status(), Xorriso_blank_media(), Xorriso_format_media(), Xorriso_get_drive_handles(), Xorriso_may_burn(), and Xorriso_msgs_submit().

Referenced by Xorriso_option_blank().

◆ Xorriso_blank_media()

int Xorriso_blank_media ( struct XorrisO xorriso,
int  flag 
)

Definition at line 1763 of file write_run.c.

1764 {
1765  int ret, do_deformat= 0, signal_mode, using_immed;
1766  struct burn_drive_info *dinfo;
1767  struct burn_drive *drive;
1768  enum burn_disc_status disc_state;
1769  struct burn_progress p;
1770  double percent = 1.0;
1771  int current_profile;
1772  char current_profile_name[80];
1773  time_t start_time;
1774  char mode_names[4][80]= {"all", "fast", "deformat", "deformat_quickest"};
1775  char progress_text[40];
1776 
1777  ret= Xorriso_may_burn(xorriso, 0);
1778  if(ret <= 0)
1779  return(0);
1780  ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
1781  "on attempt to -blank", 2);
1782  if(ret<=0)
1783  return(0);
1784 
1785  burn_disc_get_profile(drive, &current_profile, current_profile_name);
1786 
1787  disc_state = isoburn_disc_get_status(drive);
1788  if(current_profile == 0x13) { /* overwritable DVD-RW */
1789  /* Depending on flag bit1 formatted DVD-RW will get blanked to sequential
1790  state or pseudo blanked by invalidating an eventual ISO image. */
1791  if(flag&2)
1792  do_deformat= 1;
1793  } else if(current_profile == 0x14) { /* sequential DVD-RW */
1794  if((flag&1) && !(flag&2)) {
1795  sprintf(xorriso->info_text,
1796  "-blank: DVD-RW present. Mode 'fast' defaulted to mode 'all'.");
1797  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
1798  sprintf(xorriso->info_text,
1799  "Mode 'deformat_quickest' produces single-session-only media.");
1800  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0);
1801  flag&= ~1;
1802  }
1803  }
1804  if(disc_state == BURN_DISC_BLANK) {
1805  if(!do_deformat) {
1806  sprintf(xorriso->info_text,
1807  "Blank medium detected. Will leave it untouched");
1808  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
1809  return 2;
1810  }
1811  } else if(disc_state==BURN_DISC_FULL || disc_state==BURN_DISC_APPENDABLE) {
1812  ;
1813  } else if(disc_state == BURN_DISC_EMPTY) {
1814  sprintf(xorriso->info_text,"No media detected in drive");
1815  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
1816  return 0;
1817  } else {
1818  sprintf(xorriso->info_text, "Unsuitable drive and media state");
1819  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
1820  return 0;
1821  }
1822  if(!isoburn_disc_erasable(drive)) {
1823  sprintf(xorriso->info_text, "Media is not of erasable type");
1824  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
1825  return 0;
1826  }
1827  if(xorriso->do_dummy) {
1828  sprintf(xorriso->info_text,
1829  "-dummy mode prevents blanking of medium in mode '%s'.",
1830  mode_names[flag&3]);
1831  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
1832  return(1);
1833  }
1834  using_immed= burn_drive_get_immed(drive);
1835  sprintf(xorriso->info_text, "Beginning to blank medium in mode '%s'.\n",
1836  mode_names[flag&3]);
1837  Xorriso_info(xorriso,0);
1838 
1839  /* Important: do not return until burn_is_aborting() was checked */
1840  signal_mode= 1;
1841  ret= burn_drive_get_drive_role(drive);
1842  if(ret == 1)
1843  signal_mode|= 2;
1844  Xorriso_set_signal_handling(xorriso, signal_mode);
1845 
1846  if(do_deformat)
1847  burn_disc_erase(drive, (flag&1));
1848  else
1849  isoburn_disc_erase(drive, (flag&1));
1850  start_time= time(0);
1851  usleep(1000000);
1852  if(!using_immed)
1853  sprintf(progress_text, "synchronously since");
1854  while (burn_drive_get_status(drive, &p) != BURN_DRIVE_IDLE) {
1855  Xorriso_process_msg_queues(xorriso,0);
1856  if(p.sectors>0 && p.sector>=0) /* display 1 to 99 percent */
1857  percent = 1.0 + ((double) p.sector+1.0) / ((double) p.sectors) * 98.0;
1858  if(using_immed)
1859  sprintf(progress_text, "%.1f%% done in", percent);
1860  sprintf(xorriso->info_text, "Blanking ( %s %d seconds )",
1861  progress_text, (int) (time(0) - start_time));
1862  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0);
1863  usleep(1000000);
1864  }
1865  Xorriso_process_msg_queues(xorriso,0);
1866  if(burn_is_aborting(0))
1867  Xorriso_abort(xorriso, 0); /* Never comes back */
1868  Xorriso_set_signal_handling(xorriso, 0);
1869  if(burn_drive_wrote_well(drive)) {
1870  sprintf(xorriso->info_text, "Blanking done\n");
1871  Xorriso_info(xorriso,0);
1872  } else {
1873  sprintf(xorriso->info_text, "Blanking failed.");
1874  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
1875  }
1876  if(!(flag & 4)) {
1877  ret= Xorriso_reaquire_outdev(xorriso,
1878  2 + (xorriso->in_drive_handle == xorriso->out_drive_handle));
1879  if(ret <= 0)
1880  return(-1);
1881  }
1882  return(1);
1883 }
int isoburn_disc_erasable(struct burn_drive *d)
Tells whether the medium can be treated by isoburn_disc_erase().
Definition: burn_wrap.c:682
void isoburn_disc_erase(struct burn_drive *drive, int fast)
Mark the medium as blank.
Definition: burn_wrap.c:710
int Xorriso_reaquire_outdev(struct XorrisO *xorriso, int flag)
Definition: drive_mgt.c:907
int Xorriso_abort(struct XorrisO *xorriso, int flag)
Definition: lib_mgt.c:62
int Xorriso_set_signal_handling(struct XorrisO *xorriso, int flag)
Definition: lib_mgt.c:85

References XorrisO::do_dummy, XorrisO::in_drive_handle, XorrisO::info_text, isoburn_disc_erasable(), isoburn_disc_erase(), isoburn_disc_get_status(), XorrisO::out_drive_handle, Xorriso_abort(), Xorriso_get_drive_handles(), Xorriso_info(), Xorriso_may_burn(), Xorriso_msgs_submit(), Xorriso_process_msg_queues(), Xorriso_reaquire_outdev(), and Xorriso_set_signal_handling().

Referenced by Xorriso_blank_as_needed(), Xorriso_format_media(), and Xorriso_option_blank().

◆ Xorriso_boot_image_status()

int Xorriso_boot_image_status ( struct XorrisO xorriso,
char *  filter,
FILE *  fp,
int  flag 
)

Definition at line 662 of file iso_img.c.

664 {
665  int ret, i, num_boots, hflag;
666  int is_default, no_defaults;
667  char *path= NULL, *form= "any", *line, *hpt;
668  struct burn_drive_info *dinfo;
669  struct burn_drive *drive;
670  IsoImage *image= NULL;
671  ElToritoBootImage **boots = NULL;
672  IsoFile **bootnodes = NULL;
673  int platform_id, patch, load_size;
674  enum eltorito_boot_media_type media_type;
675  unsigned char id_string[29], sel_crit[21];
676 
677  Xorriso_alloc_meM(path, char, SfileadrL);
678  line= xorriso->result_line;
679  no_defaults= flag & 1;
680 
681  ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
682  "on attempt to print boot info", 2 | 16);
683  if(ret<=0)
684  goto no_image;
685  image= isoburn_get_attached_image(drive);
686  Xorriso_process_msg_queues(xorriso,0);
687  if(image == NULL)
688  goto no_image;
689 
690  ret= Xorriso_boot_status_non_mbr(xorriso, image, filter, fp, flag & 3);
691  if(ret < 0) /* == 0 is normal */
692  {ret= 0; goto ex;}
693 
694  if(xorriso->boot_count == 0 && xorriso->boot_image_bin_path[0] == 0) {
695 no_image:;
696  if(xorriso->patch_isolinux_image & 1) {
697  sprintf(line, "-boot_image %s patch\n",
698  xorriso->patch_isolinux_image & 2 ? "grub" : form);
699  is_default= 0;
700  } else if(xorriso->keep_boot_image) {
701  sprintf(line, "-boot_image %s keep\n", form);
702  is_default= 0;
703  } else {
704  sprintf(line, "-boot_image %s discard\n", form);
705  is_default= 1;
706  }
707  if(!(is_default && no_defaults))
708  Xorriso_status_result(xorriso,filter,fp,flag&2);
709  goto report_open_item;
710  }
711 
712  is_default= (xorriso->boot_image_cat_path[0] == 0);
713  sprintf(line,"-boot_image %s cat_path=", form);
714  Text_shellsafe(xorriso->boot_image_cat_path, line, 1);
715  strcat(line, "\n");
716  if(!(is_default && no_defaults))
717  Xorriso_status_result(xorriso,filter,fp,flag&2);
718 
719  is_default= !xorriso->boot_image_cat_hidden;
720  hpt= Xorriso__hide_mode_text(xorriso->boot_image_cat_hidden & 63, 0);
721  if(hpt != NULL)
722  sprintf(line, "-boot_image %s cat_hidden=%s\n", form, hpt);
723  Xorriso_free_meM(hpt);
724  if(!(is_default && no_defaults))
725  Xorriso_status_result(xorriso,filter,fp,flag&2);
726 
727  if(xorriso->boot_count > 0) {
728 
729  /* show attached boot image info */;
730 
731  ret= iso_image_get_all_boot_imgs(image, &num_boots, &boots, &bootnodes, 0);
732  Xorriso_process_msg_queues(xorriso,0);
733  if(ret == 1 && num_boots > 0) {
734  for(i= 0; i < num_boots; i++) {
735  ret= Xorriso_path_from_node(xorriso, (IsoNode *) bootnodes[i], path, 0);
736  if(ret <= 0)
737  continue;
738  platform_id= el_torito_get_boot_platform_id(boots[i]);
739  patch= el_torito_get_isolinux_options(boots[i], 0);
740  el_torito_get_boot_media_type(boots[i], &media_type);
741  load_size= el_torito_get_load_size(boots[i]) * 512;
742  el_torito_get_id_string(boots[i], id_string);
743  el_torito_get_selection_crit(boots[i], sel_crit);
744  if(media_type == ELTORITO_FLOPPY_EMUL)
745  media_type= 2;
746  else if(media_type == ELTORITO_HARD_DISC_EMUL)
747  media_type= 1;
748  else
749  media_type= 0;
750  ret= Xorriso_boot_item_status(xorriso, xorriso->boot_image_cat_path,
751  path, platform_id, patch, media_type,
752  load_size, id_string, sel_crit, "any",
753  filter, fp, 16 | (flag & 3));
754  if(ret <= 0)
755  continue;
756  sprintf(line,"-boot_image %s next\n", form);
757  Xorriso_status_result(xorriso,filter,fp,flag&2);
758  }
759  }
760  }
761 
762  /* Show pending boot image info */
763  if(strcmp(xorriso->boot_image_bin_form, "isolinux") == 0 ||
764  strcmp(xorriso->boot_image_bin_form, "grub") == 0)
765  form= xorriso->boot_image_bin_form;
766 
767  if(xorriso->boot_count > 0 &&
768  xorriso->boot_platform_id == 0 &&
769  xorriso->patch_isolinux_image == 0 &&
770  xorriso->boot_image_bin_path[0] == 0 &&
771  xorriso->boot_image_emul == 0 &&
772  xorriso->boot_image_load_size == 4 * 512) {
773  for(i= 0; i < 20; i++)
774  if(xorriso->boot_selection_crit[i])
775  break;
776  if(i >= 20)
777  for(i= 0; i < 28; i++)
778  if(xorriso->boot_id_string[i])
779  break;
780  if(i >= 28)
781  {ret= 1; goto ex;} /* Images registered, pending is still default */
782  }
783 
784 report_open_item:;
785  hflag= 16;
786  if(xorriso->boot_platform_id == 0xef && !xorriso->boot_efi_default)
787  hflag= 0;
788  ret= Xorriso_boot_item_status(xorriso, xorriso->boot_image_cat_path,
789  xorriso->boot_image_bin_path, xorriso->boot_platform_id,
790  xorriso->patch_isolinux_image, xorriso->boot_image_emul,
791  xorriso->boot_image_load_size, xorriso->boot_id_string,
792  xorriso->boot_selection_crit, form,
793  filter, fp, hflag | (flag & 3));
794  if(ret <= 0)
795  goto ex;
796 
797  ret = Xorriso_append_part_status(xorriso, image, filter, fp, flag & 3);
798  if(ret <= 0)
799  goto ex;
800 
801  ret= 1;
802 ex:
803  if(boots != NULL)
804  free(boots);
805  if(bootnodes != NULL)
806  free(bootnodes);
807  if(image != NULL)
808  iso_image_unref(image);
809  Xorriso_free_meM(path);
810  return(ret);
811 }
int Xorriso_boot_item_status(struct XorrisO *xorriso, char *cat_path, char *bin_path, int platform_id, int patch_isolinux, int emul, off_t load_size, unsigned char *id_string, unsigned char *selection_crit, char *form, char *filter, FILE *fp, int flag)
Definition: iso_img.c:379
int Xorriso_boot_status_non_mbr(struct XorrisO *xorriso, IsoImage *image, char *filter, FILE *fp, int flag)
Definition: iso_img.c:560
int Xorriso_append_part_status(struct XorrisO *xorriso, IsoImage *image, char *filter, FILE *fp, int flag)
Definition: iso_img.c:627
int Xorriso_path_from_node(struct XorrisO *xorriso, IsoNode *in_node, char path[4096], int flag)
Definition: iso_tree.c:399
char * Xorriso__hide_mode_text(int hide_mode, int flag)
Definition: misc_funct.c:1273
int boot_image_cat_hidden
int Xorriso_status_result(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
Definition: text_io.c:2687

References XorrisO::boot_count, XorrisO::boot_efi_default, XorrisO::boot_id_string, XorrisO::boot_image_bin_form, XorrisO::boot_image_bin_path, XorrisO::boot_image_cat_hidden, XorrisO::boot_image_cat_path, XorrisO::boot_image_emul, XorrisO::boot_image_load_size, XorrisO::boot_platform_id, XorrisO::boot_selection_crit, isoburn_get_attached_image(), XorrisO::keep_boot_image, XorrisO::patch_isolinux_image, XorrisO::result_line, SfileadrL, Text_shellsafe(), Xorriso__hide_mode_text(), Xorriso_alloc_meM, Xorriso_append_part_status(), Xorriso_boot_item_status(), Xorriso_boot_status_non_mbr(), Xorriso_free_meM, Xorriso_get_drive_handles(), Xorriso_path_from_node(), Xorriso_process_msg_queues(), and Xorriso_status_result().

Referenced by Xorriso_status().

◆ Xorriso_burn_track()

int Xorriso_burn_track ( struct XorrisO xorriso,
off_t  write_start_address,
char *  track_source,
off_t  tsize,
int  flag 
)

Definition at line 2174 of file write_run.c.

2176 {
2177  int ret, fd, profile_number, is_cd= 0, dummy, nwa= -1;
2178  int isosize= -1, do_isosize, is_bd= 0, signal_mode;
2179  struct burn_drive_info *dinfo;
2180  struct burn_drive *drive;
2181  struct burn_write_opts *burn_options= NULL;
2182  struct burn_disc *disc= NULL;
2183  struct burn_session *session= NULL;
2184  struct burn_track *track= NULL;
2185  struct stat stbuf;
2186  off_t fixed_size= 0;
2187  struct burn_source *data_src= NULL, *fifo_src= NULL;
2188  enum burn_disc_status disc_state;
2189  char *reasons= NULL, *profile_name= NULL;
2190  char *head_buffer= NULL;
2191 
2192  Xorriso_alloc_meM(reasons, char, BURN_REASONS_LEN);
2193  Xorriso_alloc_meM(profile_name, char, 80);
2194  Xorriso_alloc_meM(head_buffer, char, 64 * 1024);
2195 
2196  ret= Xorriso_may_burn(xorriso, 0);
2197  if(ret <= 0)
2198  {ret= 0; goto ex;}
2199  ret= Xorriso_auto_format(xorriso, 0);
2200  if(ret <=0 )
2201  {ret= 0; goto ex;}
2202 
2203  do_isosize= !!(flag&2);
2204  ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
2205  "on attempt to burn track", 2);
2206  if(ret<=0)
2207  {ret= 0; goto ex;}
2208 
2209  ret= Xorriso_check_multi(xorriso, drive, 1);
2210  if(ret<=0)
2211  goto ex;
2212  ret= Xorriso_make_write_options(xorriso, drive, &burn_options, 0);
2213  if(ret<=0)
2214  goto ex;
2215 
2216  disc= burn_disc_create();
2217  session= burn_session_create();
2218  ret= burn_disc_add_session(disc,session,BURN_POS_END);
2219  if(ret==0) {
2220  sprintf(xorriso->info_text, "Cannot add session object to disc object.");
2221  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
2222  goto ex;
2223  }
2224  track= burn_track_create();
2225  if(track_source[0] == '-' && track_source[1] == 0) {
2226  fd= 0;
2227  } else {
2228  if(xorriso->fs >= 64)
2229  fd= burn_os_open_track_src(track_source, O_RDONLY, 0);
2230  else
2231  fd= open(track_source, O_RDONLY | O_BINARY);
2232  if(fd>=0)
2233  if(fstat(fd,&stbuf)!=-1)
2234  if((stbuf.st_mode&S_IFMT)==S_IFREG)
2235  fixed_size= stbuf.st_size;
2236  }
2237 
2238  if(fd>=0)
2239  data_src= burn_fd_source_new(fd, -1, fixed_size);
2240  if(data_src==NULL) {
2241  sprintf(xorriso->info_text, "Could not open data source ");
2242  Text_shellsafe(track_source, xorriso->info_text, 1);
2243  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
2244  ret= 0; goto ex;
2245  }
2246  if((do_isosize || xorriso->fs != 0) && xorriso->fs < 64)
2247  xorriso->fs= 64;
2248  if(xorriso->fs > 0) {
2249  fifo_src= burn_fifo_source_new(data_src, 2048 + 8 * !!(flag & 4),
2250  xorriso->fs, 1);
2251  if(fifo_src == NULL) {
2252  sprintf(xorriso->info_text, "Could not create fifo object of %.f MB",
2253  ((double) xorriso->fs) / 1024.0 / 1024.0);
2254  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
2255  ret= 0; goto ex;
2256  }
2257  }
2258  xorriso->pacifier_fifo= fifo_src;
2259  if(burn_track_set_source(track, fifo_src == NULL ? data_src : fifo_src)
2260  != BURN_SOURCE_OK) {
2261  sprintf(xorriso->info_text,
2262  "Cannot attach source object to track object");
2263  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
2264  ret= 0; goto ex;
2265  }
2266  burn_track_set_cdxa_conv(track, !!(flag & 4));
2267  burn_session_add_track(session, track, BURN_POS_END);
2268  burn_source_free(data_src);
2269 
2270  if(flag&1)
2271  /* consider overwriteables with ISO as appendable */
2272  disc_state= isoburn_disc_get_status(drive);
2273  else
2274  /* handle overwriteables as always blank */
2275  disc_state= burn_disc_get_status(drive);
2276 
2277  if(disc_state == BURN_DISC_BLANK || disc_state == BURN_DISC_APPENDABLE) {
2278  /* ok */;
2279  } else {
2280  if(disc_state == BURN_DISC_FULL) {
2281  sprintf(xorriso->info_text,
2282  "Closed media with data detected. Need blank or appendable media.");
2283  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
2284  if(burn_disc_erasable(drive)) {
2285  sprintf(xorriso->info_text, "Try -blank as_needed\n");
2286  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0);
2287  }
2288  } else if(disc_state == BURN_DISC_EMPTY) {
2289  sprintf(xorriso->info_text, "No media detected in drive");
2290  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
2291  } else {
2292  sprintf(xorriso->info_text,
2293  "Cannot recognize state of drive and media");
2294  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
2295  }
2296  ret= 0; goto ex;
2297  }
2298  if(isoburn_needs_emulation(drive))
2299  burn_write_opts_set_multi(burn_options, 0);
2300 
2301  if(tsize > 0) {
2302  fixed_size= tsize;
2303  burn_track_set_size(track, fixed_size);
2304  }
2305  if(do_isosize) {
2306  ret= burn_fifo_peek_data(xorriso->pacifier_fifo, head_buffer, 64*1024, 0);
2307  if(ret<=0) {
2308  Xorriso_process_msg_queues(xorriso,0);
2309  sprintf(xorriso->info_text,
2310  "Cannot obtain first 64 kB from input stream.");
2311  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
2312  ret= 0; goto ex;
2313  }
2314  /* read isosize from head_buffer, not from medium */
2315  ret= isoburn_read_iso_head(drive, 0, &isosize, head_buffer, (1<<13));
2316  if(ret<=0) {
2317  Xorriso_process_msg_queues(xorriso,0);
2318  sprintf(xorriso->info_text,
2319  "Option -isosize given but data stream seems not to be ISO 9660");
2320  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
2321  ret= 0; goto ex;
2322  }
2323  sprintf(xorriso->info_text, "Size of ISO 9660 image: %ds", isosize);
2324  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
2325  fixed_size= ((off_t) (isosize)) * (off_t) 2048;
2326  burn_track_set_size(track, fixed_size);
2327  }
2328 
2329  ret= Xorriso_get_profile(xorriso, &profile_number, profile_name, 2);
2330  is_cd= (ret==2);
2331  is_bd= (ret == 3);
2332 
2333  if(isoburn_needs_emulation(drive)) {
2334  if(flag&1) {
2335  ret= isoburn_disc_track_lba_nwa(drive, burn_options, 0, &dummy, &nwa);
2336  Xorriso_process_msg_queues(xorriso,0);
2337  if(ret<=0) {
2338  sprintf(xorriso->info_text,
2339  "Cannot obtain next writeable address of emulated multi-session media\n");
2340  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
2341  ret= 0; goto ex;
2342  }
2343  if(nwa == 32 && disc_state != BURN_DISC_APPENDABLE)
2344  nwa= 0; /* No automatic toc emulation. Formatter might not be aware. */
2345  } else {
2346  nwa= 0;
2347  if (disc_state == BURN_DISC_APPENDABLE) {
2348  ret= isoburn_disc_track_lba_nwa(drive, burn_options, 0, &dummy, &nwa);
2349  Xorriso_process_msg_queues(xorriso,0);
2350  if(ret<=0) {
2351  sprintf(xorriso->info_text,
2352  "Cannot obtain next writeable address of emulated appendable media\n");
2353  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
2354  ret= 0; goto ex;
2355  }
2356  }
2357  }
2358  burn_write_opts_set_start_byte(burn_options,((off_t) nwa) * (off_t) 2048);
2359  }
2360 
2361  if(write_start_address>=0) {
2362  nwa= write_start_address / (off_t) 2048;
2363  if(((off_t) nwa) * (off_t) 2048 < write_start_address )
2364  nwa++;
2365  burn_write_opts_set_start_byte(burn_options, ((off_t) nwa) * (off_t) 2048);
2366  }
2367 
2368  if(xorriso->do_tao) {
2369  if (xorriso->do_tao > 0)
2370  burn_write_opts_set_write_type(burn_options,
2371  BURN_WRITE_TAO, BURN_BLOCK_MODE1);
2372  else
2373  burn_write_opts_set_write_type(burn_options,
2374  BURN_WRITE_SAO, BURN_BLOCK_SAO);
2375 
2376  ret = burn_precheck_write(burn_options, disc, reasons, 0);
2377  if(ret<=0) {
2378  sprintf(xorriso->info_text,
2379  "Cannot set write type %s for this medium.\n",
2380  xorriso->do_tao > 0 ? "TAO" : "SAO");
2381  sprintf(xorriso->info_text+strlen(xorriso->info_text),
2382  "Reasons given:\n%s", reasons);
2383  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
2384  ret= 0; goto ex;
2385  }
2386  sprintf(xorriso->info_text, "Explicitly chosen write type: %s",
2387  xorriso->do_tao > 0 ? "TAO" : "SAO");
2388  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
2389  } else {
2390  if(burn_write_opts_auto_write_type(burn_options, disc, reasons, 0) ==
2391  BURN_WRITE_NONE) {
2392  sprintf(xorriso->info_text,
2393  "Failed to find a suitable write mode with this media.\n");
2394  sprintf(xorriso->info_text+strlen(xorriso->info_text),
2395  "Reasons given:\n%s", reasons);
2396  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
2397  ret= 0; goto ex;
2398  }
2399  }
2400 
2401  ret= Xorriso_sanitize_image_size(xorriso, drive, disc, burn_options, 2);
2402  if(ret<=0)
2403  goto ex;
2404 
2405  sprintf(xorriso->info_text, "Beginning to write data track.\n");
2406  Xorriso_info(xorriso,0);
2407 
2408  /* Important: do not return until burn_is_aborting() was checked */
2409  signal_mode= 1;
2410  ret= burn_drive_get_drive_role(drive);
2411  if(ret == 1)
2412  signal_mode|= 2;
2413  Xorriso_set_signal_handling(xorriso, signal_mode);
2414 
2415  xorriso->run_state= 1; /* Indicate that burning has started */
2416  burn_disc_write(burn_options, disc);
2417 
2418  ret= Xorriso_pacifier_loop(xorriso, drive, 2 | (is_cd << 4) | (is_bd << 5));
2419  if(burn_is_aborting(0))
2420  Xorriso_abort(xorriso, 0); /* Never comes back */
2421  Xorriso_set_signal_handling(xorriso, 0);
2422  if(ret<=0)
2423  goto ex;
2424  if(!burn_drive_wrote_well(drive)) {
2425  Xorriso_process_msg_queues(xorriso,0);
2426  if(xorriso->auto_close && xorriso->do_close == 0) {
2427  if(burn_drive_was_feat21_failure(drive)) {
2428  sprintf(xorriso->info_text,
2429  "libburn indicates failure with writing DVD-RW to appendable state.");
2430  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
2431  /* Urge caller to call Xorriso_retry_burn_rack() */
2432  ret= 2; goto ex;
2433  }
2434  }
2435  sprintf(xorriso->info_text,
2436  "libburn indicates failure with writing.");
2437  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
2438  ret= 0; goto ex;
2439  }
2440 
2441  if(flag & 1) {
2442  ret= Xorriso_update_iso_lba0(xorriso, nwa, isosize, head_buffer, NULL,
2443  flag & 2);
2444  if(ret <= 0)
2445  goto ex;
2446  }
2447  sprintf(xorriso->info_text, "Writing to ");
2448  Text_shellsafe(xorriso->outdev, xorriso->info_text, 1);
2449  strcat(xorriso->info_text, " completed successfully.\n\n");
2450  Xorriso_info(xorriso, 0);
2451  ret= 1;
2452 ex:;
2453  Xorriso_process_msg_queues(xorriso,0);
2454  if(disc!=NULL)
2455  burn_disc_free(disc);
2456  if(session != NULL)
2457  burn_session_free(session);
2458  if(track != NULL)
2459  burn_track_free(track);
2460  if(burn_options != NULL)
2461  burn_write_opts_free(burn_options);
2462  if(xorriso->pacifier_fifo!=NULL)
2463  burn_source_free(xorriso->pacifier_fifo);
2464  xorriso->pacifier_fifo= NULL;
2465  xorriso->run_state= 0; /* Indicate that burning has ended */
2466  Xorriso_free_meM(reasons);
2467  Xorriso_free_meM(profile_name);
2468  Xorriso_free_meM(head_buffer);
2469  return(ret);
2470 }
int isoburn_needs_emulation(struct burn_drive *drive)
Inquire whether the medium needs emulation or would be suitable for generic multi-session via libburn...
Definition: burn_wrap.c:1062
int isoburn_read_iso_head(struct burn_drive *d, int lba, int *image_blocks, char *info, int flag)
Try whether the data at the given address look like a ISO 9660 image header and obtain its alleged si...
Definition: burn_wrap.c:1301
int isoburn_disc_track_lba_nwa(struct burn_drive *d, struct burn_write_opts *opts, int trackno, int *lba, int *nwa)
Use this with trackno==0 to obtain the predicted start block number of the new session.
Definition: burn_wrap.c:831
int Xorriso_get_profile(struct XorrisO *xorriso, int *profile_number, char profile_name[80], int flag)
Definition: drive_mgt.c:2236
void * pacifier_fifo
int Xorriso_check_multi(struct XorrisO *xorriso, struct burn_drive *drive, int flag)
Definition: write_run.c:69
#define O_BINARY
Definition: write_run.c:39
int Xorriso_make_write_options(struct XorrisO *xorriso, struct burn_drive *drive, struct burn_write_opts **burn_options, int flag)
Definition: write_run.c:137
int Xorriso_pacifier_loop(struct XorrisO *xorriso, struct burn_drive *drive, int flag)
Definition: write_run.c:1553
int Xorriso_sanitize_image_size(struct XorrisO *xorriso, struct burn_drive *drive, struct burn_disc *disc, struct burn_write_opts *burn_options, int flag)
Definition: write_run.c:198
int Xorriso_update_iso_lba0(struct XorrisO *xorriso, int iso_lba, int isosize, char *head_buffer, struct CheckmediajoB *job, int flag)
Definition: write_run.c:3026
int Xorriso_auto_format(struct XorrisO *xorriso, int flag)
Definition: write_run.c:311

References XorrisO::auto_close, XorrisO::do_close, XorrisO::do_tao, XorrisO::fs, XorrisO::info_text, isoburn_disc_get_status(), isoburn_disc_track_lba_nwa(), isoburn_needs_emulation(), isoburn_read_iso_head(), O_BINARY, XorrisO::outdev, XorrisO::pacifier_fifo, XorrisO::run_state, Text_shellsafe(), Xorriso_abort(), Xorriso_alloc_meM, Xorriso_auto_format(), Xorriso_check_multi(), Xorriso_free_meM, Xorriso_get_drive_handles(), Xorriso_get_profile(), Xorriso_info(), Xorriso_make_write_options(), Xorriso_may_burn(), Xorriso_msgs_submit(), Xorriso_pacifier_loop(), Xorriso_process_msg_queues(), Xorriso_sanitize_image_size(), Xorriso_set_signal_handling(), and Xorriso_update_iso_lba0().

Referenced by Xorriso_cdrskin(), and Xorriso_retry_burn_track().

◆ Xorriso_check_md5()

int Xorriso_check_md5 ( struct XorrisO xorriso,
void *  in_node,
char *  path,
int  flag 
)

Definition at line 2595 of file read_run.c.

2597 {
2598  int ret, wanted, rret, buffer_size= 64 * 1024;
2599  IsoImage *image;
2600  IsoNode *node;
2601  IsoFile *file;
2602  char node_md5[16], data_md5[16], *buffer= NULL;
2603  void *stream= NULL, *ctx= NULL;
2604  off_t todo;
2605 
2606  Xorriso_alloc_meM(buffer, char, 64 * 1024);
2607 
2608  node= (IsoNode *) in_node;
2609  if(node == NULL) {
2610  ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0);
2611  if(ret<=0)
2612  {ret= -1; goto ex;}
2613  }
2614  if(!LIBISO_ISREG(node)) {
2615  strcpy(xorriso->info_text, "-check_md5: Not a data file: ");
2616  Text_shellsafe(path, xorriso->info_text, 1);
2617  if(!(flag & 2))
2618  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
2619  ret= 3; goto ex;
2620  }
2621  file= (IsoFile *) node;
2622 
2623  /* obtain MD5 */
2624  ret= Xorriso_get_volume(xorriso, &image, 0);
2625  if(ret <= 0)
2626  {ret= -1; goto ex;}
2627  ret= iso_file_get_md5(image, file, node_md5, 0);
2628  Xorriso_process_msg_queues(xorriso,0);
2629  if(ret < 0)
2630  {ret= -1; goto ex;}
2631  if(ret == 0) {
2632  strcpy(xorriso->info_text, "-check_md5: No MD5 recorded with file: ");
2633  Text_shellsafe(path, xorriso->info_text, 1);
2634  if(!(flag & 2))
2635  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
2636  ret= 2; goto ex;
2637  }
2638 
2639  /* Read file and compute MD5 */;
2640  ret= Xorriso_iso_file_open(xorriso, path, (void *) node, &stream, 1 | 2);
2641  if(ret <= 0)
2642  {ret= -1; goto ex;}
2643  ret= iso_md5_start(&ctx);
2644  if(ret < 0)
2645  goto ex;
2646  todo= iso_stream_get_size(stream);
2647  while(todo > 0) {
2648  if(todo < buffer_size)
2649  wanted= todo;
2650  else
2651  wanted= buffer_size;
2652  rret = Xorriso_iso_file_read(xorriso, stream, buffer, wanted, 0);
2653  if(rret <= 0)
2654  {ret= -1; goto ex;}
2655  todo-= rret;
2656  ret = iso_md5_compute(ctx, buffer, rret);
2657  if(ret < 0)
2658  goto ex;
2659  xorriso->pacifier_count+= rret;
2660  xorriso->pacifier_byte_count+= rret;
2661  Xorriso_pacifier_callback(xorriso, "content bytes read",
2662  xorriso->pacifier_count, 0, "", 8);
2664  xorriso,
2665  xorriso->check_media_default != NULL
2667  : "/var/opt/xorriso/do_abort_check_media",
2668  Sfile_microtime(0), &xorriso->last_abort_file_time, 0);
2669  if(ret == 1)
2670  {ret= -2; goto ex;}
2671  }
2672  ret= iso_md5_end(&ctx, data_md5);
2673  if(ret < 0)
2674  goto ex;
2675 
2676  /* Report outcome */
2677  Xorriso_process_msg_queues(xorriso,0);
2678  if(! iso_md5_match(node_md5, data_md5)) {
2679  sprintf(xorriso->result_line, "MD5 MISMATCH: ");
2680  Text_shellsafe(path, xorriso->result_line, 1);
2681  strcat(xorriso->result_line, "\n");
2682  if(!(flag & 1))
2683  Xorriso_result(xorriso,0);
2684  ret= 0;
2685  } else {
2686  sprintf(xorriso->result_line, "md5 match : ");
2687  Text_shellsafe(path, xorriso->result_line, 1);
2688  strcat(xorriso->result_line, "\n");
2689  if(flag & 4)
2690  Xorriso_result(xorriso,0);
2691  ret= 1;
2692  }
2693 
2694 ex:;
2695  Xorriso_process_msg_queues(xorriso,0);
2696  Xorriso_iso_file_close(xorriso, &stream, 0);
2697  if(ctx != NULL)
2698  iso_md5_end(&ctx, data_md5);
2699  Xorriso_free_meM(buffer);
2700  if(ret < 0) {
2701  if(ret == -2)
2702  sprintf(xorriso->result_line, "Aborted at: ");
2703  else
2704  sprintf(xorriso->result_line, "NOT READABLE: ");
2705  Text_shellsafe(path, xorriso->result_line, 1);
2706  strcat(xorriso->result_line, "\n");
2707  if(!(flag & 1))
2708  Xorriso_result(xorriso,0);
2709  if(ret == -2)
2710  xorriso->request_to_abort= 1;
2711  }
2712  return(ret);
2713 }
int Xorriso_check_for_abort(struct XorrisO *xorriso, char *abort_file_path, double post_read_time, double *last_abort_file_time, int flag)
Definition: drive_mgt.c:2466
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_iso_file_open(struct XorrisO *xorriso, char *pathname, void *node_pt, void **stream, int flag)
Definition: read_run.c:66
int Xorriso_iso_file_close(struct XorrisO *xorriso, void **stream, int flag)
Definition: read_run.c:169
int Xorriso_iso_file_read(struct XorrisO *xorriso, void *stream, char *buf, int count, int flag)
Definition: read_run.c:145
double Sfile_microtime(int flag)
Return a double representing seconds and microseconds since 1 Jan 1970.
Definition: sfile.c:883
char abort_file_path[SfileadrL]
Definition: check_media.h:115
off_t pacifier_byte_count
int request_to_abort
struct CheckmediajoB * check_media_default
double last_abort_file_time

References CheckmediajoB::abort_file_path, XorrisO::check_media_default, XorrisO::info_text, XorrisO::last_abort_file_time, LIBISO_ISREG, XorrisO::pacifier_byte_count, XorrisO::pacifier_count, XorrisO::request_to_abort, XorrisO::result_line, Sfile_microtime(), Text_shellsafe(), Xorriso_alloc_meM, Xorriso_check_for_abort(), Xorriso_free_meM, Xorriso_get_node_by_path(), Xorriso_get_volume(), Xorriso_iso_file_close(), Xorriso_iso_file_open(), Xorriso_iso_file_read(), Xorriso_msgs_submit(), Xorriso_pacifier_callback(), Xorriso_process_msg_queues(), and Xorriso_result().

Referenced by Xorriso_findi_action(), and Xorriso_option_check_md5().

◆ Xorriso_check_media()

int Xorriso_check_media ( struct XorrisO xorriso,
struct SpotlisT **  spotlist,
struct CheckmediajoB job,
int  flag 
)

Definition at line 3213 of file drive_mgt.c.

3215 {
3216  int media_blocks= 0, read_chunk= 32, ret, mode, start_lba= 0;
3217  int blocks, os_errno, i, j, last_track_end= -1, track_blocks, track_lba;
3218  int num_sessions, num_tracks, declare_untested= 0, md5_start;
3219  int read_capacity= -1, end_lba, hret, count, quality, profile_no;
3220  int track_bad_claim= 0;
3221  char *toc_info= NULL, profile_name[80], msg[160];
3222  struct burn_drive *drive;
3223  struct burn_drive_info *dinfo;
3224  enum burn_disc_status s;
3225  struct isoburn_toc_disc *isoburn_disc= NULL;
3226  struct isoburn_toc_session **isoburn_sessions;
3227  struct isoburn_toc_track **iso_burn_tracks;
3228  struct burn_toc_entry isoburn_entry;
3229  struct stat stbuf;
3230  struct burn_multi_caps *caps= NULL;
3231 
3232  *spotlist= NULL;
3233 
3234  ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
3235  "on attempt to check media readability",
3236  2 * !!job->use_dev);
3237  if(ret<=0)
3238  goto ex;
3239 
3240  ret = burn_disc_get_profile(drive, &profile_no, profile_name);
3241  if(ret <= 0)
3242  profile_no= 0;
3243 
3244  if(job->min_block_size != 0)
3245  read_chunk= job->min_block_size;
3246 
3247  ret= Spotlist_new(spotlist, 0);
3248  if(ret <= 0)
3249  {ret= -1; goto ex;}
3250 
3251  if(job->sector_map_path[0]) {
3252  Sectorbitmap_destroy(&(job->sector_map), 0);
3253  if(stat(job->sector_map_path, &stbuf) != -1) {
3255  xorriso->info_text, &os_errno, 0);
3256  if(ret <= 0) {
3257  if(xorriso->info_text[0])
3258  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, os_errno,
3259  "FAILURE", 0);
3260  goto ex;
3261  }
3262  }
3263  Xorriso_toc_to_string(xorriso, &toc_info,
3264  (2 * !!job->use_dev) | (4 * !job->map_with_volid));
3265  }
3266  ret= Xorriso_open_job_data_to(xorriso, job, 0);
3267  if(ret <= 0)
3268  goto ex;
3269  Xorriso_pacifier_reset(xorriso, 0);
3270  job->start_time= time(NULL);
3271  mode= job->mode;
3272  if(job->min_lba > 0) {
3273  start_lba= job->min_lba;
3274  ret= Spotlist_add_item(*spotlist, 0, job->min_lba,
3276  if(ret <= 0)
3277  goto ex;
3278  }
3279 
3280  s= isoburn_disc_get_status(drive);
3281  if(s != BURN_DISC_APPENDABLE && s != BURN_DISC_FULL) {
3282  Xorriso_msgs_submit(xorriso, 0, "-check_media: No readable medium found",
3283  0, "SORRY", 0);
3284  ret= 0; goto ex;
3285  }
3286 
3287  ret= burn_get_read_capacity(drive, &read_capacity, 0);
3288  if(ret <= 0)
3289  read_capacity= -1;
3290 
3291  if(job->max_lba >= 0) {
3292  blocks= job->max_lba + 1 - start_lba;
3293  xorriso->pacifier_total= blocks;
3294  ret= Xorriso_check_interval(xorriso, *spotlist, job, start_lba, blocks,
3295  read_chunk, 0, 0);
3296  if(ret <= 0)
3297  goto ex;
3298 
3299  } else if(mode == 0) { /* track by track */
3300  isoburn_disc= isoburn_toc_drive_get_disc(drive);
3301  if(isoburn_disc == NULL)
3302  goto libburn_whole_disc;
3303  isoburn_sessions=
3304  isoburn_toc_disc_get_sessions(isoburn_disc, &num_sessions);
3305  for(i= 0; i < num_sessions; i++) {
3306  iso_burn_tracks= isoburn_toc_session_get_tracks(isoburn_sessions[i],
3307  &num_tracks);
3308  for(j= 0; j < num_tracks; j++) {
3309  isoburn_toc_track_get_entry(iso_burn_tracks[j], &isoburn_entry);
3310  if(!(isoburn_entry.extensions_valid & 1)) /* should not happen */
3311  continue;
3312  track_lba= isoburn_entry.start_lba;
3313  track_blocks= isoburn_entry.track_blocks;
3314 
3315  /* The last track of an appendable BD-R reports more blocks than the
3316  read capacity allows. All BD-R track sizes are multiple of 64 kB.
3317  */
3318  if (i == num_sessions - 1 &&
3319  (track_lba + track_blocks > read_capacity &&
3320  track_lba + track_blocks < read_capacity + 32 &&
3321  (profile_no == 0x41 || profile_no == 0x40)))
3322  track_blocks= read_capacity - track_lba;
3323  if(track_lba + track_blocks > read_capacity) {
3324  if(track_bad_claim < track_lba + track_blocks)
3325  track_bad_claim= track_lba + track_blocks;
3326  if(track_lba >= read_capacity) {
3327  sprintf(msg, "-check_media: Track %d of session %d begins after end of readable medium area.",
3328  j + 1, i + 1);
3329  Xorriso_msgs_submit(xorriso, 0, msg, 0, "WARNING", 0);
3330  continue;
3331  } else {
3332 
3333  if(profile_no >= 0x08 && profile_no <= 0x0a &&
3334  track_lba + track_blocks == read_capacity + 2 &&
3335  i == num_sessions - 1 && j == num_tracks - 1) {
3336  sprintf(msg, "-check_media: Last CD track exceeds readable area by 2 blocks. Assuming TAO.");
3337  Xorriso_msgs_submit(xorriso, 0, msg, 0, "DEBUG", 0);
3338  } else {
3339  sprintf(msg, "-check_media: Track %d of session %d extends over the end of readable medium area.",
3340  j + 1, i + 1);
3341  Xorriso_msgs_submit(xorriso, 0, msg, 0, "WARNING", 0);
3342  }
3343  track_blocks= read_capacity - track_lba;
3344  }
3345  }
3346  md5_start= track_lba;
3347  if(i == 0 && j == 0) {
3348  if(track_lba == 32) {
3349  ret= burn_disc_get_multi_caps(drive, BURN_WRITE_NONE, &caps, 0);
3350  if(ret > 0) {
3351  if(caps->start_adr) {
3352  /* block 0 to 31 are the overall mount entry of overwritable */
3353  track_lba= 0;
3354  track_blocks+= 32;
3355  }
3356  }
3357  }
3358  }
3359  if(last_track_end >= 0 && last_track_end < track_lba &&
3360  last_track_end >= start_lba) {
3361  ret= Spotlist_add_item(*spotlist, last_track_end,
3362  track_lba - last_track_end,
3364  if(ret <= 0)
3365  goto ex;
3366  }
3367  last_track_end= track_lba + track_blocks;
3368 
3369  if(track_lba < start_lba) {
3370  track_blocks-= start_lba - track_lba;
3371  track_lba= start_lba;
3372  }
3373  if(track_blocks <= 0)
3374  continue;
3375  if(declare_untested) {
3376  ret= Spotlist_add_item(*spotlist, track_lba, track_blocks,
3378  if(ret <= 0)
3379  goto ex;
3380  } else {
3381  ret= Xorriso_check_interval(xorriso, *spotlist, job, track_lba,
3382  track_blocks, read_chunk, md5_start,
3383  (i > 0) | (4 * (xorriso->do_md5 & 1)));
3384  if(ret <= 0)
3385  goto ex;
3386  if(ret == 2)
3387  declare_untested= 1;
3388  }
3389  }
3390  }
3391 
3392  if(track_bad_claim > read_capacity) {
3393  count= Spotlist_count(*spotlist, 0);
3394  Spotlist_get_item(*spotlist, count - 1, &track_lba, &blocks, &quality, 0);
3395  if(profile_no >= 0x08 && profile_no <= 0x0a &&
3396  track_bad_claim - read_capacity == 2 &&
3397  quality != Xorriso_read_quality_tao_enD)
3399  else
3401  ret= Spotlist_add_item(*spotlist, read_capacity,
3402  track_bad_claim - read_capacity, quality, 0);
3403  if(ret <= 0)
3404  goto ex;
3405  }
3406 
3407  } else if(mode == 1) { /* Image range */
3408  /* Default is the emulated disc capacity.
3409  */
3410  isoburn_disc= isoburn_toc_drive_get_disc(drive);
3411  if(isoburn_disc == NULL)
3412  goto libburn_whole_disc;
3413  blocks= media_blocks= isoburn_toc_disc_get_sectors(isoburn_disc);
3414 
3415  /* If possible, determine the end address of the loaded ISO image.
3416  */
3417  track_lba= isoburn_get_attached_start_lba(drive);
3418  if(track_lba >= 0) {
3419  ret= isoburn_read_iso_head(drive, track_lba, &track_blocks, NULL, 0);
3420  if(ret > 0) {
3421  blocks= media_blocks= track_lba + track_blocks;
3422  }
3423  }
3424 
3425  if(start_lba >= 0)
3426  blocks-= start_lba;
3427  if(media_blocks <= 0)
3428  goto libburn_whole_disc;
3429  xorriso->pacifier_total= blocks;
3430  ret= Xorriso_check_interval(xorriso, *spotlist, job, start_lba, blocks,
3431  read_chunk, 0, (4 * (xorriso->do_md5 & 1)));
3432  if(ret <= 0)
3433  goto ex;
3434  } else if(mode == 2) {
3435 libburn_whole_disc:;
3436  /* single sweep over libburn medium capacity */
3437  ret= burn_get_read_capacity(drive, &blocks, 0);
3438  if(ret <= 0) {
3439  Xorriso_process_msg_queues(xorriso,0);
3440  sprintf(xorriso->info_text, "No content detected on media");
3441  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
3442  {ret= 0; goto ex;}
3443  }
3444  blocks-= start_lba;
3445  xorriso->pacifier_total= blocks;
3446  ret= Xorriso_check_interval(xorriso, *spotlist, job, start_lba, blocks,
3447  read_chunk, 0, (4 * (xorriso->do_md5 & 1)));
3448  if(ret <= 0)
3449  goto ex;
3450  }
3451 
3452  Xorriso_pacifier_callback(xorriso, "blocks read",
3453  xorriso->pacifier_count, xorriso->pacifier_total, "",
3454  1 | 8 | 16 | 32 | (128 * (job->use_dev == 1)));
3455  ret= 1;
3456 ex:;
3457 
3458  if(job->data_to_fd != -1 && strcmp(job->data_to_path, "-") != 0)
3459  close(job->data_to_fd);
3460  job->data_to_fd= -1;
3461 
3462  if(read_capacity >= 0) {
3463  count= Spotlist_count(*spotlist, 0);
3464  end_lba= 0;
3465  for(i= 0; i < count; i++) {
3466  Spotlist_get_item(*spotlist, i, &start_lba, &blocks, &quality, 0);
3467  if(start_lba + blocks > end_lba)
3468  end_lba= start_lba + blocks;
3469  }
3470  if(read_capacity > end_lba) {
3471  hret= Spotlist_add_item(*spotlist, end_lba, read_capacity - end_lba,
3473  if(hret < ret)
3474  ret= hret;
3475  }
3476  }
3477 
3478  if(ret > 0)
3479  ret= Xorriso_update_in_sector_map(xorriso, *spotlist, read_chunk, job, 0);
3480 
3481  if(ret > 0) {
3482  ret= Xorriso_spotlist_to_sectormap(xorriso, *spotlist, read_chunk,
3483  &(job->sector_map), 2);
3484  if(ret > 0 && job->sector_map_path[0]) {
3485  ret= Sectorbitmap_to_file(job->sector_map, job->sector_map_path, toc_info,
3486  xorriso->info_text, &os_errno, 0);
3487  if(ret <= 0) {
3488  if(xorriso->info_text[0])
3489  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, os_errno,
3490  "FAILURE", 0);
3491  }
3492  }
3493  }
3494  if(toc_info != NULL)
3495  free(toc_info);
3496  if(ret <= 0)
3497  Spotlist_destroy(spotlist, 0);
3498  if(caps!=NULL)
3499  burn_disc_free_multi_caps(&caps);
3500  if(isoburn_disc != NULL)
3501  isoburn_toc_disc_free(isoburn_disc);
3502  return(ret);
3503 }
struct isoburn_toc_session ** isoburn_toc_disc_get_sessions(struct isoburn_toc_disc *disc, int *num)
Get the array of session handles and the number of complete sessions from the table of content.
Definition: burn_wrap.c:1774
struct isoburn_toc_track ** isoburn_toc_session_get_tracks(struct isoburn_toc_session *s, int *num)
Get the array of track handles from a particular session.
Definition: burn_wrap.c:1852
void isoburn_toc_track_get_entry(struct isoburn_toc_track *t, struct burn_toc_entry *entry)
Obtain a copy of the entry which describes a particular track.
Definition: burn_wrap.c:1860
int isoburn_toc_disc_get_sectors(struct isoburn_toc_disc *disc)
Tell the number of 2048 byte blocks covered by the table of content.
Definition: burn_wrap.c:1728
void isoburn_toc_disc_free(struct isoburn_toc_disc *d)
Release the memory associated with a master handle of a medium.
Definition: burn_wrap.c:1893
struct isoburn_toc_disc * isoburn_toc_drive_get_disc(struct burn_drive *d)
Obtain a master handle for the table of content.
Definition: burn_wrap.c:1631
int Xorriso_spotlist_to_sectormap(struct XorrisO *xorriso, struct SpotlisT *spotlist, int read_chunk, struct SectorbitmaP **map, int flag)
Definition: check_media.c:1006
int Spotlist_get_item(struct SpotlisT *o, int idx, int *start_lba, int *blocks, int *quality, int flag)
Definition: check_media.c:182
int Sectorbitmap_from_file(struct SectorbitmaP **o, char *path, char *msg, int *os_errno, int flag)
Definition: check_media.c:288
int Xorriso_update_in_sector_map(struct XorrisO *xorriso, struct SpotlisT *spotlist, int read_chunk, struct CheckmediajoB *job, int flag)
Definition: check_media.c:1104
int Xorriso_open_job_data_to(struct XorrisO *xorriso, struct CheckmediajoB *job, int flag)
Definition: check_media.c:1082
int Sectorbitmap_to_file(struct SectorbitmaP *o, char *path, char *info, char *msg, int *os_errno, int flag)
Definition: check_media.c:375
int Spotlist_add_item(struct SpotlisT *o, int start_lba, int blocks, int quality, int flag)
Definition: check_media.c:120
int Spotlist_destroy(struct SpotlisT **o, int flag)
Definition: check_media.c:102
int Spotlist_count(struct SpotlisT *o, int flag)
Definition: check_media.c:147
int Spotlist_new(struct SpotlisT **o, int flag)
Definition: check_media.c:85
#define Xorriso_read_quality_off_tracK
Definition: check_media.h:91
#define Xorriso_read_quality_tao_enD
Definition: check_media.h:90
#define Xorriso_read_quality_unreadablE
Definition: check_media.h:92
#define Xorriso_read_quality_untesteD
Definition: check_media.h:87
int Xorriso_check_interval(struct XorrisO *xorriso, struct SpotlisT *spotlist, struct CheckmediajoB *job, int from_lba, int block_count, int read_chunk, int md5_start, int flag)
Definition: drive_mgt.c:2807
int Xorriso_toc_to_string(struct XorrisO *xorriso, char **toc_text, int flag)
Definition: drive_mgt.c:870
struct SectorbitmaP * sector_map
Definition: check_media.h:126
char data_to_path[SfileadrL]
Definition: check_media.h:117
char sector_map_path[SfileadrL]
Definition: check_media.h:125
time_t start_time
Definition: check_media.h:110
off_t pacifier_total

References CheckmediajoB::data_to_fd, CheckmediajoB::data_to_path, XorrisO::do_md5, XorrisO::info_text, isoburn_disc_get_status(), isoburn_get_attached_start_lba(), isoburn_read_iso_head(), isoburn_toc_disc_free(), isoburn_toc_disc_get_sectors(), isoburn_toc_disc_get_sessions(), isoburn_toc_drive_get_disc(), isoburn_toc_session_get_tracks(), isoburn_toc_track_get_entry(), CheckmediajoB::map_with_volid, CheckmediajoB::max_lba, xorriso_md5_state::md5_start, CheckmediajoB::min_block_size, CheckmediajoB::min_lba, CheckmediajoB::mode, XorrisO::pacifier_count, XorrisO::pacifier_total, CheckmediajoB::sector_map, CheckmediajoB::sector_map_path, Sectorbitmap_destroy(), Sectorbitmap_from_file(), Sectorbitmap_to_file(), Spotlist_add_item(), Spotlist_count(), Spotlist_destroy(), Spotlist_get_item(), Spotlist_new(), CheckmediajoB::start_time, CheckmediajoB::use_dev, Xorriso_check_interval(), Xorriso_get_drive_handles(), Xorriso_msgs_submit(), Xorriso_open_job_data_to(), Xorriso_pacifier_callback(), Xorriso_pacifier_reset(), Xorriso_process_msg_queues(), Xorriso_read_quality_off_tracK, Xorriso_read_quality_tao_enD, Xorriso_read_quality_unreadablE, Xorriso_read_quality_untesteD, Xorriso_spotlist_to_sectormap(), Xorriso_toc_to_string(), and Xorriso_update_in_sector_map().

Referenced by Xorriso_option_check_media().

◆ Xorriso_check_session_md5()

int Xorriso_check_session_md5 ( struct XorrisO xorriso,
char *  severity,
int  flag 
)

Definition at line 2430 of file drive_mgt.c.

2432 {
2433  int ret, i;
2434  IsoImage *image;
2435  uint32_t start_lba, end_lba;
2436  char md5[16], md5_text[33];
2437 
2438  ret= Xorriso_get_volume(xorriso, &image, 0);
2439  if(ret<=0)
2440  return(ret);
2441  ret= iso_image_get_session_md5(image, &start_lba, &end_lba, md5, 0);
2442  Xorriso_process_msg_queues(xorriso,0);
2443  if(ret < 0)
2444  return(ret);
2445  if(ret == 0) {
2446  sprintf(xorriso->info_text,
2447  "No session MD5 is recorded with the loaded session");
2448  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
2449  return(0);
2450  }
2451 
2452  sprintf(xorriso->info_text, "Checking loaded session by its recorded MD5.\n");
2453  Xorriso_info(xorriso, 0);
2454  for(i= 0; i < 16; i++)
2455  sprintf(md5_text + 2 * i, "%2.2x", ((unsigned char *) md5)[i]);
2456  sprintf(xorriso->result_line,
2457  "Session MD5 %s , LBA %.f , %.f blocks\n",
2458  md5_text, (double) start_lba, (double) end_lba - start_lba);
2459  Xorriso_result(xorriso,0);
2460  ret= Xorriso_check_md5_range(xorriso, (off_t) start_lba, (off_t) end_lba,
2461  md5, 0);
2462  return(ret);
2463 }
int Xorriso_check_md5_range(struct XorrisO *xorriso, off_t start_lba, off_t end_lba, char md5[16], int flag)
Definition: drive_mgt.c:2366

References XorrisO::info_text, XorrisO::result_line, Xorriso_check_md5_range(), Xorriso_get_volume(), Xorriso_info(), Xorriso_msgs_submit(), Xorriso_process_msg_queues(), and Xorriso_result().

Referenced by Xorriso_option_check_md5().

◆ Xorriso_clone_tree()

int Xorriso_clone_tree ( struct XorrisO xorriso,
void *  boss_iter,
char *  origin,
char *  dest,
int  flag 
)

Definition at line 1808 of file iso_manip.c.

1810 {
1811  int ret, dest_ret, l;
1812  char *eff_dest= NULL, *eff_origin= NULL, *dir_adr= NULL;
1813  char *leafname;
1814  IsoImage *volume;
1815  IsoDir *new_parent;
1816  IsoNode *origin_node, *dir_node, *new_node;
1817 
1818  Xorriso_alloc_meM(eff_dest, char, SfileadrL);
1819  Xorriso_alloc_meM(eff_origin, char, SfileadrL);
1820  Xorriso_alloc_meM(dir_adr, char, SfileadrL);
1821 
1822  ret= Xorriso_get_volume(xorriso, &volume, 0);
1823  if(ret <= 0)
1824  goto ex;
1825 
1826  ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, origin, eff_origin, 0);
1827  if(ret<=0)
1828  goto ex;
1829  ret= Xorriso_node_from_path(xorriso, volume, eff_origin, &origin_node, 0);
1830  if(ret <= 0)
1831  goto ex;
1832 
1833  dest_ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, dest, eff_dest,1);
1834  if(dest_ret<0)
1835  {ret= dest_ret; goto ex;}
1836  if(dest_ret > 0) {
1837  if(eff_dest[0] == 0)
1838  strcpy(eff_dest, "/");
1839  sprintf(xorriso->info_text,
1840  "Cloning: Copy address already exists: ");
1841  Text_shellsafe(eff_dest, xorriso->info_text, 1);
1842  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
1843  {ret= 0; goto ex;}
1844  } else {
1845  /* obtain eff_dest address despite it does not exist */
1846  ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, dest, eff_dest, 2);
1847  if(ret<=0)
1848  goto ex;
1849  }
1850 
1851  /* Obtain parent path and leaf name */
1852  strcpy(dir_adr, eff_dest);
1853  for(l= strlen(dir_adr); l > 0; ) {
1854  if(dir_adr[l - 1] == '/')
1855  dir_adr[--l]= 0;
1856  else
1857  break;
1858  }
1859  leafname= strrchr(dir_adr, '/');
1860  if(leafname == NULL) {
1861  leafname= dir_adr;
1862  if (leafname[0] == 0) {
1863  Xorriso_msgs_submit(xorriso, 0, "Empty file name as clone destination",
1864  0, "FAILURE", 0);
1865  {ret= 0; goto ex;}
1866  }
1867  } else {
1868  *leafname= 0;
1869  leafname++;
1870  if(dir_adr[0] != 0) {
1871  /* Ensure existence of destination directory */
1872  ret= Xorriso_graft_in(xorriso, boss_iter, NULL, dir_adr,
1873  (off_t) 0, (off_t) 0, 1);
1874  if(ret <= 0)
1875  goto ex;
1876  }
1877  }
1878 
1879  ret= Xorriso_node_from_path(xorriso, volume, dir_adr, &dir_node, 0);
1880  if(ret <= 0)
1881  goto ex;
1882  new_parent= (IsoDir *) dir_node;
1883 
1884  ret = iso_image_tree_clone(volume, origin_node, new_parent, leafname,
1885  &new_node, (flag & 1) | 2);
1886  Xorriso_process_msg_queues(xorriso,0);
1887  if(ret < 0) {
1888  Xorriso_cannot_clone(xorriso, eff_origin, eff_dest, ret, 0);
1889  {ret= 0; goto ex;}
1890  }
1891  Xorriso_set_change_pending(xorriso, 0);
1892  if(!(flag & 2)) {
1893  strcpy(xorriso->info_text, "Cloned in ISO image: ");
1894  Text_shellsafe(eff_origin, xorriso->info_text, 1);
1895  strcat(xorriso->info_text, " to ");
1896  Text_shellsafe(eff_dest, xorriso->info_text, 1 | 2);
1897  strcat(xorriso->info_text, "\n");
1898  Xorriso_info(xorriso, 0);
1899  }
1900  ret= 1;
1901 ex:;
1902  Xorriso_free_meM(eff_dest);
1903  Xorriso_free_meM(eff_origin);
1904  Xorriso_free_meM(dir_adr);
1905  return(ret);
1906 }
int Xorriso_set_change_pending(struct XorrisO *xorriso, int flag)
Definition: iso_img.c:1004
int Xorriso_cannot_clone(struct XorrisO *xorriso, char *eff_origin, char *eff_dest, int iso_error, int flag)
Definition: iso_manip.c:1793
int Xorriso_graft_in(struct XorrisO *xorriso, void *boss_iter, char *disk_path, char *img_path, off_t offset, off_t cut_size, int flag)
Definition: iso_manip.c:789
int Xorriso_normalize_img_path(struct XorrisO *xorriso, char *wd, char *img_path, char eff_path[], int flag)
Definition: iso_tree.c:55
char wdi[4096]

References XorrisO::info_text, SfileadrL, Text_shellsafe(), XorrisO::wdi, Xorriso_alloc_meM, Xorriso_cannot_clone(), Xorriso_free_meM, Xorriso_get_volume(), Xorriso_graft_in(), Xorriso_info(), Xorriso_msgs_submit(), Xorriso_node_from_path(), Xorriso_normalize_img_path(), Xorriso_process_msg_queues(), and Xorriso_set_change_pending().

Referenced by Xorriso_option_clone(), and Xorriso_option_cp_clone().

◆ Xorriso_clone_under()

int Xorriso_clone_under ( struct XorrisO xorriso,
char *  origin,
char *  dest,
int  flag 
)

Definition at line 1909 of file iso_manip.c.

1911 {
1912  int ret, pass;
1913  char *eff_dest= NULL, *eff_origin= NULL, *namept;
1914  IsoDir *origin_dir, *dest_dir;
1915  IsoDirIter *iter= NULL;
1916  IsoNode *origin_node, *new_node;
1917  IsoImage *volume;
1918 
1919  Xorriso_alloc_meM(eff_dest, char, SfileadrL);
1920  Xorriso_alloc_meM(eff_origin, char, SfileadrL);
1921 
1922  ret= Xorriso_get_volume(xorriso, &volume, 0);
1923  if(ret <= 0)
1924  goto ex;
1925  ret= Xorriso_dir_from_path(xorriso, "Copy source", origin, &origin_dir, 0);
1926  if(ret <= 0)
1927  goto ex;
1928  ret= Xorriso_dir_from_path(xorriso, "Copy destination", dest, &dest_dir, 0);
1929  if(ret <= 0)
1930  goto ex;
1931 
1932  for(pass= 0; pass < 2; pass++) {
1933  ret= iso_dir_get_children(origin_dir, &iter);
1934  if(ret < 0) {
1935  Xorriso_cannot_create_iter(xorriso, ret, 0);
1936  {ret= -1; goto ex;}
1937  }
1938  Xorriso_process_msg_queues(xorriso,0);
1939 
1940  while(iso_dir_iter_next(iter, &origin_node) == 1) {
1941  namept= (char *) iso_node_get_name(origin_node);
1942  sprintf(eff_origin, "%s/%s", origin, namept);
1943  sprintf(eff_dest, "%s/%s", dest, namept);
1944  if(pass == 0) {
1945  ret= Xorriso_node_from_path(xorriso, volume, eff_dest, &new_node, 1);
1946  if(ret < 0)
1947  goto ex;
1948  if(ret > 0) {
1949  sprintf(xorriso->info_text, "Cloning: Copy address already exists: ");
1950  Text_shellsafe(eff_dest, xorriso->info_text, 1);
1951  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
1952  ret= 0; goto ex;
1953  }
1954  } else {
1955  ret = iso_image_tree_clone(volume, origin_node, dest_dir, namept,
1956  &new_node, 1 | 2);
1957  Xorriso_process_msg_queues(xorriso,0);
1958  if(ret < 0) {
1959  Xorriso_cannot_clone(xorriso, eff_origin, eff_dest, ret, 0);
1960  ret= 0; goto ex;
1961  }
1962  }
1963  }
1964  iso_dir_iter_free(iter);
1965  iter= NULL;
1966  }
1967  Xorriso_set_change_pending(xorriso, 0);
1968  ret= 1;
1969 ex:;
1970  if(iter != NULL)
1971  iso_dir_iter_free(iter);
1972  Xorriso_free_meM(eff_dest);
1973  Xorriso_free_meM(eff_origin);
1974  Xorriso_process_msg_queues(xorriso,0);
1975  return(ret);
1976 }
int Xorriso_cannot_create_iter(struct XorrisO *xorriso, int iso_error, int flag)
Definition: iso_manip.c:2509
int Xorriso_dir_from_path(struct XorrisO *xorriso, char *purpose, char *path, IsoDir **dir_node, int flag)
Definition: iso_tree.c:2687

References XorrisO::info_text, SfileadrL, Text_shellsafe(), Xorriso_alloc_meM, Xorriso_cannot_clone(), Xorriso_cannot_create_iter(), Xorriso_dir_from_path(), Xorriso_free_meM, Xorriso_get_volume(), Xorriso_msgs_submit(), Xorriso_node_from_path(), Xorriso_process_msg_queues(), and Xorriso_set_change_pending().

Referenced by Xorriso_genisofs().

◆ Xorriso_close_damaged()

int Xorriso_close_damaged ( struct XorrisO xorriso,
int  flag 
)

Definition at line 3724 of file write_run.c.

3725 {
3726  int ret;
3727  struct burn_drive_info *dinfo;
3728  struct burn_drive *drive;
3729  struct burn_write_opts *burn_options= NULL;
3730 
3731  if(Xorriso_change_is_pending(xorriso, 0)) {
3732  sprintf(xorriso->info_text,
3733  "Image changes pending. -commit or -rollback first");
3734  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
3735  ret= 0; goto ex;
3736  }
3737  ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
3738  "on attempt to close damaged session", 2);
3739  if(ret<=0)
3740  goto ex;
3741  ret= Xorriso_check_multi(xorriso, drive, 0);
3742  if(ret<=0)
3743  goto ex;
3744  ret= Xorriso_make_write_options(xorriso, drive, &burn_options, 0);
3745  if(ret <= 0)
3746  goto ex;
3747  ret= burn_disc_close_damaged(burn_options, flag & 1);
3748  Xorriso_process_msg_queues(xorriso, 0);
3749  Xorriso_option_dev(xorriso, "", 3 | 4); /* Give up drives */
3750  if(ret <= 0)
3751  goto ex;
3752 
3753  ret= 1;
3754 ex:;
3755  Xorriso_process_msg_queues(xorriso, 0);
3756  if(burn_options != NULL)
3757  burn_write_opts_free(burn_options);
3758  return(ret);
3759 }
int Xorriso_change_is_pending(struct XorrisO *xorriso, int flag)
Definition: iso_img.c:995
int Xorriso_option_dev(struct XorrisO *xorriso, char *in_adr, int flag)
Definition: opts_d_h.c:72

References XorrisO::info_text, Xorriso_change_is_pending(), Xorriso_check_multi(), Xorriso_get_drive_handles(), Xorriso_make_write_options(), Xorriso_msgs_submit(), Xorriso_option_dev(), and Xorriso_process_msg_queues().

Referenced by Xorriso_option_close_damaged().

◆ Xorriso_coordinate_system_area()

int Xorriso_coordinate_system_area ( struct XorrisO xorriso,
int  sa_type,
int  options,
char *  cmd,
int  flag 
)

Definition at line 1357 of file iso_img.c.

1359 {
1360  int old_type, old_options, new_options;
1361  static char *type_names[7] = {
1362  "MBR", "MIPS Big Endian Volume Header", "MIPS Little Endian Boot Block",
1363  "SUN Disk Label", "HP-PA PALO v4", "HP-PA PALO v5",
1364  "DEC Alpha SRM Boot Block"};
1365  static int num_names = 7;
1366 
1367  old_type= (xorriso->system_area_options & 0xfc) >> 2;
1368  old_options= xorriso->system_area_options & 0x3c03;
1369  new_options= options & 0x3c03;
1370  if(((options & (1 << 14)) && (xorriso->system_area_options & 2)) ||
1371  ((options & 2) && (xorriso->system_area_options & (1 << 14))))
1372  goto reject;
1373  if(flag & 2)
1374  return(1);
1375  if((old_type != 0 || old_options != 0) &&
1376  (old_type != sa_type || (old_options != 0 && old_options != new_options))){
1377 reject:;
1378  sprintf(xorriso->info_text, "%s : First sector already occupied by %s",
1379  cmd, old_type < num_names ?
1380  type_names[old_type] : "other boot facility");
1381  if(old_type == 0 && (old_options & 2))
1382  strcat(xorriso->info_text, " for ISOLINUX isohybrid");
1383  else if (old_type == 0 && (xorriso->system_area_options & (1 << 14))) {
1384  strcat(xorriso->info_text, " for GRUB2 patching");
1385  if(old_type == 0 && (old_options & 1))
1386  strcat(xorriso->info_text, " with partition table");
1387  } else if(old_type == 0 && (old_options & 1))
1388  strcat(xorriso->info_text, " for partition table");
1389  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
1390  goto hint_revoke;
1391  }
1392  if(!(flag & 1))
1393  xorriso->system_area_options= (xorriso->system_area_options & ~0x3cff) |
1394  ((sa_type << 2) & 0xfc) | (options & 0x3c03);
1395  return(1);
1396 
1397 hint_revoke:;
1398  if(old_type == 0)
1399  sprintf(xorriso->info_text, "Revokable by -boot_image any discard");
1400  else if(old_type == 1 || old_type == 2)
1401  sprintf(xorriso->info_text, "Revokable by -boot_image any mips_discard");
1402  else if(old_type == 3)
1403  sprintf(xorriso->info_text, "Revokable by -boot_image any sparc_discard");
1404  if(old_type < 4)
1405  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0);
1406  return(0);
1407 }
int system_area_options

References XorrisO::info_text, XorrisO::system_area_options, and Xorriso_msgs_submit().

Referenced by Xorriso_genisofs(), and Xorriso_option_boot_image().

◆ Xorriso_copy_properties()

int Xorriso_copy_properties ( struct XorrisO xorriso,
char *  disk_path,
char *  img_path,
int  flag 
)

Definition at line 726 of file iso_manip.c.

728 {
729  int ret;
730  IsoNode *node;
731  struct stat stbuf;
732 
733  ret= Xorriso_get_node_by_path(xorriso, img_path, NULL, &node, 0);
734  if(ret<=0)
735  return(ret);
736  if(flag & 1) {
737  if(stat(disk_path, &stbuf)==-1)
738  return(0);
739  } else {
740  if(lstat(disk_path, &stbuf)==-1)
741  return(0);
742  }
743  Xorriso_transfer_properties(xorriso, &stbuf, disk_path, node,
744  ((flag & 2) >> 1) | ((flag & 1) << 5) | (flag & 4));
745  Xorriso_set_change_pending(xorriso, 0);
746  return(1);
747 }
int Xorriso_transfer_properties(struct XorrisO *xorriso, struct stat *stbuf, char *disk_path, IsoNode *node, int flag)
Definition: iso_manip.c:48

References Xorriso_get_node_by_path(), Xorriso_set_change_pending(), and Xorriso_transfer_properties().

Referenced by Xorriso_update_interpreter().

◆ Xorriso_create_empty_iso()

int Xorriso_create_empty_iso ( struct XorrisO xorriso,
int  flag 
)

Definition at line 68 of file iso_img.c.

69 {
70  int ret;
71  IsoImage *volset;
72  struct isoburn_read_opts *ropts;
73  struct burn_drive_info *dinfo= NULL;
74  struct burn_drive *drive= NULL;
75 
76  if(xorriso->out_drive_handle != NULL) {
77  ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
78  "on attempt to attach volset to drive", 2);
79  if(ret<=0)
80  return(ret);
81  }
82  if(xorriso->in_volset_handle!=NULL) {
83  iso_image_unref((IsoImage *) xorriso->in_volset_handle);
84  xorriso->in_volset_handle= NULL;
85  Sectorbitmap_destroy(&(xorriso->in_sector_map), 0);
86  Xorriso_destroy_di_array(xorriso, 0);
87  Xorriso_destroy_hln_array(xorriso, 0);
88  xorriso->loaded_volid[0]= 0;
89  xorriso->volset_change_pending= 0;
90  xorriso->boot_count= 0;
91  xorriso->no_volset_present= 0;
92  }
93 
94  ret= isoburn_ropt_new(&ropts, 0);
95  if(ret<=0)
96  return(ret);
97  /* Note: no return before isoburn_ropt_destroy() */
100  isoburn_ropt_set_data_cache(ropts, 1, 1, 0);
101  isoburn_set_read_pacifier(drive, NULL, NULL);
103 
104  ret= isoburn_read_image(drive, ropts, &volset);
105  Xorriso_process_msg_queues(xorriso,0);
106  isoburn_ropt_destroy(&ropts, 0);
107  if(ret<=0) {
108  sprintf(xorriso->info_text, "Failed to create new empty ISO image object");
109  Xorriso_report_iso_error(xorriso, "", ret, xorriso->info_text, 0, "FATAL",
110  0);
111  return(-1);
112  }
113  xorriso->in_volset_handle= (void *) volset;
114  xorriso->in_sector_map= NULL;
115  Xorriso_update_volid(xorriso, 0);
116  xorriso->volset_change_pending= 0;
117  xorriso->boot_count= 0;
118  xorriso->system_area_clear_loaded=
119  (strcmp(xorriso->system_area_disk_path, "/dev/zero") == 0);
120  xorriso->no_volset_present= 0;
121  return(1);
122 }
int isoburn_ropt_set_data_cache(struct isoburn_read_opts *o, int cache_tiles, int tile_blocks, int flag)
Sets the size and granularity of the cache which libisoburn provides to libisofs for reading of ISO i...
Definition: isoburn.c:896
#define isoburn_ropt_pretend_blank
Definition: libisoburn.h:930
int volset_change_pending
int no_volset_present

References XorrisO::boot_count, XorrisO::file_name_limit, XorrisO::in_charset, XorrisO::in_sector_map, XorrisO::in_volset_handle, XorrisO::info_text, isoburn_read_image(), isoburn_ropt_destroy(), isoburn_ropt_new(), isoburn_ropt_pretend_blank, isoburn_ropt_set_data_cache(), isoburn_ropt_set_extensions(), isoburn_ropt_set_input_charset(), isoburn_ropt_set_truncate_mode(), isoburn_set_read_pacifier(), XorrisO::loaded_volid, XorrisO::no_volset_present, XorrisO::out_drive_handle, Sectorbitmap_destroy(), XorrisO::system_area_clear_loaded, XorrisO::system_area_disk_path, XorrisO::volset_change_pending, Xorriso_destroy_di_array(), Xorriso_destroy_hln_array(), Xorriso_get_drive_handles(), Xorriso_process_msg_queues(), Xorriso_report_iso_error(), and Xorriso_update_volid().

Referenced by Xorriso_aquire_drive(), and Xorriso_give_up_drive().

◆ Xorriso_cut_out()

int Xorriso_cut_out ( struct XorrisO xorriso,
char *  disk_path,
off_t  startbyte,
off_t  bytecount,
char *  iso_rr_path,
int  flag 
)

Definition at line 1230 of file iso_manip.c.

1232 {
1233  int ret;
1234  char *eff_source= NULL, *eff_dest= NULL;
1235  struct stat stbuf;
1236 
1237  Xorriso_alloc_meM(eff_source, char, SfileadrL);
1238  Xorriso_alloc_meM(eff_dest, char, SfileadrL);
1239 
1240  ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, disk_path, eff_source,
1241  2|4);
1242  if(ret<=0)
1243  goto ex;
1244  ret= Xorriso_path_is_excluded(xorriso, disk_path, !(flag&1));
1245  if(ret!=0)
1246  {ret= 0; goto ex;}
1247 
1248  if(lstat(eff_source, &stbuf)==-1) {
1249  Xorriso_msgs_submit(xorriso, 0, eff_source, 0, "ERRFILE", 0);
1250  sprintf(xorriso->info_text, "-cut_out: Cannot determine type of ");
1251  Text_shellsafe(eff_source, xorriso->info_text, 1);
1252  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
1253  {ret= 0; goto ex;}
1254  }
1255 
1256  if((stbuf.st_mode&S_IFMT) == S_IFLNK) {
1257  if(!(xorriso->do_follow_links || (xorriso->do_follow_param && !(flag&1))))
1258  goto unsupported_type;
1259  if(stat(eff_source, &stbuf)==-1) {
1260  Xorriso_msgs_submit(xorriso, 0, eff_source, 0, "ERRFILE", 0);
1261  sprintf(xorriso->info_text,
1262  "-cut_out: Cannot determine link target type of ");
1263  Text_shellsafe(eff_source, xorriso->info_text, 1);
1264  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0);
1265  {ret= 0; goto ex;}
1266  }
1267  }
1268  if(S_ISREG(stbuf.st_mode)) {
1269  if(stbuf.st_size<startbyte) {
1270  Xorriso_msgs_submit(xorriso, 0, eff_source, 0, "ERRFILE", 0);
1271  sprintf(xorriso->info_text,
1272  "-cut_out: Byte offset %.f larger than file size %.f",
1273  (double) startbyte, (double) stbuf.st_size);
1274  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "SORRY", 0);
1275  {ret= 0; goto ex;}
1276  }
1277  } else {
1278 unsupported_type:;
1279  Xorriso_msgs_submit(xorriso, 0, eff_source, 0, "ERRFILE", 0);
1280  sprintf(xorriso->info_text, "-cut_out: Unsupported file type (%s) with ",
1281  Ftypetxt(stbuf.st_mode, 0));
1282  Text_shellsafe(eff_source, xorriso->info_text, 1);
1283  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
1284  {ret= 0; goto ex;}
1285  }
1286 
1287  ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, iso_rr_path, eff_dest,
1288  2);
1289  if(ret<=0)
1290  goto ex;
1291 
1292  ret= Xorriso_graft_in(xorriso, NULL, eff_source, eff_dest,
1293  startbyte, bytecount, 8);
1294 ex:;
1295  Xorriso_free_meM(eff_source);
1296  Xorriso_free_meM(eff_dest);
1297  return(ret);
1298 }
char * Ftypetxt(mode_t st_mode, int flag)
Definition: misc_funct.c:732
int Xorriso_path_is_excluded(struct XorrisO *xorriso, char *path, int flag)
Definition: parse_exec.c:3130
int do_follow_links
char wdx[4096]
int do_follow_param

References XorrisO::do_follow_links, XorrisO::do_follow_param, Ftypetxt(), XorrisO::info_text, SfileadrL, Text_shellsafe(), XorrisO::wdi, XorrisO::wdx, Xorriso_alloc_meM, Xorriso_free_meM, Xorriso_graft_in(), Xorriso_msgs_submit(), Xorriso_normalize_img_path(), and Xorriso_path_is_excluded().

Referenced by Xorriso_option_cut_out().

◆ Xorriso_destroy_all_extf()

int Xorriso_destroy_all_extf ( struct XorrisO xorriso,
int  flag 
)

Definition at line 158 of file filters.c.

159 {
160  struct Xorriso_extF *filter;
161  struct Xorriso_lsT *lst, *next_lst;
162 
163  for(lst= xorriso->filters; lst != NULL; lst= next_lst) {
164  filter= (struct Xorriso_extF *) Xorriso_lst_get_text(lst, 0);
165  Xorriso_lst_detach_text(lst, 0);
166  next_lst= Xorriso_lst_get_next(lst, 0);
167  Xorriso_lst_destroy(&lst, 0);
168  Xorriso_extf_destroy(xorriso, &filter, 0);
169  }
170  xorriso->filters= NULL;
171  return(1);
172 }
int Xorriso_lst_detach_text(struct Xorriso_lsT *entry, int flag)
Definition: aux_objects.c:642
struct Xorriso_lsT * Xorriso_lst_get_next(struct Xorriso_lsT *entry, int flag)
Obtain the address of the next item in the chain of messages.
Definition: aux_objects.c:624
char * Xorriso_lst_get_text(struct Xorriso_lsT *entry, int flag)
Obtain the text message from the current list item.
Definition: aux_objects.c:636
int Xorriso_lst_destroy(struct Xorriso_lsT **lstring, int flag)
Destroy a single list item and connect its eventual list neighbors.
Definition: aux_objects.c:571
int Xorriso_extf_destroy(struct XorrisO *xorriso, struct Xorriso_extF **filter, int flag)
Definition: filters.c:109
struct Xorriso_lsT * filters

References XorrisO::filters, Xorriso_extf_destroy(), Xorriso_lst_destroy(), Xorriso_lst_detach_text(), Xorriso_lst_get_next(), and Xorriso_lst_get_text().

Referenced by Xorriso_destroy().

◆ Xorriso_destroy_di_array()

int Xorriso_destroy_di_array ( struct XorrisO xorriso,
int  flag 
)

Definition at line 699 of file base_obj.c.

700 {
701  int i;
702 
703  if(xorriso->di_array != NULL) {
704  for(i= 0; i < xorriso->di_count; i++)
705  if(xorriso->di_array[i] != NULL)
706  iso_node_unref((IsoNode *) xorriso->di_array[i]);
707  free(xorriso->di_array);
708  xorriso->di_array= NULL;
709  }
710  if(xorriso->di_do_widen != NULL) {
711  free(xorriso->di_do_widen);
712  xorriso->di_do_widen= NULL;
713  }
714  Xorriso_lst_destroy_all(&(xorriso->di_disk_paths), 0);
715  Xorriso_lst_destroy_all(&(xorriso->di_iso_paths), 0);
716  xorriso->di_count= 0;
717 
718 #ifdef NIX
719  /* <<< */
720  fprintf(stderr, "xorriso_DEBUG: get_di_count= %lu\n",
721  Xorriso_get_di_counteR);
722 #endif /* NIX */
723 
724  return(1);
725 }
int Xorriso_lst_destroy_all(struct Xorriso_lsT **lstring, int flag)
Destroy all list items which are directly or indirectly connected to the given link item.
Definition: aux_objects.c:591
struct Xorriso_lsT * di_disk_paths
struct Xorriso_lsT * di_iso_paths
void ** di_array
char * di_do_widen

References XorrisO::di_array, XorrisO::di_count, XorrisO::di_disk_paths, XorrisO::di_do_widen, XorrisO::di_iso_paths, and Xorriso_lst_destroy_all().

Referenced by Xorriso_aquire_drive(), Xorriso_create_empty_iso(), Xorriso_destroy(), Xorriso_detach_libraries(), Xorriso_finish_hl_update(), and Xorriso_give_up_drive().

◆ Xorriso_destroy_hln_array()

int Xorriso_destroy_hln_array ( struct XorrisO xorriso,
int  flag 
)

Definition at line 675 of file base_obj.c.

676 {
677  int i;
678 
679 
680  if(xorriso->hln_array != NULL && !(flag & 1)) {
681  for(i= 0; i < xorriso->hln_count; i++)
682  iso_node_unref((IsoNode *) xorriso->hln_array[i]);
683  free(xorriso->hln_array);
684  xorriso->hln_array= NULL;
685  xorriso->hln_count= 0;
686  }
687  if(xorriso->hln_targets != NULL) {
688  for(i= 0; i < xorriso->hln_count; i++)
689  if(xorriso->hln_targets[i] != NULL)
690  free(xorriso->hln_targets[i]);
691  free(xorriso->hln_targets);
692  xorriso->hln_targets= NULL;
693  }
694  xorriso->node_targets_availmem= 0;
695  return(1);
696 }
void ** hln_array
void ** hln_targets
off_t node_targets_availmem

References XorrisO::hln_array, XorrisO::hln_count, XorrisO::hln_targets, and XorrisO::node_targets_availmem.

Referenced by Xorriso_aquire_drive(), Xorriso_create_empty_iso(), Xorriso_destroy(), Xorriso_detach_libraries(), Xorriso_give_up_drive(), Xorriso_make_hln_array(), Xorriso_new_hln_array(), and Xorriso_option_hardlinks().

◆ Xorriso_destroy_node_array()

int Xorriso_destroy_node_array ( struct XorrisO xorriso,
int  flag 
)

Definition at line 656 of file base_obj.c.

657 {
658  int i;
659 
660  if(xorriso->node_array != NULL) {
661  for(i= 0; i < xorriso->node_counter; i++)
662  iso_node_unref((IsoNode *) xorriso->node_array[i]);
663  free(xorriso->node_array);
664  }
665  xorriso->node_array= NULL;
666  xorriso->node_counter= xorriso->node_array_size= 0;
669  return(1);
670 }
struct Xorriso_lsT * node_img_prefixes
struct Xorriso_lsT * node_disk_prefixes
void ** node_array
int node_counter
int node_array_size

References XorrisO::node_array, XorrisO::node_array_size, XorrisO::node_counter, XorrisO::node_disk_prefixes, XorrisO::node_img_prefixes, and Xorriso_lst_destroy_all().

Referenced by Xorriso_all_node_array(), Xorriso_destroy(), Xorriso_findi_sorted(), Xorriso_option_extract(), Xorriso_option_map_l(), and Xorriso_restore_sorted().

◆ Xorriso_detach_libraries()

int Xorriso_detach_libraries ( struct XorrisO xorriso,
int  flag 
)

Definition at line 258 of file lib_mgt.c.

259 {
260  Xorriso_give_up_drive(xorriso, 3);
261  if(xorriso->in_volset_handle!=NULL) { /* standalone image */
262  iso_image_unref((IsoImage *) xorriso->in_volset_handle);
263  xorriso->in_volset_handle= NULL;
264  Sectorbitmap_destroy(&(xorriso->in_sector_map), 0);
265  Xorriso_destroy_di_array(xorriso, 0);
266  Xorriso_destroy_hln_array(xorriso, 0);
267  xorriso->boot_count= 0;
268  }
269  if(flag&1) {
270  if(xorriso->libs_are_started==0)
271  return(0);
272  isoburn_finish();
273 
274 #ifdef Xorriso_with_editlinE
275  Xorriso__shutdown_editline(0);
276 #endif
277 
278  }
279  return(1);
280 }
void isoburn_finish(void)
Shutdown all three libraries.
Definition: burn_wrap.c:1054
int libs_are_started

References XorrisO::boot_count, XorrisO::in_sector_map, XorrisO::in_volset_handle, isoburn_finish(), XorrisO::libs_are_started, Sectorbitmap_destroy(), Xorriso_destroy_di_array(), Xorriso_destroy_hln_array(), and Xorriso_give_up_drive().

Referenced by Xorriso_destroy().

◆ Xorriso_drive_snooze()

int Xorriso_drive_snooze ( struct XorrisO xorriso,
int  flag 
)

Definition at line 2329 of file drive_mgt.c.

2330 {
2331  int in_is_out_too, ret;
2332  struct burn_drive_info *dinfo;
2333  struct burn_drive *drive;
2334 
2335  in_is_out_too= (xorriso->in_drive_handle == xorriso->out_drive_handle);
2336  if((flag & 1) && xorriso->in_drive_handle != NULL) {
2337  Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
2338  "on attempt to calm drive", 0);
2339  burn_drive_snooze(drive, !!(flag & 4));
2340  if(in_is_out_too)
2341  {ret= 1; goto ex;}
2342  }
2343  if((flag&2) && xorriso->out_drive_handle!=NULL) {
2344  Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
2345  "on attempt to calm drive", 2);
2346  burn_drive_snooze(drive, !!(flag & 4));
2347  }
2348  ret= 1;
2349 ex:;
2350  Xorriso_process_msg_queues(xorriso,0);
2351  return(ret);
2352 }

References XorrisO::in_drive_handle, XorrisO::out_drive_handle, Xorriso_get_drive_handles(), and Xorriso_process_msg_queues().

Referenced by Xorriso_option_calm_drive().

◆ Xorriso_estimate_file_size()

int Xorriso_estimate_file_size ( struct XorrisO xorriso,
struct FindjoB job,
char *  basename,
mode_t  st_mode,
off_t  st_size,
int  flag 
)

Definition at line 2390 of file iso_manip.c.

2392 {
2393  off_t upper, lower, size;
2394 
2395  lower = 3 * strlen(basename) + 34; /* >>> + minimum RR ? */
2396  upper = 3 * strlen(basename) + 2048;
2397  if(S_ISREG(st_mode)) {
2398  size= ((st_size + (off_t) 2047) / (off_t) 2048) * (off_t) 2048;
2399  lower+= size;
2400  upper+= size;
2401  } else if(S_ISDIR(st_mode)) {
2402  upper+= 4096;
2403  }
2404  job->estim_upper_size+= upper;
2405  if(!(flag & 1))
2406  job->estim_lower_size+= lower;
2407  return(1);
2408 }
off_t estim_lower_size
Definition: findjob.h:204
off_t estim_upper_size
Definition: findjob.h:203

References FindjoB::estim_lower_size, and FindjoB::estim_upper_size.

Referenced by Xorriso_findi_action(), and Xorriso_findx_action().

◆ Xorriso_expand_pattern()

int Xorriso_expand_pattern ( struct XorrisO xorriso,
int  num_patterns,
char **  patterns,
int  extra_filec,
int *  filec,
char ***  filev,
off_t *  mem,
int  flag 
)

Definition at line 2091 of file iso_tree.c.

2094 {
2095  int ret, count= 0, abs_adr= 0, i, was_count, was_filec;
2096  int nonconst_mismatches= 0, dive_count= 0;
2097  IsoImage *volume;
2098  IsoDir *dir= NULL, *root_dir;
2099  IsoNode *iso_node;
2100 
2101  *filec= 0;
2102  *filev= NULL;
2103 
2104  xorriso->search_mode= 3;
2105  xorriso->structured_search= 1;
2106 
2107  ret= Xorriso_get_volume(xorriso, &volume, 0);
2108  if(ret<=0)
2109  return(ret);
2110  root_dir= iso_image_get_root(volume);
2111  if(root_dir==NULL) {
2112  Xorriso_process_msg_queues(xorriso,0);
2113  sprintf(xorriso->info_text,
2114  "While expanding pattern : Cannot obtain root node of ISO image");
2115  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
2116  ret= -1; goto ex;
2117  }
2118 
2119  for(i= 0; i<num_patterns; i++) {
2120  ret= Xorriso_prepare_expansion_pattern(xorriso, patterns[i], 0);
2121  if(ret<=0)
2122  return(ret);
2123  if(ret==2)
2124  abs_adr= 4;
2125  if(patterns[i][0]=='/' || abs_adr) {
2126  dir= root_dir;
2127  abs_adr= 4;
2128  } else {
2129  /* This is done so late to allow the following:
2130  It is not an error if xorriso->wdi does not exist yet, but one may
2131  not use it as base for relative address searches.
2132  */
2133  ret= Xorriso_node_from_path(xorriso, volume, xorriso->wdi, &iso_node, 1);
2134  dir= (IsoDir *) iso_node;
2135  if(ret<=0) {
2136  Xorriso_process_msg_queues(xorriso,0);
2137  sprintf(xorriso->info_text, "While expanding pattern ");
2138  Text_shellsafe(patterns[i], xorriso->info_text, 1);
2139  strcat(xorriso->info_text,
2140  " : Working directory does not exist in ISO image");
2141  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
2142  ret= 0; goto ex;
2143  }
2144  if(!LIBISO_ISDIR((IsoNode *) dir)) {
2145  sprintf(xorriso->info_text,
2146  "Working directory path does not lead to a directory in ISO image");
2147  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
2148  ret= 0; goto ex;
2149  }
2150  }
2151 
2152  /* count the matches */
2153  was_count= count;
2154  ret= Xorriso_obtain_pattern_files_i(xorriso, "", dir, &count, NULL, 0,
2155  mem, &dive_count, 1 | abs_adr);
2156  if(ret<=0)
2157  goto ex;
2158  if(was_count==count && strcmp(patterns[i],"*")!=0 && (flag&3)!=1 &&
2159  !(flag & 8)) {
2160  count++;
2161  Xorriso_eval_nonmatch(xorriso, patterns[i], &nonconst_mismatches, mem, 0);
2162  }
2163  }
2164 
2165  ret= Xorriso_check_matchcount(xorriso, count, nonconst_mismatches,
2166  num_patterns, patterns, (flag&1)|2);
2167  if(ret<=0)
2168  goto ex;
2169  count+= extra_filec;
2170  (*mem)+= extra_filec * sizeof(char *);
2171  if(count<=0)
2172  {ret= !!(flag & 8); goto ex;}
2173  ret= Xorriso_alloc_pattern_mem(xorriso, *mem, count, filev, !!(flag & 4));
2174  if(ret<=0)
2175  goto ex;
2176  /* now store addresses */
2177  for(i= 0; i<num_patterns; i++) {
2178  ret= Xorriso_prepare_expansion_pattern(xorriso, patterns[i], 0);
2179  if(ret<=0)
2180  return(ret);
2181  if(ret==2)
2182  abs_adr= 4;
2183 
2184  was_filec= *filec;
2185  ret= Xorriso_obtain_pattern_files_i(xorriso, "", dir, filec, *filev, count,
2186  mem, &dive_count, abs_adr);
2187  if(ret<=0)
2188  goto ex;
2189  if(was_filec == *filec && strcmp(patterns[i],"*")!=0 && (flag&3) != 1 &&
2190  !(flag & 8)) {
2191  (*filev)[*filec]= strdup(patterns[i]);
2192  if((*filev)[*filec]==NULL) {
2193  (*mem)= strlen(patterns[i])+1;
2194  Xorriso_no_pattern_memory(xorriso, *mem, 0);
2195  ret= -1; goto ex;
2196  }
2197  (*filec)++;
2198  }
2199  }
2200  ret= 1;
2201 ex:;
2202  if(ret<=0) {
2203  Sfile_destroy_argv(&count, filev, 0);
2204  *filec= 0;
2205  }
2206  return(ret);
2207 }
int Xorriso_obtain_pattern_files_i(struct XorrisO *xorriso, char *wd, IsoDir *dir, int *filec, char **filev, int count_limit, off_t *mem, int *dive_count, int flag)
Definition: iso_tree.c:2014
#define LIBISO_ISDIR(node)
Definition: iso_tree.h:17
int Xorriso_no_pattern_memory(struct XorrisO *xorriso, off_t mem, int flag)
Definition: match.c:596
int Xorriso_check_matchcount(struct XorrisO *xorriso, int count, int nonconst_mismatches, int num_patterns, char **patterns, int flag)
Definition: match.c:574
int Xorriso_alloc_pattern_mem(struct XorrisO *xorriso, off_t mem, int count, char ***filev, int flag)
Definition: match.c:609
int Xorriso_prepare_expansion_pattern(struct XorrisO *xorriso, char *pattern, int flag)
Definition: match.c:339
int Xorriso_eval_nonmatch(struct XorrisO *xorriso, char *pattern, int *nonconst_mismatches, off_t *mem, int flag)
Definition: match.c:548
int structured_search

References XorrisO::info_text, LIBISO_ISDIR, XorrisO::search_mode, Sfile_destroy_argv(), XorrisO::structured_search, Text_shellsafe(), XorrisO::wdi, Xorriso_alloc_pattern_mem(), Xorriso_check_matchcount(), Xorriso_eval_nonmatch(), Xorriso_get_volume(), Xorriso_msgs_submit(), Xorriso_no_pattern_memory(), Xorriso_node_from_path(), Xorriso_obtain_pattern_files_i(), Xorriso_prepare_expansion_pattern(), and Xorriso_process_msg_queues().

Referenced by Xorriso_apply_sort_file(), Xorriso_opt_args(), and Xorriso_option_lsi().

◆ Xorriso_external_filter()

int Xorriso_external_filter ( struct XorrisO xorriso,
char *  name,
char *  options,
char *  path,
int  argc,
char **  argv,
int  flag 
)

Definition at line 509 of file filters.c.

512 {
513  int ret, delete= 0, behavior= 0, extf_flag= 0, is_banned= 0;
514  char *what, *what_next, *suffix= "";
515  struct Xorriso_lsT *lst;
516  struct Xorriso_extF *found_filter, *new_filter= NULL;
517 
518  is_banned= Xorriso_external_filter_banned( xorriso,
519  flag & 1 ? "-unregister_filter" : "-external_filter", 0);
520  if(is_banned)
521  return(0);
522  if((!(flag & 1)) && path[0] != '/') {
523  sprintf(xorriso->info_text,
524  "-external_filter : Given command path does not begin by '/' : ");
525  Text_shellsafe(path, xorriso->info_text, 1);
526  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
527  return(0);
528  }
529 
530 
531  delete= flag & 1;
532  ret= Xorriso_lookup_extf(xorriso, name, &lst, 0);
533  if(ret < 0)
534  return(ret);
535  if(ret > 0) {
536  if(delete) {
537  found_filter= (struct Xorriso_extF *) Xorriso_lst_get_text(lst, 0);
538  if(found_filter->cmd->refcount > 0) {
539  sprintf(xorriso->info_text,
540  "-external_filter: Cannot remove filter because it is in use by %.f nodes : ",
541  (double) found_filter->cmd->refcount);
542  Text_shellsafe(name, xorriso->info_text, 1);
543  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
544  ret= 0; goto ex;
545  }
546  Xorriso_lst_detach_text(lst, 0);
547  if(xorriso->filters == lst)
548  xorriso->filters= Xorriso_lst_get_next(lst, 0);
549  Xorriso_lst_destroy(&lst, 0);
550  Xorriso_extf_destroy(xorriso, &found_filter, 0);
551  ret= 1; goto ex;
552  }
553  strcpy(xorriso->info_text,
554  "-external_filter: filter with given name already existing: ");
555  Text_shellsafe(name, xorriso->info_text, 1);
556  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
557  ret= 0; goto ex;
558  }
559  if(delete) {
560  strcpy(xorriso->info_text,
561  "-external_filter: filter with given name does not exist: ");
562  Text_shellsafe(name, xorriso->info_text, 1);
563  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
564  ret= 0; goto ex;
565  }
566 
567  for(what= options; what!=NULL; what= what_next) {
568  what_next= strchr(what, ':');
569  if(what_next!=NULL) {
570  *what_next= 0;
571  what_next++;
572  }
573  if(strncmp(what, "default", 7) == 0) {
574  suffix= "";
575  behavior= 0;
576  } else if(strncmp(what, "suffix=", 7) == 0) {
577  suffix= what + 7;
578  } else if(strcmp(what, "remove_suffix") == 0) {
579  behavior|= 8;
580  } else if(strcmp(what, "if_nonempty") == 0) {
581  behavior|= 1;
582  } else if(strcmp(what, "if_reduction") == 0) {
583  behavior|= 2;
584  } else if(strcmp(what, "if_block_reduction") == 0) {
585  behavior|= 4;
586  } else if(strncmp(what, "used=", 5) == 0) {
587  ; /* this is informational output from -status */
588  } else if(what[0]) {
589  strcpy(xorriso->info_text,
590  "-external_filter: unknown option ");
591  Text_shellsafe(what, xorriso->info_text, 1);
592  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
593  ret= 0; goto ex;
594  }
595  }
596 
597  ret= Xorriso_extf_new(xorriso, &new_filter, path, argc, argv, behavior,
598  suffix, name, extf_flag);
599  if(ret <= 0) {
600 could_not_create:;
601  strcpy(xorriso->info_text,
602  "-external_filter: Could not create filter object");
603  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
604  goto ex;
605  }
606  ret= Xorriso_lst_append_binary(&(xorriso->filters), (char *) new_filter,0, 4);
607  if(ret <= 0)
608  goto could_not_create;
609  ret= 1;
610 ex:;
611  if(ret <= 0) {
612  if(new_filter != NULL)
613  Xorriso_extf_destroy(xorriso, &new_filter, 0);
614  }
615  return(ret);
616 }
int Xorriso_lst_append_binary(struct Xorriso_lsT **entry, char *data, int data_len, int flag)
Create a new list item at the end of a given list.
Definition: aux_objects.c:609
int Xorriso_external_filter_banned(struct XorrisO *xorriso, char *purpose, int flag)
Definition: filters.c:466
int Xorriso_lookup_extf(struct XorrisO *xorriso, char *name, struct Xorriso_lsT **found_lst, int flag)
Definition: filters.c:141
int Xorriso_extf_new(struct XorrisO *xorriso, struct Xorriso_extF **filter, char *path, int argc, char **argv, int behavior, char *suffix, char *name, int flag)
Definition: filters.c:55
int flag
Definition: filters.c:44
IsoExternalFilterCommand * cmd
Definition: filters.c:46

References Xorriso_extF::cmd, XorrisO::filters, Xorriso_extF::flag, XorrisO::info_text, Text_shellsafe(), Xorriso_external_filter_banned(), Xorriso_extf_destroy(), Xorriso_extf_new(), Xorriso_lookup_extf(), Xorriso_lst_append_binary(), Xorriso_lst_destroy(), Xorriso_lst_detach_text(), Xorriso_lst_get_next(), Xorriso_lst_get_text(), and Xorriso_msgs_submit().

Referenced by Xorriso_option_external_filter(), and Xorriso_option_unregister_filter().

◆ Xorriso_external_filter_banned()

int Xorriso_external_filter_banned ( struct XorrisO xorriso,
char *  purpose,
int  flag 
)

Definition at line 466 of file filters.c.

468 {
469  int is_banned= 0;
470 
471 #ifndef Xorriso_allow_external_filterS
472  /* To be controlled by: configure --enable-external-filters */
473 
474  sprintf(xorriso->info_text, "%s : Banned at compile time.", purpose);
475  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
476  sprintf(xorriso->info_text,
477 "This may be changed at compile time by ./configure option --enable-external-filters");
478  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0);
479  is_banned= 1;
480 
481 #endif /* ! Xorriso_allow_external_filterS */
482 
483 #ifndef Xorriso_allow_extf_suiD
484  /* To be controlled by: configure --enable-external-filters-setuid */
485 
486  if(getuid() != geteuid()) {
487  sprintf(xorriso->info_text,
488  "-set_filter: UID and EUID differ. Will not run external programs.");
489  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
490  sprintf(xorriso->info_text,
491 "This may be changed at compile time by ./configure option --enable-external-filters-setuid");
492  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0);
493  is_banned= 1;
494  }
495 #endif /* ! Xorriso_allow_extf_suiD */
496 
497  if(xorriso->filter_list_closed) {
498  sprintf(xorriso->info_text,
499  "%s : Banned by previous command -close_filter_list", purpose);
500  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
501  is_banned= 1;
502  }
503  return(is_banned);
504 }
int filter_list_closed

References XorrisO::filter_list_closed, XorrisO::info_text, and Xorriso_msgs_submit().

Referenced by Xorriso_external_filter(), and Xorriso_pipe_open().

◆ Xorriso_extract_boot_images()

int Xorriso_extract_boot_images ( struct XorrisO xorriso,
char *  disk_dir_path,
int  flag 
)

Definition at line 2486 of file read_run.c.

2488 {
2489  int ret, img_count= 0, i, was_problem= 0;
2490  char **imgs= NULL, *eff_path= NULL, *cpt, *eff_namept;
2491  struct stat stbuf;
2492  off_t byte_offset, byte_size;
2493 
2494  Xorriso_alloc_meM(eff_path, char, SfileadrL);
2495  ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, disk_dir_path,
2496  eff_path, 2 | 4);
2497  if(ret <= 0)
2498  goto ex;
2499  if(strlen(eff_path) > SfileadrL - 80) {
2500  sprintf(xorriso->info_text,
2501  "-extract_boot_images: disk_path is too long (%lu)\n",
2502  (unsigned long int) strlen(eff_path));
2503  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
2504  ret= 0; goto ex;
2505  }
2506  ret= stat(eff_path, &stbuf);
2507  if(ret == 0) {
2508  if(!S_ISDIR(stbuf.st_mode)) {
2509  sprintf(xorriso->info_text,
2510  "-extract_boot_images: disk_path is not a directory : ");
2511  Text_shellsafe(eff_path, xorriso->info_text, 1);
2512  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
2513  ret= 0; goto ex;
2514  }
2515  } else {
2516  ret= mkdir(eff_path, 0777);
2517  if(ret == -1) {
2518  sprintf(xorriso->info_text,
2519  "-extract_boot_images: cannot create directory : ");
2520  Text_shellsafe(eff_path, xorriso->info_text, 1);
2521  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
2522  ret= 0; goto ex;
2523  }
2524  }
2525  strcat(eff_path, "/");
2526  eff_namept= eff_path + strlen(eff_path);
2527 
2528  ret= Xorriso_list_boot_images(xorriso, &imgs, &img_count, 0);
2529  if(ret <= 0)
2530  goto ex;
2531 
2532  /* Interpret list and create files */
2533  for(i= 0; i < img_count; i++) {
2534  ret= Xorriso_eval_problem_status(xorriso, 1, 1 | 2);
2535  if(ret < 0)
2536  {ret= 0; goto ex;}
2537  cpt= strchr(imgs[i], '/');
2538  if(cpt == NULL)
2539  continue;
2540  *cpt= 0;
2541  cpt+= 2;
2542  ret= Sfile_text_to_off_t(cpt, &byte_offset, 0);
2543  if(ret <= 0)
2544  continue;
2545  cpt+= ret;
2546  if(*cpt == 0)
2547  continue;
2548  cpt++;
2549  ret= Sfile_text_to_off_t(cpt, &byte_size, 0);
2550  if(ret <= 0)
2551  continue;
2552 
2553  strcpy(eff_namept, imgs[i]);
2554  sprintf(xorriso->info_text, "%s : offset=%.f size=%.f\n",
2555  eff_path, (double) byte_offset, (double) byte_size);
2556  Xorriso_info(xorriso, 0);
2557 
2558  ret= stat(eff_path, &stbuf);
2559  if(ret != -1) {
2560  sprintf(xorriso->info_text,
2561  "-extract_boot_images: File already exists on disk: ");
2562  Text_shellsafe(eff_path, xorriso->info_text, 1);
2563  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
2564  continue;
2565  }
2566  ret= Xorriso_read_file_data(xorriso, NULL, NULL, eff_path,
2567  byte_offset, (off_t) 0, byte_size, 1);
2568  if(ret <= 0)
2569  was_problem= 1;
2570  }
2571  ret= Xorriso_eval_problem_status(xorriso, 1, 1 | 2);
2572  if(ret < 0 || was_problem)
2573  {ret= 0; goto ex;}
2574 
2575  ret= 1;
2576 ex:;
2577  Xorriso_free_meM(eff_path);
2578  Xorriso_list_boot_images(xorriso, &imgs, &img_count, 1 << 15);
2579  return(ret);
2580 }
int Xorriso_list_boot_images(struct XorrisO *xorriso, char ***imgs, int *img_count, int flag)
Definition: iso_img.c:3140
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_read_file_data(struct XorrisO *xorriso, IsoNode *node, char *img_path, char *disk_path, off_t img_offset, off_t disk_offset, off_t bytes, int flag)
Definition: read_run.c:2338
int Sfile_text_to_off_t(char *text, off_t *num, int flag)
Definition: sfile.c:435

References XorrisO::info_text, Sfile_text_to_off_t(), SfileadrL, Text_shellsafe(), XorrisO::wdx, Xorriso_alloc_meM, Xorriso_eval_problem_status(), Xorriso_free_meM, Xorriso_info(), Xorriso_list_boot_images(), Xorriso_msgs_submit(), Xorriso_normalize_img_path(), and Xorriso_read_file_data().

Referenced by Xorriso_option_extract_boot_images().

◆ Xorriso_extract_cut()

int Xorriso_extract_cut ( struct XorrisO xorriso,
char *  img_path,
char *  disk_path,
off_t  img_offset,
off_t  bytes,
int  flag 
)

Definition at line 2255 of file read_run.c.

2258 {
2259  int ret, stbuf_ret, read_raw;
2260  double mem_lut= 0.0;
2261  char *eff_img_path= NULL, *eff_disk_path= NULL;
2262  IsoImage *volume;
2263  IsoNode *node;
2264 
2265  Xorriso_alloc_meM(eff_img_path, char, SfileadrL);
2266  Xorriso_alloc_meM(eff_disk_path, char, SfileadrL);
2267 
2268  ret= Xorriso_get_volume(xorriso, &volume, 0);
2269  if(ret<=0)
2270  goto ex;
2271  ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi,
2272  img_path, eff_img_path, 0);
2273  if(ret<=0)
2274  goto ex;
2275  ret= Xorriso_node_from_path(xorriso, volume, eff_img_path, &node, 0);
2276  if(ret<=0)
2277  goto ex;
2278  ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx,
2279  disk_path, eff_disk_path, 2 | 4);
2280  if(ret<=0)
2281  goto ex;
2282  Xorriso_pacifier_reset(xorriso, 0);
2283  mem_lut= xorriso->last_update_time;
2284 
2285  ret= Xorriso_handle_collision(xorriso, node, img_path, eff_disk_path,
2286  disk_path, &stbuf_ret, 0);
2287  if(ret<=0 || ret==3)
2288  {ret= 0; goto ex;}
2289 
2290  /* If it is a non-filtered stream from the ISO image
2291  and img_offset is a multiple of 2048
2292  then use Xorriso_read_file_data() for random access offset.
2293  */
2294  if(!LIBISO_ISREG(node)) {
2295  Xorriso_msgs_submit(xorriso, 0, eff_disk_path, 0, "ERRFILE", 0);
2296  sprintf(xorriso->info_text, "-extract_cut: ISO file ");
2297  Text_shellsafe(eff_img_path, xorriso->info_text, 1);
2298  strcat(xorriso->info_text, " is not a data file");
2299  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
2300  {ret= 0; goto ex;}
2301  }
2302  read_raw= 0;
2303  if((img_offset % 2048) == 0) {
2304  ret= Xorriso_is_plain_image_file(xorriso, node, "", 0);
2305  if(ret > 0)
2306  read_raw= 1;
2307  }
2308  if (read_raw) {
2309  ret= Xorriso_read_file_data(xorriso, node, eff_img_path, eff_disk_path,
2310  img_offset, (off_t) 0, bytes, 0);
2311  if(ret<=0)
2312  goto ex;
2313  } else {
2314  ret= Xorriso_tree_restore_node(xorriso, node, eff_img_path, img_offset,
2315  eff_disk_path, (off_t) 0, bytes, 2 | 8);
2316  if(ret<=0)
2317  goto ex;
2318  }
2319 
2320  ret= Xorriso_restore_properties(xorriso, eff_disk_path, node, 0);
2321  if(ret<=0)
2322  goto ex;
2323 
2324  if(mem_lut != xorriso->last_update_time)
2325  Xorriso_pacifier_callback(xorriso, "blocks read",
2326  xorriso->pacifier_count, 0, "", 1 | 8 | 16 | 32);
2327  ret= 1;
2328 ex:;
2329  Xorriso_free_meM(eff_img_path);
2330  Xorriso_free_meM(eff_disk_path);
2331  return(ret);
2332 }
int Xorriso_is_plain_image_file(struct XorrisO *xorriso, void *in_node, char *path, int flag)
Definition: iso_tree.c:2749
int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node, char *img_path, off_t img_offset, char *disk_path, off_t disk_offset, off_t bytes, int flag)
Definition: read_run.c:819
int Xorriso_restore_properties(struct XorrisO *xorriso, char *disk_path, IsoNode *node, int flag)
Definition: read_run.c:309
int Xorriso_handle_collision(struct XorrisO *xorriso, IsoNode *node, char *img_path, char *disk_path, char *nominal_disk_path, int *stbuf_ret, int flag)
Definition: read_run.c:1522
double last_update_time

References XorrisO::info_text, XorrisO::last_update_time, LIBISO_ISREG, XorrisO::pacifier_count, SfileadrL, Text_shellsafe(), XorrisO::wdi, XorrisO::wdx, Xorriso_alloc_meM, Xorriso_free_meM, Xorriso_get_volume(), Xorriso_handle_collision(), Xorriso_is_plain_image_file(), Xorriso_msgs_submit(), Xorriso_node_from_path(), Xorriso_normalize_img_path(), Xorriso_pacifier_callback(), Xorriso_pacifier_reset(), Xorriso_read_file_data(), Xorriso_restore_properties(), and Xorriso_tree_restore_node().

Referenced by Xorriso_option_extract_cut().

◆ Xorriso_findi()

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 at line 3355 of file iso_manip.c.

3359 {
3360  int ret, action= 0, hflag, deleted= 0, no_dive= 0;
3361  IsoDirIter *iter= NULL;
3362  IsoDir *dir_node= NULL;
3363  IsoNode *node, *iso_node;
3364  IsoImage *volume= NULL;
3365  struct stat stbuf;
3366  char *name;
3367  off_t mem;
3368  IsoNode **node_array= NULL;
3369  int node_count= 0, node_idx;
3370  char *path= NULL, *abs_path= NULL;
3371 
3372  job->depth= depth;
3373 
3374  if(xorriso->request_to_abort)
3375  {ret= 0; goto ex;}
3376 
3377  path= malloc(SfileadrL);
3378  abs_path= malloc(SfileadrL);
3379  if(path==NULL || abs_path==NULL) {
3380  Xorriso_no_malloc_memory(xorriso, &path, 0);
3381  {ret= -1; goto ex;}
3382  }
3383 
3384  action= Findjob_get_action(job, 0);
3385  if(action<0)
3386  action= 0;
3387  if(!(flag & 1)) {
3388  Xorriso_findi_headline(xorriso, job, 0);
3389  job->last_data_file_block= 0;
3390  }
3391 
3392  dir_node= (IsoDir *) dir_node_generic;
3393  if(dir_node==NULL) {
3394  ret= Xorriso_get_volume(xorriso, &volume, 0);
3395  if(ret<=0)
3396  {ret= -1; goto ex;}
3397  ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, dir_path, path, 1|2|4);
3398  if(ret<=0)
3399  goto ex;
3400  ret= Xorriso_node_from_path(xorriso, volume, path, &iso_node, 0);
3401  dir_node= (IsoDir *) iso_node;
3402  if(ret<=0)
3403  {ret= 0; goto ex;}
3404  ret= Xorriso_fake_stbuf(xorriso, "", dir_stbuf, &iso_node, 1);
3405  if(ret<=0)
3406  goto ex;
3407 
3408  name= strrchr(dir_path, '/');
3409  if(name==NULL)
3410  name= dir_path;
3411  else
3412  name++;
3413 
3414  ret= Xorriso_findi_test(xorriso, job, iso_node, name, path, NULL, dir_stbuf,
3415  depth, 0);
3416  if(ret<0)
3417  goto ex;
3418  if(job->prune)
3419  no_dive= 1;
3420  if(ret>0) {
3421  iso_node_ref(iso_node); /* protect from real disposal */
3422  ret= Xorriso_findi_action(xorriso, job,
3423  (IsoDirIter *) boss_iter, boss_mem,
3424  path, dir_path, iso_node, depth,
3425  flag&(1|2));
3426  deleted= (iso_node_get_parent(iso_node) == NULL); /* still in tree ? */
3427  iso_node_unref(iso_node); /* eventually do real disposal */
3428  if(xorriso->request_to_abort)
3429  {ret= 0; goto ex;}
3430  if(ret == 4)
3431  goto ex;
3432  if(ret<=0)
3433  goto ex;
3434  if(ret==2 || deleted) {
3435  /* re-determine dir_node in case it has a new persona */
3436  ret= Xorriso_node_from_path(xorriso, volume, path, &iso_node, 1);
3437  if(ret==0) {
3438  deleted= 1;
3439  {ret= 2; goto ex;}
3440  }
3441  if(ret<0)
3442  {ret= 0; goto ex;}
3443  dir_node= (IsoDir *) iso_node;
3444  ret= Xorriso_fake_stbuf(xorriso, "", dir_stbuf, &iso_node, 1);
3445  if(ret<=0)
3446  goto ex;
3447  }
3448  if(ret==3)
3449  no_dive= 1;
3450  }
3451  }
3452  if(no_dive || !LIBISO_ISDIR((IsoNode *) dir_node))
3453  {ret= 1; goto ex;}
3454  if(action == 14 || action == 17 || (flag & 4))
3455  if(Xorriso_is_split(xorriso, dir_path, (IsoNode *) dir_node, 1)>0)
3456  {ret= 1; goto ex;}
3457 
3458  mem= boss_mem;
3459  hflag= 1;
3460  if(action==1 || action==2 || action==3 || action==17 || action == 28 ||
3461  action == 32 || action == 41 || action == 42)
3462  hflag|= 2; /* need freedom to manipulate image */
3463  if(action==14 || action==17 || action == 28 || action == 35 || action == 36 ||
3464  action == 41)
3465  hflag|= 4; /* need LBA sorted iteration for good data reading performance */
3466  ret= Xorriso_findi_iter(xorriso, dir_node, &mem,
3467  &iter, &node_array, &node_count, &node_idx,
3468  &node, hflag);
3469  if(ret<=0)
3470  goto ex;
3471  job->depth++;
3472  while(1) {
3473  ret= Xorriso_findi_iter(xorriso, dir_node, &mem, &iter,
3474  &node_array, &node_count, &node_idx, &node, 0);
3475  if(ret<0)
3476  goto ex;
3477  if(ret==0)
3478  break;
3479  name= (char *) iso_node_get_name(node);
3480  ret= Xorriso_make_abs_adr(xorriso, dir_path, name, path, 4);
3481  if(ret<=0)
3482  goto ex;
3483  ret= Xorriso_fake_stbuf(xorriso, "", &stbuf, &node, 1);
3484  if(ret<0)
3485  goto ex;
3486  if(ret==0)
3487  continue;
3488 
3489 /* ??? This seems to be redundant with the single test above
3490  ??? Should i dive in unconditionally and leave out test and action here ?
3491  ??? Then do above test unconditionally ?
3492  --- Seems that the current configuration represents the special
3493  handling of the find start path with mount points. Dangerous to change.
3494 */
3495 
3496  ret= Xorriso_findi_test(xorriso, job, node, name, path, dir_stbuf, &stbuf,
3497  depth, 0);
3498  if(ret<0)
3499  goto ex;
3500  if(job->prune)
3501  no_dive= 1;
3502  if(ret>0) {
3503  ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, path, abs_path, 1|2|4);
3504  if(ret<=0)
3505  goto ex;
3506  ret= Xorriso_findi_action(xorriso, job, iter, mem,
3507  abs_path, path, node, depth, 1|(flag&2));
3508  if(xorriso->request_to_abort)
3509  {ret= 0; goto ex;}
3510  if(ret == 4)
3511  goto ex;
3512  if(ret==2) { /* node has been deleted */
3513  /* re-determine node in case it has a new persona */
3514  if(volume==NULL) {
3515  ret= Xorriso_get_volume(xorriso, &volume, 0);
3516  if(ret<=0)
3517  {ret= -1; goto ex;}
3518  }
3519  ret= Xorriso_node_from_path(xorriso, volume, abs_path, &node, 1);
3520  if(ret==0)
3521  continue;
3522  if(ret<0)
3523  {ret= 0; goto ex;}
3524  ret= Xorriso_fake_stbuf(xorriso, "", &stbuf, &node, 1);
3525  if(ret<0)
3526  goto ex;
3527  if(ret==0)
3528  continue;
3529  }
3530  no_dive= (ret==3);
3531  if(ret<=0) {
3532  if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0)
3533  goto ex;
3534  }
3535  }
3536 
3537  if(S_ISDIR(stbuf.st_mode) && !no_dive) {
3538  ret= Xorriso_findi(xorriso, job, (void *) iter, mem,
3539  (void *) node, path, &stbuf, depth+1, flag|1);
3540  if(ret<0)
3541  goto ex;
3542  if(xorriso->request_to_abort)
3543  {ret= 0; goto ex;}
3544  if(ret == 4)
3545  goto ex;
3546  }
3547  }
3548 
3549  ret= 1;
3550 ex:;
3551  job->depth= depth;
3552  if(path!=NULL)
3553  free(path);
3554  if(abs_path!=NULL)
3555  free(abs_path);
3556  Xorriso_process_msg_queues(xorriso,0);
3557 
3558  Xorriso_findi_iter(xorriso, dir_node, &mem, &iter, &node_array, &node_count,
3559  &node_idx, &node, (1u<<31));
3560  if(ret<=0)
3561  return(ret);
3562  if(deleted)
3563  return(2);
3564  return(1);
3565 }
int Findjob_get_action(struct FindjoB *o, int flag)
Definition: findjob.c:1120
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: iso_manip.c:2528
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_findi_test(struct XorrisO *xorriso, struct FindjoB *job, IsoNode *node, char *name, char *path, struct stat *boss_stbuf, struct stat *stbuf, int depth, int flag)
Definition: iso_manip.c:3312
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 Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf, IsoNode **node, int flag)
Definition: iso_tree.c:245
int Xorriso_is_split(struct XorrisO *xorriso, char *path, void *node, int flag)
Definition: iso_tree.c:633
int Xorriso_make_abs_adr(struct XorrisO *xorriso, char *wd, char *name, char adr[], int flag)
Definition: parse_exec.c:2812
uint32_t last_data_file_block
Definition: findjob.h:206
int Xorriso_no_malloc_memory(struct XorrisO *xorriso, char **to_free, int flag)
Definition: text_io.c:4077

References FindjoB::depth, Findjob_get_action(), FindjoB::last_data_file_block, LIBISO_ISDIR, FindjoB::prune, XorrisO::request_to_abort, SfileadrL, XorrisO::wdi, Xorriso_eval_problem_status(), Xorriso_fake_stbuf(), Xorriso_findi_action(), Xorriso_findi_headline(), Xorriso_findi_iter(), Xorriso_findi_test(), Xorriso_get_volume(), Xorriso_is_split(), Xorriso_make_abs_adr(), Xorriso_no_malloc_memory(), Xorriso_node_from_path(), and Xorriso_process_msg_queues().

Referenced by Xorriso_all_node_array(), Xorriso_findi_action(), Xorriso_findi_sorted(), Xorriso_grasp_loaded_aaip(), Xorriso_highest_data_block(), Xorriso_option_alter_date(), Xorriso_option_check_media(), Xorriso_option_chgrpi(), Xorriso_option_chmodi(), Xorriso_option_chowni(), Xorriso_option_find(), Xorriso_option_getfacli(), Xorriso_option_set_filter(), Xorriso_option_setfacli(), Xorriso_option_setfattri(), Xorriso_path_from_lba(), Xorriso_scan_report_lines(), and Xorriso_set_file_name_limit().

◆ 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_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_start_path(struct FindjoB *o, char *start_path, int flag)
Definition: findjob.c:420
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
int temp_mem_limit

References FindjoB::action, Findjob_set_start_path(), XorrisO::node_array, XorrisO::node_array_size, XorrisO::node_counter, SfileadrL, FindjoB::start_path, FindjoB::subjob, XorrisO::temp_mem_limit, Xorriso_alloc_meM, Xorriso_check_temp_mem_limit(), Xorriso_destroy_node_array(), Xorriso_eval_problem_status(), Xorriso_findi(), Xorriso_findi_action(), Xorriso_findi_headline(), Xorriso_free_meM, Xorriso_get_node_by_path(), Xorriso_new_node_array(), Xorriso_path_from_node(), and Xorriso_sort_node_array().

Referenced by Xorriso_option_check_md5(), and Xorriso_option_find().

◆ Xorriso_finish_hl_update()

int Xorriso_finish_hl_update ( struct XorrisO xorriso,
int  flag 
)

Definition at line 704 of file sort_cmp.c.

705 {
706  int ret, zero= 0;
707  char *argv[4];
708  struct Xorriso_lsT *disk_lst, *iso_lst;
709 
710  if(xorriso->di_array == NULL)
711  {ret= 1; goto ex;}
712  disk_lst= xorriso->di_disk_paths;
713  iso_lst= xorriso->di_iso_paths;
714  while(disk_lst != NULL && iso_lst != NULL) {
715  argv[0]= Xorriso_lst_get_text(iso_lst, 0);
716  argv[1]= "-exec";
717  argv[2]= "widen_hardlinks";
718  argv[3]= Xorriso_lst_get_text(disk_lst, 0);
719  zero= 0;
720  ret= Xorriso_option_find(xorriso, 4, argv, &zero, 0); /* -findi */
721  if(ret < 0)
722  goto ex;
723  disk_lst= Xorriso_lst_get_next(disk_lst, 0);
724  iso_lst= Xorriso_lst_get_next(iso_lst, 0);
725  }
726  ret= 1;
727 ex:;
728  if(!(flag & 1))
729  Xorriso_destroy_di_array(xorriso, 0);
730  return(ret);
731 }

References XorrisO::di_array, XorrisO::di_disk_paths, XorrisO::di_iso_paths, Xorriso_destroy_di_array(), Xorriso_lst_get_next(), Xorriso_lst_get_text(), and Xorriso_option_find().

Referenced by Xorriso_make_di_array(), Xorriso_option_hardlinks(), and Xorriso_write_session().

◆ Xorriso_format_guid()

int Xorriso_format_guid ( struct XorrisO xorriso,
uint8_t  guid[16],
char *  line,
int  flag 
)

Definition at line 1009 of file lib_mgt.c.

1011 {
1012 
1013  /* >>> Maybe let the user switch between hex string and structured text */;
1014 
1015  Xorriso__format_guid(guid, line, 1);
1016  return(1);
1017 }
int Xorriso__format_guid(uint8_t guid[16], char *text, int flag)
Definition: misc_funct.c:1341

References Xorriso__format_guid().

Referenced by Xorriso_make_guid(), and Xorriso_report_system_area().

◆ Xorriso_format_media()

int Xorriso_format_media ( struct XorrisO xorriso,
off_t  size,
int  flag 
)

Definition at line 1895 of file write_run.c.

1896 {
1897  int ret, mode_flag= 0, index, status, num_formats, signal_mode, using_immed;
1898  unsigned dummy;
1899  struct burn_drive_info *dinfo;
1900  struct burn_drive *drive;
1901  struct burn_progress p;
1902  double percent = 1.0;
1903  int current_profile;
1904  char current_profile_name[80], progress_text[40];
1905  off_t size= 0;
1906  time_t start_time;
1907  enum burn_disc_status disc_state;
1908 
1909  ret= Xorriso_may_burn(xorriso, 0);
1910  if(ret <= 0)
1911  return(0);
1912  ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
1913  "on attempt to -format", 2);
1914  if(ret<=0)
1915  return(0);
1916 
1917  if(flag & 2) {
1918  mode_flag= 0; /* format to given size */
1919  } else {
1920  mode_flag= 4; /* format to full size */
1921  }
1922  if(flag & 32)
1923  mode_flag|= 32; /* try to disable Defect Management */
1924 
1925  burn_disc_get_profile(drive, &current_profile, current_profile_name);
1926 
1927  if(flag&128) { /* by_index */
1928  index= (flag>>8) & 0xff;
1929  ret= burn_disc_get_formats(drive, &status, &size, &dummy, &num_formats);
1930  if(ret<=0)
1931  num_formats= 0;
1932  if(ret<=0 || index<0 || index>=num_formats) {
1933  if(num_formats>0)
1934  sprintf(xorriso->info_text,
1935  "-format by_index_%d: format descriptors range from index 0 to %d",
1936  index, num_formats-1);
1937  else
1938  sprintf(xorriso->info_text,
1939  "-format by_index_%d: no format descriptors available", index);
1940  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
1941  return(0);
1942  }
1943  mode_flag|= (flag & 0xff80);
1944  if(flag&1)
1945  mode_flag|= (1<<6);
1946 
1947  } else if(current_profile == 0x12) { /* DVD+RAM */
1948  if(!(flag & 2))
1949  mode_flag= 6; /* format to default payload size */
1950  if(flag&1)
1951  mode_flag|= (1<<6);
1952 
1953  } else if(current_profile == 0x13) { /* DVD-RW */
1954  if(flag&1) {
1955  sprintf(xorriso->info_text,
1956  "Detected formatted DVD-RW. Thus omitting desired fast format run.");
1957  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
1958  return(2);
1959  }
1960 
1961  } else if(current_profile == 0x14) { /* DVD-RW sequential */
1962  if(flag & 1) {
1963  size= 128*1024*1024;
1964  mode_flag= 1; /* format to size, then write size of zeros */
1965  } else
1966  mode_flag= 4;
1967 
1968  } else if(current_profile == 0x1a) { /* DVD+RW */
1969  if(flag&1) {
1970  sprintf(xorriso->info_text,
1971  "Detected DVD+RW. Thus omitting desired fast format run.");
1972  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
1973  return(2);
1974  }
1975 
1976  } else if(current_profile == 0x41) { /* BD-R SRM */
1977  if(!(flag & 2))
1978  mode_flag= 6; /* format to default payload size */
1979  if(flag&1)
1980  mode_flag|= (1<<6);
1981 
1982  } else if(current_profile == 0x43) { /* BD-RE */
1983  if(!(flag & (2 | 32)))
1984  mode_flag= 6; /* format to default payload size */
1985  if(flag&1)
1986  mode_flag|= (1<<6);
1987 
1988  } else {
1989  sprintf(xorriso->info_text,
1990  "-format: Unsuitable media detected.");
1991  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
1992  sprintf(xorriso->info_text,"Media current: %s (%4.4xh)",
1993  current_profile_name, current_profile);
1994  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
1995  return(0);
1996  }
1997  if(!(flag & 1))
1998  mode_flag|= 16; /* enable re-formatting */
1999 
2000  if(xorriso->do_dummy) {
2001  sprintf(xorriso->info_text, "-dummy mode prevents formatting of medium.");
2002  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
2003  return(1);
2004  }
2005  using_immed= burn_drive_get_immed(drive);
2006  sprintf(xorriso->info_text, "Beginning to format medium.\n");
2007  Xorriso_info(xorriso, 0);
2008  if(flag & 2)
2009  size= in_size;
2010 
2011  /* Important: do not return until burn_is_aborting() was checked */
2012  signal_mode= 1;
2013  ret= burn_drive_get_drive_role(drive);
2014  if(ret == 1)
2015  signal_mode|= 2;
2016  Xorriso_set_signal_handling(xorriso, signal_mode);
2017 
2018  burn_disc_format(drive, size, mode_flag);
2019 
2020  start_time= time(0);
2021  usleep(1000000);
2022  if(!using_immed)
2023  sprintf(progress_text, "synchronously since");
2024  while (burn_drive_get_status(drive, &p) != BURN_DRIVE_IDLE) {
2025  Xorriso_process_msg_queues(xorriso,0);
2026  if(p.sectors>0 && p.sector>=0) /* display 1 to 99 percent */
2027  percent = 1.0 + ((double) p.sector+1.0) / ((double) p.sectors) * 98.0;
2028  if(using_immed)
2029  sprintf(progress_text, "%.1f%% done in", percent);
2030  sprintf(xorriso->info_text, "Formatting ( %s %d seconds )",
2031  progress_text, (int) (time(0) - start_time));
2032  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0);
2033  usleep(1000000);
2034  }
2035  Xorriso_process_msg_queues(xorriso,0);
2036  if(burn_is_aborting(0))
2037  Xorriso_abort(xorriso, 0); /* Never comes back */
2038  Xorriso_set_signal_handling(xorriso, 0);
2039 
2040  if(burn_drive_wrote_well(drive)) {
2041  sprintf(xorriso->info_text, "Formatting done\n");
2042  Xorriso_info(xorriso,0);
2043  } else {
2044  sprintf(xorriso->info_text,
2045  "libburn indicates failure with formatting.");
2046  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
2047  return(-1);
2048  }
2049 
2050  if(!(flag & 4)) {
2051  ret= Xorriso_reaquire_outdev(xorriso,
2052  2 + (xorriso->in_drive_handle == xorriso->out_drive_handle));
2053  if(ret <= 0)
2054  return(-1);
2055  }
2056  disc_state = isoburn_disc_get_status(drive);
2057  if(disc_state==BURN_DISC_FULL && !(flag&1)) {
2058  /* Blank because full format certification pattern might be non-zero */
2059  ret= Xorriso_blank_media(xorriso, 1);
2060  if(ret <= 0)
2061  return(0);
2062  }
2063  return(1);
2064 }

References XorrisO::do_dummy, XorrisO::in_drive_handle, XorrisO::info_text, isoburn_disc_get_status(), XorrisO::out_drive_handle, Xorriso_abort(), Xorriso_blank_media(), Xorriso_get_drive_handles(), Xorriso_info(), Xorriso_may_burn(), Xorriso_msgs_submit(), Xorriso_process_msg_queues(), Xorriso_reaquire_outdev(), and Xorriso_set_signal_handling().

Referenced by Xorriso_auto_format(), Xorriso_blank_as_needed(), and Xorriso_option_blank().

◆ Xorriso_get_attrs()

int Xorriso_get_attrs ( struct XorrisO xorriso,
void *  in_node,
char *  path,
size_t *  num_attrs,
char ***  names,
size_t **  value_lengths,
char ***  values,
int  flag 
)

Definition at line 1188 of file iso_tree.c.

1191 {
1192  int ret, i, widx;
1193  IsoNode *node;
1194 
1195  if(flag & (1 << 15)) {
1196  if(flag & 2) {
1197  iso_local_get_attrs(NULL, num_attrs, names, value_lengths, values,
1198  1 << 15);
1199  } else {
1200  iso_node_get_attrs(NULL, num_attrs, names, value_lengths, values,
1201  1 << 15);
1202  }
1203  return(1);
1204  }
1205 
1206  *num_attrs= 0;
1207  if(flag & 2) {
1208  ret= iso_local_get_attrs(path, num_attrs, names, value_lengths, values,
1209  flag & (8 | 32));
1210  if(ret < 0) {
1211  strcpy(xorriso->info_text, "Error with reading xattr of disk file ");
1212  Text_shellsafe(path, xorriso->info_text, 1);
1213  Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
1214  }
1215  } else {
1216  node= (IsoNode *) in_node;
1217  if(node == NULL) {
1218  ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0);
1219  if(ret<=0)
1220  goto ex;
1221  }
1222  ret= iso_node_get_attrs(node, num_attrs, names, value_lengths, values,
1223  0);
1224  if(ret < 0) {
1225  Xorriso_report_iso_error(xorriso, "", ret,
1226  "Error when obtaining xattr of ISO node", 0, "FAILURE", 1);
1227  goto ex;
1228  }
1229 
1230  if(!(flag & 8)) {
1231  /* Filter away any non-userspace xattr */;
1232  widx= 0;
1233  for(i= 0; i < (int) *num_attrs; i++) {
1234  if(strncmp((*names)[i], "user.", 5) != 0) {
1235  free((*names)[i]);
1236  (*names)[i]= NULL;
1237  if((*values)[i] != NULL) {
1238  free((*values)[i]);
1239  (*values)[i]= NULL;
1240  }
1241  } else {
1242  if(widx != i) {
1243  (*names)[widx]= (*names)[i];
1244  (*value_lengths)[widx]= (*value_lengths)[i];
1245  (*values)[widx]= (*values)[i];
1246  (*names)[i]= NULL;
1247  (*value_lengths)[i]= 0;
1248  (*values)[i]= NULL;
1249  }
1250  widx++;
1251  }
1252  }
1253  *num_attrs= widx;
1254  }
1255  }
1256  ret= 1;
1257 ex:;
1258  Xorriso_process_msg_queues(xorriso,0);
1259  return(ret);
1260 }

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

Referenced by Xorriso_get_attr_value(), Xorriso_getfattr(), and Xorriso_list_extattr().

◆ Xorriso_get_dus()

int Xorriso_get_dus ( struct XorrisO xorriso,
char *  iso_rr_path,
off_t *  size,
off_t  boss_mem,
int  flag 
)

Definition at line 1863 of file iso_tree.c.

1865 {
1866  int ret;
1867  IsoNode *node;
1868  char *path= NULL;
1869  struct stat stbuf;
1870 
1871  Xorriso_alloc_meM(path, char, SfileadrL);
1872 
1873  ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, iso_rr_path, path,
1874  1 | 2 | 4);
1875  if(ret <= 0)
1876  goto ex;
1877  ret= Xorriso_fake_stbuf(xorriso, path, &stbuf, &node, 0);
1878  if(ret <= 0)
1879  goto ex;
1880  if(!S_ISDIR(stbuf.st_mode)) {
1881  *size= stbuf.st_size;
1882  ret= 2; goto ex;
1883  }
1884  ret= Xorriso_show_du_subs(xorriso, (IsoDir *) node, path, iso_rr_path, size,
1885  boss_mem, 4);
1886  if(ret <= 0)
1887  goto ex;
1888  ret= 1;
1889 ex:
1890  Xorriso_free_meM(path);
1891  return(ret);
1892 }
int Xorriso_show_du_subs(struct XorrisO *xorriso, IsoDir *dir_node, char *abs_path, char *rel_path, off_t *size, off_t boss_mem, int flag)
Definition: iso_tree.c:1415

References SfileadrL, XorrisO::wdi, Xorriso_alloc_meM, Xorriso_fake_stbuf(), Xorriso_free_meM, Xorriso_make_abs_adr(), and Xorriso_show_du_subs().

Referenced by Xorriso_update_interpreter().

◆ Xorriso_get_local_charset()

int Xorriso_get_local_charset ( struct XorrisO xorriso,
char **  name,
int  flag 
)

Definition at line 476 of file lib_mgt.c.

477 {
478  (*name)= iso_get_local_charset(0);
479  return(1);
480 }

Referenced by Xorriso_make_iso_write_opts(), Xorriso_option_charset(), Xorriso_status(), and Xorriso_write_session().

◆ Xorriso_get_md5()

int Xorriso_get_md5 ( struct XorrisO xorriso,
void *  in_node,
char *  path,
char  md5[16],
int  flag 
)

Definition at line 1339 of file iso_tree.c.

1341 {
1342  int ret= 1, i;
1343  char *wpt;
1344  IsoImage *image;
1345  IsoNode *node;
1346 
1347  ret= Xorriso_get_volume(xorriso, &image, 0);
1348  if(ret <= 0)
1349  goto ex;
1350  node= (IsoNode *) in_node;
1351  if(node == NULL) {
1352  ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0);
1353  if(ret<=0)
1354  goto ex;
1355  }
1356  if(!LIBISO_ISREG(node))
1357  return(0);
1358  ret= iso_file_get_md5(image, (IsoFile *) node, md5, 0);
1359  Xorriso_process_msg_queues(xorriso,0);
1360  if(ret <= 0)
1361  goto ex;
1362  if(flag & 1)
1363  {ret= 1; goto ex;}
1364 
1365  wpt= xorriso->result_line;
1366  for(i= 0; i < 16; i++) {
1367  sprintf(wpt, "%2.2x", ((unsigned char *) md5)[i]);
1368  wpt+= 2;
1369  }
1370  strcpy(wpt, " ");
1371  wpt+= 2;
1372  Xorriso_getfname(xorriso, path, 1 | 2);
1373  ret= 1;
1374 ex:;
1375  return(ret);
1376 }