From c68d4f2ec654859182debd31cc6acd679ab8c025 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Tue, 27 Aug 2024 22:52:49 +0200 Subject: [PATCH] Enabled more tests for findx: -has_acl, -has_xattr, -has_any_xattr, -disk_name, -disk_path, -bad_outname, -size --- xorriso/iso_manip.c | 87 +++++++++++++++++++++++++---------- xorriso/iso_tree.c | 3 +- xorriso/xorriso.1 | 15 ++++-- xorriso/xorriso.info | 91 +++++++++++++++++++------------------ xorriso/xorriso.texi | 15 ++++-- xorriso/xorriso_timestamp.h | 2 +- 6 files changed, 133 insertions(+), 80 deletions(-) diff --git a/xorriso/iso_manip.c b/xorriso/iso_manip.c index 30589007..8f77c532 100644 --- a/xorriso/iso_manip.c +++ b/xorriso/iso_manip.c @@ -2460,8 +2460,9 @@ int Xorriso_estimate_file_size(struct XorrisO *xorriso, struct FindjoB *job, /* @param flag bit0= do not compare but print input and back converted name + bit1= if node is NULL: this is a directory */ -int Xorriso_test_outchar(struct XorrisO *xorriso, void *node_pt, +int Xorriso_test_outchar(struct XorrisO *xorriso, void *node_pt, char *in_name, int name_space, int flag) { IsoNode *node; @@ -2485,14 +2486,20 @@ int Xorriso_test_outchar(struct XorrisO *xorriso, void *node_pt, ret= -1; goto ex; } - if(iso_node_get_type(node) == LIBISO_DIR) - name_space |= 256; - name_space|= 512; /* no error messages */ - - name= (char *) iso_node_get_name(node); + if(node == NULL) { + if(flag & 2) + name_space|= 256; + name= in_name; + } else { + if(iso_node_get_type(node) == LIBISO_DIR) + name_space|= 256; + name= (char *) iso_node_get_name(node); + } if(name == NULL) { ret= 1; goto ex; } + name_space|= 512; /* no error messages */ + ret= isoburn_conv_name_chars(sopts, name, strlen(name), &result, &result_len, name_space); if(ret <= 0) { @@ -2940,7 +2947,7 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job, ret= 1; } else if(action == 50) { /* print_outname */ - ret= Xorriso_test_outchar(xorriso, (void *) node, type, 1); + ret= Xorriso_test_outchar(xorriso, (void *) node, "", type, 1); if(ret <= 0) return(ret); @@ -3111,7 +3118,7 @@ return: off_t start_lba; uint64_t lfa_flags, node_flags; void *arg1, *arg2; - char ft, *decision, md5[16], bless_code[17]; + char ft, *decision, md5[16], bless_code[17], *acl_text= NULL; regmatch_t name_match; off_t damage_start, damage_end, size, *section_sizes= NULL, size_arg; void *xinfo_dummy; @@ -3128,8 +3135,9 @@ return: if(node == NULL) { switch(ftest->test_type) { - case 0: case 1: case 2: case 4: case 11: case 12: case 13: - case 22: case 23: case 25: case 26: case 28: case 29: + case 0: case 1: case 2: case 4: case 5: case 6: + case 11: case 12: case 13: case 14: case 16: case 20: case 21: + case 22: case 23: case 25: case 26: case 27: case 28: case 29: /* Tests which need no node parameter or can work without it */ break; default: @@ -3143,6 +3151,7 @@ return: value= 0; break; case 1: /* -name *arg1 (regex in *arg2) */ +test_name:; if (ftest->boss->use_pattern) { ret= regexec(arg2, name, 1, &name_match, 0); value= !ret; @@ -3225,7 +3234,23 @@ return: } break; case 5: /* -has_acl */ - ret = Xorriso_getfacl(xorriso, (void *) node, "", NULL, 2); + if(node == NULL) { + value= 0; + ret= Xorriso_local_getfacl(xorriso, path, &acl_text, 16); + if(acl_text != NULL) + Xorriso_local_getfacl(xorriso, "", &acl_text, 1 << 15); + if(ret == 1) { + value= 1; + } else if(S_ISDIR(stbuf->st_mode)) { + ret= Xorriso_local_getfacl(xorriso, path, &acl_text, 1 | 16); + if(acl_text != NULL) + Xorriso_local_getfacl(xorriso, "", &acl_text, 1 << 15); + if(ret == 1) + value= 1; + } + } else { + ret= Xorriso_getfacl(xorriso, (void *) node, "", NULL, 2); + } if(ret <= 0) { value= -1; Xorriso_process_msg_queues(xorriso, 0); @@ -3235,8 +3260,9 @@ return: break; case 6: /* -has_xattr */ case 14: /* -has_any_xattr */ - ret = Xorriso_getfattr(xorriso, (void *) node, "", NULL, - 64 | (8 * (ftest->test_type == 14))); + ret = Xorriso_getfattr(xorriso, (void *) node, path, NULL, + (2 * (node == NULL)) | (8 * (ftest->test_type == 14)) | + 64 | 128); if(ret < 0) { value= -1; Xorriso_process_msg_queues(xorriso, 0); @@ -3297,8 +3323,12 @@ return: value= (ret > 0); break; case 16: /* -disk_name *arg1 (regex in *arg2) */ - value= !! Exprtest_match_disk_name(xorriso, ftest, node, - 2 * (ftest->boss->use_pattern)); + if(node == NULL) { + goto test_name; + } else { + value= !! Exprtest_match_disk_name(xorriso, ftest, node, + 2 * (ftest->boss->use_pattern)); + } break; case 17: /* -hidden int *arg1 */ value= 1; @@ -3338,11 +3368,16 @@ return: } break; case 20: /* -disk_path */ - value= !! Exprtest_match_disk_name(xorriso, ftest, node, - 1 | 2 * (ftest->boss->use_pattern)); + if(node == NULL) { + value= (strcmp(path, ftest->arg1) == 0); + } else { + value= !! Exprtest_match_disk_name(xorriso, ftest, node, + 1 | 2 * (ftest->boss->use_pattern)); + } break; case 21: /* -bad_outname */ - ret= Xorriso_test_outchar(xorriso, node, *((int *) arg1), 0); + ret= Xorriso_test_outchar(xorriso, node, name, *((int *) arg1), + 2 * !!S_ISDIR(stbuf->st_mode)); if(ret < 0) { value= -1; goto ex; @@ -3371,12 +3406,16 @@ return: break; case 27: /* -size */ size_arg= *((off_t *) arg1); size_mode= *((int *) arg2); - ret= Xorriso__get_file_size(node, &size, 0); - if(ret <= 0) { - if(ret < 0) - Xorriso_process_msg_queues(xorriso, 0); - value= 0; - goto ex; + if(node == NULL) { + size= stbuf->st_size; + } else { + ret= Xorriso__get_file_size(node, &size, 0); + if(ret <= 0) { + if(ret < 0) + Xorriso_process_msg_queues(xorriso, 0); + value= 0; + goto ex; + } } if(size_mode == 0) { value= (size == size_arg); diff --git a/xorriso/iso_tree.c b/xorriso/iso_tree.c index d058c22c..717ba918 100644 --- a/xorriso/iso_tree.c +++ b/xorriso/iso_tree.c @@ -823,6 +823,7 @@ too_long: bit5= in case of symbolic link on disk: inquire link target bit6= check for existence of xattr, return 0 or 1 (depends also on bit3) + bit7= ignore bit10 of xorriso->do_aaip (i.e. no -xattr any) */ int Xorriso_getfattr(struct XorrisO *xorriso, void *in_node, char *path, char **attr_text, int flag) @@ -833,7 +834,7 @@ int Xorriso_getfattr(struct XorrisO *xorriso, void *in_node, char *path, if(attr_text != NULL) *attr_text= NULL; - if((xorriso->do_aaip & 1024) && !(flag & 8)) + if((xorriso->do_aaip & 1024) && !((flag & 8) || (flag & 128))) flag|= 8 | 16; ret= Xorriso_get_attrs(xorriso, in_node, path, &num_attrs, &names, &value_lengths, &values, flag & (2 | 8 | 32)); diff --git a/xorriso/xorriso.1 b/xorriso/xorriso.1 index eeec8e30..a35daa2f 100644 --- a/xorriso/xorriso.1 +++ b/xorriso/xorriso.1 @@ -5117,12 +5117,17 @@ Similar to shell command du \-sk. Like \-find but operating on local filesystem and not on the ISO image. This is subject to the settings of \-follow. .br -\-findx accepts the same tests as \-find. But except the following ones, they -will be defaulted to \-false: +\-findx accepts the same tests as \-find, but only the following ones work +like described with \-find: .br - \-name, \-type, \-lba_range, \-decision, \-prune, \-wholename, - \-use_pattern, \-or_use_pattern, \-maxdepth, \-mindepth, - \-has_lfa_flags, \-has_some_lfa_flags_of + \-bad_outname, \-decision, \-disk_name, \-disk_path, \-has_acl, + \-has_any_xattr, \-has_lfa_flags, \-has_some_lfa_flags_of, + \-has_xattr, \-lba_range, \-maxdepth, \-mindepth, \-name, + \-or_use_pattern, \-prune, \-size, \-true, \-type, + \-use_pattern, \-wholename +.br +The others get defaulted to \-false, because they are not applicable to disk +files. .br Test \-type accepts the same parameters as with \-find. Additionally it recognizes type "mountpoint" (or "m") which matches subdirectories which reside diff --git a/xorriso/xorriso.info b/xorriso/xorriso.info index 89f7bbc1..467d5012 100644 --- a/xorriso/xorriso.info +++ b/xorriso/xorriso.info @@ -4297,11 +4297,14 @@ File: xorriso.info, Node: Navigate, Next: Verify, Prev: Inquiry, Up: Command -findx disk_path [test [op] [test ...]] [-exec action [params]] -- Like -find but operating on local filesystem and not on the ISO image. This is subject to the settings of -follow. - -findx accepts the same tests as -find. But except the following - ones, they will be defaulted to -false: - -name, -type, -lba_range, -decision, -prune, -wholename, - -use_pattern, -or_use_pattern, -maxdepth, -mindepth, - -has_lfa_flags, -has_some_lfa_flags_of + -findx accepts the same tests as -find, but only the following ones + work like described with -find: + -bad_outname, -decision, -disk_name, -disk_path, -has_acl, + -has_any_xattr, -has_lfa_flags, -has_some_lfa_flags_of, -has_xattr, + -lba_range, -maxdepth, -mindepth, -name, -or_use_pattern, -prune, + -size, -true, -type, -use_pattern, -wholename + The others get defaulted to -false, because they are not applicable + to disk files. Test -type accepts the same parameters as with -find. Additionally it recognizes type "mountpoint" (or "m") which matches subdirectories which reside on a different device than their @@ -6009,9 +6012,9 @@ File: xorriso.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: Top * -close_filter_list bans filter registration: Filter. (line 50) * -commit writes pending ISO image: Writing. (line 27) * -commit_eject writes and ejects: Writing. (line 53) -* -compare reports ISO/disk differences: Navigate. (line 153) -* -compare_l reports ISO/disk differences: Navigate. (line 169) -* -compare_r reports ISO/disk differences: Navigate. (line 165) +* -compare reports ISO/disk differences: Navigate. (line 156) +* -compare_l reports ISO/disk differences: Navigate. (line 172) +* -compare_r reports ISO/disk differences: Navigate. (line 168) * -compliance controls standard compliance: SetWrite. (line 62) * -concat copies ISO file content: Restore. (line 148) * -copyright_file sets copyright file name: SetWrite. (line 266) @@ -6179,8 +6182,8 @@ File: xorriso.info, Node: CommandIdx, Next: ConceptIdx, Prev: Legal, Up: Top * -setfattr_r sets xattr in ISO image: Manip. (line 118) * -set_filter applies filter to file: Filter. (line 58) * -set_filter_r applies filter to file tree: Filter. (line 84) -* -show_stream shows data source and filters: Navigate. (line 173) -* -show_stream_r shows data source and filters: Navigate. (line 191) +* -show_stream shows data source and filters: Navigate. (line 176) +* -show_stream_r shows data source and filters: Navigate. (line 194) * -sh_style_result makes results look more like shell: Scripting. (line 63) * -signal_handling controls handling of system signals: Exception. @@ -6315,8 +6318,8 @@ File: xorriso.info, Node: ConceptIdx, Prev: CommandIdx, Up: Top * Filter, apply to file, -set_filter: Filter. (line 58) * Filter, ban registration, -close_filter_list: Filter. (line 50) * Filter, register, -external_filter: Filter. (line 20) -* Filter, show chain, -show_stream: Navigate. (line 173) -* Filter, show chains of tree, -show_stream_r: Navigate. (line 191) +* Filter, show chain, -show_stream: Navigate. (line 176) +* Filter, show chains of tree, -show_stream_r: Navigate. (line 194) * Filter, unregister, -unregister_filter: Filter. (line 47) * Filter, zisofs parameters, -zisofs: SetWrite. (line 317) * Filter, _definition: Filter. (line 6) @@ -6520,9 +6523,9 @@ File: xorriso.info, Node: ConceptIdx, Prev: CommandIdx, Up: Top * Unsuitable media states, _definition: Media. (line 25) * UTF-16, for Joliet paths, -compliance: SetWrite. (line 114) * Verify, check blocks, -check_media: Verify. (line 21) -* Verify, compare ISO and disk file, -compare: Navigate. (line 153) -* Verify, compare ISO and disk tree, -compare_r: Navigate. (line 165) -* Verify, compare ISO and disk, -compare_l: Navigate. (line 169) +* Verify, compare ISO and disk file, -compare: Navigate. (line 156) +* Verify, compare ISO and disk tree, -compare_r: Navigate. (line 168) +* Verify, compare ISO and disk, -compare_l: Navigate. (line 172) * Verify, file checksum, -check_md5: Verify. (line 184) * Verify, file tree checksums, -check_md5_r: Verify. (line 198) * Verify, preset -check_media, -check_media_defaults: Verify. (line 40) @@ -6584,34 +6587,34 @@ Node: Exception208836 Node: DialogCtl215025 Node: Inquiry217627 Node: Navigate230192 -Node: Verify240074 -Node: Restore251223 -Node: Emulation263430 -Node: Scripting273886 -Node: Frontend281780 -Node: Examples291406 -Node: ExDevices292584 -Node: ExCreate293245 -Node: ExDialog294545 -Node: ExGrowing295816 -Node: ExModifying296625 -Node: ExBootable297135 -Node: ExCharset297690 -Node: ExPseudo298586 -Node: ExCdrecord299513 -Node: ExMkisofs299833 -Node: ExGrowisofs301730 -Node: ExException302883 -Node: ExTime303341 -Node: ExIncBackup303799 -Node: ExRestore307825 -Node: ExRecovery308771 -Node: Files309343 -Node: Environ310677 -Node: Seealso311425 -Node: Bugreport312189 -Node: Legal312780 -Node: CommandIdx313792 -Node: ConceptIdx332121 +Node: Verify240256 +Node: Restore251405 +Node: Emulation263612 +Node: Scripting274068 +Node: Frontend281962 +Node: Examples291588 +Node: ExDevices292766 +Node: ExCreate293427 +Node: ExDialog294727 +Node: ExGrowing295998 +Node: ExModifying296807 +Node: ExBootable297317 +Node: ExCharset297872 +Node: ExPseudo298768 +Node: ExCdrecord299695 +Node: ExMkisofs300015 +Node: ExGrowisofs301912 +Node: ExException303065 +Node: ExTime303523 +Node: ExIncBackup303981 +Node: ExRestore308007 +Node: ExRecovery308953 +Node: Files309525 +Node: Environ310859 +Node: Seealso311607 +Node: Bugreport312371 +Node: Legal312962 +Node: CommandIdx313974 +Node: ConceptIdx332303  End Tag Table diff --git a/xorriso/xorriso.texi b/xorriso/xorriso.texi index e306b02e..ff62d180 100644 --- a/xorriso/xorriso.texi +++ b/xorriso/xorriso.texi @@ -5838,12 +5838,17 @@ Similar to shell command du -sk. Like -find but operating on local filesystem and not on the ISO image. This is subject to the settings of -follow. @* --findx accepts the same tests as -find. But except the following ones, they -will be defaulted to -false: +-findx accepts the same tests as -find, but only the following ones work +like described with -find: @* - -name, -type, -lba_range, -decision, -prune, -wholename, - -use_pattern, -or_use_pattern, -maxdepth, -mindepth, - -has_lfa_flags, -has_some_lfa_flags_of + -bad_outname, -decision, -disk_name, -disk_path, -has_acl, + -has_any_xattr, -has_lfa_flags, -has_some_lfa_flags_of, + -has_xattr, -lba_range, -maxdepth, -mindepth, -name, + -or_use_pattern, -prune, -size, -true, -type, + -use_pattern, -wholename +@* +The others get defaulted to -false, because they are not applicable to disk +files. @* Test -type accepts the same parameters as with -find. Additionally it recognizes type "mountpoint" (or "m") which matches subdirectories which reside diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index 9733ec9a..ec523365 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2024.08.27.160729" +#define Xorriso_timestamP "2024.08.27.205212"