[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: xorriso: how to find fixed-string filenames?



> Date: Wed, 16 Apr 2014 10:25:43 +0200
> From: Thomas Schmitt <scdbackup@gmx.net>
> 
> Do i get it right that you want to get a non-zero exit value from
> the program run if none of the files in the list exists in the ISO ?
 
In fact in this case I wanted the simplest beahaviour to abort on any
error: stop if the iso is invalid, stop if any file cannot be found.

> Maybe you would be better off with a simple -ls command while
> wildcard expansion is disabled by -iso_rr_pattern "off":
> 
>   $ xorriso -indev /some/non-ISO \
>             -return_with WARNING 32 -report_about WARNING \
>             -iso_rr_pattern off \
>             -ls "/such*.c" --
>   GNU xorriso 1.3.7 : RockRidge filesystem manipulator, libburnia project.
> 
>   xorriso : WARNING : Not found in ISO image: '/such*.c'
> 
> although a file /such.c does exist in the ISO image. It would be
> listed without warning if -iso_rr_pattern was set to "on" or to "ls".

Thanks for the tip.  The command -lsdl is what I needed; I had
overlooked it and thought that -find was the canonical way to list files
verbosily as it is the only way to list recursively.

> You already get a warning when loading a non-ISO-image.
> 
>   $ xorriso -indev /some/non-ISO \
>             -return_with WARNING 32 -report_about WARNING
>   GNU xorriso 1.3.7 : RockRidge filesystem manipulator, libburnia project.
> 
>   libisoburn: WARNING : No ISO 9660 image at LBA 0. Creating blank image.
>   $ echo $?
>   32
> 
> The commands -report_about and -return_with are already in effect
> when the interpretation of -indev happens. That's because more than
> one such setting might be desired. By this rule they do not have to
> fight for being first command in the list.
> (Normally commands get into effect only after all previous commands
>  in the argument list have been executed.)
> 
> If you really want to tolerate a WARNING with -indev and later take
> WARNING as cause for a non-zero exit value, then you first have to
> set the event thresholds to a higher severity for the duration
> of the -indev command:
> 
>   xorriso -return_with FAILURE 32 -report_about WARNING \
>           -indev /some/non-ISO \
>           -return_with WARNING 32 \
>           -find ...
 
In fact for what I wanted, it seems that the solution is -abort_on:

  $ xorriso -indev img.iso -abort_on WARNING -iso_rr_pattern off \
      -lsdl /file1 /file2
  # to fail earlier:
  $ xorriso -indev img.iso -abort_on WARNING -iso_rr_pattern off \
      -lsdl /file1 -- -lsdl /file2
  # to list all the files:
  $ xorriso -indev img.iso -abort_on WARNING -find / -exec lsdl

There is one small shortcoming though: if the input image is not an iso
but is filled with only nulls (or is empty), then xorriso does not fail:

  $ dd if=/dev/zero of=null.iso count=10; \
    xorriso -indev null.iso -abort_on WARNING -find / -exec lsdl &&
    echo "SUCCESS on null image"
 
> If you just want to know whether a data file is an ISO image
> or not, you could also use the shell command "file"
> 
>   $ file test.iso
>   test.iso: ISO 9660 CD-ROM filesystem data '...Volume.Id...'
> 
>   $ file not_an_iso
>   not_an_iso: ASCII text

I had expected that such a complex piece as xorriso would be able to do
that itself (testing that the input is blank).

  $ xorriso -indev null.iso -abort_on WARNING -find / -exec lsdl &&
    file null.iso | grep -qF null.iso': ISO 9660 '

-------------------------------------------------------------------

> > The system find has a similar issue, but there is a way to find fixed
> > filenames by using the option -exec
> 
> In xorriso's -find, -exec is not a test and can only appear once.

That is why I suggested a different name of -fexec that would be a test.

> > Would you consider adding a -fexec to your -find to use a system command
> > to test a filename (and maybe more than the filename)?
> 
> That would be applicable to disk files, but not to files in the
> ISO image.
> It would be quite some effort to enable multiple -exec with arbitrary
> xorriso commands and to attribute exit values to those commands.
> This feature of POSIX "find" depends on the concept of a shell resp.
> of POSIX program execution. xorriso would have to mimic this.

What I had in mind is the possibility to make arbitrary tests against
the filename only (that would be passed on the command line of a system
command) and possibly against other attributes like size, mode, time
that would be passed as environement variables ISO_SIZE, ISO_MODE etc.

  $ xorriso -indev img.iso -find \
      -fexec sh -c 'test "$1" = "$2" || test $ISO_MODE = 755' s "$name" '{}' \; \
      -exec lsdl


On Wed, Apr 16, 2014 at 05:00:30PM +0200, Thomas Schmitt wrote:
> Date: Wed, 16 Apr 2014 17:00:30 +0200
> From: Thomas Schmitt <scdbackup@gmx.net>
> 
> i now understand why command -ls is not what you need:
> It warns if any of the given files is missing.
> You want a warning if all given files are missing.

Nope.  This time I wanted a simple behaviour of failing on the first
error (which includes a missing file).

> So i implemented two new -find tests:
> 
>   -use_pattern   "on"|"off"   :  This  pseudo  test  controls  the
>       interpretation of wildcards with tests -name,  -whole_name,  and
>       -disk_name.  Default  is  "on". If interpretation is disabled by
>       "off", then the parameters of -name, -wholename, and  -disk_name
>       have  to  match  literally  rather than as search pattern.  This
>       test itself does always match.
> 
>   -or_use_pattern   "on"|"off"   :    Like    -use_pattern,    but
>       automatically  appending  the  test  by -or rather than by -and.
>       Further the test itself does never match. So a  subsequent  test
>       -or will cause its other operand to be performed.

However this is still useful to list directories recursively and fail if
one is not found.

  $ xorriso -indev img.iso -abort_on WARNING \
      -find -use_pattern off /dir -exec lsdl -- \
      -find -use_pattern off /file -exec lsdl
  # or to list as many files as possible then fail:
  $ xorriso -abort_on WARNING -indev img.iso -abort_on FATAL \
      -find -use_pattern off /dir -exec lsdl -- \
      -find -use_pattern off /file -exec lsdl

I think that it is important to have the possibility to disable patterns
(or regexps), as the alternative is often to have to escape them, which
is not portable I believe, and always painful to write since there is
no standard command to do that for you.  For example I always found it
surprising that there is no standard easy way on UNIX-like systems to
substitute an arbitrary fixed string by another inside a stream, although
it is possible in a filename by using rename(1).

> Your example could look like
> 
>   xorriso -indev image.iso -return_with WARNING 32 -report_about WARNING \
>     -find / -use_pattern off \
>             -wholename "$name1" -or -wholename "$name2" -exec lsdl

This does not even fail when none of the files are found.

> This feature is now in the SVN of libisoburn.

I haven't had a chance to test it yet.

Regards
-- 
G.raud Meyer


Reply to: