diff --git a/libisoburn/branches/ZeroFourTwo/AUTHORS b/libisoburn/branches/ZeroFourTwo/AUTHORS new file mode 100644 index 00000000..0547ea18 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/AUTHORS @@ -0,0 +1,3 @@ +Thomas Schmitt +Vreixo Formoso Lopes + diff --git a/libisoburn/branches/ZeroFourTwo/CONTRIBUTORS b/libisoburn/branches/ZeroFourTwo/CONTRIBUTORS new file mode 100644 index 00000000..e69de29b diff --git a/libisoburn/branches/ZeroFourTwo/COPYING b/libisoburn/branches/ZeroFourTwo/COPYING new file mode 100644 index 00000000..5a965fbc --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/COPYING @@ -0,0 +1,280 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS diff --git a/libisoburn/branches/ZeroFourTwo/COPYRIGHT b/libisoburn/branches/ZeroFourTwo/COPYRIGHT new file mode 100644 index 00000000..49f817e9 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/COPYRIGHT @@ -0,0 +1,22 @@ +Mario Danic , +Vreixo Formoso +Thomas Schmitt +libisoburn is Copyright (C) 2007-2009 Vreixo Formoso, Thomas Schmitt +xorriso is Copyright (C) 2007-2009 Thomas Schmitt +libisofs (if included) is Copyright (C) 2007-2009 Vreixo Formoso, Mario Danic +libburn (if included) is Copyright (C) 2002-2006 Derek Foreman, Ben Jansens + and Copyright (C) 2006-2009 Mario Danic, Thomas Schmitt + + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License version 2 as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA diff --git a/libisoburn/branches/ZeroFourTwo/INSTALL b/libisoburn/branches/ZeroFourTwo/INSTALL new file mode 100644 index 00000000..a6580e5a --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/INSTALL @@ -0,0 +1,237 @@ + +See file README for libisoburn and xorriso specific installation instructions. +This file here is rather a manual for advanced usage of ./configure + +------------------------------------------------------------------- + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006 Free Software Foundation, Inc. + +This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + +Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. + + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + +Some systems require unusual options for compilation or linking that the +`configure' script does not know about. Run `./configure --help' for +details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + +You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you can use GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + +Installation Names +================== + +By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + +Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + +There may be some features `configure' cannot figure out automatically, +but needs to determine by the type of machine the package will run on. +Usually, assuming the package is built to be run on the _same_ +architectures, `configure' can figure that out, but if it prints a +message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + +If you want to set default values for `configure' scripts to share, you +can create a site shell script called `config.site' that gives default +values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + +Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: + + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + +`configure' recognizes the following options to control how it operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/libisoburn/branches/ZeroFourTwo/Makefile.am b/libisoburn/branches/ZeroFourTwo/Makefile.am new file mode 100644 index 00000000..e348bcc9 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/Makefile.am @@ -0,0 +1,176 @@ + +# ts A90315 : LIBBURNIA_PKGCONFDIR is defined OS specific in acinclude.m4 +# was: pkgconfigdir=$(libdir)/pkgconfig +pkgconfigdir=$(LIBBURNIA_PKGCONFDIR) + +libincludedir=$(includedir)/libisoburn + +lib_LTLIBRARIES = libisoburn/libisoburn.la + +## ========================================================================= ## + +# Build libraries +libisoburn_libisoburn_la_LDFLAGS = \ + -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) +libisoburn_libisoburn_la_SOURCES = \ + libisoburn/burn_wrap.c \ + libisoburn/data_source.c \ + libisoburn/isoburn.c \ + libisoburn/isoburn.h \ + libisoburn/isofs_wrap.c \ + libisoburn/libisoburn.h \ + version.h + +libisoburn_libisoburn_la_LIBADD = \ + -lisofs \ + -lburn + +libinclude_HEADERS = \ + libisoburn/libisoburn.h + +## ========================================================================= ## + + +# This is the reference application of libisoburn. See man xorriso/xorriso.1 +# +bin_PROGRAMS = \ + xorriso/xorriso + +# This looks quite ugly with make install: xorriso.c is compiled twice again +# +# Trying to create a build timestamp file +# +# BUILT_SOURCES = xorriso/xorriso_buildstamp.h +# +# phony targets get rebuilt every time +# +# .PHONY: xorriso/xorriso_buildstamp.h +# xorriso/xorriso_buildstamp.h: +# date -u '+#define Xorriso_build_timestamP "%Y.%m.%d.%H%M%S"' >xorriso/xorriso_buildstamp.h +# cat xorriso/xorriso_buildstamp.h + +xorriso_xorriso_CPPFLAGS = -Ilibisoburn +xorriso_xorriso_CFLAGS = -DXorriso_with_maiN \ + $(READLINE_DEF) $(LIBACL_DEF) $(XATTR_DEF) \ + $(EXTF_DEF) $(EXTF_SUID_DEF) $(ZLIB_DEF) + +xorriso_xorriso_LDADD = libisoburn/libisoburn.la -lisofs -lburn \ + $(THREAD_LIBS) $(LIBBURN_ARCH_LIBS) + +xorriso_xorriso_SOURCES = \ + xorriso/xorriso.h \ + xorriso/xorriso_private.h \ + xorriso/xorriso.c \ + xorriso/xorrisoburn.h \ + xorriso/xorrisoburn.c \ + xorriso/xorriso_timestamp.h \ + xorriso/xorriso_buildstamp.h + + +# Install symbolic links to the xorriso binary +# +install-exec-hook: + if test -e "$(DESTDIR)$(bindir)"/xorrisofs ; then rm "$(DESTDIR)$(bindir)"/xorrisofs ; else echo ; fi + ln -s xorriso "$(DESTDIR)$(bindir)"/xorrisofs + if test -e "$(DESTDIR)$(bindir)"/osirrox ; then rm "$(DESTDIR)$(bindir)"/osirrox ; else echo ; fi + ln -s xorriso "$(DESTDIR)$(bindir)"/osirrox + if test -e "$(DESTDIR)$(bindir)"/xorrecord ; then rm "$(DESTDIR)$(bindir)"/xorrecord ; else echo ; fi + ln -s xorriso "$(DESTDIR)$(bindir)"/xorrecord + + +# Alternative to the disabled .PHONY above. +# Trying to create a build timestamp file semi-manually: make buildstamped +# +buildstamp: + date -u '+#define Xorriso_build_timestamP "%Y.%m.%d.%H%M%S"' >xorriso/xorriso_buildstamp.h + cat xorriso/xorriso_buildstamp.h + +# For now make buildstamped has to be performed explicitely. +buildstamped: buildstamp + make + + + +## Build test applications +noinst_PROGRAMS = \ + test/compare_file + +# A program to compare two files in mirrored trees in mounted filesystems +# To compare tree /media/dvd and /original/dir : +# find /media/dvd -exec test/compare_file '{}' /media/dvd /original/dir ';' +# +test_compare_file_CPPFLAGS = +test_compare_file_CFLAGS = +test_compare_file_LDADD = +test_compare_file_SOURCES = test/compare_file.c + + +## ========================================================================= ## + +## Build documentation (You need Doxygen for this to work) +webhost = http://libburn-api.pykix.org +webpath = / +docdir = $(DESTDIR)$(prefix)/share/doc/$(PACKAGE)-$(VERSION) + +doc: doc/html + +doc/html: doc/doxygen.conf + if [ -f ./doc/doc.lock ]; then \ + $(RM) -r doc/html; \ + doxygen doc/doxygen.conf; \ + fi + +doc-upload: doc/html + scp -r $ + and Thomas Schmitt +Integrated sub project of libburnia-project.org. +http://files.libburnia-project.org/releases/libisoburn-0.4.0.pl00.tar.gz +Copyright (C) 2006-2009 Vreixo Formoso, Thomas Schmitt. +Provided under GPL version 2. +------------------------------------------------------------------------------ + +libisoburn is a frontend for libraries libburn and libisofs which enables +creation and expansion of ISO-9660 filesystems on all CD/DVD/BD media supported +by libburn. This includes media like DVD+RW, which do not support multi-session +management on media level and even plain disk files or block devices. + +The price for that is thorough specialization on data files in ISO-9660 +filesystem images. So libisoburn is not suitable for audio (CD-DA) or any +other CD layout which does not entirely consist of ISO-9660 sessions. + +Currently it is fully supported on Linux with kernels >= 2.4 and on +FreeBSD versions with ATAPI/CAM support enabled in the kernel, see atapicam(4). +On other X/Open compliant systems libburn will only offer POSIX i/o with disk +file objects, but no direct MMC operation on CD/DVD/BD drives. + +By using this software you agree to the disclaimer at the end of this text: +"... without even the implied warranty ..." + + + Compilation, First Glimpse, Installation + +Dynamic library and compile time header requirements for libisoburn-0.4.0 : +- libburn.so.4 , version libburn-0.6.4 or higher +- libisofs.so.6 , version libisofs-0.6.20 or higher +libisoburn and xorriso will not start with libraries which are older than their +headers seen at compile time. + +Obtain libisoburn-0.4.0.pl00.tar.gz, take it to a directory of your choice +and do: + + tar xzf libisoburn-0.4.0.pl00.tar.gz + cd libisoburn-0.4.0 + +Within that directory execute: + + ./configure --prefix=/usr + make + +Then become superuser and execute + make install +which will make available libisoburn.so.1 and the program xorriso. + +For the API concepts and calls see + ./libisoburn/libisoburn.h +as well as + /usr/lib/libisofs/libisofs.h + /usr/lib/libburn/libburn.h + + + xorriso + +libisoburn comes with a command line and dialog application named xorriso, +which offers a substantial part of libisoburn features to shell scripts and +users. Its file xorriso/README describes a standalone tarball as first +preference for statically linked xorriso installation. +The libisoburn installation described above produces a dynamically linked +xorriso binary depending on libburn.so, libisofs.so, libisoburn.so. + +After installation documentation is available via + man xorriso + +Several alias links point to the xorriso binary: + xorrisofs starts xorriso with -as mkisofs emulation already enabled + xorrecord starts xorriso with -as cdrecord emulation already enabled + osirrox starts with -osirrox image-to-disk copying already enabled + +By default xorriso will depend on libreadline if the readline-dev headers +are present. This dependcy can be avoided by running + ./configure --prefix=/usr --disable-libreadline + make clean ; make +Never omit the "make clean" command after switching libreadline enabling. +Other deliberate dependency reduction options of ./configure are: + --disable-libacl avoid use of ACL functions like acl_to_text() + --disable-xattr avoid use of xattr functions like listxattr() + --disable-zlib avoid use of zlib functions like compress2() + +xorriso allows to use external processes as file content filters. This is +a potential security risk which may be avoided by ./configure option + --disable-external-filters +By default the filter feature is disabled if effective user id and real +user id differ. This ban can be lifted by + --enable-external-filters-setuid + + + Drives and Disk File Objects + +The user of libisoburn applications needs rw-permission for the CD/DVD burner +devices which shall be used. +A list of rw-accessible drives can be obtained by + xorriso -devices +resp. by libburn API call + burn_drive_scan() + + +A possible source of problems are hald or other automounters. +If you can spot a process "hald-addon-storage" with the address of +your desired drive, then consider to kill it. + +If you cannot get rid of the automounter that easily, try whether it helps +to always load the drive tray manually before starting a write run of +xorriso. Wait until the drive light is off. +Better try to unmount an eventually mounted media before a write run. + + +Besides true optical drives, libisoburn can also address disk files as input or +output drives. The addresses of the disk files have to be preceded by "stdio:". +Like: + "stdio:/tmp/pseudo_drive" + +Note: xorriso by default prefixes "stdio:" to addresses outside the /dev tree + if they do not lead to an optical drive device file. + + + Testing + +We are quite sure that libisofs produces accurate representations of the disk +files. This opinion is founded on a lot of test burns and checks by a little +test program which compares files from the mounted image with the orignals +on disk. It uses the normal POSIX filesystem calls, i.e. no libburnia stuff. + +This program is not installed systemwide but stays in the installation +directory of the xorriso tarball as test/compare_file . Usually it is +run as -exec payload of a find command. It demands at least three arguments: +The path of the file to compare, the prefix1 to be cut off from path +and the prefix2 which gets prepended afterwards to obtain the path of the +second file to compare. +As further argument there can be -no_ctime which suppresses the comparison +of ctime date stamps. +The exit value is 0 if no difference was detected, non-0 else. + +Example: After + xorriso ... -pathspecs on -add /=/original/dir -- + mount /media/dvd + cd test +compare tree /media/dvd with tree /original/dir : + find /original/dir -exec ./compare_file '{}' /original/dir /media/dvd ';' \ + | less +and vice versa: + find /media/dvd -exec ./compare_file '{}' /media/dvd /original/dir ';' \ + | less + + +------------------------------------------------------------------------------ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License version 2 as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +------------------------------------------------------------------------------ +Based on and sub project of: +libburnia-project.org +By Mario Danic , + Vreixo Formoso + Thomas Schmitt +Copyright (C) 2006-2009 Mario Danic, Vreixo Formoso, Thomas Schmitt. + +libburnia-project.org is inspired by and in other components still containing +parts of old +Libburn. By Derek Foreman and + Ben Jansens +Copyright (C) 2002-2006 Derek Foreman and Ben Jansens + diff --git a/libisoburn/branches/ZeroFourTwo/TODO b/libisoburn/branches/ZeroFourTwo/TODO new file mode 100644 index 00000000..23e3b643 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/TODO @@ -0,0 +1,11 @@ +[Task] Figure out how to use "Requires" in pc.in (libisoburn and libisofs would benefit) +[Task] Figure out the usage of Libs.private (used in libburn) +[Task] Improve build system +[Task] Investigate build system, so other libburnia components can benefit +[Task] Write Doxygen files +[Task] Explain to Thomas & Vreixo about NEWS importance (all libburnia components + will benefit +[Task] Write a document about ABI & API +[Task] Create following targets for make: Src, Indent, Docs, Test, All [Any other suggestions?) + +All those tasks are currently assigned to Mario. diff --git a/libisoburn/branches/ZeroFourTwo/acinclude.m4 b/libisoburn/branches/ZeroFourTwo/acinclude.m4 new file mode 100644 index 00000000..0b2c9af1 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/acinclude.m4 @@ -0,0 +1,120 @@ +AC_DEFUN([TARGET_SHIZZLE], +[ + ARCH="" + LIBBURNIA_PKGCONFDIR="$libdir"/pkgconfig + + AC_MSG_CHECKING([target operating system]) + + case $target in + *-*-linux*) + ARCH=linux + LIBBURN_ARCH_LIBS= + ;; + *-*-freebsd*) + ARCH=freebsd + LIBBURN_ARCH_LIBS=-lcam + + # This may later be overridden by configure --enable-libdir-pkgconfig + LIBBURNIA_PKGCONFDIR=$(echo "$libdir" | sed 's/\/lib$/\/libdata/')/pkgconfig + ;; + *) + ARCH= + LIBBURN_ARCH_LIBS= +# AC_ERROR([You are attempting to compile for an unsupported platform]) + ;; + esac + + AC_MSG_RESULT([$ARCH]) +]) + + +dnl LIBBURNIA_CHECK_ICONV is by Thomas Schmitt, libburnia project +dnl It is based on gestures from: +dnl iconv.m4 serial AM7 (gettext-0.18) +dnl Copyright (C) 2000-2002, 2007-2009 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl From Bruno Haible. +dnl +AC_DEFUN([LIBBURNIA_CHECK_ICONV], +[ + dnl Check whether it is allowed to link with -liconv + AC_MSG_CHECKING([for separate -liconv ]) + libburnia_liconv="no" + libburnia_save_LIBS="$LIBS" + LIBS="$LIBS -liconv" + AC_TRY_LINK([#include +#include ], + [iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);], + [libburnia_liconv="yes"], + [LIBS="$libburnia_save_LIBS"] + ) + AC_MSG_RESULT([$libburnia_liconv]) + + dnl Check for iconv(..., const char **inbuf, ...) + AC_MSG_CHECKING([for const qualifier with iconv() ]) + AC_TRY_COMPILE([ +#include +#include +size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); +], [], [libburnia_iconv_const=""], [libburnia_iconv_const="const"] + ) + AC_DEFINE_UNQUOTED([ICONV_CONST], [$libburnia_iconv_const]) + test -z "$libburnia_iconv_const" && libburnia_iconv_const="no" + AC_MSG_RESULT([$libburnia_iconv_const]) +]) + + +dnl LIBBURNIA_SET_PKGCONFIG determines the install directory for the *.pc file. +dnl Important: Must be performed _after_ TARGET_SHIZZLE +dnl +AC_DEFUN([LIBBURNIA_SET_PKGCONFIG], +[ +### for testing --enable-libdir-pkgconfig on Linux +### LIBBURNIA_PKGCONFDIR="$libdir"data/pkgconfig + +if test "x$LIBBURNIA_PKGCONFDIR" = "x$libdir"/pkgconfig +then + dummy=dummy +else + AC_ARG_ENABLE(libdir-pkgconfig, + [ --enable-libdir-pkgconfig Install to $libdir/pkgconfig on any OS, default=no], + , enable_libdir_pkgconfig="no") + AC_MSG_CHECKING([for --enable-libdir-pkgconfig]) + if test "x$enable_libdir_pkgconfig" = xyes + then + LIBBURNIA_PKGCONFDIR="$libdir"/pkgconfig + fi + AC_MSG_RESULT([$enable_libdir_pkgconfig]) +fi + +libburnia_pkgconfig_override="no" +AC_ARG_ENABLE(pkgconfig-path, +[ --enable-pkgconfig-path=DIR Absolute path of directory for libisofs-*.pc], +libburnia_pkgconfig_override="yes" , enable_pkgconfig_path="none") +AC_MSG_CHECKING([for overridden pkgconfig directory path]) +if test "x$enable_pkgconfig_path" = xno +then + libburnia_pkgconfig_override="no" +fi +if test "x$enable_pkgconfig_path" = x -o "x$enable_pkgconfig_path" = xyes +then + libburnia_pkgconfig_override="invalid argument" +fi +if test "x$libburnia_pkgconfig_override" = xyes +then + LIBBURNIA_PKGCONFDIR="$enable_pkgconfig_path" + AC_MSG_RESULT([$LIBBURNIA_PKGCONFDIR]) +else + AC_MSG_RESULT([$libburnia_pkgconfig_override]) +fi +AC_SUBST(LIBBURNIA_PKGCONFDIR) + +dnl For debugging only +### AC_MSG_RESULT([LIBBURNIA_PKGCONFDIR = $LIBBURNIA_PKGCONFDIR]) + +]) + diff --git a/libisoburn/branches/ZeroFourTwo/bootstrap b/libisoburn/branches/ZeroFourTwo/bootstrap new file mode 100755 index 00000000..3583d1c7 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/bootstrap @@ -0,0 +1,7 @@ +#!/bin/sh -x + +aclocal +libtoolize --copy --force +autoconf +automake --foreign --add-missing --copy --include-deps + diff --git a/libisoburn/branches/ZeroFourTwo/configure.ac b/libisoburn/branches/ZeroFourTwo/configure.ac new file mode 100644 index 00000000..81335bdb --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/configure.ac @@ -0,0 +1,234 @@ +AC_INIT([libisoburn], [0.4.1], [http://libburnia-project.org]) +AC_PREREQ([2.50]) +dnl AC_CONFIG_HEADER([config.h]) + +AC_CANONICAL_HOST +AC_CANONICAL_TARGET + +AM_INIT_AUTOMAKE([subdir-objects]) + +dnl Hint: Search list for version code aspects: +dnl /AC_INIT( +dnl /ISOBURN_.*_VERSION +dnl /LT_.* +dnl /LIB.*_REQUIRED + +dnl The API version codes are defined in libisoburn/libisoburn.h +dnl #define isoburn_header_version_* +dnl configure.ac only rules the libtool revision numbering about +dnl LT_CURREN, LT_AGE, LT_REVISION where SONAME becomes LT_CURRENT - LT_AGE +dnl +dnl These three are only copies to provide libtool with unused LT_RELEASE +ISOBURN_MAJOR_VERSION=0 +ISOBURN_MINOR_VERSION=4 +ISOBURN_MICRO_VERSION=1 + +dnl ISOBURN_VERSION=$ISOBURN_MAJOR_VERSION.$ISOBURN_MINOR_VERSION.$ISOBURN_MICRO_VERSION + +AC_SUBST(ISOBURN_MAJOR_VERSION) +AC_SUBST(ISOBURN_MINOR_VERSION) +AC_SUBST(ISOBURN_MICRO_VERSION) +dnl AC_SUBST(ISOBURN_VERSION) + +dnl Libtool versioning +dnl Generate libisoburn.so.1.x.y +dnl SONAME will become LT_CURRENT - LT_AGE +dnl +dnl ts A90628 +dnl ### This is the release version 0.4.0 = libisoburn.so.1.29.0 +dnl This is the development version after above stable release +dnl LT_CURRENT++, LT_AGE++ have not happened happened yet. +dnl ### LT_CURRENT++, LT_AGE++ has happened meanwhile. +dnl +dnl SONAME = 30 - 29 = 1 . Library name = libisoburn.so.1.29.0 +LT_RELEASE=$ISOBURN_MAJOR_VERSION.$ISOBURN_MINOR_VERSION +LT_CURRENT=30 +LT_AGE=29 +LT_REVISION=0 +LT_CURRENT_MINUS_AGE=`expr $LT_CURRENT - $LT_AGE` + +AC_SUBST(LT_RELEASE) +AC_SUBST(LT_CURRENT) +AC_SUBST(LT_REVISION) +AC_SUBST(LT_AGE) +AC_SUBST(LT_CURRENT_MINUS_AGE) + +AC_PREFIX_DEFAULT([/usr/local]) +test "$prefix" = "NONE" && prefix=$ac_default_prefix + +AM_MAINTAINER_MODE + +AM_PROG_CC_C_O +AC_C_CONST +AC_C_INLINE +AC_C_BIGENDIAN + +dnl Large file support +AC_SYS_LARGEFILE +AC_FUNC_FSEEKO +AC_CHECK_FUNC([fseeko]) +if test ! $ac_cv_func_fseeko; then + AC_ERROR([Libburn requires largefile support.]) +fi + +dnl If iconv(3) is in an extra lib, then it gets added to variable LIBS. +dnl If not, then no -liconv will be added. +AC_CHECK_LIB(iconv, iconv, , ) +dnl GNU iconv has no function iconv() but libiconv() and a macro iconv() +AC_CHECK_LIB(iconv, libiconv, , ) + +AC_PROG_LIBTOOL +AC_SUBST(LIBTOOL_DEPS) +LIBTOOL="$LIBTOOL --silent" + +AC_PROG_INSTALL + +AC_CHECK_HEADERS() + +THREAD_LIBS=-lpthread +AC_SUBST(THREAD_LIBS) + +TARGET_SHIZZLE +AC_SUBST(ARCH) +AC_SUBST(LIBBURNIA_PKGCONFDIR) +AC_SUBST(LIBBURN_ARCH_LIBS) + + +dnl Determine target directory for libisoburn-*.pc +dnl Important: Must be performed _after_ TARGET_SHIZZLE +dnl +LIBBURNIA_SET_PKGCONFIG + + +AC_ARG_ENABLE(libreadline, +[ --enable-libreadline Enable use of libreadline by xorriso, default=yes], + , enable_libreadline=yes) +if test x$enable_libreadline = xyes; then +dnl Check whether there is readline-devel and readline-runtime. +dnl If not, erase this macro which would enable use of readline(),add_history() + READLINE_DEF="-DXorriso_with_readlinE" +dnl The empty yes case obviously causes -lreadline to be linked + AC_CHECK_HEADER(readline/readline.h, AC_CHECK_LIB(readline, readline, , READLINE_DEF= ), READLINE_DEF= ) +dnl The X= in the yes case prevents that -lreadline gets linked twice + AC_CHECK_HEADER(readline/history.h, AC_CHECK_LIB(readline, add_history, X= , READLINE_DEF= ), READLINE_DEF= ) +else + READLINE_DEF= +fi +AC_SUBST(READLINE_DEF) + +dnl ts A90329 +dnl ACL and xattr do not need to be enabled in libisoburn or xorriso source +dnl but without AC_CHECK_LIB() xorriso will not be linked with -lacl . +dnl On my Linux this does work with an ACL enabled libisofs but in general +dnl it seems not be right. +dnl So for now it seems to be best to do the same configuration for libisoburn +dnl and xorriso as for libisofs. + +AC_ARG_ENABLE(libacl, +[ --enable-libacl Enable use of libacl by libisofs, default=yes], + , enable_libacl=yes) +if test x$enable_libacl = xyes; then +dnl Check whether there is libacl-devel and libacl-runtime. +dnl If not, erase this macro which would enable use of acl_to_text and others + LIBACL_DEF="-DLibisofs_with_aaip_acL" +dnl The empty yes case obviously causes -lacl to be linked + AC_CHECK_HEADER(sys/acl.h, AC_CHECK_LIB(acl, acl_to_text, , LIBACL_DEF= ), LIBACL_DEF= ) +else + LIBACL_DEF= +fi +AC_SUBST(LIBACL_DEF) + + +AC_ARG_ENABLE(xattr, +[ --enable-xattr Enable use of xattr by libisofs, default=yes], + , enable_xattr=yes) +if test x$enable_xattr = xyes; then +dnl Check whether there is the header for Linux xattr. +dnl If not, erase this macro which would enable use of listxattr and others + XATTR_DEF="-DLibisofs_with_aaip_xattR" + AC_CHECK_HEADER(attr/xattr.h, AC_CHECK_LIB(c, listxattr, X= , XATTR_DEF= ), XATTR_DEF= ) +else + XATTR_DEF= +fi +AC_SUBST(XATTR_DEF) + + +dnl ts A90409 +dnl Same situation as with xattr and ACL: libisoburn does not depend directly +dnl on zlib. But if it is enabled in libisofs then it seems wise to link it +dnl with libisoburn apps. +AC_ARG_ENABLE(zlib, +[ --enable-zlib Enable use of zlib by libisofs, default=yes], + , enable_zlib=yes) +if test x$enable_zlib = xyes; then +dnl Check whether there is the header for zlib. +dnl If not, erase this macro which would enable use of compress2() and others. +dnl The empty parameter after "compress2" causes -lz. + ZLIB_DEF="-DLibisofs_with_zliB" + AC_CHECK_HEADER(zlib.h, AC_CHECK_LIB(z, compress2, , ZLIB_DEF= ), ZLIB_DEF= ) +else + ZLIB_DEF= +fi +AC_SUBST(ZLIB_DEF) + + +AC_ARG_ENABLE(external-filters, +[ --enable-external-filters Enable use of external filter programs by xorriso, default=yes], + , enable_external_filters=yes) +if test x"$enable_external_filters" = xyes; then + EXTF_DEF="-DXorriso_allow_external_filterS" + echo "enabled xorriso external filter programs" +else + EXTF_DEF= + echo "disabled xorriso external filter programs" +fi +AC_SUBST(EXTF_DEF) + +AC_ARG_ENABLE(external-filters-setuid, +[ --enable-external-filters-setuid Enable xorriso external filter programs under setuid, default=no], + , enable_external_filters_setuid=no) +if test x$enable_external_filters_setuid = xyes; then + EXTF_SUID_DEF="-DXorriso_allow_extf_suiD" + echo "enabled xorriso external filter programs under setuid" +else + EXTF_SUID_DEF= + echo "disabled xorriso external filter programs under setuid" +fi +AC_SUBST(EXTF_SUID_DEF) + + +AC_CHECK_HEADER(libburn/libburn.h) +AC_CHECK_HEADER(libisofs/libisofs.h) + +dnl Check for proper library versions +LIBBURN_REQUIRED=0.7.0 +LIBISOFS_REQUIRED=0.6.22 +PKG_CHECK_MODULES(LIBBURN, libburn-1 >= $LIBBURN_REQUIRED) +PKG_CHECK_MODULES(LIBISOFS, libisofs-1 >= $LIBISOFS_REQUIRED) + +dnl Add compiler-specific flags + +dnl See if the user wants aggressive optimizations of the code +AC_ARG_ENABLE(debug, +[ --enable-debug Disable aggressive optimizations [default=yes]], + , enable_debug=yes) +if test x$enable_debug != xyes; then + if test x$GCC = xyes; then + CFLAGS="$CFLAGS -O3" + CFLAGS="$CFLAGS -fexpensive-optimizations" + fi + CFLAGS="$CFLAGS -DNDEBUG" +else + if test x$GCC = xyes; then + CFLAGS="$CFLAGS -g -pedantic -Wall" + fi + CFLAGS="$CFLAGS -DDEBUG" +fi + +AC_CONFIG_FILES([ + Makefile + doc/doxygen.conf + version.h + libisoburn-1.pc + ]) +AC_OUTPUT diff --git a/libisoburn/branches/ZeroFourTwo/doc/comments b/libisoburn/branches/ZeroFourTwo/doc/comments new file mode 100644 index 00000000..6d50d4e6 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/doc/comments @@ -0,0 +1,58 @@ +/** + @author Mario Danic, Vreixo Formoso, Thomas Schmitt + + @mainpage Libisoburn Documentation Index + + @section intro Introduction + +Libburnia is an open-source project for reading, mastering and writing +optical discs. This page is about its capability to read, manipulate, and +write ISO 9660 filesystems with Rock Ridge extensions. Media can be optical +media or filesystem objects. + +Our scope is currently Linux 2.4 and 2.6, or FreeBSD . + +libisoburn is an add-on to libburn and libisofs which coordinates both and +also allows to grow ISO-9660 filesystem images on multi-session media as well +as on overwriteable media via the same API. +All media peculiarities are handled automatically. + +xorriso is an application of all three libraries which creates, loads, +manipulates and writes ISO 9660 filesystem images with Rock Ridge extensions. +Manipulation is not only adding or overwriting of files but also deletion, +renaming, and attribute changing. An incremental backup feature is provided. +See xorriso/README for more + +SONAME: +libisoburn.so.1 (since 0.1.0, February 2008). + + + @section using Using the libraries + +Our build system is based on autotools. +User experience tells us that you will need at least autotools version 1.7. + +To build libisoburn go into its toplevel directory and execute + +- ./bootstrap (needed if you downloaded from SVN) + +- ./configure + +- make + +To make the libraries accessible for running resp. developing applications + +- make install + +Read libisoburn/libisoburn.h for a description of the API. +See also README, xorriso/README, and the man page xorriso/xorriso.1 which +gives an idea of the capabilities provided by Libburnia. + +You will also have to install and understand the two libraries of the +Libburnia project which provide fundamental services: +libburn is the library by which preformatted data get onto optical media. +See libburn/libburn.h for its API description. +libisofs is the library to handle ISO 9660 filesystems with Rock Ridge +extensions. Its API is described in libisofs/libisofs.h . + +*/ diff --git a/libisoburn/branches/ZeroFourTwo/doc/doxygen.conf.in b/libisoburn/branches/ZeroFourTwo/doc/doxygen.conf.in new file mode 100644 index 00000000..0a847861 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/doc/doxygen.conf.in @@ -0,0 +1,1298 @@ +# Doxyfile 1.5.3 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file that +# follow. The default is UTF-8 which is also the encoding used for all text before +# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into +# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of +# possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = @PACKAGE_NAME@ + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = @PACKAGE_VERSION@ + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, +# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, +# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, +# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = @top_srcdir@ + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = YES + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = YES + +# If the DETAILS_AT_TOP tag is set to YES then Doxygen +# will output the detailed description near the top, like JavaDoc. +# If set to NO, the detailed description appears after the member +# documentation. + +DETAILS_AT_TOP = YES + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for Java. +# For instance, namespaces will be presented as packages, qualified scopes +# will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to +# include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = YES + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be extracted +# and appear in the documentation as a namespace called 'anonymous_namespace{file}', +# where file will be replaced with the base name of the file that contains the anonymous +# namespace. By default anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from the +# version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = YES + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text " + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = libisoburn \ + doc \ + test + +# This tag can be used to specify the character encoding of the source files that +# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default +# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. +# See http://www.gnu.org/software/libiconv for the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the output. +# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, +# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = test + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. If you have enabled CALL_GRAPH or CALLER_GRAPH +# then you must also enable this option. If you don't then doxygen will produce +# a warning and turn it on anyway + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = YES + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = NO + +# If the REFERENCED_BY_RELATION tag is set to YES (the default) +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES (the default) +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentstion. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = OB \ + OTK \ + _ + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = doc/html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be +# generated containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 200 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = letter + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = NO + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = DOXYGEN + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to +# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to +# specify the directory where the mscgen tool resides. If left empty the tool is assumed to +# be found in the default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = YES + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will +# generate a call dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable call graphs for selected +# functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will +# generate a caller dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable caller graphs for selected +# functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = NO + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the number +# of direct children of the root node in a graph is already larger than +# MAX_DOT_GRAPH_NOTES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, which results in a white background. +# Warning: Depending on the platform used, enabling this option may lead to +# badly anti-aliased labels on the edges of a graph (i.e. they become hard to +# read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO diff --git a/libisoburn/branches/ZeroFourTwo/libisoburn-1.pc.in b/libisoburn/branches/ZeroFourTwo/libisoburn-1.pc.in new file mode 100644 index 00000000..7fae3f90 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/libisoburn-1.pc.in @@ -0,0 +1,12 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libisoburn +Description: Multi-session filesystem extension to libisofs, libburn. +Version: @VERSION@ +Requires: +Libs: -L${libdir} -lisoburn +Cflags: -I${includedir}/libisoburn + diff --git a/libisoburn/branches/ZeroFourTwo/libisoburn/burn_wrap.c b/libisoburn/branches/ZeroFourTwo/libisoburn/burn_wrap.c new file mode 100644 index 00000000..275f9104 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/libisoburn/burn_wrap.c @@ -0,0 +1,1785 @@ + +/* + cc -g -c \ + -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE \ + burn_wrap.c +*/ +/* libburn wrappers for libisoburn + + Copyright 2007 - 2009 Thomas Schmitt, +*/ + +/* <<< A70929 : hardcoded CD-RW with fabricated -msinfo +#define Hardcoded_cd_rW 1 +#define Hardcoded_cd_rw_c1 12999 +#define Hardcoded_cd_rw_nwA 152660 +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#ifndef Xorriso_standalonE + +#include + +#include + +#else /* ! Xorriso_standalonE */ + +#include "../libisofs/libisofs.h" +#include "../libburn/libburn.h" + +#endif /* Xorriso_standalonE */ + + +#include "libisoburn.h" +#include "isoburn.h" + + +/* The global list of isoburn objects. Usually there is only one. */ +extern struct isoburn *isoburn_list_start; /* in isoburn.c */ + +/* Default values for application provided msgs_submit methods. + To be attached to newly aquired drives. + Storage location is isoburn.c +*/ +extern int (*libisoburn_default_msgs_submit) + (void *handle, int error_code, char msg_text[], + int os_errno, char severity[], int flag); +extern void *libisoburn_default_msgs_submit_handle; +extern int libisoburn_default_msgs_submit_flag; + + +static int isoburn_emulate_toc(struct burn_drive *d, int flag); + + +int isoburn_initialize(char msg[1024], int flag) +{ + int major, minor, micro, bad_match= 0; + + +/* First two ugly compile time checks for header version compatibility. + If everthing matches, then they produce no C code. In case of mismatch, + intentionally faulty C code will be inserted. +*/ + +#ifdef iso_lib_header_version_major +/* The minimum requirement of libisoburn towards the libisofs header + at compile time is defined in libisoburn/libisoburn.h : + isoburn_libisofs_req_major + isoburn_libisofs_req_minor + isoburn_libisofs_req_micro + It gets compared against the version macros in libisofs/libisofs.h : + iso_lib_header_version_major + iso_lib_header_version_minor + iso_lib_header_version_micro + If the header is too old then the following code shall cause failure of + libisoburn compilation rather than to allow production of a program with + unpredictable bugs or memory corruption. + The compiler messages supposed to appear in this case are: + error: 'LIBISOFS_MISCONFIGURATION' undeclared (first use in this function) + error: 'INTENTIONAL_ABORT_OF_COMPILATION__HEADERFILE_libisofs_dot_h_TOO_OLD__SEE_libisoburn_dot_h_AND_burn_wrap_dot_h' undeclared (first use in this function) + error: 'LIBISOFS_MISCONFIGURATION_' undeclared (first use in this function) +*/ +/* The indendation is an advise of man gcc to help old compilers ignoring */ + #if isoburn_libisofs_req_major > iso_lib_header_version_major + #define Isoburn_libisofs_dot_h_too_olD 1 + #endif + #if isoburn_libisofs_req_major == iso_lib_header_version_major && isoburn_libisofs_req_minor > iso_lib_header_version_minor + #define Isoburn_libisofs_dot_h_too_olD 1 + #endif + #if isoburn_libisofs_req_minor == iso_lib_header_version_minor && isoburn_libisofs_req_micro > iso_lib_header_version_micro + #define Isoburn_libisofs_dot_h_too_olD 1 + #endif + +#ifdef Isoburn_libisofs_dot_h_too_olD +LIBISOFS_MISCONFIGURATION = 0; +INTENTIONAL_ABORT_OF_COMPILATION__HEADERFILE_libisofs_dot_h_TOO_OLD__SEE_libisoburn_dot_h_AND_burn_wrap_dot_h = 0; +LIBISOFS_MISCONFIGURATION_ = 0; +#endif + +#endif /* iso_lib_header_version_major */ + +/* The minimum requirement of libisoburn towards the libburn header + at compile time is defined in libisoburn/libisoburn.h : + isoburn_libburn_req_major + isoburn_libburn_req_minor + isoburn_libburn_req_micro + It gets compared against the version macros in libburn/libburn.h : + burn_header_version_major + burn_header_version_minor + burn_header_version_micro + If the header is too old then the following code shall cause failure of + cdrskin compilation rather than to allow production of a program with + unpredictable bugs or memory corruption. + The compiler messages supposed to appear in this case are: + error: 'LIBBURN_MISCONFIGURATION' undeclared (first use in this function) + error: 'INTENTIONAL_ABORT_OF_COMPILATION__HEADERFILE_libburn_dot_h_TOO_OLD__SEE_libisoburn_dot_h_and_burn_wrap_dot_h' undeclared (first use in this function) + error: 'LIBBURN_MISCONFIGURATION_' undeclared (first use in this function) +*/ + +/* The indendation is an advise of man gcc to help old compilers ignoring */ + #if isoburn_libburn_req_major > burn_header_version_major + #define Isoburn_libburn_dot_h_too_olD 1 + #endif + #if isoburn_libburn_req_major == burn_header_version_major && isoburn_libburn_req_minor > burn_header_version_minor + #define Isoburn_libburn_dot_h_too_olD 1 + #endif + #if isoburn_libburn_req_minor == burn_header_version_minor && isoburn_libburn_req_micro > burn_header_version_micro + #define Isoburn_libburn_dot_h_too_olD 1 + #endif + +#ifdef Isoburn_libburn_dot_h_too_olD +LIBBURN_MISCONFIGURATION = 0; +INTENTIONAL_ABORT_OF_COMPILATION__HEADERFILE_libburn_dot_h_TOO_OLD__SEE_libisoburn_dot_h_and_burn_wrap_dot_h = 0; +LIBBURN_MISCONFIGURATION_ = 0; +#endif + +/* End of ugly compile time tests (scroll up for explanation) */ + + + + msg[0]= 0; + if(iso_init()<0) { + sprintf(msg+strlen(msg), "Cannot initialize libisofs\n"); + return(0); + } + iso_lib_version(&major, &minor, µ); + sprintf(msg+strlen(msg), "libisofs-%d.%d.%d ", major, minor, micro); +#ifdef iso_lib_header_version_major + if(iso_lib_is_compatible(iso_lib_header_version_major, + iso_lib_header_version_minor, + iso_lib_header_version_micro)) { + sprintf(msg+strlen(msg), "ok, "); + } else { + sprintf(msg+strlen(msg),"- TOO OLD -, need at least libisofs-%d.%d.%d ,\n", + iso_lib_header_version_major, iso_lib_header_version_minor, + iso_lib_header_version_micro); + bad_match= 1; + } +#else + if(iso_lib_is_compatible(isoburn_libisofs_req_major, + isoburn_libisofs_req_minor, + isoburn_libisofs_req_micro)) { + sprintf(msg+strlen(msg), "suspicious, "); + } else { + sprintf(msg+strlen(msg),"- TOO OLD -, need at least libisofs-%d.%d.%d ,\n", + isoburn_libisofs_req_major, isoburn_libisofs_req_minor, + isoburn_libisofs_req_micro); + bad_match= 1; + } +#endif /* ! iso_lib_header_version_major */ + + if(!burn_initialize()) { + sprintf(msg+strlen(msg), "Cannot initialize libburn\n"); + return(0); + } + burn_version(&major, &minor, µ); + sprintf(msg+strlen(msg), "libburn-%d.%d.%d ", major, minor, micro); + if(major > burn_header_version_major + || (major == burn_header_version_major + && (minor > burn_header_version_minor + || (minor == burn_header_version_minor + && micro >= burn_header_version_micro)))) { + sprintf(msg+strlen(msg), "ok, "); + } else { + sprintf(msg+strlen(msg), "- TOO OLD -, need at least libburn-%d.%d.%d ,\n", + burn_header_version_major, burn_header_version_minor, + burn_header_version_micro); + bad_match= 1; + } + + isoburn_version(&major, &minor, µ); + sprintf(msg+strlen(msg), "for libisoburn-%d.%d.%d", major, minor, micro); + if(bad_match) + return(0); + + isoburn_destroy_all(&isoburn_list_start, 0); /* isoburn_list_start= NULL */ + return(1); +} + + +/* API @since 0.1.0 */ +int isoburn_libisofs_req(int *major, int *minor, int *micro) +{ + *major= iso_lib_header_version_major; + *minor= iso_lib_header_version_minor; + *micro= iso_lib_header_version_micro; + return(1); +} + + +/* API @since 0.1.0 */ +int isoburn_libburn_req(int *major, int *minor, int *micro) +{ + *major= burn_header_version_major; + *minor= burn_header_version_minor; + *micro= burn_header_version_micro; + return(1); +} + + +int isoburn_set_msgs_submit(int (*msgs_submit)(void *handle, int error_code, + char msg_text[], int os_errno, + char severity[], int flag), + void *submit_handle, int submit_flag, int flag) +{ + libisoburn_default_msgs_submit= msgs_submit; + libisoburn_default_msgs_submit_handle= submit_handle; + libisoburn_default_msgs_submit_flag= submit_flag; + return(1); +} + + +int isoburn_is_intermediate_dvd_rw(struct burn_drive *d, int flag) +{ + int profile, ret= 0, format_status, num_formats; + char profile_name[80]; + enum burn_disc_status s; + off_t format_size= -1; + unsigned bl_sas; + + s= isoburn_disc_get_status(d); + ret= burn_disc_get_profile(d, &profile, profile_name); + if(ret>0 && profile==0x13) + ret= burn_disc_get_formats(d, &format_status, &format_size, + &bl_sas, &num_formats); + if(ret>0 && profile==0x13 && s==BURN_DISC_BLANK && + format_status==BURN_FORMAT_IS_UNKNOWN) + return(1); + return(0); +} + + +/** Examines the media and sets appropriate emulation if needed. + @param flag bit0= pretent blank on overwriteable media + bit3= if the drive reports a -ROM profile then try to read + table of content by scanning for ISO image headers. + bit4= do not emulate TOC on overwriteable media + bit5= ignore ACL from external filesystems + bit6= ignore POSIX Extended Attributes from external filesystems +*/ +static int isoburn_welcome_media(struct isoburn **o, struct burn_drive *d, + int flag) +{ + int ret, lba, nwa, profile, readonly= 0; + struct burn_multi_caps *caps= NULL; + struct isoburn_toc_entry *t; + char profile_name[80]; + struct isoburn_toc_disc *disc= NULL; + struct isoburn_toc_session **sessions; + struct isoburn_toc_track **tracks; + int num_sessions= 0, num_tracks= 0, track_count= 0, session_no= 0; + char msg[80]; + + profile_name[0]= 0; + ret= burn_disc_get_profile(d, &profile, profile_name); + if(ret<=0) + profile= 0x00; + ret= burn_disc_get_multi_caps(d, BURN_WRITE_NONE, &caps, 0); + if(ret<0) /* == 0 is read-only media, but it is too early to reject it here */ + goto ex; + if(ret==0) + readonly= 1; + ret= isoburn_new(o, 0); + if(ret<=0) + goto ex; + (*o)->drive= d; + (*o)->msgs_submit= libisoburn_default_msgs_submit; + (*o)->msgs_submit_handle= libisoburn_default_msgs_submit_handle; + (*o)->msgs_submit_flag= libisoburn_default_msgs_submit_flag; + iso_image_set_ignore_aclea((*o)->image, (flag >> 5 ) & 3); + +#ifdef Hardcoded_cd_rW + /* <<< A70929 : hardcoded CD-RW with fabricated -msinfo */ + caps->start_adr= 0; + (*o)->fabricated_disc_status= BURN_DISC_APPENDABLE; +#endif + + if(caps->start_adr) { /* set emulation to overwriteable */ + (*o)->emulation_mode= 1; + ret= isoburn_is_intermediate_dvd_rw(d, 0); + if(ret>0) { + (*o)->min_start_byte= 0; + (*o)->nwa= 0; + (*o)->zero_nwa= 0; + } + if(flag&1) { + (*o)->nwa= (*o)->zero_nwa; + (*o)->fabricated_disc_status= BURN_DISC_BLANK; + } else { + ret= isoburn_start_emulation(*o, 0); + if(ret<=0) { + (*o)->emulation_mode= -1; + goto ex; + } + /* try to read emulated toc */ + ret= isoburn_emulate_toc(d, flag & 16); + if(ret<0) { + (*o)->emulation_mode= -1; + goto ex; + } + } + } else { + + /* >>> recognize unsuitable media (but allow read-only media) */; + + if(readonly) { + /* This might be overwriteable media in a -ROM drive. + Pitfall: + Multi-session media which bear a xorriso image for overwriteables + in their first session would get a TOC of that first image rather + than of the media. + It is not possible to distinguish a BD-RE from a single session + BD-R with an image for overwriteables. But as soon as the media + bears 2 logical tracks it cannot be overwriteable. + So count the number of tracks first. + */ + disc= isoburn_toc_drive_get_disc(d); + if(disc != NULL) { + sessions= isoburn_toc_disc_get_sessions(disc, &num_sessions); + for(session_no= 0; session_no < num_sessions; session_no++) { + tracks= isoburn_toc_session_get_tracks(sessions[session_no], + &num_tracks); + track_count+= num_tracks; + } + isoburn_toc_disc_free(disc); + } + + sprintf(msg, "ROM media has libburn track count = %d", track_count); + isoburn_msgs_submit(*o, 0x00060000, msg, 0, "DEBUG", 0); + + if((flag & 16) || track_count >= 2) { + ret= 0; /* toc emulation off, or not overwriteable */ + } else { + ret= isoburn_emulate_toc(d, 1); + if(ret<0) + goto ex; + } + if(ret == 0 && profile != 0x08 && (flag&8)) { + /* This might also be multi-session media which do not + get shown with a decent TOC. + CD-R TOC (profile 0x08) can be trusted. Others not. + Do a scan search of ISO headers. + */ + ret= isoburn_emulate_toc(d, 1|2); + if(ret<0) + goto ex; + if(ret>0) { /* point msc1 to last session */ + if((*o)->toc!=NULL) { + for(t= (*o)->toc; t->next!=NULL; t= t->next); + (*o)->fabricated_msc1= t->start_lba; + } + } + } + } +#ifdef Hardcoded_cd_rW + (*o)->nwa= Hardcoded_cd_rw_nwA; +#else + ret= burn_disc_track_lba_nwa(d, NULL, 0, &lba, &nwa); + if(ret>0) + (*o)->nwa= nwa; +#endif + + } + + ret= 1; +ex: + if(caps!=NULL) + burn_disc_free_multi_caps(&caps); + return(ret); +} + + +/** + @param flag bit0= load + bit1= regard overwriteable media as blank + bit2= if the drive is a regular disk file: truncate it to + the write start address + bit3= if the drive reports a -ROM profile then try to read + table of content by scanning for ISO image headers. + (depending on media type and drive state this might + help or it might make the resulting toc even worse) + bit4= do not emulate TOC on overwriteable media + bit5= ignore ACL from external filesystems + bit6= ignore POSIX Extended Attributes from external filesystems +*/ +int isoburn_drive_aquire(struct burn_drive_info *drive_infos[], + char *adr, int flag) +{ + int ret, drive_grabbed= 0; + struct isoburn *o= NULL; + +#ifndef NIX + +/* <<< should be obsolete by new drive addressing of libburn-0.5.2 */ +/* >>> but helps with kernel 2.4 to use /dev/sr */ + + int conv_ret; + char libburn_drive_adr[BURN_DRIVE_ADR_LEN]; + + conv_ret= burn_drive_convert_fs_adr(adr, libburn_drive_adr); + if(conv_ret<=0) + strcpy(libburn_drive_adr, adr); + ret= burn_drive_scan_and_grab(drive_infos, libburn_drive_adr, flag&1); + +#else + + ret= burn_drive_scan_and_grab(drive_infos, adr, flag & 1); + +#endif /* ! NIX */ + + if(ret<=0) + goto ex; + drive_grabbed= 1; + ret= isoburn_welcome_media(&o, (*drive_infos)[0].drive, + (flag & (8 | 16 | 32 | 64)) | !!(flag&2)); + if(ret<=0) + goto ex; + + if(flag&4) { + ret= isoburn_find_emulator(&o, (*drive_infos)[0].drive, 0); + if(ret>0 && o!=NULL) + o->truncate= 1; + } + + ret= 1; +ex: + if(ret<=0) { + if(drive_grabbed) + burn_drive_release((*drive_infos)[0].drive, 0); + isoburn_destroy(&o, 0); + } + return(ret); +} + + +int isoburn_drive_scan_and_grab(struct burn_drive_info *drive_infos[], + char *adr, int load) +{ + int ret; + + ret= isoburn_drive_aquire(drive_infos, adr, !!load); + return(ret); +} + + +int isoburn_drive_grab(struct burn_drive *drive, int load) +{ + int ret; + struct isoburn *o= NULL; + + ret= burn_drive_grab(drive, load); + if(ret<=0) + goto ex; + ret= isoburn_welcome_media(&o, drive, 0); + if(ret<=0) + goto ex; + + ret= 1; +ex: + if(ret<=0) + isoburn_destroy(&o,0); + return(ret); +} + + +/** Retrieve media emulation and eventual isoburn emulator of drive. + @return -1 unsuitable media, 0 generic media, 1 emulated media. +*/ +int isoburn_find_emulator(struct isoburn **pt, + struct burn_drive *drive, int flag) +{ + int ret; + + ret= isoburn_find_by_drive(pt, drive, 0); + if(ret<=0) + return(0); + if((*pt)->emulation_mode==-1) { + isoburn_msgs_submit(*pt, 0x00060000, + "Unsuitable drive and media state", 0, "FAILURE", 0); + return(-1); + } + if((*pt)->emulation_mode==0) + return(0); + return(1); +} + + +enum burn_disc_status isoburn_disc_get_status(struct burn_drive *drive) +{ + int ret; + struct isoburn *o; + + ret= isoburn_find_emulator(&o, drive, 0); + if(ret<0) + return(BURN_DISC_UNSUITABLE); + if(o!=NULL) + if(o->fabricated_disc_status!=BURN_DISC_UNREADY) + return(o->fabricated_disc_status); + if(ret==0) + return(burn_disc_get_status(drive)); + + /* emulated status */ + if(o->emulation_mode==-1) + return(BURN_DISC_UNSUITABLE); + if(o->nwa>o->zero_nwa) + return(BURN_DISC_APPENDABLE); + return(BURN_DISC_BLANK); +} + + +int isoburn_disc_erasable(struct burn_drive *d) +{ + int ret; + struct isoburn *o; + + ret= isoburn_find_emulator(&o, d, 0); + if(ret>0) + if(o->emulation_mode==1) + return(1); + return burn_disc_erasable(d); +} + + +void isoburn_disc_erase(struct burn_drive *drive, int fast) +{ + int ret; + struct isoburn *o; + enum burn_disc_status s; + char zero_buffer[Libisoburn_target_head_sizE]; + + ret= isoburn_find_emulator(&o, drive, 0); + if(ret>0) { + if(o->emulation_mode==-1) { + /* To cause a negative reply with burn_drive_wrote_well() */ + burn_drive_cancel(drive); + return; + } + if(o->emulation_mode>0) { + s= isoburn_disc_get_status(drive); + if(s==BURN_DISC_FULL) { /* unknown data format in first 64 kB */ + memset(zero_buffer, 0, Libisoburn_target_head_sizE); + ret= burn_random_access_write(drive, (off_t) 0, zero_buffer, + (off_t) Libisoburn_target_head_sizE, 1); + } else { + ret= isoburn_invalidate_iso(o, 0); + } + if(ret<=0) + burn_drive_cancel(drive); /* mark run as failure */ + return; + } + } + burn_disc_erase(drive, fast); +} + + +off_t isoburn_disc_available_space(struct burn_drive *d, + struct burn_write_opts *opts) +{ + int ret; + struct isoburn *o; + struct burn_write_opts *eff_opts= NULL, *local_opts= NULL; + enum burn_disc_status s; + off_t avail; + + eff_opts= opts; + ret= isoburn_find_emulator(&o, d, 0); + if(ret>0 && o!=NULL) + if(o->emulation_mode!=0) { + s= isoburn_disc_get_status(d); + if(s==BURN_DISC_FULL) /* unknown data format in first 64 kB */ + return((off_t) 0); + local_opts= burn_write_opts_new(d); + eff_opts= local_opts; + burn_write_opts_set_start_byte(eff_opts, ((off_t) o->nwa) * (off_t) 2048); + } + avail= burn_disc_available_space(d, eff_opts); + if(local_opts!=NULL) + burn_write_opts_free(local_opts); + local_opts= NULL; + return(avail); +} + + +int isoburn_disc_get_msc1(struct burn_drive *d, int *start_lba) +{ + int ret; + struct isoburn *o; + +#ifdef Hardcoded_cd_rW + /* <<< A70929 : hardcoded CD-RW with fabricated -msinfo */ + *start_lba= Hardcoded_cd_rw_c1; + return(1); +#endif + + if(isoburn_disc_get_status(d)!=BURN_DISC_APPENDABLE && + isoburn_disc_get_status(d)!=BURN_DISC_FULL) { + isoburn_msgs_submit(NULL, 0x00060000, + "Media contains no recognizable data", 0, "SORRY", 0); + return(0); + } + ret= isoburn_find_emulator(&o, d, 0); + if(ret<0) + return(0); + if(o->fabricated_msc1>=0) { + *start_lba= o->fabricated_msc1; + return(1); + } + if(ret>0) if(o->emulation_mode>0) { + *start_lba= 0; + return(1); + } + return(burn_disc_get_msc1(d, start_lba)); +} + + +int isoburn_disc_track_lba_nwa(struct burn_drive *d, + struct burn_write_opts *opts, + int trackno, int *lba, int *nwa) +{ + int ret; + struct isoburn *o; + +#ifdef Hardcoded_cd_rW + /* <<< A70929 : hardcoded CD-RW with fabricated -msinfo */ + *lba= Hardcoded_cd_rw_c1; + *nwa= Hardcoded_cd_rw_nwA; + return(1); +#endif + + *nwa= *lba= 0; + ret= isoburn_find_emulator(&o, d, 0); + if(ret<0) + return(0); + if(ret>0) if(o->emulation_mode>0) { + *lba= 0; + *nwa= o->nwa; + return(1); + } + if(burn_drive_get_drive_role(d) != 1) + return(1); + return(burn_disc_track_lba_nwa(d, opts, trackno, lba, nwa)); +} + + +int isoburn_get_msc2(struct isoburn *o, + struct burn_write_opts *opts, int *msc2, int flag) +{ + int ret, lba, nwa; + + if(o->fabricated_msc2>=0) + *msc2= o->fabricated_msc2; + else { + ret= isoburn_disc_track_lba_nwa(o->drive, opts, 0, &lba, &nwa); + if(ret<=0) + return(ret); + *msc2= nwa; + } + return(1); +} + + +void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc) +{ + int ret; + off_t nwa= 0; + struct isoburn *o; + struct burn_drive *drive; + char reasons[BURN_REASONS_LEN],msg[160+BURN_REASONS_LEN]; + char adr[BURN_DRIVE_ADR_LEN]; + enum burn_write_types write_type; + struct stat stbuf; + + drive= burn_write_opts_get_drive(opts); + ret= isoburn_find_emulator(&o, drive, 0); + if(ret<0) + return; + if(o!=NULL) { + o->wrote_well= -1; + if(o->emulation_mode!=0) { + burn_write_opts_set_multi(opts, 0); + if(o->emulation_mode>0 && o->nwa >= 0) { + nwa= o->nwa; + + /* This caters for unwritten formatted DVD-RW. They need to be written + sequentially on the first use. Only written areas are random access. + If the first session is not written to LBA 0, then re-opening of + formatting and padding is needed. + This can be done. But when the track gets closed after padding, + this lasts a long time. There is a high risk that an app will not + poll the message queue while waiting for isoburn_disc_write() to + return. The pacifier loop usually happens only afterwards. + So automatic formatting might cause a nervous clueless user. + */ + ret= isoburn_is_intermediate_dvd_rw(drive, 0); + if(ret>0 && nwa>0 && nwa <= o->zero_nwa) { + /* actually this should not happen since such media get recognized + by isoburn_welcome_media and o->zero_nwa gets set to 0 + */ + sprintf(msg, + "DVD-RW insufficiently formatted. (Intermediate State, size unknown)"); + isoburn_msgs_submit(o, 0x00060000, msg, 0, "FAILURE", 0); + sprintf(msg, + "It might help to first deformat it and then format it again"); + isoburn_msgs_submit(o, 0x00060000, msg, 0, "HINT", 0); + burn_drive_cancel(drive); /* mark run as failure */ + return; + } + /* end of DVD-RW oriented check */ + + burn_write_opts_set_start_byte(opts, nwa * (off_t) 2048); + } + } + } + + write_type= burn_write_opts_auto_write_type(opts, disc, reasons, 0); + if (write_type == BURN_WRITE_NONE) { + sprintf(msg, "Failed to find a suitable write mode:\n%s", reasons); + isoburn_msgs_submit(o, 0x00060000, msg, 0, "FAILURE", 0); + if(o!=NULL) + o->wrote_well= 0; + /* To cause a negative reply with burn_drive_wrote_well() */ + burn_drive_cancel(drive); + return; + } + + sprintf(reasons, "%d", (int) write_type); + sprintf(msg, "Write_type = %s\n", + (write_type == BURN_WRITE_SAO ? "SAO" : + (write_type == BURN_WRITE_TAO ? "TAO" : reasons))); + isoburn_msgs_submit(o, 0x00060000, msg, 0, "DEBUG", 0); + +#ifdef Hardcoded_cd_rW + /* <<< A70929 : hardcoded CD-RW with fabricated -msinfo */ + fprintf(stderr, "Setting write address to LBA %d\n", Hardcoded_cd_rw_nwA); + burn_write_opts_set_start_byte(opts, + ((off_t) Hardcoded_cd_rw_nwA) * (off_t) 2048); +#endif + + if(o->truncate) { + ret= burn_drive_get_drive_role(drive); + if(ret==2) { + ret= burn_drive_d_get_adr(drive, adr); + if(ret>0) { + ret= lstat(adr, &stbuf); + if(ret!=-1) + if(S_ISREG(stbuf.st_mode)) + truncate(adr, nwa * (off_t) 2048); + } + } + } + + burn_disc_write(opts, disc); +} + + +void isoburn_drive_release(struct burn_drive *drive, int eject) +{ + int ret; + struct isoburn *o; + + ret= isoburn_find_emulator(&o, drive, 0); + if(ret<0) + return; + if(o!=NULL) { + isoburn_destroy(&o, 0); + } + burn_drive_release(drive, eject); +} + + +void isoburn_finish(void) +{ + isoburn_destroy_all(&isoburn_list_start, 0); + burn_finish(); + iso_finish(); +} + + +int isoburn_needs_emulation(struct burn_drive *drive) +{ + int ret; + struct isoburn *o; + enum burn_disc_status s; + + s= isoburn_disc_get_status(drive); + if(s!=BURN_DISC_BLANK && s!=BURN_DISC_APPENDABLE) + return(-1); + ret= isoburn_find_emulator(&o, drive, 0); + if(ret<0) + return(-1); + if(ret>0) + if(o->emulation_mode>0) + return(1); + return(0); +} + + +int isoburn_set_start_byte(struct isoburn *o, off_t value, int flag) +{ + int ret; + struct burn_drive *drive = o->drive; + struct burn_multi_caps *caps= NULL; + + ret= burn_disc_get_multi_caps(drive, BURN_WRITE_NONE, &caps, 0); + if(ret<=0) + goto ex; + if(!caps->start_adr) { + isoburn_msgs_submit(o, 0x00060000, + "Cannot set start byte address with this type of media", + 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + o->min_start_byte= value; + if(value % caps->start_alignment) + value+= caps->start_alignment - (value % caps->start_alignment); + o->nwa= value/2048; + /* If suitable for media alignment, round up to Libisoburn_nwa_alignemenT */ + if((o->nwa % Libisoburn_nwa_alignemenT) && + ((Libisoburn_nwa_alignemenT*2048) % caps->start_alignment)==0 ) + o->nwa+= Libisoburn_nwa_alignemenT - (o->nwa % Libisoburn_nwa_alignemenT); + ret= 1; +ex: + if(caps!=NULL) + burn_disc_free_multi_caps(&caps); + return(ret); +} + + +int isoburn_get_min_start_byte(struct burn_drive *d, off_t *start_byte, + int flag) +{ + int ret; + struct isoburn *o; + + ret= isoburn_find_emulator(&o, d, 0); + if(ret<0) + return(-1); + if(ret==0) + return(0); + *start_byte= o->min_start_byte; + if(o->min_start_byte<=0) + return(0); + return(1); +} + + +int isoburn_drive_wrote_well(struct burn_drive *d) +{ + int ret; + struct isoburn *o; + + ret= isoburn_find_emulator(&o, d, 0); + if(ret<0) + return(-1); + if(o!=NULL) + if(o->wrote_well>=0) + return(o->wrote_well); + ret= burn_drive_wrote_well(d); + return ret; +} + + +int isoburn_get_fifo_status(struct burn_drive *d, int *size, int *free_bytes, + char **status_text) +{ + int ret; + struct isoburn *o; + size_t hsize= 0, hfree_bytes= 0; + + ret= isoburn_find_emulator(&o, d, 0); + if(ret<0) + return(-1); + + if(o==NULL) + return(-1); + if(o->iso_source==NULL) + return(-1); + ret= iso_ring_buffer_get_status(o->iso_source, &hsize, &hfree_bytes); + if(hsize > 1024*1024*1024) + *size= 1024*1024*1024; + else + *size= hsize; + if(hfree_bytes > 1024*1024*1024) + *free_bytes= 1024*1024*1024; + else + *free_bytes= hfree_bytes; + *status_text= ""; + if(ret==0) + *status_text= "standby"; + else if(ret==1) + *status_text= "active"; + else if(ret==2) + *status_text= "ending"; + else if(ret==3) + *status_text= "failing"; + else if(ret==4) + *status_text= "unused"; + else if(ret==5) + *status_text= "abandoned"; + else if(ret==6) + *status_text= "ended"; + else if(ret==7) + *status_text= "aborted"; + return(ret); +} + + +/* @param flag bit0= -reserved- + bit1= this is a libburn severity +*/ +int isoburn__sev_to_text(int severity, char **severity_name, + int flag) +{ + int ret; + + ret= iso_sev_to_text(severity, severity_name); + if(ret>0) + return(ret); + ret= burn_sev_to_text(severity, severity_name, 0); + return(ret); +} + + +int isoburn__text_to_sev(char *severity_name, int *severity_number, int flag) +{ + int ret= 1; + + ret= iso_text_to_sev(severity_name, severity_number); + if(ret>0) + return(ret); + ret= burn_text_to_sev(severity_name, severity_number, 0); + return(ret); +} + + +int isoburn_report_iso_error(int iso_error_code, char msg_text[], int os_errno, + char min_severity[], int flag) +{ + int error_code, iso_sev, min_sev, ret; + char *sev_text_pt, *msg_text_pt= NULL; + + error_code= iso_error_get_code(iso_error_code); + if(error_code < 0x00030000 || error_code >= 0x00040000) + error_code= (error_code & 0xffff) | 0x00050000; + + if(iso_error_code<0) + msg_text_pt= (char *) iso_error_to_msg(iso_error_code); + if(msg_text_pt==NULL) + msg_text_pt= msg_text; + iso_sev= iso_error_get_severity(iso_error_code); + sev_text_pt= min_severity; + isoburn__text_to_sev(min_severity, &min_sev, 0); + if(min_sev < iso_sev) + isoburn__sev_to_text(iso_sev, &sev_text_pt, 0); + ret= iso_msgs_submit(error_code, msg_text_pt, os_errno, sev_text_pt, 0); + return(ret); +} + + +/* @param flag bit0-7: info return mode + 0= do not return anything in info (do not even touch it) + 1= copy volume id to info (info needs 33 bytes) + 2= do not touch info (caller will copy 64 kB header to it) + bit14= -reserved - + bit15= -reserved- + @return 1 seems to be a valid ISO image , 0 format not recognized, <0 error +*/ +int isoburn_read_iso_head_parse(struct burn_drive *d, unsigned char *data, + int *image_blocks, char *info, int flag) +{ + int i, info_mode; + + /* is this an ISO image ? */ + if(data[0]!=1) + return(0); + if(strncmp((char *) (data+1),"CD001",5)!=0) + return(0); + /* believe so */ + + *image_blocks= data[80] | (data[81]<<8) | (data[82]<<16) | (data[83]<<24); + info_mode= flag&255; + if(info_mode==0) { + ; + } else if(info_mode==1) { + strncpy(info, (char *) (data+40), 32); + info[32]= 0; + for(i= strlen(info)-1; i>=0; i--) + if(info[i]!=' ') + break; + else + info[i]= 0; + } else if(info_mode==2) { + ; + } else { + isoburn_msgs_submit(NULL, 0x00060000, + "Program error: Unknown info mode with isoburn_read_iso_head()", + 0, "FATAL", 0); + return(-1); + } + return(1); +} + + +/* API + @param flag bit0-7: info return mode + 0= do not return anything in info (do not even touch it) + 1= copy volume id to info (info needs 33 bytes) + 2= copy 64 kB header to info (needs 65536 bytes) + bit13= do not read head from media but use first 64 kB from info + bit14= check both half buffers (not only second) + return 2 if found in first block + bit15= return-1 on read error + @return 1 seems to be a valid ISO image , 2 found in first half buffer, + 0 format not recognized, <0 error +*/ +int isoburn_read_iso_head(struct burn_drive *d, int lba, + int *image_blocks, char *info, int flag) +{ + unsigned char buffer[64*1024]; + int ret, info_mode; + off_t data_count; + + info_mode= flag&255; + *image_blocks= 0; + if(flag&(1<<13)) { + memcpy(buffer, info, 64*1024); + } else { + ret = burn_read_data(d, ((off_t) lba) * (off_t) 2048, (char *) buffer, + (off_t) 64*1024, &data_count, 2); /* no error messages */ + if(ret<=0) + return(-1*!!(flag&(1<<15))); + if(info_mode==2) + memcpy(info, buffer, 64*1024); + } + + if(flag&(1<<14)) { + ret= isoburn_read_iso_head_parse(d, buffer, image_blocks, info, info_mode); + if(ret<0) + return(ret); + if(ret>0) + return(2); + } + ret= isoburn_read_iso_head_parse(d, buffer+32*1024, image_blocks, info, + info_mode); + if(ret<=0) + return(ret); + return(1); +} + + +int isoburn_make_toc_entry(struct isoburn *o, int *session_count, int lba, + int track_blocks, char *volid, int flag) +{ + int ret; + struct isoburn_toc_entry *item; + + ret= isoburn_toc_entry_new(&item, o->toc, 0); + if(ret<=0) { +no_memory:; + isoburn_msgs_submit(o, 0x00060000, + "Not enough memory for emulated TOC entry object", + 0, "FATAL", 0); + return(-1); + } + if(o->toc==NULL) + o->toc= item; + (*session_count)++; + item->session= *session_count; + item->track_no= *session_count; + item->start_lba= lba; + item->track_blocks= track_blocks; + if(volid != NULL) { + item->volid= strdup(volid); + if(item->volid == NULL) + goto no_memory; + } + return(1); +} + + +/* @param flag bit0= allow unemulated media + bit1= free scanning without enclosing LBA-0-header + bit4= represent emulated media as one single session + (not with bit1) + @return -1 severe error, 0= no neat header chain, 1= credible chain read +*/ +int isoburn_emulate_toc(struct burn_drive *d, int flag) +{ + int ret, image_size= 0, lba, track_blocks, session_count= 0, read_flag= 0; + int scan_start= 0, scan_count= 0, probe_minus_16= 0, growisofs_nwa; + int with_enclosure= 0; + struct isoburn *o; + char msg[160], size_text[80], *sev, volid[33], *volid_pt= NULL; + time_t start_time, last_pacifier, now; + + /* is the media emulated multi-session ? */ + ret= isoburn_find_emulator(&o, d, 0); + if(ret<0) + return(-1); + if(o==NULL) + return(-1); + if(o->emulation_mode<=0 && !(flag&1)) + return(0); + + start_time= last_pacifier= time(NULL); + lba= 0; + if(!(flag&2)) { + ret= isoburn_read_iso_head(d, lba, &image_size, NULL, 0); + if(ret<=0) + {ret= 0; goto failure;} + lba= Libisoburn_overwriteable_starT; + with_enclosure= 1; + if((flag & 16) && o->emulation_mode == 1) { + ret= 1; + goto failure; /* This will represent the media as single session */ + } + } + while(lba= 5) { + last_pacifier= now; + if(scan_count>=10*512) + sprintf(size_text, "%.f MB", ((double) scan_count) / 512.0); + else + sprintf(size_text, "%.f kB", 2 * (double) scan_count); + sprintf(msg, "Found %d ISO sessions by scanning %s in %.f seconds", + session_count, size_text, (double) (now - start_time)); + isoburn_msgs_submit(o, 0x00060000, msg, 0, "UPDATE", 0); + } + read_flag= 1; + if(flag&2) + read_flag|= (1<<15)|((session_count>0)<<14); + else { + + /* growisofs aligns to 16 rather than 32. Overwriteable TOC emulation + relies on not accidentially seeing inter-session trash data. + But one can safely access 16 blocks earlier because a xorriso header + would have overwritten with the unused 16 blocks at its start. + If libisoburn alignment would increase, then this would not be + possible any more. + */ + + if(probe_minus_16) + read_flag|= (1<<14); + probe_minus_16= 0; + } + + ret= isoburn_read_iso_head(d, lba, &track_blocks, volid, read_flag); + if(ret > 0) { + volid_pt= volid; + } else { + volid_pt= NULL; + if(session_count>0) { + if(flag&2) { + if(ret==0) { + /* try at next 64 k block (check both 32 k halves) */ + lba+= 32; + scan_count+= 32; + if(lba-scan_start <= Libisoburn_toc_scan_max_gaP) + continue; + } + break; + } + sprintf(msg, + "Chain of ISO session headers broken at #%d, LBA %ds", + session_count+1, lba); + isoburn_msgs_submit(o, 0x00060000, msg, 0, "WARNING", 0); + + if(with_enclosure) { + ret= isoburn_make_toc_entry(o, &session_count, 0, image_size, NULL,0); + if(ret<=0) + goto failure; + } + break; /* do not return failure */ + + } + {ret= 0; goto failure;} + } + if(ret==2) /* ISO header was found in first half block */ + lba-= 16; + + ret= isoburn_make_toc_entry(o, &session_count, lba, track_blocks, volid_pt, + 0); + if(ret<=0) + goto failure; + lba+= track_blocks; + scan_count+= 32; + + /* growisofs aligns to 16 rather than 32 */ + growisofs_nwa= lba; + if(growisofs_nwa % 16) + growisofs_nwa+= 16 - (growisofs_nwa % 16); + if(lba % Libisoburn_nwa_alignemenT) + lba+= Libisoburn_nwa_alignemenT - (lba % Libisoburn_nwa_alignemenT); + scan_start= lba; + if(lba - growisofs_nwa == 16) + probe_minus_16= 1; + } + if(last_pacifier != start_time) + sev= "UPDATE"; + else + sev= "DEBUG"; + now= time(NULL); + if(scan_count>=10*512) + sprintf(size_text, "%.f MB", ((double) scan_count) / 512.0); + else + sprintf(size_text, "%.f kB", 2 * (double) scan_count); + sprintf(msg, "Found %d ISO sessions by scanning %s in %.f seconds", + session_count, size_text, (double) (now - start_time)); + isoburn_msgs_submit(o, 0x00060000, msg, 0, sev, 0); + return(1); +failure:; + isoburn_toc_entry_destroy(&(o->toc), 1); + if(with_enclosure && o->emulation_mode == 1) { + session_count= 0; + ret= isoburn_make_toc_entry(o, &session_count, 0, image_size, NULL, 0); + } + return(ret); +} + + +int isoburn_toc_new_arrays(struct isoburn_toc_disc *o, + int session_count, int track_count, int flag) +{ + int i; + int isoburn_toc_destroy_arrays(struct isoburn_toc_disc *o, int flag); + + o->sessions= calloc(session_count, sizeof(struct isoburn_toc_session)); + o->session_pointers= + calloc(session_count, sizeof(struct isoburn_toc_session *)); + o->tracks= calloc(track_count, sizeof(struct isoburn_toc_track)); + o->track_pointers= calloc(track_count, sizeof(struct isoburn_toc_track *)); + if(o->sessions!=NULL && o->session_pointers!=NULL && + o->tracks!=NULL && o->track_pointers!=NULL) { + for(i= 0; isessions[i].session= NULL; + o->sessions[i].track_pointers= NULL; + o->sessions[i].track_count= 0; + o->sessions[i].toc_entry= NULL; + o->session_pointers[i]= NULL; + } + for(i= 0; itracks[i].track= NULL; + o->tracks[i].toc_entry= NULL; + o->track_pointers[i]= NULL; + } + return(1); + } + /* failed */ + isoburn_toc_destroy_arrays(o, 0); + return(-1); +} + + +int isoburn_toc_destroy_arrays(struct isoburn_toc_disc *o, int flag) +{ + if(o->sessions!=NULL) + free((char *) o->sessions); + o->sessions= NULL; + if(o->session_pointers!=NULL) + free((char *) o->session_pointers); + o->session_pointers= NULL; + if(o->tracks!=NULL) + free((char *) o->tracks); + o->tracks= NULL; + if(o->track_pointers!=NULL) + free((char *) o->track_pointers); + o->track_pointers= NULL; + return(1); +} + + +struct isoburn_toc_disc *isoburn_toc_drive_get_disc(struct burn_drive *d) +{ + int ret, session_count= 0, track_count= 0, num_tracks= 0, i, j; + struct isoburn *o; + struct isoburn_toc_entry *t; + struct isoburn_toc_disc *toc_disc= NULL; + struct burn_session **s; + struct burn_track **tracks; + + toc_disc= calloc(1, sizeof(struct isoburn_toc_disc)); + if(toc_disc==NULL) + return(NULL); + toc_disc->disc= NULL; + toc_disc->sessions= NULL; + toc_disc->session_pointers= NULL; + toc_disc->tracks= NULL; + toc_disc->track_pointers= NULL; + toc_disc->session_count= 0; + toc_disc->track_count= 0; + toc_disc->toc= NULL; + + /* is the media emulated multi-session ? */ + ret= isoburn_find_emulator(&o, d, 0); + if(ret<0) + goto libburn; + if(o->toc==NULL) + goto libburn; + + /* This is an emulated TOC */ + toc_disc->toc= o->toc; + for(t= toc_disc->toc; t!=NULL; t= t->next) + session_count++; + ret= isoburn_toc_new_arrays(toc_disc, session_count, session_count, 0); + if(ret<=0) + goto failure; + t= toc_disc->toc; + for(i= 0; isessions[i].track_pointers= toc_disc->track_pointers+i; + toc_disc->sessions[i].track_count= 1; + toc_disc->sessions[i].toc_entry= t; + toc_disc->session_pointers[i]= toc_disc->sessions+i; + toc_disc->tracks[i].toc_entry= t; + toc_disc->track_pointers[i]= toc_disc->tracks+i; + t= t->next; + } + toc_disc->session_count= session_count; + toc_disc->track_count= session_count; + return(toc_disc); + +libburn:; + /* This is a libburn provided TOC */ + toc_disc->disc= burn_drive_get_disc(d); + if(toc_disc->disc == NULL) { +failure:; + free((char *) toc_disc); + return(NULL); + } + s= burn_disc_get_sessions(toc_disc->disc, &session_count); + for(i= 0; isessions[i].session= s[i]; + toc_disc->sessions[i].track_pointers= toc_disc->track_pointers+track_count; + toc_disc->sessions[i].track_count= num_tracks; + toc_disc->session_pointers[i]= toc_disc->sessions+i; + for(j= 0; jtracks[track_count+j].track= tracks[j]; + toc_disc->track_pointers[track_count+j]= toc_disc->tracks+(track_count+j); + } + track_count+= num_tracks; + } + toc_disc->session_count= session_count; + toc_disc->track_count= track_count; + return(toc_disc); +} + + +int isoburn_toc_disc_get_sectors(struct isoburn_toc_disc *disc) +{ + struct isoburn_toc_entry *t; + int ret= 0, num_sessions, num_tracks; + struct burn_session **sessions; + struct burn_track **tracks; + struct burn_toc_entry entry; + + if(disc==NULL) + return(0); + if(disc->toc!=NULL) { + for(t= disc->toc; t!=NULL; t= t->next) + ret= t->start_lba + t->track_blocks; + } else if(disc->disc!=NULL) { + sessions= burn_disc_get_sessions(disc->disc, &num_sessions); + if(num_sessions > 0) { + tracks = burn_session_get_tracks(sessions[num_sessions - 1], + &num_tracks); + if(num_tracks > 0) { + burn_track_get_entry(tracks[num_tracks - 1], &entry); + if(entry.extensions_valid & 1) + ret= entry.start_lba + entry.track_blocks; + } + } +/* + ret= burn_disc_get_sectors(disc->disc); +*/ + } + return(ret); +} + + +struct isoburn_toc_session **isoburn_toc_disc_get_sessions( + struct isoburn_toc_disc *disc, int *num) +{ + *num= disc->session_count; + return(disc->session_pointers); +} + + +int isoburn_toc_session_get_sectors(struct isoburn_toc_session *s) +{ + struct isoburn_toc_entry *t; + int count= 0, i; + + if(s==NULL) + return(0); + if(s->toc_entry!=NULL) { + t= s->toc_entry; + for(i= 0; itrack_count; i++) { + count+= t->track_blocks; + t= t->next; + } + } else if(s->session!=NULL) + count= burn_session_get_sectors(s->session); + return(count); +} + + +int isoburn_toc_entry_finish(struct burn_toc_entry *entry, + int session_no, int track_no, int flag) +{ + int pmin, psec, pframe; + + entry->extensions_valid= 1; + entry->adr= 1; + entry->control= 4; + entry->session= session_no & 255; + entry->session_msb= (session_no >> 8) & 255; + entry->point= track_no & 255; + entry->point_msb= (track_no >> 8) & 255; + + burn_lba_to_msf(entry->start_lba, &pmin, &psec, &pframe); + if(pmin<=255) + entry->pmin= pmin; + else + entry->pmin= 255; + entry->psec= psec; + entry->pframe= pframe; + return(1); +} + + +void isoburn_toc_session_get_leadout_entry(struct isoburn_toc_session *s, + struct burn_toc_entry *entry) +{ + struct isoburn_toc_track *t; + + if(s==NULL) + return; + if(s->session!=NULL && s->toc_entry==NULL) { + burn_session_get_leadout_entry(s->session, entry); + return; + } + if(s->track_count<=0 || s->track_pointers==NULL || s->toc_entry==NULL) + return; + t= s->track_pointers[s->track_count-1]; + entry->start_lba= t->toc_entry->start_lba + t->toc_entry->track_blocks; + entry->track_blocks= 0; + isoburn_toc_entry_finish(entry, s->toc_entry->session, t->toc_entry->track_no, + 0); +} + + +struct isoburn_toc_track **isoburn_toc_session_get_tracks( + struct isoburn_toc_session *s, int *num) +{ + *num= s->track_count; + return(s->track_pointers); +} + + +void isoburn_toc_track_get_entry(struct isoburn_toc_track *t, + struct burn_toc_entry *entry) +{ + if(t==0) + return; + if(t->track!=NULL && t->toc_entry==NULL) { + burn_track_get_entry(t->track, entry); + return; + } + if(t->toc_entry==NULL) + return; + entry->start_lba= t->toc_entry->start_lba; + entry->track_blocks= t->toc_entry->track_blocks; + isoburn_toc_entry_finish(entry, t->toc_entry->session, t->toc_entry->track_no, + 0); +} + + +int isoburn_toc_track_get_emul(struct isoburn_toc_track *t, int *start_lba, + int *image_blocks, char volid[33], int flag) +{ + if(t->toc_entry == NULL) + return(0); + if(t->toc_entry->volid == NULL) + return(0); + *start_lba= t->toc_entry->start_lba; + *image_blocks= t->toc_entry->track_blocks; + strncpy(volid, t->toc_entry->volid, 32); + volid[32]= 0; + return(1); +} + + +void isoburn_toc_disc_free(struct isoburn_toc_disc *d) +{ + if(d->disc!=NULL) + burn_disc_free(d->disc); + isoburn_toc_destroy_arrays(d, 0); + free((char *) d); +} + + +int isoburn_get_track_lba(struct isoburn_toc_track *track, int *lba, int flag) +{ + struct burn_toc_entry entry; + + isoburn_toc_track_get_entry(track, &entry); + if (entry.extensions_valid & 1) + *lba= entry.start_lba; + else + *lba= burn_msf_to_lba(entry.pmin, entry.psec, entry.pframe); + return(1); +} + + +int isoburn_drive_set_msgs_submit(struct burn_drive *d, + int (*msgs_submit)(void *handle, int error_code, + char msg_text[], int os_errno, + char severity[], int flag), + void *submit_handle, int submit_flag, int flag) +{ + struct isoburn *o; + int ret; + + ret= isoburn_find_emulator(&o, d, 0); + if(ret<0 || o==NULL) + return(-1); + o->msgs_submit= msgs_submit; + o->msgs_submit_handle= submit_handle; + o->msgs_submit_flag= submit_flag; + return(1); +} + + +/* @param flag bit0= with adr_mode 3: adr_value might be 16 blocks too high + bit1= insist in seeing a disc object with at least one session + bit2= with adr_mode 4: use adr_value as regular expression +*/ +int isoburn_set_msc1(struct burn_drive *d, int adr_mode, char *adr_value, + int flag) +{ + int ret, num_sessions, num_tracks, adr_num, i, j, total_tracks; + int lba, best_lba, size, re_valid= 0, track_count= 0; + time_t start_time= 0, last_pacifier= 0, now; + char volid[33], msg[160]; + struct isoburn *o; + struct isoburn_toc_disc *disc= NULL; + struct isoburn_toc_session **sessions= NULL; + struct isoburn_toc_track **tracks= NULL; + static char mode_names[][20]= {"auto", "session", "track", "lba", "volid"}; + static int max_mode_names= 4; + regex_t re; + regmatch_t match[1]; + + ret= isoburn_find_emulator(&o, d, 0); + if(ret<0) + return(-1); + if(o==NULL) + return(-1); + + start_time= last_pacifier= time(NULL); + adr_num= atoi(adr_value); + if(adr_mode!=3 || (flag & 2)) { + disc= isoburn_toc_drive_get_disc(d); + if(disc==NULL) { +not_found:; + if(adr_mode<0 || adr_mode>max_mode_names) + goto unknown_mode; + sprintf(msg, "Failed to find %s %s", mode_names[adr_mode], + strlen(adr_value)<=80 ? adr_value : "-oversized-string-"); + isoburn_msgs_submit(o, 0x00060000, msg, 0, "FAILURE", 0); + ret= 0; goto ex; + } + sessions= isoburn_toc_disc_get_sessions(disc, &num_sessions); + if(sessions==NULL || num_sessions<=0) + goto not_found; + } + if(adr_mode==0) { + /* Set fabricated_msc1 to last session in TOC */ + tracks= isoburn_toc_session_get_tracks(sessions[num_sessions-1], + &num_tracks); + if(tracks==NULL || num_tracks<=0) + goto not_found; + isoburn_get_track_lba(tracks[0], &(o->fabricated_msc1), 0); + + } else if(adr_mode==1) { + /* Use adr_num as session index (first session is 1, not 0) */ + if(adr_num<1 || adr_num>num_sessions) + goto not_found; + tracks= isoburn_toc_session_get_tracks(sessions[adr_num-1], &num_tracks); + if(tracks==NULL || num_tracks<=0) + goto not_found; + isoburn_get_track_lba(tracks[0], &(o->fabricated_msc1), 0); + + } else if(adr_mode==2) { + /* use adr_num as track index */ + total_tracks= 0; + for(i=0; ifabricated_msc1), 0); + ret= 1; goto ex; + } + } + } + goto not_found; + + } else if(adr_mode==3) { + o->fabricated_msc1= adr_num; + if((flag & 1) && o->fabricated_msc1 >= 16) { + /* adr_num is possibly 16 blocks too high */ + ret= isoburn_read_iso_head(d, o->fabricated_msc1, &size,volid, 1|(1<<14)); + if(ret==2) + o->fabricated_msc1-= 16; + } + } else if(adr_mode==4) { + /* search for volume id that is equal to adr_value */ + if(flag & 4) { + ret= regcomp(&re, adr_value, 0); + if(ret != 0) + flag&= ~4; + else + re_valid= 1; + } + best_lba= -1; + for(i=0; i= 5 && track_count > 0) { + last_pacifier= now; + sprintf(msg, + "Scanned %d tracks for matching volid in %.f seconds", + track_count, (double) (now - start_time)); + isoburn_msgs_submit(o, 0x00060000, msg, 0, "UPDATE", 0); + } + track_count++; + ret= isoburn_toc_track_get_emul(tracks[0], &lba, &size, volid, 0); + if(ret < 0) + continue; + if(ret == 0) { + isoburn_get_track_lba(tracks[0], &lba, 0); + ret= isoburn_read_iso_head(d, lba, &size, volid, 1); + if(ret<=0) + continue; + } + if(flag & 4) { + ret= regexec(&re, volid, 1, match, 0); + if(ret != 0) + continue; + } else { + if(strcmp(volid, adr_value)!=0) + continue; + } + best_lba= lba; + } + } + if(best_lba<0) + goto not_found; + o->fabricated_msc1= best_lba; + + } else { +unknown_mode:; + sprintf(msg, "Program error: Unknown msc1 address mode %d", adr_mode); + isoburn_msgs_submit(o, 0x00060000, msg, 0, "FATAL", 0); + ret= 0; goto ex; + } + ret= 1; +ex:; + if(start_time != last_pacifier && track_count > 0) { + now= time(NULL); + sprintf(msg, + "Scanned %d tracks for matching volid in %.f seconds", + track_count, (double) (now - start_time)); + isoburn_msgs_submit(o, 0x00060000, msg, 0, "UPDATE", 0); + } + if(disc!=NULL) + isoburn_toc_disc_free(disc); + if((flag & 4) && re_valid) + regfree(&re); + return(ret); +} + + +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) +{ + int msc1_mem, ret, total_tracks, num_sessions, num_tracks, i, j, track_lba; + int size, is_iso= 0; + struct isoburn *o; + struct isoburn_toc_disc *disc= NULL; + struct isoburn_toc_session **sessions= NULL; + struct isoburn_toc_track **tracks= NULL; + + *lba= *track= *session= -1; + volid[0]= 0; + ret= isoburn_find_emulator(&o, d, 0); + if(ret < 0 || o == NULL) + return(-1); + msc1_mem= o->fabricated_msc1; + ret= isoburn_set_msc1(d, adr_mode, adr_value, 2 | (flag & 4)); + if(ret <= 0) + return(ret); + *lba= o->fabricated_msc1; + + disc= isoburn_toc_drive_get_disc(d); + if(disc==NULL) + {ret= -1; goto ex;} /* cannot happen because checked by isoburn_set_msc1 */ + sessions= isoburn_toc_disc_get_sessions(disc, &num_sessions); + if(sessions==NULL || num_sessions<=0) + {ret= -1; goto ex;} /* cannot happen because checked by isoburn_set_msc1 */ + total_tracks= 0; + for(i=0; ifabricated_msc1= msc1_mem; + return(2 - is_iso); +} + + diff --git a/libisoburn/branches/ZeroFourTwo/libisoburn/data_source.c b/libisoburn/branches/ZeroFourTwo/libisoburn/data_source.c new file mode 100644 index 00000000..652602b3 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/libisoburn/data_source.c @@ -0,0 +1,269 @@ +/* + data source for libisoburn. + + Copyright 2007 - 2009 Vreixo Formoso Lopes + and Thomas Schmitt +*/ + +#include +#include + +#include + + +#ifndef Xorriso_standalonE + +#include + +#include + +#else /* ! Xorriso_standalonE */ + +#include "../libisofs/libisofs.h" +#include "../libburn/libburn.h" + +#endif /* Xorriso_standalonE */ + + +#include "isoburn.h" + + +/* Cached reading of image tree data */ +/* Multi tile: 32 * 64 kB */ + +/* The size of a single tile. + Powers of 2 only ! Less than 16 makes not much sense. +*/ +#define Libisoburn_tile_blockS 32 + +/* The number of tiles in the cache +*/ +#define Libisoburn_cache_tileS 32 + + +/* Debugging only: This reports cache loads on stderr. +#define Libisoburn_read_cache_reporT 1 +*/ + + +struct isoburn_cache_tile { + char cache_data[Libisoburn_tile_blockS * 2048]; + uint32_t cache_lba; + uint32_t last_error_lba; + uint32_t last_aligned_error_lba; + int cache_hits; + int age; +}; + +struct isoburn_cached_drive { + struct burn_drive *drive; + struct isoburn_cache_tile tiles[Libisoburn_cache_tileS]; + int current_age; +}; + +#define Libisoburn_max_agE 2000000000 + +static int ds_inc_age(struct isoburn_cached_drive *icd, int idx, int flag); + + +int ds_read_block(IsoDataSource *src, uint32_t lba, uint8_t *buffer) +{ + int ret, i, oldest, oldest_age; + struct burn_drive *d; + off_t count; + uint32_t aligned_lba; + char msg[80]; + struct isoburn_cache_tile *tiles; + struct isoburn_cached_drive *icd; + + if(src == NULL || buffer == NULL) + /* It is not required by the specs of libisofs but implicitely assumed + by its current implementation that a data source read result <0 is + a valid libisofs error code. + */ + return ISO_NULL_POINTER; + + icd = (struct isoburn_cached_drive *) src->data; + d = (struct burn_drive*) icd->drive; + + if(d == NULL) { + /* This would happen if libisoburn saw output data in the fifo and + performed early drive release and afterwards libisofs still tries + to read data. + That would constitute a bad conceptual problem in libisoburn. + */ + isoburn_msgs_submit(NULL, 0x00060000, + "Programming error: Drive released while libisofs still attempts to read", + 0, "FATAL", 0); + return ISO_ASSERT_FAILURE; + } + + tiles = (struct isoburn_cache_tile *) icd->tiles; + + aligned_lba= lba & ~(Libisoburn_tile_blockS - 1); + + for(i=0; i 0) + return 1; + tiles[oldest].last_error_lba = lba; + +#ifdef ISO_DATA_SOURCE_MISHAP + ret= ISO_DATA_SOURCE_MISHAP; +#else + /* <<< pre libisofs-0.6.7 */ + /* It is not required by the specs of libisofs but implicitely assumed + ... + But it is not possible to ignore FAILURE. + libisofs insists in original error codes, i.e. libisoburn cannot + change severity FAILURE associated with ISO_FILE_READ_ERROR. + So ISO_FILE_READ_ERROR is not an option and libisoburn has to + misuse ISO_FILE_CANT_WRITE, which is actually for image generation + and not for image reading. + This is quite wrong, although the error message text is unclear + enough to make it appear plausible. + */ + ret= ISO_FILE_CANT_WRITE; +#endif + + if(ret >= 0) + ret = -1; + sprintf(msg, "ds_read_block(%lu) returns %d", (unsigned long) lba, ret); + isoburn_msgs_submit(NULL, 0x00060000, msg, 0, "DEBUG", 0); + return ret; + } + +#ifdef Libisoburn_read_cache_reporT + fprintf(stderr, "Tile %2.2d : After %3d hits, new load from %8x , count= %d\n", + oldest, tiles[oldest].cache_hits, aligned_lba, (int) count); +#endif + + tiles[oldest].cache_lba= aligned_lba; + tiles[oldest].cache_hits= 1; + ds_inc_age(icd, oldest, 0); + + memcpy(buffer, tiles[oldest].cache_data + (lba - aligned_lba) * 2048, 2048); + count= 2048; + + return 1; +} + + +static int ds_open(IsoDataSource *src) +{ + /* nothing to do, device is always grabbed */ + return 1; +} + +static int ds_close(IsoDataSource *src) +{ + /* nothing to do, device is always grabbed */ + return 1; +} + +static void ds_free_data(IsoDataSource *src) +{ + /* nothing to do */; + if(src->data != NULL) + free(src->data); + src->data= NULL; +} + + +int isoburn_data_source_shutdown(IsoDataSource *src, int flag) +{ + struct isoburn_cached_drive *icd; + + if(src==NULL) + return(0); + icd= (struct isoburn_cached_drive *) src->data; + icd->drive= NULL; + return(1); +} + + +IsoDataSource *isoburn_data_source_new(struct burn_drive *d) +{ + IsoDataSource *ret; + struct isoburn_cached_drive *icd= NULL; + int i; + + if (d==NULL) + return NULL; + ret = malloc(sizeof(IsoDataSource)); + icd = calloc(1,sizeof(struct isoburn_cached_drive)); + if (ret == NULL || icd == NULL) + return NULL; + ret->refcount = 1; + ret->read_block = ds_read_block; + ret->open = ds_open; + ret->close = ds_close; + ret->free_data = ds_free_data; + ret->data = icd; + icd->drive = d; + icd->current_age= 0; + for(i= 0; itiles[i].cache_lba = 0xffffffff; + icd->tiles[i].cache_hits = 0; + icd->tiles[i].last_error_lba = 0xffffffff; + icd->tiles[i].last_aligned_error_lba = 0xffffffff; + icd->tiles[i].age= 0; + } + return ret; +} + + +static int ds_inc_age(struct isoburn_cached_drive *icd, int idx, int flag) +{ + int i; + + (icd->current_age)++; + if(icd->current_age>=Libisoburn_max_agE) { /* reset all ages (allow waste) */ + for(i= 0; itiles)[i].age= 0; + icd->current_age= 1; + } + (icd->tiles)[idx].age= icd->current_age; + return(1); +} + + diff --git a/libisoburn/branches/ZeroFourTwo/libisoburn/isoburn.c b/libisoburn/branches/ZeroFourTwo/libisoburn/isoburn.c new file mode 100644 index 00000000..a0dacaaf --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/libisoburn/isoburn.c @@ -0,0 +1,1029 @@ + +/* + cc -g -c isoburn.c +*/ + +/* + Class core of libisoburn. + + Copyright 2007 - 2009 Vreixo Formoso Lopes + Thomas Schmitt +*/ + +/* ( derived from stub generated by CgeN on Sat, 01 Sep 2007 12:04:36 GMT ) */ + +#include +#include +#include +#include +#include +#include + +#ifndef Xorriso_standalonE + +#include + +#include + +#else /* ! Xorriso_standalonE */ + +#include "../libisofs/libisofs.h" +#include "../libburn/libburn.h" + +#endif /* Xorriso_standalonE */ + + +#include "libisoburn.h" + +#include "isoburn.h" + + +/* Default values for application provided msgs_submit methods. + To be attached to newly aquired drives. +*/ +int (*libisoburn_default_msgs_submit) + (void *handle, int error_code, char msg_text[], + int os_errno, char severity[], int flag)= NULL; +void *libisoburn_default_msgs_submit_handle= NULL; +int libisoburn_default_msgs_submit_flag= 0; + + +/* ----------------------- isoburn_toc_entry ---------------------- */ + + +int isoburn_toc_entry_new(struct isoburn_toc_entry **objpt, + struct isoburn_toc_entry *boss, int flag) +{ + struct isoburn_toc_entry *o, *s; + + *objpt= o= (struct isoburn_toc_entry *) + malloc(sizeof(struct isoburn_toc_entry)); + if(o==NULL) { + isoburn_msgs_submit(NULL, 0x00060000, + "Cannot allocate memory for isoburn toc entry", + 0, "FATAL", 0); + return(-1); + } + o->session= 0; + o->track_no= 0; + o->start_lba= -1; + o->track_blocks= 0; + o->volid= NULL; + o->next= NULL; + if(boss!=NULL) { + for(s= boss; s->next!=NULL; s= s->next); + s->next= o; + } + return(1); +} + + +/* @param flag bit0= delete all subordinates too +*/ +int isoburn_toc_entry_destroy(struct isoburn_toc_entry **o, int flag) +{ + if(*o==NULL) + return(0); + if(flag&1) + isoburn_toc_entry_destroy(&((*o)->next), flag); + if((*o)->volid != NULL) + free((*o)->volid); + free((char *) (*o)); + *o= NULL; + return(1); +} + + +/* --------------------- end isoburn_toc_entry -------------------- */ + +/* -------------------------- isoburn ----------------------- */ + + +/* The global list of isoburn objects. Usually there is only one. + >>> we are not ready for multiple control threads yet. See >>> mutex . + Multiple burns under one control thread should work. +*/ +struct isoburn *isoburn_list_start= NULL; + + +int isoburn_new(struct isoburn **objpt, int flag) +{ + struct isoburn *o; + int i, ret; + + *objpt= o= (struct isoburn *) malloc(sizeof(struct isoburn)); + if(o==NULL) { + isoburn_msgs_submit(NULL, 0x00060000, + "Cannot allocate memory for isoburn control object", + 0, "FATAL", 0); + return(-1); + } + + o->drive= NULL; + o->emulation_mode= 0; + o->fabricated_msc1= -1; + o->fabricated_msc2= -1; + o->zero_nwa= Libisoburn_overwriteable_starT; + o->min_start_byte= o->zero_nwa * 2048; + o->nwa= o->zero_nwa; + o->truncate= 0; + o->iso_source= NULL; + o->fabricated_disc_status= BURN_DISC_UNREADY; + o->toc= NULL; + o->wrote_well= -1; + for(i=0;itarget_iso_head[i]= 0; + o->image= NULL; + o->iso_data_source= NULL; + o->read_pacifier= NULL; + o->read_pacifier_handle= NULL; + o->msgs_submit= NULL; + o->msgs_submit_handle= NULL; + o->msgs_submit_flag= 0; + o->prev= NULL; + o->next= NULL; + ret= iso_image_new("ISOIMAGE", &o->image); + if(ret<0) { + isoburn_report_iso_error(ret, "Cannot create image", 0, "FATAL", 0); + goto failed; + } + isoburn_link(o, isoburn_list_start, 1); + return(1); +failed:; + isoburn_destroy(objpt, 0); + return(-1); +} + + +int isoburn_destroy(struct isoburn **objpt, int flag) +{ + struct isoburn *o; + + o= *objpt; + if(o==NULL) + return(0); + + /* >>> mutex */ + + if(o==isoburn_list_start) + isoburn_list_start= o->next; + if(o->prev!=NULL) + o->prev->next= o->next; + if(o->next!=NULL) + o->next->prev= o->prev; + + /* >>> end mutex */ + + if(o->image!=NULL) + iso_image_unref(o->image); + if(o->toc!=NULL) + isoburn_toc_entry_destroy(&(o->toc), 1); /* all */ + if(o->iso_source!=NULL) + burn_source_free(o->iso_source); + if(o->iso_data_source!=NULL) + iso_data_source_unref(o->iso_data_source); + free((char *) o); + *objpt= NULL; + return(1); +} + + +int isoburn_destroy_all(struct isoburn **objpt, int flag) +{ + struct isoburn *o,*n; + + o= *objpt; + if(o==NULL) + return(0); + for(;o->prev!=NULL;o= o->prev); + for(;o!=NULL;o= n) { + n= o->next; + isoburn_destroy(&o,0); + } + *objpt= NULL; + return(1); +} + + +int isoburn_get_target_image(struct isoburn *o, IsoImage **pt, int flag) +{ + *pt= o->image; + return(1); +} + + +int isoburn_get_prev(struct isoburn *o, struct isoburn **pt, int flag) +{ + *pt= o->prev; + return(1); +} + + +int isoburn_get_next(struct isoburn *o, struct isoburn **pt, int flag) +{ + *pt= o->next; + return(1); +} + + +int isoburn_link(struct isoburn *o, struct isoburn *link, int flag) +/* + bit0= insert as link->prev rather than as link->next +*/ +{ + + /* >>> mutex */ + + if(isoburn_list_start==NULL || + (isoburn_list_start==link && (flag&1))) + isoburn_list_start= o; + if(o->prev!=NULL) + o->prev->next= o->next; + if(o->next!=NULL) + o->next->prev= o->prev; + o->prev= o->next= NULL; + if(link==NULL) + return(1); + if(flag&1) { + o->next= link; + o->prev= link->prev; + if(o->prev!=NULL) + o->prev->next= o; + link->prev= o; + } else { + o->prev= link; + o->next= link->next; + if(o->next!=NULL) + o->next->prev= o; + link->next= o; + } + + /* >>> end mutex */ + + return(1); +} + + +int isoburn_count(struct isoburn *o, int flag) +/* flag: bit1= count from start of list */ +{ + int counter= 0; + + if(flag&2) + for(;o->prev!=NULL;o= o->prev); + for(;o!=NULL;o= o->next) + counter++; + return(counter); +} + + +int isoburn_by_idx(struct isoburn *o, int idx, struct isoburn **pt, int flag) +/* flag: bit0= fetch first (idx<0) or last (idx>0) item in list + bit1= address from start of list */ +{ + int i,abs_idx; + struct isoburn *npt; + + if(flag&2) + for(;o->prev!=NULL;o= o->prev); + abs_idx= (idx>0?idx:-idx); + *pt= o; + for(i= 0;(i0) + npt= o->next; + else + npt= o->prev; + if(npt==NULL && (flag&1)) + break; + *pt= npt; + } + return(*pt!=NULL); +} + + +int isoburn_find_by_drive(struct isoburn **pt, struct burn_drive *d, int flag) +{ + struct isoburn *o; + + *pt= NULL; + for(o= isoburn_list_start;o!=NULL;o= o->next) + if(o->drive==d) { + *pt= o; + return(1); + } + return(0); +} + + +int isoburn_msgs_submit(struct isoburn *o, int error_code, char msg_text[], + int os_errno, char severity[], int flag) +{ + int ret, use_drive_method= 0; + + if(o!=NULL) + if(o->msgs_submit!=NULL) + use_drive_method= 1; + if(use_drive_method) { + ret= o->msgs_submit(o->msgs_submit_handle, error_code, msg_text, os_errno, + severity, o->msgs_submit_flag); + return(ret); + } + if(libisoburn_default_msgs_submit != NULL) { + ret= libisoburn_default_msgs_submit(libisoburn_default_msgs_submit_handle, + error_code, msg_text, os_errno, severity, + libisoburn_default_msgs_submit_flag); + return(ret); + } + /* Fallback: use message queue of libburn */ + burn_msgs_submit(error_code, msg_text, os_errno, severity, NULL); + return(1); +} + + +/* @param flag bit0= modifying rather than growing + bit1= prepare for early release of input drive: + wait until input and then disable image data source +*/ +static +int isoburn_prepare_disc_aux(struct burn_drive *in_d, struct burn_drive *out_d, + struct burn_disc **disc, + struct isoburn_imgen_opts *opts, int flag) +{ + struct burn_source *wsrc; + struct burn_session *session; + struct burn_track *track; + struct isoburn *in_o, *out_o; + IsoWriteOpts *wopts= NULL; + enum burn_disc_status state; + int ret, fifo_chunks, lba, nwa, i, new_img, early_indev_release; + uint32_t data_start= -1; + size_t buffer_size= 0, buffer_free= 0; + char msg[160]; + + new_img= flag&1; + early_indev_release= flag&2; + if(new_img && early_indev_release) { + isoburn_msgs_submit(in_o, 0x00060000, + "Programming error: Wrong session setup: new_img && early_indev_release", + 0, "FATAL", 0); + {ret= -4; goto ex;} + } + + ret= isoburn_find_emulator(&in_o, in_d, 0); + if(ret<0 || in_o==NULL) + {ret= -1; goto ex;} + ret= isoburn_find_emulator(&out_o, out_d, 0); + if(ret<0 || out_o==NULL) + {ret= -1; goto ex;} + /* early end will be registered as failure */ + in_o->wrote_well= out_o->wrote_well= 0; + + state = isoburn_disc_get_status(in_d); + if (state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE && + state != BURN_DISC_FULL) { + isoburn_msgs_submit(in_o, 0x00060000, "Unsuitable source media state", + 0, "FAILURE", 0); + {ret= -2; goto ex;} + } + state = isoburn_disc_get_status(out_d); + if (state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE) { + isoburn_msgs_submit(out_o, 0x00060000, "Unsuitable target media state", + 0, "FAILURE", 0); + {ret= -2; goto ex;} + } + + fifo_chunks= 32; + if(opts->fifo_size >= 64*1024 && opts->fifo_size <= 1024.0 * 1024.0 * 1024.0){ + fifo_chunks= opts->fifo_size/2048; + if(fifo_chunks*2048 < opts->fifo_size) + fifo_chunks++; + } + + ret = iso_write_opts_new(&wopts, 0); + if (ret < 0) { + isoburn_report_iso_error(ret, "Cannot create iso_write_opts", 0, "FATAL",0); + goto ex; + } + iso_write_opts_set_iso_level(wopts, opts->level); + iso_write_opts_set_rockridge(wopts, opts->rockridge); + iso_write_opts_set_joliet(wopts, opts->joliet); + iso_write_opts_set_iso1999(wopts, opts->iso1999); + + /* <<< #ifdef shall be removed when libisofs-0.6.20 is released */ +#ifdef Libisofs_hardlink_prooF + + iso_write_opts_set_hardlinks(wopts, opts->hardlinks); + if(opts->hardlinks) + iso_write_opts_set_rrip_1_10_px_ino(wopts, 1); + +#endif + + iso_write_opts_set_aaip(wopts, opts->aaip); + iso_write_opts_set_omit_version_numbers(wopts, opts->omit_version_numbers); + iso_write_opts_set_allow_deep_paths(wopts, opts->allow_deep_paths); + iso_write_opts_set_allow_longer_paths(wopts, opts->allow_longer_paths); + iso_write_opts_set_max_37_char_filenames(wopts, opts->max_37_char_filenames); + iso_write_opts_set_no_force_dots(wopts, opts->no_force_dots); + iso_write_opts_set_allow_lowercase(wopts, opts->allow_lowercase); + iso_write_opts_set_allow_full_ascii(wopts, opts->allow_full_ascii); + iso_write_opts_set_relaxed_vol_atts(wopts, 1); + iso_write_opts_set_joliet_longer_paths(wopts, opts->joliet_longer_paths); + iso_write_opts_set_always_gmt(wopts, opts->always_gmt); + iso_write_opts_set_rrip_version_1_10(wopts, opts->rrip_version_1_10); + iso_write_opts_set_dir_rec_mtime(wopts, opts->dir_rec_mtime); + iso_write_opts_set_aaip_susp_1_10(wopts, opts->aaip_susp_1_10); + iso_write_opts_set_sort_files(wopts, opts->sort_files); + iso_write_opts_set_record_md5(wopts, opts->session_md5, opts->file_md5 & 3); + iso_write_opts_set_replace_mode(wopts, opts->replace_dir_mode, + opts->replace_file_mode, opts->replace_uid, opts->replace_gid); + iso_write_opts_set_default_dir_mode(wopts, opts->dir_mode); + iso_write_opts_set_default_file_mode(wopts, opts->file_mode); + iso_write_opts_set_default_uid(wopts, opts->uid); + iso_write_opts_set_default_gid(wopts, opts->gid); + iso_write_opts_set_output_charset(wopts, opts->output_charset); + iso_write_opts_set_fifo_size(wopts, fifo_chunks); + + ret = isoburn_disc_track_lba_nwa(out_d, NULL, 0, &lba, &nwa); + opts->effective_lba= nwa; + ret= isoburn_get_msc2(out_o, NULL, &nwa, 0); + if (ret != 1) { + isoburn_msgs_submit(out_o, 0x00060000, + "Cannot determine next writeable address", 0, "FAILURE", 0); + {ret= -3; goto ex;} + } + iso_write_opts_set_ms_block(wopts, nwa); + iso_write_opts_set_appendable(wopts, !new_img); + iso_write_opts_set_overwrite_buf(wopts, + nwa>0 ? out_o->target_iso_head : NULL); + + ret = iso_image_create_burn_source(in_o->image, wopts, &wsrc); + if (ret < 0) { + isoburn_report_iso_error(ret, "Cannot create burn source", 0, "FAILURE", 0); + {ret= -1; goto ex;} + } + if (early_indev_release) { + for(i= 0; i<300; i++) { + + /* <<< ??? */ + if((i%30) == 0) { + sprintf(msg, "Waiting for data in fifo since %d seconds", i/30); + isoburn_msgs_submit(in_o, 0x00060000, msg, 0, "DEBUG", 0); + } + + usleep(100000); + ret= iso_ring_buffer_get_status(wsrc, &buffer_size, &buffer_free); + if(ret >0 && buffer_size != buffer_free) + break; + } + + /* <<< ??? */ + sprintf(msg, + "After %.1f seconds: %d bytes of output available (fifo state=%d)", + ((double) i+1) / 10.0, (int) (buffer_size - buffer_free), ret); + isoburn_msgs_submit(in_o, 0x00060000, msg, 0, "DEBUG", 0); + + if(in_o->iso_data_source!=NULL) + isoburn_data_source_shutdown(in_o->iso_data_source, 0); + } + + ret= iso_write_opts_get_data_start(wopts, &data_start, 0); + opts->data_start_lba= -1; + if(ret > 0 && data_start <= 0x7FFFFFFF) + opts->data_start_lba= data_start; + + /* TODO check return values for failure. propertly clean-up on error */ + + out_o->iso_source= wsrc; + + *disc = burn_disc_create(); + session = burn_session_create(); + burn_disc_add_session(*disc, session, BURN_POS_END); + track = burn_track_create(); + burn_track_set_source(track, out_o->iso_source); + burn_session_add_track(session, track, BURN_POS_END); + + /* give up local references */ + burn_track_free(track); + burn_session_free(session); + + in_o->wrote_well= out_o->wrote_well= -1; /* neutral */ + ret= 1; +ex: + if(wopts!=NULL) + {iso_write_opts_free(wopts); wopts= NULL;} + return ret; +} + + +int isoburn_prepare_disc(struct burn_drive *d, struct burn_disc **disc, + struct isoburn_imgen_opts *opts) +{ + return isoburn_prepare_disc_aux(d, d, disc, opts, 0); +} + + +int isoburn_prepare_new_image(struct burn_drive *d, struct burn_disc **disc, + struct isoburn_imgen_opts *opts, + struct burn_drive *out_drive) +{ + int ret; + + ret= isoburn_prepare_disc_aux(d, out_drive, disc, opts, 1); + if (ret<=0) + return ret; + return 1; +} + + +/* API since 0.2.2 */ +int isoburn_prepare_blind_grow(struct burn_drive *d, struct burn_disc **disc, + struct isoburn_imgen_opts *opts, + struct burn_drive *out_drive, int nwa) +{ + int ret; + struct isoburn *o= NULL; + + ret= isoburn_find_emulator(&o, out_drive, 0); + if(ret<0 || o==NULL) + return(-1); + if(nwa >= 0) + o->fabricated_msc2= nwa; + if(o->nwa == o->zero_nwa) + o->nwa= o->zero_nwa= 0; + else + o->zero_nwa= 0; + ret= isoburn_prepare_disc_aux(d, out_drive, disc, opts, 2); + if (ret<=0) + return ret; + return(1); +} + + +/* API @since 0.1.0 + @param flag bit0= this is a regular end, not an abort + give up source reference +*/ +int isoburn_cancel_prepared_write(struct burn_drive *d, + struct burn_drive *output_drive, int flag) +{ + int ret; + struct isoburn *o= NULL; + + if(output_drive!=NULL) { + ret= isoburn_find_emulator(&o, output_drive, 0); + if(ret<0 || o==NULL) + o= NULL; + else if(o->iso_source==NULL) + o= NULL; + } + if(o==NULL) { + ret= isoburn_find_emulator(&o, d, 0); + if(ret<0) + return(-1); + if(o==NULL) + return(0); + if(o->iso_source==NULL) + return(0); + } + if(o->iso_source->read!=NULL) + return(0); + if(o->iso_source->version<1) + return(0); + o->iso_source->cancel(o->iso_source); + burn_source_free(o->iso_source); + o->iso_source= NULL; + return(1); +} + + +/* API @since 0.1.0 */ +int isoburn_sync_after_write(struct burn_drive *d, + struct burn_drive *output_drive, int flag) +{ + return isoburn_cancel_prepared_write(d, output_drive, 1); +} + + +void isoburn_version(int *major, int *minor, int *micro) +{ + *major= isoburn_header_version_major; + *minor= isoburn_header_version_minor; + *micro= isoburn_header_version_micro; + +/* No more: values from version.h generated from version.h.in and + macro values defined in configure.ac + + *major = ISOBURN_MAJOR_VERSION; + *minor = ISOBURN_MINOR_VERSION; + *micro = ISOBURN_MICRO_VERSION; +*/ +} + + +int isoburn_is_compatible(int major, int minor, int micro, int flag) +{ + int own_major, own_minor, own_micro; + + isoburn_version(&own_major, &own_minor, &own_micro); + return(own_major > major || + (own_major == major && (own_minor > minor || + (own_minor == minor && own_micro >= micro)))); +} + + +/* ----------------------------------------------------------------------- */ +/* + Options for image reading. +*/ +/* ----------------------------------------------------------------------- */ + + +int isoburn_ropt_new(struct isoburn_read_opts **new_o, int flag) +{ + struct isoburn_read_opts *o; + + o= (*new_o)= calloc(1, sizeof(struct isoburn_read_opts)); + if(o==NULL) { + isoburn_msgs_submit(NULL, 0x00060000, + "Cannot allocate memory for read options", 0, "FATAL", 0); + return(-1); + } + o->norock= 0; + o->nojoliet= 0; + o->noiso1999= 1; + o->noaaip= 1; + o->noacl= 1; + o->noea= 1; + o->noino= 1; + o->nomd5= 1; + o->preferjoliet= 0; + o->uid= geteuid(); + o->gid= getegid(); + o->mode= 0444; + o->dirmode= 0555; + o->input_charset= NULL; + o->hasRR= 0; + o->hasJoliet= 0; + o->hasIso1999= 0; + o->hasElTorito= 0; + o->size= 0; + o->pretend_blank= 1; + return(1); +} + + +int isoburn_ropt_destroy(struct isoburn_read_opts **o, int flag) +{ + if(*o==NULL) + return(0); + free(*o); + *o= NULL; + return(1); +} + + +int isoburn_ropt_set_extensions(struct isoburn_read_opts *o, int ext) +{ + o->norock= !!(ext&1); + o->nojoliet= !!(ext&2); + o->noiso1999= !!(ext&4); + o->preferjoliet= !!(ext&8); + o->pretend_blank= !!(ext&16); + o->noaaip= !!(ext & 32); + o->noacl= !!(ext & 64); + o->noea= !!(ext & 128); + o->noino= !!(ext & 256); + o->nomd5= !!(ext & 512); + return(1); +} + + +int isoburn_ropt_get_extensions(struct isoburn_read_opts *o, int *ext) +{ + *ext= (!!o->norock) | ((!!o->nojoliet)<<1) | ((!!o->noiso1999)<<2) | + ((!!o->preferjoliet)<<3) | ((!!o->pretend_blank)<<4) | + ((!!o->noaaip) << 5) | ((!!o->noacl) << 6) | ((!!o->noea) << 7) | + ((!!o->noino) << 8) | ((!!o->nomd5) << 9); + return(1); +} + + +int isoburn_ropt_set_default_perms(struct isoburn_read_opts *o, + uid_t uid, gid_t gid, mode_t mode) +{ + mode_t dirmode; + + o->uid= uid; + o->gid= gid; + o->mode= mode; + dirmode= mode; + if(dirmode & S_IRUSR) + dirmode|= S_IXUSR; + if(dirmode & S_IRGRP) + dirmode|= S_IXGRP; + if(dirmode & S_IROTH) + dirmode|= S_IXOTH; + o->dirmode= dirmode; + return(1); +} + + +int isoburn_ropt_get_default_perms(struct isoburn_read_opts *o, + uid_t *uid, gid_t *gid, mode_t *mode) +{ + *uid= o->uid; + *gid= o->gid; + *mode= o->mode; + return(1); +} + + +int isoburn_ropt_set_default_dirperms(struct isoburn_read_opts *o, + mode_t mode) +{ + o->dirmode= mode; + return(1); +} + + +int isoburn_ropt_get_default_dirperms(struct isoburn_read_opts *o, + mode_t *mode) +{ + *mode= o->dirmode; + return(1); +} + + +int isoburn_ropt_set_input_charset(struct isoburn_read_opts *o, + char *input_charset) +{ + o->input_charset= input_charset; + return(1); +} + + +int isoburn_ropt_get_input_charset(struct isoburn_read_opts *o, + char **input_charset) +{ + *input_charset= o->input_charset; + return(1); +} + + +int isoburn_ropt_set_auto_incharset(struct isoburn_read_opts *o, int mode) +{ + o->auto_input_charset= mode & 1; + return(1); +} + + +int isoburn_ropt_get_auto_incharset(struct isoburn_read_opts *o, int *mode) +{ + *mode= o->auto_input_charset; + return(1); +} + + +int isoburn_ropt_get_size_what(struct isoburn_read_opts *o, + uint32_t *size, int *has_what) +{ + *size= o->size; + *has_what= (!!o->hasRR) | ((!!o->hasJoliet)<<1) | + ((!!o->hasIso1999)<<2) | ((!!o->hasElTorito)<<3); + return(1); +} + + +/* ----------------------------------------------------------------------- */ +/* + Options for image generation by libisofs and image transport to libburn. +*/ +/* ----------------------------------------------------------------------- */ + + +int isoburn_igopt_new(struct isoburn_imgen_opts **new_o, int flag) +{ + struct isoburn_imgen_opts *o; + + o= (*new_o)= calloc(1, sizeof(struct isoburn_imgen_opts)); + if(o==NULL) { + isoburn_msgs_submit(NULL, 0x00060000, + "Cannot allocate memory for image generation options", + 0, "FATAL", 0); + return(-1); + } + o->level= 2; + o->rockridge= 1; + o->joliet= 0; + o->iso1999= 0; + o->hardlinks= 0; + o->aaip = 0; + o->omit_version_numbers= 0; + o->allow_deep_paths= 1; + o->allow_longer_paths= 0; + o->max_37_char_filenames= 0; + o->no_force_dots= 0; + o->allow_lowercase= 0; + o->allow_full_ascii= 0; + o->joliet_longer_paths= 0; + o->always_gmt= 0; + o->rrip_version_1_10= 0; + o->dir_rec_mtime= 0; + o->aaip_susp_1_10= 0; + o->sort_files= 0; + o->replace_dir_mode= 0; + o->replace_file_mode= 0; + o->replace_uid= 0; + o->replace_gid= 0; + o->dir_mode= 0555; + o->file_mode= 0444; + o->uid= 0; + o->gid= 0; + o->output_charset= NULL; + o->fifo_size= 4*1024*1024; + o->effective_lba= -1; + o->data_start_lba= -1; + return(1); +} + + +int isoburn_igopt_destroy(struct isoburn_imgen_opts **o, int flag) +{ + if(*o==NULL) + return(0); + free(*o); + *o= NULL; + return(1); +} + + +int isoburn_igopt_set_level(struct isoburn_imgen_opts *o, int level) +{ + o->level= level; + return(1); +} + + +int isoburn_igopt_get_level(struct isoburn_imgen_opts *o, int *level) +{ + *level= o->level; + return(1); +} + + +int isoburn_igopt_set_extensions(struct isoburn_imgen_opts *o, int ext) +{ + o->rockridge= !!(ext&1); + o->joliet= !!(ext&2); + o->iso1999= !!(ext&4); + o->hardlinks= !!(ext & 8); + o->aaip= !!(ext & 32); + o->session_md5= !!(ext & 64); + o->file_md5= (ext & (128 | 256)) >> 7; + return(1); +} + + +int isoburn_igopt_get_extensions(struct isoburn_imgen_opts *o, int *ext) +{ + *ext= (!!o->rockridge) | ((!!o->joliet)<<1) | ((!!o->iso1999)<<2) | + ((!!o->hardlinks) << 3) | ((!!o->aaip) << 5) | + ((!!o->session_md5) << 6) | ((o->file_md5 & 3) << 7); + return(1); +} + + +int isoburn_igopt_set_relaxed(struct isoburn_imgen_opts *o, int relax) +{ + o->omit_version_numbers= !!(relax&1); + o->allow_deep_paths= !!(relax&2); + o->allow_longer_paths= !!(relax&4); + o->max_37_char_filenames= !!(relax&8); + o->no_force_dots= !!(relax&16); + o->allow_lowercase= !!(relax&32); + o->allow_full_ascii= !!(relax&64); + o->joliet_longer_paths= !!(relax&128); + o->always_gmt= !!(relax & isoburn_igopt_always_gmt); + o->rrip_version_1_10= !!(relax & isoburn_igopt_rrip_version_1_10); + o->dir_rec_mtime= !!(relax & isoburn_igopt_dir_rec_mtime); + o->aaip_susp_1_10= !!(relax & isoburn_igopt_aaip_susp_1_10); + return(1); +} + + +int isoburn_igopt_get_relaxed(struct isoburn_imgen_opts *o, int *relax) +{ + *relax= (!!o->omit_version_numbers) | ((!!o->allow_deep_paths)<<1) | + ((!!o->allow_longer_paths)<<2) | ((!!o->max_37_char_filenames)<<3) | + ((!!o->no_force_dots)<<4) | ((!!o->allow_lowercase)<<5) | + ((!!o->allow_full_ascii)<<6) | ((!!o->joliet_longer_paths)<<7) | + ((!!o->always_gmt)<<8) | ((!!o->rrip_version_1_10)<<9) | + ((!!o->dir_rec_mtime)<<10) | ((!!o->aaip_susp_1_10)<<11); + return(1); +} + + +int isoburn_igopt_set_sort_files(struct isoburn_imgen_opts *o, int value) +{ + o->sort_files= !!(value&1); + return(1); +} + + +int isoburn_igopt_get_sort_files(struct isoburn_imgen_opts *o, int *value) +{ + *value= !!o->sort_files; + return(1); +} + + +int isoburn_igopt_set_over_mode(struct isoburn_imgen_opts *o, + int replace_dir_mode, int replace_file_mode, + mode_t dir_mode, mode_t file_mode) +{ + o->replace_dir_mode= replace_dir_mode%3; + o->replace_file_mode= replace_file_mode%3; + o->dir_mode= dir_mode; + o->file_mode= file_mode; + return(1); +} + + +int isoburn_igopt_get_over_mode(struct isoburn_imgen_opts *o, + int *replace_dir_mode, int *replace_file_mode, + mode_t *dir_mode, mode_t *file_mode) +{ + *replace_dir_mode= o->replace_dir_mode%3; + *replace_file_mode= o->replace_file_mode%3; + *dir_mode= o->dir_mode; + *file_mode= o->file_mode; + return(1); +} + + +int isoburn_igopt_set_over_ugid(struct isoburn_imgen_opts *o, + int replace_uid, int replace_gid, + uid_t uid, gid_t gid) +{ + o->replace_uid= replace_uid%3; + o->replace_gid= replace_gid%3; + o->uid= uid; + o->gid= gid; + return(1); +} + +int isoburn_igopt_get_over_ugid(struct isoburn_imgen_opts *o, + int *replace_uid, int *replace_gid, + uid_t *uid, gid_t *gid) +{ + *replace_uid= o->replace_uid%3; + *replace_gid= o->replace_gid%3; + *uid= o->uid; + *gid= o->gid; + return(1); +} + + +int isoburn_igopt_set_out_charset(struct isoburn_imgen_opts *o, + char *output_charset) +{ + o->output_charset= output_charset; + return(1); +} + + +int isoburn_igopt_get_out_charset(struct isoburn_imgen_opts *o, + char **output_charset) +{ + *output_charset= o->output_charset; + return(1); +} + + +int isoburn_igopt_set_fifo_size(struct isoburn_imgen_opts *o, int fifo_size) +{ + o->fifo_size= fifo_size; + return(1); +} + + +int isoburn_igopt_get_fifo_size(struct isoburn_imgen_opts *o, int *fifo_size) +{ + *fifo_size= o->fifo_size; + return(1); +} + + +int isoburn_igopt_get_effective_lba(struct isoburn_imgen_opts *o, int *lba) +{ + *lba= o->effective_lba; + return(1); +} + + +int isoburn_igopt_get_data_start(struct isoburn_imgen_opts *o, int *lba) +{ + *lba= o->data_start_lba; + return(1); +} + diff --git a/libisoburn/branches/ZeroFourTwo/libisoburn/isoburn.h b/libisoburn/branches/ZeroFourTwo/libisoburn/isoburn.h new file mode 100644 index 00000000..4411e3ce --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/libisoburn/isoburn.h @@ -0,0 +1,543 @@ + +/* + Class struct of libisoburn. + + Copyright 2007 Vreixo Formoso Lopes + and Thomas Schmitt +*/ + +#ifndef Isoburn_includeD +#define Isoburn_includeD + + +/* for uint8_t */ +#include + +/* For emulated TOC of overwriteable media. + Provides minimal info for faking a struct burn_toc_entry. +*/ +struct isoburn_toc_entry { + int session; + int track_no; /* point */ + int start_lba; + int track_blocks; + + char *volid; /* For caching a volume id from emulated toc on overwriteables */ + + struct isoburn_toc_entry *next; +}; + +int isoburn_toc_entry_new(struct isoburn_toc_entry **objpt, + struct isoburn_toc_entry *boss, int flag); + +/* @param flag bit0= delete all subordinates too +*/ +int isoburn_toc_entry_destroy(struct isoburn_toc_entry **o, int flag); + + +/* Size of target_iso_head which is to be written during + isoburn_activate_session() +*/ +#define Libisoburn_target_head_sizE (32*2048) + +struct isoburn { + + + /* The libburn drive to which this isoburn object is related + Most isoburn calls will use a burn_drive as object handle */ + struct burn_drive *drive; + + /* -1= inappropriate media state detected + 0= libburn multi-session media, resp. undecided yet + 1= random access media */ + int emulation_mode; + + /* Although rarely used, libburn can operate on several + drives simultaneously. */ + struct isoburn *prev; + struct isoburn *next; + + + /* If >= 0, this address is used as reply for isoburn_disc_get_msc1() + */ + int fabricated_msc1; + + /* If >= 0, this address is used in isoburn_disc_track_lba_nwa() + as reply parameter nwa. + (The other nwa parameters below apply only to the effective write address + on random access media. msc2 is handed to libisofs but not to libburn.) + */ + int fabricated_msc2; + + + /* The nwa to be used for a first session on the present kind of overwriteable + media (usually Libisoburn_overwriteable_starT, but might be forced to 0) + */ + int zero_nwa; + + /* Start address as given by image examination (bytes, not blocks) */ + off_t min_start_byte; + + /* Aligned start address to be used for processing (counted in blocks) */ + int nwa; + + + /* Truncate to .nwa an eventual regular file serving as output drive */ + int truncate; + + /* Eventual freely fabricated isoburn_disc_get_status(). + BURN_DISC_UNREADY means that this variable is disabled + and normally emulated status is in effect. + */ + enum burn_disc_status fabricated_disc_status; + + /* Eventual emulated table of content read from the chain of ISO headers + on overwriteable media. + */ + struct isoburn_toc_entry *toc; + + /* Indicator wether the most recent burn run worked : + -1 = undetermined, ask libburn , 0 = failure , 1 = success + To be inquired by isoburn_drive_wrote_well() + */ + int wrote_well; + + + /* Buffered ISO head from media (should that become part of + ecma119_read_opts ?) */ + uint8_t target_iso_head[Libisoburn_target_head_sizE]; + + /* Libisofs image context */ + IsoImage *image; + + /* The block data source from which the existing image is read. + */ + IsoDataSource *iso_data_source; + + /* The burn source which transfers data from libisofs to libburn. + It has its own fifo. + */ + struct burn_source *iso_source; + + /* For iso_tree_set_report_callback() */ + int (*read_pacifier)(IsoImage*, IsoFileSource*); + + /* For iso_image_attach_data() */ + void *read_pacifier_handle; + + /* An application provided method to immediately deliver messages */ + int (*msgs_submit)(void *handle, int error_code, char msg_text[], + int os_errno, char severity[], int flag); + void *msgs_submit_handle; /* specific to application method */ + int msgs_submit_flag; /* specific to application method */ + +}; + + +/* Creation and disposal function */ +int isoburn_new(struct isoburn **objpt, int flag); +int isoburn_destroy(struct isoburn **objpt, int flag); + +/* Eventual readers for public attributes */ +/* ( put into separate .h file then ) */ +int isoburn_get_emulation_mode(struct isoburn *o, int *pt, int flag); +int isoburn_get_target_volset(struct isoburn *o, IsoImage **pt, int flag); + +/* List management */ +int isoburn_get_prev(struct isoburn *o, struct isoburn **pt, int flag); +int isoburn_get_next(struct isoburn *o, struct isoburn **pt, int flag); +int isoburn_destroy_all(struct isoburn **objpt, int flag); +int isoburn_link(struct isoburn *o, struct isoburn *link, int flag); +int isoburn_count(struct isoburn *o, int flag); +int isoburn_by_idx(struct isoburn *o, int idx, struct isoburn **pt, int flag); +int isoburn_find_by_drive(struct isoburn **pt, struct burn_drive *d, int flag); + + +/* Non API inner interfaces */ + +/* Submit a libisofs error to the libburn messenger. An application message + reader shall recognize the error code range and attribute it to the + libisofs message channel to which one cannot submit via API. + @param iso_error_code return value <= 0 from a libisofs API call. + @param default_msg_text is to be put out if iso_error_code leads to no + error message + @param os_errno operating system errno, submit 0 if none is known + @param min_severity minimum severity, might be be increased if libisofs + error severity surpasses min_severity. + @param flag Bitfield, submit 0 for now +*/ +int isoburn_report_iso_error(int iso_error_code, char default_msg_text[], + int os_errno, char min_severity[], int flag); + +/* Calls from burn_wrap.c into isofs_wrap.c */ + +int isoburn_start_emulation(struct isoburn *o, int flag); +int isoburn_invalidate_iso(struct isoburn *o, int flag); + + +/* Calls from isofs_wrap.c into burn_wrap.c */ + +/** Get an eventual isoburn object which is wrapped around the drive. + @param pt Eventually returns a pointer to the found object. + It is allowed to become NULL if return value is -1 or 0. + In this case, the drive is a genuine libburn drive + with no emulation activated by isoburn. + @param drive The drive to be searched for + @param flag unused yet + @return -1 unsuitable media, 0 generic media, 1 emulated media. +*/ +int isoburn_find_emulator(struct isoburn **pt, + struct burn_drive *drive, int flag); + +/* Deliver an event message. Either via a non-NULL o->msgs_submit() method + or via burn_msgs_submit() of libburn. +*/ +int isoburn_msgs_submit(struct isoburn *o, int error_code, char msg_text[], + int os_errno, char severity[], int flag); + +/** Set the start address for an emulated add-on session. The value will + be rounded up to the alignment necessary for the media. The aligned + value will be divided by 2048 and then put into o->nwa . + @param o The isoburn object to be programmed. + @param value The start address in bytes + @param flag unused yet + @return <=0 is failure , >0 success +*/ +int isoburn_set_start_byte(struct isoburn *o, off_t value, int flag); + +/** Obtains the image address offset to be used with image generation. + This is either the (emulated) drive nwa or a value set by + isoburn_prepare_blind_grow(). + In any case this is the address to tell to iso_write_opts_set_ms_block(). + @param o The isoburn object to be inquired + @param opts If not NULL: write parameters to be set on drive before query + @param msc2 The value to be used with iso_write_opts_set_ms_block() + @param flag unused yet + @return <=0 is failure , >0 success +*/ +int isoburn_get_msc2(struct isoburn *o, + struct burn_write_opts *opts, int *msc2, int flag); + +/** Get a data source suitable for read from a drive using burn_read_data() + function. + @param d drive to read from. Must be grabbed. + @return the data source, NULL on error. Must be freed with libisofs + iso_data_source_unref() function. Note: this doesn't release + the drive. +*/ +IsoDataSource * +isoburn_data_source_new(struct burn_drive *d); + +/** Disable read capabilities of a data source which was originally created + by isoburn_data_source_new(). After this any attempt to read will yield + a FATAL programming error event. + This is usually done to allow libburn to release the drive while libisofs + still holds a reference to the data source object. libisofs is not supposed + to use this object for reading any more, nevertheless. The disabled state + of the data source is a safety fence around this daring situation. + @param src The data source to be disabled + @param flag unused yet + @return <=0 is failure , >0 success +*/ +int isoburn_data_source_shutdown(IsoDataSource *src, int flag); + + +/** + * Options for image reading. + (Comments here may be outdated. API getter/setter function descriptions + may override the descriptions here. Any difference is supposed to be a + minor correction only.) + */ +struct isoburn_read_opts { + unsigned int norock:1; /*< Do not read Rock Ridge extensions */ + unsigned int nojoliet:1; /*< Do not read Joliet extensions */ + unsigned int noiso1999:1; /*< Do not read ISO 9660:1999 enhanced tree */ + + /* ts A90121 */ + unsigned int noaaip:1; /* Do not read AAIP for ACL and EA */ + unsigned int noacl:1; /* Do not read ACL from external file objects */ + unsigned int noea:1; /* Do not read XFS-style EA from externals */ + + /* ts A90508 */ + unsigned int noino:1; /* Discard eventual PX inode numbers */ + + /* ts A90810 */ + unsigned int nomd5:1; /* Do not read eventual MD5 array */ + + unsigned int preferjoliet:1; + /*< When both Joliet and RR extensions are present, the RR + * tree is used. If you prefer using Joliet, set this to 1. */ + uid_t uid; /**< Default uid when no RR */ + gid_t gid; /**< Default uid when no RR */ + mode_t mode; /**< Default mode when no RR (only permissions) */ + mode_t dirmode; /**< Default mode for directories + when no RR (only permissions) */ + + /** + * Input charset for RR file names. NULL to use default locale charset. + */ + char *input_charset; + + /** + * Enable or disable methods to automatically choose an input charset. + * This eventually overrides input_charset. + * + * bit0= allow to set the input character set automatically from + * attribute "isofs.cs" of root directory + */ + int auto_input_charset; + + /* modified by the function isoburn_read_image */ + unsigned int hasRR:1; /*< It will be set to 1 if RR extensions are present, + to 0 if not. */ + unsigned int hasJoliet:1; /*< It will be set to 1 if Joliet extensions are + present, to 0 if not. */ + + /** + * It will be set to 1 if the image is an ISO 9660:1999, i.e. it has + * a version 2 Enhanced Volume Descriptor. + */ + unsigned int hasIso1999:1; + + /** It will be set to 1 if El-Torito boot record is present, to 0 if not.*/ + unsigned int hasElTorito:1; + + uint32_t size; /**< Will be filled with the size (in 2048 byte block) of + * the image, as reported in the PVM. */ + unsigned int pretend_blank:1; /* always create empty image */ +}; + + +/** + * Options for image generation by libisofs and image transport to libburn. + (Comments here may be outdated. API getter/setter function descriptions + may override the descriptions here. Any difference is supposed to be a + minor correction only.) + */ +struct isoburn_imgen_opts { + + /* Options for image generation */ + + int level; /**< ISO level to write at. */ + + /** Which extensions to support. */ + unsigned int rockridge :1; + unsigned int joliet :1; + unsigned int iso1999 :1; + + /* Whether to mark suitable IsoNode as hardlinks in RRIP PX */ + unsigned int hardlinks :1; + + /* Write eventual AAIP info containing ACL and EA */ + unsigned int aaip :1; + + /* Produce and write a MD5 checksum of the whole session stream. */ + unsigned int session_md5 :1; + + /* Produce and write MD5 checksums for each single IsoFile. + See parameter files of iso_write_opts_set_record_md5(). + */ + unsigned int file_md5 :2; + + /* relaxed constraints */ + + /* + * Relaxed constraints. Setting any of these to 1 break the specifications, + * but it is supposed to work on most moderns systems. Use with caution. + */ + + /** + * Omit the version number (";1") at the end of the ISO-9660 identifiers. + * Version numbers are usually not used. + */ + unsigned int omit_version_numbers :1; + + /** + * Allow ISO-9660 directory hierarchy to be deeper than 8 levels. + */ + unsigned int allow_deep_paths :1; + + /** + * Allow path in the ISO-9660 tree to have more than 255 characters. + */ + unsigned int allow_longer_paths :1; + + /** + * Allow a single file or directory hierarchy to have up to 37 characters. + * This is larger than the 31 characters allowed by ISO level 2, and the + * extra space is taken from the version number, so this also forces + * omit_version_numbers. + */ + unsigned int max_37_char_filenames :1; + + /** + * ISO-9660 forces filenames to have a ".", that separates file name from + * extension. libisofs adds it if original filename doesn't has one. Set + * this to 1 to prevent this behavior + */ + unsigned int no_force_dots :1; + + /** + * Allow lowercase characters in ISO-9660 filenames. By default, only + * uppercase characters, numbers and a few other characters are allowed. + */ + unsigned int allow_lowercase :1; + + /** + * Allow all ASCII characters to be appear on an ISO-9660 filename. Note + * that "/" and "\0" characters are never allowed, even in RR names. + */ + unsigned int allow_full_ascii :1; + + /** + * Allow paths in the Joliet tree to have more than 240 characters. + */ + unsigned int joliet_longer_paths :1; + + /** + * Store timestamps as GMT rather than in local time. + */ + unsigned int always_gmt :1; + + /** + * Write Rock Ridge info as of specification RRIP-1.10 rather than + * RRIP-1.12: signature "RRIP_1991A" rather than "IEEE_1282", + * field PX without file serial number + */ + unsigned int rrip_version_1_10 :1; + + /** + * Store as ECMA-119 Directory Record timestamp the mtime + * of the source rather than the image creation time. + */ + unsigned int dir_rec_mtime :1; + + /** + * Write AAIP as extension according to SUSP 1.10 rather than SUSP 1.12. + * I.e. without announcing it by an ER field and thus without the need + * to preceed the RRIP fields by an ES and to preceed the AA field by ES. + */ + unsigned int aaip_susp_1_10 :1; + + unsigned int sort_files:1; + /**< If files should be sorted based on their weight. */ + + /** + * The following options set the default values for files and directory + * permissions, gid and uid. All these take one of three values: 0, 1 or 2. + * If 0, the corresponding attribute will be kept as set in the IsoNode. + * Unless you have changed it, it corresponds to the value on disc, so it + * is suitable for backup purposes. If set to 1, the corresponding attrib. + * will be changed by a default suitable value. Finally, if you set it to + * 2, the attrib. will be changed with the value specified in the options + * below. Note that for mode attributes, only the permissions are set, the + * file type remains unchanged. + */ + unsigned int replace_dir_mode :2; + unsigned int replace_file_mode :2; + unsigned int replace_uid :2; + unsigned int replace_gid :2; + + mode_t dir_mode; /** Mode to use on dirs when replace_dir_mode == 2. */ + mode_t file_mode; /** Mode to use on files when replace_file_mode == 2. */ + uid_t uid; /** uid to use when replace_uid == 2. */ + gid_t gid; /** gid to use when replace_gid == 2. */ + + char *output_charset; /**< NULL to use default charset */ + + + /* Options for image transport */ + + /** The number of bytes to be used for the fifo which decouples libisofs + and libburn for better throughput and for reducing the risk of + interrupting signals hitting the libburn thread which operates the + MMC drive. + The size will be rounded up to the next full 2048. + Minimum is 64kiB, maximum is 1 GiB (but that is too much anyway). + */ + int fifo_size; + + + /** Output value: Block address of session start as evaluated from media + and other options by libisoburn and libburn. + If <0 : Invalid + If >=0: Valid block number. Block size is always 2 KiB. + */ + int effective_lba; + + /** Output value: Block address of data section start as predicted by + libisofs. + If < 16: Invalid + If >=16: Valid block number. Block size is always 2 KiB. + */ + int data_start_lba; +}; + + +/* Alignment for session starts on overwriteable media. + (Increased from 16 to 32 blocks for aligning to BD-RE clusters.) +*/ +#define Libisoburn_nwa_alignemenT 32 + + +/* Alignment for outer session scanning with -ROM drives. + (E.g. my DVD-ROM drive shows any DVD type as 0x10 "DVD-ROM" with + more or less false capacity and TOC.) +*/ +#define Libisoburn_toc_scan_alignemenT 16 + +/* Maximum gap to be bridged during a outer TOC scan. Gaps appear between the + end of a session and the start of the next session. + The longest gap found so far was about 38100 after the first session of a + DVD-R. +*/ +#define Libisoburn_toc_scan_max_gaP 65536 + + +/* Creating a chain of image headers which form a TOC: + + The header of the first session is written after the LBA 0 header. + So it persists and can give the end of its session. By help of + Libisoburn_nwa_alignemenT it should be possible to predict the start + of the next session header. + The LBA 0 header is written by isoburn_activate_session() already + with the first session. So the media is mountable. + A problem arises with DVD-RW in Intermediate State. They cannot be + written by random access before they were written sequentially. + In this case, no copy of the session 1 header is maintained and no TOC + will be possible. Thus writing begins sequentially at LBA 0. +*/ +#define Libisoburn_overwriteable_starT \ + ((off_t) (Libisoburn_target_head_sizE/2048)) + + +/* Wrappers for emulation of TOC on overwriteable media */ + +struct isoburn_toc_track { + /* Either track or toc_entry are supposed to be NULL */ + struct burn_track *track; + struct isoburn_toc_entry *toc_entry; +}; + +struct isoburn_toc_session { + /* Either session or tracks and toc_entry are supposed to be NULL */ + struct burn_session *session; + struct isoburn_toc_track **track_pointers; + int track_count; + struct isoburn_toc_entry *toc_entry; +}; + +struct isoburn_toc_disc { + /* Either disc or sessions and toc are supposed to be NULL */ + struct burn_disc *disc; + struct isoburn_toc_session *sessions; /* storage array */ + struct isoburn_toc_session **session_pointers; /* storage array */ + struct isoburn_toc_track *tracks; /* storage array */ + struct isoburn_toc_track **track_pointers; /* storage array */ + int session_count; + int track_count; + struct isoburn_toc_entry *toc; +}; + +#endif /* Isoburn_includeD */ + diff --git a/libisoburn/branches/ZeroFourTwo/libisoburn/isofs_wrap.c b/libisoburn/branches/ZeroFourTwo/libisoburn/isofs_wrap.c new file mode 100644 index 00000000..82c2c124 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/libisoburn/isofs_wrap.c @@ -0,0 +1,411 @@ + +/* + cc -g -c isofs_wrap.c +*/ + +/* + libisofs related functions of libisoburn. + + Copyright 2007 - 2009 Vreixo Formoso Lopes + Thomas Schmitt +*/ + +#include +#include +#include + +#ifndef Xorriso_standalonE + +#include + +#include + +#else /* ! Xorriso_standalonE */ + +#include "../libisofs/libisofs.h" +#include "../libburn/libburn.h" + +#endif /* Xorriso_standalonE */ + +#include "isoburn.h" +#include "libisoburn.h" + +#define BP(a,b) [(b) - (a) + 1] + +struct ecma119_pri_vol_desc +{ + uint8_t vol_desc_type BP(1, 1); + uint8_t std_identifier BP(2, 6); + uint8_t vol_desc_version BP(7, 7); + uint8_t unused1 BP(8, 8); + uint8_t system_id BP(9, 40); + uint8_t volume_id BP(41, 72); + uint8_t unused2 BP(73, 80); + uint8_t vol_space_size BP(81, 88); + uint8_t unused3 BP(89, 120); + uint8_t vol_set_size BP(121, 124); + uint8_t vol_seq_number BP(125, 128); + uint8_t block_size BP(129, 132); + uint8_t path_table_size BP(133, 140); + uint8_t l_path_table_pos BP(141, 144); + uint8_t opt_l_path_table_pos BP(145, 148); + uint8_t m_path_table_pos BP(149, 152); + uint8_t opt_m_path_table_pos BP(153, 156); + uint8_t root_dir_record BP(157, 190); + uint8_t vol_set_id BP(191, 318); + uint8_t publisher_id BP(319, 446); + uint8_t data_prep_id BP(447, 574); + uint8_t application_id BP(575, 702); + uint8_t copyright_file_id BP(703, 739); + uint8_t abstract_file_id BP(740, 776); + uint8_t bibliographic_file_id BP(777, 813); + uint8_t vol_creation_time BP(814, 830); + uint8_t vol_modification_time BP(831, 847); + uint8_t vol_expiration_time BP(848, 864); + uint8_t vol_effective_time BP(865, 881); + uint8_t file_structure_version BP(882, 882); + uint8_t reserved1 BP(883, 883); + uint8_t app_use BP(884, 1395); + uint8_t reserved2 BP(1396, 2048); +}; + +static +uint32_t iso_read_lsb(const uint8_t *buf, int bytes) +{ + int i; + uint32_t ret = 0; + + for (i=0; iimage); + return o->image; +} + + +static void isoburn_idle_free_function(void *ignored) +{ + return; +} + + +/* API function. See libisoburn.h +*/ +int isoburn_read_image(struct burn_drive *d, + struct isoburn_read_opts *read_opts, + IsoImage **image) +{ + int ret, int_num, dummy; + IsoReadOpts *ropts= NULL; + IsoReadImageFeatures *features= NULL; + uint32_t ms_block; + char msg[160]; + enum burn_disc_status status= BURN_DISC_BLANK; + IsoDataSource *ds= NULL; + struct isoburn *o= NULL; + + if(d != NULL) { + ret = isoburn_find_emulator(&o, d, 0); + if (ret < 0 || o == NULL) + return 0; + status = isoburn_disc_get_status(d); + } + if(read_opts==NULL) { + isoburn_msgs_submit(o, 0x00060000, + "Program error: isoburn_read_image: read_opts==NULL", + 0, "FATAL", 0); + return(-1); + } + if (d == NULL || status == BURN_DISC_BLANK || read_opts->pretend_blank) { +create_blank_image:; + /* + * Blank disc, we create a new image without files. + */ + + if (d == NULL) { + /* New empty image without relation to a drive */ + if (image==NULL) { + isoburn_msgs_submit(o, 0x00060000, + "Program error: isoburn_read_image: image==NULL", + 0, "FATAL", 0); + return -1; + } + /* create a new image */ + ret = iso_image_new("ISOIMAGE", image); + if (ret < 0) { + isoburn_report_iso_error(ret, "Cannot create image", 0, "FATAL", 0); + return ret; + } + } else { + /* Blank new image for the drive */ + iso_image_unref(o->image); + ret = iso_image_new("ISOIMAGE", &o->image); + if (ret < 0) { + isoburn_report_iso_error(ret, "Cannot create image", 0, "FATAL", 0); + return ret; + } + if (image) { + *image = o->image; + iso_image_ref(*image); /*protects object from premature free*/ + } + } + iso_image_set_ignore_aclea(*image, + (!!(read_opts->noacl)) | ((!!read_opts->noea) << 1) ); + return 1; + } + + if (status != BURN_DISC_APPENDABLE && status != BURN_DISC_FULL) { + isoburn_msgs_submit(o, 0x00060000, + "Program error: isoburn_read_image: incorrect disc status", + 0, "FATAL", 0); + return -4; + } + + memset((char *) &ropts, 0, sizeof(ropts)); + + ret = isoburn_disc_get_msc1(d, &int_num); + if (ret <= 0) + return -2; + ms_block= int_num; + ret = isoburn_read_iso_head(d, int_num, &dummy, NULL, 0); + if (ret <= 0) { + sprintf(msg, "No ISO 9660 image at LBA %d. Creating blank image.", int_num); + isoburn_msgs_submit(o, 0x00060000, msg, 0, "WARNING", 0); + goto create_blank_image; + } + + /* create the data source */ + ret = iso_read_opts_new(&ropts, 0); + if (ret < 0) { + isoburn_report_iso_error(ret, "Cannot create write opts", 0, "FATAL", 0); + return ret; + } + /* Important: do not return until iso_read_opts_free() */ + iso_read_opts_set_start_block(ropts, ms_block); + iso_read_opts_set_no_rockridge(ropts, read_opts->norock); + iso_read_opts_set_no_aaip(ropts, read_opts->noaaip); + iso_read_opts_set_no_md5(ropts, read_opts->nomd5); + + iso_read_opts_set_new_inos(ropts, read_opts->noino); + + iso_read_opts_set_no_joliet(ropts, read_opts->nojoliet); + iso_read_opts_set_no_iso1999(ropts, read_opts->noiso1999); + iso_read_opts_set_preferjoliet(ropts, read_opts->preferjoliet); + iso_read_opts_set_default_permissions(ropts, + read_opts->mode, read_opts->dirmode); + iso_read_opts_set_default_uid(ropts, read_opts->uid); + iso_read_opts_set_default_gid(ropts, read_opts->gid); + iso_read_opts_set_input_charset(ropts, read_opts->input_charset); + iso_read_opts_auto_input_charset(ropts, read_opts->auto_input_charset); + + ds = isoburn_data_source_new(d); + if(o->iso_data_source!=NULL) + iso_data_source_unref(o->iso_data_source); + o->iso_data_source= ds; + iso_image_attach_data(o->image, o->read_pacifier_handle, + isoburn_idle_free_function); + if(o->read_pacifier_handle==NULL) + iso_tree_set_report_callback(o->image, NULL); + else + iso_tree_set_report_callback(o->image, o->read_pacifier); + ret = iso_image_import(o->image, ds, ropts, &features); + iso_tree_set_report_callback(o->image, NULL); + iso_read_opts_free(ropts); + + if (ret < 0) { + isoburn_report_iso_error(ret, "Cannot import image", 0, "FAILURE", 0); + return ret; + } + /* Important: do not return until free(features) */ + if (image!=NULL) { + *image = o->image; + iso_image_ref(*image); /*protects object from premature free*/ + } + read_opts->hasRR = iso_read_image_features_has_rockridge(features); + read_opts->hasJoliet = iso_read_image_features_has_joliet(features); + read_opts->hasIso1999 = iso_read_image_features_has_iso1999(features); + read_opts->hasElTorito = iso_read_image_features_has_eltorito(features); + read_opts->size = iso_read_image_features_get_size(features); + iso_read_image_features_destroy(features); + return 1; +} + + +/* API function. See libisoburn.h +*/ +int isoburn_attach_image(struct burn_drive *d, IsoImage *image) +{ + int ret; + struct isoburn *o; + + ret = isoburn_find_emulator(&o, d, 0); + if (ret < 0 || o == NULL) + return 0; + if (image == NULL) { + isoburn_msgs_submit(o, 0x00060000, + "Program error: isoburn_attach_image: image==NULL", + 0, "FATAL", 0); + return -1; + } + if(o->image != NULL) + iso_image_unref(o->image); + o->image = image; + return(1); +} + + +/* API function. See libisoburn.h +*/ +int isoburn_activate_session(struct burn_drive *drive) +{ + int ret; + struct isoburn *o; + + ret = isoburn_find_emulator(&o, drive, 0); + if (ret < 0) + return -1; + + if (o->emulation_mode != 1) + return 1; /* don't need to activate session */ + if (o->fabricated_msc2 >= 0) + return 1; /* blind growing: do not alter anything outside the session */ + + if (!(o->fabricated_disc_status == BURN_DISC_APPENDABLE || + (o->fabricated_disc_status == BURN_DISC_BLANK && + o->zero_nwa > 0))) + return 1; + + ret = burn_random_access_write(drive, (off_t) 0, (char*)o->target_iso_head, + Libisoburn_target_head_sizE, 1); + + return ret; +} + + +/** Initialize the emulation of multi-session on random access media. + The need for emulation is confirmed already. + @param o A freshly created isoburn object. isoburn_create_data_source() was + already called, nevertheless. + @return <=0 error , 1 = success +*/ +int isoburn_start_emulation(struct isoburn *o, int flag) +{ + int ret, i; + off_t data_count; + struct burn_drive *drive; + struct ecma119_pri_vol_desc *pvm; + + if(o==NULL) { + isoburn_msgs_submit(NULL, 0x00060000, + "Program error: isoburn_start_emulation: o==NULL", + 0, "FATAL", 0); + return -1; + } + + drive= o->drive; + + /* we can assume 0 as start block for image */ + /* TODO what about ms? where we validate valid iso image in ms disc? */ + ret = burn_read_data(drive, (off_t) 0, (char*)o->target_iso_head, + (off_t) Libisoburn_target_head_sizE, &data_count, 2); + + /* an error means an empty disc */ + if (ret <= 0) { + o->fabricated_disc_status= BURN_DISC_BLANK; + return 1; + } + + /* check first 64K. If 0's, the disc is treated as a blank disc, and thus + overwritten without extra check. */ + i = Libisoburn_target_head_sizE; + while (i && !o->target_iso_head[i-1]) + --i; + + if (!i) { + o->fabricated_disc_status= BURN_DISC_BLANK; + return 1; + } + + pvm = (struct ecma119_pri_vol_desc *)(o->target_iso_head + 16 * 2048); + + if (!strncmp((char*)pvm->std_identifier, "CD001", 5)) { + off_t size; + + /* sanity check */ + if (pvm->vol_desc_type[0] != 1 || pvm->vol_desc_version[0] != 1 + || pvm->file_structure_version[0] != 1 ) { + /* TODO for now I treat this as a full disc */ + o->fabricated_disc_status= BURN_DISC_FULL; + return 1; + } + + /* ok, PVM found, set size */ + size = (off_t) iso_read_lsb(pvm->vol_space_size, 4); + size *= (off_t) 2048; /* block size in bytes */ + isoburn_set_start_byte(o, size, 0); + o->fabricated_disc_status= BURN_DISC_APPENDABLE; + } else if (!strncmp((char*)pvm->std_identifier, "CDXX1", 5)) { + + /* empty image */ + isoburn_set_start_byte(o, o->zero_nwa * 2048, 0); + o->fabricated_disc_status= BURN_DISC_BLANK; + } else { + /* treat any disc in an unknown format as full */ + o->fabricated_disc_status= BURN_DISC_FULL; + } + return 1; +} + + +/** Alters and writes the first 64 kB of a "media" to invalidate + an ISO image. (It shall stay restorable by skilled humans, though). + The result shall especially keep libisoburn from accepting the media + image as ISO filesystem. + @param o A fully activated isoburn object. isoburn_start_emulation() + was already called. + @return <=0 error , 1 = success +*/ +int isoburn_invalidate_iso(struct isoburn *o, int flag) +{ + /* + * replace CD001 with CDXX1 in PVM. + * I think this is enought for invalidating an iso image + */ + strncpy((char*)o->target_iso_head + 16 * 2048 + 1, "CDXX1", 5); + return isoburn_activate_session(o->drive); +} + + +/* API @since 0.1.0 */ +int isoburn_set_read_pacifier(struct burn_drive *drive, + int (*read_pacifier)(IsoImage*, IsoFileSource*), + void *read_handle) +{ + int ret; + struct isoburn *o; + + ret = isoburn_find_emulator(&o, drive, 0); + if(ret < 0 || o == NULL) + return -1; + o->read_pacifier_handle= read_handle; + o->read_pacifier= read_pacifier; + return(1); +} + diff --git a/libisoburn/branches/ZeroFourTwo/libisoburn/libisoburn.h b/libisoburn/branches/ZeroFourTwo/libisoburn/libisoburn.h new file mode 100644 index 00000000..04996908 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/libisoburn/libisoburn.h @@ -0,0 +1,1503 @@ + +/* + API definition of libisoburn. + + Copyright 2007-2009 Vreixo Formoso Lopes + and Thomas Schmitt +*/ + +/** Overview + +libisoburn is a frontend for libraries libburn and libisofs which enables +creation and expansion of ISO-9660 filesystems on all CD/DVD media supported +by libburn. This includes media like DVD+RW, which do not support multi-session +management on media level and even plain disk files or block devices. + +The price for that is thorough specialization on data files in ISO-9660 +filesystem images. So libisoburn is not suitable for audio (CD-DA) or any +other CD layout which does not entirely consist of ISO-9660 sessions. + + + Connector functions + +libisofs and libburn do not depend on each other but share some interfaces +by which they can cooperate. +libisoburn establishes the connection between both modules by creating the +necessary interface objects and attaching them to the right places. + + + Wrapper functions + +The priciple of this frontend is that you may use any call of libisofs or +libburn unless it has a isoburn_*() wrapper listed in the following function +documentation. + +E.g. call isoburn_initialize() rather than iso_init(); burn_initialize(); +and call isoburn_drive_scan_and_grab() rather than burn_drive_scan_and_grab(). +But you may call burn_disc_get_profile() directly if you want to display +the media type. + +The wrappers will transparently provide the necessary emulations which +are appropriate for particular target drives and media states. +To learn about them you have to read both API descriptions: the one of +the wrapper and the one of the underlying libburn or libisofs call. + +Macros BURN_* and functions burn_*() are documented in +Macros ISO_* and functions iso_*() are documented in + + + Usage model + +There may be an input drive and an output drive. Either of them may be missing +with the consequence that no reading resp. writing is possible. +Both drive roles can be fulfilled by the same drive. + +Input can be a random access readable libburn drive: + optical media, regular files, block devices. +Output can be any writeable libburn drive: + writeable optical media in burner, writeable file objects (no directories). + +libburn demands rw-permissions to drive device file resp. file object. + +If the input drive provides a suitable ISO RockRidge image, then its tree +may be loaded into memory and can then be manipulated by libisofs API calls. +The loading is done by isoburn_read_image() under control of +struct isoburn_read_opts which the application obtains from libisoburn +and manipulates by the family of isoburn_ropt_set_*() functions. + +Writing of result images is controlled by libisofs related parameters +in a struct isoburn_imgen_opts which the application obtains from libisoburn +and manipulates by the family of isoburn_igopt_set_*() functions. + +All multi-session aspects are handled by libisoburn according to these +settings. The application does not have to analyze media state and write +job parameters. It rather states its desires which libisoburn tries to +fulfill, or else will refuse to start the write run. + + + Setup for Growing, Modifying or Blind Growing + +The connector function family offers alternative API calls for performing +the setup for several alternative image generation strategies. + +Growing: +If input and output drive are the same, then isoburn_prepare_disc() is to +be used. It will lead to an add-on session on appendable or overwriteable +media with existing ISO image. With blank media it will produce a first +session. + +Modifying: +If the output drive is not the input drive, and if it bears blank media +or overwriteable without a valid ISO image, then one may produce a consolidated +image with old and new data. This will copy file data from an eventual input +drive with valid image, add any newly introduced data from the local +filesystem, and produce a first session on output media. +To prepare for such an image generation run, use isoburn_prepare_new_image(). + +Blind Growing: +This method reads the old image from one drive and writes the add-on session +to a different drive. That output drive is nevertheless supposed to +finally lead to the same media from where the session was loaded. Usually it +will be stdio:/dev/fd/1 (i.e. stdout) being piped into some burn program +like with this classic gesture: + mkisofs -M $dev -C $msc1,$nwa | cdrecord -waiti dev=$dev +Blind growing is prepared by the call isoburn_prepare_blind_grow(). +The input drive should be released immediately after this call in order +to allow the consumer of the output stream to access that drive for writing. + +After either of these setups, some peripheral libburn drive parameter settings +like burn_write_opts_set_simulate(), burn_write_opts_set_multi(), + burn_drive_set_speed(), burn_write_opts_set_underrun_proof() should be made. +Do not set the write mode. It will be chosen by libisoburn so it matches job +and media state. + + Writing the image + +Then one may start image generation and write threads by isoburn_disc_write(). +Progress may be watched at the output drive by burn_drive_get_status() and +isoburn_get_fifo_status(). + +At some time, the output drive will be BURN_DRIVE_IDLE indicating that +writing has ended. +One should inquire isoburn_drive_wrote_well() to learn about overall success. + +Finally one must call isoburn_activate_session() which will complete any +eventual multi-session emulation. + + + Application Constraints + +Applications shall include libisofs/libisofs.h , libburn/libburn.h and this +file itself: libisoburn/libisoburn.h . +They shall link with -lisofs -lburn -lisoburn or with the .o files emerging +from building those libraries from their sources. + +Applications must use 64 bit off_t, e.g. on 32-bit Linux by defining + #define _LARGEFILE_SOURCE + #define _FILE_OFFSET_BITS 64 +or take special precautions to interface with the library by 64 bit integers +where above .h files prescribe off_t. Not to use 64 bit file i/o will keep +the application from producing and processing ISO images of more than 2 GB +size. + +*/ + + + /* API functions */ + + +/** Initialize libisoburn, libisofs and libburn. + Wrapper for : iso_init() and burn_initialize() + @since 0.1.0 + @param msg A character array for eventual messages (e.g. with errors) + @param flag Bitfield for control purposes (unused yet, submit 0) + @return 1 indicates success, 0 is failure +*/ +int isoburn_initialize(char msg[1024], int flag); + + +/** Check whether all features of header file libisoburn.h from the given + major.minor.micro revision triple can be delivered by the library version + which is performing this call. + An application of libisoburn can easily memorize the version of the + libisofs.h header in its own code. Immediately after isoburn_initialize() + it should simply do this check: + if (! isoburn_is_compatible(isoburn_header_version_major, + isoburn_header_version_minor, + isoburn_header_version_micro, 0)) + ...refuse to start the program with this dynamic library version... + @since 0.1.0 + @param major obtained at build time + @param minor obtained at build time + @param micro obtained at build time + @param flag Bitfield for control purposes. Unused yet. Submit 0. + @return 1= library can work for caller + 0= library is not usable in some aspects. Caller must restrict + itself to an earlier API version or must not use this libray + at all. +*/ +int isoburn_is_compatible(int major, int minor, int micro, int flag); + + +/** Obtain the three release version numbers of the library. These are the + numbers encountered by the application when linking with libisoburn, + i.e. possibly not before run time. + Better do not base the fundamental compatibility decision of an application + on these numbers. For a reliable check use isoburn_is_compatible(). + @since 0.1.0 + @param major The maturity version (0 for now, as we are still learning) + @param minor The development goal version. + @param micro The development step version. This has an additional meaning: + + Pare numbers indicate a version with frozen API. I.e. you can + rely on the same set of features to be present in all + published releases with that major.minor.micro combination. + Features of a pare release will stay available and ABI + compatible as long as the SONAME of libisoburn stays "1". + Currently there are no plans to ever change the SONAME. + + Odd numbers indicate that API upgrades are in progress. + I.e. new features might be already present or they might + be still missing. Newly introduced features may be changed + incompatibly or even be revoked before release of a pare + version. + So micro revisions {1,3,5,7,9} should never be used for + dynamic linking unless the proper library match can be + guaranteed by external circumstances. + + @return 1 success, <=0 might in future become an error indication +*/ +void isoburn_version(int *major, int *minor, int *micro); + + +/** The minimum version of libisofs to be used with this version of libisoburn + at compile time. + @since 0.1.0 +*/ +#define isoburn_libisofs_req_major 0 +#define isoburn_libisofs_req_minor 6 +#define isoburn_libisofs_req_micro 22 + +/** The minimum version of libburn to be used with this version of libisoburn + at compile time. + @since 0.1.0 +*/ +#define isoburn_libburn_req_major 0 +#define isoburn_libburn_req_minor 7 +#define isoburn_libburn_req_micro 0 + + +/** The minimum version of libisofs to be used with this version of libisoburn + at runtime. This is checked already in isoburn_initialize() which will + refuse on outdated version. So this call is for information purposes after + successful startup only. + @since 0.1.0 + @param major isoburn_libisofs_req_major as seen at build time + @param minor as seen at build time + @param micro as seen at build time + @return 1 success, <=0 might in future become an error indication +*/ +int isoburn_libisofs_req(int *major, int *minor, int *micro); + + +/** The minimum version of libburn to be used with this version of libisoburn + at runtime. This is checked already in isoburn_initialize() which will + refuse on outdated version. So this call is for information purposes after + successful startup only. + @since 0.1.0 + @param major isoburn_libburn_req_major as seen at build time + @param minor as seen at build time + @param micro as seen at build time + @return 1 success, <=0 might in future become an error indication +*/ +int isoburn_libburn_req(int *major, int *minor, int *micro); + + +/** These three release version numbers tell the revision of this header file + and of the API it describes. They are memorized by applications at build + time. + @since 0.1.0 +*/ +#define isoburn_header_version_major 0 +#define isoburn_header_version_minor 4 +#define isoburn_header_version_micro 1 +/** Note: + Above version numbers are also recorded in configure.ac because libtool + wants them as parameters at build time. + For the library compatibility check, ISOBURN_*_VERSION in configure.ac + are not decisive. Only the three numbers here do matter. +*/ +/** Usage discussion: + +Some developers of the libburnia project have differing +opinions how to ensure the compatibility of libaries +and applications. + +It is about whether to use at compile time and at runtime +the version numbers isoburn_header_version_* provided here. +Thomas Schmitt advises to use them. +Vreixo Formoso advises to use other means. + +At compile time: + +Vreixo Formoso advises to leave proper version matching +to properly programmed checks in the the application's +build system, which will eventually refuse compilation. + +Thomas Schmitt advises to use the macros defined here +for comparison with the application's requirements of +library revisions and to eventually break compilation. + +Both advises are combinable. I.e. be master of your +build system and have #if checks in the source code +of your application, nevertheless. + +At runtime (via *_is_compatible()): + +Vreixo Formoso advises to compare the application's +requirements of library revisions with the runtime +library. This is to allow runtime libraries which are +young enough for the application but too old for +the lib*.h files seen at compile time. + +Thomas Schmitt advises to compare the header +revisions defined here with the runtime library. +This is to enforce a strictly monotonous chain +of revisions from app to header to library, +at the cost of excluding some older libraries. + +These two advises are mutually exclusive. + +----------------------------------------------------- + +For an implementation of the Thomas Schmitt approach, +see libisoburn/burn_wrap.c : isoburn_initialize() +This connects libisoburn as "application" with libisofs +as "library". + +The compatible part of Vreixo Formoso's approach is implemented +in configure.ac LIBBURN_REQUIRED, LIBISOFS_REQUIRED. +In isoburn_initialize() it would rather test by + iso_lib_is_compatible(isoburn_libisofs_req_major,... +than by + iso_lib_is_compatible(iso_lib_header_version_major,... +and would leave out the ugly compile time traps. + +*/ + + +/** Announce to the library an application provided method for immediate + delivery of messages. It is used when no drive is affected directly or + if the drive has no own msgs_submit() method attached by + isoburn_drive_set_msgs_submit. + If no method is preset or if the method is set to NULL then libisoburn + delivers its messages through the message queue of libburn. + @param msgs_submit The function call which implements the method + @param submit_handle Handle to be used as first argument of msgs_submit + @param submit_flag Flag to be used as last argument of msgs_submit + @param flag Unused yet, submit 0 + @since 0.2.0 +*/ +int isoburn_set_msgs_submit(int (*msgs_submit)(void *handle, int error_code, + char msg_text[], int os_errno, + char severity[], int flag), + void *submit_handle, int submit_flag, int flag); + + +/** Aquire a target drive by its filesystem path resp. libburn persistent + address. + Wrapper for: burn_drive_scan_and_grab() + @since 0.1.0 + @param drive_infos On success returns a one element array with the drive + (cdrom/burner). Thus use with driveno 0 only. On failure + the array has no valid elements at all. + The returned array should be freed via burn_drive_info_free() + when the drive is no longer needed. But before this is done + one has to call isoburn_drive_release(drive_infos[0].drive). + @param adr The persistent address of the desired drive. + @param load 1 attempt to load the disc tray. 0 no attempt,rather failure. + @return 1 = success , 0 = drive not found , <0 = other error +*/ +int isoburn_drive_scan_and_grab(struct burn_drive_info *drive_infos[], + char* adr, int load); + + +/** Aquire a target drive by its filesystem path resp. libburn persistent + address. This is a modern successor of isoburn_drive_scan_and_grab(). + Wrapper for: burn_drive_scan_and_grab() + @since 0.1.2 + @param drive_infos On success returns a one element array with the drive + (cdrom/burner). Thus use with driveno 0 only. On failure + the array has no valid elements at all. + The returned array should be freed via burn_drive_info_free() + when the drive is no longer needed. But before this is done + one has to call isoburn_drive_release(drive_infos[0].drive). + @param adr The persistent address of the desired drive. + @param flag bit0= attempt to load the disc tray. + Else: failure if not loaded. + bit1= regard overwriteable media as blank + bit2= if the drive is a regular disk file: truncate it to + the write start address + bit3= if the drive reports a read-only profile try to read + table of content by scanning for ISO image headers. + (depending on media type and drive this might + help or it might make the resulting toc even worse) + bit4= do not emulate table of content on overwriteable media + bit5= ignore ACL from external filesystems + bit6= ignore POSIX Extended Attributes from external + filesystems + @return 1 = success , 0 = drive not found , <0 = other error +*/ +int isoburn_drive_aquire(struct burn_drive_info *drive_infos[], + char* adr, int flag); + +/** Aquire a drive from the burn_drive_info[] array which was obtained by + a previous call of burn_drive_scan(). + Wrapper for: burn_drive_grab() + @since 0.1.0 + @param drive The drive to grab. E.g. drive_infos[1].drive . + Call isoburn_drive_release(drive) when it it no longer needed. + @param load 1 attempt to load the disc tray. 0 no attempt, rather failure. + @return 1 success, <=0 failure +*/ +int isoburn_drive_grab(struct burn_drive *drive, int load); + + +/** Attach to a drive an application provided method for immediate + delivery of messages. + If no method is set or if the method is set to NULL then libisoburn + delivers messages of the drive through the global msgs_submit() method + set by isoburn_set_msgs_submiti() or by the message queue of libburn. + @since 0.2.0 + @param d The drive to which this function, handle and flag shall apply + @param msgs_submit The function call which implements the method + @param submit_handle Handle to be used as first argument of msgs_submit + @param submit_flag Flag to be used as last argument of msgs_submit + @param flag Unused yet, submit 0 +*/ +int isoburn_drive_set_msgs_submit(struct burn_drive *d, + int (*msgs_submit)(void *handle, int error_code, + char msg_text[], int os_errno, + char severity[], int flag), + void *submit_handle, int submit_flag, int flag); + + +/** Inquire the media status. Expect the whole spectrum of libburn BURN_DISC_* + with multi-session media. Emulated states with random access media are + BURN_DISC_BLANK and BURN_DISC_APPENDABLE. + Wrapper for: burn_disc_get_status() + @since 0.1.0 + @param drive The drive to inquire. + @return The status of the drive, or what kind of disc is in it. + Note: BURN_DISC_UNGRABBED indicates wrong API usage +*/ +enum burn_disc_status isoburn_disc_get_status(struct burn_drive *drive); + + +/** Tells whether the media can be treated by isoburn_disc_erase(). + Wrapper for: burn_disc_erasable() + @since 0.1.0 + @param drive The drive to inquire. + @return 0=not erasable , else erasable +*/ +int isoburn_disc_erasable(struct burn_drive *d); + + +/** Mark the media as blank. With multi-session media this will call + burn_disc_erase(). With random access media, an eventual ISO-9660 + filesystem will get invalidated by altering its start blocks on media. + In case of success, the media is in status BURN_DISC_BLANK afterwards. + Wrapper for: burn_disc_erase() + @since 0.1.0 + @param drive The drive with the media to erase. + @param fast 1=fast erase, 0=thorough erase + With DVD-RW, fast erase yields media incapable of multi-session. +*/ +void isoburn_disc_erase(struct burn_drive *drive, int fast); + + +/** Set up isoburn_disc_get_msc1() to return a fabricated value. + This makes only sense between aquiring the drive and reading the + image. After isoburn_read_image() it will confuse the coordination + of libisoburn and libisofs. + Note: Sessions and tracks are counted beginning with 1, not with 0. + @since 0.1.6 + @param drive The drive where msc1 is to be set + @param adr_mode Determines how to interpret adr_value and to set msc1. + If adr_value shall represent a number then decimal ASCII + digits are expected. + 0= start lba of last session in TOC, ignore adr_value + 1= start lba of session number given by adr_value + 2= start lba of track given number by adr_value + 3= adr_value itself is the lba to be used + 4= start lba of last session with volume id + given by adr_value + @param adr_value A string describing the value to be eventually used. + @param flag Bitfield for control purposes. + bit0= @since 0.2.2 + with adr_mode 3: adr_value might be 16 blocks too high + (e.g. -C stemming from growisofs). Probe for ISO head + at adr_value-16 and eventually adjust setting. + bit1= insist in seeing a disc object with at least one session + bit2= with adr_mode 4: use adr_value as regular expression +*/ +int isoburn_set_msc1(struct burn_drive *d, int adr_mode, char *adr_value, + int flag); + + +/* ----------------------------------------------------------------------- */ +/* + + Wrappers for emulation of TOC on overwriteable media + + Media which match the overwriteable usage model lack of a history of sessions + and tracks. libburn will not even hand out a burn_disc object for them and + always declare them blank. libisoburn checks for a valid ISO filesystem + header at LBA 0 and eventually declares them appendable. + Nevertheless one can only determine an upper limit of the size of the overall + image (by isoburn_get_min_start_byte()) but not a list of stored sessions + and their LBAs, as it is possible with true multi-session media. + + The following wrappers add the capability to obtain a session and track TOC + from emulated multi-session images on overwriteables if the first session + was written by libisoburn-0.1.6 or later (i.e. with a header copy at LBA 32). + + Be aware that the structs emitted by these isoburn calls are not compatible + with the libburn structs. I.e. you may use them only with isoburn_toc_* + calls. + isoburn_toc_disc needs to be freed after use. isoburn_toc_session and + isoburn_toc_track vanish together with their isoburn_toc_disc. +*/ + +/* Opaque handles to media, session, track */ +struct isoburn_toc_disc; +struct isoburn_toc_session; +struct isoburn_toc_track; + + +/** Obtain a master handle for the table of content. + This handle governs allocated resources which have to be released by + isoburn_toc_disc_free() when no longer needed. + Wrapper for: burn_drive_get_disc() + @since 0.1.6 + @param drive The drive with the media to inspect + @return NULL in case there is no content info, else it is a valid handle +*/ +struct isoburn_toc_disc *isoburn_toc_drive_get_disc(struct burn_drive *d); + + +/** Tell the number of 2048 byte blocks covered by the table of content. + This number includes the eventual gaps between sessions and tracks. + So this call is not really a wrapper for burn_disc_get_sectors(). + @since 0.1.6 + @param disc The master handle of the media + @return number of blocks, <=0 indicates unknown or unreadable state +*/ +int isoburn_toc_disc_get_sectors(struct isoburn_toc_disc *disc); + + +/** Get the array of session handles from the table of content. + Wrapper for: burn_disc_get_sessions() + @since 0.1.6 + @param disc The master handle of the media + @param num returns the number of sessions in the array + @return the address of the array of session handles +*/ +struct isoburn_toc_session **isoburn_toc_disc_get_sessions( + struct isoburn_toc_disc *disc, int *num); + + +/** Tell the number of 2048 byte blocks covered by a particular session. + Wrapper for: burn_session_get_sectors() + @since 0.1.6 + @param s The session handle + @return number of blocks, <=0 indicates unknown or unreadable state +*/ +int isoburn_toc_session_get_sectors(struct isoburn_toc_session *s); + + +/** Obtain a copy of the entry which describes the end of a particular session. + Wrapper for: burn_session_get_leadout_entry() + @since 0.1.6 + @param s The session handle + @param entry A pointer to memory provided by the caller. It will be filled + with info according to struct burn_toc_entry as defined + in libburn.h +*/ +void isoburn_toc_session_get_leadout_entry(struct isoburn_toc_session *s, + struct burn_toc_entry *entry); + + +/** Get the array of track handles from a particular session. + Wrapper for: burn_session_get_tracks() + @since 0.1.6 + @param s The session handle + @param num returns the number of tracks in the array + @return the address of the array of track handles +*/ +struct isoburn_toc_track **isoburn_toc_session_get_tracks( + struct isoburn_toc_session *s, int *num); + + +/** Obtain a copy of the entry which describes a particular track. + Wrapper for: burn_track_get_entry() + @since 0.1.6 + @param t The track handle + @param entry A pointer to memory provided by the caller. It will be filled + with info according to struct burn_toc_entry as defined + in libburn.h +*/ +void isoburn_toc_track_get_entry(struct isoburn_toc_track *t, + struct burn_toc_entry *entry); + + +/** Obtain eventual ISO image parameters of an emulated track. This info was + gained with much effort and thus gets cached in the track object. + If this call returns 1 then one can save a call of isoburn_read_iso_head() + with return mode 1 which could cause an expensive read operation. + @since 0.4.0 + @param t The track handle + @param start_lba Returns the start address of the ISO session + @param image_blocks Returns the number of 2048 bytes blocks + @param volid Caller provided memory for the volume id + @param flag unused yet, submit 0 + @return 0= not an emulated ISO session , 1= reply is valid +*/ +int isoburn_toc_track_get_emul(struct isoburn_toc_track *t, int *start_lba, + int *image_blocks, char volid[33], int flag); + + + +/** Release the memory associated with a master handle of media. + The handle is invalid afterwards and may not be used any more. + Wrapper for: burn_disc_free() + @since 0.1.6 + @param disc The master handle of the media +*/ +void isoburn_toc_disc_free(struct isoburn_toc_disc *disc); + + +/** Try whether the data at the given address look like a ISO 9660 + image header and obtain its alleged size. Depending on the info mode + one other string of text information can be retrieved too. + @since 0.1.6 + @param drive The drive with the media to inspect + @param lba The block number from where to read + @param image_blocks The number of 2048 bytes blocks + @param info Caller provided memory, enough to take eventual info reply + @param flag bit0-7: info return mode + 0= do not return anything in info (do not even touch it) + 1= copy volume id to info (info needs 33 bytes) + 2= @since 0.2.2 : + copy 64 kB header to info (needs 65536 bytes) + bit13= @since 0.2.2: + do not read head from media but use first 64 kB from info + bit14= check both half buffers (not only second) + return 2 if found in first block + bit15= return -1 on read error + @return >0 seems to be a valid ISO image, 0 format not recognized, <0 error +*/ +int isoburn_read_iso_head(struct burn_drive *d, int lba, + int *image_blocks, char *info, int flag); + + +/** Try to convert the given entity address into various entity addresses + which would describe it. + Note: Sessions and tracks are counted beginning with 1, not with 0. + @since 0.3.2 + @param drive The drive where msc1 is to be set + @param adr_mode Determines how to interpret the input adr_value. + If adr_value shall represent a number then decimal ASCII + digits are expected. + 0= start lba of last session in TOC, ignore adr_value + 1= start lba of session number given by adr_value + 2= start lba of track given number by adr_value + 3= adr_value itself is the lba to be used + 4= start lba of last session with volume id + given by adr_value + @param adr_value A string describing the value to be eventually used. + @param lba returns the block address of the entity, -1 means invalid + @param track returns the track number of the entity, -1 means invalid + @param session returns the session number of the entity, -1 means invalid + @param volid returns the volume id of the entity if it is a ISO session + @param flag Bitfield for control purposes. + bit2= with adr_mode 4: use adr_value as regular expression + @return <=0 error , 1 ok, ISO session, 2 ok, not an ISO session +*/ +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); + + +/* ----------------------------------------------------------------------- */ +/* + + Options for image reading. + + An application shall create an option set object by isoburn_ropt_new(), + program it by isoburn_ropt_set_*(), use it with isoburn_read_image(), + and finally delete it by isoburn_ropt_destroy(). + +*/ +/* ----------------------------------------------------------------------- */ + +struct isoburn_read_opts; + +/** Produces a set of image read options, initialized with default values. + @since 0.1.0 + @param o the newly created option set object + @param flag Bitfield for control purposes. Submit 0 for now. + @return 1=ok , <0 = failure +*/ +int isoburn_ropt_new(struct isoburn_read_opts **o, int flag); + + +/** Deletes an option set which was created by isoburn_ropt_new(). + @since 0.1.0 + @param o The option set to work on + @param flag Bitfield for control purposes. Submit 0 for now. + @return 1= **o destroyed , 0= *o was already NULL (harmless) +*/ +int isoburn_ropt_destroy(struct isoburn_read_opts **o, int flag); + + +/** Which existing ISO 9660 extensions in the image to read or not to read. + Whether to read the content of an existing image at all. + The bits can be combined by | resp. inquired by &. + @since 0.1.0 + @param ext Bitfield: + bit0= norock + Do not read Rock Ridge extensions + bit1= nojoliet + Do not read Joliet extensions + bit2= noiso1999 + Do not read ISO 9660:1999 enhanced tree + bit3= preferjoliet + When both Joliet and RR extensions are present, the RR + tree is used. If you prefer using Joliet, set this to 1. + bit4= pretend_blank + Always create empty image.Ignore any image on input drive. + bit5= noaaip + @since 0.3.4 + Do not load AAIP information from image. This information + eventually contains ACL or XFS-style Extended Attributes. + bit6= noacl + @since 0.3.4 + Do not obtain ACL from external filesystem objects (e.g. + local filesystem files). + bit7= noea + @since 0.3.4 + Do not obtain XFS-style Extended Attributes from external + filesystem objects (e.g. local filesystem files). + bit8= noino + @since 0.4.0 + Do not load eventual inode numbers from RRIP entry PX, + but generate a new unique inode number for each imported + IsoNode object. + PX inode numbers allow to mark families of hardlinks by + giving all family members the same inode number. libisofs + keeps the PX inode numbers unaltered when IsoNode objects + get written into an ISO image. + bit9= nomd5 + @since 0.4.2 + Do not load the eventual MD5 checksum array. + @return 1 success, <=0 failure +*/ +#define isoburn_ropt_norock 1 +#define isoburn_ropt_nojoliet 2 +#define isoburn_ropt_noiso1999 4 +#define isoburn_ropt_preferjoliet 8 +#define isoburn_ropt_pretend_blank 16 +#define isoburn_ropt_noaaip 32 +#define isoburn_ropt_noacl 64 +#define isoburn_ropt_noea 128 +#define isoburn_ropt_noino 256 +#define isoburn_ropt_nomd5 512 + +int isoburn_ropt_set_extensions(struct isoburn_read_opts *o, int ext); +int isoburn_ropt_get_extensions(struct isoburn_read_opts *o, int *ext); + + +/** Default attributes to use if no RockRidge extension gets loaded. + @since 0.1.0 + @param o The option set to work on + @param uid user id number (see /etc/passwd) + @param gid group id number (see /etc/group) + @param mode permissions (not file type) as of man 2 stat. + With directories, r-permissions will automatically imply + x-permissions. See isoburn_ropt_set_default_dirperms() below. + @return 1 success, <=0 failure +*/ +int isoburn_ropt_set_default_perms(struct isoburn_read_opts *o, + uid_t uid, gid_t gid, mode_t mode); +int isoburn_ropt_get_default_perms(struct isoburn_read_opts *o, + uid_t *uid, gid_t *gid, mode_t *mode); + +/** Default attributes to use on directories if no RockRidge extension + gets loaded. + Above call isoburn_ropt_set_default_perms() automatically adds + x-permissions to r-permissions for directories. This call here may + be done afterwards to set independend permissions for directories, + especially to override the automatically added x-permissions. + @since 0.1.0 + @param o The option set to work on + @param mode permissions (not file type) as of man 2 stat. + @return 1 success, <=0 failure +*/ +int isoburn_ropt_set_default_dirperms(struct isoburn_read_opts *o, + mode_t mode); +int isoburn_ropt_get_default_dirperms(struct isoburn_read_opts *o, + mode_t *mode); + + + +/** Set the character set for reading RR file names from ISO images. + @since 0.1.0 + @param o The option set to work on + @param input_charset Set this to NULL to use the default locale charset + For selecting a particular character set, submit its + name, e.g. as listed by program iconv -l. + Example: "UTF-8". + @return 1 success, <=0 failure +*/ +int isoburn_ropt_set_input_charset(struct isoburn_read_opts *o, + char *input_charset); +int isoburn_ropt_get_input_charset(struct isoburn_read_opts *o, + char **input_charset); + +/** + Enable or disable methods to automatically choose an input charset. + This eventually overrides the name set via isoburn_ropt_set_input_charset() + @since 0.3.8 + + @param mode Bitfield for control purposes: + bit0= allow to set the input character set automatically from + attribute "isofs.cs" of root directory. + Submit any other bits with value 0. + @return 1 success, <=0 failure + */ +int isoburn_ropt_set_auto_incharset(struct isoburn_read_opts *o, int mode); +int isoburn_ropt_get_auto_incharset(struct isoburn_read_opts *o, int *mode); + + +/** After calling function isoburn_read_image() there are informations + available in the option set. + This info can be obtained as bits in parameter has_what. Like: + joliet_available = (has_what & isoburn_ropt_has_joliet); + @since 0.1.0 + @param o The option set to work on + @param size Number of image data blocks, 2048 bytes each. + @param has_what Bitfield: + bit0= has_rockridge + RockRidge extension info is available (POSIX filesystem) + bit1= has_joliet + Joliet extension info is available (suitable for MS-Windows) + bit2= has_iso1999 + ISO version 2 Enhanced Volume Descriptor is available. + This is rather exotic. + bit3= has_el_torito + El-Torito boot record is present + @return 1 success, <=0 failure +*/ +#define isoburn_ropt_has_rockridge 1 +#define isoburn_ropt_has_joliet 2 +#define isoburn_ropt_has_iso1999 4 +#define isoburn_ropt_has_el_torito 8 + +/* ts A90122 */ +/* >>> to be implemented: +#define isoburn_ropt_has_acl 64 +#define isoburn_ropt_has_ea 128 +*/ + +int isoburn_ropt_get_size_what(struct isoburn_read_opts *o, + uint32_t *size, int *has_what); + + +/* ----------------------------------------------------------------------- */ +/* End of Options for image reading */ +/* ----------------------------------------------------------------------- */ + +/* ----------------------------------------------------------------------- */ +/* + + Options for image generation by libisofs and image transport to libburn. + + An application shall create an option set by isoburn_igopt_new(), + program it by isoburn_igopt_set_*(), use it with either + isoburn_prepare_new_image() or isoburn_prepare_disc(), and finally delete + it by isoburn_igopt_destroy(). + +*/ +/* ----------------------------------------------------------------------- */ + +struct isoburn_imgen_opts; + +/** Produces a set of generation and transfer options, initialized with default + values. + @since 0.1.0 + @param o the newly created option set object + @param flag Bitfield for control purposes. Submit 0 for now. + @return 1=ok , <0 = failure +*/ +int isoburn_igopt_new(struct isoburn_imgen_opts **o, int flag); + + +/** Deletes an option set which was created by isoburn_igopt_new(). + @since 0.1.0 + @param o The option set to give up + @param flag Bitfield for control purposes. Submit 0 for now. + @return 1= **o destroyed , 0= *o was already NULL (harmless) +*/ +int isoburn_igopt_destroy(struct isoburn_imgen_opts **o, int flag); + + +/** ISO level to write at. + @since 0.1.0 + @param o The option set to work on + @param level is a term of the ISO 9660 standard. It should be one of: + 1= filenames restricted to form 8.3 + 2= filenames allowed up to 31 characters + @return 1 success, <=0 failure +*/ +int isoburn_igopt_set_level(struct isoburn_imgen_opts *o, int level); +int isoburn_igopt_get_level(struct isoburn_imgen_opts *o, int *level); + + +/** Which extensions to support. + @since 0.1.0 + @param o The option set to work on + @param ext Bitfield: + bit0= rockridge + Rock Ridge extensions add POSIX file attributes like + owner, group, access permissions, long filenames. Very + advisable if the designed audience has Unix style systems. + bit1= joliet + Longer filenames for Windows systems. + Weaker than RockRidge, but also readable with Linux. + bit2= iso1999 + This is rather exotic. Better do not surprise the readers. + bit3= hardlinks + Enable hardlink consolidation. IsoNodes which refer to the + same source object and have the same properties will get + the same ISO image inode numbers. + If combined with isoburn_igopt_rrip_version_1_10 below, + then the PX entry layout of RRIP-1.12 will be used within + RRIP-1.10 (mkisofs does this without causing visible trouble). + bit5= aaip + The libisofs specific SUSP based extension of ECMA-119 which + can encode ACL and XFS-style Extended Attributes. + bit6= session_md5 + @since 0.4.2 + Produce and write a MD5 checksum of the whole session stream. + bit7= file_md5 + @since 0.4.2 + Produce and write MD5 checksums for each single IsoFile. + bit8= file_stability (only together with file_md5) + @since 0.4.2 + Compute MD5 of each file before copying it into the image and + compare this with the MD5 of the actual copying. If they do + not match then issue MISHAP event. + See also libisofs.h iso_write_opts_set_record_md5() + @return 1 success, <=0 failure +*/ +#define isoburn_igopt_rockridge 1 +#define isoburn_igopt_joliet 2 +#define isoburn_igopt_iso1999 4 +#define isoburn_igopt_hardlinks 8 +#define isoburn_igopt_aaip 32 +#define isoburn_igopt_session_md5 64 +#define isoburn_igopt_file_md5 128 +#define isoburn_igopt_file_stability 256 +int isoburn_igopt_set_extensions(struct isoburn_imgen_opts *o, int ext); +int isoburn_igopt_get_extensions(struct isoburn_imgen_opts *o, int *ext); + +/** Relaxed constraints. Setting any of the bits to 1 break the specifications, + but it is supposed to work on most moderns systems. Use with caution. + @since 0.1.0 + @param o The option set to work on + @param relax Bitfield: + bit0= omit_version_numbers + Omit the version number (";1") at the end of the + ISO-9660 identifiers. Version numbers are usually + not used. + bit1= allow_deep_paths + Allow ISO-9660 directory hierarchy to be deeper + than 8 levels. + bit2= allow_longer_paths + Allow path in the ISO-9660 tree to have more than + 255 characters. + bit3= max_37_char_filenames + Allow a single file or directory hierarchy to have + up to 37 characters. This is larger than the 31 + characters allowed by ISO level 2, and the extra space + is taken from the version number, so this also forces + omit_version_numbers. + bit4= no_force_dots + ISO-9660 forces filenames to have a ".", that separates + file name from extension. libisofs adds it if original + filename has none. Set this to 1 to prevent this + behavior. + bit5= allow_lowercase + Allow lowercase characters in ISO-9660 filenames. + By default, only uppercase characters, numbers and + a few other characters are allowed. + bit6= allow_full_ascii + Allow all ASCII characters to be appear on an ISO-9660 + filename. Note * that "/" and "\0" characters are never + allowed, even in RR names. + bit7= joliet_longer_paths + Allow paths in the Joliet tree to have more than + 240 characters. + bit8= always_gmt + Write timestamps as GMT although the specs prescribe local + time with eventual non-zero timezone offset. Negative + timezones (west of GMT) can trigger bugs in some operating + systems which typically appear in mounted ISO images as if + the timezone shift from GMT was applied twice + (e.g. in New York 22:36 becomes 17:36). + bit9= rrip_version_1_10 + Write Rock Ridge info as of specification RRIP-1.10 rather + than RRIP-1.12: signature "RRIP_1991A" rather than + "IEEE_1282", field PX without file serial number. + bit10= dir_rec_mtime + Store as ECMA-119 Directory Record timestamp the mtime + of the source rather than the image creation time. + bit11= aaip_susp_1_10 + Write AAIP fields without announcing AAIP by an ER field and + without distinguishing RRIP fields from the AAIP field by + prefixed ES fields. This saves 5 to 10 bytes per file and + might avoid problems with readers which only accept RRIP. + SUSP-1.10 allows it, SUSP-1.12 frowns on it. + + @return 1 success, <=0 failure +*/ +#define isoburn_igopt_omit_version_numbers 1 +#define isoburn_igopt_allow_deep_paths 2 +#define isoburn_igopt_allow_longer_paths 4 +#define isoburn_igopt_max_37_char_filenames 8 +#define isoburn_igopt_no_force_dots 16 +#define isoburn_igopt_allow_lowercase 32 +#define isoburn_igopt_allow_full_ascii 64 +#define isoburn_igopt_joliet_longer_paths 128 +#define isoburn_igopt_always_gmt 256 +#define isoburn_igopt_rrip_version_1_10 512 +#define isoburn_igopt_dir_rec_mtime 1024 +#define isoburn_igopt_aaip_susp_1_10 2048 +int isoburn_igopt_set_relaxed(struct isoburn_imgen_opts *o, int relax); +int isoburn_igopt_get_relaxed(struct isoburn_imgen_opts *o, int *relax); + + +/** Whether and how files should be sorted. + @since 0.1.0 + @param o The option set to work on + @param value Bitfield: bit0= sort_files_by_weight + files should be sorted based on their weight. + Weight is attributed to files in the image + by libisofs call iso_node_set_sort_weight(). + @return 1 success, <=0 failure +*/ +#define isoburn_igopt_sort_files_by_weight 1 +int isoburn_igopt_set_sort_files(struct isoburn_imgen_opts *o, int value); +int isoburn_igopt_get_sort_files(struct isoburn_imgen_opts *o, int *value); + + +/** Set the override values for files and directory permissions. + The parameters replace_* these take one of three values: 0, 1 or 2. + If 0, the corresponding attribute will be kept as set in the IsoNode + at the time of image generation. + If set to 1, the corresponding attrib. will be changed by a default + suitable value. + With value 2, the attrib. will be changed with the value specified + in the corresponding *_mode options. Note that only the permissions + are set, the file type remains unchanged. + @since 0.1.0 + @param o The option set to work on + @param replace_dir_mode whether and how to override directories + @param replace_file_mode whether and how to override files of other type + @param dir_mode Mode to use on dirs with replace_dir_mode == 2. + @param file_mode; Mode to use on files with replace_file_mode == 2. + @return 1 success, <=0 failure +*/ +int isoburn_igopt_set_over_mode(struct isoburn_imgen_opts *o, + int replace_dir_mode, int replace_file_mode, + mode_t dir_mode, mode_t file_mode); +int isoburn_igopt_get_over_mode(struct isoburn_imgen_opts *o, + int *replace_dir_mode, int *replace_file_mode, + mode_t *dir_mode, mode_t *file_mode); + +/** Set the override values values for group id and user id. + The rules are like with above overriding of mode values. replace_* controls + whether and how. The other two parameters provide values for eventual use. + @since 0.1.0 + @param o The option set to work on + @param replace_uid whether and how to override user ids + @param replace_gid whether and how to override group ids + @param uid User id to use with replace_uid == 2. + @param gid Group id to use on files with replace_gid == 2. + @return 1 success, <=0 failure +*/ +int isoburn_igopt_set_over_ugid(struct isoburn_imgen_opts *o, + int replace_uid, int replace_gid, + uid_t uid, gid_t gid); +int isoburn_igopt_get_over_ugid(struct isoburn_imgen_opts *o, + int *replace_uid, int *replace_gid, + uid_t *uid, gid_t *gid); + +/** Set the charcter set to use for representing filenames in the image. + @since 0.1.0 + @param o The option set to work on + @param output_charset Set this to NULL to use the default output charset. + For selecting a particular character set, submit its + name, e.g. as listed by program iconv -l. + Example: "UTF-8". + @return 1 success, <=0 failure +*/ +int isoburn_igopt_set_out_charset(struct isoburn_imgen_opts *o, + char *output_charset); +int isoburn_igopt_get_out_charset(struct isoburn_imgen_opts *o, + char **output_charset); + + +/** The number of bytes to be used for the fifo which decouples libisofs + and libburn for better throughput and for reducing the risk of + interrupting signals hitting the libburn thread which operates the + MMC drive. + The size will be rounded up to the next full 2048. + Minimum is 64kiB, maximum is 1 GiB (but that is too much anyway). + @since 0.1.0 + @param o The option set to work on + @param fifo_size Number of bytes to use + @return 1 success, <=0 failure +*/ +int isoburn_igopt_set_fifo_size(struct isoburn_imgen_opts *o, int fifo_size); +int isoburn_igopt_get_fifo_size(struct isoburn_imgen_opts *o, int *fifo_size); + + +/** Obtain after image preparation the block address where the session will + start on media. + This value cannot be set by the application but only be inquired. + @since 0.1.4 + @param o The option set to work on + @param lba The block number of the session start on media. + <0 means that no address has been determined yet. + @return 1 success, <=0 failure +*/ +int isoburn_igopt_get_effective_lba(struct isoburn_imgen_opts *o, int *lba); + + +/** Obtain after image preparation the lowest block address of file content + data. Failure can occur if libisofs is too old to provide this information, + if the result exceeds 31 bit, or if the call is made before image + preparation. + This value cannot be set by the application but only be inquired. + @since 0.3.6 + @param o The option set to work on + @param lba The block number of the session start on media. + <0 means that no address has been determined yet. + @return 1 success, <=0 failure +*/ +int isoburn_igopt_get_data_start(struct isoburn_imgen_opts *o, int *lba); + + + +/* ----------------------------------------------------------------------- */ +/* End of Options for image generation */ +/* ----------------------------------------------------------------------- */ + + +/** Get the image attached to a drive, if any. + @since 0.1.0 + @param d The drive to inquire + @return A reference to attached image, or NULL if the drive has no image + attached. This reference needs to be released via iso_image_unref() + when it is not longer needed. +*/ +IsoImage *isoburn_get_attached_image(struct burn_drive *d); + + +/** Load the ISO filesystem directory tree from the media in the given drive. + This will give libisoburn the base on which it can let libisofs perform + image growing or image modification. The loaded volset gets attached + to the drive object and handed out to the application. + Not a wrapper, but peculiar to libisoburn. + @since 0.1.0 + @param d The drive which holds an existing ISO filesystem or blank media. + d is allowed to be NULL which produces an empty ISO image. In + this case one has to call before writing isoburn_attach_volset() + with the volset from this call and with the intended output + drive. + @param read_opts The read options which can be chosen by the application + @param image the image read, if the disc is blank it will have no files. + This reference needs to be released via iso_image_unref() when + it is not longer needed. The drive, if not NULL, will hold an + own reference which it will release when it gets a new volset + or when it gets released via isoburn_drive_release(). + You can pass NULL if you already have a reference or you plan to + obtain it later with isoburn_get_attached_image(). Of course, if + you haven't specified a valid drive (i.e., if d == NULL), this + parameter can't be NULL. + @return <=0 error , 1 = success +*/ +int isoburn_read_image(struct burn_drive *d, + struct isoburn_read_opts *read_opts, + IsoImage **image); + +/** Set a callback function for producing pacifier messages during the lengthy + process of image reading. The callback function and the application handle + are stored until they are needed for the underlying call to libisofs. + Other than with libisofs the handle is managed entirely by the application. + An idle .free() function is exposed to libisofs. The handle has to stay + valid until isoburn_read_image() is done. It has to be detached by + isoburn_set_read_pacifier(drive, NULL, NULL); + before it may be removed from memory. + @since 0.1.0 + @param drive The drive which will be used with isoburn_read_image() + It has to be aquired by an isoburn_* wrapper call. + @param read_pacifier The callback function + @param app_handle The app handle which the callback function can obtain + via iso_image_get_attached_data() from its IsoImage* + @return 1 success, <=0 failure +*/ +int isoburn_set_read_pacifier(struct burn_drive *drive, + int (*read_pacifier)(IsoImage*, IsoFileSource*), + void *app_handle); + + +/** Set the IsoImage to be used with a drive. This eventually releases + the reference to the old IsoImage attached to the drive. + Caution: Use with care. It hardly makes sense to replace an image that + reflects a valid ISO image on media. + This call is rather intended for writing a newly created and populated + image to blank media. The use case in xorriso is to let an image survive + the change or demise of the outdev target drive. + @since 0.1.0 + @param d The drive which shall be write target of the volset. + @param image The image that represents the image to be written. + This image pointer MUST already be a valid reference suitable + for iso_image_unref(). + It may have been obtained by appropriate libisofs calls or by + isoburn_read_image() with d==NULL. + @return <=0 error , 1 = success +*/ +int isoburn_attach_image(struct burn_drive *d, IsoImage *image); + + +/** Return the best possible estimation of the currently available capacity of + the media. This might depend on particular write option settings and on + drive state. + An eventual start address for emulated multi-session will be subtracted + from the capacity estimation given by burn_disc_available_space(). + Negative results get defaulted to 0. + Wrapper for: burn_disc_available_space() + @since 0.1.0 + @param d The drive to query. + @param o If not NULL: write parameters to be set on drive before query + @return number of most probably available free bytes +*/ +off_t isoburn_disc_available_space(struct burn_drive *d, + struct burn_write_opts *o); + + +/** Obtain the start block number of the most recent session on media. In + case of random access media this will normally be 0. Successfull return is + not a guarantee that there is a ISO-9660 image at all. The call will fail, + nevertheless,if isoburn_disc_get_status() returns not BURN_DISC_APPENDABLE + or BURN_DISC_FULL. + Note: The result of this call may be fabricated by a previous call of + isoburn_set_msc1() which can override the rule to load the most recent + session. + Wrapper for: burn_disc_get_msc1() + @since 0.1.0 + @param d The drive to inquire + @param start_lba Contains on success the start address in 2048 byte blocks + @return <=0 error , 1 = success +*/ +int isoburn_disc_get_msc1(struct burn_drive *d, int *start_lba); + + +/** Use this with trackno==0 to obtain the predicted start block number of the + new session. The interesting number is returned in parameter nwa. + Wrapper for: burn_disc_track_lba_nwa() + @since 0.1.0 + @param d The drive to inquire + @param o If not NULL: write parameters to be set on drive before query + @param trackno Submit 0. + @param lba return value: start lba + @param nwa return value: Next Writeable Address + @return 1=nwa is valid , 0=nwa is not valid , -1=error +*/ +int isoburn_disc_track_lba_nwa(struct burn_drive *d, struct burn_write_opts *o, + int trackno, int *lba, int *nwa); + + +/** Obtain the size which was attributed to an emulated appendable on actually + overwriteable media. This value is supposed to be <= 2048 * nwa as of + isoburn_disc_track_lba_nwa(). + @since 0.1.0 + @param drive The drive holding the media. + @param start_byte The reply value counted in bytes, not in sectors. + @param flag Unused yet. Submit 0. + @return 1=stat_byte is valid, 0=not an emulated appendable, -1=error +*/ +int isoburn_get_min_start_byte(struct burn_drive *d, off_t *start_byte, + int flag); + + +/** To choose the expansion method of Growing: + Create a disc object for writing the new session from the created or loaded + iso_volset which has been manipulated via libisofs, to the same media from + where the image was eventually loaded. This struct burn_disc is ready for + use by a subsequent call to isoburn_disc_write(). + After this asynchronous writing has ended and the drive is BURN_DRIVE_IDLE + again, the burn_disc object has to be disposed by burn_disc_free(). + @since 0.1.0 + @param drive The combined source and target drive, grabbed with + isoburn_drive_scan_and_grab(). . + @param disc Returns the newly created burn_disc object. + @param opts Image generation options, see isoburn_igopt_*() + @return <=0 error , 1 = success +*/ +int isoburn_prepare_disc(struct burn_drive *drive, struct burn_disc **disc, + struct isoburn_imgen_opts *opts); + + +/** To choose the expansion method of Modifying: + Create a disc object for producing a new image from a previous image + plus the changes made by user. The generated burn_disc is suitable + to be written to a grabbed drive with blank writeable media. + But you must not use the same drive for input and output, because data + will be read from the source drive while at the same time the target + drive is already writing. + The resulting burn_disc object has to be disposed when all its writing + is done and the drive is BURN_DRIVE_IDLE again after asynchronous + burn_disc_write(). + @since 0.1.0 + @param in_drive The input drive, grabbed with isoburn_drive_aquire() or + one of its alternatives. + @param disc Returns the newly created burn_disc object. + @param opts Options for image generation and data transport to media. + @param out_drive The output drive, from isoburn_drive_aquire() et.al.. + @return <=0 error , 1 = success +*/ +int isoburn_prepare_new_image(struct burn_drive *in_drive, + struct burn_disc **disc, + struct isoburn_imgen_opts *opts, + struct burn_drive *out_drive); + + +/** To choose the expansion method of Blind Growing: + Create a disc object for writing an add-on session from the created or + loaded IsoImage which has been manipulated via libisofs, to a different + drive than the one from where it was loaded. + Usually output will be stdio:/dev/fd/1 (i.e. stdout) being piped + into some burn program like with this classic gesture: + mkisofs -M $dev -C $msc1,$nwa | cdrecord -waiti dev=$dev + Parameter translation into libisoburn: + $dev is the address by which parameter in_drive of this call was aquired + $msc1 was set by isoburn_set_msc1() before image reading + or was detected from the in_drive media + $nwa is a parameter of this call + or can be used as detected from the in_drive media + + This call waits for libisofs output to become available and then detaches + the input drive object from the data source object by which libisofs was + reading from the input drive. + So, as far as libisofs is concerned, that drive may be released immediately + after this call in order to allow the consumer to access the drive for + writing. + The consumer should wait for input to become available and only then open + its burn drive. With cdrecord this is caused by option -waiti. + + The resulting burn_disc object has to be disposed when all its writing + is done and the drive is BURN_DRIVE_IDLE again after asynchronous + burn_disc_write(). + @since 0.2.2 + @param in_drive The input drive,grabbed with isoburn_drive_scan_and_grab(). + @param disc Returns the newly created burn_disc object. + @param opts Options for image generation and data transport to media. + @param out_drive The output drive, from isoburn_drive_aquire() et.al.. + typically stdio:/dev/fd/1 . + @param nwa The address (2048 byte block count) where the add-on + session will be finally stored on a mountable media + or in a mountable file. + If nwa is -1 then the address is used as determined from + the in_drive media. + @return <=0 error , 1 = success +*/ +int isoburn_prepare_blind_grow(struct burn_drive *d, struct burn_disc **disc, + struct isoburn_imgen_opts *opts, + struct burn_drive *out_drive, int nwa); + + +/** + Revoke isoburn_prepare_*() instead of running isoburn_disc_write(). + libisofs reserves resources and maybe already starts generating the + image stream when one of above three calls is performed. It is mandatory to + either run isoburn_disc_write() or to revoke the preparations by the + call described here. + @since 0.1.0 + @param input_drive The drive resp. in_drive which was used with the + preparation call. + @param output_drive The out_drive used with isoburn_prepare_new_image(), + NULL if none. + @param flag Bitfield, submit 0 for now. + bit0= -reserved for internal use- + @return <0 error, 0= no pending preparations detectable, 1 = canceled +*/ +int isoburn_cancel_prepared_write(struct burn_drive *input_drive, + struct burn_drive *output_drive, int flag); + + +/** Start writing of the new session. + This call is asynchrounous. I.e. it returns quite soon and the progress has + to be watched by a loop with call burn_drive_get_status() until + BURN_DRIVE_IDLE is returned. + Wrapper for: burn_disc_write() + @since 0.1.0 + @param o Options which control the burn process. See burnwrite_opts_*() + in libburn.h. + @param disc Disc object created either by isoburn_prepare_disc() or by + isoburn_prepare_new_image(). +*/ +void isoburn_disc_write(struct burn_write_opts *o, struct burn_disc *disc); + + +/** Inquire state and fill parameters of the fifo which is attached to + the emerging track. This should be done in the pacifier loop while + isoburn_disc_write() or burn_disc_write() are active. + This works only with drives obtained by isoburn_drive_scan_and_grab() + or isoburn_drive_grab(). If isoburn_prepare_new_image() was used, then + parameter out_drive must have announced the track output drive. + Hint: If only burn_write_opts and not burn_drive is known, then the drive + can be obtained by burn_write_opts_get_drive(). + @since 0.1.0 + @param d The drive to which the track with the fifo gets burned. + @param size The total size of the fifo + @param free_bytes The current free capacity of the fifo + @param status_text Returns a pointer to a constant text, see below + @return <0 reply invalid, >=0 fifo status code: + bit0+1=input status, bit2=consumption status, i.e: + 0="standby" : data processing not started yet + 1="active" : input and consumption are active + 2="ending" : input has ended without error + 3="failing" : input had error and ended, + 4="unused" : ( consumption has ended before processing start ) + 5="abandoned" : consumption has ended prematurely + 6="ended" : consumption has ended without input error + 7="aborted" : consumption has ended after input error +*/ +int isoburn_get_fifo_status(struct burn_drive *d, int *size, int *free_bytes, + char **status_text); + + +/** Inquire whether the most recent write run was successful. + Wrapper for: burn_drive_wrote_well() + @since 0.1.0 + @param d The drive to inquire + @return 1=burn seems to have went well, 0=burn failed +*/ +int isoburn_drive_wrote_well(struct burn_drive *d); + + +/** Call this after isoburn_disc_write has finished and burn_drive_wrote_well() + indicates success. It will eventually complete the emulation of + multi-session functionality, if needed at all. Let libisoburn decide. + Not a wrapper, but peculiar to libisoburn. + @since 0.1.0 + @param d The output drive to which the session was written + @return 1 success , <=0 failure +*/ +int isoburn_activate_session(struct burn_drive *drive); + + +/** Wait after normal end of operations until libisofs ended all write + threads and freed resource reservations. + This call is not mandatory. But without it, messages from the ending + threads might appear after the application ended its write procedure. + @since 0.1.0 + @param input_drive The drive resp. in_drive which was used with the + preparation call. + @param output_drive The out_drive used with isoburn_prepare_new_image(), + NULL if none. + @param flag Bitfield, submit 0 for now. + @return <=0 error , 1 = success +*/ +int isoburn_sync_after_write(struct burn_drive *input_drive, + struct burn_drive *output_drive, int flag); + + +/** Release an aquired drive. + Wrapper for: burn_drive_release() + @since 0.1.0 + @param drive The drive to be released + @param eject 1= eject media from drive , 0= do not eject +*/ +void isoburn_drive_release(struct burn_drive *drive, int eject); + + +/** Shutdown all three libraries. + Wrapper for : iso_finish() and burn_finish(). + @since 0.1.0 +*/ +void isoburn_finish(void); + + +/* + The following calls are for expert applications only. + An application should have a special reason to use them. +*/ + + +/** Inquire wether the media needs emulation or would be suitable for + generic multi-session via libburn. + @since 0.1.0 + @param d The drive to inquire + @return 0 is generic multi-session + 1 is emulated multi-session + -1 is not suitable for isoburn +*/ +int isoburn_needs_emulation(struct burn_drive *drive); + + diff --git a/libisoburn/branches/ZeroFourTwo/test/compare_file.c b/libisoburn/branches/ZeroFourTwo/test/compare_file.c new file mode 100644 index 00000000..7056e793 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/test/compare_file.c @@ -0,0 +1,277 @@ +/* + Compare two copies of a file object in as many aspects as i can imagine + to make sense. (E.g.: comparing atime makes no sense.) + + To compare tree /media/dvd and /original/dir : + find /media/dvd -exec compare_file '{}' /media/dvd /original/dir ';' + + Copyright 2008 Thomas Schmitt, + + Provided under GPL version 2. + + + cc -g -o compare_file compare_file.c +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/* @param flag bit0= single letters */ +char *Ftypetxt(mode_t st_mode, int flag) +{ + if(flag&1) + goto single_letters; + if(S_ISDIR(st_mode)) + return("directory"); + else if(S_ISREG(st_mode)) + return("regular_file"); + else if(S_ISLNK(st_mode)) + return("symbolic_link"); + else if(S_ISBLK(st_mode)) + return("block_device"); + else if(S_ISCHR(st_mode)) + return("char_device"); + else if(S_ISFIFO(st_mode)) + return("name_pipe"); + else if(S_ISSOCK(st_mode)) + return("unix_socket"); + return("unknown"); +single_letters:; + if(S_ISDIR(st_mode)) + return("d"); + else if(S_ISREG(st_mode)) + return("-"); + else if(S_ISLNK(st_mode)) + return("l"); + else if(S_ISBLK(st_mode)) + return("b"); + else if(S_ISCHR(st_mode)) + return("c"); + else if(S_ISFIFO(st_mode)) + return("p"); + else if(S_ISSOCK(st_mode)) + return("s"); + return("?"); +} + + +char *Ftimetxt(time_t t, char timetext[40], int flag) +{ + char *rpt; + struct tm tms, *tmpt; + static char months[12][4]= { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + + tmpt= localtime_r(&t, &tms); + rpt= timetext; + rpt[0]= 0; + if(tmpt==0) + sprintf(rpt+strlen(rpt), "%12.f", (double) t); + else if(time(NULL)-t < 180*86400 && time(NULL)-t >= 0) + sprintf(rpt+strlen(rpt), "%3s %2d %2.2d:%2.2d", + months[tms.tm_mon], tms.tm_mday, tms.tm_hour, tms.tm_min); + else + sprintf(rpt+strlen(rpt), "%3s %2d %4.4d", + months[tms.tm_mon], tms.tm_mday, 1900+tms.tm_year); + return(timetext); +} + + +/* @param flag bit0= compare atime + bit1= compare ctime +*/ +int Compare_2_files(char *adr1, char *adr2, char *adrc, int flag) +{ + struct stat s1, s2; + int ret, differs= 0, r1, r2, fd1= -1, fd2= -1, i, done; + char buf1[4096], buf2[4096], a[4096], ttx1[40], ttx2[40]; + off_t r1count= 0, r2count= 0, diffcount= 0, first_diff= -1; + + ret= lstat(adr1, &s1); + if(ret==-1) { + printf("? %s : cannot lstat() : %s\n", adr1, strerror(errno)); + return(0); + } + strcpy(a, Ftypetxt(s1.st_mode, 1)); + strcat(a, " "); + if(adrc[0]) + strcat(a, adrc); + else + strcat(a, "."); + + ret= lstat(adr2, &s2); + if(ret==-1) { + printf("? %s : cannot lstat() : %s\n", adr2, strerror(errno)); + return(0); + } + + /* Attributes */ + if(s1.st_mode != s2.st_mode) { + if((s1.st_mode&~S_IFMT)!=(s2.st_mode&~S_IFMT)) + printf("%s : st_mode : %7.7o <> %7.7o\n", a, + (unsigned int) (s1.st_mode & ~S_IFMT), + (unsigned int) (s2.st_mode & ~S_IFMT)); + if((s1.st_mode&S_IFMT)!=(s2.st_mode&S_IFMT)) + printf("%s : type : %s <> %s\n", + a, Ftypetxt(s1.st_mode, 0), Ftypetxt(s2.st_mode, 0)); + differs= 1; + } + if(s1.st_uid != s2.st_uid) { + printf("%s : st_uid : %d <> %d\n", a, s1.st_uid, s2.st_uid); + differs= 1; + } + if(s1.st_gid != s2.st_gid) { + printf("%s : st_gid : %d <> %d\n", a, s1.st_gid, s2.st_gid); + differs= 1; + } + if((S_ISCHR(s1.st_mode) && S_ISCHR(s2.st_mode)) || + (S_ISBLK(s1.st_mode) && S_ISBLK(s2.st_mode))) { + if(s1.st_rdev != s2.st_rdev) { + printf("%s : %s st_rdev : %lu <> %lu\n", a, + (S_ISCHR(s1.st_mode) ? "S_IFCHR" : "S_IFBLK"), + (unsigned long) s1.st_rdev, (unsigned long) s1.st_rdev); + differs= 1; + } + } + if(S_ISREG(s2.st_mode) && s1.st_size != s2.st_size) { + printf("%s : st_size : %.f <> %.f diff= %.f\n", + a, (double) s1.st_size, (double) s2.st_size, + ((double) s1.st_size) - (double) s2.st_size); + differs= 1; + } + if(s1.st_mtime != s2.st_mtime) { + printf("%s : st_mtime : %s <> %s diff= %.f s\n", + a, Ftimetxt(s1.st_mtime, ttx1, 0), + Ftimetxt(s2.st_mtime, ttx2, 0), + ((double) s1.st_mtime) - (double) s2.st_mtime); + differs= 1; + } + if(flag&1) { + if(s1.st_atime != s2.st_atime) { + printf("%s : st_atime : %s <> %s diff= %.f s\n", + a, Ftimetxt(s1.st_atime, ttx1, 0), + Ftimetxt(s2.st_atime, ttx2, 0), + ((double) s1.st_atime) - (double) s2.st_atime); + differs= 1; + } + } + if(flag&2) { + if(s1.st_ctime != s2.st_ctime) { + printf("%s : st_ctime : %s <> %s diff= %.f s\n", + a, Ftimetxt(s1.st_ctime, ttx1, 0), + Ftimetxt(s2.st_ctime, ttx2, 0), + ((double) s1.st_ctime) - (double) s2.st_ctime); + differs= 1; + } + } + if(S_ISREG(s1.st_mode) && S_ISREG(s2.st_mode)) { + fd1= open(adr1, O_RDONLY); + if(fd1==-1) { + printf("- %s : cannot open() : %s\n", adr1, strerror(errno)); + return(0); + } + fd2= open(adr2, O_RDONLY); + if(fd2==-1) { + printf("- %s : cannot open() : %s\n", adr2, strerror(errno)); + close(fd1); + return(0); + } + + /* Content */ + done= 0; + while(!done) { + r1= read(fd1, buf1, sizeof(buf1)); + r2= read(fd2, buf2, sizeof(buf2)); + if((r1==EOF && r2==EOF) || (r1==0 && r2==0)) + break; + if(r1==EOF || r1==0) { + if(r1==EOF) + r1= 0; + if(s1.st_size > r1count + r1) + printf("- %s : early EOF after %.f bytes\n", adr1, (double) r1count); + differs= 1; + } + r1count+= r1; + if(r2==EOF || r2 r2count + r2) + printf("- %s : early EOF after %.f bytes\n", adr2, (double) r2count); + differs= 1; + done= 1; + } + if(r2>r1) { + if(s1.st_size > r1count + r1) + printf("- %s : early EOF after %.f bytes\n", adr1, (double) r1count); + differs= 1; + done= 1; + } + r2count+= r2; + if(r1>r2) + r1= r2; + for(i= 0; i0 || r1count!=r2count) { + if(first_diff<0) + first_diff= (r1count>r2count ? r2count : r1count); + printf("%s : %s : differs by at least %.f bytes. First at %.f\n", a, + (s1.st_mtime==s2.st_mtime ? "CONTENT":"content"), + (double) (diffcount + abs(r1count-r2count)), (double) first_diff); + differs= 1; + } + } + if(fd1!=-1) + close(fd1); + if(fd2!=-1) + close(fd2); + return(!differs); +} + + +int main(int argc, char **argv) +{ + int ret, i, with_ctime= 1; + char adr1[4096], adr2[4096], adrc[4096]; + + if(argc<4) { + fprintf(stderr, "usage: %s path prefix1 prefix2\n", argv[0]); + exit(2); + } + for(i= 4; i + and Thomas Schmitt +*/ + + +#include +#include +#include +#include +#include +#include +#include +#include + + +#include +#include +#include "../src/libisoburn.h" + +const char * const optstring = "JRh"; +extern char *optarg; +extern int optind; + + +/** Activates the usage of function graft_point() rather than + plain iso_tree_radd_dir() from libisofs +*/ +#define With_graft_poinT 1 + + +static int graft_point(struct iso_volume *volume, const char *disk_path, + const char *img_path, struct iso_tree_radd_dir_behavior *behav) +{ + char path[4096], *apt, *npt; + struct iso_tree_node_dir *dir; + struct iso_tree_node *node; + int done= 0, is_dir= 0; + struct stat stbuf; + + strncpy(path, img_path, sizeof(path)-1); + path[sizeof(path)-1]= 0; + apt= npt= path; + + if(lstat(disk_path, &stbuf) == -1) { + fprintf(stderr, "Cannot determine attributes of '%s' : %s (%d)\n", + disk_path, (errno > 0 ? strerror(errno) : "unknown error"), errno); + return(0); + } + if(S_ISDIR(stbuf.st_mode)) + is_dir= 1; + else if(!(S_ISREG(stbuf.st_mode) || S_ISLNK(stbuf.st_mode))) { + fprintf(stderr, "File object '%s' is of non-supported file type\n", + disk_path); + return(0); + } + + dir= iso_volume_get_root(volume); + if(dir==NULL) { + fprintf(stderr, "While grafting '%s' : no root node available\n", img_path); + return(0); + } + for(npt= apt; !done; apt= npt+1) { + npt= strchr(apt, '/'); + if(npt==NULL) { + npt= apt+strlen(apt); + done= 1; + } else + *npt= 0; + if(*apt==0) { + *apt= '/'; + apt++; + continue; + } + node= iso_tree_volume_path_to_node(volume,path); + if(node!=NULL) { + if(iso_tree_node_get_type(node)!=LIBISO_NODE_DIR) { + fprintf(stderr, "While grafting '%s' : '%s' is not a directory\n", + img_path, path); + return(0); + } + dir= (struct iso_tree_node_dir *) node; + } else { + dir= iso_tree_add_dir(dir, apt); + if(dir==NULL) { + fprintf(stderr, "While grafting '%s' : could not insert '%s'\n", + img_path, path); + return(0); + } + } + if(done) { + if(is_dir) { + iso_tree_radd_dir(dir, disk_path, behav); + } else { + node= iso_tree_add_node(dir, disk_path); + if(node == NULL) { + fprintf(stderr, "While grafting '%s'='%s' : libisofs_errno = %d\n", + img_path, disk_path, libisofs_errno); + } + } + } else + *npt= '/'; + } + fprintf(stderr, "NOTE: added %s '%s'='%s'\n", (is_dir ? "directory" : "node"), + img_path, disk_path); + return(1); +} + + +static +void usage() +{ + printf("test [OPTIONS] DRIVE DIRECTORY\n"); +} + +static +void help() +{ + printf( +"Options:\n" +" -J Add Joliet support\n" +" -R Add Rock Ridge support\n" +" -h Print this message\n" +); +} + +int main(int argc, char **argv) +{ + struct burn_drive_info *drives; + struct iso_volset *volset; + struct burn_drive *drive; + struct burn_disc *disc; + enum burn_disc_status state; + struct isoburn_read_opts ropts; + struct isoburn_source_opts sopts; + int c; + struct iso_tree_radd_dir_behavior behav = {0,0,0}; + int flags=0; + int ret=0, i; + int size, free_bytes; + char *status_text; + + while ((c = getopt(argc, argv, optstring)) != -1) { + switch(c) { + case 'h': + usage(); + help(); + exit(0); + break; + case 'J': + flags |= ECMA119_JOLIET; + break; + case 'R': + flags |= ECMA119_ROCKRIDGE; + break; + case '?': + usage(); + exit(1); + break; + } + } + + if (argc < optind + 1) { + fprintf(stderr, "Please supply device name\n"); + usage(); + exit(1); + } + if (argc < optind + 2) { + fprintf(stderr, "Please supply directory to add to disc\n"); + usage(); + exit(1); + } + + + if (!isoburn_initialize()) { + fprintf(stderr, "Can't init libisoburn\n"); + exit(1); + } + + /* TODO change this. maybe we can add wrapp in libisoburn */ + iso_msgs_set_severities("NEVER", "DEBUG", "libisofs : "); + burn_msgs_set_severities("NEVER", "DEBUG", "libburn : "); + burn_set_signal_handling("libisoburn/test/test : ", NULL, 0); + + printf("Growing drive %s\n", argv[optind]); + + if (isoburn_drive_scan_and_grab(&drives, argv[optind], 1) <= 0) { + fprintf(stderr, + "Can't open device. Are you sure it is a valid drive?\n"); + exit(1); + } + drive = drives[0].drive; + + /* check for invalid state */ + state = isoburn_disc_get_status(drive); + if (state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE) { + fprintf(stderr, "Unsuitable disc status\n"); + goto exit_cleanup; + } + + /* fill read opts */ + memset(&ropts, sizeof(ropts), 0); + ropts.norock = 0; + ropts.nojoliet = 0; + ropts.preferjoliet = 0; + ropts.uid = 0; + ropts.gid = 0; + ropts.mode = 0555; + ropts.pretend_blank= 0; + + if (isoburn_read_volset(drive, &ropts, &volset) <= 0) { + fprintf(stderr, "Can't read volset\n"); + goto exit_cleanup; + } + + +#ifdef With_graft_poinT + for (i = optind + 1; i < argc; i++) { + if (graft_point(iso_volset_get_volume(volset, 0), + argv[i], argv[i], &behav) <= 0) { + fprintf(stderr, "Canot graft '%s'\n", argv[optind+1]); + goto exit_cleanup; + } + } + +#else + struct iso_tree_node_dir *root; + root = iso_volume_get_root(iso_volset_get_volume(volset, 0)); + /* add a new dir */ + iso_tree_radd_dir(root, argv[optind+1], &behav); +#endif /* ! With_graft_poinT */ + + + sopts.level = 2; + sopts.flags = flags; + sopts.relaxed_constraints = 0; + sopts.copy_eltorito = 1; + sopts.no_cache_inodes = 0; + sopts.sort_files = 1; + sopts.default_mode = 0; + sopts.replace_dir_mode = 0; + sopts.replace_file_mode = 0; + sopts.replace_uid = 0; + sopts.replace_gid = 0; + sopts.dir_mode = 0555; + sopts.file_mode = 0444; + sopts.gid = 0; + sopts.uid = 0; + sopts.input_charset = NULL; + sopts.ouput_charset = NULL; + + if (isoburn_prepare_disc(drive, &disc, &sopts) <= 0) { + fprintf(stderr, "Can't prepare disc\n"); + goto volset_cleanup; + } + + /* a. write the new image */ + printf("Adding new data...\n"); + { + struct burn_write_opts *burn_options; + struct burn_progress progress; + + burn_options = burn_write_opts_new(drive); + burn_drive_set_speed(drive, 0, 0); + burn_write_opts_set_underrun_proof(burn_options, 1); + + /* ok, write the new track */ + isoburn_disc_write(burn_options, disc); + burn_write_opts_free(burn_options); + + while (burn_drive_get_status(drive, NULL) == BURN_DRIVE_SPAWNING) + usleep(100002); + + while (burn_drive_get_status(drive, &progress) + != BURN_DRIVE_IDLE) { + + printf("Writing: sector %d of %d", + progress.sector, progress.sectors); + ret = isoburn_get_fifo_status(drive, &size, + &free_bytes, &status_text); + if (ret > 0 ) + printf(" [fifo %s, %2d%% fill]", status_text, + (int) (100.0 - 100.0 * + ((double) free_bytes) / + (double) size)); + printf("\n"); + sleep(1); + } + } + + /* b. write the new vol desc */ + printf("Writing the new vol desc...\n"); + if (isoburn_activate_session(drive) <= 0) { + fprintf(stderr, "Ups, new vol desc write failed\n"); + } + + ret= 0; +volset_cleanup:; +/* + iso_volset_free(volset); +*/ + +exit_cleanup:; + isoburn_drive_release(drive, 0); + isoburn_finish(); + + exit(ret); +} + diff --git a/libisoburn/branches/ZeroFourTwo/version.h.in b/libisoburn/branches/ZeroFourTwo/version.h.in new file mode 100644 index 00000000..cf529233 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/version.h.in @@ -0,0 +1,6 @@ + +/* <<< this file is on its way out +#define ISOBURN_MAJOR_VERSION @ISOBURN_MAJOR_VERSION@ +#define ISOBURN_MINOR_VERSION @ISOBURN_MINOR_VERSION@ +#define ISOBURN_MICRO_VERSION @ISOBURN_MICRO_VERSION@ +*/ diff --git a/libisoburn/branches/ZeroFourTwo/xorriso/README b/libisoburn/branches/ZeroFourTwo/xorriso/README new file mode 100644 index 00000000..2f32253e --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/xorriso/README @@ -0,0 +1,263 @@ +------------------------------------------------------------------------------ + libburnia-project.org scdbackup.sourceforge.net/xorriso_eng.html +------------------------------------------------------------------------------ +xorriso. By Thomas Schmitt +Integrated sub project of libburnia-project.org but also published via: +http://scdbackup.sourceforge.net/xorriso_eng.html +http://scdbackup.sourceforge.net/xorriso-0.4.1.tar.gz +Copyright (C) 2006-2009 Thomas Schmitt, provided under GPL version 2. +------------------------------------------------------------------------------ + + +xorriso is a program which maps file objects from POSIX compliant +filesystems into Rock Ridge enhanced ISO 9660 filesystems and allows +session-wise manipulation of such filesystems. It can load the management +information of existing ISO images and it writes the session results to +optical media or to filesystem objects. +Vice versa xorriso is able to restore file objects from ISO 9660 filesystems. + +A special property of xorriso is that it needs neither an external ISO 9660 +formatter program nor an external burn program for CD or DVD but rather +incorporates the libraries of libburnia-project.org . + +Currently it is fully supported on Linux with kernels >= 2.4 and on +FreeBSD versions with ATAPI/CAM support enabled in the kernel, see atapicam(4). +On other X/Open compliant systems there will only be POSIX i/o with disk +file objects, but no direct MMC operation on CD/DVD/BD drives. + +By using this software you agree to the disclaimer at the end of this text: +"... without even the implied warranty ..." + + + Compilation, First Glimpse, Installation + +The most simple way to get xorriso from source code is the xorriso standalone +tarball. + +Prerequisites: +The tarball contains anything that is needed except the following system +components: + libc, libpthread + plus on FreeBSD: libiconv, libcam +Optional at compile time are: + libreadline and the readline-dev headers make dialog mode more convenient. + on Linux: libacl and libacl-devel allow getting and setting ACLs. + zlib and zlib-devel allow zisofs compression. +If they were present at compile time, then the optional libraries have to +be present at runtime, too. + +Obtain xorriso-0.4.1.tar.gz, take it to a directory of your choice and do: + + tar xzf xorriso-0.4.1.tar.gz + cd xorriso-0.4.1 + +Within that directory execute: + + ./configure --prefix=/usr + make + +This will produce a binary named + ./xorriso/xorriso + +which you may strip to reduce it in size + strip ./xorriso/xorriso + +You may copy or move it to a directory where it can be found by the shell, +or you may execute xorriso at the place where it was built, +or you may execute as superuser: + make install + +For general concepts, options and usage examples see + man 1 xorriso + +This man page is part of the tarball as + xorriso/xorriso.1 +You may get a first glimpse by + man ./xorriso/xorriso.1 + +It gets installed with "make install" but may also be placed manually in the +./man1 directory below one of the directories mentioned in environment +variable $MANPATH. + +The installation creates several alias links pointing to the xorriso binary: + xorrisofs starts xorriso with -as mkisofs emulation already enabled + xorrecord starts xorriso with -as cdrecord emulation already enabled + osirrox starts with -osirrox image-to-disk copying already enabled + +If you want to avoid dependecy on libreadline although the libreadline +development package is installed, then rather build xorriso by: + ./configure --prefix=/usr --disable-libreadline + make clean ; make +Never omit the "make clean" command after switching libreadline enabling. +Other deliberate dependency reduction options of ./configure are: + --disable-libacl avoid use of ACL functions like acl_to_text() + --disable-xattr avoid use of xattr functions like listxattr() + --disable-zlib avoid use of zlib functions like compress2() + +xorriso allows to use external processes as file content filters. This is +a potential security risk which may be avoided by ./configure option + --disable-external-filters + +By default the filter feature is disabled if effective user id and real +user id differ. This ban can be lifted by + --enable-external-filters-setuid + +If you want xorriso to report a "Build timestamp" with its option -version: + make buildstamped + + + Drives and Disk File Objects + +The user of xorriso needs rw-permission for the CD burner device. +A list of rw-accessible drives can be obtained by + + xorriso -devices + +CD devices which offer no rw-permission are invisible to normal users. +The superuser should be able to see any usable drive and then set the +permissions as needed. + +The output of xorriso -devices might look like + +0 -dev '/dev/sr0' rwrw-- : 'TSSTcorp' 'CDDVDW SH-S203B' +1 -dev '/dev/hda' rwrw-- : 'HL-DT-ST' 'DVD-ROM GDR8162B' + +Full and insecure enabling of both for everybody would look like + chmod a+rw /dev/sr0 /dev/hda +This is equivalent to the traditional setup chmod a+x,u+s cdrecord. + +I strongly discourage to run xorriso with setuid root or via sudo ! +It is not checked for the necessary degree of hacker safety. + +Consider to put all authorized users into group "floppy", to chgrp the +device file to that group and to disallow w-access to others. + + +A possible source of problems are hald or other automounters. +If you can spot a process "hald-addon-storage" with the address of +your desired drive, then consider to kill it. + +If you cannot get rid of the automounter that easily, try whether it helps +to always load the drive tray manually before starting a write run of +xorriso. Wait until the drive light is off. +Better try to unmount an eventually mounted media before a write run. + + +Besides true optical drives, xorriso can also address disk files as input or +output drives. By default paths to files under /dev are accepted only if the +device represents a real optical drive. Other device files may be addressed +by prepending "stdio:" to the path. +Like: + xorriso -dev stdio:/dev/sdb ...more arguments... +This rule may be changed by xorriso option -drive_class. +Prefix "mmc:" causes a path to be accepted only if it is a real optical drive +which is accessible by generic SCSI/MMC commands. + + + Testing + +We are quite sure that libisofs produces accurate representations of the disk +files. This opinion is founded on a lot of test burns and checks by a little +test program which compares files from the mounted image with the orignals +on disk. It uses the normal POSIX filesystem calls, i.e. no libburnia stuff. + +This program is not installed systemwide but stays in the installation +directory of the xorriso tarball as test/compare_file . Usually it is +run as -exec payload of a find command. It demands at least three arguments: +The path of the first file to compare, the prefix1 to be cut off from path +and the prefix2 which gets prepended afterwards to obtain the path of the +second file to compare. +As further argument there can be -no_ctime which suppresses the comparison +of ctime date stamps. +The exit value is 0 if no difference was detected, non-0 else. + +Example: After + xorriso ... -pathspecs on -add /=/original/dir -- -commit_eject all + mount /media/dvd + cd test +compare tree /media/dvd with tree /original/dir : + find /original/dir -exec ./compare_file '{}' /original/dir /media/dvd ';' \ + | less +and vice versa: + find /media/dvd -exec ./compare_file '{}' /media/dvd /original/dir ';' \ + | less + + + File Formats + +Currently there is only one file format peculiar to xorriso : sector maps +which describe the valid and invalid blocks on a media or a disk copy of +a media. xorriso creates and reads these file with its option -check_media. + +The file begins with 32 bytes of cleartext of which the last one is a +newline character. The first 25 say "xorriso sector bitmap v2 ", the +remaining six characters give the size of the info text as decimal number. +This number of bytes follows the first 32 and will not be interpreted +by xorriso. They are rather to inform a human reader about the media type +and its track layout. +After the info text there are two 4 byte signed integers, most significant +byte first. The first one, N, gives the number of bits in the following bitmap +and the second number S gives the number of 2 KiB blocks governed by a single +bit in the map. Then come the bits in form of 8-bit bytes. +Data block M is covered by bit B=M/S in the map, bit number B is stored in +byte B/8 as bit B%8. A valid readable data block has its bit set to 1. + + + libisoburn + +xorriso is based on libisofs which does ISO 9600 filesystem aspects and on +libburn which does the input and output aspects. Parts of this foundation +are accessed via libisoburn, which is closely related to xorriso. + +libisoburn provides two services: +- Encapsulation of coordination between libisofs and libburn. +- Emulation of ISO 9660 multi-session on overwriteable media + or random access files. + +The sourcecode of all three libraries is included in the xorriso standalone +tarball. It is compiled with xorriso and linked statically. +But you may as well get and install releases of libburn and libisofs, in order +to be able to install a release of libisoburn which produces libisoburn.so.1 +and a matching dynamically linked xorriso binary. +This binary is leaner but depends on properly installed libraries of suitable +revision. + +Dynamic library and compile time header requirements for libisoburn-0.4.0 : +- libburn.so.4 , version libburn-0.6.4 or higher +- libisofs.so.6 , version libisofs-0.6.20 or higher +libisoburn and xorriso will not start with libraries which are older than their +headers seen at compile time. So compile in the oldest possible installation +setup unless you have reason to enforce a newer bug fix level. + +Standalone xorriso has less runtime dependencies and can be moved more freely. + + +------------------------------------------------------------------------------ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License version 2 as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +------------------------------------------------------------------------------ +Based on and sub project of: +libburnia-project.org +By Mario Danic , + Vreixo Formoso + Thomas Schmitt +Copyright (C) 2006-2009 Mario Danic, Vreixo Formoso, Thomas Schmitt. + +libburnia-project.org is inspired by and in other components still containing +parts of old +Libburn. By Derek Foreman and + Ben Jansens +Copyright (C) 2002-2006 Derek Foreman and Ben Jansens + diff --git a/libisoburn/branches/ZeroFourTwo/xorriso/changelog.txt b/libisoburn/branches/ZeroFourTwo/xorriso/changelog.txt new file mode 100644 index 00000000..bf6561e0 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/xorriso/changelog.txt @@ -0,0 +1,6027 @@ +------------------------------------------------------------------------------ + libburnia-project.org libisoburn , xorriso +------------------------------------------------------------------------------ + +------------------------------------------------------------------------------ + Changelog +------------------------------------------------------------------------------ + + +1 Sep 2007 [983] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/burn_wrap.c +libisoburn/isofs_wrap.c +Initial content of libisoburn + +1 Sep 2007 [985] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/isofs_wrap.c +Should have used copy+paste when writing Vreixos name + +5 Sep 2007 [990] +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/burn_wrap.c +Implemented use of stdio-pseudo-drives + +5 Sep 2007 [993] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/burn_wrap.c +Changes in plans as discussed up to Sep 5 2007 + +5 Sep 2007 [994] +libisoburn/libisoburn.h +Updated explanations about the usage principles of libisoburn + +6 Sep 2007 [998] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/burn_wrap.c +Updated to state of discussion + +9 Sep 2007 [1025] +libisoburn/burn_wrap.c +New wrapper isoburn_disc_erasable() declares ISO DVD-RAM, DVD+RW erasable + +10 Sep 2007 [1027] +libisoburn/libisoburn.h +New wrapper isoburn_disc_erasable() declares ISO DVD-RAM, DVD+RW erasable + +11 Sep 2007 [1029] +libisoburn/burn_wrap.c +libisoburn/isoburn.h +New inner function isoburn_set_start_byte() + +12 Sep 2007 [1031] +libisoburn/libisoburn.h +libisoburn/burn_wrap.c +Removed isoburn_write_opts_set_start_byte() + +13 Sep 2007 [1043] +libisoburn/burn_wrap.c +Took into respect fabricated_disc_status + +21 Sep 2007 [1092] +Makefile.am +Removed libburn file addresses + +22 Sep 2007 [1093] ++ doc/doxygen.conf.in +Added file demanded by build system + +22 Sep 2007 [1094] +src/burn_wrap.c +Prevented SIGSEGV in isoburn_drive_scan_and_grab() + +22 Sep 2007 [1095] +src/burn_wrap.c +Enabled treatment==2 in isoburn_drive_scan_and_grab() + +22 Sep 2007 [1099] +src/burn_wrap.c +Made use of burn_msgs_submit() for error messages + +23 Sep 2007 [1102] +src/burn_wrap.c +Removed all references to isoburn.treatment from burn_wrap.c + +23 Sep 2007 [1105] +src/burn_wrap.c +Called isoburn_create_data_source() and isoburn_free_data_source() + +28 Sep 2007 [1129] libisofs +libisofs/libiso_msgs.h +Removed apostrophes which my compiler does not like + +29 Sep 2007 [1133] +src/burn_wrap.c +Added optional code for a pseudo CD-RW to test the code for MMC multi-session + +29 Sep 2007 [1134] +src/burn_wrap.c +Released drive in case welcome_media fails + +1 Oct 2007 [1141] +src/burn_wrap.c +Allowed isoburn_disc_get_msc1() for closed media + +2 Oct 2007 [1149] +test/test.c +Function graft_point(),some general polishing, call of iso_volset_free disabled + +8 Oct 2007 [1169] +src/libisoburn.h +src/isoburn.h +src/isoburn.c +src/burn_wrap.c +Introduced fifo reference into isoburn object + +8 Oct 2007 [1170] +test/test.c +Several directories and files in one session, added display of fifo + +12 Oct 2007 [1171] ++ test/xorriso.h ++ test/xorriso.c ++ test/xorriso.txt +The stub of new application xorriso + +12 Oct 2007 [1172] ++ test/compile_xorriso.sh ++ test/make_timestamp.sh ++ test/xorriso_timestamp.h +A build facility to circumvent autotools during development + +12 Oct 2007 [1173] +test/xorriso.c +Introduced version and build timestamps, library headers + +13 Oct 2007 [1174] +test/xorriso.c ++ test/changelog.txt +Made -dialog and -options_from_file work + +2007.10.13.141503 [1175] +test/xorriso.c +Implemented -speed and enlarged -status list + +2007.10.13.152252 [1176] +test/xorriso.c +test/xorriso.txt +Implemented xorriso setter level of -fs, -gid, -uid + +2007.10.14.110003 [1177] +test/xorriso.c +Implemented setter level of -abort_on, fixed bugs about -f,-no_rc,startup files + +2007.10.14.122456 [1178] +test/xorriso.c ++ test/xorriso_private.h ++ test/xorrisoburn.h ++ test/xorrisoburn.c +Began to implement interface to our libraries + +2007.10.15.152705 [1183] +test/xorriso.h +test/xorriso.c +test/xorriso_private.h +test/xorrisoburn.h +test/xorrisoburn.c +Implemented -dev, -add, -commit + +2007.10.15.160303 [1184] +test/xorriso.c +Made -end give up drives + +2007.10.15.203554 [1185] +test/xorriso.c +Some safety precautions against malicious input, enabled -cdx, -cdi for -add + +2007.10.15.203714 [1186] +test/xorrisoburn.c +Corrected image path bug with -add of regular files, and -add /=/some/dir + +2007.10.15.224005 [1187] +test/xorriso.c +test/xorrisoburn.c +Implemented -rollback + +2007.10.16.210911 [1188] +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +Worked on failure severities, message system, program abort decision + +2007.10.17.130041 [1190] [1191 +test/xorriso.h +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +Worked on failure severities, message system, program abort decision + +2007.10.17.130311 [1192] +src/isofs_wrap.c +Told burn_read_data() to stay silent on non-existent drive or read error + +2007.10.17.150142 [1193] +test/xorriso.c +test/xorrisoburn.c +Reinstated the distinction of message sources, respected '#' in dialog + +2007.10.17.165352 [1194] +test/xorriso.c +Prepended a "-" to any input line if missing + +2007.10.17.183024 [1195] +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +Implemented core of option -toc + +2007.10.17.200241 [1196] +test/xorrisoburn.c +Continued work with -toc + +2007.10.17.213852 [1197] +test/compile_xorriso.sh +Forgot to make off_t 64 bit + +2007.10.17.214228 [1198] +src/libisoburn.h +src/burn_wrap.c +test/xorrisoburn.c +Rounding up fabricated nwa to full 32k addresses, API call for exact image size + +2007.10.17.215809 [1199] +test/xorriso.c +Activated -ban_stdio_write + +2007.10.17.224924 [1200] +test/xorrisoburn.c +Fixed obvious bug with -J. (Still wondering wether it works) + +2007.10.17.225039 [1201] +test/xorriso.c +Fixed bug with -speed. + +2007.10.17.225837 [1202] +test/xorriso.c +Fixed bug with -prompt. Fixed bug with # comments. (of rev 1194) + +18 Oct 2007 [1203] +test/changelog.txt +Updated changelog and todo list + +2007.10.18.144841 [1205] +src/isofs_wrap.c +test/xorrisoburn.c +isoburn_read_volset() now hands out an official volset reference + +2007.10.18.171415 [1206] +test/xorriso.c +test/xorriso.txt +test/xorrisoburn.h +test/xorrisoburn.c +Implemented option -devices + +2007.10.18.183200 [1207] +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +Implemented option -tell_media_space + +2007.10.18.185731 [1208] +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.c +Fixed a SIGSEGV with xorriso -version run + +2007.10.18.221756 [1211] +test/xorrisoburn.c +src/libisoburn.h +Took care of disposal of burn_disc ovbject + +18 Oct 2007 [1212] +test/test.c +Silenced compile warning + +2007.10.18.225654 [1213] +src/isofs_wrap.c +test/xorriso.c +test/xorrisoburn.c +Fixed a SIGSEGV with empty drive + +2007.10.19.140031 [1218] +test/xorrisoburn.c +Made reports with -add normal infos (formerly NOTE events) + +2007.10.19.151339 [1219] +test/xorriso.c +test/xorrisoburn.c +test/xorriso.txt +Implemented -print-size + +2007.10.19.164957 [1220] +test/xorriso_private.h +test/xorriso.c +test/xorriso.h +test/xorrisoburn.c +test/xorriso.txt +Implemented verbosity control by option -report_about + +2007.10.19.173547 [1221] +test/xorriso.c +test/xorrisoburn.c +test/xorriso.txt +Implemented option -eject + +2007.10.19.204155 [1222] +test/xorriso_private.h +test/xorriso.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +Implemented option -blank + +2007.10.20.170731 [1223] +src/burn_wrap.c +Directed write mode failure message to libburn queue, repaired wrote_well + +2007.10.20.171046 [1224] +test/xorrisoburn.c +test/xorriso_private.h +test/xorriso.c +Implemented options -format and -blank deformat, -close and closed media + +20 Oct 2007 [1225] +test/xorriso.txt ++ test/xorriso.1 +test/changelog.txt +Splitted think text from emerging man page, formatted man page + +2007.10.20.194918 [1226] +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +Completed -tell_media_space, checked space before burn, failed -end exits >0 + +20 Oct 2007 [1227] +test/xorriso.1 +Polished man page + +2007.10.21.094818 [1228] +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +Implemented -rm and -rm_r + +2007.10.21.105228 [1229] +src/data_source.c +Silenced compiler warning about C++ style comment + +2007.10.21.124315 [1230] +test/xorriso.c +test/xorrisoburn.c +test/xorrisoburn.h +Began to implement -ls and -ls_l, enhanced -cdi, not done yet + +2007.10.21.151124 [1231] +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.c +test/xorrisoburn.h +Hopefully completed -cd alias -cdi + +2007.10.21.185248 [1232] +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +Hopefully completed -cdx + +2007.10.21.213303 [1233] +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.c +test/xorriso.1 +Implemented sorting of -ls by node name, implemented leaf name search patterns + +2007.10.22.211928 [1237] +test/xorrisoburn.c +test/xorriso.1 +Implemented file size and mtime for -ls_l + +2007.10.23.122349 [1238] +src/libisoburn.h +src/isoburn.c +Added fifo_size to struct isoburn_source_opts + +2007.10.23.122753 [1239] +test/xorrisoburn.c +test/xorriso.c +test/xorriso.1 +Made use of isoburn_source_opts.fifo_size + +2007.10.24.100156 [1244] +test/xorriso.c +test/xorrisoburn.c +Normalized paths to target and source before adding or removing from image + +2007.10.24.105424 [1245] +test/xorriso.c +test/xorriso.h +Implemented option -path-list + +2007.10.24.175337 [1247] +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +Made -cd useable with no image loaded + +2007.10.27.224148 [1257] +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +Implemented option -mv + +2007.10.27.230512 [1258] +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +Bug fixes with option -mv + +2007.10.28.125501 [1260] +test/xorriso.c +test/xorrisoburn.c +Prevented some interesting pitfalls with -mv + +2007.10.28.165516 [1261] +test/xorriso.c +test/xorriso.1 +test/xorrisoburn.h +test/xorrisoburn.c +Implemented option -mkdir + +2007.10.28.174550 [1262] +test/xorriso.c +Warning of wildcards in paths + +28 Oct 2007 [1263] +test/xorriso.1 +Updated man page about -path-list + +2007.10.29.213920 [1273] +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +Structured patterns for options -ls and -ls_l + +2007.10.30.214242 [1274] +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +test/compile_xorriso.sh +Multiple structured patterns, changed option -ls from single to multi args + +2007.10.31.103338 [1275] +test/xorriso_private.h +test/xorriso.h +test/xorriso.c +test/xorrisoburn.c +test/xorriso.1 +Implemented new option -temp_mem_limit + +2007.10.31.165413 [1276] +test/xorriso.c +test/xorrisoburn.c +test/xorrisoburn.h +Gave simple -ls an implemention with minimal memory consumption + +31 Oct 2007 [1277] +test/xorriso.1 +Overhauled info paragraphs of man page + +2007.10.31.175916 [1278] +test/xorriso_private.h +Overhauled comments in struct XorrisO + +31 Oct 2007 [1279] +test/changelog.txt +Updating changelog + +2007.11.01.111351 [1280] +test/xorrisoburn.c +Got rid of bad pacifier text at end of CD writing + +2007.11.01.191106 [1281] +test/xorriso.h +test/xorriso.c +test/xorrisoburn.c +test/xorrisoburn.h +test/xorriso.1 +Implemented option -du + +2007.11.02.143549 [1282] +test/xorrisoburn.h +test/xorrisoburn.c +Clearer status messages after reading new volume and after burning + +2007.11.02.143658 [1283] +test/xorriso.c +Made -abort_on and -report_about complain with bad severity names + +2007.11.02.184705 [1284] +test/xorrisoburn.c +test/xorriso.1 +Polished write success message and man page + +2007.11.06.163305 [1285] +test/xorriso_private.h +test/xorriso.h +test/xorriso.c +test/xorrisoburn.c +test/xorriso.1 +Implemented -overwrite control + +2007.11.06.163929 [1286] +src/libisoburn.h +Corrected a typo in a comment + +2007.11.06.164029 [1287] +src/isoburn.c +Closed memory leak by freeing session and track in isoburn_prepare_disc_aux() + +2007.11.07.123744 [1288] +test/xorriso_private.h +test/xorriso.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +Implemented option -reassure + +2007.11.07.150157 [1289] +test/xorriso.h +test/xorriso.c +test/xorrisoburn.c +test/xorriso.1 +Implemented option -rmdir + +2007.11.07.191915 [1290] +test/xorriso.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +Implemented option -chmod (does not get written into image, though) + +2007.11.07.225624 [1291] +test/xorriso.c +test/xorrisoburn.c +test/xorrisoburn.h +Implemented options -chown and -chgrp (not written into image, though) + +2007.11.08.144451 [1292] +test/xorriso.c +test/xorrisoburn.c +test/xorrisoburn.h +test/xorriso.1 +Implemented option -alter_date, corrected write problem with mode and ownership + +2007.11.08.145016 [1293] +test/xorriso_private.h +Forgotten source file for rev 1292 + +8 Nov 2007 [1294] +test/xorriso.1 +Enhanced man page text for options -chmod, -chown, -chgrp + +2007.11.08.160302 [1295] +test/xorriso.c +Fixed bug with -chmod go=r + +2007.11.08.161215 [1296] +test/xorriso.c +test/xorrisoburn.c +Enlarged string size limit of Text_shellsafe() + +2007.11.09.193142 [1297] +test/xorriso_private.h +test/xorriso.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +New option -iso_rr_pattern, influencing several options with multiple args + +2007.11.11.112321 [1298] +test/xorriso.h +test/xorriso.c +test/xorrisoburn.c +Gave problem handling finer granularity within loops + +11 Nov 2007 [1299] +test/xorriso.1 +Clarified man page + +2007.11.11.154453 [1300] +test/xorriso.c +Added missing commit to normal end of program + +11 Nov 2007 [1301] +test/xorriso.1 +Added some examples to man page + +2007.11.14.142904 [1302] +src/libisoburn.h +src/isofs_wrap.c +src/isoburn.c +test/test.c +New API call isoburn_attach_volset(), changes with isoburn_read_volset() + +2007.11.14.143119 [1303] +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +Implemented options -outdev and -indev + +2007.11.14.175446 [1304] +test/xorriso.c +Corrected premature abort bug with misspelled command words + +14 Nov 2007 [1305] +test/xorriso.1 +Polished xorriso man page + +14 Nov 2007 [1306] +test/changelog.txt +Updated xorriso changelog + +2007.11.26.192113 [1311] +test/xorriso.c +test/xorrisoburn.c +Reacted on warnings on a 64 bit system + +2007.12.04.074340 [1314] +test/xorriso.h +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.c +test/xorriso.1 +Implemented -disk_pattern, -lsx, ls_lx, -dux, -du_lx + +2007.12.04.205919 [1315] +test/xorrisoburn.c +test/xorriso_private.h +test/xorriso.c +Removed some redundancy of disk_pattern and iso_rr_pattern matching + +4 Dec 2007 [1316] +test/xorriso.1 +Polished man page + +2007.12.05.090438 [1317] +test/xorriso.h +test/xorriso.c +test/xorriso.1 +Option -f-off as counterpart of option -f + +2007.12.05.143632 [1318] +test/xorriso.c +Made dashes at options optional + +5 Dec 2007 [1319] +test/xorriso.1 +Overhauled description of media types, states and expansion methods + +2007.12.06.150102 [1320] +test/xorriso.h +test/xorriso.c +test/xorriso.1 +Changed -f, -f-off to -follow, -graft-points, -graf-points-off to -pathspecs + +6 Dec 2007 [1321] +test/xorriso.1 +Removed references to option -graft-points + +2007.12.06.192437 [1322] +test/xorriso.c +Corrected warning function about wildcards + +8 Dec 2007 [1326] +test/xorriso.1 +Explained result pager + +2007.12.08.175117 [1327] +test/xorriso.c +test/xorriso_private.h +test/xorrisoburn.c +Removed more code redundancies and fd leak with Xorriso_obtain_pattern_files_x() + +2007.12.15.162039 [1328] +test/compile_xorriso.sh +Added -O0 to -g to get better gdb behavior on my new system + +2007.12.15.183022 [1329] +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +Implemented option -follow + +2007.12.16.103456 [1330] +test/xorriso.c +test/xorriso.1 +Added link hop limit to option -follow + +2007.12.16.122626 [1331] +test/xorrisoburn.c +Added copying of attributes from symbolic link into image + +2007.12.16.144615 [1332] +test/xorrisoburn.c +Removed waste of time in Xorriso_show_du_subs() + +2007.12.18.175924 [1333] +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +Changed options -ls* to -lsd*, introduced new family of -ls* without d + +2007.12.20.111338 [1334] +test/xorriso.h +test/xorriso.c +test/xorrisoburn.c +test/xorriso.1 +Changed -du_s* into -dus* + +2007.12.21.131538 [1335] +test/xorriso.h +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +Implemented option -find alias -findi + +2007.12.21.132017 [1336] +test/xorriso.c +test/xorriso.1 +Corrected documentation about -find + +2007.12.22.143803 [1337] +test/xorriso.h +test/xorriso.c +test/xorrisoburn.c +test/xorriso.1 +Implemented option -findx + +2007.12.24.161107 [1339] +test/xorriso.c +Repaired options -dus and -dusx + +24 Dec 2007 [1340] +test/changelog.txt +Updated changelog + +2007.12.25.160100 [1341] +test/xorriso.h +test/xorriso.c +test/xorriso.1 +Implemented option -cpr + +2007.12.26.160040 [1342] +test/xorriso.h +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +Changed option -J to -joliet "on"|"off", implemented option -volid + +2007.12.28.132741 [1343] +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.c +Made leaner the local memory of recursive functions (because of ulimit -s) + +2007.12.30.190138 [1344] +test/xorriso.h +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.c +test/xorriso.1 +Implemented -find option -exec echo, chown, chgrp, chmod, alter_date, lsdl + +2007.12.30.203336 [1345] +test/xorriso.c +Corrected superuser behavior of Sfile_lookup_permissions() + +2007.12.31.095229 [1346] +test/xorriso.c +test/xorrisoburn.c +Repaired some bugs in -find and -findx + +2007.12.31.135237 [1347] +test/xorriso.h +test/xorriso.c +test/xorriso.1 +Implemented options -chown_r, -chgrp_r, -chmod_r, -alter_date_r + +2007.12.31.135330 [1348] +test/xorrisoburn.c +Repaired a bug in -find + +2008.01.01.123118 [1349] +test/xorriso.h +test/xorriso_private.h +test/xorriso.c +test/xorrisoburn.h +test/xorrisoburn.c +test/xorriso.1 +Implemented -find actions chown_r, chgrp_r, chmod_r, alter_date_r, find + +2008.01.02.175011 [1350] +test/xorriso.c +test/xorriso.1 +Implemented -find test -type + +2008.01.09.175418 [1351] +test/xorrisoburn.c +Corrections made during porting to nglibisofs + +2008.01.10.114451 [1352] ++ test/ng_xorrisoburn.h ++ test/ng_xorrisoburn.c +test/compile_xorriso.sh +Begin of porting to next generation libisofs + +2008.01.10.151924 [1353] +Makefile.am ++ ng_src ++ ng_src/libisoburn.h ++ ng_src/isoburn.h ++ ng_src/isoburn.c ++ ng_src/isofs_wrap.c ++ ng_src/data_source.c ++ ng_src/burn_wrap.c +Begin of porting to next generation libisofs + +2008.01.10.152353 [1354] +test/ng_xorrisoburn.c +test/compile_xorriso.sh +Made compile_xorriso.sh -nglibisofs work on ./ng_src + +2008.01.10.154948 [1355] +test/ng_xorrisoburn.c +test/compile_xorriso.sh +Made compile_xorriso.sh -oglibisofs work on ./og_src + +2008.01.11.133319 [1356] +test/compile_xorriso.sh +Adapted to existence of nglibisofs eltorito.o + +2008.01.11.133631 [1357] +test/xorriso.c +test/ng_xorrisoburn.c +test/xorrisoburn.c +Removed old and new bugs + +2008.01.11.174733 [1358] +test/xorriso.c +test/ng_xorrisoburn.c +test/xorrisoburn.c +Tracing the different behavior of isoburn_read_image() + +2008.01.11.175423 [1359] +test/ng_xorrisoburn.c +ng_src/isoburn.c +ng_src/libisoburn.h +Changed isoburn_source_opts.ouput_charset to output_charset + +2008.01.11.212545 [1361] +ng_src/isofs_wrap.c +Made initialization of iso_read_opts safer + +13 Jan 2008 [1364] ++ og_src +- src src/burn_wrap.c +- src/isoburn.c +- src/isoburn.h +- src/data_source.c +- src/isofs_wrap.c +- src/libisoburn.h ++ og_src/burn_wrap.c ++ og_src/isoburn.c ++ og_src/isoburn.h ++ og_src/data_source.c ++ og_src/isofs_wrap.c ++ og_src/libisoburn.h +Moved src to og_src and installed symbolic link instead + +13 Jan 2008 [1365] +ng_src/isofs_wrap.c +Changes about blanking loaded image + +2008.01.13.224929 [1366] +test/ng_xorrisoburn.c +Allowed all filetypes as input, silenced debug during image read + +14 Jan 2008 [1367] +test/compile_xorriso.sh +Added forgotten source module + +14 Jan 2006 [1368] +ng_src/libisoburn.h +ng_src/isoburn.c +New members in isoburn_source_opts + +2008.01.14.163814 [1369] +test/ng_xorrisoburn.c +Closed memory leak, adapted to new members in isoburn_source_opts + +2008.01.14.164628 [1370] +test/ng_xorrisoburn.c +Repaired memory hog and a freshly introduced bug + +2008.01.14.190220 [1371] +test/xorriso.c +test/ng_xorrisoburn.c +test/xorriso.1 +Removed some bugs and made adaptions to nglibisofs + +2008.01.14.224645 [1372] +test/xorriso_private.h +test/xorriso.c +test/ng_xorrisoburn.h +test/ng_xorrisoburn.c +test/xorriso.1 +Made improvements around volume id + +2008.01.15.174409 [1373] +test/xorriso.h +test/xorriso_private.h +test/xorriso.c +test/ng_xorrisoburn.h +test/ng_xorrisoburn.c +test/xorrisoburn.h +test/xorrisoburn.c +Made improvements about pattern matching .., closed small memory leaks + +2008.01.15.204057 [1374] +test/xorriso.c +test/ng_xorrisoburn.h +test/ng_xorrisoburn.c +test/xorrisoburn.h +test/xorrisoburn.c +Closed a small memory leak + +2008.01.15.211511 [1375] +test/ng_xorrisoburn.c +Added a forgotten iso_dir_iter_free() + +2008.01.16.132909 [1376] +ng_src/isofs_wrap.c +Repaired bug about MMC multi-session image loading + +2008.01.16.141631 [1378] +ng_src/isoburn.c +Changed default name of initial image to ISOIMAGE + +16 Jan 2008 [1378] +libisoburn.pc.in +Set correct name of library + +2008.01.16.200942 [1379] +test/xorriso.c +test/ng_xorrisoburn.c +Adaption to Xorriso_standalonE, some consequences from compiler warnings + +16 Jan 2008 [1380] ++ test/make_xorriso_standalone.sh ++ test/xorriso_makefile_am.txt ++ test/configure_ac.txt ++ test/xorriso_pc_in.txt +A sketch of a xorriso source standalone release generator + +16 Jan 2008 [1381] +test/configure_ac.txt +test/xorriso_makefile_am.txt +Added a test for readline.h and eventually enabled use of libreadline + +2008.01.17.145135 [1382] +test/ng_xorrisoburn.c +Silenced -pedantic compiler warnings about type punning + +17 Jan 2008 [1385] +test/make_xorriso_standalone.sh +Silenced most compiler warnings of libisofs in xorriso-standalone + +17 Jan 2008 [1386] ++ test/README +Began a README file for xorriso + +18 Jan 2008 [1387] +test/make_xorriso_standalone.sh +test/README ++ test/xorriso_eng.html +Worked on documentation + +2008.01.18.101933 [1388] +test/xorriso.c +Changed -report_about default to "UPDATE" + +18 Jan 2008 [1389] +test/xorriso.1 +test/make_xorriso_standalone.sh ++ test/convert_man_to_html.sh +Made a generator for HTML man page + +2008.01.19.090417 [1390] +ng_src/libisoburn.h +ng_src/isoburn.c +ng_src/isofs_wrap.c +test/ng_xorrisoburn.c +test/compile_xorriso.sh +test/xorriso_makefile_am.txt +Adaptions to revision 241 of nglibisofs + +2008.01.19.090546 [1391] +test/xorriso.c +Added startup message. Removed helptext sentence about unimplemented options + +19 Jan 2008 [1392] +test/xorriso_eng.html +test/make_xorriso_standalone.sh +Producing a bootstrapped xorriso standalone tarball + +19 Jan 2008 [1393] +test/README +test/xorriso.1 +test/xorriso_eng.html +Some polishing of xorriso documentation + +2008.01.19.162244 [1394] +test/xorriso.c +test/ng_xorrisoburn.c +Small corrections with version number and write counter report + +19 Jan 2008 [1395] +test/changelog.txt +Updated SVN copy of changelog + +2008.01.20.102946 [1397] +ng_src/burn_wrap.c +ng_src/data_source.c +ng_src/isoburn.c +ng_src/isofs_wrap.c +Made forgotten adaption to Xorriso_standalonE + +2008.01.20.131050 [1398] +test/xorriso.h +test/xorriso_private.h +test/xorriso.c +test/ng_xorrisoburn.c +test/xorriso.1 +Made -outdev stdio:/dev/fd/1 safe for single session runs + +2008.01.20.200254 [1399] +test/xorriso.h +test/xorriso_private.h +test/xorriso.c +test/xorriso.1 +New option -add_plainly + +2008.01.21.221939 [1400] +test/xorriso.c +test/xorriso.1 +Rejected unsuitable addresses "stdio:" , "stdio:/", "stdio:-", "stdio:." + +22 Jan 2008 [1401] ++ test/compare_file.c +Program which compares two files in different trees. Attributes and content. + +22 Jan 2008 [1402] +test/configure_ac.txt +Copied test for tm.tm_gmtim from libisofs configure.ac + +22 Jan 2008 [1403] +test/compare_file.c +Prepended type indication letter to report lines + +2008.01.22.224321 [1404] +test/ng_xorrisoburn.c +Better attributes with directories + +2008.01.23.195855 [] +ng_src/burn_wrap.c +test/ng_xorrisoburn.c +Adapted to libisofs revision 261 + +24 Jan 2008 [1410] +test/make_xorriso_standalone.sh +Removed remover of C++ comment lines + +2008.01.24.202206 [1411] +ng_src/isoburn.c +ng_src/burn_wrap.c +ng_src/isoburn.h +Gave up use of libburn fifo. Attached -fs and pacifier to libisofs fifo. + +2008.01.25.150902 [1413] +test/xorriso.h +test/xorriso.c +test/xorriso.1 +New option -rollback_end + +25 Jan 2008 [1414] +test/compare_file.c +Fixed bug about file content comparison. + +25 Jan 2008 [1415] +test/compare_file.c +Better handling of various content difference situations + +2008.01.25.175353 [1416] +test/xorriso.h +test/xorriso.c +test/xorriso.1 +test/ng_xorrisoburn.c +New option -commit_eject + +2008.01.26.002011 [1417] +- og_src/libisoburn.h +- og_src/isoburn.h +- og_src/isoburn.c +- og_src/isofs_wrap.c +- og_src/burn_wrap.c +- og_src/data_source.c +- og_src/ ++ libisoburn/ +- ng_src/libisoburn.h +- ng_src/isoburn.h +- ng_src/isoburn.c +- ng_src/isofs_wrap.c +- ng_src/burn_wrap.c +- ng_src/data_source.c ++ libisoburn/libisoburn.h ++ libisoburn/isoburn.h +*+ libisoburn/isoburn.c +*+ libisoburn/isofs_wrap.c +*+ libisoburn/burn_wrap.c +*+ libisoburn/data_source.c ++ xorriso/ +- test/README +- test/changelog.txt +- test/compare_file.c +- test/compile_xorriso.sh +- test/configure_ac.txt +- test/convert_man_to_html.sh +- test/make_timestamp.sh +- test/make_xorriso_standalone.sh +- test/ng_xorrisoburn.c +- test/ng_xorrisoburn.h +- test/xorriso.1 +- test/xorriso.c +- test/xorriso.h +- test/xorriso_eng.html +- test/xorriso_makefile_am.txt +- test/xorriso_pc_in.txt +- test/xorriso_private.h +- test/xorriso_timestamp.h +- test/xorrisoburn.c +- test/xorrisoburn.h ++ xorriso/README ++ xorriso/changelog.txt ++ xorriso/compare_file.c +*+ xorriso/compile_xorriso.sh ++ xorriso/configure_ac.txt +*+ xorriso/convert_man_to_html.sh +*+ xorriso/make_timestamp.sh +*+ xorriso/make_xorriso_standalone.sh ++ xorriso/xorriso.1 +*+ xorriso/xorriso.c ++ xorriso/xorriso.h ++ xorriso/xorriso_eng.html ++ xorriso/xorriso_makefile_am.txt ++ xorriso/xorriso_pc_in.txt ++ xorriso/xorriso_private.h ++ xorriso/xorriso_timestamp.h +*+ xorriso/xorrisoburn.c ++ xorriso/xorrisoburn.h +Makefile.am +Gave up adapter to old libisofs. Renaming libisoburn and xorriso dirs. + +2008.01.26.113604 [1418] +libisoburn/libisoburn.h +libisoburn/burn_wrap.c +xorriso/xorrisoburn.c +INCOMPATIBLE API CHANGE: isoburn_initialize(char msg[1024], int flag) + +2008.01.26.120534 [1419] +libisoburn/libisoburn.h +configure.ac +version.h.in +libisoburn/isoburn.c +libisoburn/burn_wrap.c +Introduced versioning (still pre-release) and new API function isoburn_version() + +2008.01.26.140005 [1423] +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +xorriso/xorriso_eng.html +Adapted standalone tarball to version functions + +2008.01.26.142130 [1424] +xorriso/xorriso.c +Set program revision to 0.0.1 (previous 0.1.0 was too early) + +2008.01.26.171156 [1425] +libisoburn/libisoburn.h +libisoburn/isoburn.c +libisoburn/burn_wrap.c +xorriso/xorrisoburn.c +INCOMPATIBLE API CHANGE: isoburn_prepare_new_image() now gets output drive + +2008.01.27.174454 [1434] +xorriso/xorriso.c +xorriso/xorriso.1 +Changed meaning of -add relative/path + +2008.01.28.105404 [1435] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +Made use of iso_set_abort_severity() with option -abort_on + +2008.01.28.140149 [1436] +libisoburn/libisoburn.h +Updated API introduction and marked API instabilities for mending (soon) + +2008.01.28.171915 [1437] +libisoburn/isoburn.c +libisoburn/isofs_wrap.c +xorriso/xorrisoburn.c +xorriso/compile_xorriso.sh +xorriso/make_xorriso_standalone.sh +Adapted to libisofs revison 294 + +2008.01.28.235717 [1438] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +xorriso/xorrisoburn.c +Changed struct isoburn_source_opts to opaque handle struct isoburn_imgen_opts + +2008.01.29.125956 [1439] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +xorriso/xorrisoburn.c +Changed struct isoburn_read_opts to opaque handle + +2008.01.29.184356 [1440] +configure.ac +version.h.in +libisoburn/libisoburn.h +libisoburn/isoburn.c +libisoburn/burn_wrap.c +xorriso/xorrisoburn.c +xorriso/configure_ac.txt +New API call isoburn_is_compatible() + +29 Jan 2008 [1441] +libisoburn/libisoburn.h +Some API documentation enhancements + +2008.01.29.211543 [1443] +libisoburn/burn_wrap.c +Made use of newest libburn version features + +2008.01.31.152131 [1449] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/isofs_wrap.c +xorriso/make_xorriso_standalone.sh +Adapted to libisofs revision 313 + +2008.01.31.214647 [1450] +xorriso/xorrisoburn.h +libisoburn/libisoburn.h +libisoburn/burn_wrap.c +xorriso/make_xorriso_standalone.sh +Compile time and runtime checks for library compatibility + +2008.02.01.195817 [1455] +configure.ac +Makefile.am +- libisoburn.pc.in ++ libisoburn-1.pc.in +xorriso/README +Enabled build of dynamically linked xorriso, joined -1.pc club + +2008.02.01.200153 [1456] +xorriso/xorriso_makefile_am.txt +Corrected some false paths in xorriso-standalone Makefile.am + +2008.02.02.131049 [1457] +configure.ac +Added version checks for libburn and libisofs (by Vreixo) + +2008.02.02.131903 [1458] +xorriso/xorriso.h +xorriso/xorriso.c +Added argument to option -commit_eject + +2 Feb 2008 [1459] +xorriso/xorriso_eng.html +Updated to current state of development + +2008.02.02.181200 [1460] +xorriso/xorrisoburn.c +Compile time check of libisoburn. Enforced minimum track size of 300 sectors. + +2008.02.03.131525 [1466] +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/burn_wrap.c +libisoburn/isofs_wrap.c +xorriso/xorrisoburn.c +Made use of ISO_ERR_SEV() and ISO_ERR_PRIO() + +2008.02.03.155704 [1467] +libisoburn/isofs_wrap.c +Adapted to libisofs revisio 328 + +2008.02.03.164038 [1468] +libisoburn/libisoburn.h +libisoburn/isoburn.c +xorriso/xorrisoburn.c +New API call isoburn_cancel_prepared_write() + +2008.02.03.164916 [1469] +xorriso/xorrisoburn.c +Reacted on compiler warning + +2008.02.03.181259 [1470] +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Made -abort_on and -report_about preemptive if given as dashed start arguments + +2008.02.04.093106 [1471] +libisoburn/burn_wrap.c +xorriso/xorrisoburn.c +Adapted to libisofs revision 332 + +2008.02.04.154405 [1472] +libisoburn/libisoburn.h +libisoburn/isoburn.c +xorriso/xorrisoburn.c +New API call isoburn_sync_after_write() + +2008.02.04.184038 [1475] +libisoburn/libisoburn.h +libisoburn/isoburn.c +libisoburn/burn_wrap.c +libisoburn/isofs_wrap.c +xorriso/xorrisoburn.c +Inserted problem messages where libisoburn API produces own failures + +2008.02.04.214133 [1476] +libisoburn/libisoburn.h +libisoburn/isoburn.c +xorriso/xorrisoburn.c +Added parameter to new API calls isoburn_cancel_prepared_write, isoburn_sync_after_write + +2008.02.05.162621 [1477] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -padding + +2008.02.05.175733 [1478] +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorriso.1 +Implemented reassure for -rollback, -rollback_end, -end, -commit, -commit_eject + +2008.02.05.191456 [1479] +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorriso.1 +Implemented reassure for -blank, -format, -dev, -indev, -devices + +2008.02.06.131028 [1480] +xorriso/xorriso.c +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +libisoburn/libisoburn.h +libisoburn/burn_wrap.c +Now loading libraries before -version, pacifier for -add + +2008.02.06.153709 [1481] +libisoburn/burn_wrap.c +xorriso/xorriso.c +xorriso/xorriso.1 +xorriso/xorrisoburn.c +Rectified SORRY,FAILURE,FATAL classification + +2008.02.06.183423 [1484] +libisoburn/burn_wrap.c +xorriso/xorrisoburn.c +Adapted to libisofs revision 337 + +2008.02.06.183557 [1485] +xorriso/xorriso.c +Removed some unused code + +2009.02.06.184008 [1486] +libisoburn/burn_wrap.c +xorriso/xorrisoburn.c +Added a missing 0 digit + +2008.02.06.214426 [1487] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/isofs_wrap.c +xorriso/xorrisoburn.c +Pacifier for isoburn_read_image() + +2008.02.07.074248 [1489] +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso_private.h +Added final message to image read pacifier + +2008.02.07.154947 [1490] +libisoburn/data_source.c +Implemented a primitive single tile cache for image reading + +2008.02.07.211424 [1491] +libisoburn/data_source.c +Stuffed memory leak with read cache. Economized on error retries. + +8 Feb 2008 [1494] +- xorriso/compare_file. ++ test/compare_file.c +- ng_src +Cleaning up remainings of move to ng_src + +8 Feb 2008 [1495] +test/compare_file.c +Fixed an endless cycle with early EOF + +2008.02.08.102122 [1496] +xorriso/xorriso_makefile_am.txt +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +xorriso/README +Added test/compare_file.c to xorriso-standalone tarball + +2008.02.08.173928 [1497] +2008.02.08.174126 [1498] +libisoburn/data_source.c +Renamed macro which controls read caching + +2008.02.08.175152 [1499] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Protecting volume ids from getting overwritten by predecessor + +2008.02.08.195627 [1500] +xorriso/xorriso.c +Warning of -volid which are not ECMA 119 compliant + +2008.02.08.215113 [1501] +xorriso/xorriso.h +xorriso/xorriso.c +Silenced misleading toc messages with -commit_eject "in" + +2008.02.09.092805 [1502] +libisoburn/libisoburn.h +libisoburn/isoburn.c +Adapted to libisofs revision 346 + +2008.02.09.100750 [1503] +libisoburn/libisoburn.h +libisoburn/burn_wrap.c +xorriso/xorriso.c +xorriso/xorrisoburn.c +New API function isoburn_disc_available_space() fixes bug with DVD+RW capacity + +10 Feb 2008 [1504] +xorriso/README +Some adjustments in description of compare_file and libisoburn + +2008.02.10.122020 [1505] +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Fixed bugs about -mv /im/age . -cdx / -cpr di/sk im/age -- -cpr di/sk . -- + +2008.02.10.130852 [1506] +Makefile.am +Added build of test/compare_file as noinst binary + +2008.02.10.135822 [1507] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +Better handling of not-yet-existing -cd + +2008.02.11.094742 [1509] +xorriso/xorriso_private.h +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Discarding, keeping or patching boot images from existing ISO images + +2008.02.11.112917 [1510] +xorriso/xorrisoburn.c +Corrected message about isolinux patch option + +2008.02.11.113235 [1511] +xorriso/xorriso.h +xorriso/xorriso.c +Final UPDATE message after grafting in files from disk + +2008.02.11.135418 [1512] +xorriso/xorriso_private.h +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorriso.1 +New option -return_with + +2008.02.11.150123 [1513] +xorriso/xorrisoburn.c +isoburn_igopt_allow_full_ascii for -bootimage any keep + +2008.02.11.150700 [1514] +xorriso/xorriso.c +xorriso/xorriso.1 +Clarifications about -volid rules + +11 Feb 2008 [1515] +xorriso/README +Adjustments about libisoburn and xorriso dynamic dependencies, compare_file + +2008.02.11.162406 [1516] +xorriso/xorrisoburn.c +xorriso/xorriso.c +Changed failure to find a file for removal from FAILURE to SORRY + +2008.02.11.174517 [1517] +xorriso/xorriso.c +Corrected a bug about -status -return_with + +2008.02.11.194807 [1519] +libisoburn/burn_wrap.c +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New severity MISHAP + +2008.02.11.213918 [1520] +xorriso/xorrisoburn.c +Mapping in burn runs -abort_on MISHAP to SORRY + +2008.02.12.215327 [1521] +libisoburn/burn_wrap.c +xorriso/xorriso.c +xorriso/xorrisoburn.c +Improved MISHAP - SORRY mapping and tunneling + +2008.02.14.084342 [1525] ++ README ++ COPYING ++ COPYRIGHT ++ INSTALL +libisoburn/libisoburn.h +Completing documentation + +2008.02.14.101916 [1526] +Makefile.am +Adjusted EXTRA_DIST list of files + +2008.02.14.120557 [1527] +xorriso/xorrisoburn.c +Made a final abort check before burning begins + +2008.02.14.175623 [1528] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +Imprinting version of xorriso and libraries into ISO preparer_id + +2008.02.14.182351 [1529] +xorriso/xorrisoburn.c +Made preparer_id more safe against oversize + +14 Feb 2008 [1530] +xorriso/xorriso.1 +Polished man page + +14 Feb 2008 [1531] +xorriso/changelog.txt +Updated changelog + +2008.02.15.100001 [branch 1533] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/compile_xorriso.sh +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Made version number leap to 0.1.0 + +15 Feb 2008 [branch 1534] +xorriso/changelog.txt +Documented initial release and timestamp + +15 Feb 2008 [1536] +configure.ac +Increased libisofs requirement to 0.6.2 + +----------------------------- release - xorriso-0.1.0.pl00 - 2008.02.15.100001 +* Operates on an existing ISO image or creates a new one. +* Copies files from filesystem into the ISO image. +* Renames or deletes file objects in the ISO image. +* Changes file properties in the ISO image. +* Can write result as completely new image to optical media + or filesystem objects. +* Can write result as add-on session to appendable + multi-session media, to overwriteable media, + to regular files, and to block devices. +* Scans for optical drives, blanks re-useable optical media. +* Reads its instructions from command line arguments, dialog, and batch files. +* Provides navigation commands for interactive ISO image manipulation. +* Adjustable thresholds for abort, exit value, and problem reporting. + + +2008.02.15.211836 [1537] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/compile_xorriso.sh +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to 0.1.1 + +15 Feb 2008 [1538] +COPYRIGHT +Corrected according to content of libisofs/COPYRIGHT + +2008.02.15.212030 [1539] +xorriso/xorriso.c +Changed pacifier text for 0 nodes read from blank image + +------------------------------------ cycle - xorriso-0.1.1 - 2008.02.15.212030 + +15 Feb 2008 [1540] +xorriso/changelog.txt +Updated changelog + +16 Feb 2008 [1543] +xorriso/xorriso.1 +Adjusted CREDITS text + +2008.02.16.202533 [1544] +xorriso/xorriso_private.h +xorriso/xorrisoburn.c +Transfering properties from disk to implicit directories in image path + +2008.02.16.211549 [1545] +xorriso/xorriso_eng.html +xorriso/changelog.txt +Mentioned better directory attribute copying + +------------------------------------ cycle - xorriso-0.1.1 - 2008.02.16.211549 +* Improved attribute transfer from disk for implicit target directories + +2008.02.18.210343 [1546] +xorriso/xorriso.c +Bug fix: -report_about higher than NOTE did not report at all + +19 Feb 2008 [1547] +test/compare_file.c +Improved report format + +2008.02.19.184432 [1548] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -as cdrecord emulates a narrow set of cdrecord gestures + +2008.02.19.212322 [1549] +xorriso/xorriso.c +xorriso/xorriso_private.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Improved -as cdrecord + +20 Feb 2008 [1550] +test/compare_file.c +Revoked inflation of file type characters to words + +2008.02.20.234726 [1551] +libisoburn/libisoburn.h +libisoburn/burn_wrap.c +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -as mkisofs emulates a narrow set of mkisofs gestures + +------------------------------------ cycle - xorriso-0.1.1 - 2008.02.21.090014 +* Bug fix: -report_about HINT or higher did not report at all +* Bug fix: speed=number without unit or media type letter was always CD speed +* Bug fix: it was possible to write to appendable media which was not -indev +* New option -as "cdrecord" emulates a narrow set of cdrecord gestures +* New option -as "mkisofs" emulates a narrow set of mkisofs gestures + +2008.02.21.090014 [1552] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +New option -publisher + +2008.02.21.185203 [1553] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/burn_wrap.c +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Implemented a more reasonable solution for drive truncation with regular files + +2008.02.21.204613 [1558] +libisoburn/burn_wrap.c +xorriso/xorrisoburn.c +Introduced new severity ERRFILE + +2008.02.21.211101 [1559] +xorriso/xorriso.c +Updated -help text + +2008.02.22.114917 [1561] +libisoburn/burn_wrap.c +xorriso/xorriso.c +xorriso/xorrisoburn.c +Producing ERRFILE messages where appropriate + +2008.02.23.101619 [1568] +libisoburn/libisoburn.h +Changed libisofs requirements to 0.6.3 + +2008.02.23.101619 [1569] +libisoburn/burn_wrap.c +xorriso/xorrisoburn.c +Testwise implementation of libisofs.0.6.3 features + +2008.02.23.101619 [1570] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorriso.1 +New option -errfile_log + +2008.02.23.102903 [1571] +xorriso/configure_ac.txt +Made libisofs version leap in xorriso-standalone + +2008.02.23.113902 [1572] +xorriso/xorriso.h +xorriso/xorriso.c +Directed -as mkisofs -print-size to real stdout + +2008.02.23.125537 [1573] +xorriso/xorrisoburn.c +Various bugs and deviations around -as mkisofs -print-size + +2008.02.23.131825 [1574] +xorriso/xorrisoburn.c +Wrong description text + +2008.02.25.090001 [ZeroOneZero-pl01 1576 1577] +libisoburn/burn_wrap.c +xorriso/xorriso_timestamp.h +Safety cap for ABI usage bug towards libisofs >= 0.6.2 + +2008.02.25.174229 [1579] +libisoburn/burn_wrap.c +xorriso/xorrisoburn.c +Adapted to libisofs 362 from Vreixo bzr + +2008.02.25.204402 [1580] +xorriso/xorriso.c +Adaptions of -as mkisofs and -as cdrecord to enable full use by scdbackup + +25 Feb 2008 [1581] +xorriso/changelog.txt +Updated changelog + +------------------------------------ cycle - xorriso-0.1.1 - 2008.02.25.204402 +* New option -publisher +* New option -errfile_log + + +26 Feb 2008 [1582] +test/compare_file.c +Avoided to read content of non-regular files + +2008.02.26.213437 [1583] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -compare + +2008.02.27.185744 [1584] +xorriso/xorriso.c +Installed pacifier for data reading + +2008.02.28.132656 [1587] +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Added new action "compare" to -find + +28 Feb 2008 [1588] +xorriso/xorriso_eng.html +Mentioned capability to write DVD+R/DL. + +2008.02.28.212210 [1589] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +New option -compare_r + +28 Feb 2008 [1590] +xorriso/xorriso.1 +New option -compare_r, new -findx -exec in_iso, -exec no_in_iso + +28 Feb 2008 [1591] +test/compare_file.c +Micro bug fix ported from xorriso + +2008.02.28.215343 [1592] +xorriso/xorriso.c +Better handling of disk to iso address mapping during compare runs + +2008.02.29.200510 [1593] +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -update (not yet completed) + +2008.03.01.151219 [1594] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option update_r, -find actions "update" and "add_missing" (not yet completed) + +2008.03.02.172751 [1596] +xorriso/xorrisoburn.c +Made -update_r and -find -exec update safe against IsoDirIter pitfalls + +2008.03.02.201455 [1597] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +Made IsoDirIter workaround obey -temp_mem_limit + +4 Mar 2008 [libisofs_thomas 1599 1600] +Switch to Vreixo development branch 378 + +2008.03.04.174107 [1601] +xorriso/make_xorriso_standalone.sh +xorriso/xorriso_makefile_am.txt +Adapted to libisofs Vreixo 378 + +2008.03.04.180738 [1602] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Improvements about -update_r and -compare_r + +2008.03.05.125118 [1603] +xorriso/xorrisoburn.c +Bug fix: -follow param did not work for symbolic links + +------------------------------------ cycle - xorriso-0.1.1 - 2008.03.05.125118 +* Support for DVD+R/DL media +* Bug fix: -follow param did not work for adding non-directory symbolic links + + +2008.03.05.173329 [1604] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Made -compare* and -update* obey -follow links (-follow mount still not correct) + +5 Mar 2008 [1605] +xorriso/xorriso.1 +Some man page clarification + +2008.03.06.114233 [1606] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New -find actions "rm" and "rm_r", silenced comparison results with -update* + +2008.03.06.174724 [1608] +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Fixed bug about non existing disk_path with -update_r + +7 Mar 2008 [1609] +xorriso/xorriso_eng.html +Re-arranged development download part + +2008.03.07.075325 [1610] +xorriso/xorriso.c +xorriso/xorrisoburn.c +New -findx -type "m" for active mount points + +2008.03.07.182411 [1611] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New -findx -exec action "empty_iso_dir", workaround for ticket 132 + +2008.03.07.220442 [1612] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Made -update_r and -compare_r obey disabling of -follow "mount" + +8 Mar 2008 [libisofs_thomas 1613] +Switch to Vreixo development branch 383 + +2008.03.08.104231 [1614] +xorriso/xorrisoburn.c +Adapted to iso_tree_add_new_node() + +8 Mar 2008 [1615] +xorriso/xorriso.1 +Example use case for -update_r "Incremental backup of a few directory trees" + +------------------------------------ cycle - xorriso-0.1.1 - 2008.03.08.122747 +* Bug fix: It was not possible to -add /THIS=a /b=THIS +* New options -compare, -compare_r and according -find -exec action +* New options -update, -update_r and according -find -exec action +* New -find actions "rm", "rm_r", new -findx -type "m" -exec "empty_iso_dir" + + +2008.03.09.142200 [1616] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -cut_out + +9 Mar 2008 [libisofs_thomas 1617] +Switch to Vreixo development branch 386 + +2008.03.09.211041 [1618] +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Some polishing about -cut_out + +2008.03.11.113444 [1619] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Sketched split file scheme with partno,totalparts,offset,count,totalsize + +11 Mar 2008 [1620] +xorriso/xorriso.1 +Updated description of -cut_out + +------------------------------------ cycle - xorriso-0.1.1 - 2008.03.11.113444 +* New option -cut_out + + +2008.03.12.100001 [XorrisoZeroOneTwo 1626] +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to xorriso-0.1.2 + +---------------------------------- release - xorriso-0.1.2 - 2008.03.12.100001 +* Bug fix: -report_about HINT or higher did not report at all +* Bug fix: speed=number without unit or media type letter was always CD speed +* Bug fix: it was possible to write to appendable media which was not -indev +* Bug fix: -follow param did not work for adding non-directory symbolic links +* Bug fix: It was not possible to -add /THIS=a /b=THIS +* Improved attribute transfer from disk for implicit target directories +* New option -as "cdrecord" emulates a narrow set of cdrecord gestures +* New option -as "mkisofs" emulates a narrow set of mkisofs gestures +* New option -publisher +* New option -errfile_log +* Support for DVD+R/DL media +* New options -compare, -compare_r and according -find -exec action +* New options -update, -update_r and according -find -exec action +* New -find actions "rm", "rm_r", new -findx -type "m" -exec "empty_iso_dir" +* New option -cut_out + + +2008.03.12.130605 [1627] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to 0.1.3 + +------------------------------------ cycle - xorriso-0.1.3 - 2008.03.12.130605 + +12 Mar 2008 [XorrisoZeroOneTwo 1628] [1629] +xorriso/changelog.txt +Documented changes and release timestamp + +2008.03.19.081837 [1637] +xorriso/xorriso.c +Bug fix: -as mkisofs -nopad must be -no-pad + +19 Mar 2008 [1638] +xorriso/xorriso.1 +Added a hint about alternating media with -update_r + +------------------------------------ cycle - xorriso-0.1.3 - 2008.03.19.081837 +* Bug fix: -as mkisofs -no-pad was misspelled -nopad + + +20 Mar 2008 [1639] +xorriso/README +Added -commit_eject all to an example which involves mount + +2008.03.20.192317 [1640] +xorriso/xorriso.c +Changed messages of -update and -update_r + +2008.03.20.210522 [1641] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +Better handling of attempt to manipulate non-existent ISO image + +2008.03.22.130031 [1642] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +Working towards coordination of -compare, -update and -cut_out + +2008.03.22.130128 [1643] +xorriso/xorrisoburn.c +Bug fix: Implicite directory attribute copying with -cut_out was wrong + +------------------------------------ cycle - xorriso-0.1.3 - 2008.03.22.130128 +* Bug fix: Implicite directory attribute copying with -cut_out was wrong + + +22 Mar 2008 [1644] +xorriso/xorriso.1 +Correction about Linux mount which does not accept session= with DVD. + +2008.03.25.170747 [1645] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +Working towards coordination of -compare, -update and -cut_out + +2008.03.26.092120 [1646] +xorriso/xorrisoburn.c +Gave up obsoleted macros and their code branches + +2008.03.27.103344 [1647] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Working towards coordination of -update and -cut_out + +27 Mar 2008 [1648] +xorriso/xorriso.1 +Published coordination rules for -cut_out, -compare and -update + +2008.03.29.164038 [1649] +xorriso/xorriso_private.h +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -split_size, automated splitting of oversized files + +------------------------------------ cycle - xorriso-0.1.3 - 2008.03.29.164038 +* Coordination of -cut_out, -compare and -update +* New option -split_size, automated splitting of oversized files + +2008.03.31.081347 [1650] +xorriso/xorriso.c +xorriso/xorriso.1 +Adjusted documentation of -split_size + +2008.04.01.213121 [1652] +libisoburn/data_source.c +Replaced single 128 kB cache tile by 32 tiles of 64 kB each + +2 Apr 2008 [1653] +COPYRIGHT +Corrected GPL version + +------------------------------------ cycle - xorriso-0.1.3 - 2008.04.03.074309 +* Improved performance with reading directory trees + +2008.04.03.204051 [1657] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -session_log + +5 Apr 2008 [1658] +xorriso/xorriso.1 +Mentioned that drives close full media automatically + +2008.04.05.112055 [1659] +xorriso/xorrisoburn.c +Reporting amount of non-data with -toc media summary + +5 Apr 2008 [1660] +xorriso/xorriso_eng.html +Mentioned new features + +------------------------------------ cycle - xorriso-0.1.3 - 2008.04.05.112055 +* New option -session_log + +2008.04.07.185727 [1662] +xorriso/xorriso.h +Added prototype of Xorriso_option_session_log() + +2008.04.07.201253 [1664] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Removed some unused code + +8 Apr 2008 [1677] +xorriso/configure_ac.txt +Followed version leaps of libburn + +2008.04.08.153508 [1678] +libisoburn/libisoburn.h +xorriso/xorrisoburn.c +Made libisoburn and xorriso require libburn >= 0.4.4 + +2008.04.09.114815 [1679] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Corrected behavior around image data read error + +2008.04.12.112159 [1682] +xorriso/xorriso.c +Changed behavior of -commit_eject "" + +2008.04.18.184517 [1690] +libisoburn/data_source.c +Restricted ds_read_block() messages about unreadable data to actual data block + +2008.04.20.111054 [1692] +libisoburn/data_source.c +Corrected maximum age value for read buffer tiles + +20 Apr 2008 [1693] +xorriso/xorriso.1 +Mentioned stdin with option -path_list + +2008.04.20.111419 [1694] +libisoburn/burn_wrap.c +xorriso/xorrisoburn.c +Displaying free space rather than "non-data" on drive aquiry and -toc + +28 Apr 2008 [1709] +xorriso/configure_ac.txt +Updated libisofs version number in xorriso-standalone + +------------------------------------ cycle - xorriso-0.1.3 - 2008.04.28.082539 +* Now depending on libisofs-0.6.4 + +2008.04.28.120001 [branch 1711] +configure.ac +README +libisoburn/libisoburn.h (isoburn_header_version_*) +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h (xorriso_libisoburn_req_*) +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to 0.1.4 + +28 Apr 2008 [branch 1712] +xorriso/changelog.txt +Documented changes and release timestamp + +---------------------------------- release - xorriso-0.1.4 - 2008.04.28.120001 +* Bug fix: -as mkisofs -no-pad was misspelled -nopad +* Bug fix: Implicite directory attribute copying with -cut_out was wrong +* Coordination of -cut_out, -compare and -update +* New option -split_size, automated splitting of oversized files +* Improved performance with reading directory trees +* New option -session_log +* Dynamically linkable with release version 0.6.4 of libisofs + + +2008.04.28.122244 [1713] +configure.ac +README +libisoburn/libisoburn.h (isoburn_header_version_*) +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h (xorriso_libisoburn_req_*) +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to 0.1.5 + +28 Apr 2008 [1714] +xorriso/changelog.txt +Documented changes and release timestamp + +------------------------------------ cycle - xorriso-0.1.5 - 2008.04.28.122244 + +2008.05.01.124248 [1716] +libisoburn/isofs_wrap.c +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -error_behavior with a first occasion 'image_loading' + +1 May 2008 [1717] +xorriso/convert_man_to_html.sh +Fine tuning of HTML man page appearance + +1 May 2008 [1718] +xorriso/xorriso.1 +Clarified "best_effort" behavior + +2008.05.01.135421 [1719] +libisoburn/data_source.c +Adjusted ds_read_block() to inofficial libisofs expectations + +2008.05.01.174110 [1720] +libisoburn/data_source.c +Adjusted ds_read_block() to inofficial libisofs expectations + +2008.05.02.072505 [1721] +libisoburn/data_source.c +Adjusted ds_read_block() to inofficial libisofs expectations + +2008.05.02.204942 [1722] +xorriso/xorriso_private.h +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +Working towards exclusion of user defined absolute paths and leaf patterns + +2008.05.03.151106 [1724] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +Working towards exclusion of user defined absolute paths and leaf patterns + +2008.05.03.223204 [1725] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +Working towards exclusion of user defined absolute paths and leaf patterns + +2008.05.04.133525 [1726] +xorriso/xorriso.c +xorriso/xorriso.1 +New options -not_paths, -not_leaf, -not_list, -not_mgt, -as mkisofs -m + +4 May 2008 [1727] +xorriso/xorriso_eng.html +xorriso/changelog.txt +Mentioned new options + +------------------------------------ cycle - xorriso-0.1.5 - 2008.05.04.133525 +* New option -error_behavior with a first occasion 'image_loading' +* New options -not_paths, -not_leaf, -not_list, -not_mgt, -as mkisofs -m + + +2008.05.05.210317 [1728] +xorriso/xorrisoburn.c +After formatting DVD-RW write 128 MB and close track to end Intermediate State + +2008.05.06.084439 [1731] +xorriso/xorrisoburn.c +Calling isoburn_cancel_prepared_write() after failed isoburn_disc_write() + +2008.05.06.144606 [1732] +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/isofs_wrap.c +libisoburn/burn_wrap.c +Experiment for TOC on overwriteables: Keep a target_head copy of session #1 + +2008.05.07.071427 [1737] +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/burn_wrap.c +libisoburn/isofs_wrap.c +Removed some outdated ifdef cases + +2008.05.07.175508 [1738] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/burn_wrap.c +Reading emulated toc info from overwriteable media, new API isoburn_toc_*() + +2008.05.07.175640 [1739] +xorriso/xorrisoburn.c +Making use of new isoburn_toc_* functions + +2008.05.07.214343 [1740] +libisoburn/libisoburn.h +libisoburn/burn_wrap.c +New API function isoburn_read_iso_head() + +2008.05.07.214442 [1741] +xorriso/xorrisoburn.c +New format with -toc is more concise and shows volume id + +2008.05.08.141054 [1742] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/burn_wrap.c +Try to read header chain from alleged -ROM media (e.g. DVD+RW in -ROM drive) + +2008.05.08.141920 [1743] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +xorriso/xorriso_eng.html +New TOC layout with volume id and sbsector=, new option -rom_toc_scan + +8 May 2008 [1744] +xorriso/xorriso_eng.html +Mentioned new features + +------------------------------------ cycle - xorriso-0.1.5 - 2008.05.08.141920 +* Emulated TOC on overwriteable media +* New TOC layout with volume id and sbsector= +* New option -rom_toc_scan + + +2008.05.08.185350 [1745] +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/burn_wrap.c +Adjusted reply of isoburn_disc_get_msc1() to eventual -rom_toc_scan result + +8 May 2008 [1746] +xorriso/xorriso.1 +Updated man page examples + +8 May 2008 [1747] +xorriso/xorriso.1 +Updated man page examples + +------------------------------------ cycle - xorriso-0.1.5 - 2008.05.08.205551 + +9 May 2008 [1751] +xorriso/xorriso_eng.html +Updated details in web page + +2008.05.09.205517 [1752] +libisoburn/isofs_wrap.c +Trying to better handle non ISO images on -indev + +10 May 2008 [1761] +xorriso/configure_ac.txt +Adapted xorriso standalone production to new libburn cycle 0.4.7 + +10 May 2008 [1762] +xorriso/xorriso.1 +xorriso/xorriso_eng.html +Minor change in -update_r example + +2008.05.10.194336 [1763] +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.c +Better behavior of update_r with no image present + +2008.05.12.080812 [1765] +configure.ac +libisoburn/libisoburn.h +Switched requirements to libburn-0.4.6 + +2008.05.12.081331 [1766] +libisoburn/libisoburn.h +libisoburn/burn_wrap.c +New API call isoburn_set_msc1() + +2008.05.12.082733 [1767] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +xorriso/xorriso_eng.html +New option -load session|track|sbsector|volid + +------------------------------------ cycle - xorriso-0.1.5 - 2008.05.12.082733 +* New option -load session|track|sbsector|volid +* Now depending on libburn-0.4.6 + + +2008.05.12.193341 [1768] +libisoburn/burn_wrap.c +Reacted on harmless compiler warning + +2008.05.12.193642 [1769] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New -blank and -format modes as_needed + +2008.05.13.115901 [1770] +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +xorriso/xorriso_eng.html +New option -list_formats + +2008.05.13.135251 [1771] +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/isofs_wrap.c +libisoburn/burn_wrap.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Corrected strange behavior with non-ISO images on overwriteable media + +2008.05.13.153837 [1772] +xorriso/xorrisoburn.c +Prepared Xorriso_get_profile() for potential call without flag bit1 + +2008.05.13.180624 [1773] +xorriso/xorrisoburn.c +Handled -list_format with non MMC drives + +2008.05.13.180912 [1774] +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorriso.1 +Eat up leading dashes with command options, convert inner dashes to underscores + +------------------------------------ cycle - xorriso-0.1.5 - 2008.05.13.180912 +* New -blank and -format modes as_needed +* New option -list_formats + +2008.05.14.114548 [1775] +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New -format types by_index and fast_by_index + +2008.05.14.173201 [1779] +configure.ac +libisoburn/libisoburn.h +Required libburn version is now 0.4.7 (because of DVD-RAM BD-RE bug fix) + +2008.05.14.173430 [1780] +xorriso/xorrisoburn.c +Automatic fast format on attempt to write to unformatted DVD-RAM or BD-RE + +2008.05.14.174846 [1781] +xorriso/xorriso_private.h +Uploaded forgotten enhancements + +2008.05.15.092028 [1783] +xorriso/xorriso.c +Enabled a pacifier for compare_r + +2008.05.15.150041 [1784] +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +xorriso/xorriso_eng.html +New options -map and -map_single + +2008.05.15.192118 [1785] +xorriso/xorriso.c +Bug fix: -update_r and others did not work properly with relative paths + +------------------------------------ cycle - xorriso-0.1.5 - +* New options -map and -map_single +* Bug fix: -update_r and others did not work properly with relative paths + + +2008.05.17.162753 [1794] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Corrected ugly message with -update_r and root directory + +2008.05.17.170001 [1796] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to 0.1.6, requiring libburn-0.4.8 now + +2008.05.18.070001 [1797] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Bug fix: -findi operated on nodes which ceased existence shortly before + +18 May 2008 [1799] +xorriso/changelog.txt +Documented changes and release timestamp + +---------------------------------- release - xorriso-0.1.6 - 2008.05.18.070001 +* New option -error_behavior with a first occasion 'image_loading' +* New options -not_paths, -not_leaf, -not_list, -not_mgt, -as mkisofs -m +* Emulated TOC on overwriteable media +* New TOC layout with volume id and sbsector= +* New option -rom_toc_scan +* New option -load session|track|sbsector|volid +* Now depending on libburn-0.4.8 +* New -blank and -format modes as_needed +* New option -list_formats +* New options -map and -map_single +* Bug fix: -update_r and others did not work properly with relative paths +* Bug fix: -findi operated on nodes which ceased existence shortly before + + +2008.05.18.082208 [1798] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Bug fix: -findi operated on nodes which ceased existence shortly before + +2008.05.18.084729 [1800] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +xorriso/changelog.txt +Version leap to 0.1.7, requiring libburn-0.4.8 now + +------------------------------------ cycle - xorriso-0.1.7 - 2008.05.18.084729 + +2008.05.20.075142 [1804] +xorriso/xorriso.c +Making Xorriso_prescan_args() safe against misunderstandings + +2008.05.22.192618 [1808] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +First experiments of osirrox ISO-to-disk copying + +2008.05.22.192737 [1809] +libisoburn/data_source.c +Removed outdated code branch + +2008.05.22.210835 [1810] +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New options -osirrox and -cpx + +2008.05.24.092546 [1812] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Enabled osirrox of more file types, curbed with device files + +2008.05.24.092853 [1813] +libisoburn/isoburn.c +Bug fix: modifying to overwriteable target yielded unmountable results + +------------------------------------ cycle - xorriso-0.1.7 - 2008.05.24.092853 +* Bug fix: Modifying to overwriteable target yielded unmountable results +* New options -osirrox and -cpx + + +2008.05.24.170109 [1814] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Some polishing with -cpx + +26 May 2008 [1815] +xorriso/configure_ac.txt +standalone version switch to libisofs-0.6.5 + +2008.05.26.181210 [1816] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +Improved access permission restauration by osirrox + +2008.05.27.201513 [1817] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +xorriso/xorriso_eng.html +New option -stream_recording + +2008.05.31.174045 [1819] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Implemented concatenation of split files during -cpx + +------------------------------------ cycle - xorriso-0.1.7 - 2008.05.31.174045 +* New option -stream_recording + +2008.06.01.134322 [1820] +xorriso/xorrisoburn.c +Reacted on harmless compiler warning + +2008.06.01.145038 [1821] +xorriso/configure_ac.txt +standalone version switch to libisofs-0.6.6 + +2008.06.01.145155 [1822] +configure.ac +libisoburn/libisoburn.h +Switched requirements to libisofs-0.6.6 + +------------------------------------ cycle - xorriso-0.1.7 - 2008.06.01.145155 +* Bug fix: major,minor numbers of device files appeared as 0,1 in next session + + +2008.06.02.070301 [1824] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to 0.1.8 + +2 Jun 2008 [1825] +xorriso/changelog.txt +Documented changes and release timestamp + +---------------------------------- release - xorriso-0.1.8 - 2008.06.02.070301 +* Bug fix: Modifying to overwriteable target yielded unmountable results +* Bug fix: major,minor numbers of device files appeared as 0,1 in next session +* New option -stream_recording for full speed with DVD-RAM and BD-RE +* New options -osirrox and -cpx allow to extract single files from ISO image + + +2008.06.02.141334 [1826] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to 0.1.9 + +2 Jun 2008 [1827] +xorriso/changelog.txt +Documented changes and release timestamp + +2 Jun 2008 [1828] +xorriso/xorriso.1 +Beautified documentation of -osirrox + +------------------------------------ cycle - xorriso-0.1.9 - 2008.06.02.141334 + +5 Jun 2008 [1834] +xorriso/convert_man_to_html.sh +Beautified HTML man page + +2008.06.05.165023 [1835] +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New options -cpax, -cp_rx, -cp_rax to restore files and trees from ISO to disk + +2008.06.06.083432 [1839] +xorriso/xorriso.c +Bug fix: -chmod unintentionally performed o-x as first operation + +2008.06.06.103735 [1840] +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Fine tuning of directory attribute copying with -cp_rx + + +------------------------------------ cycle - xorriso-0.1.9 - +* New options -cpax, -cp_rx, -cp_rax to restore files and trees from ISO to disk +* Bug fix: -chmod unintentionally performed o-x as first operation + + +2008.06.09.134432 [1841] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +Allowing to restore from image with pending changes + +2008.06.09.165735 [1842] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Removed some outdated code parts + +2008.06.10.094304 [1844] +libisoburn/isoburn.c +libisoburn/burn_wrap.c +Removed outdated code parts + +2008.06.10.100231 [1845] +xorriso/xorrisoburn.c +Removed outdated code parts + +2008.06.11.131607 [1846] +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Proper handling of restore overwrite situations with directories and softlinks + +------------------------------------ cycle - xorriso-0.1.9 - 2008.06.11.131607 + +2008.06.12.112644 [1847] +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Corrections about restoring of directories + +------------------------------------ cycle - xorriso-0.1.9 - 2008.06.12.112644 + +2008.06.13.151630 [1848] +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -paste_in + +2008.06.14.104745 [1849] +xorriso/xorriso.c +xorriso/xorriso.1 +xorriso/xorriso_eng.html +New options -extract and -extract_single + +14 Jun 2008 [1850] +xorriso/convert_man_to_html.sh +Beautification of HTML man page + +2008.06.14.140459 [1851] +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Correction about -extract / / + +2008.06.14.184512 [1854] +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorriso.1 +xorriso/convert_man_to_html.sh +Gave up the unusual parameter sequences of -extract and -paste_in + +------------------------------------ cycle - xorriso-0.1.9 - 2008.06.14.184512 +* New option -paste_in to copy ISO files into parts of disk files +* New option -extract restores with arguments of -map or -update_r + + +2008.06.17.121524 [1857] +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorriso.1 +New options -map_l, -compare_l, -update_l, -extract_l + +2008.06.17.133914 [1858] +xorriso/xorriso.c +Reacted on harmless compiler warning + +2008.06.17.170622 [1859] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Fixed a bug about -update_l + +2008.06.18.132057 [1860] +libisoburn/isoburn.h +libisoburn/burn_wrap.c +Made -rom_toc_scan work on closed DVD-R in a DVD-ROM drive + +2008.06.18.161512 [1861] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/isofs_wrap.c +libisoburn/burn_wrap.c +libisoburn/data_source.c +New API functions isoburn_preset_msgs_submit(), isoburn_set_msgs_submit() + +2008.06.18.161723 [1862] +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +Made use of isoburn_preset_msgs_submit() + +------------------------------------ cycle - xorriso-0.1.9 - 2008.06.18.161723 +* New options -map_l, -compare_l, -update_l, -extract_l +* New API functions isoburn_set_msgs_submit(), isoburn_drive_set_msgs_submit() + + +2008.06.18.192913 [1863] +libisoburn/burn_wrap.c +Improved pacifier with -rom_toc_scan + +2008.06.19.090436 [1864] +libisoburn/libisoburn.h +libisoburn/burn_wrap.c +xorriso/xorrisoburn.c +Renamed isoburn_*set_msgs_submit() and slightly changed meaning + +2008.06.19.092458 [1865] +libisoburn/burn_wrap.c +Corrected wrong size unit MB to kB in toc scan pacifier text + +2008.06.20.091647 [1866] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New -osirrox option auto_chmod_on + +------------------------------------ cycle - xorriso-0.1.9 - 2008.06.20.091647 + + +2008.06.20.164105 [1867] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +Fixed several bugs with restore operations + +2008.06.21.180701 [1870] +xorriso/xorriso.1 +Corrected mistake in xorriso man page + +------------------------------------ cycle - xorriso-0.1.9 - 2008.06.21.180701 + +2008.06.22.080000 [1872] +xorriso/xorriso.c +Removed duplicated help text snippet + +2008.06.22.090001 [1873] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to 0.2.0 + +22 Jun 2008 [1874] +xorriso/changelog.txt +Documented changes and release timestamp + +---------------------------------- release - xorriso-0.2.0 - 2008.06.22.090001 +* Bug fix: -chmod unintentionally performed o-x as first operation +* New options -cpax, -cp_rx, -cp_rax to restore files and trees from ISO to disk +* New option -extract restores with arguments of -map or -update_r +* New option -paste_in to copy ISO files into parts of disk files +* New options -map_l, -compare_l, -update_l, -extract_l +* New API functions isoburn_set_msgs_submit(), isoburn_drive_set_msgs_submit() + +2008.06.22.111236 [1875] +xorriso/xorriso.c +Removed duplicated help text snippet + +2008.06.22.135202 [1876] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to 0.2.1 + +22 Jun 2008 [1877] +xorriso/changelog.txt +Documented changes and release timestamp + +------------------------------------ cycle - xorriso-0.2.1 - 2008.06.22.135202 + + +2008.06.27.124201 [1880] +xorriso/xorrisoburn.c +Bug fix: -as cdrecord -atip falsely announced overwriteable DVD-RW to sdvdbackup + +2008.06.27.130235 [1881] +xorriso/xorriso.c +Extended -as cdrecord blank= by blank type format_overwrite + +------------------------------------ cycle - xorriso-0.2.1 - 2008.06.27.130235 + + +2008.07.03.133023 [1882] +xorriso/xorriso.c +Flushing stdout after each result text to deconfuse stdout/stderr with SSH + +2008.07.04.070001 [1884] +xorriso/xorriso.c +Supporting option -as cdrecord -waiti + +2008.07.05.132528 [1885] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/isofs_wrap.c +libisoburn/burn_wrap.c +libisoburn/data_source.c +New API function isoburn_prepare_blind_grow() for -as mkisofs -multi + +2008.07.05.133721 [1886] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -grow_blindly + +2008.07.05.180241 [1887] +libisoburn/isoburn.c +Fixed a bug with -grow_blindly to overwriteable media + +2008.07.05.182424 [1888] +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorriso.1 +New options -C and -M for -as mkisofs + +2008.07.05.184434 [1889] +xorriso/xorriso.c +Cared for a peculiarity of growisofs when using mkisofs -C + +5 Jul 2008 [1890] +xorriso/xorriso_eng.html +Updated xorriso homepage + +------------------------------------ cycle - xorriso-0.2.1 - 2008.07.05.184434 +* New API function isoburn_prepare_blind_grow() +* New option -grow_blindly +* New options -C and -M for -as mkisofs emulation + + +2008.07.06.110336 [1891] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +Improved effective drive address with -as mkisofs -M + +2008.07.07.095531 [1892] +xorriso/xorriso.c +Fixed bug about -as mkisofs without -C + +2008.07.07.102941 [1893] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +Semi-permanent emulation by start names xorrisofs,genisofs,mkisofs,genioimage + +------------------------------------ cycle - xorriso-0.2.1 - 2008.07.07.102941 + +2008.07.07.150241 [1894] +xorriso/xorriso.c +Correction about -as mkisofs -C if already an input device was set + +2008.07.07.150337 [1895] +libisoburn/isoburn.c +Correction about isoburn_igopt_get_effective_lba() with blind growing + +7 Jul 2008 [1896] +xorriso/xorriso.1 +Clarification about -grow_blindly predicted_nwa + +2008.07.07.150337 [1897] +xorriso/xorriso.c +xorriso/xorriso.1 +Made leafname triggered emulation more similar to -as emulation + +2008.07.08.092732 [1898] +Makefile.am +README +xorriso/xorriso_makefile_am.txt +xorriso/README +Installing softlinks xorrisofs and osirrox pointing to the xorriso binary + +2008.07.08.102622 [1899] +xorriso/xorriso_private.h +Header file forgotten with rev 1897 + +2008.07.08.132054 [1900] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Avoided misleading message about emptied ISO image during -as mkisofs -C + +8 Jul 2008 [1901] +xorriso/xorriso_eng.html +Documented newest progress + +------------------------------------ cycle - xorriso-0.2.1 - 2008.07.08.132054 +* Can serve growisofs if started as xorrisofs, genisofs, mkisofs, genisoimage +* make install creates xorriso aliases as symbolic links: osirrox, xorrisofs + +2008.07.09.055133 [1901] +xorriso/xorriso.c +Avoided to use MMC code with -as mkisofs -M by prepending stdio: to address + +2008.07.09.055133 [1902] +xorriso/xorriso.h +xorriso/xorriso.c +Fixed bug with -as mkisofs -x and pattern expansion + +------------------------------------ cycle - xorriso-0.2.1 - 2008.07.09.055133 + + +2008.07.09.155540 [1903] +Makefile.am +xorriso/xorriso_private.h ++ xorriso/xorriso_buildstamp.h ++ xorriso/xorriso_buildstamp_none.h +xorriso/xorriso_makefile_am.txt +xorriso/make_xorriso_standalone.sh +Opportunity to generate build timestamp via make buildstamped + +9 Jul 2008 [1904] +xorriso/xorriso_makefile_am.txt +Completed (unused) dist rule of standalone-xorriso + +2008.07.10.141731 [1905] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Enabled -multi and -msinfo with -as cdrecord + +2008.07.10.141913 [1906] +libisoburn/libisoburn.h +Small correction in API introduction text + +2008.07.10.144535 [1907] +xorriso/xorriso_private.h +Header file forgotten with rev 1903 + +2008.07.10.162809 [1908] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorriso.1 +cdrecord emulation by start names xorrecord, cdrecord, wodim, cdrskin + +2008.07.10.164015 [1909] +xorriso/xorriso.c +Reacted on compiler warning + +2008.07.10.164412 [1910] +Makefile.am +README +xorriso/xorriso_makefile_am.txt +xorriso/README +Installing softlink xorrecord pointing to the xorriso binary + +10 Jul 2008 [1911] +xorriso/xorriso.1 +xorriso/xorriso_eng.html +xorriso/convert_man_to_html.sh +Some documentation updates + +------------------------------------ cycle - xorriso-0.2.1 - 2008.07.10.164412 +* New options -multi and -msinfo for -as cdrecord emulation +* make install creates xorriso alias as symbolic link: xorrecord + + +2008.07.12.181846 [1912] +libisoburn/libisoburn.h +libisoburn/burn_wrap.c +New info mode 2 with isoburn_read_iso_head() + +2008.07.12.184833 [1913] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New options --grow_overwriteable_iso and write_start_address= with -as cdrecord + +2008.07.14.114515 [1918] +libisoburn/libisoburn.h +Required libburn version is now 0.4.9 + +2008.07.14.114613 [1919] +configure.ac +Did LT_CURRENT++, LT_AGE++ which was forgotten with revision 1885 + +2008.07.14.120527 [1920] +libisoburn/libisoburn.h +libisoburn/burn_wrap.c +New flag options with isoburn_read_iso_head() + +2008.07.14.125133 [1921] +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -isosize with -as cdrecord + +14 Jul 2008 [1923] +xorriso/convert_man_to_html.sh +Small correction with a sed expression + +2008.07.15.063040 [1924] +xorriso/xorriso_makefile_am.txt +Generating automatic build timestamp + +2008.07.15.121754 [1925] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option tsize= with -as cdrecord + +------------------------------------ cycle - xorriso-0.2.1 - 2008.07.15.121754 +* New options --grow_overwriteable_iso and write_start_address= with -as cdrecord +* New options -isosize and tsize= with -as cdrecord + + +2008.07.16.130711 [1933] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -pacifier, more compatible pacifier with -as mkisofs + +2008.07.16.130758 [1934] +xorriso/configure_ac.txt +Updated xorriso standalone configure.ac version number BURN_*_VERSION + +2008.07.16.130841 [1935] +libisoburn/libisoburn.h +Required libburn version is now 0.5.0 + +2008.07.16.131110 [1936] +configure.ac +Required libburn version is now 0.5.0 + +2008.07.16.140043 [1937] +xorriso/xorriso.c +xorriso/xorriso.1 +Recognizing "b" as speed factor for BD media + +------------------------------------ cycle - xorriso-0.2.1 - 2008.07.16.140043 +* New option -pacifier, more compatible pacifier with -as mkisofs + +2008.07.17.110812 [1939] +libisoburn/libisoburn.h +libisoburn/burn_wrap.c +Ability to emulate a featured bug with mkisofs -C : read 16 block too early + +2008.07.17.111411 [1940] +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Rectified usage of original xorriso options underneath growisofs + +2008.07.17.183024 [1941] +libisoburn/burn_wrap.c +Recognizing growisofs follow-up sessions on xorriso overwriteables + +2008.07.17.184520 [1942] +libisoburn/burn_wrap.c +xorriso/xorriso.c +xorriso/xorrisoburn.c +Removed MULTI construction site remarks + +------------------------------------ cycle - xorriso-0.2.1 - 2008.07.17.184520 + + +2008.07.18.120001 [1944] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt + +18 Jul 2008 [1946] +README +xorriso/README +Corrected outdated statement about minimum library requirements + + +---------------------------------- release - xorriso-0.2.2 - 2008.07.18.120001 +* New API function isoburn_prepare_blind_grow() +* New option -grow_blindly +* Options -C and -M for -as mkisofs emulation +* Can serve growisofs if started as xorrisofs, genisofs, mkisofs, genisoimage +* make install creates aliases as symbolic links: osirrox, xorrisofs, xorrecord +* Options for -as cdrecord emulation: -multi, -msinfo, -isosize, tsize, + --grow_overwriteable_iso, write_start_address, +* New option -pacifier, more compatible pacifier with -as mkisofs + + +2008.07.18.135540 [1947] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +xorriso/changelog.txt +Version leap to 0.2.3 + +------------------------------------ cycle - xorriso-0.2.3 - 2008.07.18.135540 + + +2008.07.19.113048 [1949] +Makefile.am +xorriso/compile_xorriso.sh +Introduced automatic buildstamp generation for dynamic library version + +2008.07.21.155324 [1950] +Makefile.am +xorriso/xorriso_makefile_am.txt +Reacting on ticket 138 by stick, revoked buildstamp due to ugly make install + +2008.07.21.161826 [1951] +Makefile.am +xorriso/xorriso_makefile_am.txt +Used quotation marks as does ./bootstrap when generating Makefile.in + +------------------------------------ cycle - xorriso-0.2.3 - 2008.07.21.161826 +* Bug fix: Variable DESTDIR was not properly respected during make install + + +2008.07.23.080001 [xorriso-0.2.2.pl01] +Makefile.in +xorriso/xorriso_timestamp.h +xorriso/changelog.txt +* Bug fix: external make variable DESTDIR was not used by xorriso link creation + +------------------------------- patch - xorriso-0.2.2.pl01 - 2008.07.23.080001 +* Bug fix: Variable DESTDIR was not properly respected during make install + + +2008.07.26.075027 [1953] +libisoburn/burn_wrap.c +Producing on overwriteables a partial TOC up to first damaged superblock + +2008.08.01.101355 [1955] +xorriso/xorrisoburn.c +Better finish time estimation with -pacifier mkisofs + +2008.08.01.141210 [1956] +xorriso/xorrisoburn.c +Better finish time estimation with -pacifier mkisofs + +2008.08.06.143825 [1967] +xorriso/xorriso_private.h +Removed obsolete type definition + +2008.08.06.143922 [1968] +xorriso/xorrisoburn.c +Removed obsolete function + +2008.08.07.112529 [1972] +xorriso/xorriso.c +Minor changes around display of time and byte counts + +2008.08.09.160515 [1977] +configure.ac +libisoburn/libisoburn.h +Demanding libburn-0.5.1 now + +2008.08.09.160947 [1978] +libisoburn/burn_wrap.c +Create emulated toc entry for simple ISO session on overwriteable media + +2008.08.09.161311 [1979] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +Evaluating readability of media + +2008.08.11.201604 [1980] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +Adapted media evaluation to CD peculiarities + +2008.08.13.185434 [1981] +libisoburn/libisoburn.h +Corrected documentation of isoburn_disc_get_msc1() + +2008.08.13.190704 [1982] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +New capability to redirect program output used for toc in sector map file + +2008.08.14.220520 [1983] +libisoburn/burn_wrap.c +Changed wrong update message from MB to kB + +2008.08.14.221412 [1984] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -check_media + +2008.08.15.102849 [1985] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +Allowed independent redirecton of result and info channel + +2008.08.15.155421 [1986] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Enabled printing of sector bitmaps by use=sector_map + +15 Aug 2008 [1987] +xorriso/xorriso_eng.html +Mentioned progress of development version + +2008.08.17.220043 [1988] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +-find tests -damaged and -lba_range, new -find action report_damage + +2008.08.17.221350 [1989] +xorriso/xorrisoburn.c +xorriso/xorriso_eng.html +Reacted on compiler warning + +------------------------------------ cycle - xorriso-0.2.3 - +* Included libburn has enhanced Linux drive access and listing code +* New option -check_media +* New -find test -damaged, new -find action "report_damage" + + +2008.08.18.134140 [1990] +xorriso/xorrisoburn.c +xorriso/README +xorriso/xorriso.1 +New -find action report_lba + +2008.08.20.101410 [2000] +xorriso/configure_ac.txt +Adopted to new libburn version 0.5.3 + +2008.08.20.121008 [2002] +libisoburn/libisoburn.h +configure.ac +Demanding libburn-0.5.2 now + +2008.08.20.181734 [2003] +xorriso/xorrisoburn.c +Made -check_media process first 32 blocks of a multi-session overwriteable + +2008.08.21.070602 [2004] +xorriso/xorriso.c +Synced -lsl display of major,minor numbers with /usr/include/sys/sysmacros.h + +2008.08.22.231051 [2005] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New -check_media option -patch_lba0= + +2008.08.24.100552 [2007] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +xorriso/xorriso_eng.html +New -error_behavior behavior occasion "file_extraction" + +2008.08.24.124424 [2008] +xorriso/xorrisoburn.c +Fixed a bug with -check_media use=outdev + +2008.08.24.125257 [2009] +xorriso/xorrisoburn.c +Reacted on compiler warning + +------------------------------------ cycle - xorriso-0.2.3 - 2008.08.24.125257 +* New -find action "report_lba" +* New -error_behavior behavior occasion "file_extraction" + + +2008.08.24.160001 [2011] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to 0.2.4 + +24 Aug 2008 [2012] +xorriso/changelog.txt +Documented changes and release timestamp + +24 Aug 2008 [2013] +configure.ac +Corrected ISOBURN_MICRO_VERSION + +---------------------------------- release - xorriso-0.2.4 - 2008.08.24.160001 +* Included libburn has enhanced Linux drive access and listing code +* New option -check_media +* New -find test -damaged, new -find actions "report_damage", "report_lba" +* New -error_behavior occasion "file_extraction" + + +2008.08.24.173217 [2014] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to 0.2.5 + +24 Aug 2008 [2015] +xorriso/changelog.txt +Documented changes and release timestamp + +------------------------------------ cycle - xorriso-0.2.5 - 2008.08.24.173217 + +26 Aug 2008 [2017] +xorriso/convert_man_to_html.sh +Adjusted HTML generator to recent man page changes + +2008.08.26.163254 [2018] +libisoburn/libisoburn.h +libisoburn/data_source.c +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/configure_ac.txt +Adopting next development step of libisofs + +26 Aug 2008 [2019] +xorriso/xorriso.1 +Adjusted man page statements about file size limits + +2008.08.27.121211 [2020] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -file_size_limit, -as mkisofs now supports -iso-level 1 to 3 + +2008.08.27.122127 [2021] +xorriso/xorriso.c +Reacted on compiler warning + +------------------------------------ cycle - xorriso-0.2.5 - 2008.08.27.122127 +* Capability to insert and extract files far larger than 4 GB +* New option -file_size_limit, -as mkisofs now supports -iso-level 1 to 3 + + +27 Aug 2008 [2022] +xorriso/xorriso.1 +Corrected a typo in man page + +2008.09.02.164803 [2025] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -extract_cut + +2008.09.03.143218 [2026] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New -error_behavior "file_extraction" behavior "best_effort" + +2008.09.04.100158 [2027] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -check_media_defaults + +------------------------------------ cycle - xorriso-0.2.5 - 2008.09.04.100158 +* New option -extract_cut +* New -error_behavior "file_extraction" behavior "best_effort" +* New option -check_media_defaults + + +2008.09.05.095344 [2028] +xorriso/xorriso_private.h +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -list_delimiter + +5 Sep 2008 [2029] +xorriso/xorriso_eng.html +Updated development feature list + +2008.09.05.114936 [2030] +xorriso/xorriso.c +-commit_eject, -alter_date, -alter_date_r, -pacifier, -prog_help had wrong argument count prediction + +5 Sep 2008 [2031] +xorriso/xorriso.1 +Documented forgotten option -publisher + +5 Sep 2008 [2032] +xorriso/xorriso_eng.html +xorriso/xorriso.1 +Minor documentation polishing + +------------------------------------ cycle - xorriso-0.2.5 - 2008.09.05.114936 +* New option -list_delimiter + + +6 Sep 2008 [2033] +xorriso/xorriso_eng.html +xorriso/xorriso.1 +Documentation polishing + +2008.09.07.144714 [2034] +xorriso/xorrisoburn.c +Removed outdated alternative code for support of libisofs-0.6.6 + +2008.09.08.094748 [2035] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Made use of new libisofs call iso_image_update_sizes() + +2008.09.08.121548 [2036] +xorriso/xorrisoburn.c +Bug fix: -format full did not re-format already formatted DVD+RW + +2008.09.09.082406 [2037] +xorriso/xorrisoburn.c +Smoothened time estimation with pacifier mkisofs style + +9 Sep 2008 [2038] +xorriso/xorriso_eng.html +Updated web page + +------------------------------------ cycle - xorriso-0.2.5 - 2008.09.09.082406 +* Bug fix: -format full did not re-format already formatted DVD+RW + + +2008.09.11.114227 [2040] +xorriso/xorrisoburn.c +Issuing message at begin of image loading + +2008.09.13.204455 [2047] +xorriso/xorrisoburn.c +Correction about -check_media report and message about image loading + +2008.09.16.060427 [2053] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Corrected pacifier text (Ticket 141) + +2008.09.16.185206 [2054] +xorriso/xorriso_private.h +xorriso/xorriso.1 +Corrected falsely computed default setting of -file_size_limit + +2008.09.17.193824 [2056] +xorriso/xorrisoburn.c +Corrected message duplication about emulated sessions on overwriteable media + +2008.09.19.090619 [2057] [2058] +xorriso/configure_ac.txt +standalone version switch to libisofs-0.6.8 + +19 Sep 2008 [2059] +xorriso/xorriso.1 +Small change in man page + +2008.09.19.104424 [2060] +configure.ac +libisoburn/libisoburn.h +Switched requirements to libisofs-0.6.8 + +------------------------------------ cycle - xorriso-0.2.5 - 2008.09.19.104424 + + +2008.09.19.122656 [2061] +xorriso/xorrisoburn.c +Changed WARNING about non-writeable media to NOTE severity of blank messages + + +2008.09.19.180001 [2066] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to 0.2.6 + +20 Sep 2008 [2067] +xorriso/changelog.txt +Documented changes and release timestamp + +---------------------------------- release - xorriso-0.2.6 - 2008.09.19.180001 +* Capability to insert and extract files far larger than 4 GB +* New option -file_size_limit, -as mkisofs now supports -iso-level 1 to 3 +* New option -extract_cut +* New -error_behavior "file_extraction" behavior "best_effort" +* New option -check_media_defaults +* New option -list_delimiter +* Bug fix: -format full did not re-format already formatted DVD+RW + + +2008.09.20.093140 [2068] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to 0.2.7 + +20 Sep 2008 [2069] +xorriso/changelog.txt +Documented changes and release timestamp + +------------------------------------ cycle - xorriso-0.2.7 - 2008.09.20.093140 + +2008.09.24.155424 [2077] +xorriso/xorrisoburn.c +Trying to get pacifiers of simultaneously running emulations into sync + +2008.09.26.120934 [2082] +xorriso/xorriso.c +Bug fix: -as mkisofs -iso-level was accused to be an unknown option + +2008.09.26.161331 [2083] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +A first attempt on making bootable ISO images + +2008.09.28.112850 [2084] +xorriso/configure_ac.txt +Standalone version switch to libisofs-0.6.9 (vreixoml 387) to avoid SIGSEGV + +2008.09.28.113256 [2085] +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +xorriso/convert_man_to_html.sh +xorriso/xorriso_eng.html +Made -boot_image isolinux activation obey -overwrite setting + +2008.09.30.102243 [2088] +libisoburn/libisoburn.h +Requiring libisofs-0.6.9 because of bug fixes with El Torito + +2008.09.30.102753 [2089] +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Adjustments about -boot_image after testing with various media types + +30 Sep 2008 [2090] +xorriso/xorriso_eng.html +Mentioned progress and bug fixes in 0.2.7 + +------------------------------------ cycle - xorriso-0.2.7 - 2008.09.30.102753 +* Bug fix: -as mkisofs -iso-level was accused to be an unknown option +* Ability to write and maintain bootable ISO images based on ISOLINUX + + +2008.09.30.174925 [2091] +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Small adjustments about -boot_image + +2008.10.02.092354 [2092] +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Small adjustments about -boot_image + +2008.10.02.092635 [2093] +xorriso/xorriso.c +Enabled -as cdrecord blank=as_needed + +2008.10.02.105442 [2094] +xorriso/README +xorriso/configure_ac.txt +Introduced xorriso-standalone ./configure option --disable-libreadline + +2008.10.02.110828 [2095] +README +xorriso/README +xorriso/configure_ac.txt +Fine tuning about ./configure option --disable-libreadline + +------------------------------------ cycle - xorriso-0.2.7 - 2008.10.02.110828 +* New ./configure option --disable-libreadline to make binary more portable + + +4 Oct 2008 [2099] +xorriso/convert_man_to_html.sh +xorriso/xorriso.1 +Relocated the El Torito paragraph in man xorriso + +2008.10.05.075432 [2101] +libisoburn/libisoburn.h +libisoburn/burn_wrap.c +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +-rom_toc_scan nonrom_off disables toc emulation on overwriteables + +2008.10.05.093703 [2105] +xorriso/xorrisoburn.c +Bug fix: Random target filenames with looping symbolic links + +2008.10.05.125046 [2109] +xorriso/configure_ac.txt +Adapted standalone BURN_*_VERSION to libburn 0.5.5 + +2008.10.05.125242 [2110] +configure.ac +libisoburn/libisoburn.h +libisoburn now demands libburn-0.5.4 + +------------------------------------ cycle - xorriso-0.2.7 - 2008.10.05.125242 +* Bug fix: -follow link attributed random target filenames to looping links + + +2008.10.06.114114 [2113] +xorriso/configure_ac.txt +Adapted standalone LIBISOFS_*_VERSION to libisofs 0.6.10 + +2008.10.06.114845 [2114] +configure.ac +libisoburn/libisoburn.h +libisoburn now demands libisofs-0.6.10 + +------------------------------------ cycle - xorriso-0.2.7 - 2008.10.06.114845 + + +7 Oct 2008 [2115] +xorriso/xorriso.1 +Polished man xorriso + +2008.10.08.135848 [2116] +xorriso/xorriso.c +xorriso/xorriso.1 +Changed newly introduced -rom_toc_scan nonrom_off to off:emul_off + +2008.10.09.145926 [2117] +configure.ac +README +Introduced libburn ./configure option --disable-libreadline + +9 Oct 2008 [2118] +xorriso/compile_xorriso.sh +Introduced xorriso development compiler script option -no_libreadline + +------------------------------------ cycle - xorriso-0.2.7 - 2008.10.09.145926 + + +2008.10.10.131102 [2119] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorriso.1 +Enabled dialog for multi-lines and newline characters in quotation marks + +2008.10.10.134020 [2120] +xorriso/xorriso.c +Polishing multi-line dialog + +2008.10.12.120001 [2122] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to 0.2.8 + +12 Oct 2008 [2123] +xorriso/changelog.txt +Documented changes and release timestamp + +---------------------------------- release - xorriso-0.2.8 - 2008.10.12.120001 +* Bug fix: -as mkisofs -iso-level was accused to be an unknown option +* Bug fix: -follow link attributed random target filenames to looping links +* Ability to write and maintain bootable ISO images based on ISOLINUX +* New ./configure option --disable-libreadline to make binary more portable + + +2008.10.12.133957 [2124] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to 0.2.9 + +12 Oct 2008 [2125] +xorriso/changelog.txt +Documented changes and release timestamp + +------------------------------------ cycle - xorriso-0.2.9 - 2008.10.12.133957 + + +15 Oct 2008 [2128] +xorriso/xorriso_eng.html +Corrected a typo in xorriso web page + +2008.10.15.182605 [2130] +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New options -quoted_path_list, -quoted_not_list. Multiline for -options_from_file + +2008.10.17.074953 [2131] +xorriso/xorriso_private.h +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorriso.1 +New option -backslash_codes for expressing weird file names + +2008.10.17.123308 [2132] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorriso.1 +Adjustments and documentation about -backslash_codes + +17 Oct 2008 [2133] +xorriso/xorriso_eng.html +Updated xorriso web page + +------------------------------------ cycle - xorriso-0.2.9 - 2008.10.17.123308 +* New options -quoted_path_list, -quoted_not_list +* New option -backslash_codes for weird file names and terminal safety + +18 Oct 2008 [2134] +xorriso/make_isohybrid_mbr.c +Exposed function make_isohybrid_mbr() for discussion + +19 Oct 2008 [2135] +xorriso/make_isohybrid_mbr.c +Corrected a bug in make_isohybrid_mbr() + +2008.10.19.172237 [2136] +xorriso/configure_ac.txt +xorriso/xorriso_makefile_am.txt +Adapted to libisofs 0.6.11 + +19 Oct 2008 [2137] +xorriso/compile_xorriso.sh +Adapted to libisofs 0.6.11 + +19 Oct 2008 [2138] +- xorriso/make_isohybrid_mbr.c +The make_isohybrid_mbr() function is now part of libisofs development + +2008.10.19.182512 [2139] +libisoburn/libisoburn.h +libisoburn now depends on libisofs-0.6.11 + +2008.10.20.180747 [2140] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Made use of new libisofs isohybrid capability + +------------------------------------ cycle - xorriso-0.2.9 - 2008.10.20.180747 +* Suitable ISOLINUX boot images are made alternatively bootable via MBR + + +21 Oct 2008 [2141] +xorriso/xorriso_eng.html +Mentioned isohybrid capability in xorriso homepage + +2008.10.21.112523 [2142] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +Implemented in xorriso provisory 1 MB alignement for MBR enhanced ISO images + +2008.10.21.123226 [2143] +xorriso/xorrisoburn.c +Showing a "Media summary:" with blank media + +------------------------------------ cycle - xorriso-0.2.9 - 2008.10.21.123226 + + +2008.10.22.110204 [2144] +xorriso/xorriso.c +xorriso/xorriso.1 +New options --quoted_path_list , isolinux_mbr= for -as mkisofs + +2008.10.22.201702 [2145] +xorriso/xorriso.1 +xorriso/xorrisoburn.c +Gave up automatic switch to -boot_image "isolinux" "patch" after writing + +------------------------------------ cycle - xorriso-0.2.9 - 2008.10.22.201702 + +2008.10.24.130124 [2146] +xorriso/xorrisoburn.c +Fixed image size aligment to 1 MB with follow-up sessions + +------------------------------------ cycle - xorriso-0.2.9 - 2008.10.24.130124 + + +2008.10.25.123133 [2147] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +Eventually reporting boot info with TOC of -indev, redirected drive aquiration TOC to info channel + +2008.10.25.170010 [2148] +xorriso/xorrisoburn.c +Fixed SIGSEGV introduced with previous revision + +2008.10.26.134421 [2149] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Introduced info option -boot_image "any" "show_status" + +2008.10.26.142422 [2150] +xorriso/xorrisoburn.c +Precautions against patching deleted boot images + +------------------------------------ cycle - xorriso-0.2.9 - 2008.10.26.142422 + + +2008.10.27.142720 [2151] +xorriso/xorrisoburn.c +Trying to recognize isohybrid MBR for "Boot record :" message + +------------------------------------ cycle - xorriso-0.2.9 - 2008.10.27.142720 + + +2008.10.30.110049 [2152] +xorriso/xorriso.c +Made -as mkisofs -path-list and --quoted_path_list switch pacifier mode + +2008.10.30.114313 [2153] +xorriso/xorriso.c +Enabled @ as indicator of UTC seconds in timestrings + +2008.11.03.115721 [2159] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +xorriso/convert_man_to_html.sh +New options -charset, -in_charset, -out_charset + +2008.11.04.162214 [2162] +xorriso/xorriso_private.h +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -application_id + +4 Nov 2008 [2163] +xorriso/xorriso_eng.html +Mentioned new options in xorriso homepage + +2008.11.06.183736 [2164] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -local_charset + +------------------------------------ cycle - xorriso-0.2.9 - 2008.11.06.183736 +* New options -charset, -in_charset, -out_charset +* New option -application_id +* New option -local_charset + + +2008.11.07.173315 [2170] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Copying -out_charset to -in_charset after -commit + +2008.11.07.201909 [2171] +xorriso/xorrisoburn.c +Removed some defunct code from xorrisoburn.c + +2008.11.09.102554 [2176] +xorriso/xorriso.c +Added a setlocale() call to xorriso main() + +------------------------------------ cycle - xorriso-0.2.9 - 2008.11.09.102554 +* Bug fix in libisofs: ISOLINUX boot images were not patched correctly + +2008.11.10.123332 [2177] +xorriso/xorrisoburn.c +Disabled experimental weight sorting with MBR generation + +2008.11.10.123713 [2178] +xorriso/xorriso.c +xorriso/xorriso.1 +Eventual backslash output conversion outside quotes for more terminal-safety + +11 Nov 2008 [2179] +xorriso/xorriso_eng.html +Updated xorriso home page + +------------------------------------ cycle - xorriso-0.2.9 - 2008.11.10.123713 + + +12 Nov 2008 [2190] +xorriso/configure_ac.txt +Version leap to libburn-0.5.7 + +2008.11.12.153437 [2192] +xorriso/xorriso.c +Added forgotten exit value registration to -return_with. Thanks to Steve Dodd. + +------------------------------------ cycle - xorriso-0.2.9 - 2008.11.12.153437 +* Bug fix: Forgot exit value registration to -return_with. Thanks to Steve Dodd. + + +15 Nov 2008 [2195] +xorriso/xorriso.1 +Took into respect that xorriso loads non-RR images + +2008.11.15.133724 [2196] +xorriso/xorriso.c +Adaptions to FreeBSD. Thanks to J.R. Oldroyd. + +2008.11.15.231831 [2198] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +Introduced new relax flag isoburn_igopt_always_gmt + +2008.11.15.232058 [2199] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +Making use of new relax flag isoburn_igopt_always_gmt + +------------------------------------ cycle - xorriso-0.2.9 - 2008.11.18.110100 + +18 Nov 2008 [2204] +test/aaip.c +Demo of the emerging Arbitrary Attribute Interchange Protocol format + +18 Nov 2008 [2205] +README +xorriso/README +xorriso/xorriso.1 +xorriso/xorriso_eng.html +Mentioned FreeBSD peculiarities in our docs + +2008.11.21.160019 [2206] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +Making use of experimental libisofs calls _rrip_version_1_10() _dir_rec_mtime() + +2008.11.21.160632 [2207] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +xorriso/xorriso_eng.html +New option -relax_compliance + +22 Nov 2008 [2209] +- test/aaip.c +Revoked proposal AAIP 0.0 in favor of 0.2 which is nearly like RRIP field SL + + +------------------------------------ cycle - xorriso-0.2.9 - 2008.11.21.160632 + +26 Nov 2008 [2210] +xorriso/configure_ac.txt +Promoted standalone libisofs copy to 0.6.12 + +2008.11.26.174940 [2211] +xorriso/xorrisoburn.c +Disabled "Starting up libraries ..." message + +2008.11.26.180935 [2212] +xorriso/xorriso.c +Augmented version message by "and burn program" + +------------------------------------ cycle - xorriso-0.2.9 - 2008.11.26.180935 + + +2008.11.29.091030 [2216] +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Renamed new option -relax_compliance to -compliance, added _off rules + +------------------------------------ cycle - xorriso-0.2.9 - 2008.11.29.091030 +* New option -compliance allows certain deviations from standards + + +2008.11.29.140837 [2219] +xorriso/xorrisoburn.c +Bug fix: -format as_needed did not recognize unformatted BD-RE + +2008.11.29.165843 [2220] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +Re-aquiring outdev after formatting and blanking already in xorrisoburn + +2008.11.29.214208 [2221] +xorriso/xorriso.c +New -as cdrecord option stream_recording=on|off + +2008.11.30.095007 [2222] +xorriso/xorrisoburn.c +Reporting BD speed units with pacifier rather than DVD units + +2008.11.30.123700 [2223] +xorriso/xorriso.c +Gave -as mkisofs problem handlers rather than to let it abort on any error + +2008.11.30.214121 [2224] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Changed layout of xorriso style write pacifier line + +2008.12.01.110022 [2225] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Removed outdated macro case Xorriso_fat_local_meM + +2008.12.01.122825 [2226] +xorriso/xorriso.c +Bug fix: disk patterns with relative addresses were not properly resolved + +1 Dec 2008 [2227] +xorriso/xorriso_eng.html +Updated list of bugfixes in xorriso home page + +------------------------------------ cycle - xorriso-0.2.9 - +* Bug fix: -format as_needed did not recognize unformatted BD-RE +* Bug fix: disk patterns with relative addresses were not properly resolved + + +1 Dec 2008 [2228] +Branching for libisoburn release 0.3.0 + +2008.12.01.200001 [2229] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to 0.3.0 + +1 Dec 2008 [2230] +xorriso/changelog.txt +Documented changes and release timestamp + +1 Dec 2008 [2231] +configure.ac +Corrected values of LIB*_REQUIRED + +---------------------------------- release - xorriso-0.3.0 - 2008.12.01.200001 + +* New options -quoted_path_list, -quoted_not_list +* New option -backslash_codes for weird file names and terminal safety +* New options -charset, -in_charset, -out_charset +* New option -local_charset allows to override locale +* New option -application_id +* New option -compliance allows certain deviations from standards +* Suitable ISOLINUX boot images are made alternatively bootable via an MBR +* Bug fix in libisofs: ISOLINUX boot images were not patched correctly +* Bug fix in libisofs: mkisofs images with empty files got damaged +* Bug fix: Forgot exit value registration to -return_with. Thanks to Steve Dodd. +* Bug fix: -format as_needed did not recognize unformatted BD-RE +* Bug fix: disk patterns with relative addresses were not properly resolved + + +2008.12.01.202911 [2232] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to 0.3.1 + +1 Dec 2008 [2233] +xorriso/changelog.txt +Documented changes and release timestamp + +------------------------------------ cycle - xorriso-0.3.1 - 2008.12.01.202911 + + +2 Dec 2008 [2234] +Promoted libisoburn 0.3.0 from branch to tag + +2 Dec 2008 [2235] [2236] [2237] [2238] +Deleted obsoleted branches + +2008.12.04.175459 [2240] [2241] +xorriso/xorriso.c +Bug fix: Options -extract and -extract_single were enabled with -osirrox off + +2008.12.05.171005 [2242] +libisoburn/libisoburn.h +libisoburn/burn_wrap.c +New API function isoburn_get_mount_params() + +2008.12.05.171700 [2243] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New options -mount and -mount_cmd + +2008.12.06.140828 [2244] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso_eng.html +Using uname() rather than #ifdef __FreeBSD__ + +2008.12.07.122439 [2245] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Got rid of call system() in Xorriso_mount(), new option -session_string + +Dec 7 2008 [2246] [2247] +xorriso/xorriso_eng.html +xorriso/xorriso.1 +Small documentation adjustments + +------------------------------------ cycle - xorriso-0.3.1 - 2008.12.07.122439 +* Bug fix: Options -extract and -extract_single were enabled with -osirrox off +* New API function isoburn_get_mount_params() +* New options -mount , -mount_cmd , -session_string + + +2008.12.08.120712 [2256] +xorriso/configure_ac.txt +Standalone version switch to libburn-0.5.9 + +2008.12.08.121106 [2257] +README +configure.ac +libisoburn/libisoburn.h +xorriso/README +Requiring at least libburn-0.5.8 + +8 Dec 2008 [2258] +xorriso/xorriso.1 +Small documentation adjustments + +2008.12.08.154521 [2259] +Makefile.am +xorriso/xorriso_private.h +xorriso/compile_xorriso.sh +xorriso/xorriso_makefile_am.txt +Got rid of Xorriso_with_regeX + +2008.12.10.093424 [2272] +xorriso/xorrisoburn.c +Enabled formatting of BD-R media to SRM-POW default size + +10 Dec 2008 [2275] +xorriso/xorriso.1 +Mentioned BD-R in man xorriso + +2008.12.11.072427 [2277] +xorriso/xorrisoburn.c +Proper message after failed or refused formatting + +2008.12.13.142726 [2281] [2282] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New -format modes by_size_ and fast_by_size_ + +2008.12.13.144622 [2283] +configure.ac +libisoburn/libisoburn.h +Demanding libburn-0.5.9 now + +------------------------------------ cycle - xorriso-0.3.1 - 2008.12.13.144622 +* By using libburn-0.5.9: support for BD-R media +* New -format modes by_size_ and fast_by_size_ + + +2008.12.13.161650 [2285] +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Revoked -format mode by_size for DVD-RW + +12 Dec 2008 [2286] +xorriso/xorriso_eng.html +Updated xorriso web page + +2008.12.14.093125 [2288] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -assert_volid + +2008.12.14.151550 [2291] +xorriso/xorriso.c +Removed outdated alternative code + +2008.12.14.231145 [2293] +xorriso/xorriso.c +xorriso/xorriso.1 +Options for -as mkisofs: -input-charset, -output-charset + +2008.12.16.130139 [2295] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -drive_class for safety management of pseudo-drive access + +16 Dec 2008 [2296] +xorriso/README +xorriso/xorriso_eng.html +Updated xorriso documentation + +------------------------------------ cycle - xorriso-0.3.1 - 2008.12.16.130139 +* New option -assert_volid +* New option -drive_class for safety management of pseudo-drive access + + +17 Dec 2008 [2299] ++ doc/comments +Preparations for a more presentable online API documentation + +2008.12.17.102216 [2300] +Makefile.am +Delivering doxygen input for API documentation with releases + +17 Dec 2008 [2301] +doc/comments +Corrected list of authors in libisoburn API documentation + +2008.12.21.101705 [2317] +xorriso/xorrisoburn.c +Corrected message about non-matching volume id + +------------------------------------ cycle - xorriso-0.3.1 - 2008.12.21.154636 + + +21 Dec 2008 [2318] ++ test/aaip_0_2.h ++ test/aaip_0_2.c ++ test/aaip_0_2_test.c +A first implementation of AAIP 0.2 encoding and decoding + +23 Dec 2008 [2326] +test/aaip_0_2.h +test/aaip_0_2.c +test/aaip_0_2_test.c +Gave aaip_0_2 a ring buffer rather than a shifted fifo + +25 Dec 2008 [2336] +test/aaip_0_2.h +test/aaip_0_2.c +test/aaip_0_2_test.c +Encoder for ACL long text form + +26 Dec 2008 [2338] +test/aaip_0_2.h +test/aaip_0_2.c +test/aaip_0_2_test.c +Decoder for ACL to long text form + +1 Jan 2009 [2343] +test/aaip_0_2.h +test/aaip_0_2.c +test/aaip_0_2_test.c ++ test/aaip-os-linux.c ++ test/aaip-os-freebsd.c ++ doc/susp_aaip_0_2.txt +Introduced system adapters for getting and setting EA and ACL + +1 Jan 2009 [2344] +test/aaip_0_2.c +Corrected some bugs with attribute list decoding + +1 Jan 2009 [2345] +test/aaip_0_2.c +Corrected some more bug with attribute list decoding + +4 Jan 2009 [2355] +xorriso/configure_ac.txt +Standalone version switch to libburn-0.6.1 + +5 Jan 2009 [2357] +svn copy -m "Branching for libisoburn release 0.3.2 + http://svn.libburnia-project.org/libisoburn/trunk + http://svn.libburnia-project.org/libisoburn/branches/ZeroThreeTwo + +2009.01.05.120643 [2358] +COPYRIGHT +libisoburn/burn_wrap.c +libisoburn/data_source.c +libisoburn/isoburn.c +libisoburn/isofs_wrap.c +xorriso/compile_xorriso.sh +xorriso/xorrisoburn.c +xorriso/xorriso.h +Updated copyright marks to 2009 + +2009.01.05.123001 [2359] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to 0.3.2 + +5 Jan 2009 [2360] [2361] +xorriso/changelog.txt +Documented changes and release timestamp + +----------------------------------- release - xorriso-0.3.2 - 2009.01.05.123001 +* Bug fix: Options -extract and -extract_single were enabled with -osirrox off +* New API function isoburn_get_mount_params() +* New options -mount , -mount_cmd , -session_string +* New -format modes by_size_ and fast_by_size_ +* New option -assert_volid +* New option -drive_class for safety management of pseudo-drive access +* By using libburn-0.6.0: support for BD-R media + + +2009.01.05.145703 [2362] +COPYRIGHT +libisoburn/burn_wrap.c +libisoburn/data_source.c +libisoburn/isoburn.c +libisoburn/isofs_wrap.c +xorriso/compile_xorriso.sh +xorriso/xorrisoburn.c +xorriso/xorriso.h +Updated copyright marks to 2009 + +2009.01.05.153105 [2363] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_timestamp.h +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +Version leap to 0.3.3 + +5 Jan 2009 [2364] +xorriso/changelog.txt +Documented changes and release timestamp + +------------------------------------ cycle - xorriso-0.3.3 - 2009.01.05.153105 + + +5 Jan 2009 [2365] +svn move http://svn.libburnia-project.org/libisoburn/branches/ZeroThreeTwo + http://svn.libburnia-project.org/libisoburn/tags/ZeroThreeTwo +Promoted branch to tag + +2009.01.06.123047 [2368] +xorriso/xorriso.c +xorriso/xorriso_eng.html +Some small corrections of documentation + +9 Jan 2009 [2382] +xorriso/xorriso_eng.html +Mentioned bug fix and pl01 + +------------------------------------ cycle - xorriso-0.3.3 - 2009.01.09.103251 + +2009.01.10.154018 [2386] +xorriso/xorriso.h +xorriso/xorriso.c +Avoiding use of function parameter name "class" + +14 Jan 2009 [2395] +doc/susp_aaip_0_2.txt +Clarified that AAIP is only allowed if RRIP is present + +2009.01.14.110935 [2396] +Makefile.am +xorriso/compile_xorriso.sh +xorriso/xorriso_makefile_am.txt +Introduced AAIP code. Now linking with libacl. + +2009.01.17.181500 [2400] +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +New option -getfacl + +2009.01.18.213952 [2401] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +Restoring ACLs with -extract and others + +2009.01.21.150243 [2402] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/isofs_wrap.c +New API macro isoburn_ropt_noaaip controls enabling of AAIP loading + +2009.01.21.203852 [2403] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/isofs_wrap.c +libisoburn/burn_wrap.c +Had to split isoburn_ropt_noaaip into isoburn_ropt_noacl and isoburn_ropt_noea + +2009.01.21.204513 [2404] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +New option -acl enables ACL loading + +2009.01.22.130107 [2405] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/isofs_wrap.c +Now it is isoburn_ropt_noaaip , isoburn_ropt_noacl and isoburn_ropt_noea + +2009.01.22.130255 [2406] +xorriso/xorrisoburn.c +Adapted to new macro situation in libisoburn + +2009.01.22.143210 [2407] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +New macro isoburn_igopt_aaip controls writing of AAIP info into images + +2009.01.22.143253 [2408] +xorriso/xorrisoburn.c +Making use of new libisoburn macro isoburn_igopt_aaip + +2009.01.22.152252 [2409] +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Restoring ACL only if -acl "on" + +2009.01.22.155049 [2410] +xorriso/xorrisoburn.c +Removing leading slash from -getfacl output of file path + +------------------------------------ cycle - xorriso-0.3.3 - 2009.01.22.155049 +* New option -acl enables ACL import and export + + +2009.01.23.101305 [2411] +xorriso/configure_ac.txt +Promoted standalone libisofs to 0.6.13 + +2009.01.23.102843 [2412] +libisoburn/libisoburn.h +libisoburn/burn_wrap.c +Demanding libisofs 0.6.13 now + +2009.01.23.140824 [2413] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New find tests -has_acl, -has_no_acl, new action getfacl, new option getfacl_r + +23 Jan 2009 [2414] +xorriso/xorriso_eng.html +Updated xorriso web page + +------------------------------------ cycle - xorriso-0.3.3 - 2009.01.23.140824 +* New find tests -has_acl, -has_no_acl , new find action getfacl +* New option -getfacl_r + +2009.01.23.172652 [2415] +configure.ac +Makefile.am +xorriso/configure_ac.txt +xorriso/xorriso_makefile_am.txt +xorriso compilation detects availability of libacl and of Linux listxattr call + +2009.01.23.172757 [2416] +xorriso/xorrisoburn.c +Silenced a FAILURE message with -acl if no image is loaded + +23 Jan 2009 [2417] +xorriso/xorriso_eng.html +Updated xorriso web page + +------------------------------------ cycle - xorriso-0.3.3 - 2009.01.23.172757 + + +24 Jan 2009 [2418] +xorriso/compile_xorriso.sh +Took into respect changed .o file names of libisofs + +2009.01.25.141124 [2424] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +xorriso/xorriso_eng.html +New option -setfacl, -setfacl_r, new -find action setfacl + +------------------------------------ cycle - xorriso-0.3.3 - 2009.01.25.141124 +* New option -setfacl, -setfacl_r, new -find action setfacl + + +25 Jan 2009 [2425] +- test/aaip_0_2.h +- test/aaip_0_2.c +- test/aaip-os-freebsd.c +- test/aaip-os-linux.c +- test/aaip_0_2_test.c +- doc/susp_aaip_0_2.txt +AAIP code now resides in libisofs + +2009.01.26.173254 [2426] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +New macro isoburn_igopt_aaip_susp_1_10 controls writing of AAIP ER and ES + +2009.01.26.173606 [2427] +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Gave user control over isoburn_igopt_aaip_susp_1_10 + +26 Jan 2009 [2428] +xorriso/make_xorriso_standalone.sh +Including doc/susp_aaip_0_2.txt in xorriso-standalone + +2009.01.27.121417 [2432] +libisoburn/libisoburn.h +Mentioned the need for 64 bit file i/o + +2009.01.28.074917 [2434] +xorriso/xorrisoburn.c +Bug fixes and enhancements about "default" ACL + +2009.01.28.114755 [2435] +xorriso/xorrisoburn.c +Bug fixes and enhancements about "default" ACL + +------------------------------------ cycle - xorriso-0.3.3 - 2009.01.28.114755 + + +2009.01.28.190140 [1436] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +Made -getfacl file name escaping more similar to shell command behavior + +2009.01.29.165339 [2437] +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorriso.1 +New option -setfacl_list + +28 Jan 2009 [2438] +xorriso/xorriso_eng.html +Updated xorriso web page + +------------------------------------ cycle - xorriso-0.3.3 - 2009.01.29.165339 +* New option -setfacl_list + +29 Jan 2009 [2439] +xorriso/xorriso_makefile_am.txt +Added aaip-os-dummy.c to xorriso-standalone + +2009.01.29.210606 [2440] +xorriso/xorrisoburn.c +Bug fix: included sys/wait.h rather than wrong wait.h + +2009.01.30.145624 [2442] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +Followed changes in iso_node_*acl_text API + +------------------------------------ cycle - xorriso-0.3.3 - 2009.01.30.200825 + +2009.01.31.101122 [2443] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +Equipped output of lsl with '+' perm if ACL is present + +2009.02.02.134346 [2444] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New options -xattr, -getfattr, find -has_xattr, -has_aaip, -exec getfattr + +2009.02.02.201124 [2445] +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Enabled restoring of xattr + +------------------------------------ cycle - xorriso-0.3.3 - 2009.02.02.201124 +* New options -xattr, -getfattr, find -has_xattr, -has_aaip, -exec getfattr + + +2009.02.03.162440 [2446] +Makefile.am +xorriso/xorriso_makefile_am.txt +Linking with $LIBBURN_ARCH_LIBS to get -lcam on FreeBSD + +------------------------------------ cycle - xorriso-0.3.3 - 2009.02.03.162440 + + +2009.02.04.200055 [2449] +xorriso/xorrisoburn.c +Took into respect eventual resolution of symbolic links + +2009.02.04.200653 [2450] +configure.ac +xorriso/configure_ac.txt +Checking for iconv(3) in separate libiconv (e.g. on FreeBSD) + +2009.02.07.090104 [2453] +xorriso/xorrisoburn.c +Correct group permission bits with -acl off and -extract file that has ACL + +2009.02.07.142605 [2454] +xorriso/xorrisoburn.c +Correct group permission bits with -acl off and disk file that has ACL + +2009.02.08.132116 [2455] +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +First code for -setfattr (have to fix some ACL problems before going on) + +2009.02.08.151354 [2456] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +Displaying "+" with lslx if ACL is detected + +------------------------------------ cycle - xorriso-0.3.3 - 2009.02.08.151354 +------------------------------------ cycle - xorriso-0.3.3 - 2009.02.09.103308 +------------------------------------ cycle - xorriso-0.3.3 - 2009.02.09.170857 + +2009.02.09.185940 [2458] +xorriso/xorriso.c +xorriso/xorrisoburn.c +New options -setfattr, -setfattr_r, new find -exec setfattr + +10 Feb 2009 [2459] +xorriso/xorriso_eng.html +Updated xorriso home page + +2009.02.10.125831 [2460] +xorriso/xorrisoburn.c +Closed a memory leak with unreleased IsoImage in boot image inquiry + +------------------------------------ cycle - xorriso-0.3.3 - 2009.02.10.195106 + +12 Feb 2009 [2461] +xorriso/convert_man_to_html.sh +Adapted html man page generator to textchanges + +2009.02.12.110516 [2462] +xorriso/xorriso.h +xorriso/xorriso.c +New -as mkisofs options --acl and --xattr + +12 Feb 2009 [2463] +xorriso/xorriso.1 +Updated xorriso man page + +2009.02.13.202539 [2464] +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +xorriso/xorriso_eng.html +New option -setfattr_list + +------------------------------------ cycle - xorriso-0.3.3 - 2009.02.13.202539 +* New -as mkisofs options --acl and --xattr +* New option -setfattr_list + + +2009.02.14.133013 [2465] +xorriso/xorriso.c +-as mkisofs --acl and --xattr was not properly recognized + +2009.02.16.082645 [2466] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Took into respect ACL and xattr with -compare and -update + +------------------------------------ cycle - xorriso-0.3.3 - 2009.02.16.082645 + + +2009.02.17.184231 [2467] +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +xorriso/xorriso_eng.html +New option -disk_dev_ino + +2009.02.19.123524 [2475] +libisoburn/isofs_wrap.c +Adapted to removal of Libburn_with_aaiP macro + +2009.02.19.123607 [2476] +xorriso/xorrisoburn.c +Adapted to removal of Libburn_with_aaiP macro + +19 Feb 2009 [2477] +xorriso/configure_ac.txt +Adapted to version leap libisofs-0.6.14 + +------------------------------------ cycle - xorriso-0.3.3 - 2009.02.19.123607 +* New option -disk_dev_ino accelerates incremental backups + + +2009.02.19.183707 [2478] +xorriso/xorriso_private.h +Committing forgotten xorriso_private.h + +20 Feb 2009 [2487] +xorriso/configure_ac.txt +Adapted to version leap libburn-0.6.2 + +2009.02.25.144045 [2496] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +-disk_dev_ino mode ino_only + +2009.02.28.175747 [2502] +configure.ac +Requiring libisofs-0.6.14 now, libburn-0.6.0 still suffices + +2009.02.28.175926 [2503] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +New API function isoburn_igopt_get_data_start() + +2009.02.28.181358 [2504] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New -stream_recording mode with start address, "on" is now 32s + +2009.02.28.181750 [2505] +xorriso/configure_ac.txt +Switched standalone version to libisofs-0.6.15 + +------------------------------------ cycle - xorriso-0.3.3 - 2009.02.28.181750 + +01 Mar 2009 [2506] +svn copy -m Branching for libisoburn release 0.3.4 + http://svn.libburnia-project.org/libisoburn/trunk + http://svn.libburnia-project.org/libisoburn/branches/ZeroThreeFour + +2009.03.01.103001 [2507] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/xorriso.1 +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +xorriso/xorriso_timestamp.h +Version leap to 0.3.4 + +1 Mar 2009 [2508] +xorriso/changelog.txt +Documented changes and release timestamp + +1 Mar 2009 [2509] +README +xorriso/README +Correction about libisofs.so version requirement + +----------------------------------- release - xorriso-0.3.4 - 2009.03.01.103001 +* New option -acl enables ACL import and export +* New options -getfacl, -getfacl_r, -setfacl, -setfacl_r, -setfacl_list +* New find tests -has_acl, -has_no_acl , new find actions getfacl, setfacl +* New option -xattr enables import and export of Extended Attributes +* New options -getfattr, -getfattr_r, -setfattr, -setfattr_r, -setfattr_list +* New find tests -has_xattr, -has_aaip, new find actions getfattr, setfattr +* New -as mkisofs options --acl and --xattr +* New option -disk_dev_ino accelerates incremental backups + + +2009.03.01.113444 [2510] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/xorriso.1 +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +xorriso/xorriso_timestamp.h +Version leap to 0.3.5 + +1 Mar 2009 [2511] +xorriso/changelog.txt +Documented changes and release timestamp + +------------------------------------ cycle - xorriso-0.3.5 - 2009.03.01.113444 + +1 Mar 2009 [2512] +svn move -m 'Promoted branch to tag' + http://svn.libburnia-project.org/libisoburn/branches/ZeroThreeFour + http://svn.libburnia-project.org/libisoburn/tags/ZeroThreeFour + +2009.03.03.103421 [2517] +libisoburn/libisoburn.h +isoburn_igopt_get_data_start() @since 0.3.6 because not announced in 0.3.4 + +2009.03.03.103706 [2518] +xorriso/configure_ac.txt +Making optional use of statvfs() in sg-dummy + +------------------------------------ cycle - xorriso-0.3.5 - 2009.03.03.103706 + +2009.03.05.121700 [2519] +acinclude.m4 +Lifted the ban on operating systems other than Linux and FreeBSD + +------------------------------------ cycle - xorriso-0.3.5 - 2009.03.05.121700 +* Dummy MMC adapter for compilation on systems other than Linux, FreeBSD + + +2009.03.08.140002 [2521] +xorriso/xorriso.c +xorriso/xorrisoburn.c +test/compare_file.c +Reacted on compiler warnings of SchilliX-0.6.7 (based on Solaris 5.11) + + +2009.03.10.092227 [2523] +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Made -compliance old_rr imply -compliance aaip_susp_1_10 + +------------------------------------ cycle - xorriso-0.3.5 - 2009.03.10.092227 + +2009.03.11.170125 [2524] +configure.ac +libisoburn/libisoburn.h +libisoburn/isoburn.c +Requiring libisofs-0.6.16 now + +2009.03.11.170236 [2525] +xorriso/configure_ac.txt +Adapted xorriso-standalone to version leap libisofs-0.6.16 + +11 Mar 2009 [2526] +xorriso/xorriso_eng.html +Mentioned bug fixes in libisofs + +11 Mar 2009 [2527] +xorriso/xorriso.1 +Minor changes in xorriso man page + +------------------------------------ cycle - xorriso-0.3.5 - 2009.03.11.170236 + + +2009.03.12.141647 [2528] +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Made -compliance old_rr the default + +2009.03.13.150731 [2536] +xorriso/xorrisoburn.c +Defaulting -stream_recording "data" to "100m" + +2009.03.13.150838 [2537] +xorriso/configure_ac.txt +Adapted xorriso-standalone to version leap libburn-0.6.5 + +2009.03.14.113811 [2539] +xorriso/xorriso.c +Fixed the inappropriate refusal on paths like /u/test/../.. + +2009.03.14.115711 [2540] +configure.ac +libisoburn/libisoburn.h +Requiring libburn-0.6.4 now + +------------------------------------ cycle - xorriso-0.3.5 - 2009.03.14.115711 +* default of -compliance has been changed to "old_rr", new rule "new_rr" + +16 Mar 2009 [2541] +svn copy -m "Branching for libisoburn release 0.3.6" \ + http://svn.libburnia-project.org/libisoburn/trunk \ + http://svn.libburnia-project.org/libisoburn/branches/ZeroThreeSix + +2009.03.16.090001 [2542] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +xorriso/xorriso_timestamp.h +Version leap to libisoburn-0.3.6 + +16 Mar 2009 [2543] +xorriso/changelog.txt +Documented changes and release timestamp + +16 Mar 2009 [2544] +configure.ac +Adjusted forgotten version number + +----------------------------------- release - xorriso-0.3.6 - 2009.03.16.090001 +* Dummy MMC adapter for compilation on systems other than Linux, FreeBSD +* Default of -compliance has been changed to "old_rr", new rule "new_rr" +* New -stream_recording modes with start address or "data". "on" is now 32s. + + +2009.03.16.112837 [2545] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +xorriso/xorriso_timestamp.h +Version leap to libisoburn-0.3.7 + +16 Mar 2009 [2546] +xorriso/changelog.txt +Documented changes and release timestamp + +17 Mar 2009 [2548] +svn move -m 'Promoted branch to tag' \ + http://svn.libburnia-project.org/libisoburn/branches/ZeroThreeSix \ + http://svn.libburnia-project.org/libisoburn/tags/ZeroThreeSix + +------------------------------------ cycle - xorriso-0.3.7 - 2009.03.16.112837 + + +2009.03.18.103858 [2550] +configure.ac +acinclude.m4 +Makefile.am +Get on FreeBSD pkgconfigdir=.../libdata , on Linux and others: .../lib + +2009.03.18.104037 [2551] +xorriso/configure_ac.txt +xorriso/xorriso_makefile_am.txt +Adapted xorriso-standalone to version leap libisofs-0.6.17 and FreeBSD libdata + +18 Mar 2009 [2552] +configure.ac +Removed useless libisoburn configure options --enable-libacl --enable-xattr + +2009.03.19.172806 [2555] +xorriso/xorriso.c +Unified -status filtering decision + +2009.03.20.192910 [2557] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/isofs_wrap.c +New API functions isoburn_ropt_[sg]et_auto_incharset() + +2009.03.20.193334 [2558] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -auto_charset based on xattr "isofs.cs" + +------------------------------------ cycle - xorriso-0.3.7 - 2009.03.21.131424 +* New option -auto_charset based on xattr "isofs.cs" + + +22 Mar 2009 [2559] +xorriso/xorriso.1 +Clarification about -auto_charset pitfalls + +2009.03.22.090232 [2560] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Stuffed memory leaks on -commit and loading of El Torito records + +2009.03.29.164336 [2561] +configure.ac +Revoked revision 2552. Dynamic xorriso did not get linked with -lacl any more. + +2009.03.29.164411 [2562] +libisoburn/libisoburn.h +libisoburn now demands libisofs-0.6.17 + +2009.03.29.164703 [2563] +xorriso/compile_xorriso.sh +xorriso/xorriso_makefile_am.txt +Adapted to new libisofs feature iso_file_add_external_filter() + +2009.03.29.164931 [2564] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Experimental -find action -exec set_filter with some hardcoded filter commands + +2009.04.02.162530 [2565] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +xorriso/xorriso_eng.html +New options -external_filter , -unregister_filter, -set_filter , -set_filter_r + +------------------------------------ cycle - xorriso-0.3.7 - 2009.04.02.162530 +* New options -external_filter , -unregister_filter, -set_filter , -set_filter_r + + +2009.04.03.172034 [2566] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Fixed a potential blind spot of 1 second in -disk_dev_ino comparison + +2009.04.04.082636 [2567] +xorriso/xorrisoburn.c +Fixed a bug with the error message about external filters and setuid + +2009.04.04.144009 [2568] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -close_filter_list + +2009.04.04.144241 [2569] +configure.ac +Makefile.am +README +xorriso/configure_ac.txt +xorriso/xorriso_makefile_am.txt +xorriso/compile_xorriso.sh +xorriso/README +configure options to control availability of external filters in xorriso + +2009.04.05.110534 [2570] +xorriso/xorriso.c +Reporting number of processed filters with -set_filter and -set_filter_r + +2009.04.05.110652 [2571] +xorriso/xorrisoburn.c +Fixed a bug about detection of failure with -set_filter + +2009.04.05.131536 [2572] +xorriso/xorriso.c +Included sys/select.h as prescribed by POSIX and Linux, FreeBSD man pages + +2009.04.05.143043 [2573] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorriso.1 +New -osirrox mode "banned" + +5 Apr 2009 [2574] +xorriso/xorriso_eng.html +Updated xorriso web page + +------------------------------------ cycle - xorriso-0.3.7 - 2009.04.05.143043 +* New option -close_filter_list +* New -osirrox mode "banned" + + +2009.04.06.100802 [2575] +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Suffix rollback with -set_filter --remove-all-filters + +2009.04.06.132007 [2576] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New options -show_stream, -show_stream_r, -exec show_stream + +2009.04.06.143109 [2577] +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Changed appearance of -show_stream, fixed bug introduced with rev 2575 + +2009.04.06.161541 [2578] +xorriso/xorrisoburn.c +Fixed bug introduced with 2575 + +------------------------------------ cycle - xorriso-0.3.7 - 2009.04.06.161541 +* New options -show_stream, -show_stream_r, new -find -exec show_stream + +2009.04.07.120250 [2579] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New -find tests -has_filter, -has_no_filter + +2009.04.07.122117 [2580] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Removed some unused old code branches + +2009.04.10.102558 [2581] +configure.ac +Makefile.am +xorriso/configure_ac.txt +xorriso/xorriso_makefile_am.txt +xorriso/compile_xorriso.sh +Took into respect optional libz dependency of libisofs + +2009.04.10.103130 [2582] +xorriso/xorrisoburn.c +Introduced builtin filters --zisofs and --zisofs-decode + +11 Apr 2009 [2583] +xorriso/make_xorriso_standalone.sh +Included a copy of doc/zisofs_format.txt in xorriso-standalone + +2009.04.11.125331 [2584] +xorriso/xorrisoburn.c +Adjustments with filter --zisofs-decode + +2009.04.11.172644 [2585] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -zisofs, builtin filters --zisofs and --zisofs-decode + +12 Apr 2009 [2586] +xorriso/xorriso_eng.html +Updated xorriso web page + +------------------------------------ cycle - xorriso-0.3.7 - 2009.04.12.142252 +* New option -zisofs, builtin filters --zisofs and --zisofs-decode + + +14 Apr 2009 [2588] +README +xorriso/README +Updated README texts of libisoburn and xorriso + +2009.04.14.092306 [2589] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New -zisofs option by_magic=on + +------------------------------------ cycle - xorriso-0.3.7 - 2009.04.14.092306 + +2009.04.15.071944 [2590] +xorriso/compile_xorriso.sh +xorriso/xorriso_makefile_am.txt +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Adopted new libisofs filter module gzip.c, builtin filters --gzip, --gunzip + +2009.04.15.185131 [2591] +libisoburn/isofs_wrap.c +xorriso/xorrisoburn.c +Removed dependency on Libisofs_has_auto_input_charseT + +2009.04.15.185238 [2592] +configure.ac +libisoburn/libisoburn.h +Requiring libisofs-0.6.18 now + +2009.04.15.185359 [2593] +xorriso/configure_ac.txt +Adapted xorriso-standalone to version leap libisofs-0.6.18 + +2009.04.16.145617 [2594] +xorriso/make_xorriso_standalone.sh +xorriso/xorriso_makefile_am.txt +Fixed bugs with rarely used make dist + +2009.04.18.090616 [2596][2597] +xorriso/configure_ac.txt +Adapted xorriso-standalone to version leap libisofs-0.6.19 + +------------------------------------ cycle - xorriso-0.3.7 - 2009.04.18.090616 + +2009.04.18.120001 [2598] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +xorriso/xorriso_timestamp.h +Version leap to libisoburn-0.3.8 + +18 Apr 2009 [2599][2600] +xorriso/xorriso.1 +Last minute correction in xorriso man page + +18 Apr 2009 [2601] +xorriso/changelog.txt +Documented changes and release timestamp + +----------------------------------- release - xorriso-0.3.8 - 2009.04.18.120001 +* New options -set_filter , -set_filter_r, -find -exec set_filter +* New option -zisofs, builtin filters --zisofs , --gzip , --gunzip +* New options -external_filter , -unregister_filter, -close_filter_list, +* New options -show_stream, -show_stream_r +* New -osirrox mode "banned" +* New option -auto_charset based on xattr "isofs.cs" + + +2009.04.18.150555 [2602] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso_private.h +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +xorriso/xorriso_timestamp.h +Version leap to libisoburn-0.3.9 + +18 Apr 2009 [2603] +xorriso/changelog.txt +Documented changes and release timestamp + +------------------------------------ cycle - xorriso-0.3.9 - 2009.04.18.150555 + +19 Apr 2009 [2608] +svn move -m 'Promoted branch to tag' \ + http://svn.libburnia-project.org/libisoburn/branches/ZeroThreeEight \ + http://svn.libburnia-project.org/libisoburn/tags/ZeroThreeEight + +2009.04.21.173600 [2612] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Enhanced -find testing by operators -not, -or, -and, (, ), -if, -else, -endif + +2009.04.21.184214 [2613] +xorriso/xorriso.c +Allowed implicit -and operator with -not, -if and -sub + +22 Apr 2009 [2614] +xorriso/xorriso_eng.html +Updated xorriso web page + +------------------------------------ cycle - xorriso-0.3.9 - 2009.04.21.184214 +* Operators with option -find : -not, -or, -and, (, ), -if, -then, -else + + +2009.04.22.173603 [2615] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/burn_wrap.c +New API call isoburn_toc_track_get_emul() + +2009.04.22.173648 [2616] +xorriso/xorrisoburn.c +Made use of new libisoburn call to accelerate option -toc for large TOC + +2009.04.23.103301 [2617] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New -find tests -wholename, -prune + +2009.04.25.160022 [2618] +libisoburn/burn_wrap.c +Used isoburn_toc_track_get_emul() in isoburn_set_msc1() + +2009.04.25.162210 [2619] +xorriso/xorrisoburn.c +Moved call of isoburn_set_msgs_submit() to Xorriso_startup_libraries() + +2009.04.25.162858 [2620] +libisoburn/burn_wrap.c +Issueing pacifier messages from within isoburn_set_msc1() + +------------------------------------ cycle - xorriso-0.3.9 - 2009.04.25.162858 +* New -find tests -wholename, -prune + + +2009.05.06.173600 [2626] +xorriso/xorrisoburn.c +Bug fix: SIGSEGV with option -status and no search string + +2009.05.06.174222 [2627] +xorriso/xorrisoburn.c +Bug fix: -load volid did not perform pattern search + +2009.05.08.073642 [2638] +xorriso/configure_ac.txt +Adapted xorriso-standalone to version leap libburn-0.6.7 + +2009.05.09.201241 [2639] +libisoburn/libisoburn.h +libisoburn/isoburn.h +libisoburn/isoburn.c +libisoburn/isofs_wrap.c +New API options isoburn_ropt_noino and isoburn_igopt_hardlinks + +2009.05.09.201742 [2640] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New option -hardlinks + +2009.05.14.082045 [2641] +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Enhanced option -extract_cut for handling filtered files + +2009.05.16.165616 [2642] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +LBA sorted processing of -compare_r and -update_r for smoother MMC reading + +2009.05.16.165940 [2643] +xorriso/xorrisoburn.c +Disabled use of iso_tree_add_new_symlink() in favor of iso_tree_add_new_node() + +2009.05.17.115101 [2644] +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +New pseudo test with -find : -sort_lba which is actually an option + +2009.05.26.140055 [2647] +xorriso/xorrisoburn.h +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Enabled -hardlinks for options -extract, -extract_l and -cp*x + +2009.05.26.142912 [2648] +xorriso/xorriso.c +Revoked LBA sorted reading with -compare_r. It was ugly. + +------------------------------------ cycle - xorriso-0.3.9 - 2009.05.26.172355 +Bug fix: SIGSEGV with option -status and no search string +Bug fix: -load volid did not perform pattern search +New option -hardlinks +Improved reading performance with -update_r and -extract + + +2009.05.29.110831 [2649] +xorriso/xorriso.c +xorriso/xorriso.1 +xorriso/xorriso_eng.html +New option -for_backup as shortcut for -acl -xattr -hardlinks + +2009.05.29.162300 [2650] +xorriso/xorrisoburn.c +Avoided unnecessary sorting during -extract + +2009.05.30.161808 [2561] +xorriso/xorriso.c +Avoided unconditional output of -hardlinks with option -status + +2009.05.31.100140 [2652] +configure.ac +libisoburn/libisoburn.h +Requiring libisofs-0.6.20 now + +2009.05.31.100315 [2653] +xorriso/configure_ac.txt +Adapted xorriso-standalone to version leap libisofs-0.6.20 + +2009.05.31.185819 [2654] +xorriso/configure_ac.txt +Adapted xorriso-standalone to version leap libisofs-0.6.21 + +13 Jun 2009 [2668] +xorriso/configure_ac.txt +xorriso/xorriso_makefile_am.txt +xorriso/make_xorriso_standalone.sh +Removed xorriso.pc.in from xorriso-standalone tarball + +2009.06.15.121525 [2670] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +With -update_r : detecting hardlink splits and fusions on disk + +2009.06.20.063853 [2671] +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +Wider scope of hardlink reconstruction with extract operations + +2009.06.22.112850 [2672] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorrisoburn.c +xorriso/xorriso.1 +Gave up risky direct update of hardlink siblings + +2009.06.23.065744 [2673] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c ++ xorriso/makefile_libxorriso_am.txt +Introduced alternative Makefile.am for libxorriso production + +2009.06.23.070934 [2674] +xorriso/xorriso_private.h +Added missing function declaration + +2009.06.23.123147 [2675] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +Removed from xorriso main() any dependency on non-API features + +2009.06.23.133210 [2676] +xorriso/xorriso.h +xorriso/xorriso_private.h +xorriso/xorriso.c +Rough test for compile time and run time libxorriso version mismatches + +2009.06.23.164351 [2677] +xorriso/xorriso.c +xorriso/xorrisoburn.c +Deprecated -hardlinks modes "start_update", "end_update" for "perform_update" + +23 Jun 2009 [2678] +xorriso/xorriso.1 +Updated xorriso man page + +2009.06.24.133521 [2679] +xorriso/xorriso.c +Reverted order of memorized hardlink update parameters + +2009.06.25.125048 [2680] +libisoburn/burn_wrap.c +Bug fix: Copies of overwriteable media onto sequential were mistaken in ROM drives + +2009.06.27.112408 [2681] +xorriso/xorriso_private.h +xorriso/xorriso.c +xorriso/xorrisoburn.c +xorriso/xorriso.1 +With -extract : made hardlink registration combinable with sort_lba + +------------------------------------ cycle - xorriso-0.3.9 - 2009.06.27.112408 +New option -for_backup as shortcut for -acl -xattr -hardlinks +Bug fix: Copies of overwriteable media on sequential were mistaken in ROM drives + +28 Jun 2009 [2681] +svn copy -m "Branching for libisoburn release 0.4.0" \ + http://svn.libburnia-project.org/libisoburn/trunk \ + http://svn.libburnia-project.org/libisoburn/branches/ZeroFourZero + +2009.06.28.090001 [2683] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +xorriso/xorriso_timestamp.h +Version leap to libisoburn-0.4.0 + +28 Jun 2009 [2684] +xorriso/changelog.txt +Documented changes and release timestamp + +----------------------------------- release - xorriso-0.4.0 - 2009.06.28.090001 +* New option -hardlinks +* Improved reading performance with -update_r and -extract +* New option -for_backup as shortcut for -acl -xattr -hardlinks +* Operators with option -find : -not, -or, -and, (, ), -if, -then, -else +* New -find tests -wholename, -prune +* Bug fix: SIGSEGV with option -status and no search string +* Bug fix: -load volid did not perform pattern search +* Bug fix: Copies of overwriteable media on sequential were mistaken in ROM drives + +2009.06.28.100124 [2685] +configure.ac +README +libisoburn/libisoburn.h +xorriso/README +xorriso/xorriso.h +xorriso/xorriso.c +xorriso/xorrisoburn.h +xorriso/xorriso_eng.html +xorriso/make_xorriso_standalone.sh +xorriso/configure_ac.txt +xorriso/xorriso_timestamp.h +Version leap to libisoburn-0.4.1 + + [] +xorriso/changelog.txt +Documented changes and release timestamp + +------------------------------------ cycle - xorriso-0.4.1 - 2009.06.28.100124 + +------------------------------------ cycle - xorriso-0.4.1 - +------------------------------------ cycle - xorriso-0.4.1 - + +=============================================================================== + TODO +=============================================================================== + +------------------------------------------------- bugs + +- what about split files and hard links ? + +- xorriso -as cdrecord in rare cases reports intermediate "X of X MB" +xorriso : UPDATE : 3671 MB written (fifo 94%) [buf 100%] 2.3x. +xorriso : UPDATE : 3680 of 3680 MB written (fifo 87%) [buf 100%] 2.3x. +xorriso : UPDATE : 3691 MB written (fifo 78%) [buf 100%] 2.3x. + Direct reason: + burn_drive_get_status(drive, &progress); + if(progress.sector<=progress.sectors) + sprintf(xorriso->info_text, "%4d of %4d MB written", + So this has to be examined in libburn. + +------------------------------------------------- important + +- during -update* + - what about differently filtered streams ? + It is not wrong but a waste to update them as siblings. + + +- >>> what about stat.st_nlink ? + - Must it be maintained for directories (i.e. nlink == files + 2)? + There are indications that it should either give the number of subdirs + (including . and ..) or be 1 + - It would be nice if xorriso -lsl could display the actual nlink number. + But that is not easy with -map /a /x -map /a /y . One would need a fast + lookup of existing inode tuples. I.e. a permanent RBTree of IsoNode. + Current is a sorted array of Ecma119Node, because Ecma119Node can record + the final inode number in the emerging image easily. + ??? Should one unite IsoNode and Ecma119 node ??? + +- libisofs call to create a hard link ? + +- sudo and setuid chapter in man page + ? option -sudo_aware + +??? move suffix processing into libisofs ? + (currently the suffice are already stored in the filter chain) + Can only be done if renaming is made safe with any open IsoDirIter. + + +------------------------------------------------- development + +- Replace Libisofs_new_fs_image_inO by Libisofs_hardlink_prooF + and make the latter unconditional. + +- Special pseudo ACL: "--remove-default" + +- libisofs , libburn , own system adapter ? : + Needed is a system dependend facility: dev_t <-> major, minor + +- ??? -getfaclx , -getfattrx + +- -load option to ignore existing images + +- image sort weight control: + isoburn_igopt_set_sort_files iso_node_set_sort_weight + +- random access read and write option + +- option to patch the mount image size and location on overwriteables + +- change -check_media what=disc to libburn disc rather than libisoburn + (seems to need new API capabilities of libburn) + +??? Clarify handling of links in ISO and on disk during restore + +> Relative addressing and pattern matching : + iso_rr_pattern on + cd /u/FERTIG + lsd nonexist/.. + +- perform any long lasting operation in separate threads while + the main thread cares for user and message queues. + +- Introduce an interrupt key for dialog + >>> but how without disturbing readline ? + +- regularly do valgrind check for memory leaks + +- ??? http://scan.coverity.com/faq.html + +- ??? curb depth of tree traversal recursion + +- eject a not yet aquired device (e.g. after modifying commit) + +- -cd[ix] and pattern + +- memory curb for image model + + +> Make transactional the tree deletions meant for replacing + + +------------------------------------------------- libisofs wishes + +------ problem fixes : + +- the error handling system should be comprehensively documented + and eventually rectified where needed. + +------ feature enhancements : + +- isohybrid + - as of syslinux-3.81pre10/utils/isohybrid.in : + - new signature {0xf7, 0xe3, 0xef, 0x0d} + - read $id from previous session: byte 440, 4 bytes, + if not {0,0,0,0} write the same byte string to new MBR byte 440 + - user adjustable parameters + - $pentry {1..4} = 1 + - $fstype {0...255} = 0x17 + - $offset {0...64} = 0 + - $h {1...256} = 64 + - $s {1...63} = 32 + - $id {0...0xffffffff] + - $hd0 {0...2} = 0 + - $partok {0...1} = 0 + + +- File checksums as backpack and as xattr values. + Problem: If they are scattered over the data section then they will cause + a lot of random access and thus be slow with BD. They need to be buffered + in memory as zinfo and written all together after data section. + +- Image checksum tag in the last data blocks of an image. + A data file entry should point to that block. + +- A dummy option in IsoWriteOpts which causes iso_image_create_burn_source() + to end before actually data get written. (For -print_size) + +- Re-use unchanged sub trees in the previous image in order to + reduce the session overhead. + + + +=============================================================================== + This is the dirty end of the todo list. + The recent changelog entries are above the headline "TODO". +=============================================================================== diff --git a/libisoburn/branches/ZeroFourTwo/xorriso/compile_xorriso.sh b/libisoburn/branches/ZeroFourTwo/xorriso/compile_xorriso.sh new file mode 100755 index 00000000..1cfec181 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/xorriso/compile_xorriso.sh @@ -0,0 +1,173 @@ +#!/bin/sh + +# compile_xorriso.sh +# Copyright 2005 - 2009 Thomas Schmitt, scdbackup@gmx.net, GPL version 2 +# +# Not intended for general use in production installations ! +# Rather use: ./bootstrap ; ./configure ; make +# +# This is a development tool which expects a special setup of directories +# on a Linux system (e.g. SuSE 10.2). +# It is to be executed in a common parent of the directories given with +# $isofs $isoburn $burn $xorr + +isofs=./nglibisofs-develop/libisofs/libisofs_libisofs_la- +isofs_filter=./nglibisofs-develop/libisofs/filters/libisofs_libisofs_la- +burn=./libburn-develop/libburn +isoburn=./libisoburn-develop/libisoburn +xorr=./libisoburn-develop/xorriso + +debug_opts="-O2" +def_opts="-DXorriso_allow_external_filterS" +largefile_opts="-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1" +do_strip=0 +static_opts= +warn_opts="-Wall" +nglibisofs=1 +def_libreadline="-DXorriso_with_readlinE" +link_libreadline="-lreadline" + +for i in "$@" +do + if test "$i" = "-do_diet" + then + def_opts="$def_opts -DXorriso_no_helP" + warn_opts= + elif test "$i" = "-do_strip" + then + do_strip=1 + elif test "$i" = "-g" + then + debug_opts="-g -O0" + elif test "$i" = "-no_libreadline" + then + def_libreadline="" + link_libreadline="" + elif test "$i" = "-help" -o "$i" = "--help" -o "$i" = "-h" + then + echo \ + "$xorr/compile_xorriso.sh : to be executed above top level directories" + echo "Options:" + echo " -no_libreadline do not compile for and link with libreadline." + echo " -do_diet produce capability reduced lean version." + echo " -do_strip apply program strip to compiled programs." + echo " -g produce debuggable programm." + echo " -static compile with cc option -static." + exit 0 + elif test "$i" = "-static" + then + static_opts="-static" + fi +done + +libisofs= +libisofs="$libisofs $isofs"buffer.o +libisofs="$libisofs $isofs"builder.o +libisofs="$libisofs $isofs"data_source.o +libisofs="$libisofs $isofs"ecma119.o +libisofs="$libisofs $isofs"ecma119_tree.o +libisofs="$libisofs $isofs"eltorito.o +libisofs="$libisofs $isofs"filesrc.o +libisofs="$libisofs $isofs"fs_image.o +libisofs="$libisofs $isofs"fs_local.o +libisofs="$libisofs $isofs"fsource.o +libisofs="$libisofs $isofs"image.o +libisofs="$libisofs $isofs"iso1999.o +libisofs="$libisofs $isofs"joliet.o +libisofs="$libisofs $isofs"libiso_msgs.o +libisofs="$libisofs $isofs"messages.o +libisofs="$libisofs $isofs"node.o +libisofs="$libisofs $isofs"rockridge.o +libisofs="$libisofs $isofs"rockridge_read.o +libisofs="$libisofs $isofs"stream.o +libisofs="$libisofs $isofs"tree.o +libisofs="$libisofs $isofs"util.o +libisofs="$libisofs $isofs"util_htable.o +libisofs="$libisofs $isofs"util_rbtree.o +libisofs="$libisofs $isofs"system_area.o +libisofs="$libisofs $isofs"make_isohybrid_mbr.o +libisofs="$libisofs $isofs"aaip_0_2.o +libisofs="$libisofs $isofs"filter.o +libisofs="$libisofs $isofs_filter"external.o +libisofs="$libisofs $isofs_filter"zisofs.o +libisofs="$libisofs $isofs_filter"gzip.o +libisofs="$libisofs $isofs"md5.o + +echo "Version timestamp : $(sed -e 's/#define Xorriso_timestamP "//' -e 's/"$//' "$xorr"/xorriso_timestamp.h)" + +date -u '+#define Xorriso_build_timestamP "%Y.%m.%d.%H%M%S"' >"$xorr"/xorriso_buildstamp.h +echo "Build timestamp : $(sed -e 's/#define Xorriso_build_timestamP "//' -e 's/"$//' "$xorr"/xorriso_buildstamp.h)" + +echo "compiling program $xorr/xorriso.c $static_opts $debug_opts $def_opts" +cc -I. -DXorriso_with_maiN $def_libreadline \ + $warn_opts \ + $static_opts \ + $debug_opts \ + $def_opts \ + $largefile_opts \ + \ + -o "$xorr"/xorriso \ + \ + "$xorr"/xorriso.c \ + \ + "$xorr"/xorrisoburn.c \ + \ + "$burn"/async.o \ + "$burn"/debug.o \ + "$burn"/drive.o \ + "$burn"/file.o \ + "$burn"/init.o \ + "$burn"/options.o \ + "$burn"/source.o \ + "$burn"/structure.o \ + \ + "$burn"/sg.o \ + "$burn"/write.o \ + "$burn"/read.o \ + "$burn"/libdax_audioxtr.o \ + "$burn"/libdax_msgs.o \ + "$burn"/cleanup.o \ + \ + "$burn"/mmc.o \ + "$burn"/sbc.o \ + "$burn"/spc.o \ + "$burn"/util.o \ + \ + "$burn"/sector.o \ + "$burn"/toc.o \ + \ + "$burn"/crc.o \ + "$burn"/lec.o \ + \ + "$isoburn"/isoburn.o \ + "$isoburn"/burn_wrap.o \ + "$isoburn"/data_source.o \ + "$isoburn"/isofs_wrap.o \ + \ + $libisofs \ + \ + $link_libreadline \ + \ + -lpthread \ + -lacl \ + -lz + + ret=$? + if test "$ret" = 0 + then + dummy=dummy + else + echo >&2 + echo "+++ FATAL : Compilation of xorriso failed" >&2 + echo >&2 + exit 1 + fi + + +if test "$do_strip" = 1 +then + echo "stripping result $xorr/xorriso" + strip "$xorr"/xorriso +fi + +echo 'done.' diff --git a/libisoburn/branches/ZeroFourTwo/xorriso/configure_ac.txt b/libisoburn/branches/ZeroFourTwo/xorriso/configure_ac.txt new file mode 100644 index 00000000..ba539e87 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/xorriso/configure_ac.txt @@ -0,0 +1,215 @@ +AC_INIT([xorriso], [0.4.1], [http://libburnia-project.org]) +AC_PREREQ([2.50]) +dnl AC_CONFIG_HEADER([config.h]) + +AC_CANONICAL_HOST +AC_CANONICAL_TARGET + +AM_INIT_AUTOMAKE([subdir-objects]) + +BURN_MAJOR_VERSION=0 +BURN_MINOR_VERSION=7 +BURN_MICRO_VERSION=1 +AC_SUBST(BURN_MAJOR_VERSION) +AC_SUBST(BURN_MINOR_VERSION) +AC_SUBST(BURN_MICRO_VERSION) + +LIBISOFS_MAJOR_VERSION=0 +LIBISOFS_MINOR_VERSION=6 +LIBISOFS_MICRO_VERSION=23 +AC_SUBST(LIBISOFS_MAJOR_VERSION) +AC_SUBST(LIBISOFS_MINOR_VERSION) +AC_SUBST(LIBISOFS_MICRO_VERSION) + +dnl The API version codes are defined in libisoburn/libisoburn.h +dnl #define isoburn_header_version_* + + +AC_PREFIX_DEFAULT([/usr/local]) +test "$prefix" = "NONE" && prefix=$ac_default_prefix + +AM_MAINTAINER_MODE + +AM_PROG_CC_C_O +AC_C_CONST +AC_C_INLINE +AC_C_BIGENDIAN + +dnl Large file support +AC_SYS_LARGEFILE +AC_FUNC_FSEEKO +AC_CHECK_FUNC([fseeko]) +if test ! $ac_cv_func_fseeko; then + AC_ERROR([Libburn requires largefile support.]) +fi + +dnl If iconv(3) is in an extra libiconv, then it gets added to variable LIBS. +dnl If not, then no -liconv will be added. +AC_CHECK_LIB(iconv, iconv, , ) +dnl GNU iconv has no function iconv() but libiconv() and a macro iconv() +AC_CHECK_LIB(iconv, libiconv, , ) + +AC_PROG_LIBTOOL +AC_SUBST(LIBTOOL_DEPS) +LIBTOOL="$LIBTOOL --silent" + +AC_PROG_INSTALL + +AC_CHECK_HEADERS() + +AC_CHECK_MEMBER([struct tm.tm_gmtoff], + [AC_DEFINE(HAVE_TM_GMTOFF, 1, + [Define this if tm structure includes a tm_gmtoff entry.])], + , + [#include ]) + +dnl Check if non standard timegm() function is available +AC_CHECK_DECL([timegm], + [AC_DEFINE(HAVE_TIMEGM, 1, [Define this if timegm function is available])], + , + [#include ]) + +dnl Check if non standard eaccess() function is available +AC_CHECK_DECL([eaccess], + [AC_DEFINE(HAVE_EACCESS, 1, [Define this if eaccess function is available])], + , + [#include ]) + +THREAD_LIBS=-lpthread +AC_SUBST(THREAD_LIBS) + +TARGET_SHIZZLE +AC_SUBST(ARCH) +AC_SUBST(LIBBURNIA_PKGCONFDIR) +AC_SUBST(LIBBURN_ARCH_LIBS) + + +dnl ts A90303 +dnl Check the preconditions for using statvfs() in sg-dummy +dnl (sg-linux and sg-freebsd use statvfs() unconditionally) +STATVFS_DEF=-DLibburn_os_has_statvfS +AC_CHECK_HEADER(sys/statvfs.h, X=, STATVFS_DEF=) +AC_CHECK_FUNC([statvfs], X=, STATVFS_DEF=) +CFLAGS="$CFLAGS $STATVFS_DEF" + + +dnl Add compiler-specific flags + +dnl See if the user wants aggressive optimizations of the code +AC_ARG_ENABLE(debug, +[ --enable-debug Disable aggressive optimizations [default=yes]], + , enable_debug=yes) +if test x$enable_debug != xyes; then + if test x$GCC = xyes; then + CFLAGS="$CFLAGS -O3" + CFLAGS="$CFLAGS -fexpensive-optimizations" + fi + CFLAGS="$CFLAGS -DNDEBUG" +else + if test x$GCC = xyes; then + CFLAGS="$CFLAGS -g -pedantic -Wall" + fi + CFLAGS="$CFLAGS -DDEBUG" +fi + + +dnl Determine target directory for libisoburn-*.pc +dnl Important: Must be performed _after_ TARGET_SHIZZLE +dnl +LIBBURNIA_SET_PKGCONFIG + + +AC_ARG_ENABLE(libreadline, +[ --enable-libreadline Enable use of libreadline by xorriso, default=yes], + , enable_libreadline=yes) +if test x$enable_libreadline = xyes; then +dnl Check whether there is readline-devel and readline-runtime. +dnl If not, erase this macro which would enable use of readline(),add_history() + READLINE_DEF="-DXorriso_with_readlinE" +dnl The empty yes case obviously causes -lreadline to be linked + AC_CHECK_HEADER(readline/readline.h, AC_CHECK_LIB(readline, readline, , READLINE_DEF= ), READLINE_DEF= ) +dnl The X= in the yes case prevents that -lreadline gets linked twice + AC_CHECK_HEADER(readline/history.h, AC_CHECK_LIB(readline, add_history, X= , READLINE_DEF= ), READLINE_DEF= ) +else + READLINE_DEF= +fi +AC_SUBST(READLINE_DEF) + + +AC_ARG_ENABLE(libacl, +[ --enable-libacl Enable use of libacl by libisofs, default=yes], + , enable_libacl=yes) +if test x$enable_libacl = xyes; then +dnl Check whether there is libacl-devel and libacl-runtime. +dnl If not, erase this macro which would enable use of acl_to_text and others + LIBACL_DEF="-DLibisofs_with_aaip_acL" +dnl The empty yes case obviously causes -lacl to be linked + AC_CHECK_HEADER(sys/acl.h, AC_CHECK_LIB(acl, acl_to_text, , LIBACL_DEF= ), LIBACL_DEF= ) +else + LIBACL_DEF= +fi +AC_SUBST(LIBACL_DEF) + + +AC_ARG_ENABLE(xattr, +[ --enable-xattr Enable use of xattr by libisofs, default=yes], + , enable_xattr=yes) +if test x$enable_xattr = xyes; then +dnl Check whether there is the header for Linux xattr. +dnl If not, erase this macro which would enable use of listxattr and others + XATTR_DEF="-DLibisofs_with_aaip_xattR" + AC_CHECK_HEADER(attr/xattr.h, AC_CHECK_LIB(c, listxattr, X= , XATTR_DEF= ), XATTR_DEF= ) +else + XATTR_DEF= +fi +AC_SUBST(XATTR_DEF) + + +AC_ARG_ENABLE(zlib, +[ --enable-zlib Enable use of zlib by libisofs, default=yes], + , enable_zlib=yes) +if test x$enable_zlib = xyes; then +dnl Check whether there is the header for zlib. +dnl If not, erase this macro which would enable use of compress2() and others. +dnl The empty parameter after "compress2" causes -lz. + ZLIB_DEF="-DLibisofs_with_zliB" + AC_CHECK_HEADER(zlib.h, AC_CHECK_LIB(z, compress2, , ZLIB_DEF= ), ZLIB_DEF= ) +else + ZLIB_DEF= +fi +AC_SUBST(ZLIB_DEF) + + +AC_ARG_ENABLE(external-filters, +[ --enable-external-filters Enable use of external filter programs by xorriso, default=yes], + , enable_external_filters=yes) +if test x"$enable_external_filters" = xyes; then + EXTF_DEF="-DXorriso_allow_external_filterS" + echo "enabled xorriso external filter programs" +else + EXTF_DEF= + echo "disabled xorriso external filter programs" +fi +AC_SUBST(EXTF_DEF) + +AC_ARG_ENABLE(external-filters-setuid, +[ --enable-external-filters-setuid Enable xorriso external filter programs under setuid, default=no], + , enable_external_filters_setuid=no) +if test x$enable_external_filters_setuid = xyes; then + EXTF_SUID_DEF="-DXorriso_allow_extf_suiD" + echo "enabled xorriso external filter programs under setuid" +else + EXTF_SUID_DEF= + echo "disabled xorriso external filter programs under setuid" +fi +AC_SUBST(EXTF_SUID_DEF) + + + +AC_CONFIG_FILES([ + Makefile + version.h + ]) +AC_OUTPUT + +# xorriso.pc diff --git a/libisoburn/branches/ZeroFourTwo/xorriso/convert_man_to_html.sh b/libisoburn/branches/ZeroFourTwo/xorriso/convert_man_to_html.sh new file mode 100755 index 00000000..1a8bf42a --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/xorriso/convert_man_to_html.sh @@ -0,0 +1,113 @@ +#!/bin/sh + +# +# convert_man_to_html.sh - ts A80118 +# +# Generates a HTML version of man page xorriso.1 +# +# To be executed in the libisoburn toplevel directory (eg. ./libisoburn-0.1.0) +# + +# set -x + +man_dir=$(pwd)"/xorriso" +export MANPATH="$man_dir" +manpage="xorriso" +raw_html=$(pwd)/"xorriso/raw_man_1_xorriso.html" +htmlpage=$(pwd)/"xorriso/man_1_xorriso.html" + +if test -r "$man_dir"/"$manpage".1 +then + dummy=dummy +else + echo "Cannot find readable man page source $1" >&2 + exit 1 +fi + +if test -e "$man_dir"/man1 +then + dummy=dummy +else + ln -s . "$man_dir"/man1 +fi + +if test "$1" = "-work_as_filter" +then + +# set -x + + sed \ + -e 's///' \ + -e 's///' \ + -e 's/XORRISO<\/title>/<title>man 1 xorriso<\/title>/' \ + -e 's/<h1 align=center>XORRISO<\/h1>/<h1 align=center>man 1 xorriso<\/h1>/' \ + -e 's/<body>/<body BGCOLOR="#F5DEB3" TEXT=#000000 LINK=#0000A0 VLINK=#800000>/' \ + -e 's/<b>Overview of features:<\/b>/\ <BR><b>Overview of features:<\/b>/' \ + -e 's/<b>General information paragraphs:<\/b>/\ <BR><b>General information paragraphs:<\/b>/' \ + -e 's/have a look at section EXAMPLES/have a look at section <A HREF="#EXAMPLES">EXAMPLES<\/A>/' \ + -e 's/<b>Session model:<\/b>/\ <BR><b>Session model:<\/b>/' \ + -e 's/<b>Media types and states:<\/b>/\ <BR><b>Media types and states:<\/b>/' \ + -e 's/<b>Creating, Growing, Modifying, Blind/\ <BR><b>Creating, Growing, Modifying, Blind/' \ + -e 's/<b>Libburn drives:<\/b>/\ <BR><b>Libburn drives:<\/b>/' \ + -e 's/^-dev /\ \ -dev /' \ + -e 's/^-devices /\ \ -devices /' \ + -e 's/<b>Rock Ridge, POSIX, X\/Open, El Torito, ACL,/\ <BR><b>Rock Ridge, POSIX, X\/Open, El Torito, ACL,/' \ + -e 's/<b>Command processing:<\/b>/\ <BR><b>Command processing:<\/b>/' \ + -e 's/<b>Dialog, Readline, Result pager:<\/b>/\ <BR><b>Dialog, Readline, Result pager:<\/b>/' \ + -e 's/<b>Aquiring source and target drive:<\/b>/\ <BR><b>Aquiring source and target drive:<\/b><BR>\ <BR>/' \ + -e 's/<b>Data manipulations:<\/b>/\ <BR><b>Data manipulations:<\/b><BR>\ <BR>/' \ + -e 's/^<p><b>−iso_rr_pattern/<p>\ <BR><b>\−iso_rr_pattern/' \ + -e 's/EXAMPLES):<br>/<A HREF="#EXAMPLES">EXAMPLES<\/A>):<br>/' \ + -e 's/<b>Writing the result:<\/b>/\ <BR><b>Writing the result:<\/b><BR>/' \ + -e 's/^-find \/ /\ \ -find \/ /' \ + -e 's/<b>Settings for data insertion:<\/b>/\ <BR><b>Settings for data insertion:<\/b><BR>\ <BR>/' \ + -e 's/^$<\/b> ln -s/\ \ $<\/b> ln -s/' \ + -e 's/<b>Settings for result writing:<\/b>/\ <BR><b>Settings for result writing:<\/b><BR>\ <BR>/' \ + -e 's/^706k = 706kB/\ \ 706k = 706kB/' \ + -e 's/^5540k = 5540kB/\ \ 5540k = 5540kB/' \ + -e 's/<b>Character sets:<\/b>/\ <BR><b>Character sets:<\/b><BR>\ <BR>/' \ + -e 's/<b>Exception processing:<\/b>/\ <BR><b>Exception processing:<\/b><BR>\ <BR>/' \ + -e 's/<b>El Torito bootable ISO images:<\/b>/\ <BR><b>El Torito bootable ISO images:<\/b><BR>\ <BR>/' \ + -e 's/<b>Dialog mode control:<\/b>/\ <BR><b>Dialog mode control:<\/b><BR>\ <BR>/' \ + -e 's/<b>Drive and media related inquiry actions:<\/b>/\ <BR><b>Drive and media related inquiry actions:<\/b><BR>\ <BR>/' \ + -e 's/<b>Navigation in ISO image/\ <BR><b>Navigation in ISO image/' \ + -e 's/^filesystem:<\/b>/filesystem:<\/b><BR>\ <BR>/' \ + -e 's/<b>Evaluation of readability and recovery:<\/b>/\ <BR><b>Evaluation of readability and recovery:<\/b><BR>\ <BR>/' \ + -e 's/<b>osirrox restore options:<\/b>/\ <BR><b>osirrox restore options:<\/b><BR>\ <BR>/' \ + -e 's/<b>Command compatibility emulations:<\/b>/\ <BR><b>Command compatibility emulations:<\/b><BR>\ <BR>/' \ + -e 's/^<p><b>−as</<p>\ <BR><b>\−as</' \ + -e 's/<b>Scripting, dialog and/\ <BR><b>Scripting, dialog and/' \ + -e 's/^features:<\/b>/features:<\/b><BR>\ <BR>/' \ + -e 's/<b>Support for frontend/\ <BR><b>Support for frontend/' \ + -e 's/^listening at stdout:<\/b>/listening at stdout:<\/b><BR>\ <BR>/' \ + -e 's/xorriso -outdev \/dev\/sr2 \\ -blank fast \\ -pathspecs on/xorriso -outdev \/dev\/sr2 -blank fast -pathspecs on/' \ + -e 's/\\ -add \\ \/sounds=\/home\/me\/sounds \\ \/pictures \\ -- \\ -rm_r \\/ -add \/sounds=\/home\/me\/sounds \/pictures -- -rm_r /' \ + -e 's/\/sounds\/indecent \\ \’\/pictures\/\*private\*\’ \\/\/sounds\/indecent \’\/pictures\/*private*\’ /' \ + -e 's/\/pictures\/confidential \\ -- \\ -add \\/\/pictures\/confidential -- -add/' \ + -e 's/xorriso -dev \/dev\/sr2 \\ -rm_r \/sounds -- \\ -mv \\/xorriso -dev \/dev\/sr2 -rm_r \/sounds -- -mv /' \ + -e 's/\/pictures\/confidential \\ \/pictures\/restricted \\ -- \\ -chmod/\/pictures\/confidential \/pictures\/restricted -- -chmod/' \ + -e 's/go-rwx \/pictures\/restricted -- \\ -pathsspecs on \\ -add \\/go-rwx \/pictures\/restricted -- -pathsspecs on -add /' \ + -e 's/\/sounds=\/home\/me\/prepared_for_dvd\/sounds_dummy /\/sounds=\/home\/me\/prepared_for_dvd\/sounds_dummy/' \ + -e 's/\/movies=\/home\/me\/prepared_for_dvd\/movies \\ -- \\ -commit/\/movies=\/home\/me\/prepared_for_dvd\/movies -- -commit/' \ + -e 's/xorriso -indev \/dev\/sr2 \\ -rm_r \/sounds -- \\/xorriso -indev \/dev\/sr2 -rm_r \/sounds -- /' \ + -e 's/-outdev \/dev\/sr0 -blank fast \\ -commit -eject all/-outdev \/dev\/sr0 -blank fast -commit -eject all/' \ + -e 's/See section FILES/See section <A HREF="#FILES">FILES<\/A>/' \ + -e 's/See section EXAMPLES/See section <A HREF="#EXAMPLES">EXAMPLES<\/A>/' \ + -e 's/<\/body>/<BR><HR><FONT SIZE=-1><CENTER>(HTML generated from '"$manpage"'.1 on '"$(date)"' by '$(basename "$0")' )<\/CENTER><\/FONT><\/body>/' \ + <"$2" >"$htmlpage" + + set +x + + chmod u+rw,go+r,go-w "$htmlpage" + echo "Emerged file:" + ls -lL "$htmlpage" + +else + + export BROWSER='cp "%s" '"$raw_html" + man -H "$manpage" + "$0" -work_as_filter "$raw_html" + rm "$raw_html" + rm "$man_dir"/man1 + +fi diff --git a/libisoburn/branches/ZeroFourTwo/xorriso/make_timestamp.sh b/libisoburn/branches/ZeroFourTwo/xorriso/make_timestamp.sh new file mode 100755 index 00000000..d6cfcb57 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/xorriso/make_timestamp.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Create version timestamp xorriso/xorriso_timestamp.h +# to be executed within ./libisoburn-develop + +timestamp="$(date -u '+%Y.%m.%d.%H%M%S')" +echo "Version timestamp : $timestamp" +echo '#define Xorriso_timestamP "'"$timestamp"'"' >xorriso/xorriso_timestamp.h + diff --git a/libisoburn/branches/ZeroFourTwo/xorriso/make_xorriso_standalone.sh b/libisoburn/branches/ZeroFourTwo/xorriso/make_xorriso_standalone.sh new file mode 100755 index 00000000..884d5635 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/xorriso/make_xorriso_standalone.sh @@ -0,0 +1,245 @@ +#!/bin/sh + +# make_xorriso_standalone.sh +# Copyright 2008 - 2009 Thomas Schmitt, scdbackup@gmx.net, GPL +# +# Not intended for general use in production installations ! +# +# This is a development tool which expects a special setup of directories. +# It is to be executed in a common parent of the directories +# nglibisofs-develop libburn-develop libisoburn-develop +# +# Creates a standalone tree for building xorriso +# from the contents of a unified libburnia development tree. +# +# The ./bootstrap script gets applied and a source tarball +# is made. +# +# From that tree can be build a binary xorriso/xorriso +# which at runtime depends only on libc and libpthread. +# Execute in $lone_dir : +# +# ./configure && make +# + +current_dir=$(pwd) +lone_dir="$current_dir"/"xorriso-standalone" + +xorriso_rev=0.4.1 +# For unstable uploads: +xorriso_pl="" +# For stable releases: +## xorriso_pl=".pl00" + +with_bootstrap_tarball=1 + +create_dir() { + if mkdir "$1" + then + dummy=dummy + else + echo "Failed to create : $1" >&2 + exit 1 + fi +} + +goto_dir() { + if cd "$1" + then + dummy=dummy + else + echo "Failed to cd $1" >&2 + exit 1 + fi +} + +copy_files() { + if cp "$@" + then + dummy=dummy + else + echo "Failed to : cp " "$@" >&2 + exit 1 + fi +} + +if test -e "$lone_dir" +then + echo "Already existing : $lone_dir" >&2 + exit 1 +fi + + +# Top level directory + +goto_dir "$current_dir"/libisoburn-develop + +create_dir "$lone_dir" + +copy_files \ + AUTHORS \ + CONTRIBUTORS \ + COPYRIGHT \ + COPYING \ + INSTALL \ + acinclude.m4 \ + aclocal.m4 \ + bootstrap \ + compile \ + config.guess \ + config.status \ + config.sub \ + depcomp \ + install-sh \ + libtool \ + ltmain.sh \ + missing \ + mkinstalldirs \ + version.h.in \ + \ + "$lone_dir" + +copy_files xorriso/configure_ac.txt "$lone_dir"/configure.ac + +copy_files xorriso/xorriso_makefile_am.txt "$lone_dir"/Makefile.am + +# copy_files xorriso/xorriso_pc_in.txt "$lone_dir"/xorriso.pc.in + +copy_files xorriso/README "$lone_dir"/README + +# echo "See end of xorriso/changelog.txt" >"$lone_dir"/TODO + + +# libisoburn + +create_dir "$lone_dir"/libisoburn +copy_files \ + libisoburn/*.[ch] \ + "$lone_dir"/libisoburn + +xorriso/convert_man_to_html.sh + +create_dir "$lone_dir"/xorriso +copy_files \ + xorriso/xorrisoburn.[ch] \ + xorriso/xorriso.[ch1] \ + xorriso/xorriso_private.h \ + \ + xorriso/xorriso_timestamp.h \ + \ + xorriso/changelog.txt \ + xorriso/xorriso_eng.html \ + xorriso/man_1_xorriso.html \ + "$lone_dir"/xorriso + +copy_files xorriso/xorriso_buildstamp_none.h \ + "$lone_dir"/xorriso/xorriso_buildstamp.h +copy_files xorriso/xorriso_buildstamp_none.h \ + "$lone_dir"/xorriso/xorriso_buildstamp_none.h + +create_dir "$lone_dir"/test +copy_files \ + test/compare_file.c \ + "$lone_dir"/test/compare_file.c + + +# nglibisofs + +create_dir "$lone_dir"/libisofs +create_dir "$lone_dir"/libisofs/filters +create_dir "$lone_dir"/doc +goto_dir "$current_dir"/nglibisofs-develop +copy_files libisofs/*.[ch] "$lone_dir"/libisofs +copy_files libisofs/filters/*.[ch] "$lone_dir"/libisofs/filters +copy_files doc/susp_aaip*.txt "$lone_dir"/doc +copy_files doc/zisofs_format.txt "$lone_dir"/doc +copy_files COPYRIGHT "$lone_dir"/libisofs + +# To get a common version.h +cat version.h.in >> "$lone_dir"/version.h.in + + +# <<< obsoleted patchings + +if test 1 = 0 +then + +# Change GNU macro name to POSIX name +sed -e 's/FNM_FILE_NAME/FNM_PATHNAME/g' \ + <libisofs/tree.c >"$lone_dir"/libisofs/tree.c + +# Filter out the semi-illegal TODO comments +( cd "$lone_dir"/libisofs && grep '^[[:space:]]*//' *.[ch] | less ) +echo "Is it ok delete all shown //-lines ?" +read yesno +if test "$yesno" = "y" -o "$yesno" = "1" +then + for i in "$lone_dir"/libisofs/*.[ch] + do + # first copy attributes + cp "$i" "$lone_dir"/libisofs/tmpfile + # now filter away // lines + grep -v '^[[:space:]]*//' <"$i" >"$lone_dir"/libisofs/tmpfile && \ + mv "$lone_dir"/libisofs/tmpfile "$i" + done +fi +echo "Remaining // lines:" +( cd "$lone_dir"/libisofs && grep '//' *.[ch] ) + +fi + + + +# libburn + +create_dir "$lone_dir"/libburn +goto_dir "$current_dir"/libburn-develop +copy_files libburn/*.[ch] "$lone_dir"/libburn +copy_files COPYRIGHT "$lone_dir"/libburn + + +# To get a common version.h +cat version.h.in >> "$lone_dir"/version.h.in + + +# tarball + +if test "$with_bootstrap_tarball" = 1 +then + +tarball_dir="$current_dir"/xorriso-"$xorriso_rev" +mv "$lone_dir" "$tarball_dir" + +goto_dir "$tarball_dir" + +./bootstrap + +# Remove unneeded temporary data from ./bootstrap +rm -r ./autom4te.cache + +# Repair non-portable shell code output of ./bootstrap +( + cd "$compile_dir" || exit 1 + sed -e 's/^for ac_header in$/test -z 1 \&\& for ac_header in dummy/' \ + < ./configure > ./configure-repaired + if test "$?" = 0 + then + echo "$0: Empty 'for ac_header in' found in configure." >&2 + fi + mv ./configure-repaired ./configure + chmod a+rx,go-w,u+w ./configure +) + +cd "$current_dir" +tar czf ./xorriso-"$xorriso_rev""$xorriso_pl".tar.gz $(basename "$tarball_dir") + +ls -l $(pwd)/xorriso-"$xorriso_rev""$xorriso_pl".tar.gz + +mv "$tarball_dir" "$lone_dir" + +fi + +echo "Done" +echo "HINT: Now build xorriso/xorriso by:" +echo " cd '$lone_dir' && ./configure && make" +echo diff --git a/libisoburn/branches/ZeroFourTwo/xorriso/makefile_libxorriso_am.txt b/libisoburn/branches/ZeroFourTwo/xorriso/makefile_libxorriso_am.txt new file mode 100644 index 00000000..06e96685 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/xorriso/makefile_libxorriso_am.txt @@ -0,0 +1,196 @@ + +# ts A90315 : LIBBURNIA_PKGCONFDIR is defined OS specific in acinclude.m4 +# was: pkgconfigdir=$(libdir)/pkgconfig +pkgconfigdir=$(LIBBURNIA_PKGCONFDIR) + +libincludedir=$(includedir)/libisoburn + +lib_LTLIBRARIES = libisoburn/libisoburn.la libxorriso/libxorriso.la + +## ========================================================================= ## + +# Build libraries +libisoburn_libisoburn_la_LDFLAGS = \ + -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) +libisoburn_libisoburn_la_SOURCES = \ + libisoburn/burn_wrap.c \ + libisoburn/data_source.c \ + libisoburn/isoburn.c \ + libisoburn/isoburn.h \ + libisoburn/isofs_wrap.c \ + libisoburn/libisoburn.h \ + version.h + +libisoburn_libisoburn_la_LIBADD = \ + -lisofs \ + -lburn + +libxorriso_libxorriso_la_LDFLAGS = \ + -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) +libxorriso_libxorriso_la_SOURCES = \ + xorriso/xorriso.h \ + xorriso/xorriso_private.h \ + xorriso/xorriso.c \ + xorriso/xorrisoburn.h \ + xorriso/xorrisoburn.c \ + xorriso/xorriso_timestamp.h \ + xorriso/xorriso_buildstamp.h \ + version.h + +libxorriso_libxorriso_la_LIBADD = \ + -lisofs \ + -lburn \ + -lisoburn + +libinclude_HEADERS = \ + libisoburn/libisoburn.h \ + xorriso/xorriso.h + +## ========================================================================= ## + + +# This is the reference application of libisoburn. See man xorriso/xorriso.1 +# +bin_PROGRAMS = \ + xorriso/xorriso + +# This looks quite ugly with make install: xorriso.c is compiled twice again +# +# Trying to create a build timestamp file +# +# BUILT_SOURCES = xorriso/xorriso_buildstamp.h +# +# phony targets get rebuilt every time +# +# .PHONY: xorriso/xorriso_buildstamp.h +# xorriso/xorriso_buildstamp.h: +# date -u '+#define Xorriso_build_timestamP "%Y.%m.%d.%H%M%S"' >xorriso/xorriso_buildstamp.h +# cat xorriso/xorriso_buildstamp.h + +xorriso_xorriso_CPPFLAGS = -Ilibisoburn +xorriso_xorriso_CFLAGS = -DXorriso_with_maiN -DXorriso_without_subS \ + $(READLINE_DEF) $(LIBACL_DEF) $(XATTR_DEF) \ + $(EXTF_DEF) $(EXTF_SUID_DEF) $(ZLIB_DEF) + +xorriso_xorriso_LDADD = libisoburn/libisoburn.la -lisofs -lburn \ + libxorriso/libxorriso.la \ + $(THREAD_LIBS) $(LIBBURN_ARCH_LIBS) + +xorriso_xorriso_SOURCES = \ + xorriso/xorriso.h \ + xorriso/xorriso_private.h \ + xorriso/xorriso.c \ + xorriso/xorrisoburn.h \ + xorriso/xorriso_timestamp.h \ + xorriso/xorriso_buildstamp.h + +# xorriso/xorrisoburn.c \ +# + +# Install symbolic links to the xorriso binary +# +install-exec-hook: + if test -e "$(DESTDIR)$(bindir)"/xorrisofs ; then rm "$(DESTDIR)$(bindir)"/xorrisofs ; else echo ; fi + ln -s xorriso "$(DESTDIR)$(bindir)"/xorrisofs + if test -e "$(DESTDIR)$(bindir)"/osirrox ; then rm "$(DESTDIR)$(bindir)"/osirrox ; else echo ; fi + ln -s xorriso "$(DESTDIR)$(bindir)"/osirrox + if test -e "$(DESTDIR)$(bindir)"/xorrecord ; then rm "$(DESTDIR)$(bindir)"/xorrecord ; else echo ; fi + ln -s xorriso "$(DESTDIR)$(bindir)"/xorrecord + + +# Alternative to the disabled .PHONY above. +# Trying to create a build timestamp file semi-manually: make buildstamped +# +buildstamp: + date -u '+#define Xorriso_build_timestamP "%Y.%m.%d.%H%M%S"' >xorriso/xorriso_buildstamp.h + cat xorriso/xorriso_buildstamp.h + +# For now make buildstamped has to be performed explicitely. +buildstamped: buildstamp + make + + + +## Build test applications +noinst_PROGRAMS = \ + test/compare_file + +# A program to compare two files in mirrored trees in mounted filesystems +# To compare tree /media/dvd and /original/dir : +# find /media/dvd -exec test/compare_file '{}' /media/dvd /original/dir ';' +# +test_compare_file_CPPFLAGS = +test_compare_file_CFLAGS = +test_compare_file_LDADD = +test_compare_file_SOURCES = test/compare_file.c + + +## ========================================================================= ## + +## Build documentation (You need Doxygen for this to work) +webhost = http://libburn-api.pykix.org +webpath = / +docdir = $(DESTDIR)$(prefix)/share/doc/$(PACKAGE)-$(VERSION) + +doc: doc/html + +doc/html: doc/doxygen.conf + if [ -f ./doc/doc.lock ]; then \ + $(RM) -r doc/html; \ + doxygen doc/doxygen.conf; \ + fi + +doc-upload: doc/html + scp -r $</* $(webhost):$(webpath) + +all: doc + +install-data-local: + if [ -f ./doc/doc.lock ]; then \ + $(mkinstalldirs) $(docdir)/html; \ + $(INSTALL_DATA) doc/html/* $(docdir)/html; \ + fi + +uninstall-local: + rm -rf $(docdir) + +## ========================================================================= ## + +# Indent source files +indent_files = \ + $(libisoburn_libisoburn_la_SOURCES) + + +indent: $(indent_files) + indent -bad -bap -nbbb -nbbo -nbc -bli0 -br -bls \ + -cdw -ce -cli0 -ncs -nbfda -i8 -l79 -lc79 \ + -lp -saf -sai -nprs -npsl -saw -sob -ss -ut \ + -sbi0 -nsc -ts8 -npcs -ncdb -fca \ + $^ + +.PHONY: indent + +## ========================================================================= ## + +# Extra things +nodist_pkgconfig_DATA = \ + libisoburn-1.pc + +man_MANS = xorriso/xorriso.1 + +EXTRA_DIST = \ + libisoburn-1.pc.in \ + version.h.in \ + doc/comments \ + doc/doxygen.conf.in \ + README \ + AUTHORS \ + CONTRIBUTORS \ + COPYRIGHT \ + COPYING \ + INSTALL \ + xorriso/changelog.txt \ + xorriso/xorriso_buildstamp_none.h \ + xorriso/README \ + $(man_MANS) + diff --git a/libisoburn/branches/ZeroFourTwo/xorriso/xorriso.1 b/libisoburn/branches/ZeroFourTwo/xorriso/xorriso.1 new file mode 100644 index 00000000..be893a4c --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/xorriso/xorriso.1 @@ -0,0 +1,3635 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" First parameter, NAME, should be all caps +.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection +.\" other parameters are allowed: see man(7), man(1) +.TH XORRISO 1 "Aug 28, 2009" +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp <n> insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.nh +.SH NAME +xorriso - creates, loads, manipulates and writes ISO 9660 filesystem images +with Rock Ridge extensions. +.SH SYNOPSIS +.B xorriso +.RI [ settings | actions ] +.br +.SH DESCRIPTION +.PP +.B xorriso +is a program which maps file objects from POSIX compliant +filesystems into Rock Ridge enhanced ISO 9660 filesystems and allows +session-wise manipulation of such filesystems. It can load the management +information of existing ISO images and it writes the session results to +optical media or to filesystem objects. +.br +Vice versa xorriso is able to restore file objects from ISO 9660 filesystems. +.PP +A special property of xorriso is that it needs neither an external ISO 9660 +formatter program nor an external burn program for CD, DVD or BD but rather +incorporates the libraries of libburnia-project.org . +.SS +.B Overview of features: +.br +Operates on an existing ISO image or creates a new one. +.br +Copies files from disk filesystem into the ISO image. +.br +Copies files from ISO image to disk filesystem (see osirrox). +.br +Renames or deletes file objects in the ISO image. +.br +Changes file properties in the ISO image. +.br +Updates ISO subtrees incrementally to match given disk subtrees. +.br +Writes result either as completely new image or as add-on session +to optical media or filesystem objects. +.br +Can activate ISOLINUX boot images via El Torito. +.br +Can perform multi-session tasks as emulation of mkisofs and cdrecord. +.br +Can record and restore hard links and ACL. +.br +Content may get zisofs compressed or filtered by external processes. +.br +Can issue commands to mount older sessions on Linux or FreeBSD. +.br +Can check media for damages and copy readable blocks to disk. +.br +Can attach MD5 checksums to each data file and the whole session. +.br +Scans for optical drives, blanks re-useable optical media. +.br +Reads its instructions from command line arguments, dialog, and files. +.br +Provides navigation commands for interactive ISO image manipulation. +.br +Adjustable thresholds for abort, exit value, and problem reporting. +.SS +.B General information paragraphs: +.br +Session model +.br +Media types and states +.br +Creating, Growing, Modifying, Blind Growing +.br +Libburn drives +.br +Rock Ridge, POSIX, X/Open, El Torito, ACL, xattr +.br +Command processing +.br +Dialog, Readline, Result pager +.sp 1 +Maybe you first want to have a look at section EXAMPLES near the end of +this text before reading the next few hundred lines of background information. +.SS +.B Session model: +.br +Unlike other filesystems, ISO 9660 is not intended for read-write operation but +rather for being generated in a single sweep and being written to media as a +.B session. +.br +The data content of the session is called filesystem +.B image. +.PP +The written image in its session can then be mounted by the operating system +for being used read-only. Linux is able to mount ISO images from block devices, +which may represent optical media, other media or via a loop device even +from regular disk files. FreeBSD mounts ISO images from devices that represent +arbitrary media or from regular disk files. +.PP +This session usage model has been extended on CD media by the concept of +.B multi-session , +which allows to add information to the CD and gives the mount programs +of the operating systems the addresses of the entry points of each +session. The mount programs recognize block devices which represent +CD media and will by default mount the image in the last session. +.br +This session usually contains an updated directory tree for the whole media +which governs the data contents in all recorded sessions. +So in the view of the mount program all sessions of a particular media +together form a single filesystem image. +.br +Adding a session to an existing ISO image is in this text referred as +\fBgrowing\fR. +.br +The multi-session model of the MMC standard does not apply to all media +types. But program growisofs by Andy Polyakov showed how to extend this +functionality to overwriteable media or disk files which carry valid ISO 9660 +filesystems. +.PP +xorriso provides growing as well as an own method named +\fBmodifying\fR which produces a completely new ISO image from the old +one and the modifications. +See paragraph Creating, Growing, Modifying, Blind Growing below. +.PP +xorriso adopts the concept of multi-session by loading an eventual image +directory tree, allowing to manipulate it by several actions, and to write +the new image to the target media. +.br +The first session of a xorriso run begins by the definition of the input +drive with the eventual ISO image or by the definition of an output drive. +The session ends by command -commit which triggers writing. A -commit is +done automatically when the program ends regularly. +.PP +After -commit a new session begins with the freshly written one as input. +A new input drive can only be chosen as long as the loaded ISO image was +not altered. Pending alteration can be revoked by command -rollback. +.PP +Writing a session to the target is supposed to be very expensive in terms of +time and of consumed space on appendable or write-once media. Therefore all +intended manipulations of a particular ISO image should be done in a single +session. +.br +In some special situations (e.g. in a file-to-file situation) it can be +useful to store intermediate states and to continue with image manipulations. +.SS +.B Media types and states: +There are two families of media in the MMC standard: +.br +\fBMulti-session media\fR are CD-R, CD-RW, DVD-R, DVD+R, DVD+R/DL, BD-R, and +unformatted DVD-RW. These media provide a table of content which +describes their existing sessions. See option \fB-toc\fR. +.br +\fBOverwriteable media\fR are DVD-RAM, DVD+RW, BD-RE, and formatted DVD-RW. +They allow random write access but do not provide information about their +session history. If they contain one or more ISO 9660 sessions and if the +first session was written by xorriso, then a table of content can +be emulated. Else only a single overall session will be visible. +.br +DVD-RW media can be formatted by -format full. +They can be made unformatted by -blank deformat. +.br +Emulated drives are handled as overwriteable media if they are random +read-write accessible. If they are only sequentially writeable then +they are handled as blank multi-session media. +.PP +These media can assume several states in which they offer different +capabilities. +.br +\fBBlank\fR media can be written from scratch. They contain no ISO image +suitable for xorriso. +.br +Blank is the state of newly purchased optical media. +With used CD-RW and DVD-RW it can be achieved by action -blank "as_needed". +Overwriteable media are considered blank if they are new or if they have +been marked as blank by xorriso. +Action -blank "as_needed" can be used to do this marking on overwriteable +media, or to apply eventual mandatory formatting of new media. +.br +\fBAppendable\fR media accept further sessions. Either they are MMC +multi-session media in appendable state, or they are overwriteable media +which contain an ISO image suitable for xorriso. +.br +Appendable is the state after writing a session with option -close off. +.br +\fBClosed\fR media cannot be written. They may contain an ISO image suitable +for xorriso. +.br +Closed is the state of DVD-ROM media and of multi-session media which were +written with option -close on. If the drive is read-only hardware then it will +probably show any media as closed CD-ROM resp. DVD-ROM. +.br +Overwriteable media assume this state in such read-only drives or if they +contain unrecognizable data in the first 32 data blocks. +.br +Read-only drives may or may not show session histories of multi-session +media. Often only the first and the last session are visible. Sometimes +not even that. Option -rom_toc_scan might or might not help in such cases. +.SS +.B Creating, Growing, Modifying, Blind Growing: +.br +A new empty ISO image gets \fBcreated\fR +if there is no input drive with a valid ISO 9660 image when the first time +an output drive is defined. This is achieved by option -dev on blank media +or by option -outdev on media in any state. +.br +The new empty image can be populated with directories and files. +Before it can be written, the media in the output drive must get into +blank state if it was not blank already. +.PP +If there is a input drive with a valid ISO image, then this image gets loaded +as foundation for manipulations and extension. The constellation of input +and output drive determines which write method will be used. +They have quite different capabilities and constraints. +.PP +The method of \fBgrowing\fR adds new data to the existing media. These +data comprise of eventual new file content and they override the existing +ISO 9660 + Rock Ridge directory tree. It is possible to hide files from +previous sessions but they still exist on media and with many types of +optical media it is quite easy to recover them by mounting older sessions. +.br +Growing is achieved by option -dev. +.PP +The write method of \fBmodifying\fR produces compact filesystem +images with no outdated files or directory trees. Modifying can write its +images to target media which are completely unsuitable for multi-session +operations. E.g. DVD-RW which were treated with -blank deformat_quickest, +named pipes, character devices, sockets. +On the other hand modified sessions cannot be written to appendable media +but to blank media only. +.br +So for this method one needs either two optical drives or has to work with +filesystem objects as source and/or target media. +.br +Modifying takes place if input drive and output drive are not the same and +if option -grow_blindly is set to its default "off". +This is achieved by options -indev and -outdev. +.PP +If option -grow_blindly is set to a non-negative number and if -indev and +-outdev are both set to different drives, then \fBblind growing\fR is +performed. It produces an add-on session which is ready for being written +to the given block address. This is the usage model of +.br + mkisofs -M $indev -C $msc1,$msc2 -o $outdev +.br +which gives much room for wrong parameter combinations and should thus only be +employed if a strict distinction between ISO formatter xorriso and the burn +program is desired. -C $msc1,$msc2 is equivalent to: +.br + -load sbsector $msc1 -grow_blindly $msc2 +.SS +.B Libburn drives: +.br +Input drive, i.e. source of an existing or empty ISO image, can be any random +access readable libburn drive: optical media with readable data, +blank optical media, regular files, block devices. +.PP +Output drive, i.e. target for writing, can be any libburn drive. +Some drive types do not support the method of growing but only the methods +of modifying and blind growing. They all are suitable for newly created images. +.br +All drive file objects have to offer rw-permission to the user of xorriso. +Even those which will not be useable for reading an ISO image. +.PP +MMC compliant (i.e. optical) drives on Linux usually get addressed by +the path of their block device or of their generic character device. E.g. +.br + -dev /dev/sr0 +.br + -dev /dev/hdc +.br + -dev /dev/sg2 +.br +On FreeBSD the device files have names like +.br + -dev /dev/cd0 +.br + -dev /dev/acd0 +.br +Get a list of accessible drives by command +.br + -devices +.br +It might be necessary to do this as +.B superuser +in order to see all drives and to then allow rw-access for the intended users. +Consider to bundle the authorized users in a group like old "floppy". +.PP +Filesystem objects of nearly any type can be addressed by prefix "stdio:" and +their path in the filesystem. E.g.: +.br + -dev stdio:/dev/sdc +.br +The default setting of -drive_class allows to address files outside the +/dev tree without that prefix. E.g.: +.br + -dev /tmp/pseudo_drive +.br +If path leads to a regular file or to a block device then the emulated drive +is random access readable and can be used for the method of growing if it +already contains a valid ISO 9660 image. Any other file type is not readable +via "stdio:" and can only be used as target for the method of modifying or +blind growing. +Non-existing paths in existing directories are handled as empty regular files. +.PP +A very special kind of pseudo drive are open file descriptors. They are +depicted by "stdio:/dev/fd/" and descriptor number (see man 2 open). +.br +Addresses "-" or "stdio:/dev/fd/1" depict standard output, which normally is +the output channel for result texts. +To prevent a fatal intermingling of ISO image and text messages, all result +texts get redirected to stderr if -*dev "-" or "stdio:/dev/fd/1" is among +the start arguments of the program. +.br +Standard output is currently suitable for creating one session +per program run without dialog. Use in other situations is discouraged +and several restrictions apply: +.br +It is not allowed to use standard output as pseudo drive if it was not +among the start arguments. Do not try to fool this ban via backdoor addresses +to stdout. +.br +If stdout is used as drive, then -use_readline is permanently disabled. +Use of backdoors will cause severe memory and/or tty corruption. +.PP +Be aware that especially the superuser can write into any accessible file or +device by using its path with the "stdio:" prefix. By default any address +in the /dev tree without prefix "stdio:" will work only if it leads to a MMC +drive. +.br +One may use option +.B -ban_stdio_write +to surely prevent this risk and to allow only MMC drives. +.br +One may prepend "mmc:" to a path to surely disallow any automatic "stdio:". +.br +By option -drive_class one may ban certain paths or allow access without +prefix "stdio:" to other paths. +.SS +.B Rock Ridge, POSIX, X/Open, El Torito, ACL, xattr: +.br +.B Rock Ridge +is the name of a set of additional informations which enhance +an ISO 9660 filesystem so that it can represent a POSIX compliant filesystem +with ownership, access permissions, symbolic links, and other attributes. +.PP +This is what xorriso uses for a decent representation of the disk files +within the ISO image. Rock Ridge information is produced with any xorriso +image. +.PP +xorriso is not named "porriso" because POSIX only guarantees 14 characters +of filename length. It is the X/Open System Interface standard XSI which +demands a file name length of up to 255 characters and paths of up to 1024 +characters. Rock Ridge fulfills this demand. +.PP +An +.B El Torito +boot record connects a boot image, which is a binary program plus some +other files stored in the ISO image, with the bootstrapping facility of +contemporary computers. +The content of the boot image files is not in the scope of El Torito. +.br +Most bootable Linux CDs are equipped with ISOLINUX boot images. xorriso is +able to create or maintain an El Torito object which makes such an image +bootable. For details see option -boot_image. +Emulation -as mkisofs supports the example options out of the ISOLINUX wiki. +.br +The support for other boot image types is sparse. +.br +An MBR is generated together with the El Torito boot record if the boot image +bears the isohybrid signature of ISOLINUX 3.72 or later. It will occupy the +first 512 bytes of the emerging ISO image and enable booting from media which +appear as hard disk rather than as CDROM. An MBR does not hamper CDROM booting. +The MBR of a follow-up session can get in effect only on overwriteable media. +.PP +.B ACL +are an advanced way of controlling access permissions to file objects. Neither +ISO 9660 nor Rock Ridge specify a way to record ACLs. So libisofs has +introduced a standard conformant extension named AAIP for that purpose. +It uses this extension if enabled by option +.B -acl. +.br +AAIP enhanced images are supposed to be mountable normally, but one cannot +expect that the mounted filesystem will show and respect the eventual ACLs. +For now, only xorriso is able to retrieve those ACLs. It can bring them into +effect when files get restored to an ACL enabled file system or it can +print them in a format suitable for tool setfacl. +.br +Files with ACL show as group permissions the setting of entry "mask::" if +that entry exists. Nevertheless the non-listed group members get handled +according to entry "group::". xorriso brings "group::" into effect before +eventually removing the ACL from a file. +.PP +.B xattr +are pairs of name and value which can be attached to file objects. AAIP is +able to represent them and xorriso allows to record and restore pairs which +have names out of the user namespace. I.e. those which begin with "user.", +like "user.x" or "user.whatever". Name has to be a 0 terminated string. +Value may be any array of bytes which does not exceed the size of 4095 bytes. +xattr processing happens only if it is enabled by option +.B -xattr. +.br +As with ACL, currently only xorriso is able to retrieve xattr from AAIP +enhanced images and to restore them to xattr capable file systems. +.SS +.B Command processing: +.br +Commands are either actions which happen immediately or settings which +influence following actions. So their sequence does matter. +.br +Commands consist of a command word, +followed by zero or more parameter words. If the list of parameter words +is of variable length (indicated by "[...]" or "[***]") then it has to be +terminated by either the \fBlist delimiter\fR, or the end of argument list, +or an end of an input line. +.PP +At program start the list delimiter is the word "--". This may be changed +by option -list_delimiter in order to allow "--" as argument in a list of +variable length. It is advised to reset the delimiter to "--" immediately +afterwards. +.br +For brevity the list delimiter is referred as "--" throughout this text. +.br +The list delimiter is silently tolerated if it appears after the parameters of +a command with a fixed list length. It is handled as normal text if it +appears among the arguments of such a command. +.PP +.B Pattern expansion +is a property of some particular commands and not a general +feature. It gets controlled by commands -iso_rr_pattern and -disk_pattern. +Commands which eventually use pattern expansion all have variable argument +lists which are marked in this man page by "[***]" rather than "[...]". +.br +Some other commands perform pattern matching unconditionally. +.PP +Command and parameter words are either read from program arguments, where one +argument is one word, or from quoted input lines where words are recognized +similar to the quotation rules of a shell parser. +.br +xorriso is not a shell, although it might appear so on first glimpse. +Be aware that the interaction of quotation marks and pattern symbols like "*" +differs from the usual shell parsers. In xorriso, a quotation mark does not +make a pattern symbol literal. +.PP +.B Quoted input +converts whitespace separated text pieces into words. +The double quotation mark " and the single quotation mark ' can be used to +enclose whitespace and make it part of words (e.g. of file names). Each mark +type can enclose the marks of the other type. A trailing backslash \\ outside +quotations or an open quotation cause the next input line to be appended. +.br +Quoted input accepts any ASCII character except NUL (0) as content of quotes. +Nevertheless it can be cumbersome for the user to produce those characters +at all. Therefore quoted input and program arguments allow optional +.B Backslash Interpretation +which can represent all ASCII characters except NUL (0) by backslash codes +as in $'...' of bash. +.br +It is not enabled by default. See option -backslash_codes. +.PP +When the program begins then it first looks for argument -no_rc. If this is +not present then it looks for its startup files and +eventually reads their content as command input lines. Then it interprets +the program arguments as commands and parameters and finally it enters +dialog mode if command -dialog "on" was executed up to then. +.PP +The program ends either by command -end, or by the end of program arguments +if not dialog was enabled up to that moment, or by a problem +event which triggers the threshold of command -abort_on. +.SS +.B Dialog, Readline, Result pager: +.br +Dialog mode prompts for a quoted input line, parses it into words, and performs +them as commands with their parameters. It provides assisting services +to make dialog more comfortable. +.PP +Readline is an enhancement for the input line. You may know it already from +the bash shell. Whether it is available in xorriso depends on the availability +of package readline-dev at the time when xorriso was built from its sourcecode. +.br +It allows to move the cursor over the text in the line by help of the +Leftward and the Rightward arrow key. +Text may be inserted at the cursor position. The Delete key removes the +character under the cursor. Upward and Downward arrow keys navigate through +the history of previous input lines. +.br +See man readline for more info about libreadline. +.PP +Option -page activates a built-in result text pager which may be convenient in +dialog. After an action has put out the given number of terminal lines, +the pager prompts the user for a line of input. +.br +An empty line lets xorriso resume work until the next page is put out. +.br +The single character "@" disables paging for the current action. +.br +"@@@", "x", "q", "X", or "Q" urge the current action to abort and suppress +further result output. +.br +Any other line will be interpreted as new dialog line. The current action +is urged to abort. Afterwards, the input line is executed. +.PP +Some actions apply paging to their info output, too. +.br +The urge to abort may or may not be obeyed by the current action. All actions +try to abort as soon as possible. +.br +.SH OPTIONS +.br +All command words are shown with a leading dash although this dash is not +mandatory for the option to be recognized. Note that with emulation modes the +dashes of the emulated options are mandatory. +.br +Normally any number of leading dashes is ignored with command words and +inner dashes are interpreted as underscores. +.TP +.B Aquiring source and target drive: +Before aquiring a drive one will eventually enable options which influence +the behavior of image loading. See next option group. +.TP +\fB\-dev\fR address +Set input and output drive to the same address and load an eventual ISO image. +If there is no ISO image then create a blank one. +Set the image expansion method to growing. +.br +This is only allowed as long as no changes are pending in the currently +loaded ISO image. Eventually one has to perform -commit or -rollback first. +.br +Special address string "-" means standard output, to which several restrictions +apply. See above paragraph "Libburn drives". +.br +An empty address string "" gives up the current device +without aquiring a new one. +.TP +\fB\-indev\fR address +Set input drive and load an eventual ISO image. If the new input drive differs +from -outdev then switch from growing to modifying or to blind growing. +It depends on the setting of -grow_blindly which of both gets activated. +The same rules and restrictions apply as with -dev. +.TP +\fB\-outdev\fR address +Set output drive and if it differs from the input drive then switch from +growing to modifying or to blind growing. Unlike -dev and -indev this action +does not load a new ISO image. So it can be performed even if there are pending +changes. +.br +-outdev can be performed without previous -dev or -indev. In that case an +empty ISO image with no changes pending is created. It can either be populated +by help of -map, -add et.al. or it can be discarded silently if -dev or -indev +are performed afterwards. +.br +Special address string "-" means standard output, to which several restrictions +apply. See above paragraph "Libburn drives". +.br +An empty address string "" gives up the current output drive +without aquiring a new one. No writing is possible without an output drive. +.TP +\fB\-grow_blindly\fR "off"|predicted_nwa +If predicted_nwa is a non-negative number then perform blind growing rather +than modifying if -indev and -outdev are set to different drives. +"off" or "-1" switch to modifying, which is the default. +.br +predicted_nwa is the block address where the add-on session of blind +growing will finally end up. It is the responsibility of the user to ensure +this final position and the presence of the older sessions. Else the +overall ISO image will not be mountable or will produce read errors when +accessing file content. xorriso will write the session to the address +as obtained from examining -outdev and not necessarily to predicted_nwa. +.br +During a run of blind growing, the input drive is given up before output +begins. The output drive is given up when writing is done. +.TP +.B Influencing the behavior of image loading: +The following options should normally be performed before loading an image +by aquiring an input drive. In rare cases it is desirable to activate +them only after image loading. +.TP +\fB\-load\fR entity id +Load a particular (possibly outdated) ISO image from -dev or -indev. +Usually all available sessions are shown with option -toc. +.br +entity depicts the kind of addressing. id depicts the particular +address. The following entities are defined: +.br +"auto" with any id addresses the last session in -toc. This is the default. +.br +"session" with id being a number as of a line "ISO session", column "Idx". +.br +"track" with id being a number as of a line "ISO track", column "Idx". +.br +"lba" or "sbsector" with a number as of a line "ISO ...", column "sbsector". +.br +"volid" with a search pattern for a text as of a line "ISO ...", +column "Volume Id". +.br +Adressing a non-existing entity or one which does not represent an ISO +image will either abandon -indev or at least lead to a blank image. +.br +If an input drive is set at the moment when -load is executed, then the +addressed ISO image is loaded immediately. Else, the setting will be pending +until the next -dev or -indev. After the image has been loaded once, the +setting is valid for -rollback until next -dev or -indev, where it +will be reset to "auto". +.TP +\fB\-drive_class\fR "harmless"|"banned"|"caution"|"clear_list" disk_pattern +Add a drive path pattern to one of the safety lists or make those lists empty. +There are three lists defined which get tested in the following sequence: +.br +If a drive address path matches the "harmless" list then the drive will be +accepted. If it is not a MMC device then the prefix "stdio:" will be prepended +automatically. This list is empty by default. +.br +Else if the path matches the "banned" list then the drive will not be +accepted by xorriso but rather lead to a FAILURE event. This list is empty by +default. +.br +Else if the path matches the "caution" list and if it is not a MMC device, +then its address must have the prefix "stdio:" or it will be rejected. +This list has by default one entry: "/dev". +.br +If a drive path matches no list then it is considered "harmless". By default +these are all paths which do not begin with directory "/dev". +.br +A path matches a list if one of its parent paths or itself matches a list +entry. An eventual address prefix "stdio:" or "mmc:" will be ignored when +testing for matches. +.br +By pseudo-class "clear_list" and pseudo-patterns "banned", "caution", +"harmless", or "all", the lists may be made empty. +.br +E.g.: -drive_class clear_list banned +.br +One will normally define the -drive_class lists in one of the xorriso +Startup Files. +.br +Note: This is not a security feature but rather a bumper for the superuser to +prevent inadverted mishaps. For reliably blocking access to a device file you +have to deny its rw-permissions in the filesystem. +.TP +\fB\-assert_volid\fR pattern severity +Refuse to load ISO images with volume ids which do not match the given +search pattern. When refusing an image, give up the input drive and issue +an event of the given severity. An empty search pattern accepts any image. +.br +This option does not hamper the creation of an empty image from blank +input media and does not discard an already loaded image. +.TP +\fB\-in_charset\fR character_set_name +Set the character set from which to convert file names when loading an +image. This has eventually to be done before specifying -dev , -indev or +-rollback. See paragraph "Character sets" for more explanations. +When loading the written image after -commit the setting of -out_charset +will be copied to -in_charset. +.TP +\fB\-auto_charset\fR "on"|"off" +Enable or disable recording and interpretation of the output character +set name in an xattr attribute of the image root directory. If enabled then +an eventual recorded character set name gets used as input character set +when reading an image. +.br +Note that the default output charset is the local character set of the +terminal where xorriso runs. Before attributing this local character set +to the produced ISO image, check whether the terminal properly displays +all intended filenames, especially exotic national characters. +.TP +\fB\-hardlinks\fR mode[:mode...] +Enable or disable loading and recording of hardlink relations. +.br +In default mode "off", iso_rr files lose their inode numbers at image load +time. Each iso_rr file object which has no inode number at image generation +time will get a new unique inode number if -compliance is set to new_rr. +.br +Mode "on" preserves eventual inode numbers from the loaded image. +When committing a session it searches for families of iso_rr files +which stem from the same disk file, have identical content filtering and have +identical properties. The family members all get the same inode number. +Whether these numbers are respected at mount time depends on the operating +system. +.br +Commands -update and -update_r track splits and fusions of hard links in +filesystems which have stable device and inode numbers. This can cause +automatic last minute changes before the session gets written. Command +-hardlinks "perform_update" may be used to do these changes earlier, +e.g. if you need to apply filters to all updated files. +.br +Mode "without_update" avoids hardlink processing during update commands. +Use this if your filesystem situation does not allow -disk_dev_ino "on". +.br +xorriso commands which extract files from an ISO image try to hardlink files +with identical inode number. The normal scope of this operation is from +image load to image load. One may give up the accumulated hard link addresses +by -hardlinks "discard_extract". +.br +A large number of hardlink families may exhaust -temp_mem_limit +if not -osirrox "sort_lba_on" and -hardlinks "cheap_sorted_extract" +are both in effect. This restricts hard linking to other files restored by +the same single extract command. -hardlinks "normal_extract" re-enables +wide and expensive hardlink accumulation. +.br +Hardlink processing automatically enables \fB\-compliance new_rr\fR. +This may be overridden by a following -compliance old_rr . In this case +the resulting image will violate the RRIP-1.10 specs for entry PX in +the same way as mkisofs does. +.TP +\fB\-acl\fR "on"|"off" +Enable or disable processing of ACLs. +If enabled, then xorriso will obtain ACLs from disk file objects, +store ACLs in the ISO image using the libisofs specific AAIP format, +load AAIP data from ISO images, test ACL during file comparison, +and restore ACLs to disk files when extracting them from ISO images. +See also options -getfacl, -setfacl. +.TP +\fB\-xattr\fR "on"|"off" +Enable or disable processing of xattr attributes in user namespace. +If enabled, then xorriso will handle xattr similar to ACL. +See also options -getfattr, -setfattr and above paragraph about xattr. +.TP +\fB\-md5\fR "on"|"all"|"off" +Enable or disable processing of MD5 checksums for the overall session and for +each single data file. If enabled then images get loaded only if eventual +checksums tags of superblock and directory tree match properly. The MD5 +checksums of data files and whole session get loaded from the image if there +are any. +.br +With options -compare and -update the eventually recorded MD5 of a file +will be used to avoid content reading from the image. Only the disk file +content will be read and compared with that MD5. This can save much time +if -disk_dev_ino "on" is not suitable. +.br +At image generation time they are computed for each file which gets its data +written into the new session. The checksums of files which have their data +in older sessions get copied into the new session. Superblock, tree and whole +session get a checksum tag each. +.br +Mode "all" will additionally check during image generation whether the checksum +of a data file changed between the time when its reading began and the time +when it ended. This implies reading every file twice. +.br +Checksums can be exploited via options -check_md5, -check_md5_r, via find +actions get_md5, check_md5, and via -check_media. +.TP +\fB\-for_backup\fR +Enable all extra features which help to produce or to restore backups with +highest fidelity of file properties. +Currently this is a shortcut for: -hardlinks on -acl on -xattr on -md5 on. +.TP +\fB\-disk_dev_ino\fR "on"|"ino_only"|"off" +Enable or disable processing of recorded file identification numbers +(dev_t and ino_t). They are eventually stored as xattr and allow +to substantially accelerate file comparison. The root node gets a global start +timestamp. If during comparison a file with younger timestamps is found in the +ISO image, then it is suspected to have inconsistent content. +.br +If device numbers and inode numbers of the disk filesystems are persistent +and if no irregular alterations of timestamps or system clock happen, +then potential content changes can be detected without reading that content. +File content change is assumed if any of mtime, ctime, device number or inode +number have changed. +.br +Mode "ino_only" replaces the precondition that device numbers are stable by the +precondition that mount points in the compared tree always lead to the +same filesystems. Use this if mode "on" always sees all files changed. +.br +The speed advantage appears only if the loaded session was produced with +-disk_dev_ino "on" too. +.br +Note that -disk_dev_ino "off" is totally in effect only if -hardlinks is "off", +too. +.TP +\fB\-rom_toc_scan\fR "on"|"off"[:"emul_on"|"emul_off"] +Read-only drives do not tell the actual media type but show any media as +ROM (e.g. as DVD-ROM). The session history of MMC multi-session media might +be truncated to first and last session or even be completely false. +(The eventual emulated history of overwriteable media is not affected by this.) +.br +To have in case of failure a chance of getting the session history and +especially the address of the last session, there is a scan for ISO 9660 +filesystem headers which might help but also might yield worse results +than the drive's table of content. At its end it can cause read attempts +to invalid addresses and thus ugly drive behavior. +Setting "on" enables that scan for alleged read-only media. +.br +On the other hand the emulation of session history on overwriteable media +can hamper reading of partly damaged media. Setting "off:emul_off" disables +the elsewise trustworthy table-of-content scan for those media. +.br +To be in effect, the -rom_toc_scan setting has to be made before the -*dev +command which aquires drive and media. +.TP +\fB\-calm_drive\fR "in"|"out"|"all"|"on"|"off" +Reduce drive noise until it is actually used again. Some drives stay alert +for substantial time after they have been used for reading. This reduces +the startup time for the next drive operation but can be loud and waste +energy if no i/o with the drive is expected to happen soon. +.br +Modes "in", "out", "all" immediately calm down -indev, -outdev, resp. both. +Mode "on" causes -calm_drive to be performed automatically after each -dev, +-indev, and -outdev. Mode "off" disables this. +.TP +\fB\-ban_stdio_write\fR +Allow for writing only the usage of MMC optical drives. Disallow +to write the result into files of nearly arbitrary type. +Once set, this command cannot be revoked. +.TP +.B Data manipulations: +.PP +The following commands expect file addresses of two kinds: +.br +.B disk_path +is a path to an object in the local filesystem tree. +.br +.B iso_rr_path +is the Rock Ridge name of a file object in the ISO image. (Do not +confuse with the lowlevel ISO 9660 names visible if Rock Ridge gets ignored.) +.PP +Note that in the ISO image you are as powerful as the superuser. Access +permissions of the existing files in the image do not apply to your write +operations. They are intended to be in effect with the read-only mounted image. +.PP +If the iso_rr_path of a newly inserted file leads to an existing +file object in the ISO image, then the following collision handling +happens: +.br +If both objects are directories then they get merged by recursively inserting +the subobjects from filesystem into ISO image. +If other file types collide then the setting of command +.B \-overwrite +decides. +.br +Renaming of files has similar collision handling, but directories can only +be replaced, not merged. Note that -mv inserts the source objects into an +eventual existing target directory rather than attempting to replace it. +.PP +The commands in this section alter the ISO image and not the local filesystem. +.TP +\fB\-iso_rr_pattern\fR "on"|"ls"|"off" +Set the pattern expansion mode for the iso_rr_path arguments of several +commands which support this feature. +.br +.B Pattern expansion +converts a list of pattern words into a list of existing file addresses. +Eventual unmatched pattern words appear themselves in that result list, though. +.br +Pattern matching supports the usual shell parser wildcards '*' '?' '[xyz]' +and respects '/' as separator which may only be matched literally. +.br +Setting "off" disables this feature for all commands which are marked in this +man page by "iso_rr_path [***]" or "iso_rr_pattern [***]". +.br +Setting "on" enables it for all those commands. +.br +Setting "ls" enables it only for those which are marked by +"iso_rr_pattern [***]". +.br +Default is "on". +.TP +\fB\-disk_pattern\fR "on"|"ls"|"off" +Set the pattern expansion mode for the disk_path arguments of several +commands which support this feature. +.br +Setting "off" disables this feature for all commands which are marked in this +man page by "disk_path [***]" or "disk_pattern [***]". +.br +Setting "on" enables it for all those commands. +.br +Setting "ls" enables it only for those which are marked by +"disk_pattern [***]". +.br +Default is "ls". +.TP +\fB\-add\fR pathspec [...] | disk_path [***] +Insert the given files or directory trees from filesystem +into the ISO image. +.br +If -pathspecs is set to "on" then pattern expansion is always disabled and +character '=' has a special meaning. It eventually separates the ISO image path +from the disk path: +.br +iso_rr_path=disk_path +.br +The separator '=' can be escaped by '\\'. +If iso_rr_path does not begin with '/' then -cd is prepended. +If disk_path does not begin with '/' then -cdx is prepended. +.br +If no '=' is given then the word is used as both, iso_rr_path and disk path. +If in this case the word does not begin with '/' then -cdx is prepended to +the disk_path and -cd is prepended to the iso_rr_path. +.br +If -pathspecs is set to "off" then eventual -disk_pattern expansion applies. +The resulting words are used as both, iso_rr_path and disk path. Eventually +-cdx gets prepended to disk_path and -cd to iso_rr_path. +.TP +\fB\-add_plainly\fR mode +If set to mode "unknown" then any command word that does not begin with "-" and +is not recognized as known command will be subject to a virtual -add command. +I.e. it will be used as pathspec or as disk_path and added to the image. +Eventually -disk_pattern expansion applies to disk_paths. +.br +Mode "dashed" is similar to "unknown" but also adds unrecognized command +words even if they begin with "-". +.br +Mode "any" announces that all further words are to be added as pathspecs +or disk_paths. This does not work in dialog mode. +.br +Mode "none" is the default. It prevents any words from being understood +as files to add, if they are not parameters to appropriate commands. +.TP +\fB\-path_list\fR disk_path +Like -add but read the parameter words from file disk_path +or standard input if disk_path is "-". +The list must contain exactly one pathspec resp. disk_path pattern per line. +.TP +\fB\-quoted_path_list\fR disk_path +Like -path_list but with quoted input reading rules. Lines get split into +parameter words for -add. Whitespace outside quotes is discarded. +.TP +\fB\-map\fR disk_path iso_rr_path +Insert file object disk_path into the ISO image as iso_rr_path. If disk_path +is a directory then its whole sub tree is inserted into the ISO image. +.TP +\fB\-map_single\fR disk_path iso_rr_path +Like -map, but if disk_path is a directory then its sub tree is not inserted. +.TP +\fB\-map_l\fR disk_prefix iso_rr_prefix disk_path [***] +Perform -map with each of the disk_path arguments. iso_rr_path will be +composed from disk_path by replacing disk_prefix by iso_rr_prefix. +.TP +\fB\-update\fR disk_path iso_rr_path +Compare file object disk_path with file object iso_rr_path. If they do not +match, then perform the necessary image manipulations to make iso_rr_path +a matching copy of disk_path. This comparison will imply lengthy content +reading before a decision is made. On the other hand it strives for the +smallest possible amount of add-on data which is needed to achieve the +matching copy. +.br +If disk_path is a directory and iso_rr_path does not exist yet, then the +whole subtree will be inserted. Else only directory attributes will be +updated. +.TP +\fB\-update_r\fR disk_path iso_rr_path +Like -update but working recursively. I.e. all file objects below both +addresses get compared whether they have counterparts below the other address +and whether both counterparts match. If there is a mismatch then the necessary +update manipulation is done. +.br +Note that the comparison result may depend on option -follow. Its setting +should always be the same as with the first adding of disk_path as iso_rr_path. +.br +If iso_rr_path does not exist yet, then it gets added. If disk_path does not +exist, then iso_rr_path gets deleted. +.TP +\fB\-update_l\fR disk_prefix iso_rr_prefix disk_path [***] +Perform -update_r with each of the disk_path arguments. iso_rr_path will be +composed from disk_path by replacing disk_prefix by iso_rr_prefix. +.TP +\fB\-cut_out\fR disk_path byte_offset byte_count iso_rr_path +Map a byte interval of a regular disk file into a regular file in the ISO +image. +This may be necessary if the disk file is larger than a single media, or if +it exceeds the traditional limit of 2 GiB - 1 for old operating systems, +or the limit of 4 GiB - 1 for newer ones. Only the newest Linux kernels +seem to read properly files >= 4 GiB - 1. +.br +A clumsy remedy for this limit is to backup file pieces and to concatenate +them at restore time. A well tested chopping size is 2047m. +It is permissible to request a higher byte_count than available. The +resulting file will be truncated to the correct size of a final piece. +To request a byte_offset higher than available yields no file in +the ISO image but a SORRY event. +E.g: +.br + -cut_out /my/disk/file 0 2047m \\ +.br + /file/part_1_of_3_at_0_with_2047m_of_5753194821 \\ +.br + -cut_out /my/disk/file 2047m 2047m \\ +.br + /file/part_2_of_3_at_2047m_with_2047m_of_5753194821 \\ +.br + -cut_out /my/disk/file 4094m 2047m \\ +.br + /file/part_3_of_3_at_4094m_with_2047m_of_5753194821 +.br +-cut_out is coordinated with -compare* and -update* if the names of the +part files follow a convention by which xorriso is able to recognize +file parts and process them accordingly: +.br +A disk file gets mapped to an ISO directory containing its split parts +as regular files. The parts have names which describe the splitting +by 5 numbers which are separated by some non-numerical text: +.br +part_number, total_parts, byte_offset, byte_count, disk_file_size +.br +Scaling characters like "m" or "k" are taken into respect and may +serve as separators as well. All digits are interpreted as decimal, +even if leading zeros are present. +.br +Not all parts have to be present on the same media. But those parts +which are present have to sit in the same directory. No other files +are allowed in there. Parts have to be disjoint. Their numbers have +to be plausible. E.g. byte_count must be valid as -cut_out argument +and it must be the same with all parts. +.br +If the disk file grows enough to need new parts then those get added +to the directory if it already contains all parts of the old disk file. +If not all parts are present, then only those present parts will +be updated. +.TP +\fB\-cpr\fR disk_path [***] iso_rr_path +Insert the given files or directory trees from filesystem +into the ISO image. +.br +The rules for generating the ISO addresses are similar as with +shell command cp -r. Nevertheless, directories of the iso_rr_path +are created if necessary. Especially a not yet existing iso_rr_path +will be handled as directory if multiple disk_paths are present. +The leafnames of the multiple disk_paths will be grafted under that +directory as would be done with an existing directory. +.br +If a single disk_path is present then a non-existing iso_rr_path will +get the same type as the disk_path. +.br +If a disk_path does not begin with '/' then -cdx is prepended. +If the iso_rr_path does not begin with '/' then -cd is prepended. +.TP +\fB\-rm\fR iso_rr_path [***] +Delete the given files from the ISO image. +.br +Note: This does not free any space on the -indev media, even if +the deletion is committed to that same media. +.br +The image size will shrink if the image is written to a different +media in modification mode. +.TP +\fB\-rm_r\fR iso_rr_path [***] +Delete the given files or directory trees from the ISO image. +See also the note with option -rm. +.TP +\fB\-mv\fR iso_rr_path [***] iso_rr_path +Rename the given file objects in the ISO tree to the last +argument in the list. Use the same rules as with shell command mv. +.br +If pattern expansion is enabled and if the last argument contains wildcard +characters then it must match exactly one existing file address, or else the +command fails with a FAILURE event. +.TP +\fB\-chown\fR uid iso_rr_path [***] +Set ownership of file objects in the ISO image. uid may either be a decimal +number or the name of a user known to the operating system. +.TP +\fB\-chown_r\fR uid iso_rr_path [***] +Like -chown but affecting all files below eventual directories. +.TP +\fB\-chgrp\fR gid iso_rr_path [***] +Set group attribute of file objects in the ISO image. gid may either be a +decimal number or the name of a group known to the operating system. +.TP +\fB\-chgrp_r\fR gid iso_rr_path [***] +Like -chgrp but affecting all files below eventual directories. +.TP +\fB\-chmod\fR mode iso_rr_path [***] +Equivalent to shell command chmod in the ISO image. +mode is either an octal number beginning with "0" or a comma separated +list of statements of the form [ugoa]*[+-=][rwxst]* . +.br +Like: go-rwx,u+rwx . +.br +.B Personalities: +u=user, g=group, o=others, a=all +.br +.B Operators: ++ adds given permissions, - revokes given permissions, += revokes all old permissions and then adds the given ones. +.br +.B Permissions: +r=read, w=write, x=execute|inspect, s=setuid|setgid, t=sticky bit +.br +For octal numbers see man 2 stat. +.TP +\fB\-chmod_r\fR mode iso_rr_path [***] +Like -chmod but affecting all files below eventual directories. +.TP +\fB\-setfacl\fR acl_text iso_rr_path [***] +Attach the given ACL to the given iso_rr_paths after deleting their eventually +existing ACLs. +If acl_text is empty, or contains the text "clear" or the text +"--remove-all", then the existing ACLs will be removed and no new ones will be +attached. Any other content of acl_text will be interpreted as a list of +ACL entries. It may be in the long multi-line format as put out by -getfacl +but may also be abbreviated as follows: +.br +ACL entries are separated by comma or newline. If an entry is empty text or +begins with "#" then it will be ignored. A valid entry has to begin +by a letter out of {ugom} for "user", "group", "other", "mask". It has to +contain two colons ":". A non-empty text between those ":" gives a user id +resp. group id. After the second ":" there may be letters out of {rwx- #}. +The first three give read, write resp. execute permission. +Letters "-", " " and TAB are ignored. "#" causes the rest of the entry to +be ignored. Letter "X" or any other letters are not supported. Examples: +.br + g:toolies:rw,u:lisa:rw,u:1001:rw,u::wr,g::r,o::r,m::rw +.br + group:toolies:rw-,user::rw-,group::r--,other::r--,mask::rw- +.br +A valid entry may be prefixed by "d", some following characters and ":". +This indicates that the entry goes to the "default" ACL rather than to the +"access" ACL. Example: +.br + u::rwx,g::rx,o::,d:u::rwx,d:g::rx,d:o::,d:u:lisa:rwx,d:m::rwx +.TP +\fB\-setfacl_r\fR acl_text iso_rr_path [***] +Like -setfacl but affecting all files below eventual directories. +.TP +\fB\-setfacl_list\fR disk_path +Read the output of -getfacl_r or shell command getfacl -R and apply it to the +iso_rr_paths as given in lines beginning with "# file:". This will change +ownership, group and ACL of the given files. +If disk_path is "-" then lines are read from standard input. Line "@" ends the +list, "@@@" aborts without changing the pending iso_rr_path. +.br +Since -getfacl and getfacl -R strip leading "/" from file paths, the setting of +-cd does always matter. +.TP +\fB\-setfattr\fR [-]name value iso_rr_path [***] +Attach the given xattr pair of name and value to the given iso_rr_paths. +If the given name is prefixed by "-", then the pair with that name gets +removed from the xattr list. If name is "--remove-all" then all user namespace +xattr of the given iso_rr_paths get deleted. In case of deletion, value must +be an empty text. +.br +Only names from the user namespace are allowed. I.e. a name has to begin with +"user.", like "user.x" or "user.whatever". +.br +Values and names undergo the normal input processing of xorriso. +See also option -backslash_codes. Other than with option -setfattr_list, +the byte value 0 cannot be expressed via -setfattr. +.TP +\fB\-setfattr_r\fR [-]name value iso_rr_path [***] +Like -setfattr but affecting all files below eventual directories. +.TP +\fB\-setfattr_list\fR disk_path +Read the output of -getfattr_r or shell command getfattr -Rd and apply it to +the iso_rr_paths as given in lines beginning with "# file:". All previously +existing user space xattr of the given iso_rr_paths will be deleted. +If disk_path is "-" then lines are read from standard input. +.br +Since -getfattr and getfattr -Rd strip leading "/" from file paths, the setting +of -cd does always matter. +.br +Empty input lines and lines which begin by "#" will be ignored +(except "# file:"). Line "@" ends the list, "@@@" aborts without changing the +pending iso_rr_path. Other input lines must have the form +.br + name="value" +.br +Name must be from user namespace. I.e. user.xyz where xyz should consist of +printable characters only. The separator "=" is not allowed in names. +Value may contain any kind of bytes. It must be in quotes. Trailing +whitespace after the end quote will be ignored. Non-printables bytes and quotes +must be represented as \\XYZ by their octal ASCII code XYZ. +Use code \\000 for 0-bytes. +.TP +\fB\-external_filter\fR name option[:option] program_path [arguments] -- +Register a content filter by associating a name with a program path, +program arguments, and some behavioral options. Once registered it can be +applied to multiple data files in the ISO image, regardless whether their +content resides in the loaded ISO image or in the local filesystem. +External filter processes may produce synthetic file content by reading the +original content from stdin and writing to stdout whatever they want. +They must deliver the same output on the same input in repeated runs. +.br +Options are: +.br + "default" means that no other option is intended. +.br + "suffix=..." sets a file name suffix. If it is not empty then it will be +appended to the file name or removed from it. +.br + "remove_suffix" will remove an eventual file name suffix +rather than appending it. +.br + "if_nonempty" will leave 0-sized files unfiltered. +.br + "if_reduction" will try filtering and revoke it if the content size does not +shrink. +.br + "if_block_reduction" will revoke if the number of 2 kB blocks does not shrink. +.br + "used=..." is ignored. Command -status shows it with the number of +files which currently have the filter applied. +.br +Examples: +.br + -external_filter bzip2 suffix=.bz2:if_block_reduction \\ +.br + /usr/bin/bzip2 -- +.br + -external_filter bunzip2 suffix=.bz2:remove_suffix \\ +.br + /usr/bin/bunzip2 -- +.TP +\fB\-unregister_filter\fR name +Remove an -external_filter registration. This is only possible if the filter +is not applied to any file in the ISO image. +.TP +\fB\-close_filter_list\fR +Irrevocably ban commands -external_filter and -unregister_filter, +but not -set_filter. Use this to prevent external filtering in general or +when all intended filters are registered. +External filters may also be banned totally at compile time of xorriso. +By default they are banned if xorriso runs under setuid permission. +.TP +\fB\-set_filter\fR name iso_rr_path [***] +Apply an -external_filter or a built-in filter to the given data files in the +ISO image. +If the filter suffix is not empty , then it will be applied to the file name. +Renaming only happens if the filter really gets attached and is not revoked by +its options. +By default files which already bear the suffix will not get filtered. The +others will get the suffix appended to their names. +If the filter has option "remove_suffix", then the filter will only be +applied if the suffix is present and can be removed. +Name oversize or collision caused by suffix change will prevent filtering. +.br +With most filter types this command will immediately run the filter once for +each file in order to determine the output size. +Content reading operations like -extract , -compare and image generation will +perform further filter runs and deliver filtered content. +.br +At image generation time the filter output must still be the same as the +output from the first run. Filtering for image generation does not happen +with files from the loaded ISO image if the write method of growing is in +effect (i.e -indev and -outdev are identical). +.br +The reserved filter name "--remove-all-filters" revokes filtering. This will +revoke eventual suffix renamings as well. Use "--remove-all-filters+" to +prevent any suffix renaming. +.br +Built-in filters are "--zisofs" and "--zisofs-decode". The former is to be +applied via -set_filter, the latter is automatically applied if zisofs +compressed content is detected with a file when loading the ISO image. +.br +Another built-in filter pair is "--gzip" and "--gunzip" with suffix ".gz". +They behave about like external gzip and gunzip but avoid forking a process +for each single file. So they are much faster if there are many small files. +.TP +\fB\-set_filter_r\fR name isuffix iso_rr_path [***] +Like -set_filter but affecting all data files below eventual directories. +.TP +\fB\-alter_date\fR type timestring iso_rr_path [***] +Alter the date entries of a file in the ISO image. type is +one of "a", "m", "b" for access time, modification time, +both times. +.br +timestring may be in the following formats +(see also section EXAMPLES): +.br +As expected by program date: + MMDDhhmm[[CC]YY][.ss]] +.br +As produced by program date: + [Day] MMM DD hh:mm:ss [TZON] YYYY +.br +Relative times counted from current clock time: + +|-Number["s"|"h"|"d"|"w"|"m"|"y"] +.br +where "s" means seconds, "h" hours, "d" days, "w" weeks, "m"=30d, +"y"=365.25d plus 1d added to multiplication result. +.br +Absolute seconds counted from Jan 1 1970: + =Number +.br +xorriso's own timestamps: + YYYY.MM.DD[.hh[mm[ss]]] +.br +scdbackup timestamps: + YYMMDD[.hhmm[ss]] +.br +where "A0" is year 2000, "B0" is 2010, etc. +.TP +\fB\-alter_date_r\fR type timestring iso_rr_path [***] +Like -alter_date but affecting all files below eventual directories. +.TP +\fB\-find\fR iso_rr_path [test [op] [test ...]] [-exec action [params]] -- +A restricted substitute for shell command find in the ISO image. +It performs an action on matching file objects at or below iso_rr_path. +.br +If not used as last command in the line then the argument list +needs to get terminated by "--". +.br +Tests are optional. If they are omitted then action is applied to all file +objects. If tests are given then they form together an expression. +The action is applied only if the expression matches the file object. Default +expression operator between tests is -and, i.e. the expression matches only +if all its tests match. +.br +Available tests are: +.br +\fB\-name\fR pattern : +Matches if pattern matches the file leaf name. +.br +\fB\-wholename\fR pattern : +Matches if pattern matches the file path as it would be printed by action +"echo". Character '/' is not special but can be matched by wildcards. +.br +\fB\-type\fR type_letter : +Matches files files of the given type: +"block", "char", "dir", "pipe", "file", "link", "socket", "eltorito", +"Xotic" which eventually matches what is not matched by the other types. +.br +Only the first letter is interpreted. E.g.: -find / -type d +.br +\fB\-damaged\fR : +Matches files which use data blocks marked as damaged by a previous +run of -check_media. The damage info vanishes when a new ISO image gets +loaded. +.br +\fB\-pending_data\fR : +Matches files which get their content from outside the loaded ISO image. +.br +\fB\-lba_range\fR start_lba block_count : +Matches files which use data blocks within the range of start_lba +and start_lba+block_count-1. +.br +\fB\-has_acl\fR : +Matches files which have a non-trivial ACL. +.br +\fB\-has_xattr\fR : +Matches files which have xattr name-value pairs from user namespace. +.br +\fB\-has_aaip\fR : +Matches files which have ACL or any xattr. +.br +\fB\-has_any_xattr\fR : +Matches files which have any xattr other than ACL. +.br +\fB\-has_md5\fR : +Matches data files which have MD5 checksums. +.br +\fB\-has_filter\fR : +Matches files which are filtered by -set_filter. +.br +\fB\-prune\fR : +If this test is reached and the tested file is a directory then -find will not +dive into that directory. This test itself does always match. +.br +\fB\-decision\fR "yes"|"no" : +If this test is reached then the evaluation ends immediately and action +is performed if the decision is "yes" or "true". See operator -if. +.br +\fB\-true\fR and \fB\-false\fR : +Always match resp. match not. Evaluation goes on. +.br +\fB\-sort_lba\fR : +Always match. This causes -find to perform its action in a sequence sorted by +the ISO image block addresses of the files. It may improve throughput with +actions which read data from optical drives. Action will always get the +absolute path as parameter. +.br +Available operators are: +.br +\fB\-not\fR : +Matches if the next test or sub expression does not match. +Several tests do this specifically: +.br +-undamaged, -lba_range with negative start_lba, -has_no_acl, -has_no_xattr, +-has_no_aaip, -has_no_filter +.br +\fB\-and\fR : +Matches if both neighboring tests or expressions match. +.br +\fB\-or\fR : +Matches if at least one of both neighboring tests or expressions matches. +.br +\fB\-sub\fR ... \fB\-subend\fR or \fB(\fR ... \fB)\fR : +Enclose a sub expression which gets evaluated first before it +is processed by neighboring operators. +Normal precedence is: -not, -or , -and. +.br +\fB\-if\fR ... \fB\-then\fR\ ... \fB\-elseif\fR ... \fB\-then\fR ... +\fB\-else\fR ... \fB\-endif\fR : +Enclose one or more sub expressions. If the -if expression matches, then +the -then expression is evaluated as the result of the whole expression +up to -endif. Else the next -elseif expression is evaluated and eventually +its -then expression. Finally in case of no match, the -else expression +is evaluated. +There may be more than one -elseif. Neither -else nor -elseif are mandatory. +If -else is missing and would be hit, then the result is a non-match. +.br +-if-expressions are the main use case for above test -decision. + +Default action is \fBecho\fR, +i.e. to print the address of the found file. Other actions are certain +xorriso commands which get performed on the found files. These commands +may have specific parameters. See also their particular descriptions. +.br +\fBchown\fR and \fBchown_r\fR change the ownership and get the user id +as parameter. E.g.: -exec chown thomas -- +.br +\fBchgrp\fR and \fBchgrp_r\fR change the group attribute and get the group id +as paramieter. E.g.: -exec chgrp_r staff -- +.br +\fBchmod\fR and \fBchmod_r\fR change access permissions and get a mode string +as parameter. E.g.: -exec chmod a-w,a+r -- +.br +\fBalter_date\fR and \fBalter_date_r\fR change the timestamps. They get a type +character and a timestring as parameters. +.br +E.g.: -exec alter_date "m" "Dec 30 19:34:12 2007" -- +.br +\fBlsdl\fR prints file information like shell command ls -dl. +.br +\fBcompare\fR performs command -compare with the found file address as +iso_rr_path and the corresponding file address below its argument +disk_path_start. For this the iso_rr_path of the -find command gets +replaced by the disk_path_start. +.br +E.g.: -find /thomas -exec compare /home/thomas -- +.br +\fBupdate\fR performs command -update with the found file address as +iso_rr_path. The corresponding file address is determined like with above +action "compare". +.br +\fBrm\fR removes the found iso_rr_path from the image if it is not a directory +with files in it. I.e. this "rm" includes "rmdir". +.br +\fBrm_r\fR removes the found iso_rr_path from the image, including whole +directory trees. +.br +\fBreport_damage\fR classifies files whether they hit a data block that is +marked as damaged. The result is printed together with the eventual address +of the first damaged byte, the maximum span of damages, file size, and the +path of the file. +.br +\fBreport_lba\fR prints files which are associated to image data blocks. +It tells the logical block address, the block number, the byte size, +and the path of each file. There may be reported more than one +line per file if the file is very large. In this case each line has a +different extent number in column "xt". +.br +\fBgetfacl\fR prints access permissions in ACL text form to the result channel. +.br +\fBsetfacl\fR attaches ACLs after removing eventually exiting ones. The new +ACL is given in text form as defined with option -setfacl. +.br +E.g.: -exec setfacl u:lisa:rw,u::rw,g::r,o::-,m::rw -- +.br +\fBgetfattr\fR prints eventual xattr name-value pairs from user namespace +to the result channel. +.br +\fBget_any_xattr\fR prints eventual xattr name-value pairs from any namespace +except ACL to the result channel. This is mostly for debugging of +namespace "isofs". +.br +\fBget_md5\fR prints eventual recorded MD5 sum together with file path. +.br +\fBcheck_md5\fR compares eventual recorded MD5 sum with the file content +and reports if mismatch. +.br +E.g.: -find / -not -pending_data -exec check_md5 FAILURE -- +\fBmake_md5\fR equips a data file with an MD5 sum of its content. Useful to +upgrade the files in the loaded image to full MD5 coverage by the next +commit with -md5 "on". +.br +E.g.: -find / -type f -not -has_md5 -exec make_md5 -- +.br +\fBsetfattr\fR sets or deletes xattr name value pairs. +.br +E.g.: -find / -has_xattr -exec setfattr --remove-all '' -- +.br +\fBset_filter\fR applies or removes filters. +.br +E.g.: -exec set_filter --zisofs -- +.br +\fBshow_stream\fR shows the content stream chain of a data file. +.br +\fBfind\fR performs another run of -find on the matching file address. +It accepts the same params as -find, except iso_rr_path. +.br +E.g.: +.br + -find / -name '???' -type d -exec find -name '[abc]*' -exec chmod a-w,a+r -- +.TP +\fB\-mkdir\fR iso_rr_path [...] +Create empty directories if they do not exist yet. +Existence as directory generates a WARNING event, existence as +other file causes a FAILURE event. +.TP +\fB\-rmdir\fR iso_rr_path [***] +Delete empty directories. +.TP +\fB\-rollback\fR +Discard the manipulated ISO image and reload it from -indev. +.TP +\fB\-rollback_end\fR +Discard the manipulated ISO image. End program without loading a new image. +.TP +.B Writing the result, drive control: +(see also paragraph about settings below) +.TP +\fB\-commit\fR +Perform the write operation. Afterwards eventually make the +-outdev the new -dev and load the image from there. +Switch to growing mode. +(A subsequent -outdev will activate modification mode or blind growing.) +-commit is performed automatically at end of program if there +are uncommitted manipulations pending. +So, to perform a final write operation with no new -dev +and no new loading of image, rather execute option -end. +To suppress a final write, execute -rollback_end. +To eject outdev after write without new loading of image, use -commit_eject. +.br + +Writing can last quite a while. It is not unnormal with several +types of media that there is no progress visible for the first +few minutes or that the drive gnaws on the media for a few +minutes after all data have been transmitted. +xorriso and the drives are in a client-server relationship. +The drives have much freedom about what to do with the media. +Some combinations of drives and media simply do not work, +despite the promises by their vendors. +If writing fails - or even the drive gets stuck and you need +to reboot - then try other media or another drive. The reason +for such failure is hardly ever in the code of the various +burn programs but you may well try some of those listed below +under SEE ALSO. +.TP +\fB\-eject\fR "in"|"out"|"all" +Eject the media in -indev, resp. -outdev, resp. both drives. +Note: It is not possible yet to effectively eject disk files. +.TP +\fB\-commit_eject\fR "in"|"out"|"all"|"none" +Combined -commit and -eject. When writing has finished do not make +-outdev the new -dev, and load no ISO image. Rather eject +-indev and/or -outdev. Eventually give up any non-ejected drive. +.TP +\fB\-blank\fR mode +Make media ready for writing from scratch (if not -dummy is activated). +.br +This affects only the -outdev not the -indev. +If both drives are the same and if the ISO image was altered +then this command leads to a FAILURE event. +Defined modes are: + as_needed, fast, all, deformat, deformat_quickest +.br +"as_needed" cares for used CD-RW, DVD-RW and for used overwriteable media +by applying -blank "fast". It applies -format "full" to yet unformatted +DVD-RAM and BD-RE. Other media in blank state are gracefully ignored. +Media which cannot be made ready for writing from scratch cause a FAILURE +event. +.br +"fast" and "all" make CD-RW and unformatted DVD-RW re-usable, +or invalidate overwriteable ISO images. +.br +"deformat" converts overwriteable DVD-RW into unformatted ones. +.br +"deformat_quickest" is a faster way to deformat or blank DVD-RW +but produces media which are only suitable for a single session. +xorriso will write onto them only if option -close is set to "on". +.br +The progress reports issued by some drives while blanking are +quite unrealistic. Do not conclude success or failure from the +reported percentages. Blanking was successful if no SORRY event or +worse occured. +.TP +\fB\-format\fR mode +Convert unformatted DVD-RW into overwriteable ones, "de-ice" DVD+RW, format +newly purchased BD-RE or BD-R, re-format DVD-RAM or BD-RE. +.br +Defined modes are: +.br + as_needed, full, fast, by_index_<num>, fast_by_index_<num> +.br +"as_needed" formats yet unformatted DVD-RW, DVD-RAM, BD-RE, or blank +unformatted BD-R. Other media are left untouched. +.br +"full" (re-)formats DVD-RW, DVD+RW, DVD-RAM, BD-RE, or blank unformatted BD-R. +.br +"fast" does the same as "full" but tries to be quicker. +.br +"by_index_" selects a format out of the descriptor list issued by option +-list_formats. The index number from that list is to be appended to the +mode word. E.g: "by_index_3". +.br +"fast_by_index_" does the same as "by_index_" but tries to be quicker. +.br +"by_size_" selects a format out of the descriptor list which provides at +least the given size. That size is to be appended to the mode word. +E.g: "by_size_4100m". This applies to media with Defect Management. +.br +"fast_by_size_" does the same as "by_size_" but tries to be quicker. +.br +The formatting action has no effect on media if -dummy is activated. +.br +Formatting is normally needed only once during the lifetime of a media, +if ever. But it is a reason for re-formatting if: +.br + DVD-RW was deformatted by -blank, +.br + DVD+RW has read failures (re-format before next write), +.br + DVD-RAM or BD-RE shall change their amount of defect reserve. +.br +BD-R may be written unformatted or may be formatted before first use. +Formatting activates Defect Management which tries to catch and repair +bad spots on media during the write process at the expense of half speed +even with flawless media. +.br +The progress reports issued by some drives while formatting are +quite unrealistic. Do not conclude success or failure from the +reported percentages. Formatting was successful if no SORRY event +or worse occured. Be patient with apparently frozen progress. +.TP +\fB\-list_formats\fR +Put out a list of format descriptors as reported by the output drive for +the current media. The list gives the index number after "Format idx", +a MMC format code, the announced size in blocks (like "2236704s") +and the same size in MiB. +.br +MMC format codes are manifold. Most important are: +"00h" general formatting, "01h" increases reserve space for DVD-RAM, +"26h" for DVD+RW, "30h" for BD-RE with reserve space, +"31h" for BD-RE without reserve space, "32h" for BD-R. +.br +Smaller format size with DVD-RAM, BD-RE, or BD-R means more reserve space. +.TP +\fB\-list_profiles\fR "in"|"out"|"all" +Put out a list of media types supported by -indev, resp. -outdev, resp. both. +The currently recognized type is marked by text "(current)". +.TP +.B Settings for data insertion: +.TP +\fB\-file_size_limit\fR value [value [...]] -- +Set the maximum permissible size for a single data file. The values get +summed up for the actual limit. If the only value is "off" then the file +size is not limited by xorriso. Default is a limit of 100 extents, 4g -2k each: +.br + -file_size_limit 400g -200k -- +.br +When mounting ISO 9660 filesystems, old operating systems can handle only files +up to 2g -1 --. Newer ones are good up to 4g -1 --. +You need quite a new Linux kernel to read correctly the final bytes +of a file >= 4g if its size is not aligned to 2048 byte blocks. +.br +xorriso's own data read capabilities are not affected by eventual +operating system size limits. They apply to mounting only. Nevertheless, +the target filesystem of an -extract must be able to take the file size. +.TP +\fB\-not_mgt\fR code[:code[...]] +Control the behavior of the exclusion lists. +.br +Exclusion processing happens before disk_paths get mapped to the ISO image +and before disk files get compared with image files. +The absolute disk path of the source is matched against the -not_paths list. +The leafname of the disk path is matched against the patterns in the -not_leaf +list. If a match is detected then the disk path will not be regarded as an +existing file and not be added to the ISO image. +.br +Several codes are defined. +The _on/_off settings persist until they are revoked by their_off/_on +counterparts. +.br +"erase" empties the lists which were accumulated by -not_paths and -not_leaf. +.br +"reset" is like "erase" but also re-installs default behavior. +.br +"off" disables exclusion processing temporarily without invalidating +the lists and settings. +.br +"on" re-enables exclusion processing. +.br +"param_off" applies exclusion processing only to paths below disk_path +parameter of commands. I.e. explicitely given disk_paths are exempted +from exclusion processing. +.br +"param_on" applies exclusion processing to command parameters as well as +to files below such parameters. +.br +"subtree_off" with "param_on" excludes parameter paths only if they +match a -not_paths item exactly. +.br +"subtree_on" additionally excludes parameter paths which lead to a file +address below any -not_paths item. +.br +"ignore_off" treats excluded disk files as if they were missing. I.e. they +get reported with -compare and deleted from the image with -update. +.br +"ignore_on" keeps excluded files out of -compare or -update activities. +.TP +\fB\-not_paths\fR disk_path [***] +Add the given paths to the list of excluded absolute disk paths. If a given +path is relative, then the current -cdx is prepended to form an absolute path. +Eventual pattern matching happens at definition time and not when exclusion +checks are made. +.br +(Do not forget to end the list of disk_paths by "--") +.TP +\fB\-not_leaf\fR pattern +Add a single shell parser style pattern to the list of exclusions for +disk leafnames. These patterns are evaluated when the exclusion checks are +made. +.TP +\fB\-not_list\fR disk_path +Read lines from disk_path and use each of them either as -not_paths argument, +if they contain a / character, or as -not_leaf pattern. +.TP +\fB\-quoted_not_list\fR disk_path +Like -not_list but with quoted input reading rules. Each word is +handled as one argument for -not_paths resp. -not_leaf. +.TP +\fB\-follow\fR occasion[:occasion[...]] +Enable or disable resolution of symbolic links and mountpoints under +disk_paths. This applies to actions -add, -du*x, -ls*x, -findx, +and to -disk_pattern expansion. +.br +There are two kinds of follow decisison to be made: +.br +"link" is the hop from a symbolic link to its target file object. +If enabled then symbolic links are handled as their target file objects, +else symbolic links are handled as themselves. +.br +"mount" is the hop from one filesystem to another subordinate filesystem. +If enabled then mountpoint directories are handled as any other directory, +else mountpoints are handled as empty directories if they are encountered in +directory tree traversals. +.br +Less general than above occasions: +.br +"pattern" is mount and link hopping, but only during -disk_pattern expansion. +.br +"param" is link hopping for parameter words (after eventual pattern expansion). +If enabled then -ls*x will show the link targets rather than the links +themselves. -du*x, -findx, and -add will process the link targets but not +follow links in an eventual directory tree below the targets (unless "link" +is enabled). +.br +Occasions can be combined in a colon separated list. All occasions +mentioned in the list will then lead to a positive follow decision. +.br +"off" prevents any positive follow decision. Use it if no other occasion +applies. +.br +Shortcuts: +.br +"default" is equivalent to "pattern:mount:limit=100". +.br +"on" always decides positive. Equivalent to "link:mount". +.br + +Not an occasion but an optional setting is: +.br +"limit="<number> which sets the maximum number of link hops. +A link hop consists of a sequence of symbolic links and a final target +of different type. Nevertheless those hops can loop. Example: +.br + \fB$\fR ln -s .. uploop +.br +Link hopping has a built-in loop detection which stops hopping at the first +repetition of a link target. Then the repeated link is handled as itself +and not as its target. +Regrettably one can construct link networks which +cause exponential workload before their loops get detected. +The number given with "limit=" can curb this workload at the risk of truncating +an intentional sequence of link hops. +.TP +\fB\-pathspecs\fR "on"|"off" +Control parameter interpretation with xorriso actions -add and -path_list. +.br +"on" enables pathspecs of the form +.B target=source +like with program mkisofs -graft-points. +It also disables -disk_pattern expansion for command -add. +.br +"off" disables pathspecs of the form target=source +and eventually enables -disk_pattern expansion. +.TP +\fB\-overwrite\fR "on"|"nondir"|"off" +Allow or disallow to overwrite existing files in the +ISO image by files with the same user defined name. +.br +With setting "off", name collisions cause FAILURE events. +With setting "nondir", only directories are protected by such events, other +existing file types get treated with -rm before the new file gets added. +Setting "on" allows automatic -rm_r. I.e. a non-directory can replace an +existing directory and all its subordinates. +.br +If restoring of files is enabled, then the overwrite rule applies to the +target file objects on disk as well, but "on" is downgraded to "nondir". +.TP +\fB\-split_size\fR number["k"|"m"] +Set the threshold for automatic splitting of regular files. Such splitting +maps a large disk file onto a ISO directory with several part files in it. +This is necessary if the size of the disk file exceeds -file_size_limit. +Older operating systems can handle files in mounted ISO 9660 filesystems +only if they are smaller than 2 GiB resp. 4 GiB. +See also option -cut_out for more information about file parts. +.br +Default is 0 which will exclude files larger than -file_size_limit by a +FAILURE event. +A well tested -split_size is 2047m. Sizes above -file_size_limit are not +permissible. +.TP +.B Settings for result writing: +.TP +Rock Ridge info will be generated by the program unconditionally. +ACLs will be written according to the setting of option -acl. +.TP +\fB\-joliet\fR "on"|"off" +If enabled by "on", generate Joliet info additional to Rock Ridge info. +.TP +\fB\-compliance\fR rule[:rule...] +Adjust the compliance to specifications of ISO 9660 and its contemporary +extensions. In some +cases it is worth to deviate a bit in order to circumvent bugs of the intended +reader system or to get inofficial extra features. +.br +There are several adjustable rules which have a keyword each. If they +are mentioned with this option then their rule gets added to the relaxation +list. This list can be erased by rules "strict" or "clear". It can be reset +to its start setting by "default". All of the following relaxation rules +can be revoked individually by appending "_off". Like "deep_paths_off". +.br +Rule keywords are: +.br +"omit_version" do not add versions (";1") to ISO file names. +.br +"deep_paths" allow ISO file paths deeper than 8 levels. +.br +"long_paths" allow ISO file paths longer than 255 characters. +.br +"long_names" allow up to 37 characters with ISO file names. +.br +"no_force_dots" do not add a dot to ISO file names which have none. +.br +"lowercase" allow lowercase characters in ISO file names. +.br +"full_ascii" allow all ASCII characters in ISO file names. +.br +"joliet_long_paths" allow Joliet paths longer than 240 characters. +.br +"always_gmt" store timestamps in GMT representation with timezone 0. +.br +"rec_mtime" record with ISO files the disk file's mtime and not the +creation time of the image. +.br +"new_rr" use Rock Ridge version 1.12 (suitable for Linux but not for older +FreeBSD or for Solaris). This implies "aaip_susp_1_10_off" which may be changed +by subsequent "aaip_susp_1_10". +.br +Default is "old_rr" which uses Rock Ridge version 1.10. This implies also +"aaip_susp_1_10" which may be changed by subsequent "aaip_susp_1_10_off". +.br +"aaip_susp_1_10" allows AAIP to be written as inofficial extension of RRIP +rather than as official extension under SUSP-1.12. +.br +Default setting is +.br + "clear:deep_paths:long_paths:always_gmt:old_rr". +.br +Note: The term "ISO file" means the plain ISO 9660 names and attributes +which get visible if the reader ignores Rock Ridge. +.TP +\fB\-volid\fR text +Specify the volume ID. xorriso accepts any text up to 32 characters, +but according to rarely obeyed specs stricter rules apply: +.br +ECMA 119 demands ASCII characters out of [A-Z0-9_]. Like: "IMAGE_23" +.br +Joliet allows 16 UCS-2 characters. Like: "Windows name" +.br +Be aware that the volume id might get used automatically as name of the +mount point when the media is inserted into a playful computer system. +.br +If an ISO image gets loaded while the volume ID is set to default "ISOIMAGE" +or to "", then the volume ID of the loaded image will become the effective +volume id for the next write run. But as soon as command -volid is performed +afterwards, this pending id is overridden by the new setting. +.br +Consider this when setting -volid "ISOIMAGE" before executing -dev, -indev, +or -rollback. +If you insist in -volid "ISOIMAGE", set it again after those commands. +.TP +\fB\-publisher\fR text +Set the publisher string to be written with the next -commit. Permissible +are up to 128 characters. +.TP +\fB\-application_id\fR text +Set the application id string to be written with the next -commit. Permissible +are up to 128 characters. +.TP +\fB\-out_charset\fR character_set_name +Set the character set to which file names get converted when writing an +image. See paragraph "Character sets" for more explanations. +When loading the written image after -commit the setting of -out_charset +will be copied to -in_charset. +.TP +\fB\-uid\fR uid +User id to be used for all files when the new ISO tree gets written to media. +.TP +\fB\-gid\fR gid +Group id to be used for all files when the new ISO tree gets written to media. +.TP +\fB\-zisofs\fR option[:options] +Set global parameters for zisofs compression. This data format is recognized +and transparently uncompressed by some Linux kernels. It is to be applied +via option -set_filter with built-in filter "--zisofs". +Parameters are: +.br + "level="[0-9] zlib compression: 0=none, 1=fast,..., 9=slow +.br + "block_size="32k|64k|128k size of compression blocks +.br + "by_magic=on" enables an expensive test at image generation time which checks +files from disk whether they already are zisofs compressed, e.g. by program +mkzftree. +.br + "default" same as "level=6:block_size=32k:by_magic=off" +.TP +\fB\-speed\fR number[k|m|c|d|b] +Set the burn speed. Default is 0 = maximum speed. +Speed can be given in media dependent numbers or as a +desired throughput per second in MMC compliant kB (= 1000) +or MB (= 1000 kB). Media x-speed factor can be set explicity +by "c" for CD, "d" for DVD, "b" for BD, "x" is optional. +.br +Example speeds: +.br + 706k = 706kB/s = 4c = 4xCD +.br + 5540k = 5540kB/s = 4d = 4xDVD +.br +If there is no hint about the speed unit attached, then the +media in the -outdev will decide. Default unit is CD = 176.4k. +.br +MMC drives usually activate their own idea of speed and take +the speed value given by the burn program only as upper limit +for their own decision. +.TP +\fB\-stream_recording\fR "on"|"off"|"full"|"data"|number +Setting "on" tries to circumvent the management of defects on DVD-RAM, BD-RE, +or BD-R. Defect management keeps partly damaged media usable. But it reduces +write speed to half nominal speed even if the media is in perfect shape. +For the case of flawless media, one may use -stream_recording "on" to get +full speed. +.br +"full" tries full speed with all write operations, whereas "on" does this +only above byte address 32s. One may give a number of at least 16s +in order to set an own address limit. +.br +"data" causes full speed to start when superblock and directory entries are +written and writing of file content blocks begins. +.TP +\fB\-dummy\fR "on"|"off" +If "on" then simulate burning or refuse with FAILURE event if +no simulation is possible, do neither blank nor format. +.TP +\fB-fs\fR number["k"|"m"] +Set the size of the fifo buffer which smoothens the data +stream from ISO image generation to media burning. Default +is 4 MiB, minimum 64 kiB, maximum 1 GiB. +The number may be followed by letter "k" or "m" +which means unit is kiB (= 1024) or MiB (= 1024 kiB). +.TP +\fB\-close\fR "on"|"off" +If "on" then mark the written media as not appendable +any more (if possible at all with the given type of target media). +.br +This is the contrary of cdrecord, wodim, cdrskin option -multi, +and is one aspect of growisofs option -dvd-compat. +.TP +\fB\-padding\fR number["k"|"m"] +Append the given number of extra bytes to the image stream. +This is a traditional remedy for a traditional bug in block +device read drivers. Needed only for CD recordings in TAO mode. +Since one can hardly predict on what media an image might end up, +xorriso adds the traditional 300k of padding by default to all images. +.br +For images which will never get to a CD it is safe to use -padding 0 . +.TP +.B El Torito bootable ISO images: +.PP +Contrary to published specifications many BIOSes will load an El Torito +object from the first session on media and not from the last one, which +gets mounted by default. This makes no problems with overwriteable media, +because they appear to inadverted readers as one single session. +.br +But with multi-session media CD-R[W], DVD-R[W], DVD+R, it implies that the +whole bootable system has to reside already in the first session and that +the last session still has to bear all files which the booted system expects +after eventually mounting the ISO image. +.br +If ISOLINUX is known to be present on media then it is advised to patch it +when a follow-up session gets written. But one should not rely on the +capability to influence the bootability of the existing sessions, unless one +can assume overwriteable media. +.TP +\fB\-boot_image\fR "any"|"isolinux" +.br + "discard"|"keep"|"patch"|"show_status"|bootspec +.br +Define the handling of an eventual El Torito object which has +been read from an existing ISO image or defines how to make a prepared +ISOLINUX file set bootable. +.br + +All types ("any") of El Torito boot images can be discarded or kept unaltered. +The latter makes only sense if the format of the boot image is +relocatable without content changes. +.br +With any type, "show_status" will print what is known about the loaded image +and its designated fate. +.br +An existing boot image of type "isolinux" can be discarded or it can be +patched to match its relocation. In the latter case the resulting ISO image +stays bootable if the boot image was really produced by ISOLINUX. +.br +CAUTION: +This is an expert option. +xorriso cannot recognize the inner form of boot images. +So the user has already to know about the particular needs of the +boot image which is present on the input media. +.br +Most safe is the default: -boot_image "any" "discard". +.br + +A bootspec is a word of the form name=value and is used to describe the +activation of a ISOLINUX boot image by an El Torito record and eventually +a MBR. The names "dir" and "bin_path" lead to boot image activation. +.br +On all media types this is possible within the first session. In further +sessions an existing boot image can get replaced by a new one, but depending +on the media type this may have few effect at boot time. See above. +.br +The ISOLINUX files have to be added to the ISO image by normal means +(image loading, -map, -add, ...) and should reside either in ISO image +directory /isolinux or in /boot/isolinux . +In that case it suffices to use as bootspec the text "dir=/isolinux" or +"dir=/boot/isolinux". E.g.: +.br + -boot_image isolinux dir=/boot/isolinux +.br +which bundles these individual settings: +.br + -boot_image isolinux bin_path=/boot/isolinux/isolinux.bin +.br + -boot_image isolinux cat_path=/boot/isolinux/boot.cat +.br + -boot_image isolinux load_size=2048 +.br +bin_path depicts the binary program which is to be started by the BIOS at +boot time. It is among the files produced by ISOLINUX. +.br +An El Torito boot catalog file gets inserted into the ISO image with address +cat_path at -commit time. +It is subject to normal -overwrite and -reassure processing if there is already +a file with the same name. +.br +Bootspec "isohybrid=off" disables MBR generation, "isohybrid=on" prevents the +write session if not the isohybrid signature is found in the bin_path file. +Default is "isohybrid=auto" which silently omits the MBR if the signature is +missing. +.TP +.B Character sets: +.PP +File names are strings of non-zero bytes with 8 bit each. Unfortunately +the same byte string may appear as different peculiar national characters +on differently nationalized terminals. +The meanings of byte codes are defined in \fBcharacter sets\fR which have +names. Shell command iconv -l lists them. +.br +Character sets should not matter as long as only english alphanumeric +characters are used for file names or as long as all writers and readers +of the media use the same character set. +Outside these constraints it may be necessary to let xorriso convert byte +codes. +.br +There is an input conversion from input character set to the local character +set which applies when an ISO image gets loaded. A conversion from local +character set to the output character set is performed when an +image tree gets written. The sets can be defined independently by options +-in_charset and -out_charset. Normally one will have both identical, if ever. +.br +If conversions are desired then xorriso needs to know the name of the +local character set. xorriso can inquire the same info as shell command +"locale" with argument "charmap". This may be influenced by environment +variables LC_ALL, LC_CTYPE, or LANG and should match the expectations of +the terminal. +.br +The default output charset is the local character set of the terminal where +xorriso runs. So by default no conversion happens between local filesystem +names and emerging names in the image. The situation stays ambigous and the +reader has to riddle what character set was used. +.br +By option -auto_charset it is possible to attribute the output charset name +to the image. This makes the situation unambigous. But if your terminal +character set does not match the character set of the local file names, +then this attribute can become plainly wrong and cause problems at read time. +To prevent this it is necessary to check whether the terminal properly +displays all intended filenames. Check especially the exotic national +characters. +.br +To enforce recording of a particular character set name without any conversion +at image generation time, set -charset and -local_charset to the desired name, +and enable -backslash_codes to avoid evil character display on your terminal. +.TP +\fB\-charset\fR character_set_name +Set the character set from which to convert file names when loading an +image and to which to convert when writing an image. +.TP +\fB\-local_charset\fR character_set_name +Override the system assumption of the local character set name. +If this appears necessary, one should consider to set -backslash_codes to +"on" in order to avoid dangerous binary codes being sent to the terminal. +.TP +.B Exception processing: +.PP +Since the tasks of xorriso are manifold and prone to external influence, there +may arise the need for xorriso to report and handle problem events. +.br +Those events get classified when they are detected by one of the software +modules and forwarded to reporting and evaluation modules which decide about +reactions. Event classes are sorted by severity: +.br +"NEVER" The upper end of the severity spectrum. +.br +"ABORT" The program is being aborted and on its way to end. +.br +"FATAL" The main purpose of the run failed +or an important resource failed unexpectedly. +.br +"FAILURE" An important part of the job could not be performed. +.br +"MISHAP" A FAILURE which can be tolerated during ISO image generation. +.br +"SORRY" A less important part of the job could not be performed. +.br +"WARNING" A situation is suspicious of being not intended by the user. +.br +"HINT" A proposal to the user how to achieve better results. +.br +"NOTE" A harmless information about noteworthy circumstances. +.br +"UPDATE" A pacifier message during long running operations. +.br +"DEBUG" A message which would only interest the program developers. +.br +"ALL" The lower end of the severity spectrum. +.TP +\fB\-abort_on\fR severity +Set the severity threshold for events to abort the program. +.br +Useful: "NEVER", "ABORT", "FATAL", "FAILURE" , "MISHAP", "SORRY" +.br +It may become necessary to abort the program anyway, despite +the setting by this option. Expect not many "ABORT" events to +be ignorable. +.br +A special property of this option is that it works preemptive if given as +program start argument. I.e. the first -abort_on setting among the +start arguments is in effect already when the first operations of xorriso +begin. Only "-abort_on" with dash "-" is recognized that way. +.TP +\fB\-return_with\fR severity exit_value +Set the threshold and exit_value to be returned at program end if no abort +has happened. This is to allow xorriso to go on after problems but to get +a failure indicating exit value from the program, nevertheless. +Useful is a value lower than the -abort_on threshold, down to "WARNING". +.br +exit_value may be either 0 (indicating success to the starter of the program) +or a number between 32 and 63. Some other exit_values are used by xorriso if +it decides to abort the program run: +.br +1=abort due to external signal +.br +2=no program arguments given +.br +3=creation of xorriso main object failed +.br +4=failure to start libburnia-project.org libraries +.br +5=program abort during argument processing +.br +6=program abort during dialog processing +.TP +\fB\-report_about\fR severity +Set the threshold for events to be reported. +.br +Useful: "SORRY", "WARNING", "HINT", "NOTE", "UPDATE", "DEBUG", "ALL" +.br +Regardless what is set by -report_about, messages get always reported if they +reach the severity threshold of -abort_on . +.br +Event messages are sent to the info channel "I" which is usually stderr +but may be influenced by command -pkt_output. +Info messages which belong to no event get attributed severity "NOTE". +.br +A special property of this option is that the first -report_about setting +among the start arguments is in effect already when the first operations +of xorriso begin. Only "-report_about" with dash "-" is recognized that way. +.TP +\fB\-error_behavior\fR occasion behavior +Control the program behavior at problem event occasions. +For now this applies to occasions "image_loading" which is given while +an image tree is read from the input device, and to "file_extraction" which +is given with osirrox options like -extract. +.br +With "image_loading" there are three behaviors available: +.br +"best_effort" goes on with reading after events with severity below FAILURE +if the threshold of option -abort_on allows this. +.br +"failure" aborts image tree reading on first event of at least SORRY. +It issues an own FAILURE event. +.br +"fatal" acts like "failure" but issues the own event as FATAL. +This is the default. +.br +With occasion "file_extraction" there are three behaviors: +.br +"keep" maintains incompletely extracted files on disk. This is the default. +.br +"delete" removes files which encountered errors during content extraction. +.br +"best_effort" starts a revovery attempt by means of -extract_cut if the +file content stems from the loaded ISO image and is not filtered. +.TP +.B Dialog mode control: +.TP +\fB\-dialog\fR "on"|"off"|"single_line" +Enable or disable to enter dialog mode after all arguments are processed. +In dialog mode input lines get prompted via readline or from stdin. +.br +Mode "on" supports input of newline characters within quotation marks and +line continuation by trailing backslash outside quotation marks. +Mode "single_line" does not. +.TP +\fB\-page\fR length width +Describe terminal to the text pager. See also above, paragraph Result pager. +.br +If parameter length is nonzero then the user gets prompted after that +number of terminal lines. Zero length disables paging. +.br +Parameter width is the number of characters per terminal line. It is used +to compute the number of terminal lines which get occupied by an output line. +A usual terminal width is 80. +.TP +\fB\-use_readline\fR "on"|"off" +If "on" then use readline for dialog. Else use plain stdin. +.br +See also above, paragraph Dialog, Readline, Result pager. +.TP +\fB\-reassure\fR "on"|"tree"|"off" +If "on" then ask the user for "y" or "n": +.br +before deleting or overwriting any file in the ISO image, +.br +before overwriting any disk file during restore operations, +.br +before rolling back pending image changes, +.br +before committing image changes to media, +.br +before changing the input drive, +.br +before blanking or formatting media, +.br +before ending the program. +.br +With setting "tree" the reassuring prompt will appear for an eventual +directory only once and not for each file in its whole subtree. +.br +Setting "off" silently kills any kind of image file object resp. performs +above irrevocable actions. +.br +To really produce user prompts, option -dialog needs to be set to "on". +Note that the prompt does not appear in situations where file removal +is forbidden by option -overwrite. -reassure only imposes an additional +curb for removing existing file objects. +.br +Be aware that file objects get deleted from the ISO image immediately +after confirmation. They are gone even if the running command gets aborted +and its desired effect gets revoked. In case of severe mess-up, consider to +use -rollback to revoke the whole session. +.TP +.B Drive and media related inquiry actions: +.TP +\fB\-devices\fR +Show list of available MMC drives with the addresses of +their libburn standard device files. +.br +This is only possible when no ISO image changes are pending. +After this option was executed, there is no drive current +and no image loaded. Eventually one has to aquire a drive again. +.br +In order to be visible, a device has to offer rw-permissions +with its libburn standard device file. Thus it might be only the +.B superuser +who is able to see all drives. +.br +Drives which are occupied by other processes get not shown. +.TP +\fB\-toc\fR +.br +Show media specific table of content. This is the media session history, +not the ISO image directory tree. +.br +In case of overwriteable media holding a valid ISO image, a single session +gets fabricated from the ISO image size info. But if the first session on the +overwriteable media was written by xorriso then in most cases a complete +session history can be emulated. +.br +A drive which is incapable of writing may show any media as CD-ROM or DVD-ROM +with only one or two sessions on it. The last of these sessions is supposed +to be the most recent real session then. +.br +Some read-only drives and media show no usable session history at all. +Eventually option -rom_toc_scan might help. +.TP +\fB\-mount_cmd\fR drive entity id path +Emit an appropriate command line for mounting the ISO session +indicated by drive, entity and id. +The result will be different on Linux and on FreeBSD. +.br +drive can be "indev" or "outdev" to indicate already aquired drives, +or it can be the path of a not yet acquired drive. +Prefix "stdio:" for non-MMC drives is not mandatory. +.br +entity must be either "sbsector" , "track" , "session" , "volid" +or "auto". See also option -load. +.br +id gives the superblock sector address, the track number, the session number, +or a search pattern for the volume id respectively. +.br +path will be used as mount point and must already exist as a directory. +.br +The command gets printed to the result channel. See option -mount +for direct execution of this command. +.TP +\fB\-session_string\fR drive entity id format +Print to the result channel a text which gets composed according to +format and the parameters of the addressed session. +.br +Formats "linux:"path or "freebsd:"path produce the output of -mount_cmd +for the given operating systems. +.br +In other texts xorriso will substitute the following parameter names. +An optional prefix "string:" will be removed. +.br +"%device%" will be substituted by the mountable device path of the drive +address. +.br +"%sbsector%" will be substituted by the session start sector. +.br +"%track%", "%session%", "%volid%" will be substituted by track number, +session number, resp. volume id of the depicted session. +.TP +\fB\-print_size\fR +Print the foreseeable consumption of 2048 byte blocks +by next -commit. This can last a while as a -commit gets +prepared and only in last moment is revoked by this option. +.TP +\fB\-tell_media_space\fR +Print available space on output media and the free space after +subtracting already foreseeable consumption by next -commit. +.TP +.B Navigation in ISO image and disk filesystem: +.TP +\fB\-cd\fR iso_rr_path +Change the current working directory in the emerging ISO +image as it is at the moment. This is prepended to iso_rr_paths +which do not begin with '/'. +.br +It is possible to set the working directory to a path which does not exist +yet in the ISO image. The necessary parent directories will be created when +the first file object is inserted into that virtual directory. +Use -mkdir if you want to enforce the existence of the directory already at +first insertion. +.TP +\fB\-cdx\fR disk_path +Change the current working directory on filesystem. +To be prepended to disk_paths which do not begin with '/'. +.TP +\fB\-pwd\fR +.br +Tell the current working directory in the ISO image. +.TP +\fB\-pwdx\fR +.br +Tell the current working directory on local filesystem. +.TP +\fB\-ls\fR iso_rr_pattern [***] +List files in the ISO image which match shell patterns +(i.e. with wildcards '*' '?' '[a-z]'). +If a pattern does not begin with '/' then it is compared with addresses +relative to -cd, the current working directory in the ISO image. +.br +Directories are listed by their content rather than as single file item. +.br +Pattern expansion may be disabled by command -iso_rr_pattern. +.TP +\fB\-lsd\fR iso_rr_pattern [***] +Like -ls but listing directories as themselves and not by their content. +This resembles shell command ls -d. +.TP +\fB\-lsl\fR iso_rr_pattern [***] +Like -ls but also list some of the file attributes. +The output format resembles shell command ls -ln. +.TP +\fB\-lsdl\fR iso_rr_pattern [***] +Like -lsd but also list some of the file attributes. +The output format resembles shell command ls -dln. +.TP +\fB\-lsx\fR disk_pattern [***] +List files on local filesystem which match shell patterns. Patterns which do +not begin with '/' are used relative to -cdx, the current working directory in +the local filesystem. +.br +Directories are listed by their content rather than as single file item. +.br +Pattern expansion may be disabled by command -disk_pattern. +.TP +\fB\-lsdx\fR disk_pattern [***] +Like -lsx but listing directories as themselves and not by their content. +This resembles shell command ls -d. +.TP +\fB\-lslx\fR disk_pattern [***] +Like -lsx but also listing some of the file attributes. +Output format resembles shell command ls -ln. +.TP +\fB\-lsdlx\fR disk_pattern [***] +Like -lsdx but also listing some of the file attributes. +Output format resembles shell command ls -dln. +.TP +\fB\-getfacl\fR iso_rr_pattern [***] +Print the access permissions of the given files in the ISO image using the +format of shell command getfacl. If a file has no ACL then it gets fabricated +from the -chmod settings. A file may have a real ACL if it was introduced into +the ISO image while option -acl was set to "on". +.TP +\fB\-getfacl_r\fR iso_rr_pattern [***] +Like -gefacl but listing recursively the whole file trees underneath eventual +directories. +.TP +\fB\-getfattr\fR iso_rr_pattern [***] +Print the xattr of the given files in the ISO image. +If a file has no such xattr then noting is printed for it. +.TP +\fB\-getfattr_r\fR iso_rr_pattern [***] +Like -gefattr but listing recursively the whole file trees underneath eventual +directories. +.TP +\fB\-du\fR iso_rr_pattern [***] +Recursively list size of directories and files in the ISO image +which match one of the patterns. +similar to shell command du -k. +.TP +\fB\-dus\fR iso_rr_pattern [***] +List size of directories and files in the ISO image +which match one of the patterns. +Similar to shell command du -sk. +.TP +\fB\-dux\fR disk_pattern [***] +Recursively list size of directories and files in the local filesystem +which match one of the patterns, similar to shell command du -k. +.TP +\fB\-dusx\fR disk_pattern [***] +List size of directories and files in the local filesystem +which match one of the patterns. +Similar to shell command du -sk. +.TP +\fB\-findx\fR disk_path [-name pattern] [-type t] [-exec action [params]] -- +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 -type arguments as -find. Additionally it recognizes +type "mountpoint" (or "m") which matches subdirectories which reside on a +different device than their parent. It never matches the disk_path +given as start address for -findx. +.br +-findx accepts the -exec actions as does -find. But except the following few +actions it will allways perform action "echo". +.br +\fBin_iso\fR reports the path if its counterpart exist in the ISO image. +For this the disk_path of the -findx command gets replaced +by the iso_rr_path given as parameter. +.br +E.g.: -findx /home/thomas -exec in_iso /thomas_on_cd -- +.br +\fBnot_in_iso\fR reports the path if its counterpart does +not exist in the ISO image. The report format is the same as with command +-compare. +.br +\fBadd_missing\fR iso_rr_path_start adds the counterpart if it does not yet +exist in the ISO image. +.br +E.g.: -findx /home/thomas -exec add_missing /thomas_on_cd -- +.br +\fBis_full_in_iso\fR reports if the counterpart in the ISO image +contains files. To be used with -type "m" to report mount points. +.br +\fBempty_iso_dir\fR deletes all files from the counterpart +in the ISO image. To be used with -type "m" to truncate mount points. +.TP +\fB\-compare\fR disk_path iso_rr_path +Compare attributes and eventual data file content of a fileobject in the +local filesystem with a file object in the ISO image. The iso_rr_path may +well point to an image file object which is not yet committed, i.e. of which +the data content still resides in the local filesystem. Such data content is +prone to externally caused changes. +.br +If iso_rr_path is empty then disk_path is used as path in the ISO image too. +.br +Differing attributes are reported in detail, differing content is summarized. +Both to the result channel. In case of no differences no result lines are +emitted. +.TP +\fB\-compare_r\fR disk_path iso_rr_path +Like -compare but working recursively. I.e. all file objects below both +addresses get compared whether they have counterparts below the other address +and whether both counterparts match. +.TP +\fB\-compare_l\fR disk_prefix iso_rr_prefix disk_path [***] +Perform -compare_r with each of the disk_path arguments. iso_rr_path will be +composed from disk_path by replacing disk_prefix by iso_rr_prefix. +.TP +\fB\-show_stream\fR iso_rr_path [***] +Display the content stream chain of data files in the ISO image. The chain +consists of the iso_rr_name and one or more streams, separated by " < " marks. +A stream consists of one or more texts eventually in ''-quotation marks, +eventually separated by ":" characters. The first text describes the stream +type, the following ones describe its individual properties. +Frequently used types are: +.br + disk:'disk_path' for local filesystem objects. +.br + image:'iso_rr_path' for ISO image file objects. +.br + cout:'disk_path offset count' for -cut_out files. +.br + extf:'filter_name' for external filters. +.br +Example: +.br + '/abc/xyz.gz' < extf:'gzip' < disk:'/home/me/x' +.TP +\fB\-show_stream_r\fR iso_rr_path [***] +Like -show_stream but working recursively. +.TP +.B Evaluation of readability and recovery: +.PP +It is not uncommon that optical media produce read errors. The reasons may be +various and get obscured by error correction which is performed by the drives +and based on extra data on the media. If a drive returns data then one can +quite trust that they are valid. But at some degree of read problems the +correction will fail and the drive is supposed to indicate error. +.br +xorriso can scan the media for readable data blocks, classify them according +to their read speed, save them to a file, and keep track of successfuly saved +blocks for further tries on the same media. +.br +By option -md5 checksums may get recorded with data files and whole +sessions. These checksums are reachable only via indev and a loaded image. +They work independently of the media type and can detect transmission errors. +.TP +\fB\-check_media\fR [option [option ...]] -- +Try to read data blocks from the indev drive, eventually copy them to a +disk file, and finally report about the encountered quality. Several options +may be used to modify the default behavior. +.br +The options given with this command override the default settings which +may have been changed by option -check_media_defaults. See there for a +description of options. +.br +The result list tells intervals of 2 KiB blocks with start address, number +of blocks and quality. Qualities which begin with "+" are +supposed to be valid readable data. Qualities with "-" are unreadable or +corrupted data. +"0" indicates qualities which are not covered by the check run or are regularly +allowed to to be unreadable (e.g. gaps between tracks). +.br +Alternatively it is possible to report damaged files rather than blocks. +.br +If -md5 is on then the default mode what=tracks looks out for libisofs +checksum tags for the ISO session data and and eventually checks them +against the checksums computed from the data stream. +.TP +\fB\-check_media_defaults\fR [option [option ...]] -- +Preset options for runs of -check_media, -extract_cut and best_effort +file extraction. Eventual options given with -check_media will override the +preset options. -extract_cut will override some options automatically. +.br +An option consists of a keyword, a "=" character, and a value. Options +may override each other. So their sequence matters. +.br +The default setting at program start is: +.br +use=indev what=tracks min_lba=-1 max_lba=-1 retry=default +.br +time_limit=28800 item_limit=100000 data_to='' event=ALL +.br +abort_file=/var/opt/xorriso/do_abort_check_media +.br +sector_map='' map_with_volid=off patch_lba0=off report=blocks +.br +Option "reset=now" restores these startup defaults. +.br +Non-default options are: +.br +"report=files" lists the files which use damaged blocks (not with use=outdev). +The format is like with find -exec report_damage. +.br +"report=blocks_files" first lists damaged blocks and then affected files. +.br +"use=outdev" reads from the output drive instead of the input drive. This +avoids loading the ISO image tree from media. +.br +"what=disc" scans the payload range of a media without respecting track gaps. +.br +"min_lba=" omits all blocks with addresses lower than the option value. +.br +"max_lba=" switches to what=disc and omits all blocks above its option value. +.br +"retry=on" forces read retries with single blocks when the normal read +chunk produces a read error. By default, retries are only enabled with CD +media. "retry=off" forbits retries for all media types. +.br +"abort_file=" gives the path of the file which may abort a scan run. Abort +happens if the file exists and its mtime is not older than the start time +of the run. Use shell command "touch" to trigger this. +Other than an aborted program run, this will report the tested and untested +blocks and go on with running xorriso. +.br +"time_limit=" gives the number of seconds after which the scan shall be +aborted. This is useful for unattended scanning of media which may else +overwork the drive in its effort to squeeze out some readable blocks. +Abort may be delayed by the drive gnawing on the last single read operation. +Value -1 means unlimited time. +.br +"item_limit=" gives the number of report list items after which to abort. +Value -1 means unlimited item number. +.br +"data_to=" copies the valid blocks to the file which is given as option value. +.br +"event=" sets the given severity for a problem event which shall be issued at +the end of a check run if data blocks were unreadable or failed to match +recorded MD5 checksums. Severity "ALL" disables this event. +.br +"sector_map=" tries to read the file given by option value as +sector bitmap and to store such a map file after the scan run. +The bitmap tells which blocks have been read successfully in previous runs. +It allows to do several scans on the same media, eventually with intermediate +eject, in order to collect readable blocks whenever the drive is lucky enough +to produce them. The stored file contains a human readable TOC of tracks +and their start block addresses, followed by binary bitmap data. +.br +"map_with_volid=on" examines tracks whether they are ISO images and eventually +prints their volume ids into the human readable TOC of sector_map=. +.br +"patch_lba0=on" transfers within the data_to= file a copy of the currently +loaded session head to the start of that file and patches it to be valid +at that position. +This makes the loaded session the default session of the image file +when it gets mounted or loaded as stdio: drive. But it usually makes +the original session 1 inaccessible. +.br +"patch_lba0=force" performs "patch_lba0=on" even if xorriso believes +that the copied data are not valid. +.br +"patch_lba0=" may also bear a number. If it is 32 or higher it is taken as +start address of the session to be copied. In this case it is not necessary to +have an -indev and a loaded image. ":force" may be appended after the number. +.br +"use=sector_map" does not read any media but loads the file given by option +sector_map= and processes this virtual outcome. +.TP +\fB\-check_md5\fR severity iso_rr_path [***] +Compare the data content of the given files in the loaded image with their +recorded MD5 checksums, if there are any. In case of any mismatch an event of +the given severity is issued. It may then be handled by appropriate settings of +options -abort_on or -return_with which both can cause non-zero exit values +of the program run. Severity ALL suppresses that event. +.br +This option reports match and mismatch of data files to the result channel. +Non-data files cause NOTE events. There will also be UPDATE events from +data reading. +.br +If no iso_rr_path is given then the whole loaded session is compared with its +MD5 sum. Be aware that this covers only one session and not the whole image +if there are older sessions. +.TP +\fB\-check_md5_r\fR severity iso_rr_path [***] +Like -check_md5 but checking all data files underneath the given paths. +Only mismatching data files will be reported. +.TP +.B osirrox restore options: +.PP +Normally xorriso only writes to disk files which were given as stdio: +pseudo-drives or as log files. +But its alter ego, osirrox, is able to extract file objects +from ISO images and to create, overwrite, or delete file objects on disk. +.br +Disk file exclusions by -not_mgt, -not_leaf, -not_paths apply. +If disk file objects already exist then the settings of -overwrite and +-reassure apply. But -overwrite "on" only triggers the behavior +of -overwrite "nondir". I.e. directories cannot be deleted. +.br +Access permissions of files in the ISO image do not restrict restoring. +The directory permissions on disk have to allow rwx. +.TP +\fB\-osirrox\fR "on"|"device_files"|"off"|"banned"|[:option:...] +Setting "off" disables disk filesystem manipulations. This is the default +unless the program was started with leafname "osirrox". Elsewise +the capability to restore files can be enabled explicitly by -osirrox "on". +It can be irrevocably disabled by -osirrox "banned". +.br +To enable restoring of special files by "device_files" is potentially +dangerous. +The meaning of the number st_rdev (see man 2 stat) depends much on the +operating system. Best is to restore device files only to the same system +from where they were copied. If not enabled, device files in the ISO image +are ignored during restore operations. +.br +Due to a bug of previous versions, device files from previous sessions might +have been altered to major=0, minor=1. So this combination does not get +restored. +.br +Option "concat_split_on" is default. It enables restoring of split file +directories as data files if the directory contains a complete collection +of -cut_out part files. With option "concat_split_off" such directories are +handled like any other ISO image directory. +.br +Option "auto_chmod_off" is default. If "auto_chmod_on" is set then access +restrictions for disk directories get circumvented if those directories +are owned by the effective user who runs xorriso. This happens by temporarily +granting rwx permission to the owner. +.br +Option "sort_lba_on" may improve read performance with optical drives. It +allows to restore large numbers of hard links without exhausting +-temp_mem_limit. It does not preserve directory mtime and it needs +-osirrox option auto_chmod_on in order to extract directories which offer no +write permission. Default is "sort_lba_off". +.TP +\fB\-extract\fR iso_rr_path disk_path +Restore the file objects at and underneath iso_rr_path to their corresponding +addresses at and underneath disk_path. +This is the inverse of -map or -update_r. +.br +If iso_rr_path is a directory and disk_path is an existing directory then +both trees will be merged. Directory attributes get extracted only if the disk +directory is newly created by the restore operation. +Disk files get removed only if they are to be replaced +by file objects from the ISO image. +.br +As many attributes as possible are copied together with restored +file objects. +.TP +\fB\-extract_single\fR iso_rr_path disk_path +Like -extract, but if iso_rr_path is a directory then its sub tree gets not +restored. +.TP +\fB\-extract_l\fR iso_rr_prefix disk_prefix iso_rr_path [***] +Perform -extract with each of the iso_rr_path arguments. disk_path will be +composed from iso_rr_path by replacing iso_rr_prefix by disk_prefix. +.TP +\fB\-extract_cut\fR iso_rr_path byte_offset byte_count disk_path +Copy a byte interval from a data file out of an ISO image into a newly created +disk file. +The main purpose for this is to allow handling of large files if they +are not supported by mount -t iso9660 and if the reading system is unable +to buffer them as a whole. +.br +If the data bytes of iso_rr_path are stored in the loaded ISO image, +and no filter is applied, +and byte_offset is a multiple of 2048, then a special run of -check_media +is performed. It may be quicker and more rugged than the general reading +method. +.TP +\fB\-cpx\fR iso_rr_path [***] disk_path +Extract single leaf file objects from the ISO image and store them under +the address given by disk_path. If more then one iso_rr_path is given then +disk_path must be a directory or non-existent. In the latter case it gets +created and the extracted files get installed in it with the same leafnames. +.br +Missing directory components in disk_path will get created, if possible. +.br +Directories are allowed as iso_rr_path only with -osirrox "concat_split_on" +and only if they actually represent a complete collection of -cut_out split +file parts. +.TP +\fB\-cpax\fR iso_rr_path [***] disk_path +Like -cpx but restoring mtime, atime as in ISO image and trying to set +ownership and group as in ISO image. +.TP +\fB\-cp_rx\fR iso_rr_path [***] disk_path +Like -cpx but also extracting whole directory trees from the ISO image. +.br +The resulting disk paths are determined as with shell command cp -r : +If disk_path is an existing directory then the trees will be inserted or merged +underneath this directory and will keep their leaf names. The ISO directory "/" +has no leaf name and thus gets mapped directly to disk_path. +.TP +\fB\-cp_rax\fR iso_rr_path [***] disk_path +Like -cp_rx but restoring mtime, atime as in ISO image and trying to set +ownership and group as in ISO image. +.TP +\fB\-paste_in\fR iso_rr_path disk_path byte_offset byte_count +Read the content of a ISO data file and write it into a data file on disk +beginning at the byte_offset. Write at most byte_count bytes. +This is the inverse of option -cut_out. +.TP +\fB\-mount\fR drive entity id path +Produce the same line as -mount_cmd and then execute it as external program run +after giving up the depicted drive. +This demands -osirrox to be enabled and normally will succeed only for the +superuser. For safety reasons the mount program is only executed if it is +reachable as /bin/mount or /sbin/mount. +.TP +.B Command compatibility emulations: +.PP +Writing of ISO 9660 on CD is traditionally done by program mkisofs +as ISO 9660 image producer and cdrecord as burn program. +xorriso does not strive for their comprehensive emulation. +Nevertheless it is ready to perform some of its core tasks under control +of commands which in said programs trigger comparable actions. +.TP +\fB\-as\fR personality option [options] -- +.br +Perform the variable length option list as sparse emulation of the program +depicted by the personality word. +.br + +Personality "\fBmkisofs\fR" accepts the options listed with: +.br + -as mkisofs -help -- +.br +Among them: -R (always on), -J, -o, -M, -C, -path-list, -m, -exclude-list, +-f, -print-size, -pad, -no-pad, -V, -v, -version, -graft-points, -z, +-no-emul-boot, -b, -c, -boot-info-table, -boot-load-size, -input-charset, +-output-charset, pathspecs as with xorriso -add. +A lot of options are not supported and lead to failure of the mkisofs +emulation. Some are ignored, but better do not rely on this tolerance. +.br +-graft-points is equivalent to -pathspecs on. Note that pathspecs without "=" +are interpreted differently than with xorriso option -add. Directories get +merged with the root directory of the ISO image, other filetypes get mapped +into that root directory. +.br +Other than with the "cdrecord" personality there is no automatic -commit at +the end of a "mkisofs" option list. Verbosity settings -v (= "UPDATE") and +-quiet (= "SORRY") persist. The output file, eventually chosen with -o, +persists until things happen like -commit, -rollback, -dev, or end of xorriso. +-pacifier gets set to "mkisofs" if files are added to the image. +.br +If pathspecs are given and if no output file was chosen before or during the +"mkisofs" option list, then standard output (-outdev "-") will get into effect. +If -o points to a regular file, then it will be truncated to 0 bytes +when finally writing begins. This truncation does not happen if the drive +is chosen by xorriso options before or after -as mkisofs. +Directories and symbolic links are no valid -o targets. +.br +Writing to stdout is possible only if -as "mkisofs" was among the start +arguments or if other start arguments pointed the output drive to +standard output. +.br +Not original mkisofs options are --quoted_path_list (see -quoted_path_list), +isolinux_mbr= (see -boot_image isolinux isohybrid=), +--hardlinks (see -hardlinks "on") --acl (see -acl "on"), +--xattr (see -xattr "on"). +.br +Personalites "\fBxorrisofs\fR", "\fBgenisoimage\fR", and "\fBgenisofs\fR" +are aliases for "mkisofs". +.br +If xorriso is started with one of the leafnames "xorrisofs", "genisofs", +"mkisofs", or "genisoimage", then it automatically prepends -as "genisofs" +to the command line arguments. I.e. all arguments will be interpreted mkisofs +style until "--" is encountered. From then on, options are interpreted +as xorriso options. +.br + +Personality "\fBcdrecord\fR" accepts the options listed with: +.br + -as cdrecord -help -- +.br +Among them: -v, dev=, speed=, blank=, fs=, -eject, -atip, padsize=, tsize=, +-isosize, -multi, -msinfo, --grow_overwriteable_iso, write_start_address=, +track source file path or "-" for standard input as track source. +.br +It ignores most other options of cdrecord and cdrskin but refuses on +-audio, -scanbus, and on blanking modes unknown to xorriso. +.br +The scope is only a single data track per session to be written +to blank, overwriteable, or appendable media. The media gets closed if +closing is applicable and not option -multi is present. +.br +An eventually aquired input drive is given up. +This is only allowed if no image changes are pending. +.br +dev= must be given as xorriso device address. Adresses like 0,0,0 or ATA:1,1,0 +are not supported. +.br +If a track source is given, then an automatic -commit happens at the end of +the "cdrecord" option list. +.br +--grow_overwriteable_iso enables emulation of multi-session on overwriteable +media. To enable emulation of a TOC, the first session needs -C 0,32 with +-as mkisofs (but no -M) and --grow_overwriteable_iso write_start_address=32s +with -as cdrecord. +.br +A much more elaborate libburn based cdrecord emulator is the program cdrskin. +.br +Personalites "\fBxorrecord\fR", "\fBwodim\fR", and "\fBcdrskin\fR" are aliases +for "cdrecord". +.br +If xorriso is started with one of the leafnames "xorrecord", "cdrskin", +"cdrecord", or "wodim", then it automatically prepends -as "cdrskin" +to the command line arguments. I.e. all arguments will be interpreted cdrecord +style until "--" is encountered and an eventual commit happens. +From then on, options are interpreted as xorriso options. +.TP +\fB\-pacifier\fR behavior_code +Control behavior of UPDATE pacifiers during write operations. +The following behavior codes are defined: +.br +"xorriso" is the default format: +.br +Writing: sector XXXXX of YYYYYY [fifo active, nn% fill] +.br +"cdrecord" looks like: +.br +X of Y MB written (fifo nn%) [buf mmm%] +.br +"mkisofs" +.br +nn% done, estimate finish Tue Jul 15 20:13:28 2008 +.TP +.B Scripting, dialog and program control features: +.TP +\fB\-no_rc\fR +.br +Only if used as first command line argument this option +prevents reading and interpretation of eventual startup +files. See section FILES below. +.TP +\fB\-options_from_file\fR fileaddress +Read quoted input from fileaddress and executes it like dialog lines. +.TP +\fB\-help\fR +.br +Print helptext. +.TP +\fB\-version\fR +Print program name and version. +.TP +\fB\-history\fR textline +Copy textline into libreadline history. +.TP +\fB\-status\fR [mode|filter] +Print the current settings of xorriso. +Modes: +.br + short... print only important or altered settings +.br + long ... print all settings including defaults +.br + long_history like long plus history lines +.br +Filters begin with '-' and are compared literally against the +output lines of -status:long_history. A line is put out only +if its start matches the filter text. No wildcards. +.TP +\fB\-status_history_max\fR number +Set maximum number of history lines to be reported with -status "long_history". +.TP +\fB\-list_delimiter\fR word +Set the list delimiter to be used instead of "--". It has to be a single word, +must not be empty, not longer than 80 characters, and must not contain +quotation marks. +.br +For brevity the list delimiter is referred as "--" throughout this text. +.TP +\fB\-backslash_codes\fR "on"|"off"|mode[:mode] +Enable or disable the interpretation of symbolic representations of special +characters with quoted input, or with program arguments, or with program +text output. If enabled the following translations apply: +.br + \\a=bell(007) \\b=backspace(010) \\e=Escape(033) \\f=formfeed(014) +.br + \\n=linefeed(012) \\r=carriage_return(015) \\t=tab(011) +.br + \\v=vtab(013) \\\\=backslash(134) \\[0-7][0-7][0-7]=octal_code +.br + \\\\x[0-9a-f][0-9a-f]=hex_code \\cC=control-C +.br +Translations can occur with quoted input in 3 modes: +.br + "in_double_quotes" translates only inside " quotation. +.br + "in_quotes" translates inside " and ' quotation. +.br + "with_quoted_input" translates inside and outside quotes. +.br +With the start program arguments there is mode: +.br + "with_program_arguments" translates all program arguments. +.br +.br +Mode "encode_output" encodes output characters. It combines "encode_results" +with "encode_infos". Inside single or double quotation marks encoding applies +to ASCII characters octal 001 to 037 , 177 to 377 and to backslash(134). +Outside quotation marks some harmless control characters stay unencoded: +bell(007), backspace(010), tab(011), linefeed(012), formfeed(014), +carriage_return(015). +.br +Mode "off" is default and disables any translation. +Mode "on" is +"with_quoted_input:with_program_arguments:encode_output". +.TP +\fB\-temp_mem_limit\fR number["k"|"m"] +Set the maximum size of temporary memory to be used for image dependent +buffering. Currently this applies to pattern expansion, LBA sorting, +restoring of hard links. +.br +Default is 16m = 16 MiB, minimum 64k = 64 kiB, maximum 1024m = 1 GiB. +.TP +\fB\-print\fR text +Print a text to result channel. +.TP +\fB\-prompt\fR text +Show text at beginning of output line and +wait for the user to hit the Enter key +resp. to send a line via stdin. +.TP +\fB\-errfile_log\fR mode path|channel +.br +If problem events are related to input files from the filesystem, then their +disk_paths can be logged to a file or to output channels R or I. +.br +Mode can either be "plain" or "marked". The latter causes marker lines which +give the time of log start, burn session start, burn session end, log end +or program end. In mode "plain", only the file paths are logged. +.br +If path is "-" or "-R" then the log is directed to the result channel. +Path "-I" directs it to the info message channel. Any text that does not +begin with "-" is used as path for a file to append the log lines. +.br +Problematic files can be recorded multiple times during one program run. +If the program run aborts then the list might not be complete because +some input file arguments might not have been processed at all. +.br +The errfile paths are transported as messages of very low priority "ERRFILE". +This transport becomes visible with -report_about "ALL". +.TP +\fB\-session_log\fR path +If path is not empty it gives the address of a plain text file where +a log record gets appended after each session. This log can be used to +determine the start_lba of a session for mount options -o sbsector= +resp. -s from date or volume id. +.br +Record format is: timestamp start_lba size volume-id +.br +The first three items are single words, the rest of the line is the volume id. +.TP +\fB\-end\fR +.br +End program immediately +.TP +\fB#\fR any text +In dialog or file execution mode only and only as first +non-whitespace in line: +Do not execute the line but eventually store it in history. +.TP +.B Support for frontend programs talking into stdin and listening at stdout: +.TP +\fB\-pkt_output\fR "on"|"off" +Consolidate text output on stdout and classify each +line by a channel indicator: +.br + 'R:' for result lines, +.br + 'I:' for notes and error messages, +.br + 'M:' for -mark texts. +.br +Next is a decimal number of which only bit 0 has a meaning for now. +0 means no newline at end of payload, 1 means that the newline character at +the end of the output line belongs to the payload. After another colon follows +the payload text. +.br +Example: +.br + I:1: enter option and arguments : +.TP +\fB\-logfile\fR channel fileaddress +Copy output of a channel to the given file. +.TP +\fB\-mark\fR text +If text is not empty it will get put out each time an +action has been completed. +.TP +\fB\-prog\fR text +Use text as this program's name in subsequent messages +.TP +\fB\-prog_help\fR text +Use text as this program's name and perform -help. +.br +.SH EXAMPLES +.SS +.B Overview of examples: +As superuser learn about available drives +.br +Blank media and compose a new ISO image as batch run +.br +A dialog session doing about the same +.br +Manipulating an existing ISO image on the same media +.br +Copy modified ISO image from one media to another +.br +Bring a prepared ISOLINUX tree onto media and make it bootable +.br +Change existing file name tree from ISO-8859-1 to UTF-8 +.br +Operate on storage facilities other than optical drives +.br +Perform multi-session runs as of cdrtools traditions +.br +Let xorriso work underneath growisofs +.br +Adjust thresholds for verbosity, exit value and program abort +.br +Examples of input timestrings +.br +Incremental backup of a few directory trees +.br +Restore directory trees from a particular ISO session to disk +.br +Try to retrieve as many blocks as possible from a damaged media +.SS +.B As superuser learn about available drives +Consider to give rw permissions to those users or groups +which shall be able to use the drives with xorriso. +.br +\fB$\fR xorriso -devices +.br +0 -dev '/dev/sr0' rwrw-- : '_NEC ' 'DVD_RW ND-4570A' +.br +1 -dev '/dev/sr1' rwrw-- : 'HL-DT-ST' 'DVDRAM GSA-4082B' +.br +2 -dev '/dev/sr2' rwrw-- : 'PHILIPS ' 'SPD3300L' +.SS +.B Blank media and compose a new ISO image as batch run +Aquire drive /dev/sr2, make media ready for writing a new image, +fill the image with the files from hard disk directories /home/me/sounds +and /home/me/pictures. +.br +Because no -dialog "on" is given, the program will then end by writing the +session to media. +.br +\fB$\fR xorriso -outdev /dev/sr2 \\ +.br + -blank as_needed \\ +.br + -map /home/me/sounds /sounds \\ +.br + -map /home/me/pictures /pictures +.br + +.br +The ISO image may be shaped in a more elaborate way like the following: +Omit some unwanted stuff by removing it from the image directory tree. +Re-add some wanted stuff. +.br +\fB$\fR cd /home/me +.br +\fB$\fR xorriso -outdev /dev/sr2 \\ +.br + -blank as_needed \\ +.br + -map /home/me/sounds /sounds \\ +.br + -map /home/me/pictures /pictures \\ +.br + -rm_r \\ +.br + /sounds/indecent \\ +.br + '/pictures/*private*' \\ +.br + /pictures/confidential \\ +.br + -- \\ +.br + -cd / \\ +.br + -add pictures/confidential/work* +.br +Note that '/pictures/*private*' is a pattern for iso_rr_paths +while pictures/confidential/work* gets expanded by the shell +with addresses from the hard disk. +.SS +.B A dialog session doing about the same +.br +-pathspecs is already given as start argument. The other activities +are done as dialog input. The pager gets set to 20 lines of 80 characters. +.br +The drive is aquired by option -dev rather than -outdev in order to see +the message about its current content. By option -blank this content is +made ready for being overwritten and the loaded ISO image is made empty. +.br +In order to be able to eject the media, the session needs to be committed +explicitely. +.br +.B $ xorriso -dialog on -page 20 80 -disk_pattern on +.br +enter option and arguments : +.br +.B \-dev /dev/sr2 +.br +enter option and arguments : +.br +.B \-blank as_needed +.br +enter option and arguments : +.br +.B \-map /home/me/sounds /sounds -map /home/me/pictures /pictures +.br +enter option and arguments : +.br +.B \-rm_r /sounds/indecent /pictures/*private* /pictures/confidential +.br +enter option and arguments : +.br +.B \-cdx /home/me/pictures -cd /pictures +.br +enter option and arguments : +.br +.B \-add confidential/office confidential/factory +.br +enter option and arguments : +.br +.B \-du / +.br +enter option and arguments : +.br +.B \-commit -eject all -end +.br +.SS +.B Manipulating an existing ISO image on the same media +Load image from drive. +Remove (i.e. hide) directory /sounds and its subordinates. +Rename directory /pictures/confidential to /pictures/restricted. +Change access permissions of directory /pictures/restricted. +Add new directory trees /sounds and /movies. Burn to the same media and eject. +.br +\fB$\fR xorriso -dev /dev/sr2 \\ +.br + -rm_r /sounds -- \\ +.br + -mv \\ +.br + /pictures/confidential \\ +.br + /pictures/restricted \\ +.br + -- \\ +.br + -chmod go-rwx /pictures/restricted -- \\ +.br + -map /home/me/prepared_for_dvd/sounds_dummy /sounds \\ +.br + -map /home/me/prepared_for_dvd/movies /movies \\ +.br + -commit -eject all +.SS +.B Copy modified ISO image from one media to another +Load image from input drive. Do the same manipulations as in the previous +example. Aquire output drive and blank it. Burn the modified image as +first and only session to the output drive. +.br +\fB$\fR xorriso -indev /dev/sr2 \\ +.br + -rm_r /sounds -- \\ +.br + ... +.br + -outdev /dev/sr0 -blank as_needed \\ +.br + -commit -eject all +.SS +.B Bring a prepared ISOLINUX tree onto media and make it bootable +The user has already created a suitable file tree on disk and copied the +ISOLINUX files into subdirectory ./boot/isolinux of that tree. +Now xorriso can burn an El Torito bootable media: +.br +\fB$\fR xorriso -outdev /dev/sr0 -blank as_needed \\ +.br + -map /home/me/ISOLINUX_prepared_tree / \\ +.br + -boot_image isolinux dir=/boot/isolinux +.SS +.B Change existing file name tree from ISO-8859-1 to UTF-8 +This example assumes that the existing ISO image was written with character +set ISO-8859-1 but that the readers expected UTF-8. Now a new session with +the same files gets added with converted file names. +In order to avoid any weaknesses of the local character set, this command +pretends that it uses already the final target set UTF-8. +Therefore strange file names may appear in eventual messages which +will be made terminal-safe by option -backslash_codes. +.br +\fB$\fR xorriso -in_charset ISO-8859-1 -local_charset UTF-8 \\ +.br + -out_charset UTF-8 -backslash_codes on -dev /dev/sr0 \\ +.br + -alter_date m +0 / -- -commit -eject all +.SS +.B Operate on storage facilities other than optical drives +Full read-write operation is possible with regular files and block devices: +.br +\fB$\fR xorriso -dev /tmp/regular_file ... +.br +Paths underneath /dev normally need prefix "stdio:" +.br +\fB$\fR xorriso -dev stdio:/dev/sdb ... +.br +If /dev/sdb is to be used frequently and /dev/sda is the system disk, +then consider to place the following lines in a xorriso Startup File. +They allow to use /dev/sdb without prefix and protect your disk from xorriso: +.br + -drive_class banned /dev/sda* + -drive_class harmless /dev/sdb +.br +Other writeable file types are supported write-only: +.br +\fB$\fR xorriso -outdev /tmp/named_pipe ... +.br +Among the write-only drives is standard output: +.br +\fB$\fR xorriso -outdev - \\ +.br + ... +.br + | gzip >image.iso.gz +.SS +.B Perform multi-session runs as of cdrtools traditions +Between both processes there can be performed arbitrary transportation +or filtering. +.br +The first session is written like this: +.br +\fB$\fR xorriso -as mkisofs prepared_for_iso/tree1 | \\ +.br + xorriso -as cdrecord -v dev=/dev/sr0 blank=fast -multi -eject - +.br +Follow-up sessions are written like this: +.br +\fB$\fR m=$(xorriso -as cdrecord dev=/dev/sr0 -msinfo) +.br +\fB$\fR xorriso -as mkisofs -M /dev/sr0 -C $m prepared_for_iso/tree2 | \\ +.br + xorriso -as cdrecord -v dev=/dev/sr0 -waiti -multi -eject - +.br +Always eject the drive tray between sessions. The old sessions +get read via stdio:/dev/sr0 and thus are prone to device driver +peculiarities. +.br +This example works for multi-session media only. +Add cdrskin option --grow_overwriteable_iso to all -as cdrecord runs +in order to enable multi-session emulation on overwriteable media. +.SS +.B Let xorriso work underneath growisofs +growisofs expects an ISO formatter program which understands options -C and +-M. If xorriso gets started by name "xorrisofs" then it is suitable for that. +.br +\fB$\fR export MKISOFS="xorrisofs" +.br +\fB$\fR growisofs -Z /dev/dvd /some/files +.br +\fB$\fR growisofs -M /dev/dvd /more/files +.br +If no "xorrisofs" is available on your system, then you will have to create +a link pointing to the xorriso binary and tell growisofs to use it. E.g. by: +.br +\fB$\fR ln -s $(which xorriso) "$HOME/xorrisofs" +.br +\fB$\fR export MKISOFS="$HOME/xorrisofs" +.br +One may quit mkisofs emulation by argument "--" and make +use of all xorriso commands. growisofs dislikes options which +start with "-o" but -outdev must be set to "-". +So use "outdev" instead: +.br +\fB$\fR growisofs -Z /dev/dvd -- outdev - -update_r /my/files /files +.br +\fB$\fR growisofs -M /dev/dvd -- outdev - -update_r /my/files /files +.br +growisofs has excellent burn capabilities with DVD and BD. +It does not emulate session history on overwriteable media, though. +.SS +.B Adjust thresholds for verbosity, exit value and program abort +Be quite verbous, exit 32 if severity "FAILURE" was encountered, +do not abort prematurely but forcibly go on until the end of commands. +.br +\fB$\fR xorriso ... \\ +.br + -report_about UPDATE \\ +.br + -return_with FAILURE 32 \\ +.br + -abort_on NEVER \\ +.br + ... +.SS +.B Examples of input timestrings +.br +As printed by program date: +.B 'Thu Nov 8 14:51:13 CET 2007' +.br +The same without ignored parts: +.B 'Nov 8 14:51:13 2007' +.br +The same as expected by date: +.B 110814512007.13 +.br +Four weeks in the future: +.B +4w +.br +The current time: +.B +0 +.br +Three hours ago: +.B \-3h +.br +Seconds since Jan 1 1970: +.B =1194531416 +.SS +.B Incremental backup of a few directory trees +This changes the directory trees /open_source_project and /personal_mail +in the ISO image so that they become exact copies of their disk counterparts. +ISO file objects get created, deleted or get their attributes adjusted +accordingly. +.br +ACL, xattr and hard links will be recorded. Accelerated comparison is enabled +at the expense of potentially larger backup size. +Only media with the expected volume id or blank media are accepted. +Files with names matching *.o or *.swp get excluded explicitely. +.br +\fB$\fR xorriso \\ +.br + -for_backup -disk_dev_ino on \\ +.br + -assert_volid 'PROJECTS_MAIL_*' FATAL \\ +.br + -dev /dev/sr0 \\ +.br + -volid PROJECTS_MAIL_"$(date '+%Y_%m_%d_%H%M%S')" \\ +.br + -not_leaf '*.o' -not_leaf '*.swp' \\ +.br + -update_r /home/thomas/open_source_projects /open_source_projects \\ +.br + -update_r /home/thomas/personal_mail /personal_mail \\ +.br + -commit -toc -eject all +.br +To be used several times on the same media, whenever an update of +the two disk trees to the media is desired. Begin with blank media and start +a new blank media when the run fails due to lack of remaining space on +the old one. +.br +This makes sense if the full backup leaves substantial remaining capacity +on media and if the expected changes are much smaller than the full backup. +To apply zisofs compression to those data files which get newly copied from +the local filesystem, insert these options immediately before -commit : +.br + -hardlinks perform_update \\ +.br + -find / -type f -pending_data -exec set_filter --zisofs -- \\ +.br +Options -disk_dev_ino and -for_backup depend on stable device and inode numbers +on disk. Without them, an update run may use -md5 "on" to match recorded MD5 +sums against the current file content on hard disk. This is usually much faster +than the default which compares both contents directly. +.br +With \fBmount\fR option \fB-o "sbsector="\fR on Linux resp. \fB-s\fR on FreeBSD +it is possible to access the session trees which represent the older backup +versions. With CD media, Linux mount accepts session numbers directly by +its option "session=". +.br +Multi-session media and most overwriteable media written by xorriso can tell +the sbsectors of their sessions by xorriso option -toc. +Used after -commit the following option prints the matching mount command for +the newly written session (here for mount point /mnt): +.br + -mount_cmd "indev" "auto" "auto" /mnt +.br +Options -mount_cmd and -mount are also able to produce the mount commands for +older sessions in the table-of-content. E.g. as superuser: +.br + \fB#\fR osirrox -mount /dev/sr0 "volid" '*2008_12_05*' /mnt +.br +Sessions on multi-session media are separated by several MB of unused blocks. +So with small sessions the payload capacity can become substantially lower +than the overall media capacity. If the remaining space on media does not +suffice for the next gap, the drive is supposed to close the media +automatically. +.br +\fBBetter do not use your youngest backup for -update_r\fR. +Have at least two media which you use alternatingly. So only older backups +get endangered by the new write operation, while the newest backup is +stored safely on a different media. +Always have a blank media ready to perform a full backup in case the update +attempt fails due to insufficient remaining capacity. +.SS +.B Restore directory trees from a particular ISO session to disk +This is an alternative to mounting the media and using normal file operations. +.br +First check which backup sessions are on the media: +.br +\fB$\fR xorriso -outdev /dev/sr0 -toc +.br +Then load the desired session and copy the file trees to disk. +Enable restoring of ACL, xattr and hard links. +Avoid to eventually create /home/thomas/restored without rwx-permission. +.br +\fB$\fR xorriso -for_backup \\ +.br + -load volid 'PROJECTS_MAIL_2008_06_19*' \\ +.br + -indev /dev/sr0 \\ +.br + -osirrox on:auto_chmod_on \\ +.br + -chmod u+rwx / -- \\ +.br + -extract /open_source_projects \\ +.br + /home/thomas/restored/open_source_projects \\ +.br + -extract /personal_mail /home/thomas/restored/personal_mail \\ +.br + -rollback_end +.SS +.B Try to retrieve as many blocks as possible from a damaged media +.br +\fB$\fR xorriso -abort_on NEVER -indev /dev/sr0 \\ +.br + -check_media time_limit=1800 report=blocks_files \\ +.br + data_to="$HOME"/dvd_copy sector_map="$HOME"/dvd_copy.map -- +.br +This can be repeated several times, eventually with -eject or with other +-indev drives. See the human readable part of "$HOME"/dvd_copy.map for +addresses which can be used on "$HOME"/dvd_copy with mount option -o sbsector= +resp. -s. +.br +If you want to make the newest session the default mount session, you +may add option "patch_lba0=on" to the final -check_media run. +.SH FILES +.SS +.B Startup files: +.br +If not -no_rc is given as the first argument then xorriso attempts on startup +to read and execute lines from the following files: +.br + /etc/default/xorriso +.br + /etc/opt/xorriso/rc +.br + /etc/xorriso/xorriso.conf +.br + $HOME/.xorrisorc +.br +The files are read in the sequence given above, but none of them is required +for xorriso to function properly. +.SS +.B Runtime control files: +.br +The default setting of -check_media abort_file= is: +.br + /var/opt/xorriso/do_abort_check_media +.br +.SH SEE ALSO +.TP +For mounting xorriso generated ISO 9660 images +.br +.BR mount(8) +.TP +Libreadline, a comfortable input line facility +.BR readline(3) +.TP +Other programs which produce ISO 9660 images +.br +.BR mkisofs(8), +.BR genisoimage(8) +.TP +Other programs which burn sessions to optical media +.BR growisofs(1), +.BR cdrecord(1), +.BR wodim(1), +.BR cdrskin(1) +.TP +ACL and xattr +.BR getfacl(1), +.BR setfacl(1), +.BR getfattr(1), +.BR setfattr(1) +.TP +MD5 checksums +.BR md5sum(1) +.br +.SH AUTHOR +Thomas Schmitt <scdbackup@gmx.net> +.br +for libburnia-project.org +.SH CREDITS +xorriso is in part based on work by Vreixo Formoso who provides libisofs +together with Mario Danic who also leads the libburnia team. +Thanks to Andy Polyakov who invented emulated growing, +to Derek Foreman and Ben Jansens who once founded libburn. +.br +Compliments towards Joerg Schilling whose cdrtools served me for ten years. + diff --git a/libisoburn/branches/ZeroFourTwo/xorriso/xorriso.c b/libisoburn/branches/ZeroFourTwo/xorriso/xorriso.c new file mode 100644 index 00000000..d3042e7d --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/xorriso/xorriso.c @@ -0,0 +1,20112 @@ + +/* + + ( cd .. ; libisoburn-develop/xorriso/compile_xorriso.sh -g ) + +or + + cc -g -DXorriso_with_maiN -DXorriso_with_readlinE \ + -DXorriso_build_timestamP='"'"$(date -u '+%Y.%m.%d.%H%M%S')"'"' \ + -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \ + -o xorriso/xorriso \ + xorriso/xorriso.c xorriso/xorrisoburn.c \ + -lz -lacl -lpthread -lreadline -lburn -lisofs -lisoburn + +or + + cc -g -DXorriso_with_readlinE \ + -DXorriso_build_timestamP='"'"$(date -u '+%Y.%m.%d.%H%M%S')"'"' \ + -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \ + -c \ + xorriso/xorriso.c xorriso/xorrisoburn.c + +*/ + +/* Command line oriented batch and dialog tool which creates, loads, + manipulates and burns ISO 9660 filesystem images. + + Copyright 2007-2009 Thomas Schmitt, <scdbackup@gmx.net> + + Initial code of this program was derived from program src/askme.c out + of scdbackup-0.8.8, Copyright 2007 Thomas Schmitt, BSD-License. + + Provided under GPL version 2, with the announcement that this might + get changed in future. I would prefer BSD or a modified LGPL with no + option to choose any kind of future GPL version. + (This announcement affects only future releases of xorriso. + If you obtain a copy licensed as "GPL version 2" then this license is + not revocable for that particular copy, of course.) + + + Overview of xorriso architecture: + + libburn provides the ability to read and write data. + + libisofs interprets and manipulates ISO 9660 directory trees. It generates + the output stream which is handed over to libburn. + + libisoburn encapsulates the connectivity issues between libburn and + libisofs. It also enables multi-session emulation on overwritable media + and random access file objects. + xorriso is intended as reference application of libisoburn. + + xorrisoburn.[ch] encapsulate any usage of the libraries by xorriso. + + xorriso.h exposes the public functions of xorriso which are intended + to be used by programs which link with xorriso.o. These functions are + direct equivalents of the xorriso interpreter commands. + There is also the API for handling event messages. + + xorriso_private.h is not to be included by other software. It encapsulates + the inner interfaces of xorriso. + + xorriso.c provides the command interpreter as described in xorriso.1. + It performs any activity that does not demand a reference to a symbol + of the library APIs. This includes: + - Interpretation of user input from arguments, dialog, and scripting. + - Output of result text and event messages. + - POSIX filesystem operations. + - Public functions which perform the particular xorriso commands. + - The main() function, if enabled by #define Xorriso_with_maiN. + +*/ + +#ifdef Xorriso_without_subS + + + +#include <ctype.h> +#include <sys/types.h> +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include <locale.h> + +/* The official xorriso options API. "No shortcuts" */ +#include "xorriso.h" + + + +#else /* Xorriso_without_subS */ + + + +#include <ctype.h> +#include <sys/types.h> +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <errno.h> +#include <sys/time.h> +#include <sys/resource.h> +#include <sys/wait.h> +#include <dirent.h> +#include <time.h> +#include <utime.h> +#include <pwd.h> +#include <grp.h> +#include <signal.h> +#include <sys/utsname.h> +#include <sys/select.h> + +/* for -charset */ +#include <iconv.h> +#include <langinfo.h> +#include <locale.h> + +/* eventually, this is done in xorriso_private.h : #include <regex.h> */ + +#ifdef Xorriso_with_readlinE +#ifdef Xorriso_with_old_readlinE +#include <readline.h> +#include <history.h> +#else /* Xorriso_with_old_readlinE */ +#include <readline/readline.h> +#include <readline/history.h> +#endif /* ! Xorriso_with_old_readlinE */ +#endif /* Xorriso_with_readlinE */ + +#define TSOB_FELD(typ,anz) (typ *) malloc((anz)*sizeof(typ)); + + +/* Diet facility: exclude help texts from binaries */ +/* This will eventually be redefined to eat up its content */ +#define AlN(x) x + + +/* There is only one stage of diet: Xorriso_no_helP */ +#ifdef Xorriso_no_helP +#undef AlN +#define AlN(x) +#endif + + +/* ------------------------------------------------------------------------ */ + + +/* The official xorriso options API. "No shortcuts" */ +#include "xorriso.h" + +/* The inner description of XorrisO */ +#define Xorriso_is_xorriso_selF 1 +#include "xorriso_private.h" + +/* The inner isofs- and burn-library interface */ +#include "xorrisoburn.h" + + +/* ------------------------------------------------------------------------ */ + + +#ifndef Xorriso_sfile_externaL +/* @param flag bit0= do not clip of carriage return at line end +*/ +char *Sfile_fgets_n(char *line, int maxl, FILE *fp, int flag) +{ + int l; + char *ret; + + ret= fgets(line,maxl,fp); + if(ret==NULL) + return(NULL); + l= strlen(line); + if(l > 0 && !(flag & 1)) if(line[l-1] == '\r') line[--l]= 0; + if(l > 0) if(line[l-1] == '\n') line[--l]= 0; + if(l > 0 && !(flag & 1)) if(line[l-1] == '\r') line[--l]= 0; + return(ret); +} + + +int Sfile_count_components(char *path, int flag) +/* + bit0= do not ignore trailing slash + bit1= do not ignore empty components (other than the empty root name) +*/ +{ + int l,count= 0; + char *cpt; + + l= strlen(path); + if(l==0) + return(0); + count= 1; + for(cpt= path+l-1;cpt>=path;cpt--) { + if(*cpt=='/') { + if(*(cpt+1)==0 && !(flag&1)) + continue; + if(*(cpt+1)=='/' && !(flag&2)) + continue; + count++; + } + } + return(count); +} + + +int Sfile_component_pointer(char *path, char **sourcept, int idx, int flag) +/* + bit0= do not ignore trailing slash + bit1= do not ignore empty components (other than the empty root name) + bit2= accept 0 as '/' +*/ +{ + int count= 0; + char *spt; + + for(spt= path;*spt!=0 || (flag&4);spt++) { + if(count>=idx) { + *sourcept= spt; + return(1); + } + if(*spt=='/' || *spt==0) { + if(*(spt+1)=='/' && !(flag&2)) + continue; + if(*(spt+1)==0 && !(flag&1)) + continue; + count++; + } + } + if((flag&1) && count>=idx) + return(1); + return(0); +} + + +int Sfile_leafname(char *path, char leafname[SfileadrL], int flag) +{ + int count, ret; + char *lpt; + + leafname[0]= 0; + count= Sfile_count_components(path, 0); + if(count==0) + return(0); + ret= Sfile_component_pointer(path, &lpt, count-1, 0); + if(ret<=0) + return(ret); + if(Sfile_str(leafname, lpt, 0)<=0) + return(0); + lpt= strchr(leafname, '/'); + if(lpt!=NULL) + *lpt= 0; + return(1); +} + + +int Sfile_add_to_path(char path[SfileadrL], char *addon, int flag) +{ + int l; + + l= strlen(path); + if(l+1>=SfileadrL) + return(0); + if(l==0) { + strcpy(path,"/"); + l= 1; + } else if(path[l-1]!='/') { + path[l++]= '/'; + path[l]= 0; + } + if(l+strlen(addon)>=SfileadrL) + return(0); + if(addon[0]=='/') + strcpy(path+l,addon+1); + else + strcpy(path+l,addon); + return(1); +} + + +int Sfile_prepend_path(char *prefix, char path[SfileadrL], int flag) +{ + int l, i; + + l= strlen(path)+strlen(prefix)+1; + if(l>=SfileadrL) { + +#ifdef Not_yeT + /* >>> ??? how to transport messages to xorriso ? */ + sprintf(xorriso->info_text, + "Combination of wd and relative address too long (%d > %d)", + l,SfileadrL-1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); +#endif + + return(-1); + } + l-= strlen(path); + for(i= strlen(path)+1; i>=0; i--) + path[i+l]= path[i]; + strcpy(path,prefix); + path[l-1]= '/'; + return(1); +} + +int Sfile_being_group_member(struct stat *stbuf, int flag) +{ + int i, suppl_groups; + gid_t *suppl_glist; + + if (getegid()==stbuf->st_gid) + return(1); + suppl_groups= getgroups(0, NULL); + suppl_glist= (gid_t *) malloc((suppl_groups + 1) * sizeof(gid_t)); + if (suppl_glist==NULL) + return(-1); + suppl_groups= getgroups(suppl_groups+1,suppl_glist); + for (i= 0; i<suppl_groups; i++) { + if (suppl_glist[i]==stbuf->st_gid) { + free((char *) suppl_glist); + return(1); + } + } + free((char *) suppl_glist); + return(0); +} + + +int Sfile_type(char *filename, int flag) +/* + bit0= return -1 if file is missing + bit1= return a hardlink with siblings as type 5 + bit2= evaluate eventual link target rather than the link object itself + bit3= return a socket or a char device as types 7 or 8 rather than 0 +*/ +/* + return: + 0=unknown + 1=regular + 2=directory + 3=symbolic link + 4=named pipe + 5=multiple hardlink (with bit1) + 6=block device + 7=socket (with bit3) + 8=character device (with bit3) +*/ +{ + struct stat stbuf; + if(flag&4) { + if(stat(filename,&stbuf)==-1) { + if(flag&1) return(-1); + else return(0); + } + } else { + if(lstat(filename,&stbuf)==-1) { + if(flag&1) return(-1); + else return(0); + } + } + if(S_ISREG(stbuf.st_mode)) { + if(flag&2) + if(stbuf.st_nlink>1) + return(5); + return(1); + } + if(S_ISDIR(stbuf.st_mode)) + return(2); + if((stbuf.st_mode&S_IFMT)==S_IFLNK) + return(3); + if(S_ISFIFO(stbuf.st_mode)) + return(4); + if(S_ISBLK(stbuf.st_mode)) + return(6); + if(flag&8) + if((stbuf.st_mode&S_IFMT)==S_IFSOCK) + return(7); + if(flag&8) + if(S_ISCHR(stbuf.st_mode)) + return(8); + return(0); +} + + +char *Sfile_datestr(time_t tim, short int flag) +/* + bit0=with hours+minutes + bit1=with seconds + + bit8= local time rather than UTC +*/ +{ + static char zeitcode[80]={"000000"}; + char puff[80]; + struct tm *azt; + + if(flag&256) + azt = localtime(&tim); + else + azt = gmtime(&tim); + + if(azt->tm_year>99) + sprintf(zeitcode,"%c%1.1d%2.2d%2.2d", + 'A'+(azt->tm_year-100)/10,azt->tm_year%10, + azt->tm_mon+1,azt->tm_mday); + else + sprintf(zeitcode,"%2.2d%2.2d%2.2d", + azt->tm_year,azt->tm_mon+1,azt->tm_mday); + if(flag&1){ + sprintf(puff,".%2.2d%2.2d",azt->tm_hour,azt->tm_min); + strcat(zeitcode,puff); + } + if(flag&2){ + sprintf(puff,"%2.2d",azt->tm_sec); + strcat(zeitcode,puff); + } + + return(zeitcode); +} + + +int Sfile_scale(double value, char *result, int siz, double thresh, int flag) +/* + bit0= eventually ommit 'b' + bit1= make text as short as possible + bit2= no fraction (if it would fit at all) +*/ +{ + char scale_c,scales[7],form[80], *negpt= NULL, *cpt; + int i,dec_siz= 0,avail_siz= 1; + + if(value<0) { + value= -value; + siz--; + result[0]= '-'; + negpt= result; + result++; + } + strcpy(scales,"bkmgtp"); + scale_c= scales[0]; + for(i=1;scales[i]!=0;i++) { + if(value<thresh-0.5) + break; + value/= 1024.0; + scale_c= scales[i]; + } + if(scale_c!='b' && !(flag&4)) { /* is there room for fractional part ? */ + avail_siz= siz-1; + sprintf(form,"%%.f"); + sprintf(result,"%.f",value); + if(strlen(result)<=avail_siz-2) + dec_siz= 1; /* we are very modest */ + } + if(scale_c=='b' && (flag&1)) { + if(flag&2) + sprintf(form,"%%.f"); + else + sprintf(form,"%%%d.f",siz); + sprintf(result,form,value); + } else { + if(flag&2) + sprintf(form,"%%.f%%c"); + else if(dec_siz>0) + sprintf(form,"%%%d.%df%%c",avail_siz,dec_siz); + else + sprintf(form,"%%%d.f%%c",siz-1); + sprintf(result,form,value,scale_c); + } + if(negpt != NULL) { + for(cpt= result; *cpt==' '; cpt++); + if(cpt > result) { + *negpt= ' '; + *(cpt - 1)= '-'; + } + } + return(1); +} + + +int Sfile_off_t_text(char text[80], off_t num, int flag) +{ + char *tpt; + off_t hnum, scale= 1; + int digits= 0, d, i; + + tpt= text; + hnum= num; + if(hnum<0) { + *(tpt++)= '-'; + hnum= -num; + } + if(hnum<0) { /* it can stay nastily persistent */ + strcpy(text, "_overflow_"); + return(0); + } + for(i= 0; i<23; i++) { /* good for up to 70 bit = 10 exp 21.07... */ + if(hnum==0) + break; + hnum/= 10; + if(hnum) + scale*= 10; + } + if(i==0) { + strcpy(text, "0"); + return(1); + } + if(i==23) { + strcpy(text, "_overflow_"); + return(0); + } + digits= i; + hnum= num; + for(; i>0; i--) { + d= hnum/scale; + tpt[digits-i]= '0'+d; + hnum= hnum%scale; + scale/= 10; + } + tpt[digits]= 0; + return(1); +} + + +/* Converts backslash codes into single characters: + \a BEL 7 , \b BS 8 , \e ESC 27 , \f FF 12 , \n LF 10 , \r CR 13 , + \t HT 9 , \v VT 11 , \\ \ 92 + \[0-9][0-9][0-9] octal code , \x[0-9a-f][0-9a-f] hex code , + \cX control-x (ascii(X)-64) + @param upto maximum number of characters to examine for backslash. + The scope of a backslash (0 to 3 characters) is not affected. + @param eaten returns the difference in length between input and output + @param flag bit0= only determine *eaten, do not convert + bit1= allow to convert \000 to binary 0 +*/ +int Sfile_bsl_interpreter(char *text, int upto, int *eaten, int flag) +{ + char *rpt, *wpt, num_text[8], wdummy[8]; + unsigned int num= 0; + + *eaten= 0; + wpt= text; + for(rpt= text; *rpt != 0 && rpt - text < upto; rpt++) { + if(flag & 1) + wpt= wdummy; + if(*rpt == '\\') { + rpt++; + (*eaten)++; + if(*rpt == 'a') { + *(wpt++)= 7; + } else if(*rpt == 'b') { + *(wpt++)= 8; + } else if(*rpt == 'e') { + *(wpt++)= 27; + } else if(*rpt == 'f') { + *(wpt++)= 12; + } else if(*rpt == 'n') { + *(wpt++)= 10; + } else if(*rpt == 'r') { + *(wpt++)= 13; + } else if(*rpt == 't') { + *(wpt++)= 9; + } else if(*rpt == 'v') { + *(wpt++)= 11; + } else if(*rpt == '\\') { + *(wpt++)= '\\'; + } else if(rpt[0] >= '0' && rpt[0] <= '7' && + rpt[1] >= '0' && rpt[1] <= '7' && + rpt[2] >= '0' && rpt[2] <= '7') { + num_text[0]= '0'; + num_text[1]= *(rpt + 0); + num_text[2]= *(rpt + 1); + num_text[3]= *(rpt + 2); + num_text[4]= 0; + sscanf(num_text, "%o", &num); + if((num > 0 || (flag & 2)) && num <= 255) { + rpt+= 2; + (*eaten)+= 2; + *(wpt++)= num; + } else + goto not_a_code; + } else if(rpt[0] == 'x' && + ((rpt[1] >= '0' && rpt[1] <= '9') || + (rpt[1] >= 'A' && rpt[1] <= 'F') || + (rpt[1] >= 'a' && rpt[1] <= 'f')) + && + ((rpt[2] >= '0' && rpt[2] <= '9') || + (rpt[2] >= 'A' && rpt[2] <= 'F') || + (rpt[2] >= 'a' && rpt[2] <= 'f')) + ) { + num_text[0]= *(rpt + 1); + num_text[1]= *(rpt + 2); + num_text[2]= 0; + sscanf(num_text, "%x", &num); + if(num > 0 && num <= 255) { + rpt+= 2; + (*eaten)+= 2; + *(wpt++)= num; + } else + goto not_a_code; + } else if(*rpt == 'c') { + if(rpt[1] > 64 && rpt[1] < 96) { + *(wpt++)= rpt[1] - 64; + rpt++; + (*eaten)++; + } else + goto not_a_code; + } else { +not_a_code:; + *(wpt++)= '\\'; + rpt--; + (*eaten)--; + } + } else + *(wpt++)= *rpt; + } + *wpt= *rpt; + return(1); +} + + +int Sfile_argv_bsl(int argc, char ***argv, int flag) +{ + int i, ret, eaten; + char **new_argv= NULL; + + if(argc <= 0) + return(0); + new_argv= (char **) Smem_malloC(argc * sizeof(char *)); + if(new_argv == NULL) + return(-1); + for(i= 0; i < argc; i++) { + new_argv[i]= strdup((*argv)[i]); + if(new_argv[i] == NULL) + {ret= -1; goto ex;} + ret= Sfile_bsl_interpreter(new_argv[i], strlen(new_argv[i]), &eaten, 0); + if(ret <= 0) + goto ex; + } + ret= 1; +ex:; + if(ret <= 0) { + if(new_argv != NULL) + free((char *) new_argv); + } else + *argv= new_argv; + return(ret); +} + + +/* @param flag bit0= only encode inside quotes + bit1= encode < 32 outside quotes except 7, 8, 9, 10, 12, 13 + bit2= encode in any case above 126 + bit3= encode in any case shellsafe and name-value-safe: + <=42 , 59, 60, 61, 62, 63, 92, 94, 96, >=123 +*/ +int Sfile_bsl_encoder(char **result, char *text, size_t text_len, int flag) +{ + char *rpt, *wpt; + int count, sq_open= 0, dq_open= 0; + + count= 0; + for(rpt= text; rpt - text < text_len; rpt++) { + count++; + if(flag & 8) { + if(!(*rpt <= 42 || (*rpt >= 59 && *rpt <= 63) || + *rpt == 92 || *rpt == 94 || *rpt == 96 || *rpt >= 123)) + continue; + } else if(*rpt >= 32 && *rpt <= 126 && *rpt != '\\') + continue; + if(((*rpt >= 7 && *rpt <= 13) || *rpt == 27 || *rpt == '\\') && !(flag & 8)) + count++; + else + count+= 3; + } + (*result)= wpt= calloc(count + 1, 1); + if(wpt == NULL) + return(-1); + for(rpt= text; rpt - text < text_len; rpt++) { + if(*rpt == '\'') + sq_open= !(sq_open || dq_open); + if(*rpt == '"') + dq_open= !(sq_open || dq_open); + + if(flag & 8) { + if(!(*rpt <= 42 || (*rpt >= 59 && *rpt <= 63) || + *rpt == 92 || *rpt == 94 || *rpt == 96 || *rpt >= 123)) { + *(wpt++)= *rpt; + continue; + } + } else if(*rpt >= 32 && *rpt <= 126 && *rpt != '\\') { + *(wpt++)= *rpt; + continue; + } else if( ((flag & 1) && !(sq_open || dq_open)) && + !((flag & 2) && (*rpt >= 1 && * rpt <= 31 && + !(*rpt == 7 || *rpt == 8 || *rpt == 9 || *rpt == 10 || + *rpt == 12 || *rpt == 13))) && + !((flag & 4) && (*rpt > 126 || *rpt < 0)) && + !((flag & 6) && *rpt == '\\')) { + *(wpt++)= *rpt; + continue; + } + *(wpt++)= '\\'; + if(((*rpt >= 7 && *rpt <= 13) || *rpt == 27 || *rpt == '\\') && !(flag&8)) { + if(*rpt == 7) + *(wpt++)= 'a'; + else if(*rpt == 8) + *(wpt++)= 'b'; + else if(*rpt == 9) + *(wpt++)= 't'; + else if(*rpt == 10) { + *(wpt++)= 'n'; + } else if(*rpt == 11) + *(wpt++)= 'v'; + else if(*rpt == 12) + *(wpt++)= 'f'; + else if(*rpt == 13) + *(wpt++)= 'c'; + else if(*rpt == 27) + *(wpt++)= 'e'; + else if(*rpt == '\\') + *(wpt++)= '\\'; + } else { + sprintf(wpt, "%-3.3o", (unsigned int) *((unsigned char *) rpt)); + wpt+= 3; + } + } + *wpt= 0; + return(1); +} + + +int Sfile_destroy_argv(int *argc, char ***argv, int flag) +{ + int i; + + if(*argc>0 && *argv!=NULL){ + for(i=0;i<*argc;i++){ + if((*argv)[i]!=NULL) + Smem_freE((*argv)[i]); + } + Smem_freE((char *) *argv); + } + *argc= 0; + *argv= NULL; + return(1); +} + + +int Sfile_make_argv(char *progname, char *line, int *argc, char ***argv, + int flag) +/* + bit0= read progname as first argument from line + bit1= just release argument list argv and return + bit2= abort with return(0) if incomplete quotes are found + bit3= eventually prepend missing '-' to first argument read from line + bit4= like bit2 but only check quote completeness, do not allocate memory + bit5+6= interpretation of backslashes: + 0= no interpretation, leave unchanged + 1= only inside double quotes + 2= outside single quotes + 3= everywhere + bit7= append a NULL element to argv +*/ +{ + int i,pass,maxl=0,l,argzaehl=0,bufl,line_start_argc, bsl_mode, ret= 0, eaten; + char *cpt,*start; + char *buf= NULL; + + Sfile_destroy_argv(argc,argv,0); + if(flag&2) + {ret= 1; goto ex;} + + if(flag & 16) + flag|= 4; + bsl_mode= (flag >> 5) & 3; + + buf= calloc(strlen(line) + SfileadrL, 1); + if(buf == NULL) + {ret= -1; goto ex;} + for(pass=0;pass<2;pass++) { + cpt= line-1; + if(!(flag&1)){ + argzaehl= line_start_argc= 1; + if(pass==0) + maxl= strlen(progname); + else + strcpy((*argv)[0],progname); + } else { + argzaehl= line_start_argc= 0; + if(pass==0) maxl= 0; + } + while(*(++cpt)!=0){ + if(isspace(*cpt)) continue; + start= cpt; + buf[0]= 0; + cpt--; + while(*(++cpt)!=0) { + if(isspace(*cpt)) break; + if(*cpt=='"'){ + l= cpt-start; bufl= strlen(buf); + if(l>0) { + strncpy(buf + bufl, start, l); buf[bufl + l]= 0; + if(bsl_mode >= 3) { + ret= Sfile_bsl_interpreter(buf, l, &eaten, 0); + if(ret <= 0) + goto ex; + } + } + l= strlen(buf); + start= cpt+1; + while(*(++cpt)!=0) if(*cpt=='"') break; + if((flag&4) && *cpt==0) + {ret= 0; goto ex;} + l= cpt-start; bufl= strlen(buf); + if(l>0) { + strncpy(buf + bufl, start, l); + buf[bufl + l]= 0; + if(bsl_mode >= 1) { + ret= Sfile_bsl_interpreter(buf + bufl, l, &eaten, 0); + if(ret <= 0) + goto ex; + } + } + start= cpt+1; + }else if(*cpt=='\''){ + l= cpt-start; bufl= strlen(buf); + if(l>0) { + strncpy(buf + bufl, start, l); buf[bufl + l]= 0; + if(bsl_mode >= 3) { + ret= Sfile_bsl_interpreter(buf, l, &eaten, 0); + if(ret <= 0) + goto ex; + } + } + l= strlen(buf); + start= cpt+1; + while(*(++cpt)!=0) if(*cpt=='\'') break; + if((flag&4) && *cpt==0) + {ret= 0; goto ex;} + l= cpt-start; bufl= strlen(buf); + if(l>0) { + strncat(buf,start,l);buf[bufl+l]= 0; + if(bsl_mode >= 2) { + ret= Sfile_bsl_interpreter(buf + bufl, l, &eaten, 0); + if(ret <= 0) + goto ex; + } + } + start= cpt+1; + } + if(*cpt==0) break; + } + l= cpt-start; + bufl= strlen(buf); + if(l>0) { + strncpy(buf + bufl, start, l); buf[bufl + l]= 0; + if(bsl_mode >= 3) { + ret= Sfile_bsl_interpreter(buf, l, &eaten, 0); + if(ret <= 0) + goto ex; + } + } + l= strlen(buf); + if(pass==0){ + if(argzaehl==line_start_argc && (flag&8)) + if(buf[0]!='-' && buf[0]!=0 && buf[0]!='#') + l++; + if(l>maxl) maxl= l; + }else{ + strcpy((*argv)[argzaehl],buf); + if(argzaehl==line_start_argc && (flag&8)) + if(buf[0]!='-' && buf[0]!=0 && buf[0]!='#') + sprintf((*argv)[argzaehl],"-%s", buf); + } + argzaehl++; + if(*cpt==0) break; + } + if(pass==0){ + if(flag & 16) + {ret= 1; goto ex;} + *argc= argzaehl; + if(argzaehl>0 || (flag & 128)) { + *argv= (char **) Smem_malloC((argzaehl + !!(flag & 128)) + * sizeof(char *)); + if(*argv==NULL) + {ret= -1; goto ex;} + } + for(i=0;i<*argc;i++) { + (*argv)[i]= (char *) Smem_malloC((maxl+1)); + if((*argv)[i]==NULL) + {ret= -1; goto ex;} + } + if(flag & 128) + (*argv)[*argc]= NULL; + } + } + ret= 1; +ex: + if(buf != NULL) + free(buf); + return(ret); +} + + +/* @param flag bit0= append */ +int Sfile_str(char target[SfileadrL], char *source, int flag) +{ + int l; + + l= strlen(source); + if(flag&1) + l+= strlen(target); + if(l>=SfileadrL) { + fprintf(stderr, "--- Path string overflow (%d > %d). Malicious input ?\n", + l,SfileadrL-1); + return(0); + } + if(flag&1) + strcat(target, source); + else + strcpy(target, source); + return(1); +} + + +/** Combine environment variable HOME with given filename + @param filename Address relative to $HOME + @param fileadr Resulting combined address + @param fa_size Size of array fileadr + @param flag Unused yet + @return 1=ok , 0=no HOME variable , -1=result address too long +*/ +int Sfile_home_adr_s(char *filename, char *fileadr, int fa_size, int flag) +{ + char *home; + + strcpy(fileadr,filename); + home= getenv("HOME"); + if(home==NULL) + return(0); + if(strlen(home)+strlen(filename)+1>=fa_size) + return(-1); + strcpy(fileadr,home); + if(filename[0]!=0){ + strcat(fileadr,"/"); + strcat(fileadr,filename); + } + return(1); +} + + +/** Return a double representing seconds and microseconds since 1 Jan 1970 */ +double Sfile_microtime(int flag) +{ + struct timeval tv; + struct timezone tz; + gettimeofday(&tv,&tz); + return((double) (tv.tv_sec+1.0e-6*tv.tv_usec)); +} + + +int Sfile_decode_datestr(struct tm *reply, char *text, int flag) +/* YYMMDD[.hhmm[ss]] */ +{ + int i,l; + time_t current_time; + struct tm *now; + + current_time= time(0); + now= localtime(¤t_time); + for(i=0;i<sizeof(struct tm);i++) + ((char *) reply)[i]= ((char *) now)[i]; + + if(text[0]<'0'|| (text[0]>'9' && text[0]<'A') || text[0]>'Z') + return(0); + l= strlen(text); + for(i=1;i<l;i++) + if(text[i]<'0'||text[i]>'9') + break; + if(i!=6) + return(0); + if(text[i]==0) + goto decode; + if(text[i]!='.' || (l!=11 && l!=13)) + return(0); + for(i++;i<l;i++) + if(text[i]<'0'||text[i]>'9') + break; + if(i!=l) + return(0); + +decode:; + reply->tm_hour= 0; + reply->tm_min= 0; + reply->tm_sec= 0; + i= 0; + if(text[0]>='A') + reply->tm_year= 100+(text[i]-'A')*10+text[1]-'0'; + else + reply->tm_year= 10*(text[0]-'0')+text[1]-'0'; + reply->tm_mon= 10*(text[2]-'0')+text[3]-'0'-1; + reply->tm_mday= 10*(text[4]-'0')+text[5]-'0'; + if(l==6) + return(1); + reply->tm_hour= 10*(text[7]-'0')+text[8]-'0'; + reply->tm_min= 10*(text[9]-'0')+text[10]-'0'; + if(l==11) + return(1); + reply->tm_sec= 10*(text[11]-'0')+text[12]-'0'; + return(1); +} + +#endif /* Xorriso_sfile_externaL */ + + +/* --------------------------------- misc --------------------------------- */ + + +int Strcmp(const void *pt1, const void *pt2) +{ + return(strcmp(*((char **) pt1), *((char **) pt2))); +} + + +int Sort_argv(int argc, char **argv, int flag) +{ + if(argc<=0) + return(2); + qsort(argv,(size_t) argc,sizeof(char *),Strcmp); + return(1); +} + + +static int Text_to_argv(char *text, int *argc, char ***argv, int flag) +{ + char *npt, *cpt; + int pass; + + *argv= NULL; + *argc= 0; + for(pass= 0; pass < 2; pass++) { + if(pass) { + if(*argc == 0) + return(1); + (*argv)= calloc(*argc, sizeof(char *)); + if(*argv == NULL) { + *argc= 0; + return(-1); + } + *argc= 0; + } + for(npt= cpt= text; npt != NULL; cpt= npt + 1) { + npt= strchr(cpt, '\n'); + if(pass) { + if(npt != NULL) + *npt= 0; + (*argv)[*argc]= cpt; + } + (*argc)++; + } + } + return(1); +} + + +static int Count_diffs(int argc1, char **argv1, int argc2, char **argv2, + int flag) +{ + int count= 0, i1= 0, i2= 0, cmp, end_corr= 0; + + Sort_argv(argc1, argv1, 0); + Sort_argv(argc2, argv2, 0); + + while(1) { + if(i1 >= argc1) { + count+= argc2 - i2 - end_corr; + break; + } + if(i2 >= argc2) { + count+= argc1 - i1 - end_corr; + break; + } + cmp= strcmp(argv1[i1], argv2[i2]); + if(cmp == 0) { + end_corr= 0; + i1++; + i2++; + } else if(cmp > 0) { + count++; + end_corr= 1; + i2++; + if(i2 < argc2 && i1 < argc1 - 1) + if(strcmp(argv1[i1 + 1], argv2[i2]) == 0) { + i1++; + end_corr= 0; + } + } else { + count++; + end_corr= 1; + i1++; + if(i1 < argc1 && i2 < argc2 - 1) + if(strcmp(argv2[i2 + 1], argv1[i1]) == 0) { + i2++; + end_corr= 0; + } + } + } + return(count); +} + + +/* + @flag bit0= do not initialize *diff_count + @return <0 error , 0 = mismatch , 1 = match +*/ +static int Compare_text_lines(char *text1, char *text2, int *diff_count, + int flag) +{ + int ret, argc1= 0, argc2= 0; + char **argv1= NULL, **argv2= NULL, *copy1= NULL, *copy2= NULL; + + if(!(flag & 1)) + *diff_count= 0; + if(text1 == NULL && text2 == NULL) + return(1); + if(text1 != NULL) { + copy1= strdup(text1); + if(copy1 == NULL) + {ret= -1; goto ex;} + ret= Text_to_argv(copy1, &argc1, &argv1, 0); + if(ret <= 0) + {ret= -1; goto ex;} + } + if(text2 != NULL) { + copy2= strdup(text2); + if(copy2 == NULL) + {ret= -1; goto ex;} + ret= Text_to_argv(copy2, &argc2, &argv2, 0); + if(ret <= 0) + {ret= -1; goto ex;} + } + ret= Count_diffs(argc1, argv1, argc2, argv2, 1); + if(ret < 0) + goto ex; + *diff_count+= ret; + ret= (*diff_count == 0); +ex:; + if(argv1 != NULL) + free(argv1); + if(argv2 != NULL) + free(argv2); + if(copy1 != NULL) + free(copy1); + if(copy2 != NULL) + free(copy2); + return ret; +} + + +/** Convert a text into a number of type double and multiply it by unit code + [kmgtpe] (2^10 to 2^60) or [s] (2048). (Also accepts capital letters.) + @param text Input like "42", "2k", "3.14m" or "-1g" + @param flag Bitfield for control purposes: + bit0= return -1 rathern than 0 on failure + @return The derived double value +*/ +double Scanf_io_size(char *text, int flag) +/* + bit0= default value -1 rather than 0 +*/ +{ + int c; + double ret= 0.0; + + if(flag&1) + ret= -1.0; + if(text[0]==0) + return(ret); + sscanf(text,"%lf",&ret); + c= text[strlen(text)-1]; + if(c=='k' || c=='K') ret*= 1024.0; + if(c=='m' || c=='M') ret*= 1024.0*1024.0; + if(c=='g' || c=='G') ret*= 1024.0*1024.0*1024.0; + if(c=='t' || c=='T') ret*= 1024.0*1024.0*1024.0*1024.0; + if(c=='p' || c=='P') ret*= 1024.0*1024.0*1024.0*1024.0*1024.0; + if(c=='e' || c=='E') ret*= 1024.0*1024.0*1024.0*1024.0*1024.0*1024.0; + if(c=='s' || c=='S') ret*= 2048.0; + return(ret); +} + + +int Decode_date_input_format(struct tm *erg, char *text, int flag) +/* MMDDhhmm[[CC]YY][.ss]] */ +{ + int i,l,year; + time_t current_time; + struct tm *now; + + current_time= time(0); + now= localtime(¤t_time); + for(i=0;i<sizeof(struct tm);i++) + ((char *) erg)[i]= ((char *) now)[i]; + + l= strlen(text); + for(i=0;i<l;i++) + if(text[i]<'0'||text[i]>'9') + break; + if(i!=8 && i!=10 && i!=12) + return(0); + if(text[i]==0) + goto decode; + if(text[i]!='.' || l!=15) + return(0); + i++; + if(text[i]<'0'||text[i]>'9') + return(0); + i++; + if(text[i]<'0'||text[i]>'9') + return(0); + +decode:; + /* MMDDhhmm[[CC]YY][.ss]] */ + i= 0; + erg->tm_mon= 10*(text[0]-'0')+text[1]-'0'-1; + erg->tm_mday= 10*(text[2]-'0')+text[3]-'0'; + erg->tm_hour= 10*(text[4]-'0')+text[5]-'0'; + erg->tm_min= 10*(text[6]-'0')+text[7]-'0'; + erg->tm_sec= 0; + if(l==8) + return(1); + if(l>10){ + year= 1000*(text[8]-'0')+100*(text[9]-'0')+10*(text[10]-'0')+(text[11]-'0'); + }else{ + year= 1900+10*(text[8]-'0')+(text[9]-'0'); + if(year<1970) + year+= 100; + } + erg->tm_year= year-1900; + if(l<=12) + return(1); + erg->tm_sec= 10*(text[13]-'0')+text[14]-'0'; + return(1); +} + + +int Decode_date_weekday(char *text, int flag) +{ + int i; + static char days[][4]= {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", ""}; + + for(i= 0; days[i][0]!=0; i++) + if(strncmp(text,days[i],3)==0) + return(i); + if((strlen(text)==3 || (strlen(text)==4 && text[3]==',')) && + isalpha(text[0]) && isalpha(text[1]) && isalpha(text[2])) + return(7); + return(-1); +} + + +int Decode_date_month(char *text, int flag) +{ + int i; + static char months[][4]= {"Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ""}; + + for(i= 0; months[i][0]!=0; i++) + if(strncmp(text,months[i],3)==0) + return(i); + return(-1); +} + + +/* @return -1=not a number, -2=not a day , 1 to 31 day of month */ +int Decode_date_mday(char *text, int flag) +{ + int ret, i; + + for(i= 0; text[i]!=0; i++) + if(!isdigit(text[i])) + return(-1); + if(strlen(text)>2 || text[0]==0) + return(-2); + sscanf(text, "%d", &ret); + if(ret<=0 || ret>31) + return(-2); + return(ret); +} + +int Decode_date_hms(char *text, struct tm *erg, int flag) +{ + int i, hour= -1, minute= -1, second= 0; + + for(i= 0; i<9; i+= 3) { + if(i==6&&text[i]==0) + break; + if(!isdigit(text[i])) + return(-1); + if(!isdigit(text[i+1])) + return(-1); + if(text[i+2]!=':' && !(text[i+2]==0 && i>=3)) + return(-1); + if(i==0) + sscanf(text+i,"%d",&hour); + else if(i==3) + sscanf(text+i,"%d",&minute); + else + sscanf(text+i,"%d",&second); + } + if(hour<0 || hour>23 || minute<0 || minute>59 || second>59) + return(-1); + erg->tm_hour= hour; + erg->tm_min= minute; + erg->tm_sec= second; + return(1); +} + + +/* @return -1=not a number, -2=not a year , >=0 years AD */ +int Decode_date_year(char *text, int flag) +{ + int ret, i; + + for(i= 0; text[i]!=0; i++) + if(!isdigit(text[i])) + return(-1); + if(strlen(text)!=4) + return(-2); + sscanf(text, "%d", &ret); + if(ret<0 || ret>3000) + return(-2); + return(ret); +} + + +int Decode_date_timezone(char *text, struct tm *erg, int flag) +{ + int i; + static char tzs[][5]= {"GMT", "CET", "CEST", "0000", ""}; + + for(i= 0; tzs[i][0]!=0; i++) + if(strcmp(text,tzs[i])==0) { + + /* ??? >>> what to do with timezone info ? Add to ->tm_hour ? */ + + return(1); + } + if(text[0]=='+' || text[0]=='-') { + for(i= 1; text[i]!=0; i++) + if(!isdigit(text[i])) + return(-1); + if(i!=5) + return(-1); + + /* ??? >>> what to do with timezone info ? Add to ->tm_hour ? */ + + return(1); + } else { + for(i= 0; text[i]!=0; i++) + if(text[i]<'A' || text[i]>'Z') + return(-1); + if(i!=3 && i!=4) + return(-1); + return(2); + } +} + + +int Decode_date_output_format(struct tm *erg, char *text, int flag) +/* Thu Nov 8 09:07:50 CET 2007 */ +/* Sat, 03 Nov 2007 08:58:30 +0100 */ +/* Nov 7 23:24 */ +{ + int ret, i, argc= 0, seen_year= 0, seen_month= 0, seen_day= 0, seen_time= 0; + char **argv= NULL; + struct tm *now; + time_t timep; + + memset(erg, 0, sizeof(*erg)); + erg->tm_isdst= -1; + ret= Sfile_make_argv("xorriso", text, &argc, &argv, 0); + if(ret<=0) + goto ex; + for(i= 1; i<argc; i++) { + if(!seen_month) { + ret= Decode_date_month(argv[i], 0); + if(ret>=0) { + seen_month= 1; + erg->tm_mon= ret; + continue; + } + } + if(!seen_day) { + ret= Decode_date_mday(argv[i], 0); + if(ret>0) { + seen_day= 1; + erg->tm_mday= ret; + continue; + } + if(ret==-2) /* first pure number must be day of month */ + {ret= 0; goto ex;} + } + if(!seen_time) { + ret= Decode_date_hms(argv[i], erg, 0); + if(ret>0) { + seen_time= 1; + continue; + } + } + if(!seen_year) { + ret= Decode_date_year(argv[i], 0); + if(ret>0) { + erg->tm_year= ret-1900; + seen_year= 1; + continue; + } + } + + /* ignorants have to stay at the end of the loop */ + + ret= Decode_date_timezone(argv[i], erg, 0); + if(ret>=0) + continue; + ret= Decode_date_weekday(argv[i], 0); + if(ret>=0) + continue; /* ignore weekdays */ + + {ret= 0; goto ex;} /* unrecognizable component */ + } + + if(!(seen_day && seen_month)) + {ret= 0; goto ex;} + if(!seen_year) { /* then use this year */ + timep= time(NULL); + now= localtime(&timep); + erg->tm_year= now->tm_year; + } + ret= 1; +ex: + Sfile_make_argv("", "", &argc, &argv, 2); /* release storage */ + return(ret); +} + + +int Decode_xorriso_timestamp(struct tm *erg, char *code, int flag) + /* 2007.11.07.225624 */ +{ + char buf[20]; + int year,month,day,hour= 0,minute= 0,second= 0, i, l, mem; + + memset(erg, 0, sizeof(*erg)); + erg->tm_isdst= -1; + + l= strlen(code); + if(l>17 || l<10) + return(0); + strcpy(buf, code); + for(i= 0; buf[i]!=0 && i<4; i++) + if(!isdigit(buf[i])) + return(0); + if(buf[4]!='.') + return(0); + buf[4]= 0; + sscanf(buf, "%d", &year); + if(year<1900 || year>3000) + return(0); + if(!(isdigit(buf[5]) && isdigit(buf[6]) && buf[7]=='.')) + return(0); + buf[7]= 0; + sscanf(buf+5, "%d", &month); + if(month<1 || month>12) + return(0); + if(!(isdigit(buf[8]) && isdigit(buf[9]) && (buf[10]=='.' || buf[10]==0))) + return(0); + buf[10]= 0; + sscanf(buf+8, "%d", &day); + if(day<1 || day>31) + return(0); + if(l==10) + goto done; + if(!(isdigit(buf[11]) && isdigit(buf[12]) && + (isdigit(buf[13]) || buf[13]==0))) + return(0); + mem= buf[13]; + buf[13]= 0; + sscanf(buf+11, "%d", &hour); + buf[13]= mem; + if(hour<0 || hour>23) + return(0); + if(l==13) + goto done; + if(!(isdigit(buf[13]) && isdigit(buf[14]) && + (isdigit(buf[15]) || buf[15]==0))) + return(0); + mem= buf[15]; + buf[15]= 0; + sscanf(buf+13, "%d", &minute); + buf[15]= mem; + if(minute<0 || minute>59) + return(0); + if(l==15) + goto done; + if(!(isdigit(buf[15]) && isdigit(buf[16]) && buf[17]==0)) + return(0); + sscanf(buf+15, "%d", &second); + if(second<0 || second>59) + return(0); + +done:; + erg->tm_year= year-1900; + erg->tm_mon= month-1; + erg->tm_mday= day; + erg->tm_hour= hour; + erg->tm_min= minute; + erg->tm_sec= second; + return(1); +} + + +time_t Decode_timestring(char *code, time_t *date, int flag) +{ + char *cpt,scale_chr; + double value,seconds; + struct tm result_tm; + int seconds_valid= 0; + + *date= 0; + cpt= code; + if(code[0]=='-' || code[0]=='+' || code[0]=='=' || code[0]=='@'){ + if(code[1]==0) + return(0); + if(!isdigit(code[1])) + return(0); + value= -1; + if(code[0]=='=' || code[0]=='@') { + seconds= 0; + sscanf(code+1,"%lf",&value); + } else { + seconds= time(NULL); + sscanf(code,"%lf",&value); + } + scale_chr= code[strlen(code)-1]; + if(isalpha(scale_chr)) + scale_chr= tolower(scale_chr); + if (scale_chr=='s') seconds+= 1.0*value; + else if(scale_chr=='h') seconds+= 3600.0*value; + else if(scale_chr=='d') seconds+= 86400.0*value; + else if(scale_chr=='w') seconds+= 86400.0*7.0*value; + else if(scale_chr=='m') seconds+= 86400.0*31.0*value; + else if(scale_chr=='y') seconds+= 86400.0*(365.25*value+1.0); + else seconds+= 1.0*value; + seconds_valid= 1; + goto completed; + } else if(Sfile_decode_datestr(&result_tm,code,0)>0) { + /* YYMMDD[.hhmm[ss]] */ + result_tm.tm_isdst= -1; + seconds= mktime(&result_tm); + seconds_valid= 1; + goto completed; + } else if(Decode_date_input_format(&result_tm,code,0)>0) { + /* MMDDhhmm[[CC]YY][.ss]] */ + result_tm.tm_isdst= -1; + seconds= mktime(&result_tm); + seconds_valid= 1; + goto completed; + } else if(Decode_xorriso_timestamp(&result_tm, code, 0)>0) { + /* 2007.11.07.225624 */ + seconds= mktime(&result_tm); + seconds_valid= 1; + goto completed; + } else if(Decode_date_output_format(&result_tm, code, 0)>0) { + /* Thu Nov 8 09:07:50 CET 2007 */; + /* Sat, 03 Nov 2007 08:58:30 +0100 */; + /* Nov 7 23:24 */; + seconds= mktime(&result_tm); + seconds_valid= 1; + goto completed; + } + return(0); +completed:; + if(!seconds_valid) + return(0); + *date= seconds; + return(1); +} + + +/* @param flag bit0=with year and seconds + bit1-3= form + 0= ls -l format + 1= timestamp format YYYY.MM.DD.hhmmss + 2= Wdy Mon Day hh:mm:ss Year + 3= Mon Day hh:mm:ss Year +*/ +char *Ftimetxt(time_t t, char timetext[40], int flag) +{ + char *rpt; + struct tm tms, *tmpt; + static char months[12][4]= { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + static char days[7][4]= {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; + int form; + + form= (flag>>1)&7; + tmpt= localtime_r(&t, &tms); + rpt= timetext; + rpt[0]= 0; + if(tmpt==0) + sprintf(rpt+strlen(rpt), "%12.f", (double) t); + else if (form==1) + sprintf(rpt+strlen(rpt), "%4.4d.%2.2d.%2.2d.%2.2d%2.2d%2.2d", + 1900+tms.tm_year, tms.tm_mon+1, tms.tm_mday, + tms.tm_hour, tms.tm_min, tms.tm_sec); + else if (form==2) + sprintf(rpt+strlen(rpt), "%s %s %2.2d %2.2d:%2.2d:%2.2d %4.4d", + days[tms.tm_wday], months[tms.tm_mon], tms.tm_mday, + tms.tm_hour, tms.tm_min, tms.tm_sec, 1900+tms.tm_year); + else if (form==3) + sprintf(rpt+strlen(rpt), "%s %2.2d %2.2d:%2.2d:%2.2d %4.4d", + months[tms.tm_mon], tms.tm_mday, + tms.tm_hour, tms.tm_min, tms.tm_sec, 1900+tms.tm_year); + else if (flag&1) + sprintf(rpt+strlen(rpt), "%2d %3s %4.4d %2.2d:%2.2d:%2.2d", + tms.tm_mday, months[tms.tm_mon], 1900+tms.tm_year, + tms.tm_hour, tms.tm_min, tms.tm_sec); + else if(time(NULL)-t < 180*86400 && time(NULL)-t >= 0) + sprintf(rpt+strlen(rpt), "%3s %2d %2.2d:%2.2d", + months[tms.tm_mon], tms.tm_mday, tms.tm_hour, tms.tm_min); + else + sprintf(rpt+strlen(rpt), "%3s %2d %4.4d", + months[tms.tm_mon], tms.tm_mday, 1900+tms.tm_year); + return(timetext); +} + + +/* @param flag bit0= single letters */ +char *Ftypetxt(mode_t st_mode, int flag) +{ + if(flag&1) + goto single_letters; + if(S_ISDIR(st_mode)) + return("directory"); + else if(S_ISREG(st_mode)) + return("regular_file"); + else if(S_ISLNK(st_mode)) + return("symbolic_link"); + else if(S_ISBLK(st_mode)) + return("block_device"); + else if(S_ISCHR(st_mode)) + return("char_device"); + else if(S_ISFIFO(st_mode)) + return("name_pipe"); + else if(S_ISSOCK(st_mode)) + return("unix_socket"); + return("unknown"); +single_letters:; + if(S_ISDIR(st_mode)) + return("d"); + else if(S_ISREG(st_mode)) + return("-"); + else if(S_ISLNK(st_mode)) + return("l"); + else if(S_ISBLK(st_mode)) + return("b"); + else if(S_ISCHR(st_mode)) + return("c"); + else if(S_ISFIFO(st_mode)) + return("p"); + else if(S_ISSOCK(st_mode)) + return("s"); + return("?"); +} + + +int Wait_for_input(int fd, int microsec, int flag) +{ + struct timeval wt; + fd_set rds,wts,exs; + int ready; + + FD_ZERO(&rds); + FD_ZERO(&wts); + FD_ZERO(&exs); + FD_SET(fd,&rds); + FD_SET(fd,&exs); + wt.tv_sec= microsec/1000000; + wt.tv_usec= microsec%1000000; + ready= select(fd+1,&rds,&wts,&exs,&wt); + if(ready<=0) + return(0); + if(FD_ISSET(fd,&exs)) + return(-1); + if(FD_ISSET(fd,&rds)) + return(1); + return(0); +} + + +int System_uname(char **sysname, char **release, char **version, + char **machine, int flag) +{ + int ret; + static struct utsname uts; + static int initialized= 0; + + if(initialized == 0) { + ret= uname(&uts); + if(ret != 0) + initialized = -1; + } + if(initialized == -1) + return(0); + if(sysname != NULL) + *sysname= uts.sysname; + if(release != NULL) + *release= uts.release; + if(version != NULL) + *version= uts.version; + if(machine != NULL) + *machine= uts.machine; + return(1); +} + +/* ------------------------------------------------------------------------ */ + + +#ifndef Xorriso_sregex_externaL + +#ifndef Smem_malloC +#define Smem_malloC malloc +#endif +#ifndef Smem_freE +#define Smem_freE free +#endif + + +int Sregex_string_cut(char **handle, char *text, int len, int flag) +/* + bit0= append (text!=NULL) +*/ +{ + int l=0; + char *old_handle; + + if((flag&1)&&*handle!=NULL) + l+= strlen(*handle); + old_handle= *handle; + if(text!=NULL) { + l+= len; + *handle= TSOB_FELD(char,l+1); + if(*handle==NULL) { + *handle= old_handle; + return(0); + } + if((flag&1) && old_handle!=NULL) + strcpy(*handle,old_handle); + else + (*handle)[0]= 0; + if(len>0) + strncat(*handle,text,len); + } else { + *handle= NULL; + } + if(old_handle!=NULL) + Smem_freE(old_handle); + return(1); +} + + +int Sregex_string(char **handle, char *text, int flag) +/* + bit0= append (text!=NULL) +*/ +{ + int ret,l=0; + + if(text!=NULL) + l= strlen(text); + +/* #define Sregex_looking_for_contenT 1 */ +#ifdef Sregex_looking_for_contenT + /* a debugging point if a certain text content has to be caught */ + if(text!=NULL) + if(strcmp(text,"clear")==0) + ret= 0; +#endif + + ret= Sregex_string_cut(handle,text,l,flag&1); + return(ret); +} + + +/* + vars[][0] points to the variable names, vars[][1] to their contents. + start marks the begin of variable names. It must be non-empty. esc before + start disables this meaning. start and esc may be equal but else they must + have disjoint character sets. + end marks the end of a variable name. It may be empty but if non-empty it + must not appear in vars[][0]. + @param flag bit0= Substitute unknown variables by empty text + (else copy start,name,end unaltered to result). + Parameter end must be non-empty for that. +*/ +int Sregex_resolve_var(char *form, char *vars[][2], int num_vars, + char *start, char *end, char *esc, + char *result, int result_size, int flag) +{ + int l_e, l_v, l_s, l_esc, i, start_equals_esc; + char *rpt, *wpt, *spt, *npt, *ept; + + if(start[0] == 0) /* It is not allowed to have no start marker */ + return(-1); + l_s= strlen(start); + l_e= strlen(end); + l_esc= strlen(esc); + start_equals_esc= !strcmp(start, esc); + rpt= form; + wpt= result; + wpt[0]= 0; + while(1) { + + /* look for start mark */ + spt= strstr(rpt, start); + if(spt == NULL) { + if((wpt - result) + strlen(rpt) >= result_size) + return(0); + strcpy(wpt, rpt); + wpt+= strlen(wpt); + break; + } + + /* copy cleartext part up to next variable */ + if((wpt - result) + (spt - rpt) >= result_size) + return(0); + strncpy(wpt, rpt, spt - rpt); + wpt+= spt - rpt; + *wpt= 0; + rpt= spt; + npt= spt + l_s; + + /* handle eventual escape */ + if(start_equals_esc) { + if(strncmp(spt + l_s, esc, l_esc) == 0) { + /* copy esc and start */ + if((wpt - result) + l_esc + l_s >= result_size) + return(0); + strncpy(wpt, spt, l_esc + l_s); + wpt+= l_esc + l_s; + rpt+= l_esc + l_s; + *wpt= 0; + continue; + } + } else { + /* escape would be already copied */ + if(l_esc > 0 && spt - form >= l_esc) { + if(strncmp(spt - l_esc, esc, l_esc) == 0) { + /* copy start */ + if((wpt - result) + l_s >= result_size) + return(0); + strncpy(wpt, spt, l_s); + wpt+= l_s; + rpt+= l_s; + *wpt= 0; + continue; + } + } + } + + /* Memorize eventual end mark for default handling */; + ept= NULL; + if(l_e > 0) + ept= strstr(npt, end); + + /* Look for defined variable name */ + for(i = 0; i < num_vars; i++) { + if(strncmp(npt, vars[i][0], strlen(vars[i][0])) == 0 + && (l_e == 0 || strncmp(npt + strlen(vars[i][0]), end, l_e) == 0)) + break; + } + if(i < num_vars) { + /* substitute found variable */ + l_v= strlen(vars[i][0]); + if((wpt - result) + strlen(vars[i][1]) >= result_size) + return(0); + strcpy(wpt, vars[i][1]); + rpt= npt + strlen(vars[i][0]) + l_e; + } else if((flag & 1) && ept != NULL) { + /* skip up to end mark */ + rpt= ept + l_e; + } else if(ept != NULL) { + /* copy start,name,end */ + if((wpt - result) + (ept - rpt) + l_e >= result_size) + return(0); + strncpy(wpt, rpt, (ept - rpt) + l_e); + rpt= ept + l_e; + } else { + /* copy start marker only */ + if((wpt - result) + l_s >= result_size) + return(0); + strncpy(wpt, rpt, l_s); + rpt= rpt + l_s; + } + wpt+= strlen(wpt); + *wpt= 0; + } + return(1); +} + + +/* @param flag bit0= only test expression whether compilable +*/ +int Sregex_match(char *pattern, char *text, int flag) +{ + int ret; + char re_text[2*SfileadrL]; + regex_t re; + regmatch_t match[1]; + + Xorriso__bourne_to_reg(pattern, re_text, 0); + ret= regcomp(&re, re_text, 0); + if(ret != 0) + return(-1); + if(flag & 1) { + regfree(&re); + return(1); + } + ret= regexec(&re, text, 1, match, 0); + regfree(&re); + if(ret != 0) + return(0); + return(1); +} + + +#endif /* Xorriso_sregex_externaL */ + + + +/* @param flag bit0= append to out_text rather than overwrite it +*/ +char *Text_shellsafe(char *in_text, char *out_text, int flag) +{ + int l,i,ol= 0,w=0; + + if(flag&1) + ol= w= strlen(out_text); + /* enclose everything by hard quotes */ + l= strlen(in_text); + out_text[w++]= '\''; + for(i=0;i<l;i++){ + if(in_text[i]=='\''){ + if(w+7>5*SfileadrL+ol) + goto overflow; + /* escape hard quote within the text */ + out_text[w++]= '\''; + out_text[w++]= '"'; + out_text[w++]= '\''; + out_text[w++]= '"'; + out_text[w++]= '\''; + } else { + if(w+3>5*SfileadrL) { +overflow:; + strncpy(out_text, "'xorriso: TEXT MUCH TOO LONG ... ",33); + break; + } + out_text[w++]= in_text[i]; + } + } + out_text[w++]= '\''; + out_text[w++]= 0; + return(out_text); +} + + +#ifndef Xorriso_fileliste_externaL + +/* ??? ts A71006 : Is this compatible with mkisofs pathspecs ? + I dimly remember so */ + +int Fileliste__target_source_limit(char *line, char sep, char **limit_pt, + int flag) +{ + char *npt; + + for(npt= line;*npt!=0;npt++) { + if(*npt=='\\') { + if(*(npt+1)!=0) + npt++; + continue; + } + if(*npt=='=') + break; + } + if(*npt==0) + npt= NULL; + (*limit_pt)= npt; + return(npt!=NULL); +} + +#endif /* ! Xorriso_fileliste_externaL */ + + +/* ------------------------------------------------------------------------ */ +/* DirseQ : crawl along a directory's content list */ + +static int Dirseq_buffer_sizE= 100; + +struct DirseQ { + char adr[SfileadrL]; + DIR *dirpt; + int count; + char **buffer; + int buffer_size; + int buffer_fill; + int buffer_rpt; + + struct DirseQ *next; +}; + +int Dirseq_destroy(struct DirseQ **o, int flag); +int Dirseq_next_adrblock(struct DirseQ *o, char *replies[], int *reply_count, + int max_replies, int flag); + + +int Dirseq_new(struct DirseQ **o, char *adr, int flag) +/* + bit0= with non-fatal errors do not complain about failed opendir() +*/ +{ + int ret,i,severe_error; + struct DirseQ *m; + + m= *o= TSOB_FELD(struct DirseQ,1); + if(m==NULL) + return(-1); + m->adr[0]= 0; + m->dirpt= NULL; + m->count= 0; + m->buffer= NULL; + m->buffer_size= 0; + m->buffer_fill= 0; + m->buffer_rpt= 0; + m->next= NULL; + if(Sfile_str(m->adr, adr, 0)<=0) + {ret= 0; goto failed;} + m->buffer= TSOB_FELD(char *,Dirseq_buffer_sizE); + if(m->buffer==NULL) + {ret= -1; goto failed;} + m->buffer_size= Dirseq_buffer_sizE; + for(i= 0;i<m->buffer_size;i++) + m->buffer[i]= NULL; + if(adr[0]==0) + m->dirpt= opendir("."); + else + m->dirpt= opendir(adr); + if(m->dirpt==NULL) { + severe_error= (errno && errno!=ENOENT && errno!=EACCES && errno!=ENOTDIR); + if(severe_error || !(flag&1)) + fprintf(stderr,"opendir(%s) failed : %s\n",adr,strerror(errno)); + ret= -severe_error; + goto failed; + } + return(1); +failed:; + Dirseq_destroy(o,0); + return(ret); +} + + +int Dirseq_destroy(struct DirseQ **o, int flag) +{ + int i; + + if(*o==NULL) + return(0); + if((*o)->dirpt!=NULL) + closedir((*o)->dirpt); + if((*o)->buffer!=NULL) { + for(i=0;i<(*o)->buffer_size;i++) + if((*o)->buffer[i]!=NULL) + free((*o)->buffer[i]); + free((char *) (*o)->buffer); + } + free((char *) *o); + (*o)= NULL; + return(1); +} + + +int Dirseq_set_next(struct DirseQ *o, struct DirseQ *next, int flag) +{ + o->next= next; + return(1); +} + + +int Dirseq_get_next(struct DirseQ *o, struct DirseQ **next, int flag) +{ + *next= o->next; + return(1); +} + + +int Dirseq_get_adr(struct DirseQ *o, char **adrpt, int flag) +{ + *adrpt= o->adr; + return(1); +} + + +int Dirseq_rewind(struct DirseQ *o, int flag) +{ + rewinddir(o->dirpt); + return(1); +} + + +int Dirseq_next_adr(struct DirseQ *o, char reply[SfileadrL], int flag) +/* +flag: + bit0= permission to use buffer + bit1= do not increment counter + bit2= ignore buffer in any case + bit3= do not exclude '.' and '..' + bit4= sort buffer + bit5= sort only incomplete last buffer +return: + <0 error + 0= no more entries available + 1= ok, reply is valid +*/ +{ + int ret; + struct dirent *entry; + char *name; + + static int override_flag_0= 0,override_flag_1= 32; + flag= (flag&~override_flag_0)|override_flag_1; + + if((flag&1) && o->buffer_rpt>=o->buffer_fill) { + /* permission to buffer and buffer empty : load a buffer */ + ret= Dirseq_next_adrblock(o,o->buffer,&(o->buffer_fill), + o->buffer_size,2|4|(flag&16)); + if(ret<=0) + return(ret); + o->buffer_rpt= 0; + if((flag&32) && o->buffer_fill<o->buffer_size && o->buffer_fill>0) + Sort_argv(o->buffer_fill,o->buffer,0); + } + if(o->buffer_rpt<o->buffer_fill && !(flag&4)) { + ret= Sfile_str(reply,o->buffer[o->buffer_rpt],0); + Sregex_string(&(o->buffer[o->buffer_rpt]),NULL,0); + if(ret<=0) + return(-1); + (o->buffer_rpt)++; + if(!(flag&2)) + o->count++; + return(1); + } + do { + entry= readdir(o->dirpt); + if(entry==NULL) { + /* >>> how to distinguish error from EOF , do i need a (FILE *) ? */ + return(0); + } + if(strlen(entry->d_name)>=SfileadrL) { + fprintf(stderr,"--- oversized directory entry (number %d) :\n %s", + o->count+1,entry->d_name); + return(-1); + } + name= entry->d_name; + if(flag&8) + break; + /* skip "." and ".." */ + } while(name[0]=='.' && ((name[1]=='.' && name[2]==0) || name[1]==0)); + if(Sfile_str(reply,name,0)<=0) + return(-1); + if(!(flag&2)) + o->count++; + return(1); +} + + +int Dirseq_next_adrblock(struct DirseQ *o, char *replies[], int *reply_count, + int max_replies, int flag) +/* @param replies A vector of Sregex_string pointers */ +/* +flag: + bit0= permission to use buffer + bit1= do not increment counter + bit2= ignore buffer in any case + bit4= sort replies +return: + <0 error + 0= no more entries available + 1= ok, reply is valid +*/ +{ + int i,ret; + char reply[SfileadrL]; + + *reply_count= 0; + for(i=0;i<max_replies;i++) { + ret= Dirseq_next_adr(o,reply,flag&(1|2|4)); + if(ret<0) + return(ret); + if(ret==0) + break; + if(Sregex_string(&(replies[i]),reply,0)<=0) + return(-1); + (*reply_count)++; + } + if((*reply_count)==0) + return(0); + if(flag&16) + Sort_argv(*reply_count,replies,0); + return(1); +} + + +/* --------------------------------- Xorriso_lsT --------------------------- */ + + +/* + @param flag Bitfield for control purposes + bit0= insert before link rather than after it + bit1= do not copy data (e.g. because *data is invalid) + bit2= attach data directly by pointer rather than by copying +*/ +int Xorriso_lst_new_binary(struct Xorriso_lsT **lstring, char *data, + int data_len, struct Xorriso_lsT *link, int flag) +{ + int ret; + struct Xorriso_lsT *s; + + s= TSOB_FELD(struct Xorriso_lsT,1); + if(s==NULL) + return(-1); + s->text= NULL; + s->next= s->prev= NULL; + + if(flag & 4) { + s->text= data; + } else { + if(data_len<=0) + {ret= -1; goto failed;} + s->text= Smem_malloC(data_len); + if(s->text==NULL) + {ret= -1; goto failed;} + if(!(flag&2)) + memcpy(s->text,data,data_len); + } + + if(link==NULL) { + ; + } else if(flag&1) { + s->next= link; + s->prev= link->prev; + if(link->prev!=NULL) + link->prev->next= s; + link->prev= s; + } else { + s->prev= link; + s->next= link->next; + if(link->next!=NULL) + link->next->prev= s; + link->next= s; + } + *lstring= s; + return(1); +failed:; + *lstring= s; + Xorriso_lst_destroy(lstring,0); + return(-1); +} + + +/* + @param flag Bitfield for control purposes + see Xorriso_lst_new_binary() +*/ +int Xorriso_lst_new(struct Xorriso_lsT **lstring, char *text, + struct Xorriso_lsT *link, int flag) +{ + int ret; + + ret= Xorriso_lst_new_binary(lstring,text,strlen(text)+1,link,flag); + return(ret); +} + + +/* + @param flag Bitfield for control purposes + bit0= do not set *lstring to NULL +*/ +int Xorriso_lst_destroy(struct Xorriso_lsT **lstring, int flag) +{ + struct Xorriso_lsT *s; + + s= *lstring; + if(s==NULL) + return(0); + if(s->prev!=NULL) + s->prev->next= s->next; + if(s->next!=NULL) + s->next->prev= s->prev; + if(s->text!=NULL) + Smem_freE(s->text); + Smem_freE((char *) s); + if(!(flag&1)) + *lstring= NULL; + return(1); +} + + +int Xorriso_lst_destroy_all(struct Xorriso_lsT **lstring, int flag) +{ + struct Xorriso_lsT *s,*next; + + if(lstring==NULL) + return(-1); + if((*lstring)==NULL) + return(0); + for(s= *lstring; s->prev!=NULL; s= s->prev); + for(;s!=NULL;s= next){ + next= s->next; + Xorriso_lst_destroy(&s,0); + } + *lstring= NULL; + return(1); +} + + +int Xorriso_lst_append_binary(struct Xorriso_lsT **entry, + char *data, int data_len, int flag) +{ + struct Xorriso_lsT *target= NULL,*newby; + + if(*entry!=NULL) + for(target= *entry; target->next!=NULL; target= target->next); + if(Xorriso_lst_new_binary(&newby, data, data_len, target, flag & ~1)<=0) + return(-1); + if(*entry==NULL || (flag & 1)) + *entry= newby; + return(1); +} + + +struct Xorriso_lsT *Xorriso_lst_get_next(struct Xorriso_lsT *entry, int flag) +{ + return(entry->next); +} + + +struct Xorriso_lsT *Xorriso_lst_get_prev(struct Xorriso_lsT *entry, int flag) +{ + return(entry->prev); +} + + +char *Xorriso_lst_get_text(struct Xorriso_lsT *entry, int flag) +{ + return(entry->text); +} + + +int Xorriso_lst_detach_text(struct Xorriso_lsT *entry, int flag) +{ + entry->text= NULL; + return(1); +} + + +/* ------------------------------ LinkiteM -------------------------------- */ + +struct LinkiteM { + char *link_path; + dev_t target_dev; + ino_t target_ino; + int link_count; + struct LinkiteM *next; +}; + +int Linkitem_destroy(struct LinkiteM **o, int flag); + + +int Linkitem_new(struct LinkiteM **o, char *link_path, dev_t target_dev, + ino_t target_ino, struct LinkiteM *next, int flag) +{ + struct LinkiteM *m; + + m= *o= TSOB_FELD(struct LinkiteM,1); + if(m==NULL) + return(-1); + m->target_dev= target_dev; + m->target_ino= target_ino; + m->next= next; + m->link_count= 1; + if(next!=NULL) + m->link_count= m->next->link_count+1; + m->link_path= strdup(link_path); + if(m->link_path==NULL) + goto failed; + return(1); +failed:; + Linkitem_destroy(o, 0); + return(-1); +} + + +int Linkitem_destroy(struct LinkiteM **o, int flag) +{ + if((*o)==NULL) + return(0); + if((*o)->link_path!=NULL) + free((*o)->link_path); + free((char *) (*o)); + *o= NULL; + return(1); +} + + +int Linkitem_reset_stack(struct LinkiteM **o, struct LinkiteM *to, int flag) +{ + struct LinkiteM *m, *m_next= NULL; + + /* Prevent memory corruption */ + for(m= *o; m!=to; m= m->next) + if(m==NULL) { /* this may actually not happen */ + *o= to; + return(-1); + } + + for(m= *o; m!=to; m= m_next) { + m_next= m->next; + Linkitem_destroy(&m, 0); + } + *o= to; + return(1); +} + + +int Linkitem_find(struct LinkiteM *stack, dev_t target_dev, ino_t target_ino, + struct LinkiteM **result, int flag) +{ + struct LinkiteM *m; + + for(m= stack; m!=NULL; m= m->next) { + if(target_dev == m->target_dev && target_ino == m->target_ino) { + *result= m; + return(1); + } + } + return(0); +} + + +/* ----------------------- Exprtest ----------------------- */ + + +int Exprtest_new( struct ExprtesT **ftest, struct FindjoB *boss, int flag) +{ + struct ExprtesT *f; + + *ftest= f= TSOB_FELD(struct ExprtesT,1); + if(f==NULL) + return(-1); + f->boss= boss; + f->invert= 0; + f->test_type= -1; + f->arg1= NULL; + f->arg2= NULL; + return(1); +} + + +int Exprtest_destroy(struct ExprtesT **ftest, int flag) +{ + struct ExprtesT *f; + + f= *ftest; + if(f==NULL) + return(0); + + if(f->test_type == 1) { + if(f->arg1 != NULL) + free(f->arg1); + if(f->arg2 != NULL) { + regfree(f->arg2); + free(f->arg2); + } + } else if(f->test_type == 9) { + /* arg1 is not an allocated value */; + } else { + if(f->arg1 != NULL) + free(f->arg1); + if(f->arg2 != NULL) + free(f->arg2); + } + free((char *) f); + *ftest= NULL; + return(1); +} + + +/* ----------------------- Nttpfnode ----------------------- */ + + +int Exprnode_new(struct ExprnodE **fnode, struct FindjoB *job, + struct ExprnodE *up, char *origin, int flag) +/* + bit0= set invert-property + bit1= set use_shortcuts +*/ +{ + struct ExprnodE *n; + int ret,i; + + *fnode= n= TSOB_FELD(struct ExprnodE,1); + if(n == NULL) + return(-1); + for(i= 0; i < sizeof(n->origin); i++) + n->origin[i]= 0; + strncpy(n->origin, origin, sizeof(n->origin) - 1); + n->up= up; + n->invert= (flag & 1); + n->assoc= 0; + n->use_shortcuts= !!(flag & 2); + n->left= NULL; + n->left_op= -1; + n->right= NULL; + n->right_op= -1; + n->sub= NULL; + n->is_if_then_else= 0; + n->true_branch= NULL; + n->false_branch= NULL; + n->test= NULL; + n->own_value= -1; + n->composed_value= -1; + + ret= Exprtest_new(&(n->test), job, 0); + if(ret<=0){ + Exprnode_destroy(fnode, 0); + return(-1); + } + return(1); +} + + +int Exprnode_destroy(struct ExprnodE **fnode, int flag) +{ + if(*fnode == NULL) + return(0); + Exprnode_destroy(&((*fnode)->right),0); + Exprnode_destroy(&((*fnode)->sub),0); + Exprnode_destroy(&((*fnode)->true_branch),0); + Exprnode_destroy(&((*fnode)->false_branch),0); + Exprtest_destroy(&((*fnode)->test),0); + free((char *) *fnode); + *fnode= NULL; + return(1); +} + + +int Exprnode_set_is_if(struct ExprnodE *fnode, int value, int flag) +{ + fnode->is_if_then_else= value; + return(1); +} + + +int Exprnode_is_if(struct ExprnodE *fnode, int flag) +{ + return(fnode->is_if_then_else); +} + + +int Exprnode_set_branch(struct ExprnodE *fnode, struct ExprnodE *target, + int flag) +/* + bit0= false_branch (else true_branch) +*/ +{ + struct ExprnodE **branch; + + if(flag&1) + branch= &(fnode->false_branch); + else + branch= &(fnode->true_branch); + Exprnode_destroy(branch,0); + (*branch)= target; + return(1); +} + + +int Exprnode_get_branch(struct ExprnodE *fnode, struct ExprnodE **branch, + int flag) +/* + bit0= false_branch (else true_branch) +*/ +{ + if(flag&1) + (*branch)= fnode->false_branch; + else + (*branch)= fnode->true_branch; + return(1); +} + + +int Exprnode_is_defined(struct ExprnodE *fnode, int flag) +{ + struct ExprtesT *ftest; + + if(fnode==NULL) + return(0); + if(fnode->sub!=NULL) + return(1); + ftest= fnode->test; + if(ftest==NULL) + return(0); + if(ftest->test_type>=0) + return(1); + return(0); +} + + +int Exprnode_own_value(struct XorrisO *xorriso, struct ExprnodE *fnode, + void *node, char *name, char *path, + struct stat *boss_stbuf, struct stat *stbuf, int flag) +/* +flag: +return: (also from Exprtest_match() and Exprnode_tree_value() ) + <0 = error + 0 = does not match + 1 = does match + 2 = immediate decision : does not match + 3 = immediate decision : does match +*/ +{ + int ret; + + if(fnode==NULL) + return(1); + if(fnode->sub!=NULL) { + ret= Exprnode_tree_value(xorriso, fnode->sub, -1, + node, name, path, boss_stbuf, stbuf, 0); + } else { + ret= Exprtest_match(xorriso, fnode->test, node, name, path, + boss_stbuf, stbuf, 0); + } + if(ret<0) + return(ret); + if(ret>1) + return(ret); + if(fnode->invert) + ret= !ret; + return(ret); +} + + +int Exprnode_op(int value1, int value2, int op, int flag) +{ + int ret; + + if(op==0) + ret= value1 || value2 ; + else + ret= value1 && value2 ; + return(ret); +} + + +int Exprnode_tree_value(struct XorrisO *xorriso, struct ExprnodE *fnode, + int left_value, void *node, char *name, char *path, + struct stat *boss_stbuf, struct stat *stbuf, int flag) +/* + bit0-7= testmode: 0=head , 1=filename +return: (also from Nntpftest_match() and Nntpfnode_own_value() ) + <0 = error + 0 = does not match + 1 = does match + 2 = immediate decision : does not match + 3 = immediate decision : does match +*/ +{ + int value= 1,ret; + + if(fnode==NULL) + return(1); + if(!Exprnode_is_defined(fnode,0)) + return(1); + + if(fnode->use_shortcuts && fnode->left!=NULL){ + fnode->composed_value= left_value; + if(fnode->left_op==0) {/* OR */ + if(left_value!=0) + goto ex; + } else { /* AND */ + if(left_value==0) + goto ex; + } + } + fnode->composed_value= fnode->own_value= + Exprnode_own_value(xorriso, fnode, node, name, path, boss_stbuf, stbuf, 0); + if(fnode->own_value < 0 || fnode->own_value > 1) + return(fnode->own_value); + + if(fnode->assoc == 0){ /* left associative */ + if(fnode->left != NULL && left_value >= 0) + fnode->composed_value= + Exprnode_op(left_value, fnode->own_value, fnode->left_op, 0); + /* compute right value */ + /* is the right value relevant ? */ + if(fnode->right!=NULL){ + if(fnode->use_shortcuts){ + if(fnode->right_op==0) {/* OR */ + if(fnode->composed_value!=0) + goto ex; + } else { /* AND */ + if(fnode->composed_value==0) + goto ex; + } + } + value= Exprnode_tree_value(xorriso, fnode->right,fnode->composed_value, + node, name, path, boss_stbuf, stbuf, 0); + if(value<0 || value>1) + return(value); + fnode->composed_value= value; + } + }else{ /* right associative */ + if(fnode->right!=NULL){ + /* is the right value relevant ? */ + if(fnode->use_shortcuts){ + if(fnode->right_op==0) {/* OR */ + if(fnode->composed_value!=0) + goto ex; + } else { /* AND */ + if(fnode->composed_value==0) + goto ex; + } + } + value= Exprnode_tree_value(xorriso, fnode->right,fnode->own_value, + node, name, path, boss_stbuf, stbuf, 0); + if(value<0||value>1) + return(value); + } else + value= fnode->own_value; + fnode->composed_value= value; + if(fnode->left!=NULL && left_value>=0) + fnode->composed_value= + Exprnode_op(left_value,fnode->composed_value,fnode->left_op,0); + } +ex: + ret= fnode->composed_value; + if(fnode->is_if_then_else) { + /* The if-condition is evaluated. Now follow the chosen branch */ + struct ExprnodE *branch; + if(ret>0) + branch= fnode->true_branch; + else + branch= fnode->false_branch; + if(branch!=NULL) { + ret= Exprnode_tree_value(xorriso, branch, -1, + node, name, path, boss_stbuf, stbuf, 0); + if(ret<0) + return(ret); + if(ret>1) + return(ret); + } + fnode->composed_value= ret; + } + return(fnode->composed_value); +} + + +/* --------------------- Findjob -------------------- */ + + +int Findjob_new(struct FindjoB **o, char *start_path, int flag) +{ + struct FindjoB *m; + int ret; + + m= *o= TSOB_FELD(struct FindjoB,1); + if(m==NULL) + return(-1); + m->start_path= NULL; + m->test_tree= NULL; + m->cursor= NULL; + m->invert= 0; + m->use_shortcuts= 1; + m->action= 0; /* print */ + m->prune= 0; + m->target= NULL; /* a mere pointer, not managed memory */ + m->text_2= NULL; /* a mere pointer, not managed memory */ + m->user= 0; + m->group= 0; + m->type= 0; + m->date= 0; + m->start_path= strdup(start_path); + if(m->start_path==NULL) + goto failed; + m->found_path= NULL; + m->subjob= NULL; + + ret= Exprnode_new(&(m->test_tree), m, NULL, "-find", (m->use_shortcuts)<<1); + if(ret<=0) + goto failed; + m->cursor= m->test_tree; + return(1); + +failed:; + Findjob_destroy(o, 0); + return(-1); +} + + +int Findjob_destroy(struct FindjoB **o, int flag) +{ + struct FindjoB *m; + + m= *o; + if(m==NULL) + return(0); + if(m->test_tree != NULL) + Exprnode_destroy(&(m->test_tree), 0); + free((char *) *o); + *o= NULL; + return(1); +} + + +int Findjob_set_start_path(struct FindjoB *o, char *start_path, int flag) +{ + if(o->start_path!=NULL) + free(o->start_path); + if(start_path!=NULL) { + o->start_path= strdup(start_path); + if(o->start_path==NULL) + return(-1); + } else + o->start_path= NULL; + return(1); +} + + +int Findjob_get_start_path(struct FindjoB *o, char **start_path, int flag) +{ + *start_path= o->start_path; + return(1); +} + + +int Findjob_cursor_complete( struct FindjoB *job, int flag) +{ + int ret; + + if(job==NULL) + return(0); + ret= Exprnode_is_defined(job->cursor,0); + return(ret); +} + + +int Findjob_is_restrictive(struct FindjoB *job, int flag) +{ + if(job == NULL) + return(0); + if(job->test_tree == NULL) + return(0); + if(!Exprnode_is_defined(job->test_tree, 0)) + return(0); + return(1); +} + + +int Findjob_new_node(struct FindjoB *job, struct ExprnodE **fnode, + char *origin, int flag) +/* + bit0= open new branch + bit1= with bit1 : do not register as sub-node of job->cursor +*/ +{ + int ret; + struct ExprnodE *f; + + ret= Exprnode_new(fnode,job,NULL,origin, + job->invert|((job->use_shortcuts)<<1)); + if(ret<=0) + return(ret); + f= *fnode; + if(flag&1) { + f->up= job->cursor; + if(job->cursor!=NULL && !(flag&2)) { + if(job->cursor->sub!=NULL) { + /* This would become a memory leak */ + job->errn= -2; + sprintf(job->errmsg, + "Program error while parsing -job : sub branch overwrite"); + return(0); + } else + job->cursor->sub= f; + } + } else { + f->up= job->cursor->up; + f->left= job->cursor; + if(job->cursor!=NULL) + job->cursor->right= f; + } + job->invert= 0; + return(1); +} + + +/* If an operator is expected : use -and + @param flag bit0= prepare for a pseudo-test: + if an operator is expected, do nothing and return 2 +*/ +int Findjob_default_and(struct FindjoB *o, int flag) +{ + int ret; + + if(Findjob_cursor_complete(o, 0)) { + if(flag & 1) + return(2); + ret= Findjob_and(o, 0); + if(ret <= 0) + return(ret); + } + return(1); +} + + +int Findjob_open_bracket(struct FindjoB *job, int flag) +{ + int ret; + struct ExprnodE *fnode; + + ret= Findjob_default_and(job, 0); + if(ret <= 0) + return(ret); + ret= Findjob_new_node(job, &fnode, "-sub", 1); + if(ret <= 0) + return(ret); + job->cursor= fnode; + return(1); +} + + +int Findjob_close_bracket(struct FindjoB *job, int flag) +{ + if(!Findjob_cursor_complete(job, 0)) { + job->errn= -3; + sprintf(job->errmsg, + "Unary operator or expression expected, closing-bracket found"); + return(0); + } + + if(job->cursor->up==NULL){ + job->errn= -1; + sprintf(job->errmsg, + "No bracket open when encountering closing bracket."); + return(0); + } + job->cursor= job->cursor->up; + return(1); +} + + +int Findjob_not(struct FindjoB *job, int flag) +{ + int ret; + + ret= Findjob_default_and(job, 0); + if(ret <= 0) + return(ret); + job->cursor->invert= !job->cursor->invert; + return(1); +} + + +int Findjob_and(struct FindjoB *job, int flag) +{ + int ret; + struct ExprnodE *fnode; + + if(!Findjob_cursor_complete(job, 0)) { + job->errn= -3; + sprintf(job->errmsg, + "Unary operator or expression expected, binary operator found"); + return(0); + } + + ret= Findjob_new_node(job, &fnode, "-and", 0); + if(ret<=0) + return(ret); + job->cursor->right_op= 1; + job->cursor->assoc= 1; /* compute right side first */ + fnode->left_op= 1; + fnode->assoc= 0; /* compute left side first */ + job->cursor= fnode; + return(1); +} + + +int Findjob_or(struct FindjoB *job, int flag) +{ + int ret; + struct ExprnodE *fnode; + + if(!Findjob_cursor_complete(job, 0)) { + job->errn= -3; + sprintf(job->errmsg, + "Unary operator or expression expected, binary operator found"); + return(0); + } + + ret= Findjob_new_node(job, &fnode, "-or", 0); + if(ret<=0) + return(ret); + job->cursor->right= fnode; + job->cursor->right_op= 0; + /* if existing : compute left side first */ + job->cursor->assoc= (job->cursor->left == NULL); + fnode->left= job->cursor; + fnode->left_op= 0; + fnode->assoc= 0; /* no right side yet : compute left side first */ + job->cursor= fnode; + return(1); +} + + +int Findjob_if(struct FindjoB *job, int flag) +{ + int ret; + struct ExprnodE *fnode; + + ret= Findjob_default_and(job, 0); + if(ret <= 0) + return(ret); + ret= Findjob_new_node(job, &fnode, "-if", 1); + if(ret<=0) + return(ret); + Exprnode_set_is_if(fnode,1,0); + job->cursor= fnode; + return(1); +} + + +int Findjob_then(struct FindjoB *job, int flag) +{ + int ret; + struct ExprnodE *fnode,*branch= NULL; + + if(! Findjob_cursor_complete(job,0)) { + job->errn= -3; + sprintf(job->errmsg, + "Unary operator or expression expected, -then-operator found"); + return(0); + } + /* Finding the -if that matches this -then + Do not go up one node but look for the leftmost one. + If everything is right we are at level of the -if node */ + while(job->cursor->left!=NULL) + job->cursor= job->cursor->left; + Exprnode_get_branch(job->cursor, &branch, 0); + if(!Exprnode_is_if(job->cursor, 0) || branch != NULL) { + job->errn= -5; + sprintf(job->errmsg, "-then-operator found outside its proper range."); + return(0); + } + ret= Findjob_new_node(job, &fnode, "-then", 1|2); + if(ret <= 0) + return(ret); + Exprnode_set_branch(job->cursor, fnode, 0); + job->cursor= fnode; + return(1); +} + + +int Findjob_else(struct FindjoB *job, int flag) +{ + int ret; + struct ExprnodE *fnode, *true_branch, *false_branch; + + if(! Findjob_cursor_complete(job, 0)) { + job->errn= -3; + sprintf(job->errmsg, + "Unary operator or expression expected, -else-operator found"); + return(0); + } + if(job->cursor->up == NULL) + goto improper_range; + job->cursor= job->cursor->up; + Exprnode_get_branch(job->cursor, &true_branch, 0); + Exprnode_get_branch(job->cursor, &false_branch, 1); + if(!Exprnode_is_if(job->cursor, 0) || + true_branch == NULL || false_branch != NULL) { +improper_range:; + job->errn= -5; + sprintf(job->errmsg, "-else-operator found outside its proper range."); + return(0); + } + ret= Findjob_new_node(job, &fnode, "-else", 1 | 2); + if(ret <= 0) + return(ret); + Exprnode_set_branch(job->cursor, fnode, 1); + job->cursor= fnode; + return(1); +} + + +int Findjob_elseif(struct FindjoB *job, int flag) +{ + int ret; + struct ExprnodE *true_branch, *false_branch; + + if(!Findjob_cursor_complete(job, 0)) { + job->errn= -3; + sprintf(job->errmsg, + "Unary operator or expression expected, -elseif-operator found"); + return(0); + } + if(job->cursor->up == NULL) + goto improper_range; + job->cursor= job->cursor->up; + Exprnode_get_branch(job->cursor, &true_branch, 0); + Exprnode_get_branch(job->cursor, &false_branch, 1); + if(!Exprnode_is_if(job->cursor, 0) || + true_branch==NULL || false_branch!=NULL) { +improper_range:; + job->errn= -5; + sprintf(job->errmsg, + "-elseif-operator found outside its proper range."); + return(0); + } + job->cursor= job->cursor->up; + /* -elseif is equivalent to the three-step sequence : -endif -or -if + ( -endif has already been performed by following job->cursor->up ) */ + ret= Findjob_or(job, 0); + if(ret <= 0) + return(0); + ret= Findjob_if(job, 0); + if(ret <= 0) + return(0); + return(1); +} + + +int Findjob_endif(struct FindjoB *job, int flag) +{ + struct ExprnodE *true_branch; + + if(!Findjob_cursor_complete(job,0)) { + job->errn= -3; + sprintf(job->errmsg, + "Unary operator or expression expected, -endif found"); + return(0); + } + if(job->cursor->up==NULL) + goto improper_range; + /* test wether parent node is -if */ + job->cursor= job->cursor->up; + Exprnode_get_branch(job->cursor, &true_branch, 0); + if(!Exprnode_is_if(job->cursor,0) || true_branch == NULL) { +improper_range:; + job->errn= -5; + sprintf(job->errmsg, "-endif-mark found outside its proper range."); + return(0); + } + /* go to grand parent node */ + job->cursor= job->cursor->up; + return(1); +} + + +/* @param flag bit0= -wholename rather than -name +*/ +int Findjob_set_name_expr(struct FindjoB *o, char *name_expr, int flag) +{ + char regexpr[2*SfileadrL+2]; + regex_t *name_re; + struct ExprtesT *t; + int ret; + + if(strlen(name_expr)>=SfileadrL) + return(0); + + ret= Findjob_default_and(o, 0); + if(ret <= 0) + return(ret); + t= o->cursor->test; + t->test_type= (flag & 1 ? 13 : 1); + name_re= (regex_t *) calloc(1, sizeof(regex_t)); + if(name_re == NULL) + return(-1); + t->arg1= strdup(name_expr); + if(t->arg1 == NULL) { + free((char *) name_re); + return(-1); + } + Xorriso__bourne_to_reg(name_expr, regexpr, 0); + if(regcomp(name_re, regexpr, 0) != 0) + return(0); + t->arg2= name_re; + return(1); +} + + +int Findjob_set_file_type(struct FindjoB *o, char file_type, int flag) +{ + static char known[]= {"bcdpf-lsmeX"}; + struct ExprtesT *t; + int ret; + + ret= Findjob_default_and(o, 0); + if(ret <= 0) + return(ret); + + if(file_type != 0) + if(strchr(known, file_type) == NULL) + return(0); + t= o->cursor->test; + t->test_type= 2; + t->arg1= calloc(1, 1); + if(t->arg1 == NULL) + return(-1); + *((char *) t->arg1)= file_type; + return(1); +} + + +/* @param value -1= only without property, 1= only with property + @param flag bit0= pseudo-test: + if no operator is open, do nothing and return 2 +*/ +int Findjob_set_prop_filter(struct FindjoB *o, int test_type, int value, + int flag) +{ + struct ExprtesT *t; + int ret; + + ret= Findjob_default_and(o, flag & 1); + if(ret <= 0 || ret == 2) + return(ret); + + t= o->cursor->test; + t->test_type= test_type; + if(value < 0) + t->invert= !t->invert; + return(1); +} + + +/* @param value -1= only undamaged files, 1= only damaged files +*/ +int Findjob_set_damage_filter(struct FindjoB *o, int value, int flag) +{ + int ret; + + ret= Findjob_set_prop_filter(o, 3, value, 0); + return(ret); +} + + +int Findjob_set_lba_range(struct FindjoB *o, int start_lba, int count, + int flag) +{ + struct ExprtesT *t; + int ret; + + ret= Findjob_default_and(o, 0); + if(ret <= 0) + return(ret); + + t= o->cursor->test; + t->test_type= 4; + t->arg1= calloc(sizeof(int), 1); + t->arg2= calloc(sizeof(int), 1); + if(t->arg1 == NULL || t->arg2 == NULL) + return(-1); + *((int *) t->arg1)= start_lba; + if(start_lba > 0) + *((int *) t->arg2)= start_lba + count - 1; + else + *((int *) t->arg2)= start_lba - count + 1; + return(1); +} + + +/* @param value -1= files without ACL, 1= only files with ACL +*/ +int Findjob_set_acl_filter(struct FindjoB *o, int value, int flag) +{ + int ret; + + ret= Findjob_set_prop_filter(o, 5, value, 0); + return(ret); +} + + +/* @param value -1= files without xattr, 1= only files with xattr + @param flag bit0=-has_any_xattr rather than -has_xattr +*/ +int Findjob_set_xattr_filter(struct FindjoB *o, int value, int flag) +{ + int ret; + + ret= Findjob_set_prop_filter(o, (flag & 1 ? 14 : 6), value, 0); + return(ret); +} + + +/* @param value -1= files without aaip, 1= only files with aaip +*/ +int Findjob_set_aaip_filter(struct FindjoB *o, int value, int flag) +{ + int ret; + + ret= Findjob_set_prop_filter(o, 7, value, 0); + return(ret); +} + + +/* @param value -1= files without filter, 1= files with filter +*/ +int Findjob_set_filter_filter(struct FindjoB *o, int value, int flag) +{ + int ret; + + ret= Findjob_set_prop_filter(o, 8, value, 0); + return(ret); +} + + +int Findjob_set_wanted_node(struct FindjoB *o, void *wanted_node, int flag) +{ + struct ExprtesT *t; + int ret; + + ret= Findjob_default_and(o, 0); + if(ret <= 0) + return(ret); + + t= o->cursor->test; + t->test_type= 9; + t->arg1= wanted_node; + return(1); +} + + +int Findjob_set_commit_filter_2(struct FindjoB *o, int flag) +{ + int ret; + + ret= Findjob_default_and(o, 0); + if(ret <= 0) + return(ret); + + o->cursor->test->test_type= 10; + return(1); +} + + +int Findjob_set_decision(struct FindjoB *o, char *decision, int flag) +{ + struct ExprtesT *t; + int ret; + + ret= Findjob_default_and(o, 0); + if(ret <= 0) + return(ret); + + t= o->cursor->test; + t->test_type= 11; + t->arg1= strdup(decision); + if(t->arg1 == NULL) + return(-1); + return(1); +} + + +/* @param value -1= true, 1= false + @param flag bit0= pseudo-test: + if no operator is open, do nothing and return 2 +*/ +int Findjob_set_false(struct FindjoB *o, int value, int flag) +{ + int ret; + + ret= Findjob_set_prop_filter(o, 0, value, flag & 1); + return(ret); +} + + +int Findjob_set_prune(struct FindjoB *o, int flag) +{ + int ret; + + ret= Findjob_set_prop_filter(o, 12, 0, 0); + return(ret); +} + + +int Findjob_set_found_path(struct FindjoB *o, char *path, int flag) +{ + if(o->found_path != NULL) + free(o->found_path); + if(path != NULL) { + o->found_path= strdup(path); + if(o->found_path == NULL) + return(-1); + } else + o->found_path= NULL; + return(1); +} + + +int Findjob_get_found_path(struct FindjoB *o, char **path, int flag) +{ + *path= o->found_path; + return(1); +} + + +int Findjob_get_action(struct FindjoB *o, int flag) +{ + return(o->action); +} + + +/* @return <0 error, >=0 see above struct FindjoB.action +*/ +int Findjob_get_action_parms(struct FindjoB *o, char **target, char **text_2, + uid_t *user, gid_t *group, + mode_t *mode_and, mode_t *mode_or, + int *type, time_t *date, struct FindjoB **subjob, + int flag) +{ + *target= o->target; + *text_2= o->text_2; + *user= o->user; + *group= o->group; + *mode_and= o->mode_and; + *mode_or= o->mode_or; + *type= o->type; + *date= o->date; + *subjob= o->subjob; + return(o->action); +} + + +int Findjob_test_2(struct XorrisO *xorriso, struct FindjoB *o, + void *node, char *name, char *path, + struct stat *boss_stbuf, struct stat *stbuf, int flag) +{ + int ret; + + ret= Exprnode_tree_value(xorriso, o->test_tree, -1, + node, name, path, boss_stbuf, stbuf, 0); + if(ret == 3) + ret= 1; + else if(ret == 2) + ret= 0; + return(ret); +} + + +int Findjob_set_action_target(struct FindjoB *o, int action, char *target, + int flag) +{ + o->action= action; + o->target= target; + return(1); +} + + +int Findjob_set_action_text_2(struct FindjoB *o, int action, char *target, + char* text_2, int flag) +{ + o->action= action; + o->target= target; + o->text_2= text_2; + return(1); +} + + +/* @param flag bit0= recursive +*/ +int Findjob_set_action_chown(struct FindjoB *o, uid_t user,int flag) +{ + int ret; + + if(flag&1) { + o->action= 0; + Findjob_destroy(&(o->subjob), 0); + ret= Findjob_new(&(o->subjob), "", 0); + if(ret<=0) + return(-1); + Findjob_set_action_chown(o->subjob, user, 0); + o->action= 9; + } else { + o->action= 4; + o->user= user; + } + return(1); +} + + +/* @param flag bit0= recursive +*/ +int Findjob_set_action_chgrp(struct FindjoB *o, gid_t group, int flag) +{ + int ret; + + if(flag&1) { + o->action= 0; + Findjob_destroy(&(o->subjob), 0); + ret= Findjob_new(&(o->subjob), "", 0); + if(ret<=0) + return(-1); + Findjob_set_action_chgrp(o->subjob, group, 0); + o->action= 10; + } else { + o->action= 5; + o->group= group; + } + return(1); +} + + +/* @param flag bit0= recursive +*/ +int Findjob_set_action_chmod(struct FindjoB *o, + mode_t mode_and, mode_t mode_or, int flag) +{ + int ret; + + if(flag&1) { + o->action= 0; + Findjob_destroy(&(o->subjob), 0); + ret= Findjob_new(&(o->subjob), "", 0); + if(ret<=0) + return(-1); + Findjob_set_action_chmod(o->subjob, mode_and, mode_or, 0); + o->action= 11; + } else { + o->action= 6; + o->mode_and= mode_and; + o->mode_or= mode_or; + } + return(1); +} + + +/* @param flag bit0= recursive +*/ +int Findjob_set_action_ad(struct FindjoB *o, int type, time_t date, int flag) +{ + int ret; + + if(flag&1) { + o->action= 0; + Findjob_destroy(&(o->subjob), 0); + ret= Findjob_new(&(o->subjob), "", 0); + if(ret<=0) + return(-1); + Findjob_set_action_ad(o->subjob, type, date, 0); + o->action= 12; + } else { + o->action= 7; + o->type= type; + o->date= date; + } + return(1); +} + + +int Findjob_set_action_subjob(struct FindjoB *o, int action, + struct FindjoB *subjob, int flag) +{ + o->action= action; + Findjob_destroy(&(o->subjob), 0); + o->subjob= subjob; + return(1); +} + + +int Findjob_set_action_found_path(struct FindjoB *o, int flag) +{ + o->action= 23; + Findjob_set_found_path(o, NULL, 0); + return(1); +} + + +/* ---------------------------- SplitparT ------------------------- */ + + +struct SplitparT { + char *name; + int partno; + int total_parts; + off_t offset; + off_t bytes; + off_t total_bytes; +}; + + +int Splitparts_new(struct SplitparT **o, int count, int flag) +{ + int i; + + (*o)= TSOB_FELD(struct SplitparT, count); + if((*o)==NULL) + return(-1); + for(i= 0; i<count; i++) { + (*o)[i].name= NULL; + (*o)[i].partno= 0; + (*o)[i].total_parts= 0; + (*o)[i].offset= 0; + (*o)[i].bytes= 0; + (*o)[i].total_bytes= 0; + } + return(1); +} + + +int Splitparts_destroy(struct SplitparT **o, int count, int flag) +{ + int i; + + if((*o)==NULL) + return(0); + for(i= 0; i<count; i++) { + if((*o)[i].name!=NULL) + free((*o)[i].name); + } + free(*o); + *o= NULL; + return(1); +} + + +int Splitparts_set(struct SplitparT *o, int idx, + char *name, int partno, int total_parts, + off_t offset, off_t bytes, off_t total_bytes, int flag) +{ + if(o[idx].name!=NULL) + free(o[idx].name); + o[idx].name= strdup(name); + if(o[idx].name==NULL) + return(-1); + o[idx].partno= partno; + o[idx].total_parts= total_parts; + o[idx].offset= offset; + o[idx].bytes= bytes; + o[idx].total_bytes= total_bytes; + return(1); +} + + +int Splitparts_get(struct SplitparT *o, int idx, char **name, int *partno, + int *total_parts, off_t *offset, off_t *bytes, + off_t *total_bytes, int flag) +{ + *name= o[idx].name; + *partno= o[idx].partno; + *total_parts= o[idx].total_parts; + *offset= o[idx].offset; + *bytes= o[idx].bytes; + *total_bytes= o[idx].total_bytes; + return(1); +} + + +int Splitpart__read_next_num(char *base_pt, char **next_pt, off_t *num, + int flag) +{ + char *cpt, *ept, scale[4]; + + *num= 0; + for(cpt= base_pt; *cpt!=0 && !isdigit(*cpt); cpt++); + if(*cpt==0) + return(0); + for(ept= cpt; *ept!=0 && isdigit(*ept); ept++) + *num= (*num)*10+(*ept)-'0'; + scale[0]= '1'; + scale[1]= *ept; + scale[2]= 0; + *num *= (off_t) Scanf_io_size(scale, 0); + if(*ept!=0) + ept++; + *next_pt= ept; + return(1); +} + + +int Splitpart__parse(char *name, int *partno, int *total_parts, + off_t *offset, off_t *bytes, off_t *total_bytes, int flag) + +{ + int ret; + off_t num; + char *cpt, *ept; + + cpt= name; + ret= Splitpart__read_next_num(cpt, &ept, &num, 0); + if(ret<=0) + return(ret); + *partno= num; + cpt= ept; + ret= Splitpart__read_next_num(cpt, &ept, &num, 0); + if(ret<=0) + return(ret); + *total_parts= num; + cpt= ept; + ret= Splitpart__read_next_num(cpt, &ept, offset, 0); + if(ret<=0) + return(ret); + cpt= ept; + ret= Splitpart__read_next_num(cpt, &ept, bytes, 0); + if(ret<=0) + return(ret); + cpt= ept; + ret= Splitpart__read_next_num(cpt, &ept, total_bytes, 0); + if(ret<=0) + return(ret); + return(1); +} + + +int Splitpart__compose(char *adr, int partno, int total_parts, + off_t offset, off_t bytes, off_t total_bytes, int flag) +{ + sprintf(adr, "part_%d_of_%d_at_", partno, total_parts); + if((offset % (1024*1024))==0 && offset>0) { + Sfile_off_t_text(adr+strlen(adr), offset / (1024*1024), 0); + strcat(adr, "m"); + } else + Sfile_off_t_text(adr+strlen(adr), offset, 0); + strcat(adr, "_with_"); + if((bytes % (1024*1024))==0) { + Sfile_off_t_text(adr+strlen(adr), bytes / (1024*1024), 0); + strcat(adr, "m"); + } else + Sfile_off_t_text(adr+strlen(adr), bytes, 0); + strcat(adr, "_of_"); + Sfile_off_t_text(adr+strlen(adr), total_bytes, 0); + return(1); +} + + +int Splitparts_cmp(const void *v1, const void *v2) +{ + struct SplitparT *p1, *p2; + + p1= (struct SplitparT *) v1; + p2= (struct SplitparT *) v2; + + if(p1->partno>p2->partno) + return(1); + if(p1->partno<p2->partno) + return(-1); + if(p1->offset>p2->offset) + return(1); + if(p1->offset<p2->offset) + return(-1); + return(0); +} + + +int Splitparts_sort(struct SplitparT *o, int count, int flag) +{ + qsort(o, (size_t) count, sizeof(struct SplitparT), Splitparts_cmp); + return(1); +} + + +/* ---------------------------- End SplitparT ------------------------- */ + +/* ------------------------------ ExclusionS ------------------------------ */ + +struct ExclusionS { + + /* Absolute input patterns which lead to not_paths */ + struct Xorriso_lsT *not_paths_descr; + + /* Actually banned absolute paths */ + struct Xorriso_lsT *not_paths; + + /* Input patterns which lead to not_leafs */ + struct Xorriso_lsT *not_leafs_descr; + + /* Compiled not_leaf patterns. Caution: not char[] but regex_t */ + struct Xorriso_lsT *not_leafs; + +}; + + +int Exclusions_new(struct ExclusionS **o, int flag) +{ + struct ExclusionS *m; + + m= *o= TSOB_FELD(struct ExclusionS, 1); + if(m==NULL) + return(-1); + m->not_paths_descr= NULL; + m->not_paths= NULL; + m->not_leafs_descr= NULL; + m->not_leafs= NULL; + return(1); +} + + +int Exclusions_destroy(struct ExclusionS **o, int flag) +{ + struct Xorriso_lsT *s,*next; + + if((*o)==NULL) + return(0); + Xorriso_lst_destroy_all(&((*o)->not_paths_descr), 0); + Xorriso_lst_destroy_all(&((*o)->not_paths), 0); + Xorriso_lst_destroy_all(&((*o)->not_leafs_descr), 0); + for(s= (*o)->not_leafs; s!=NULL; s= next){ + next= s->next; + regfree((regex_t *) s->text); + Xorriso_lst_destroy(&s, 0); + } + free((char *) *o); + (*o)= NULL; + return(1); +} + + +int Exclusions_add_not_paths(struct ExclusionS *o, int descrc, char **descrs, + int pathc, char **paths, int flag) +{ + struct Xorriso_lsT *s, *new_s; + int i, ret; + + s= NULL; + if(o->not_paths_descr!=NULL) + for(s= o->not_paths_descr; s->next!=NULL; s= s->next); + for(i= 0; i<descrc; i++) { + ret= Xorriso_lst_new(&new_s, descrs[i], s, 0); + if(ret<=0) + return(ret); + if(o->not_paths_descr==NULL) + o->not_paths_descr= new_s; + s= new_s; + } + s= NULL; + if(o->not_paths!=NULL) + for(s= o->not_paths; s->next!=NULL; s= s->next); + for(i= 0; i<pathc; i++) { + ret= Xorriso_lst_new(&new_s, paths[i], s, 0); + if(ret<=0) + return(ret); + if(o->not_paths==NULL) + o->not_paths= new_s; + s= new_s; + } + return(1); +} + + +/* @return -1=cannot store , 0=cannot compile regex , 1=ok +*/ +int Exclusions_add_not_leafs(struct ExclusionS *o, char *not_leafs_descr, + regex_t *re, int flag) +{ + int ret; + + ret= Xorriso_lst_append_binary(&(o->not_leafs_descr), + not_leafs_descr, strlen(not_leafs_descr)+1, 0); + if(ret<=0) + return(-1); + ret= Xorriso_lst_append_binary(&(o->not_leafs), (char *) re, sizeof(regex_t), 0); + if(ret<=0) + return(-1); + return(1); +} + + +/* @param flag bit0= whole subtree is banned with -not_paths + @return 0=no match , 1=not_paths , 2=not_leafs, <0=error +*/ +int Exclusions_match(struct ExclusionS *o, char *abs_path, int flag) +{ + struct Xorriso_lsT *s; + char leaf[SfileadrL], *leaf_pt; + regmatch_t match[1]; + int ret, was_non_slash, l; + + /* test abs_paths */ + if(flag&1) { + for(s= o->not_paths; s!=NULL; s= s->next) { + l= strlen(s->text); + if(strncmp(abs_path, s->text, l)==0) + if(abs_path[l]=='/' || abs_path[l]==0) + return(1); + } + } else { + for(s= o->not_paths; s!=NULL; s= s->next) + if(strcmp(abs_path, s->text)==0) + return(1); + } + + /* determine leafname */ + was_non_slash= 0; + for(leaf_pt= abs_path+strlen(abs_path); leaf_pt>abs_path; leaf_pt--) { + if(*leaf_pt=='/') { + if(was_non_slash) { + leaf_pt++; + break; + } + } else if(*leaf_pt!=0) + was_non_slash= 1; + } + if(strlen(leaf_pt)>=SfileadrL) + return(-1); + strcpy(leaf, leaf_pt); + leaf_pt= strchr(leaf, '/'); + if(leaf_pt!=NULL) + *leaf_pt= 0; + + /* test with leaf expressions */ + for(s= o->not_leafs; s!=NULL; s= s->next) { + ret= regexec((regex_t *) s->text, leaf, 1, match, 0); + if(ret==0) + return(2); + } + return(0); +} + + +int Exclusions_get_descrs(struct ExclusionS *o, + struct Xorriso_lsT **not_paths_descr, + struct Xorriso_lsT **not_leafs_descr, int flag) +{ + *not_paths_descr= o->not_paths_descr; + *not_leafs_descr= o->not_leafs_descr; + return(1); +} + + +/* ---------------------------- End ExclusionS ---------------------------- */ + +/* ------------------------------ PermstacK ------------------------------- */ + + +struct PermiteM { + char *disk_path; + struct stat stbuf; + struct PermiteM *next; +}; + + +int Permstack_push(struct PermiteM **o, char *disk_path, struct stat *stbuf, + int flag) +{ + struct PermiteM *m; + + m= TSOB_FELD(struct PermiteM,1); + if(m==NULL) + return(-1); + m->disk_path= NULL; + memcpy(&(m->stbuf), stbuf, sizeof(struct stat)); + m->next= *o; + + m->disk_path= strdup(disk_path); + if(m->disk_path==NULL) + goto failed; + + *o= m; + return(1); +failed:; + if(m->disk_path!=NULL) + free(m->disk_path); + free((char *) m); + return(-1); +} + + +/* @param flag bit0= minimal transfer: access permissions only + bit1= do not set timestamps +*/ +int Permstack_pop(struct PermiteM **o, struct PermiteM *stopper, + struct XorrisO *xorriso, int flag) +{ + int ret; + char sfe[5*SfileadrL]; + struct utimbuf utime_buffer; + struct PermiteM *m, *m_next; + + if((*o)==stopper) + return(1); + for(m= *o; m!=NULL; m= m->next) + if(m->next==stopper) + break; + if(m==NULL) { + sprintf(xorriso->info_text, + "Program error: Permstack_pop() : cannot find stopper"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(-1); + } + + for(m= *o; m!=stopper; m= m_next) { + ret= chmod(m->disk_path, m->stbuf.st_mode); + if(ret==-1) { + if(xorriso!=NULL) { + sprintf(xorriso->info_text, + "Cannot change access permissions of disk directory: chmod %o %s", + (unsigned int) (m->stbuf.st_mode & 07777), + Text_shellsafe(m->disk_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", + 0); + } + } + if(!(flag&1)) { + chown(m->disk_path, m->stbuf.st_uid, m->stbuf.st_gid); + /* don't complain if it fails */ + if(!(flag&2)) { + utime_buffer.actime= m->stbuf.st_atime; + utime_buffer.modtime= m->stbuf.st_mtime; + ret= utime(m->disk_path,&utime_buffer); + if(ret==-1 && xorriso!=NULL) { + sprintf(xorriso->info_text, + "Cannot change timestamps of disk directory: %s", + Text_shellsafe(m->disk_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", + 0); + } + } + } + m_next= m->next; + free(m->disk_path); + free((char *) m); + *o= m_next; + } + return(1); +} + + +/* ---------------------------- End PermstacK ----------------------------- */ + +/* ------------------------------ SpotlisT -------------------------------- */ + +struct SpotlistiteM { + int start_lba; + int blocks; + int quality; + struct SpotlistiteM *next; +}; + + +int Spotlistitem_new(struct SpotlistiteM **o, int start_lba, int blocks, + int quality, int flag) +{ + struct SpotlistiteM *m; + + m= TSOB_FELD(struct SpotlistiteM,1); + if(m==NULL) + return(-1); + *o= m; + m->start_lba= start_lba; + m->blocks= blocks; + m->quality= quality; + m->next= NULL; + return(1); +} + + +int Spotlistitem_destroy(struct SpotlistiteM **o, int flag) +{ + if((*o) == NULL) + return(0); + free((char *) *o); + *o= NULL; + return(1); +} + + +struct SpotlisT { + struct SpotlistiteM *list_start; + struct SpotlistiteM *list_end; + int list_count; + struct SpotlistiteM *current_item; + int current_idx; +}; + + +int Spotlist_new(struct SpotlisT **o, int flag) +{ + struct SpotlisT *m; + + m= TSOB_FELD(struct SpotlisT,1); + if(m==NULL) + return(-1); + *o= m; + m->list_start= NULL; + m->list_end= NULL; + m->list_count= 0; + m->current_item= NULL; + m->current_idx= -1; + return(1); +} + + +int Spotlist_destroy(struct SpotlisT **o, int flag) +{ + struct SpotlisT *m; + struct SpotlistiteM *li, *next_li; + + if((*o) == NULL) + return(0); + m= *o; + for(li= m->list_start; li != NULL; li= next_li) { + next_li= li->next; + Spotlistitem_destroy(&li, 0); + } + free((char *) *o); + *o= NULL; + return(1); +} + + +int Spotlist_add_item(struct SpotlisT *o, int start_lba, int blocks, + int quality, int flag) +{ + int ret; + struct SpotlistiteM *li; + static int debug_verbous= 0; + + ret= Spotlistitem_new(&li, start_lba, blocks, quality, 0); + if(ret <= 0) + return(ret); + if(o->list_end != NULL) + o->list_end->next= li; + o->list_end= li; + if(o->list_start == NULL) + o->list_start= li; + (o->list_count)++; + + if(debug_verbous) {char quality_name[80]; + fprintf(stderr, "debug: lba %10d , size %10d , quality %s\n", + start_lba, blocks, Spotlist__quality_name(quality, quality_name, 0)); + } + + return(1); +} + + +int Spotlist_count(struct SpotlisT *o, int flag) +{ + return o->list_count; +} + + +int Spotlist_block_count(struct SpotlisT *o, int flag) +{ + int list_blocks= 0; + struct SpotlistiteM *li; + + for(li= o->list_start; li != NULL; li= li->next) { + if(li->start_lba + li->blocks > list_blocks) + list_blocks= li->start_lba + li->blocks; + } + return(list_blocks); +} + + +int Spotlist_sector_size(struct SpotlisT *o, int read_chunk, int flag) +{ + int sector_size; + struct SpotlistiteM *li; + + sector_size= read_chunk * 2048; + for(li= o->list_start; li != NULL; li= li->next) { + if((li->start_lba % read_chunk) || (li->blocks % read_chunk)) { + sector_size= 2048; + break; + } + } + return(sector_size); +} + + +int Spotlist_get_item(struct SpotlisT *o, int idx, + int *start_lba, int *blocks, int *quality, int flag) +{ + int i; + struct SpotlistiteM *li; + + if(idx < 0 || idx > o->list_count) + return(0); + if(idx == o->current_idx && o->current_item != NULL) + li= o->current_item; + else if(idx == o->current_idx + 1 && o->current_item != NULL) { + li= o->current_item->next; + } else { + li= o->list_start; + for(i= 0; i < idx; i++) + li= li->next; + } + o->current_item= li; + o->current_idx= idx; + *start_lba= li->start_lba; + *blocks= li->blocks; + *quality= li->quality; + return(1); +} + + +char *Spotlist__quality_name(int quality, char name[80], int flag) +{ + if(quality == Xorriso_read_quality_gooD) + strcpy(name, "+ good"); + else if(quality == Xorriso_read_quality_md5_matcH) + strcpy(name, "+ md5_match"); + else if(quality == Xorriso_read_quality_sloW) + strcpy(name, "+ slow"); + else if(quality == Xorriso_read_quality_partiaL) + strcpy(name, "+ partial"); + else if(quality == Xorriso_read_quality_valiD) + strcpy(name, "+ valid"); + else if(quality == Xorriso_read_quality_untesteD) + strcpy(name, "0 untested"); + else if(quality == Xorriso_read_quality_invaliD) + strcpy(name, "- invalid"); + else if(quality == Xorriso_read_quality_tao_enD) + strcpy(name, "0 tao end"); + else if(quality == Xorriso_read_quality_off_tracK) + strcpy(name, "0 off track"); + else if(quality == Xorriso_read_quality_md5_mismatcH) + strcpy(name, "- md5_mismatch"); + else if(quality == Xorriso_read_quality_unreadablE) + strcpy(name, "- unreadable"); + else + sprintf(name, "0x%8.8X", (unsigned) quality); + return(name); +} + + +/* ---------------------------- End SpotlisT ------------------------------ */ + +/* ---------------------------- SectorbitmaP ------------------------------ */ + +struct SectorbitmaP { + int sectors; + int sector_size; + unsigned char *map; + int map_size; +}; + + +int Sectorbitmap_new(struct SectorbitmaP **o, int sectors, int sector_size, + int flag) +{ + struct SectorbitmaP *m; + + m= TSOB_FELD(struct SectorbitmaP,1); + if(m==NULL) + return(-1); + *o= m; + m->sectors= sectors; + m->sector_size= sector_size; + m->map= NULL; + m->map_size= sectors / 8 + 1; + + m->map= calloc(m->map_size, 1); + if(m->map == NULL) + goto failure; + return(1); +failure:; + Sectorbitmap_destroy(o, 0); + return(-1); +} + + +int Sectorbitmap_destroy(struct SectorbitmaP **o, int flag) +{ + if((*o) == NULL) + return(0); + if((*o)->map != NULL) + free((char *) (*o)->map); + free((char *) *o); + *o= NULL; + return(1); +} + + +int Sectorbitmap_from_file(struct SectorbitmaP **o, char *path, char *msg, + int *os_errno, int flag) +{ + int ret, fd= -1, sectors, sector_size, i, todo, map_size, skip; + unsigned char *map; + unsigned char buf[1024]; + + *os_errno= 0; + if(msg != NULL) + msg[0]= 0; + fd= open(path, O_RDONLY); + if(fd == -1) { + *os_errno= errno; + if(msg != NULL) { + strcpy(msg, "Cannot open path "); + Text_shellsafe(path, msg+strlen(msg), 0); + } + return(0); + } + ret= read(fd, buf, 32); + if(ret < 32) { +wrong_filetype:; + if(ret == -1) + *os_errno= errno; + if(msg != NULL) { + strcpy(msg, "Not a sector bitmap file: "); + Text_shellsafe(path, msg+strlen(msg), 0); + } + ret= 0; goto ex; + } + if(strncmp((char *) buf, "xorriso sector bitmap v1 ", 32) == 0) + /* ok */; + else if(strncmp((char *) buf, "xorriso sector bitmap v2 ", 25) == 0) { + skip= -1; + sscanf(((char *) buf) + 25, "%d", &skip); + if(skip < 0) + {ret= 0; goto wrong_filetype;} + for(i= 0; i < skip; i+= sizeof(buf)) { + todo= sizeof(buf); + if(i + todo > skip) + todo= skip - i; + ret= read(fd, buf, todo); + if(ret < todo) + goto wrong_filetype; + } + } else + {ret= 0; goto wrong_filetype;} + ret= read(fd, buf, 8); + if(ret < 4) + goto wrong_filetype; + sectors= (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; + sector_size= (buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7]; + if(sectors <= 0 || sector_size <= 0) + goto wrong_filetype; + ret= Sectorbitmap_new(o, sectors, sector_size, 0); + if(ret <= 0) { + if(msg != NULL) + sprintf(msg, "Cannot allocate bitmap memory for %d sectors", sectors); + ret= -1; goto ex; + } + map= (*o)->map; + map_size= (*o)->map_size; + for(i= 0; i < map_size; i+= sizeof(buf)) { + todo= sizeof(buf); + if(i + todo > map_size) + todo= map_size - i; + ret= read(fd, buf, todo); + if(ret != todo) + goto wrong_filetype; + memcpy(map + i, buf, todo); + } + ret= 1; +ex:; + if(fd != -1) + close(fd); + if(ret <= 0) + Sectorbitmap_destroy(o, 0); + return(ret); +} + + +int Sectorbitmap_to_file(struct SectorbitmaP *o, char *path, char *info, + char *msg, int *os_errno, int flag) +{ + int ret, fd= -1, j, l; + unsigned char buf[40]; + + *os_errno= 0; + fd= open(path, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR); + if(fd == -1) { + *os_errno= errno; + if(msg != NULL) { + strcpy(msg, "Cannot open path "); + Text_shellsafe(path, msg+strlen(msg), 0); + } + return(0); + } + + l= 0; + if(info != NULL) + l= strlen(info); + if(l > 999999) { + strcpy(msg, "Info string is longer than 999999 bytes"); + return(0); + } + sprintf((char *) buf, "xorriso sector bitmap v2 %-6d\n", l); + + ret= write(fd, buf, 32); + if(ret != 32) { +cannot_write:; + *os_errno= errno; + if(msg != NULL) { + strcpy(msg, "Cannot write to "); + Text_shellsafe(path, msg+strlen(msg), 0); + } + ret= 0; goto ex; + } + if(l > 0) { + ret= write(fd, info, l); + if(ret != l) + goto cannot_write; + } + + for(j= 0; j < 4; j++) { + buf[j]= o->sectors >> (24 - j * 8); + buf[j+4]= o->sector_size >> (24 - j * 8); + } + ret= write(fd, buf, 8); + if(ret != 8) + goto cannot_write; + ret= write(fd, o->map, o->map_size); + if(ret != o->map_size) + goto cannot_write; + + ret= 1; +ex:; + if(fd != -1) + close(fd); + return(ret); +} + + +/* @param flag bit0= sector bit value +*/ +int Sectorbitmap_set(struct SectorbitmaP *o, int sector, int flag) +{ + if(sector < 0 || sector >= o->sectors) + return(0); + if(flag & 1) + o->map[sector / 8]|= 1 << (sector % 8); + else + o->map[sector / 8]&= ~(1 << (sector % 8)); + return(1); +} + + +/* @param flag bit0= sector bit value +*/ +int Sectorbitmap_set_range(struct SectorbitmaP *o, + int start_sector, int sectors, int flag) +{ + int start_i, end_i, i; + unsigned char value; + + if(start_sector < 0 || start_sector + sectors > o->sectors || sectors < 1) + return(0); + if(flag & 1) + value= ~0; + else + value= 0; + start_i= start_sector / 8; + end_i= (start_sector + sectors - 1) / 8; + for(i= start_sector; i / 8 == start_i && i < start_sector + sectors; i++) + Sectorbitmap_set(o, i, flag & 1); + for(i= start_i + 1; i < end_i; i++) + o->map[i]= value; + if(end_i > start_i) + for(i= end_i * 8; i < start_sector + sectors; i++) + Sectorbitmap_set(o, i, flag & 1); + return(1); +} + + +int Sectorbitmap_is_set(struct SectorbitmaP *o, int sector, int flag) +{ + if(sector < 0 || sector >= o->sectors) + return(0); + return(!! (o->map[sector / 8] & (1 << (sector % 8)))); +} + + +int Sectorbitmap_bytes_are_set(struct SectorbitmaP *o, + off_t start_byte, off_t end_byte, int flag) +{ + int end_sector, i; + + end_sector= end_byte / o->sector_size; + for(i= start_byte / o->sector_size; i <= end_sector; i++) + if(!Sectorbitmap_is_set(o, i, 0)) + return(0); + return(1); +} + + +int Sectorbitmap_get_layout(struct SectorbitmaP *o, + int *sectors, int *sector_size, int flag) +{ + *sectors= o->sectors; + *sector_size= o->sector_size; + return(1); +} + + +int Sectorbitmap_copy(struct SectorbitmaP *from, struct SectorbitmaP *to, + int flag) +{ + int i, run_start, run_value, start_sec, limit_sec, start_aligned; + int end_complete; + + if(((off_t) from->sectors) * ((off_t) from->sector_size) > + ((off_t) to->sectors) * ((off_t) to->sector_size)) + return(-1); + if(from->sector_size == to->sector_size) { + for(i= 0; i < from->map_size; i++) + to->map[i]= from->map[i]; + return(1); + } + run_start= 0; + run_value= Sectorbitmap_is_set(from, 0, 0); + for(i= 1; i <= from->sectors; i++) { + if(i < from->sectors) + if(Sectorbitmap_is_set(from, i, 0) == run_value) + continue; + start_sec= run_start * from->sector_size / to->sector_size; + start_aligned= + (start_sec * to->sector_size == run_start * from->sector_size); + limit_sec= i * from->sector_size / to->sector_size; + end_complete= (limit_sec * to->sector_size == i * from->sector_size); + if(run_value) { + if(!start_aligned) + start_sec++; + } else { + if(!end_complete) + limit_sec++; + } + if(start_sec < limit_sec) + Sectorbitmap_set_range(to, start_sec, limit_sec - 1 - start_sec, + !!run_value); + run_value= !run_value; + run_start= i; + } + return(1); +} + + +int Sectorbitmap_clone(struct SectorbitmaP *from, struct SectorbitmaP **clone, + int flag) +{ + int ret; + + ret= Sectorbitmap_new(clone, from->sectors, from->sector_size, 0); + if(ret <= 0) + return(ret); + ret= Sectorbitmap_copy(from, *clone, 0); + if(ret <= 0) + Sectorbitmap_destroy(clone, 0); + return(ret); +} + + +/* -------------------------- End SectorbitmaP ---------------------------- */ + +/* ---------------------------- CheckmediajoB ----------------------------- */ + +int Checkmediajob_new(struct CheckmediajoB **o, int flag) +{ + struct CheckmediajoB *m; + + m= TSOB_FELD(struct CheckmediajoB,1); + if(m==NULL) + return(-1); + *o= m; + m->use_dev= 0; + m->min_lba= -1; + m->max_lba= -1; + m->min_block_size= 16; + m->mode= 0; + m->start_time= time(NULL); + m->time_limit= 28800; + m->item_limit= 100000; + strcpy(m->abort_file_path, "/var/opt/xorriso/do_abort_check_media"); + m->data_to_path[0]= 0; + m->data_to_fd= -1; + m->data_to_offset= 0; + m->data_to_limit= -1; + m->patch_lba0= 0; + m->patch_lba0_msc1= -1; + m->sector_map_path[0]= 0; + m->sector_map= NULL; + m->map_with_volid= 0; + m->retry= 0; + m->report_mode= 0; + strcpy(m->event_severity, "ALL"); + return(1); +} + + +int Checkmediajob_destroy(struct CheckmediajoB **o, int flag) +{ + if((*o) == NULL) + return(0); + if((*o)->data_to_fd != -1) + close((*o)->data_to_fd); + Sectorbitmap_destroy(&((*o)->sector_map), 0); + free((char *) *o); + *o= NULL; + return(1); +} + + +int Checkmediajob_copy(struct CheckmediajoB *from, struct CheckmediajoB *to, + int flag) +{ + to->use_dev= from->use_dev; + to->min_lba= from->min_lba; + to->max_lba= from->max_lba; + to->min_block_size= from->min_block_size; + to->mode= from->mode; + to->time_limit= from->time_limit; + to->item_limit= from->item_limit; + strcpy(to->abort_file_path, from->abort_file_path); + strcpy(to->data_to_path, from->data_to_path); + /* not copied: data_to_fd */ + to->data_to_offset= from->data_to_offset; + to->data_to_limit= from->data_to_limit; + to->patch_lba0= from->patch_lba0; + to->patch_lba0_msc1= from->patch_lba0_msc1; + strcpy(to->sector_map_path, from->sector_map_path); + /* not copied: sector_map */ + to->map_with_volid= from->map_with_volid; + to->retry= from->retry; + to->report_mode= from->report_mode; + strcpy(to->event_severity, from->event_severity); + return(1); +} + + +/* -------------------------- End CheckmediajoB --------------------------- */ + +/* ------------------------------- Xorriso -------------------------------- */ + + +/** The list of startup file names */ +#define Xorriso_rc_nuM 4 + +static char Xorriso_sys_rc_nameS[Xorriso_rc_nuM][80]= { + "/etc/default/xorriso", + "/etc/opt/xorriso/rc", + "/etc/xorriso/xorriso.conf", + "placeholder for $HOME/.xorrisorc" +}; + + +int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag) +{ + int i, ret; + struct XorrisO *m; + char leafname[SfileadrL]; + + *xorriso= m= TSOB_FELD(struct XorrisO,1); + if(m==NULL) + return(-1); + m->libs_are_started= 0; + strncpy(m->progname,progname,sizeof(m->progname)-1); + m->progname[sizeof(m->progname)-1]= 0; + if(getcwd(m->initial_wdx,sizeof(m->initial_wdx)-1)==NULL) + m->initial_wdx[0]= 0; + m->no_rc= 0; + m->argument_emulation= 0; + + m->rc_filename_count= Xorriso_rc_nuM; + for(i=0;i<m->rc_filename_count-1;i++) + strcpy(m->rc_filenames[i],Xorriso_sys_rc_nameS[i]); + m->rc_filenames[m->rc_filename_count-1][0]= 0; + + m->wdi[0]= 0; + strcpy(m->wdx, m->initial_wdx); + m->did_something_useful= 0; + m->add_plainly= 0; + m->split_size= 0; + strcpy(m->list_delimiter, "--"); + m->ino_behavior= 7; + m->do_joliet= 0; + m->do_aaip= 0; + m->do_md5= 0; + m->relax_compliance= 0; + m->do_follow_pattern= 1; + m->do_follow_param= 0; + m->do_follow_links= 0; + m->follow_link_limit= 100; + m->do_follow_mount= 1; + m->do_global_uid= 0; + m->global_uid= 0; + strcpy(m->volid, "ISOIMAGE"); + m->volid_default= 1; + m->loaded_volid[0]= 0; + m->assert_volid[0]= 0; + m->assert_volid_sev[0]= 0; + m->publisher[0]= 0; + m->application_id[0]= 0; + m->session_logfile[0]= 0; + m->session_lba= -1; + m->session_blocks= 0; + m->do_global_gid= 0; + m->global_gid= 0; + m->do_global_mode= 0; + m->global_dir_mode= 0555; + m->global_file_mode= 0444; + m->filters= NULL; + m->filter_list_closed= 0; + m->zlib_level_default= m->zlib_level= 6; + m->zisofs_block_size= m->zisofs_block_size_default= (1 << 15); + m->zisofs_by_magic= 0; + m->do_overwrite= 2; + m->do_reassure= 0; + m->drive_blacklist= NULL; + m->drive_greylist= NULL; + m->drive_whitelist= NULL; + m->toc_emulation_flag= 0; + m->image_start_mode= 0; + m->image_start_value[0]= 0; + m->do_calm_drive= 1; + m->indev[0]= 0; + m->in_drive_handle= NULL; + m->in_volset_handle= NULL; + m->in_charset= NULL; + m->isofs_st_out= time(0) - 1; + m->isofs_st_in= 0; + m->volset_change_pending= 0; + m->no_volset_present= 0; + m->in_sector_map= NULL; + m->check_media_default= NULL; + m->outdev[0]= 0; + m->out_drive_handle= NULL; + m->out_charset= NULL; + m->dev_fd_1= -1; + m->grow_blindly_msc2= -1; + m->ban_stdio_write= 0; + m->do_dummy= 0; + m->do_close= 0; + m->speed= 0; + m->fs= 4*512; /* 4 MiB */ + m->padding= 300*1024; + m->alignment= 0; + m->do_stream_recording= 0; + m->keep_boot_image= 0; + m->patch_isolinux_image= 0; + m->boot_image_bin_path[0]= 0; + m->boot_image_emul= 0; + m->boot_image_cat_path[0]= 0; + m->boot_image_load_size= 4 * 512; /* hearsay out of libisofs/demo/iso.c */ + m->boot_image_isohybrid= 1; + m->loaded_boot_bin_lba= 0; + m->loaded_boot_cat_path[0]= 0; + m->allow_graft_points= 0; + m->allow_restore= 0; + m->do_concat_split= 1; + m->do_auto_chmod= 0; + m->do_restore_sort_lba= 0; + m->dialog= 0; + m->bsl_interpretation= 0; + m->search_mode= 0; + m->structured_search= 1; + m->do_iso_rr_pattern= 1; + m->do_disk_pattern= 2; + m->temp_mem_limit= 16*1024*1024; + m->file_size_limit= Xorriso_default_file_size_limiT; + m->disk_exclusions= NULL; + m->disk_excl_mode= 1; + m->use_stdin= 0; + m->result_page_length= 0; + m->result_page_width= 80; + m->mark_text[0]= 0; + m->packet_output= 0; + for(i=0; i<4; i++) { + m->logfile[i][0]= 0; + m->logfile_fp[i]= NULL; + } + m->pktlog_fp= NULL; + for(i= 0; i < Xorriso_max_outlist_stacK; i++) { + m->result_msglists[i]= NULL; + m->info_msglists[i]= NULL; + m->msglist_flags[i]= 0; + } + m->msglist_stackfill= 0; + m->status_history_max= Xorriso_status_history_maX; + strcpy(m->report_about_text, "UPDATE"); + Xorriso__text_to_sev(m->report_about_text, &m->report_about_severity, 0); + m->library_msg_direct_print= 0; + strcpy(m->abort_on_text,"FATAL"); + Xorriso__text_to_sev(m->abort_on_text, &m->abort_on_severity, 0); + m->problem_status= 0; + m->problem_status_text[0]= 0; + m->errfile_log[0]= 0; + m->errfile_mode= 0; + m->errfile_fp= NULL; + + m->img_read_error_mode= 2; /* abort faulty image reading with FATAL */ + m->extract_error_mode= 1; /* keep extracted files after read error */ + strcpy(m->return_with_text, "SORRY"); + Xorriso__text_to_sev(m->return_with_text, &m->return_with_severity, 0); + m->return_with_value= 32; + m->eternal_problem_status= 0; + m->eternal_problem_status_text[0]= 0; + m->re= NULL; + /* >>> ??? how to initialize m->match[0] ? */ + m->re_constants= NULL; + m->re_count= 0; + m->re_fill= 0; + m->reg_expr[0]= 0; + m->run_state= 0; + m->is_dialog= 0; + m->bar_is_fresh= 0; + m->pending_option[0]= 0; + m->request_to_abort= 0; + m->request_not_to_ask= 0; + m->idle_time= 0.0; + m->re_failed_at= -1; + m->prepended_wd= 0; + m->insert_count= 0; + m->insert_bytes= 0; + m->error_count= 0; + m->pacifier_style= 0; + m->pacifier_interval= 1.0; + m->pacifier_count= 0; + m->pacifier_total= 0; + m->pacifier_byte_count= 0; + m->pacifier_fifo= NULL; + m->start_time= 0.0; + m->last_update_time= 0.0; + m->find_compare_result= 1; + m->find_check_md5_result= 0; + + m->node_counter= 0; + m->node_array_size= 0; + m->node_array= NULL; + m->node_disk_prefixes= NULL; + m->node_img_prefixes= NULL; + + m->hln_count= 0; + m->hln_array= NULL; + m->hln_targets= NULL; + m->hln_change_pending= 0; + m->di_do_widen= NULL; + m->di_disk_paths= NULL; + m->di_iso_paths= NULL; + + m->node_targets_availmem= 0; + + m->di_count= 0; + m->di_array= NULL; + + m->perm_stack= NULL; + + m->result_line[0]= 0; + m->result_line_counter= 0; + m->result_page_counter= 0; + m->result_open_line_len= 0; + + m->info_text[0]= 0; + + ret= Sfile_leafname(progname, leafname, 0); + if(ret<=0) + goto failure; + if(strcmp(leafname, "osirrox")==0) + m->allow_restore= 1; + else if(strcmp(leafname, "xorrisofs")==0 || strcmp(leafname, "genisofs")==0 || + strcmp(leafname, "mkisofs")==0 || strcmp(leafname, "genisoimage")==0) { + m->argument_emulation= 1; + m->pacifier_style= 1; + Xorriso_protect_stdout(*xorriso, 0); + } else if(strcmp(leafname, "xorrecord")==0 || strcmp(leafname, "wodim")==0 || + strcmp(leafname, "cdrecord")==0 || strcmp(leafname, "cdrskin")==0) { + m->argument_emulation= 2; + m->pacifier_style= 2; + } + ret= Exclusions_new(&(m->disk_exclusions), 0); + if(ret<=0) + goto failure; + Xorriso_relax_compliance(m, "default", 0); + ret= Xorriso_lst_new(&(m->drive_greylist), "/dev", m->drive_greylist, 1); + if(ret <= 0) + goto failure; + + return(1); +failure:; + Xorriso_destroy(xorriso, 0); + return(-1); +} + + +int Xorriso_destroy_re(struct XorrisO *m, int flag) +{ + int i; + + if(m->re!=NULL) { + for(i=0;i<m->re_fill;i++) { + if(m->re_constants!=NULL) + if(m->re_constants[i]!=NULL) + continue; /* ,->re[i] was never subject to regcomp() */ + regfree(&(m->re[i])); + } + free((char *) m->re); + m->re= NULL; + } + + if(m->re_constants!=NULL) { + for(i=0;i<m->re_fill;i++) + if(m->re_constants[i]!=NULL) + free(m->re_constants[i]); + free((char *) m->re_constants); + m->re_constants= NULL; + } + m->re_count= 0; + m->re_fill= 0; + return(1); +} + + +/* @param flag bit0= global shutdown of libraries */ +int Xorriso_destroy(struct XorrisO **xorriso, int flag) +{ + struct XorrisO *m; + + m= *xorriso; + if(m==NULL) + return(0); + if(m->in_charset!=NULL) + free(m->in_charset); + if(m->out_charset!=NULL) + free(m->out_charset); + Xorriso_destroy_re(m,0); + Exclusions_destroy(&(m->disk_exclusions), 0); + Xorriso_destroy_all_extf(m, 0); + Xorriso_lst_destroy_all(&(m->drive_blacklist), 0); + Xorriso_lst_destroy_all(&(m->drive_greylist), 0); + Xorriso_lst_destroy_all(&(m->drive_whitelist), 0); + Xorriso_destroy_node_array(m, 0); + Xorriso_destroy_hln_array(m, 0); + Xorriso_destroy_di_array(m, 0); + + Xorriso_detach_libraries(m, flag&1); + + free((char *) m); + *xorriso= NULL; + return(1); +} + + +int Xorriso_set_change_pending(struct XorrisO *xorriso, int flag) +{ + xorriso->volset_change_pending= 1; + if(!(flag & 2)) + xorriso->hln_change_pending= 1; + return(1); +} + + +int Xorriso_dialog_input(struct XorrisO *xorriso, char line[], int linesize, + int flag) +/* + bit0= do not write to history + bit1= do not read input (but eventually write to history) + bit2= do not write to history line which begin with "-history:" or "-history " +*/ +{ + char *cpt= NULL, **argv= NULL, *linept, *why_append= ""; + int ret, argc= 0, base_length= 0, l, append_line; +#ifdef Xorriso_with_readlinE + static char last_input[SfileadrL]= {""}; +#endif /* ! Xorriso_with_readlinE */ + double tdiff; + struct timeval tv; + struct timezone tz; + + gettimeofday(&tv,&tz); + tdiff= tv.tv_sec+(1.e-6*(double) tv.tv_usec); + + fflush(stdout); + linept= line; + +get_single:; +#ifdef Xorriso_with_readlinE + + if(xorriso->use_stdin || xorriso->dev_fd_1>=0) { + if(flag&2) + {ret= 1; goto ex;} + if(Sfile_fgets_n(linept,linesize - base_length - 1, stdin, + (xorriso->dialog == 2)) == NULL) { + /* need a very dramatic end */ + kill(getpid(),SIGHUP); + {ret= -1; goto ex;} + } + goto process_single; + } + if(flag&2) { + cpt= NULL; + } else { + cpt= readline(""); + if(cpt==NULL) { + /* need a very dramatic end */ + kill(getpid(),SIGHUP); + {ret= -1; goto ex;} + } + l= strlen(cpt); + if(l >= linesize - base_length - 1) { + strncpy(linept, cpt, linesize - 1); + line[sizeof(line)-1]= 0; + sprintf(xorriso->info_text,"Input line too long !"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + goto new_empty; + } else + strcpy(linept, cpt); + } + +process_single:; + +#else /* Xorriso_with_readlinE */ + + if(flag&2) + {ret= 1; goto ex;} + if(Sfile_fgets_n(linept, linesize - base_length - 1, stdin, + (xorriso->dialog == 2)) == NULL) { + /* need a very dramatic end */ + kill(getpid(),SIGHUP); + {ret= -1; goto ex;} + } + +#endif /* ! Xorriso_with_readlinE */ + + if(xorriso->dialog == 2) { + append_line= 0; + if(linept != line && strcmp(linept, "@@@") == 0) { + sprintf(xorriso->info_text, "Incomplete input line cleared by %s", + linept); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE",0); +new_empty:; + line[0]= 0; + linept= line; + sprintf(xorriso->info_text, "-------------------------------------\n"); + Xorriso_info(xorriso,0); + sprintf(xorriso->info_text, "Enter new text for empty input line :\n"); + Xorriso_info(xorriso,0); + goto get_single; + } + l= strlen(line); + ret= Sfile_make_argv("", line, &argc, &argv, 16); + if(ret < 0) + goto ex; + if(ret == 0 && !append_line) { + /* append a newline character */ + if(l >= linesize - 1) { + sprintf(xorriso->info_text,"Input line too long !"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + goto new_empty; + } + line[l]= '\n'; + line[l + 1]= 0; + append_line= 1; + why_append= "Quoted newline char"; + } + if(l > 0 && !append_line) + if(line[l - 1] == '\\') { + line[l - 1]= 0; + append_line= 1; + why_append= "Trailing backslash "; + } + if(append_line) { + base_length= strlen(line); + linept= line + base_length; + sprintf(xorriso->info_text, + "---------------------------------------------------------------\n"); + Xorriso_info(xorriso,0); + sprintf(xorriso->info_text, + "%s : Enter rest of line (or @@@ to clear it) :\n", why_append); + Xorriso_info(xorriso,0); + goto get_single; + } + } + +#ifdef Xorriso_with_readlinE + + if(line[0]!=0 && strcmp(last_input,line)!=0 && !(flag&1)) + if(!((flag&4) && + (strncmp(line,"-history:",9)==0 || strncmp(line,"-history ",9)==0))) { + add_history(line); + strncpy(last_input,line,sizeof(last_input)-1); + last_input[sizeof(last_input)-1]= 0; + } + +#endif /* ! Xorriso_with_readlinE */ + + ret= 1; +ex:; + if(cpt!=NULL) + free(cpt); + gettimeofday(&tv,&tz); + xorriso->idle_time+= tv.tv_sec+(1.e-6*(double) tv.tv_usec)-tdiff; + return(ret); +} + + +int Xorriso_request_confirmation(struct XorrisO *xorriso, int flag) +/* + bit0= important operation going on: + demand confirmation of abort, only abort on @@@ + bit1= mark '@' and '@@' by return 4 + bit2= accept: i|n= ignore | do not remove , r|y= retry | remove , q|x= abort + bit3= @@@ = 'done reading' rather than 'abort' + bit4= in non-dialog mode return 6 rather than 1 +*/ +/* return: <=0 error + 1= go on | do not remove existing file + 2= abort + 3= redo request for confirmation + 4= see flag bit1 + (5= skip volume) + 6= retry failed operation | remove existing file + */ +{ + int ret; + char line[SfileadrL],*cpt,previous_line[SfileadrL]; + char *abort_req_text,*abort_really_text; + + if(!xorriso->dialog) { + if(flag&16) + return(6); + return(1); + } + if(flag&8) { + abort_req_text= "request to end"; + abort_really_text= "done reading"; + } else { + abort_req_text= "request to abort"; + abort_really_text= "abort this command"; + } + ret= Xorriso_dialog_input(xorriso,line,sizeof(line),1); + xorriso->result_line_counter= 0; + xorriso->result_page_counter++; + if(ret<=0) + if(xorriso->result_page_length>0) + xorriso->result_page_length= -xorriso->result_page_length; + + cpt= line; + if(strcmp(cpt,"@@@")==0 || + strcmp(cpt,"x")==0 || strcmp(cpt,"X")==0 || + strcmp(cpt,"q")==0 || strcmp(cpt,"Q")==0) { + if(flag&1) { + strcpy(previous_line,cpt); + sprintf(xorriso->info_text, + "... [%s = %s registered. Really %s ? (y/n) ] ...\n", + cpt,abort_req_text,abort_really_text); + Xorriso_info(xorriso,0); + ret= Xorriso_dialog_input(xorriso,line,sizeof(line),1); + if(ret<=0) + return(ret); + cpt= line; + if(strcmp(cpt,previous_line)==0 || + ((*cpt=='Y' || *cpt=='y' || *cpt=='j' || *cpt=='J' || *cpt=='1') && + *(cpt+1)==0)) { + xorriso->request_to_abort= 1; + sprintf(xorriso->info_text, + "------- ( %s confirmed )\n",abort_req_text); + Xorriso_info(xorriso,0); + return(2); + } + sprintf(xorriso->info_text, "....... ( %s revoked )\n",abort_req_text); + Xorriso_info(xorriso,0); + return(3); + } + xorriso->request_to_abort= 1; + sprintf(xorriso->info_text, +"----------- [%s = request to abort registered. Operation ends ] ------------\n", + cpt); + Xorriso_info(xorriso,0); + return(2); + } else if(*cpt=='@') { + if(strcmp(cpt,"@@")==0) { + goto klammer_affe; + + } else if(strcmp(cpt,"@")==0) { +klammer_affe:; + if(xorriso->result_page_length>0) + xorriso->result_page_length= -xorriso->result_page_length; + if(flag&1) { + sprintf(xorriso->info_text, +"... [@ = prompt suppression registered. Prompting disabled temporarily ] ...\n"); + Xorriso_info(xorriso,0); + } + + } else { + Xorriso_dialog_input(xorriso,cpt,strlen(line)+1,2); /* write to history */ + sprintf(xorriso->info_text, + "--- Unrecognized input beginning with @. Please enter someting else.\n"); + Xorriso_info(xorriso,0); + return(3); + } + if(flag&2) + return(4); + if(flag&1) + return(3); + return(1); + } else if(flag&4) { + + if(strcmp(cpt,"i")==0 || strcmp(cpt,"I")==0 || + strcmp(cpt,"n")==0 || strcmp(cpt,"N")==0 || + *cpt==0) { + return(1); + } else if(strcmp(cpt,"r")==0 || strcmp(cpt,"R")==0 || + strcmp(cpt,"y")==0 || strcmp(cpt,"Y")==0) { + return(6); + } else { + /* >>> unknown input */ + sprintf(xorriso->info_text, + "--- Please enter one of : empty line, i,n, r,y, q,x, @, @@@\n"); + Xorriso_info(xorriso,0); + return(3); + } + + } else if(*cpt!=0 && !(flag&1)) { + Xorriso_dialog_input(xorriso,cpt,strlen(line)+1,2); /* write to history */ + strcpy(xorriso->pending_option,cpt); + xorriso->request_to_abort= 1; + sprintf(xorriso->info_text, +"-------------- [ Input of option registered. Operation ends ] ---------------\n"); + Xorriso_info(xorriso,0); + return(2); + + } else if(*cpt!=0) { + Xorriso_dialog_input(xorriso,cpt,strlen(line)+1,2); /* write to history */ + sprintf(xorriso->info_text, + "--- Please enter one of : empty line, @, @@@\n"); + Xorriso_info(xorriso,0); + return(3); + } + return(1); +} + + +/* @param flag bit0= quoted multiline mode + bit1= release allocated memory and return 1 + bit2= with bit0: warn of empty text arguments + bit3= deliver as single quoted text including all whitespace + and without any backslash interpretation + @return -1=out of memory , 0=line format error , 1=ok, go on , 2=done +*/ +int Xorriso_read_lines(struct XorrisO *xorriso, FILE *fp, int *linecount, + int *argc, char ***argv, int flag) +{ + char line[5 * SfileadrL + 2], *linept, *fgot; + int l, base_length, append_line, ret, mem_linecount, i; + + Sfile_make_argv("", line, argc, argv, 2); + if(flag & 2) + return(1); + + mem_linecount= *linecount; + linept= line; + base_length= 0; + while(1) { + fgot= Sfile_fgets_n(linept, SfileadrL - base_length + 1, fp, + !!(flag & (1 | 8))); + if(fgot == NULL) { + if(ferror(fp)) + return(0); + if(linept != line) { + sprintf(xorriso->info_text,"Open quotation mark at end of input"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(2); + } + l= strlen(line); + (*linecount)++; + append_line= 0; + if(flag & 1) { /* check whether the line is incomplete yet */ + ret= Sfile_make_argv("", line, argc, argv, 16); + if(ret < 0) + return(ret); + if(ret == 0 && !append_line) { + line[l]= '\n'; + line[l + 1]= 0; + append_line= 1; + } + if(l > 0 && !append_line) + if(line[l - 1] == '\\') { + line[l - 1]= 0; + append_line= 1; + } + } + if(l >= SfileadrL) { + sprintf(xorriso->info_text,"Input line too long !"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if(!append_line) + break; + base_length= strlen(line); + linept= line + base_length; + } + if((flag & 1) && !(flag & 8)) { + ret= Sfile_make_argv("", line, argc, argv, + 1 | ((xorriso->bsl_interpretation & 3) << 5)); + if(ret < 0) + return(ret); + if(flag & 4) + for(i= 0; i < *argc; i++) { + if((*argv)[i][0] == 0) { + sprintf(xorriso->info_text, "Empty text as quoted argument in "); + } else if(strlen((*argv)[i]) >= SfileadrL) { + (*argv)[i][SfileadrL - 1]= 0; + sprintf(xorriso->info_text, + "Input text too long and now truncated in"); + } else + continue; + if(mem_linecount + 1 < *linecount) + sprintf(xorriso->info_text + strlen(xorriso->info_text), + "lines %d to %d", mem_linecount + 1, *linecount); + else + sprintf(xorriso->info_text + strlen(xorriso->info_text), + "line %d", mem_linecount + 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + } + } else { + (*argv)= Smem_malloC(sizeof(char *)); + if(argv == NULL) + return(-1); + (*argv)[0]= strdup(line); + if((*argv)[0] == NULL) + return(-1); + *argc= 1; + } + return(1); +} + + +int Xorriso_predict_linecount(struct XorrisO *xorriso, char *line, + int *linecount, int flag) +{ + int width,l; + char *spt,*ept; + + *linecount= 0; + spt= line; + width= xorriso->result_page_width; + while(1) { + ept= strchr(spt,'\n'); + if(ept==NULL) + l= strlen(spt); + else + l= ept-spt; + l+= xorriso->result_open_line_len; + if(ept!=NULL && l==0) + (*linecount)++; + else { + (*linecount)+= l/width; + if(ept==NULL) { + xorriso->result_open_line_len= l%width; + break; + } + (*linecount)+= !!(l%width); + } + xorriso->result_open_line_len= 0; + spt= ept+1; + } + return(1); +} + + +int Xorriso_pager(struct XorrisO *xorriso, char *line, int flag) +/* + bit1= mark '@' by return 4 +*/ +/* return: <=0 error , 1=go on , 2=abort , 4=see flag bit1*/ +{ + int ret,linecount; + char info_text[10*SfileadrL]; + + if(xorriso->result_page_length<=0 || xorriso->request_not_to_ask || + xorriso->dialog == 0) + return(1); + Xorriso_predict_linecount(xorriso,line,&linecount,0); + if(xorriso->result_line_counter+linecount>xorriso->result_page_length) { +ask_for_page:; + strcpy(info_text,xorriso->info_text); + sprintf(xorriso->info_text,"\n"); + Xorriso_info(xorriso,0); + sprintf(xorriso->info_text, +".... [Press Enter to continue. @,Enter avoids further stops. @@@ aborts] ....\n"); + Xorriso_info(xorriso,0); + ret= Xorriso_request_confirmation(xorriso,flag&2); + strcpy(xorriso->info_text,info_text); + if(ret<=0) + return(ret); + if(ret==2) + return(2); + if(ret==3) + goto ask_for_page; + } + xorriso->result_line_counter+= linecount; + return(1); +} + + +int Xorriso_write_to_channel(struct XorrisO *xorriso, + char *in_text, int channel_no, int flag) +/* + bit0= eventually backslash encode linefeeds + bit1= text is the name of the log file for the given channel + bit2= text is the name of the consolidated packet log file for all channels +bit15= with bit1 or bit2: close depicted log file +*/ +{ + char *rpt, *npt, *text; + int ret= 1, info_redirected= 0, result_redirected= 0; + char prefix[16]; + FILE *logfile_fp, *pktlog_fp; + struct Xorriso_lsT *msglist; + static int num_channels= 4; + static char channel_prefixes[4][4]= {".","R","I","M"}; + + if(channel_no<0 || channel_no>=num_channels) + {ret= -1; goto ex;} + + text= in_text; /* might change due to backslash encoding */ + + /* Logfiles */ + logfile_fp= xorriso->logfile_fp[channel_no]; + pktlog_fp= xorriso->pktlog_fp; + if((flag&2) && logfile_fp!=NULL) { + fprintf(logfile_fp, + "! end ! end ! end ! end ! end ! end ! end ! end xorriso log : %s : %s\n", + channel_prefixes[channel_no],Sfile_datestr(time(0),1|2|256)); + fclose(logfile_fp); + xorriso->logfile_fp[channel_no]= logfile_fp= NULL; + } + if((flag&4) && pktlog_fp!=NULL) { + fprintf(pktlog_fp, + "I:1:! end ! end ! end ! end ! end ! end ! end ! end xorriso log : %s : %s\n", + channel_prefixes[channel_no],Sfile_datestr(time(0),1|2|256)); + fclose(pktlog_fp); + xorriso->pktlog_fp= pktlog_fp= NULL; + } + if(flag&(1<<15)) + {ret= 1; goto ex;} + if((flag&2)) { + xorriso->logfile_fp[channel_no]= logfile_fp= fopen(text,"a"); + if(logfile_fp==NULL) + {ret= 0; goto ex;} + fprintf(logfile_fp, + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! xorriso log : %s : %s\n", + channel_prefixes[channel_no],Sfile_datestr(time(0),1|2|256)); + fflush(logfile_fp); + } + if((flag&4)) { + xorriso->pktlog_fp= pktlog_fp= fopen(text,"a"); + if(pktlog_fp==NULL) + {ret= 0; goto ex;} + fprintf(pktlog_fp, + "I:1:!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! xorriso log : . : %s\n", + Sfile_datestr(time(0),1|2|256)); + fflush(pktlog_fp); + } + if(flag&(2|4)) + {ret= 1; goto ex;} + + /* Eventually perform backslash encoding of non-printable characters */ + if(((xorriso->bsl_interpretation & 32) && channel_no == 1) || + ((xorriso->bsl_interpretation & 64) && channel_no == 2)) { + ret= Sfile_bsl_encoder(&text, text, strlen(text), 1 | 2 | 4); + if(ret <= 0) + {ret= -1; goto ex;} + } + + /* Eventually perform messag redirection */ + if(xorriso->msglist_stackfill > 0) { + if(xorriso->msglist_flags[xorriso->msglist_stackfill - 1] & 1) + result_redirected= 1; + if(xorriso->msglist_flags[xorriso->msglist_stackfill - 1] & 2) + info_redirected= 1; + } + if(result_redirected) { + if(channel_no==1 || channel_no==3) { + msglist= xorriso->result_msglists[xorriso->msglist_stackfill - 1]; + ret= Xorriso_lst_append_binary(&msglist, text, strlen(text) + 1, 0); + if(ret <= 0) + {ret= -1; goto ex;} + if(xorriso->result_msglists[xorriso->msglist_stackfill - 1] == NULL) + xorriso->result_msglists[xorriso->msglist_stackfill - 1]= msglist; + } + } + if(info_redirected) { + if(channel_no==2 || channel_no==3) { + msglist= xorriso->info_msglists[xorriso->msglist_stackfill - 1]; + ret= Xorriso_lst_append_binary(&msglist, text, strlen(text) + 1, 0); + if(ret <= 0) + {ret= -1; goto ex;} + if(xorriso->info_msglists[xorriso->msglist_stackfill - 1] == NULL) + xorriso->info_msglists[xorriso->msglist_stackfill - 1]= msglist; + } + } + if((channel_no == 1 && result_redirected) || + (channel_no == 2 && info_redirected) || + (result_redirected && info_redirected)) + {ret= 1; goto ex;} + + /* Non-redirected output */ + if(!xorriso->packet_output) { + if(channel_no==1 || channel_no==3) { + printf("%s",text); + fflush(stdout); + } + if(channel_no==2 || channel_no==3) + fprintf(stderr,"%s",text); + if(logfile_fp!=NULL) { + fprintf(logfile_fp,"%s",text); + fflush(logfile_fp); + } + if(pktlog_fp==NULL) + {ret= 1; goto ex;} + } + rpt= text; + sprintf(prefix,"%s:x: ",channel_prefixes[channel_no]); + while(*rpt!=0) { + npt= strchr(rpt,'\n'); + if(npt==NULL) + prefix[2]= '0'; + else + prefix[2]= '1'; + if(xorriso->packet_output) { + ret= fwrite(prefix,5,1,stdout); + if(ret<=0) + {ret= 0; goto ex;} + } + if(pktlog_fp!=NULL) { + ret= fwrite(prefix,5,1,pktlog_fp); + if(ret<=0) + {ret= 0; goto ex;} + } + if(npt==NULL) { + if(xorriso->packet_output) { + ret= fwrite(rpt,strlen(rpt),1,stdout); + if(ret<=0) + {ret= 0; goto ex;} + ret= fwrite("\n",1,1,stdout); + if(ret<=0) + {ret= 0; goto ex;} + } + if(pktlog_fp!=NULL) { + ret= fwrite(rpt,strlen(rpt),1,pktlog_fp); + if(ret<=0) + {ret= 0; goto ex;} + ret= fwrite("\n",1,1,pktlog_fp); + if(ret<=0) + {ret= 0; goto ex;} + } + break; + } else { + if(xorriso->packet_output) { + ret= fwrite(rpt,npt+1-rpt,1,stdout); + if(ret<=0) + {ret= 0; goto ex;} + } + if(pktlog_fp!=NULL) { + ret= fwrite(rpt,npt+1-rpt,1,pktlog_fp); + if(ret<=0) + {ret= 0; goto ex;} + } + } + rpt= npt+1; + } + if(xorriso->packet_output) + fflush(stdout); + if(pktlog_fp!=NULL) + fflush(pktlog_fp); + ret= 1; +ex: + if(text != in_text && text != NULL) + free(text); + return(ret); +} + + +int Xorriso_push_outlists(struct XorrisO *xorriso, int *stack_handle, + int flag) +{ + if(xorriso->msglist_stackfill + 1 >= Xorriso_max_outlist_stacK) { + Xorriso_msgs_submit(xorriso, 0, + "Overflow of message output redirection stack", 0, "FATAL", 0); + return(-1); + } + if((flag & 3) == 0) + flag|= 3; + xorriso->msglist_stackfill++; + xorriso->result_msglists[xorriso->msglist_stackfill - 1]= NULL; + xorriso->info_msglists[xorriso->msglist_stackfill - 1]= NULL; + xorriso->msglist_flags[xorriso->msglist_stackfill - 1]= flag & 3; + *stack_handle= xorriso->msglist_stackfill - 1; + return(1); +} + + +int Xorriso_pull_outlists(struct XorrisO *xorriso, int stack_handle, + struct Xorriso_lsT **result_list, + struct Xorriso_lsT **info_list, int flag) +{ + int i; + + if(stack_handle < 0 || stack_handle >= xorriso->msglist_stackfill) { + Xorriso_msgs_submit(xorriso, 0, + "Program error: Wrong message output redirection stack handle", + 0, "FATAL", 0); + return(-1); + } + *result_list= xorriso->result_msglists[stack_handle]; + *info_list= xorriso->info_msglists[stack_handle]; + for(i = stack_handle + 1; i < xorriso->msglist_stackfill - 1; i++) { + xorriso->result_msglists[i - 1]= xorriso->result_msglists[i]; + xorriso->info_msglists[i - 1]= xorriso->info_msglists[i]; + } + xorriso->msglist_stackfill--; + return(1); +} + + +int Xorriso_result(struct XorrisO *xorriso, int flag) +/* + bit0= no considerations or computations or dialog. Just put out. +*/ +{ + int ret, redirected= 0; + + if(flag&1) + goto put_it_out; + if(xorriso->request_to_abort) + return(1); + if(xorriso->msglist_stackfill > 0) + if(xorriso->msglist_flags[xorriso->msglist_stackfill - 1] & 1) + redirected= 1; + if(xorriso->result_page_length>0 && !redirected) { + ret= Xorriso_pager(xorriso,xorriso->result_line,2); + if(ret<=0) + return(ret); + if(ret==2) + return(1); + if(xorriso->request_to_abort) + return(1); + } +put_it_out:; + xorriso->bar_is_fresh= 0; + ret= Xorriso_write_to_channel(xorriso, xorriso->result_line, 1,0); + return(ret); +} + + +int Xorriso_info(struct XorrisO *xorriso, int flag) +/* + bit0= use pager (as with result) + bit1= permission to suppress output + bit2= insist in showing output +*/ +{ + int ret; + static int note_sev= 0; + + if(flag&2) + if(xorriso->request_to_abort) + return(1); + + if(note_sev==0) + Xorriso__text_to_sev("NOTE", ¬e_sev, 0); + if(note_sev<xorriso->report_about_severity && + note_sev<xorriso->abort_on_severity && !(flag&4)) + return(1); + + if(flag&1) { + ret= Xorriso_pager(xorriso,xorriso->info_text,2); + if(ret<=0) + return(ret); + if(ret==2) + return(1); + if(flag&2) + if(xorriso->request_to_abort) + return(1); + } + xorriso->bar_is_fresh= 0; + ret=Xorriso_write_to_channel(xorriso, xorriso->info_text, 2, 0); + return(ret); +} + + +int Xorriso_mark(struct XorrisO *xorriso, int flag) +{ + int ret= 1,r_ret,i_ret; + + if(xorriso->mark_text[0]==0) + return(1); + if(xorriso->packet_output) + ret=Xorriso_write_to_channel(xorriso, xorriso->mark_text, 3, 0); + else { + sprintf(xorriso->result_line,"%s\n",xorriso->mark_text); + r_ret= Xorriso_result(xorriso,1); + strcpy(xorriso->info_text,xorriso->result_line); + i_ret= Xorriso_info(xorriso,0); + if(r_ret==0 || i_ret==0) + ret= 0; + } + return(ret); +} + + +int Xorriso_restxt(struct XorrisO *xorriso, char *text) +{ + int ret; + + strncpy(xorriso->result_line,text,sizeof(xorriso->result_line)-1); + xorriso->result_line[sizeof(xorriso->result_line)-1]= 0; + ret= Xorriso_result(xorriso,0); + return(ret); +} + + +int Xorriso_pacifier_reset(struct XorrisO *xorriso, int flag) +{ + xorriso->start_time= Sfile_microtime(0); + xorriso->last_update_time= xorriso->start_time; + xorriso->pacifier_count= 0; + xorriso->pacifier_total= 0; + xorriso->pacifier_byte_count= 0; + return(1); +} + + +/* This call is to be issued by long running workers in short intervals. + It will check whether enough time has elapsed since the last pacifier + message and eventually issue an update message. + @param what_done A sparse description of the action, preferrably in past + tense. E.g. "done" , "files added". + @param count The number of objects processed so far. + Is ignored if <=0. + @param todo The number of objects to be done in total. + Is ignored if <=0. + @param current_object A string telling the object currently processed. + Ignored if "". + @param flag bit0= report unconditionally, no time check + bit1= report count <=0 (no thank you for being patient then) + bit2= report xorriso->pacifier_byte_count + bit6= report with carriage return rather than line feed +*/ +int Xorriso_pacifier_callback(struct XorrisO *xorriso, char *what_done, + off_t count, off_t todo, char *current_object, + int flag) +{ + double current_time, since; + char count_text[80], byte_text[80]; + + current_time= Sfile_microtime(0); + if(current_time - xorriso->last_update_time < xorriso->pacifier_interval + && !(flag&1)) + return(1); + xorriso->last_update_time= Sfile_microtime(0); + since= current_time - xorriso->start_time; + if((flag&1)&&since<1.0) + since= 1.0; + byte_text[0]= 0; + if(flag&4) { + strcat(byte_text, " ("); + Sfile_scale((double) xorriso->pacifier_byte_count, + byte_text+strlen(byte_text), 7, 1e5, 0); + strcat(byte_text, ")"); + } + if(count<=0.0 && !(flag&2)) { + sprintf(xorriso->info_text, + "Thank you for being patient for %.f seconds", since); + } else if(todo<=0.0) { + if(count<10000000) + sprintf(count_text, "%.f", (double) count); + else + Sfile_scale((double) count, count_text, 7, 1e5, 1); + sprintf(xorriso->info_text, "%s %s%s in %.f %s", + count_text, what_done, byte_text, since, (flag&64) ? "s" : "seconds"); + } else { + sprintf(xorriso->info_text, "%.f of %.f %s%s in %.f seconds", + (double) count, (double) todo, what_done, byte_text, since); + } + if(current_object[0]!=0) + sprintf(xorriso->info_text+strlen(xorriso->info_text), + ", now at %s", current_object); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", (flag&64)); + return(1); +} + + +int Xorriso_reset_counters(struct XorrisO *xorriso, int flag) +{ + xorriso->error_count= 0; + xorriso->insert_count= 0; + xorriso->insert_bytes= 0; + Xorriso_pacifier_reset(xorriso, 0); + return(1); +} + + +int Xorriso__bourne_to_reg(char bourne_expr[], char reg_expr[], int flag) +/* reg_expr should be twice as large as bourne_expr ( + 2 to be exact) */ +/* return: 2= bourne_expr is surely a constant */ +{ + char *wpt,*lpt; + int backslash= 0,is_constant= 1,in_square_brackets= 0; + int first_in_square_brackets=0; + + wpt= reg_expr; + lpt= bourne_expr; + + *(wpt++)= '^'; + + while(*lpt!=0){ + if(first_in_square_brackets>0) + first_in_square_brackets--; + if(!backslash){ + switch(*lpt){ + case '?': + *(wpt++)= '.'; + is_constant= 0; + break;case '*': + *(wpt++)= '.'; + *(wpt++)= '*'; + is_constant= 0; + break;case '.': + *(wpt++)= '\\'; + *(wpt++)= '.'; + break;case '+': + *(wpt++)= '\\'; + *(wpt++)= '+'; + break;case '[': + *(wpt++)= *lpt; + first_in_square_brackets= 2; + in_square_brackets= 1; + is_constant= 0; + break;case ']': + *(wpt++)= *lpt; + in_square_brackets= 0; + break;case '!': + if(first_in_square_brackets) + *(wpt++)= '^'; + else if(in_square_brackets) + *(wpt++)= '!'; + else { + *(wpt++)= '\\'; + *(wpt++)= '!'; + } + break;case '^': + if(in_square_brackets) + *(wpt++)= '^'; + else + *(wpt++)= '\\'; + *(wpt++)= '^'; + break;case '$': + *(wpt++)= '\\'; + *(wpt++)= '$'; + break;case '\\': + backslash= 1; + *(wpt++)= '\\'; + is_constant= 0; + break;default: + *(wpt++)= *lpt; + } + } else { + backslash= 0; + *(wpt++)= *lpt; + } + lpt++; + } + *(wpt++)= '$'; + *wpt= 0; + return(1+(is_constant>0)); +} + + +/* @param flag bit0= do not augment relative structured search by xorriso->wdi + bit1= return 2 if bonked at start point by .. + (caller then aborts or retries without bit0) + bit2= eventually prepend wdx rather than wdi + @return <=0 error, 1= ok, 2= with bit1: relative pattern exceeds start point +*/ +int Xorriso_prepare_regex(struct XorrisO *xorriso, char *adr, int flag) +{ + int l,ret,i,count,bonked= 0,is_constant,is_still_relative= 0; + char *cpt,*npt,adr_part[2*SfileadrL],absolute_adr[2*SfileadrL],*adr_start,*wd; + + if(flag&4) + wd= xorriso->wdx; + else + wd= xorriso->wdi; + + if(xorriso->search_mode>=2 && xorriso->search_mode<=4) { + if(xorriso->search_mode==3 || xorriso->search_mode==4) { + l= strlen(adr)+strlen(wd)+1; + if(l*2+2>sizeof(xorriso->reg_expr) || l*2+2>sizeof(adr_part)) { + sprintf(xorriso->info_text,"Search pattern too long"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + } + Xorriso_destroy_re(xorriso,0); + if(xorriso->structured_search && xorriso->search_mode==3) { + if(adr[0]!='/') + is_still_relative= 1; + if(is_still_relative && !(flag&1)) { + /* relative expression : prepend working directory */ + sprintf(absolute_adr,"%s/%s",wd,adr); + adr_start= absolute_adr; + xorriso->prepended_wd= 1; + is_still_relative= 0; + } else + adr_start= adr; + /* count slashes */; + cpt= adr_start; + while(*cpt=='/') + cpt++; + for(i= 0;1;i++) { + cpt= strchr(cpt,'/'); + if(cpt==NULL) + break; + while(*cpt=='/') + cpt++; + } + count= i+1; + xorriso->re= TSOB_FELD(regex_t,count); + if(xorriso->re==NULL) + return(-1); + xorriso->re_constants= TSOB_FELD(char *,count); + if(xorriso->re_constants==NULL) + return(-1); + for(i= 0;i<count;i++) + xorriso->re_constants[i]= NULL; + xorriso->re_count= count; + xorriso->re_fill= 0; + + /* loop over slash chunks*/; + cpt= adr_start; + xorriso->re_fill= 0; + while(*cpt=='/') + cpt++; + for(i= 0;i<count;i++) { + npt= strchr(cpt,'/'); + if(npt==NULL) { + if(strlen(cpt)>=sizeof(adr_part)) + return(-1); + strcpy(adr_part,cpt); + } else { + if(npt-cpt>=sizeof(adr_part)) + return(-1); + strncpy(adr_part,cpt,npt-cpt); + adr_part[npt-cpt]= 0; + } + + if(adr_part[0]==0) + goto next_adr_part; + if(adr_part[0]=='.' && adr_part[1]==0 && + (xorriso->re_fill>0 || i<count-1)) + goto next_adr_part; + if(adr_part[0]=='.' && adr_part[1]=='.' && adr_part[2]==0) { + /* delete previous part */ + if(xorriso->re_fill <= 0) { + bonked= 1; + goto next_adr_part; + } + if(xorriso->re_constants[xorriso->re_fill-1]!=NULL) { + free(xorriso->re_constants[xorriso->re_fill-1]); + xorriso->re_constants[xorriso->re_fill-1]= NULL; + } else + regfree(&(xorriso->re[xorriso->re_fill-1])); + (xorriso->re_fill)--; + goto next_adr_part; + } + if(strcmp(adr_part,"*")==0) { + adr_part[0]= 0; + ret= 2; + } else + ret= Xorriso__bourne_to_reg(adr_part,xorriso->reg_expr,0); + if(ret==2) { + if(Sregex_string(&(xorriso->re_constants[xorriso->re_fill]),adr_part,0) + <=0) + return(-1); + } else { + if(regcomp(&(xorriso->re[xorriso->re_fill]),xorriso->reg_expr,0)!=0) + goto cannot_compile; + } + xorriso->re_fill++; +next_adr_part:; + if(i==count-1) + break; + cpt= npt+1; + while(*cpt=='/') + cpt++; + } + if(bonked) { + if(flag&2) + return(2); + sprintf(xorriso->info_text, "Your '..' bonked at the %s directory.", + is_still_relative ? "working" : "root"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE",0); + return(0); + } + + Xorriso__bourne_to_reg(adr_start,xorriso->reg_expr,0); /* just for show */ + + } else { + is_constant= 0; + if(strcmp(adr,"*")==0 || adr[0]==0) { + is_constant= 1; + } else if(xorriso->search_mode==3 || xorriso->search_mode==4) { + ret= Xorriso__bourne_to_reg(adr,xorriso->reg_expr,0); + is_constant= (ret==2); + } else { + if(strlen(adr)>=sizeof(xorriso->reg_expr)) + return(-1); + strcpy(xorriso->reg_expr,adr); + } + xorriso->re_count= 0; /* tells matcher that this is not structured */ + xorriso->re_constants= TSOB_FELD(char *,1); + if(xorriso->re_constants==NULL) + return(-1); + xorriso->re_constants[0]= NULL; + if(is_constant) { + if(strcmp(adr,"*")==0) { + if(Sregex_string(&(xorriso->re_constants[0]),"",0)<=0) + return(-1); + } else { + if(Sregex_string(&(xorriso->re_constants[0]),adr,0)<=0) + return(-1); + } + xorriso->re_fill= 1; + } else { + xorriso->re= TSOB_FELD(regex_t,1); + if(xorriso->re==NULL) + return(-1); + if(regcomp(&(xorriso->re[0]),xorriso->reg_expr,0)!=0) { +cannot_compile:; + sprintf(xorriso->info_text, "Cannot compile regular expression : %s", + xorriso->reg_expr); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE",0); + return(0); + } + } + + } + } + return(1); +} + + +/* @param flag bit0= do not shortcut last component of to_match + bit1= consider match if regex matches parent of path + bit2= retry beginning at failed last component + + @return 0=match , else no match +*/ +int Xorriso_regexec(struct XorrisO *xorriso, char *to_match, int *failed_at, + int flag) +{ + int ret,i,re_start= 0,reg_nomatch= -1; + char *cpt,*npt,adr_part[SfileadrL],*mpt; + + reg_nomatch= REG_NOMATCH; + + *failed_at= 0; + if(!(xorriso->structured_search && xorriso->re_count>0)) { + if(xorriso->re_constants!=NULL) + if(xorriso->re_constants[0]!=NULL) { + if(xorriso->re_constants[0][0]==0) + return(0); + if(strcmp(xorriso->re_constants[0],to_match)!=0) + return(reg_nomatch); + return(0); + } + ret= regexec(&(xorriso->re[0]),to_match,1,xorriso->match,0); + return(ret); + } + + cpt= to_match; + while(*cpt=='/') + cpt++; + if(flag&4) + re_start= xorriso->re_failed_at; + if(re_start<0) + re_start= 0; + for(i= re_start;i<xorriso->re_fill;i++) { + *failed_at= i; + npt= strchr(cpt,'/'); + if(npt==NULL) { + if(i<xorriso->re_fill-1 && !(flag&1)) + return(reg_nomatch); /* this must be the last expression part */ + mpt= cpt; + } else { + strncpy(adr_part,cpt,npt-cpt); + adr_part[npt-cpt]= 0; + mpt= adr_part; + } + if(xorriso->re_constants[i]!=NULL) { + if(xorriso->re_constants[i][0]!=0) /* empty constant matches anything */ + if(strcmp(xorriso->re_constants[i],mpt)!=0) + return(reg_nomatch); + } else { + ret= regexec(&(xorriso->re[i]),mpt,1,xorriso->match,0); + if(ret!=0) + return(ret); + } + if(npt==NULL) { + if(i>=xorriso->re_fill-1) + return(0); /* MATCH */ + *failed_at= i+1; + return(reg_nomatch); + } + cpt= npt+1; + while(*cpt=='/') + cpt++; + } + *failed_at= xorriso->re_fill; + if(flag & 2) + return(0); /* MATCH */ + return(reg_nomatch); +} + + +int Xorriso_is_in_patternlist(struct XorrisO *xorriso, + struct Xorriso_lsT *patternlist, char *path, + int flag) +{ + int ret, failed_at, i= 0; + struct Xorriso_lsT *s; + + xorriso->search_mode= 3; + xorriso->structured_search= 1; + + for(s= patternlist; s != NULL; s= Xorriso_lst_get_next(s, 0)) { + ret= Xorriso_prepare_regex(xorriso, Xorriso_lst_get_text(s, 0), 0); + if(ret <= 0) + return(-1); + /* Match path or parent of path */ + ret= Xorriso_regexec(xorriso, path, &failed_at, 2); + if(ret == 0) + return(i + 1); + i++; + } + return(0); +} + + +char *Xorriso_get_pattern(struct XorrisO *xorriso, + struct Xorriso_lsT *patternlist, int index, int flag) +{ + int i= 0; + struct Xorriso_lsT *s; + + for(s= patternlist; s != NULL; s= Xorriso_lst_get_next(s, 0)) { + if(i == index) + return(Xorriso_lst_get_text(s, 0)); + i++; + } + return(NULL); +} + + +/* @param flag bit0= simple readlink(): no normalization, no multi-hop +*/ +int Xorriso_resolve_link(struct XorrisO *xorriso, + char *link_path, char result_path[SfileadrL], int flag) +{ + ssize_t l; + struct stat stbuf; + int link_count= 0, ret, show_errno= 0; + char buf[SfileadrL], dirbuf[SfileadrL], *lpt, *spt, sfe[5*SfileadrL]; + static int link_limit= 100; + + if(!(flag&1)) + if(stat(link_path, &stbuf)==-1) + if(errno==ELOOP) { + show_errno= errno; + goto too_many_hops; + } + lpt= link_path; + while(1) { + l= readlink(lpt, buf, SfileadrL-1); + if(l==-1) { +handle_error:; + Xorriso_msgs_submit(xorriso, 0, link_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, "Cannot obtain link target of : %s", + Text_shellsafe(link_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0); +handle_abort:; + if(strcmp(lpt, link_path)!=0) { + sprintf(xorriso->info_text, + "Problem occured with intermediate path : %s", + Text_shellsafe(lpt, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE",0); + } + return(0); + } + buf[l]= 0; + if(l==0) { + Xorriso_msgs_submit(xorriso, 0, link_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, "Empty link target with : %s", + Text_shellsafe(link_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0); + goto handle_abort; + } + + if(flag&1) { + strcpy(result_path, buf); + return(1); + } + + /* normalize relative to disk_path */ + if(Sfile_str(dirbuf, lpt, 0)<=0) + return(-1); + while(1) { + spt= strrchr(dirbuf,'/'); + if(spt!=NULL) { + *spt= 0; + if(*(spt+1)!=0) + break; + } else + break; + } + ret= Xorriso_normalize_img_path(xorriso, dirbuf, buf, result_path, 2|4); + if(ret<=0) + return(ret); + + if(lstat(result_path, &stbuf)==-1) { + lpt= result_path; + goto handle_error; + } + if(!S_ISLNK(stbuf.st_mode)) + break; + + lpt= result_path; + link_count++; + if(link_count>link_limit) { +too_many_hops:; + Xorriso_msgs_submit(xorriso, 0, link_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, "Too many link hops with : %s", + Text_shellsafe(link_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, show_errno, + "FAILURE",0); + return(0); + } + } + return(1); +} + + +int Xorriso_status_filter(struct XorrisO *xorriso, char *filter, char *line, + int flag) +{ + if(filter!=NULL) + if(filter[0]=='-') + if(strncmp(filter, line, strlen(filter))!=0) + return(0); + return(1); +} + + +int Xorriso_status_result(struct XorrisO *xorriso, char *filter, FILE *fp, + int flag) +/* +bit1= do only report to fp +*/ +{ + int ret; + + ret= Xorriso_status_filter(xorriso, filter, xorriso->result_line, 0); + if(ret <= 0) + return(2); + if(!(flag&2)) + Xorriso_result(xorriso,0); + if(fp!=NULL) { + ret= fwrite(xorriso->result_line,strlen(xorriso->result_line),1,fp); + if(ret<=0) + return(ret); + } + return(1); +} + + +int Xorriso_check_media_setup_job(struct XorrisO *xorriso, + struct CheckmediajoB *job, + char **argv, int old_idx, int end_idx, int flag) +{ + int ret, i, sev; + double num; + struct CheckmediajoB *default_job; + char sev_text[20]; + + if(xorriso->check_media_default != NULL) + Checkmediajob_copy(xorriso->check_media_default, job, 0); + for(i= old_idx; i < end_idx; i++) { + if(strncmp(argv[i], "abort_file=", 11) == 0) { + ret= Sfile_str(job->abort_file_path, argv[i] + 11, 0); + if(ret <= 0) + goto ex; + } else if(strncmp(argv[i], "data_to=", 8) == 0) { + ret= Sfile_str(job->data_to_path, argv[i] + 8, 0); + if(ret <= 0) + goto ex; + } else if(strncmp(argv[i], "event=", 6) == 0) { + strncpy(sev_text, argv[i] + 6, 19); + sev_text[19]= 0; + ret= Xorriso__text_to_sev(sev_text, &sev, 0); + if(ret <= 0) { + strcpy(xorriso->info_text, "-check_media event="); + Text_shellsafe(sev_text, xorriso->info_text, 1); + strcat(xorriso->info_text, " : Not a known severity name"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + goto ex; + } + strcpy(job->event_severity, sev_text); + } else if(strncmp(argv[i], "map_with_volid=", 15) == 0) { + if(strcmp(argv[i] + 15, "on") == 0) + job->map_with_volid= 1; + else if(strcmp(argv[i] + 15, "off") == 0) + job->map_with_volid= 0; + else + goto unknown_value; + } else if(strncmp(argv[i], "max_lba=", 8) == 0 || + strncmp(argv[i], "min_lba=", 8) == 0) { + num= -1; + sscanf(argv[i] + 8, "%lf", &num); + if(num > 0x7fffffff || num < 0) + num= -1; + if(strncmp(argv[i], "max_lba=", 8) == 0) + job->max_lba= num; + else + job->min_lba= num; + } else if(strncmp(argv[i], "patch_lba0=", 11) == 0) { + job->patch_lba0_msc1= -1; + if(strcmp(argv[i] + 11, "on") == 0) + job->patch_lba0= 1; + else if(strcmp(argv[i] + 11, "off") == 0) + job->patch_lba0= 0; + else if(strcmp(argv[i] + 11, "force") == 0) + job->patch_lba0= 2; + else if(argv[i][11] >= '1' && argv[i][11] <= '9') { + num= -1; + sscanf(argv[i] + 11, "%lf", &num); + if(num > 0x7fffffff || num < 0) + goto unknown_value; + job->patch_lba0_msc1= num; + job->patch_lba0= (num >= 32) + (strstr(argv[i] + 11, ":force") != NULL); + } else + goto unknown_value; + } else if(strncmp(argv[i], "report=", 7) == 0) { + if(strcmp(argv[i] + 7, "blocks") == 0) + job->report_mode= 0; + else if(strcmp(argv[i] + 7, "files") == 0) + job->report_mode= 1; + else if(strcmp(argv[i] + 7, "blocks_files") == 0) + job->report_mode= 2; + else + goto unknown_value; + } else if(strcmp(argv[i], "reset=now") == 0) { + ret= Checkmediajob_new(&default_job, 0); + if(ret <= 0) { + sprintf(xorriso->info_text, + "-check_media: Cannot reset options due to lack of resources"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + ret= -1; goto ex; + } + Checkmediajob_copy(default_job, job, 0); + Checkmediajob_destroy(&default_job, 0); + } else if(strncmp(argv[i], "retry=", 6) == 0) { + if(strcmp(argv[i] + 6, "on") == 0) + job->retry= 1; + else if(strcmp(argv[i] + 6, "off") == 0) + job->retry= -1; + else if(strcmp(argv[i] + 6, "default") == 0) + job->retry= 0; + else + goto unknown_value; + } else if(strncmp(argv[i], "sector_map=", 11) == 0) { + ret= Sfile_str(job->sector_map_path, argv[i] + 11, 0); + if(ret <= 0) + goto ex; + } else if(strncmp(argv[i], "time_limit=", 11) == 0 || + strncmp(argv[i], "item_limit=", 11) == 0 ) { + num= -1; + sscanf(argv[i] + 11, "%lf", &num); + if(num > 0x7fffffff || num < 0) + num= -1; + if(strncmp(argv[i], "time_limit=", 11) == 0) + job->time_limit= num; + else + job->item_limit= num; + } else if(strncmp(argv[i], "use=", 4) == 0) { + if(strcmp(argv[i] + 4, "outdev") == 0) + job->use_dev= 1; + else if(strcmp(argv[i] + 4, "indev") == 0) + job->use_dev= 0; + else if(strcmp(argv[i] + 4, "sector_map") == 0) + job->use_dev= 2; + else + goto unknown_value; + } else if(strncmp(argv[i], "what=", 5) == 0) { + if(strcmp(argv[i]+5, "tracks") == 0) + job->mode= 0; + else if(strcmp(argv[i]+5, "disc")== 0) + job->mode= 1; + else { +unknown_value:; + sprintf(xorriso->info_text, + "-check_media: Unknown value with option %s", argv[i]); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + } else { + sprintf(xorriso->info_text, "-check_media: Unknown option '%s'", argv[i]); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + } + ret= 1; +ex:; + return(ret); +} + + +/* @param report Buffer of at least 10*SfileadrL + @param flag bit0= only report non-default settings + @return <=0 error , 1 ok , 2 with bit0: every option is on default setting +*/ +int Xorriso_check_media_list_job(struct XorrisO *xorriso, + struct CheckmediajoB *job, + char *report, int flag) +{ + int all, ret; + char default_report[161]; + struct CheckmediajoB *dflt= NULL; + + all= !(flag&1); + report[0]= 0; + ret= Checkmediajob_new(&dflt, 0); + if(ret <= 0) + return(-1); + sprintf(report, "-check_media_defaults"); + if(!all) + strcat(report, " reset=now"); + if(all || job->use_dev != dflt->use_dev) + sprintf(report + strlen(report), " use=%s", + job->use_dev == 1 ? "outdev" : + job->use_dev == 2 ? "sector_map" : "indev"); + if(all || job->mode != dflt->mode) + sprintf(report + strlen(report), " what=%s", + job->mode == 1 ? "disc" : "tracks"); + if(all || job->min_lba != dflt->min_lba) + sprintf(report + strlen(report), " min_lba=%d", job->min_lba); + if(all || job->max_lba != dflt->max_lba) + sprintf(report + strlen(report), " max_lba=%d", job->max_lba); + if(all || job->retry != dflt->retry) + sprintf(report + strlen(report), " retry=%s", + job->retry == 1 ? "on" : job->retry == -1 ? "off" : "default"); + if(all || job->time_limit != dflt->time_limit) + sprintf(report + strlen(report), " time_limit=%d", job->time_limit); + if(all || job->item_limit != dflt->item_limit) + sprintf(report + strlen(report), " item_limit=%d", job->item_limit); + if(all || strcmp(job->abort_file_path, dflt->abort_file_path)) { + strcat(report, " abort_file="); + Text_shellsafe(job->abort_file_path, report + strlen(report), 0); + } + if(strlen(report) > 4 * SfileadrL) + {ret= 0; goto ex;} + if(all || strcmp(job->data_to_path, dflt->data_to_path)) { + strcat(report, " data_to="); + Text_shellsafe(job->data_to_path, report + strlen(report), 0); + } + if(strlen(report) > 4 * SfileadrL) + {ret= 0; goto ex;} + if(all || strcmp(job->sector_map_path, dflt->sector_map_path)) { + strcat(report, " sector_map="); + Text_shellsafe(job->sector_map_path, report + strlen(report), 0); + } + if(all || job->map_with_volid != dflt->map_with_volid) + sprintf(report + strlen(report), " map_with_volid=%s", + job->map_with_volid == 1 ? "on" : "off"); + if(all || job->patch_lba0 != dflt->patch_lba0) { + sprintf(report + strlen(report), " patch_lba0="); + if(job->patch_lba0 == 0) + sprintf(report + strlen(report), "off"); + else if(job->patch_lba0_msc1 >= 0) + sprintf(report + strlen(report), "%d%s", + job->patch_lba0_msc1, job->patch_lba0 == 2 ? ":force" : ""); + else + sprintf(report + strlen(report), "%s", + job->patch_lba0 == 2 ? "force" : "on"); + } + if(all || job->report_mode != dflt->report_mode) + sprintf(report + strlen(report), " report=%s", + job->report_mode == 0 ? "blocks" : + job->report_mode == 1 ? "files" : "blocks_files"); + if(all || strcmp(job->event_severity, "ALL") != 0) + sprintf(report + strlen(report), " event=%s", job->event_severity); + if(strlen(report) > 4 * SfileadrL) + {ret= 0; goto ex;} + ret= 1; +ex:; + strcat(report, " "); + strcat(report, xorriso->list_delimiter); + Checkmediajob_destroy(&dflt, 0); + sprintf(default_report, "-check_media_defaults reset=now %s", + xorriso->list_delimiter); + if(ret > 0 && strcmp(report, default_report) == 0) + return(2); + return(ret); +} + + +int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag) +/* + bit0= do only report non-default settings + bit1= do only report to fp + bit2= report current -resume status even if bit0 is set, but only if valid + bit3= report readline history + bit4= report -resume options indirectly as + -options_from_file:${resume_state_file}_pos +*/ +{ + int is_default, no_defaults, i, ret, adr_mode, bin_path_in_use= 0, do_single; + char *line, sfe[5 * SfileadrL + 80], mode[80], *form, *treatment; + char *in_pt, *out_pt, *nl_charset, *local_charset, *mode_pt; + static char channel_prefixes[4][4]= {".","R","I","M"}; + static char load_names[][20]= {"auto", "session", "track", "lba", "volid"}; + static int max_load_mode= 4; + struct Xorriso_lsT *paths, *leafs, *s; + + no_defaults= flag&1; + line= xorriso->result_line; + + if(xorriso->no_rc) { + sprintf(line,"-no_rc\n"); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + + is_default= strcmp(xorriso->list_delimiter, "--") == 0; + sprintf(line,"-list_delimiter %s\n", xorriso->list_delimiter); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= 0; + if(xorriso->dialog == 2) + sprintf(line,"-dialog on\n"); + else if(xorriso->dialog == 1) + sprintf(line,"-dialog single_line\n"); + else { + sprintf(line,"-dialog off\n"); + is_default= 1; + } + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->result_page_length==0 && xorriso->result_page_width==80); + sprintf(line,"-page %d %d\n", + (xorriso->result_page_length>=0?xorriso->result_page_length + :-xorriso->result_page_length), + xorriso->result_page_width); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->use_stdin==0); + sprintf(line,"-use_readline %s\n", (xorriso->use_stdin?"off":"on")); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->bsl_interpretation == 0); + strcpy(line, "-backslash_codes "); + if(xorriso->bsl_interpretation == 0) + strcat(line, "off"); + else if(xorriso->bsl_interpretation == (3 | 16 | 32 | 64)) + strcat(line, "on"); + else { + if((xorriso->bsl_interpretation & 3) == 1) + strcat(line, "in_double_quotes"); + else if((xorriso->bsl_interpretation & 3) == 2) + strcat(line, "in_quotes"); + else if((xorriso->bsl_interpretation & 3) == 3) + strcat(line, "with_quoted_input"); + if(xorriso->bsl_interpretation & 16) { + if(strlen(line) > 17) + strcat(line, ":"); + strcat(line, "with_program_arguments"); + } + if((xorriso->bsl_interpretation & (32 | 64)) == (32 | 64)) { + if(strlen(line) > 17) + strcat(line, ":"); + strcat(line, "encode_output"); + } else { + if(xorriso->bsl_interpretation & 32) { + if(strlen(line) > 17) + strcat(line, ":"); + strcat(line, "encode_results"); + } + if(xorriso->bsl_interpretation & 64) { + if(strlen(line) > 17) + strcat(line, ":"); + strcat(line, "encode_infos"); + } + } + } + strcat(line, "\n"); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= !xorriso->packet_output; + sprintf(line,"-pkt_output %s\n",(xorriso->packet_output?"on":"off")); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + for(i=0;i<4;i++) { + is_default= (xorriso->logfile[i]!=0); + sprintf(line,"-logfile %s %s\n", + channel_prefixes[i],Text_shellsafe(xorriso->logfile[i],sfe,0)); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + + is_default= (xorriso->errfile_log[0]==0); + sprintf(line,"-errfile_log %s\n",Text_shellsafe(xorriso->errfile_log,sfe,0)); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + if(xorriso->check_media_default == NULL) { + is_default= 1; + sprintf(line, "-check_media_defaults reset=now %s\n", + xorriso->list_delimiter); + } else { + ret= Xorriso_check_media_list_job(xorriso, xorriso->check_media_default, + line, no_defaults); + is_default= (ret == 2); + strcat(line, "\n"); + } + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->img_read_error_mode==2); + treatment= "best_effort"; + if(xorriso->img_read_error_mode==1) + treatment= "failure"; + else if(xorriso->img_read_error_mode==2) + treatment= "fatal"; + sprintf(line,"-error_behavior image_loading %s\n", treatment); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + is_default= (xorriso->extract_error_mode == 1); + treatment= "keep"; + if(xorriso->extract_error_mode == 0) + treatment= "best_effort"; + else if(xorriso->extract_error_mode == 2) + treatment= "delete"; + sprintf(line,"-error_behavior file_extraction %s\n", treatment); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->mark_text[0]==0); + sprintf(line,"-mark %s\n",Text_shellsafe(xorriso->mark_text,sfe,0)); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->temp_mem_limit==16*1024*1024); + if((xorriso->temp_mem_limit/1024/1024)*1024*1024==xorriso->temp_mem_limit) + sprintf(line,"-temp_mem_limit %dm\n", xorriso->temp_mem_limit/1024/1024); + else + sprintf(line,"-temp_mem_limit %dk\n", xorriso->temp_mem_limit/1024); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + + sprintf(line,"-prog %s\n",Text_shellsafe(xorriso->progname,sfe,0)); + Xorriso_status_result(xorriso,filter,fp,flag&2); + + if(xorriso->ban_stdio_write) { + sprintf(line,"-ban_stdio_write\n"); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + + is_default= (xorriso->allow_restore==0 && xorriso->do_concat_split==1 && + xorriso->do_auto_chmod==0); + mode_pt= "off"; + if(xorriso->allow_restore == -1) + mode_pt= "banned"; + else if(xorriso->allow_restore == 1) + mode_pt= "on"; + else if(xorriso->allow_restore == 2) + mode_pt= "device_files"; + if(xorriso->allow_restore == -1) + sprintf(line,"-osirrox %s\n", mode_pt); + else + sprintf(line,"-osirrox %s:%s:%s:%s\n", mode_pt, + xorriso->do_concat_split ? "concat_split_on" : "concat_split_off", + xorriso->do_auto_chmod ? "auto_chmod_on" : "auto_chmod_off", + xorriso->do_restore_sort_lba ? "sort_lba_on" : "sort_lba_off" + ); + + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->keep_boot_image == 0 + && xorriso->patch_isolinux_image == 0 + && xorriso->boot_image_bin_path[0] == 0); + form= "any"; + treatment= "discard"; + if(xorriso->boot_image_bin_path[0]) { + form= "isolinux"; + if(strcmp(xorriso->boot_image_bin_path, "/isolinux.bin") == 0 && + strcmp(xorriso->boot_image_cat_path, "/boot.cat") == 0) + strcpy(sfe, "dir=/"); + else if(strcmp(xorriso->boot_image_bin_path, "/isolinux/isolinux.bin") == 0 + && strcmp(xorriso->boot_image_cat_path, "/isolinux/boot.cat") == 0) + strcpy(sfe, "dir=/isolinux"); + else if(strcmp(xorriso->boot_image_bin_path, + "/boot/isolinux/isolinux.bin") == 0 + && strcmp(xorriso->boot_image_cat_path, + "/boot/isolinux/boot.cat") == 0) + strcpy(sfe, "dir=/boot/isolinux"); + else { + strcpy(sfe, "bin_path="); + Text_shellsafe(xorriso->boot_image_bin_path, sfe + strlen(sfe), 0); + bin_path_in_use= 1; + } + treatment= sfe; + } else if(xorriso->patch_isolinux_image) { + form= "isolinux"; + treatment= "patch"; + } else if(xorriso->keep_boot_image) { + treatment= "keep"; + } + sprintf(line,"-boot_image %s %s\n", form, treatment); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + if(xorriso->boot_image_bin_path[0] && bin_path_in_use) { + is_default= 0; + sprintf(line,"-boot_image isolinux cat_path=%s\n", + Text_shellsafe(xorriso->boot_image_cat_path, sfe, 0)); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + is_default= xorriso->boot_image_load_size == 4 * 512; + sprintf(line,"-boot_image isolinux load_size=%.f\n", + (double) xorriso->boot_image_load_size); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + if(strcmp(form, "isolinux") == 0) { + static char modes[4][6]= {"off", "auto", "on", "force"}; + is_default= (xorriso->boot_image_isohybrid == 1); + sprintf(line,"-boot_image isolinux isohybrid=%s\n", + modes[xorriso->boot_image_isohybrid & 3]); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + + sprintf(line,"-cd %s\n", + (xorriso->wdi[0] ? Text_shellsafe(xorriso->wdi,sfe,0) : "'/'")); + Xorriso_status_result(xorriso,filter,fp,flag&2); + sprintf(line,"-cdx %s\n", + (xorriso->wdx[0] ? Text_shellsafe(xorriso->wdx,sfe,0) : "'/'")); + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->split_size==0); + strcpy(line,"-split_size "); + if(xorriso->split_size % (1024*1024) || xorriso->split_size==0) { + Sfile_off_t_text(line+strlen(line), xorriso->split_size, 0); + } else { + Sfile_off_t_text(line+strlen(line), xorriso->split_size / (1024*1024), 0); + strcat(line, "m"); + } + strcat(line, "\n"); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->add_plainly==0); + sprintf(line,"-add_plainly %s\n", + (xorriso->add_plainly == 1 ? "unknown" : + xorriso->add_plainly == 2 ? "dashed" : + xorriso->add_plainly == 3 ? "any" : "none")); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + ret= Exclusions_get_descrs(xorriso->disk_exclusions, &paths, &leafs, 0); + if(ret>0) { + for(; paths!=NULL; paths= paths->next) { + sprintf(line, "-not_paths %s %s\n", + Text_shellsafe(paths->text, sfe, 0), xorriso->list_delimiter); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + for(; leafs!=NULL; leafs= leafs->next) { + sprintf(line,"-not_leaf %s\n", Text_shellsafe(leafs->text, sfe, 0)); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + } + + is_default= (xorriso->file_size_limit == + Xorriso_default_file_size_limiT); + if(xorriso->file_size_limit <= 0) + sprintf(line, "-file_size_limit off %s\n", xorriso->list_delimiter); + else + sprintf(line, "-file_size_limit %.f %s\n", + (double) xorriso->file_size_limit, xorriso->list_delimiter); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->disk_excl_mode==1); + sprintf(line, "-not_mgt %s:%s:%s:%s\n", + (xorriso->disk_excl_mode&1 ? "on" : "off"), + (xorriso->disk_excl_mode&2 ? "param_on" : "param_off"), + (xorriso->disk_excl_mode&4 ? "subtree_on" : "subtree_off"), + (xorriso->disk_excl_mode&8 ? "ignore_on" : "ignore_off")); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->do_iso_rr_pattern==1); + sprintf(line,"-iso_rr_pattern %s\n", + (xorriso->do_iso_rr_pattern == 1 ? "on" : + (xorriso->do_iso_rr_pattern == 2 ? "ls" : "off"))); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->do_disk_pattern==2); + sprintf(line,"-disk_pattern %s\n", + (xorriso->do_disk_pattern == 1 ? "on" : + (xorriso->do_disk_pattern == 2 ? "ls" : "off"))); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= xorriso->volid_default; + sprintf(line,"-volid %s\n",Text_shellsafe(xorriso->volid,sfe,0)); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + if(is_default && xorriso->loaded_volid[0] && + strcmp(xorriso->loaded_volid, xorriso->volid)!=0 && !no_defaults) { + sprintf(line,"# loaded image effective -volid %s\n", + Text_shellsafe(xorriso->loaded_volid,sfe,0)); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + + is_default= (xorriso->publisher[0]==0); + sprintf(line,"-publisher %s\n",Text_shellsafe(xorriso->publisher,sfe,0)); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->application_id[0]==0); + sprintf(line,"-application_id %s\n", + Text_shellsafe(xorriso->application_id,sfe,0)); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->do_joliet==0); + sprintf(line,"-joliet %s\n", (xorriso->do_joliet == 1 ? "on" : "off")); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + if(xorriso->do_global_uid) { + sprintf(line,"-uid %lu\n", (unsigned long) xorriso->global_uid); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + + if(xorriso->do_global_gid) { + sprintf(line,"-gid %lu\n", (unsigned long) xorriso->global_gid); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + + Xorriso_status_extf(xorriso, filter, fp, flag & 2); + Xorriso_status_zisofs(xorriso, filter, fp, flag & 3); + + is_default= !xorriso->allow_graft_points; + sprintf(line,"-pathspecs %s\n", xorriso->allow_graft_points ? "on" : "off"); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->do_follow_pattern && (!xorriso->do_follow_param) + && xorriso->do_follow_mount && (!xorriso->do_follow_links) + && xorriso->follow_link_limit==100); + mode[0]= 0; + if(xorriso->do_follow_pattern && + !(xorriso->do_follow_links && xorriso->do_follow_mount)) + strcat(mode,":pattern"); + if(xorriso->do_follow_param && !(xorriso->do_follow_links)) + strcat(mode,":param"); + if(xorriso->do_follow_links) + strcat(mode,":link"); + if(xorriso->do_follow_mount) + strcat(mode,":mount"); + if(mode[0]==0) + strcpy(mode, ":off"); + sprintf(mode+strlen(mode), ":limit=%d", xorriso->follow_link_limit); + sprintf(line,"-follow %s\n", mode+1); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->do_overwrite==2); + sprintf(line,"-overwrite %s\n",(xorriso->do_overwrite == 1 ? "on" : + (xorriso->do_overwrite == 2 ? "nondir" : "off"))); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= !xorriso->do_reassure; + sprintf(line,"-reassure %s\n",(xorriso->do_reassure == 1 ? "on" : + (xorriso->do_reassure == 2 ? "tree" : "off"))); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= !xorriso->do_close; + sprintf(line,"-close %s\n",(xorriso->do_close ? "on" : "off")); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= !xorriso->do_dummy; + sprintf(line,"-dummy %s\n",(xorriso->do_dummy ? "on" : "off")); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->speed==0); + sprintf(line,"-speed %dkB/s\n", xorriso->speed); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->do_stream_recording==0); + strcpy(mode, "off"); + if(xorriso->do_stream_recording == 1) + strcpy(mode, "full"); + if(xorriso->do_stream_recording == 2) + strcpy(mode, "data"); + else if(xorriso->do_stream_recording == 32) + strcpy(mode, "on"); + else if(xorriso->do_stream_recording >= 16) + sprintf(mode, "%ds", xorriso->do_stream_recording); + sprintf(line,"-stream_recording %s\n", mode); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->fs==4*512); + if((xorriso->fs/512)*512==xorriso->fs) + sprintf(line,"-fs %dm\n", xorriso->fs/512); + else + sprintf(line,"-fs %dk\n", xorriso->fs*2); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->padding==300*1024); + sprintf(line,"-padding %dk\n", xorriso->padding/1024); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (strcmp(xorriso->report_about_text,"UPDATE")==0); + sprintf(line,"-report_about %s\n",xorriso->report_about_text); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->session_logfile[0]==0); + sprintf(line,"-session_log %s\n", + Text_shellsafe(xorriso->session_logfile,sfe,0)); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->pacifier_style==0); + sprintf(line,"-pacifier '%s'\n", + xorriso->pacifier_style==1 ? "mkisofs" : + xorriso->pacifier_style==2 ? "cdrecord" : "xorriso"); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (strcmp(xorriso->return_with_text,"SORRY")==0 && + xorriso->return_with_value==32); + sprintf(line,"-return_with %s %d\n", + xorriso->return_with_text, xorriso->return_with_value); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (strcmp(xorriso->abort_on_text,"FATAL")==0); + sprintf(line,"-abort_on %s\n",xorriso->abort_on_text); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + if(xorriso->status_history_max!=Xorriso_status_history_maX || !no_defaults) { + sprintf(line,"-status_history_max %d\n",xorriso->status_history_max); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + +#ifdef Xorriso_with_readlinE + + if((flag&8) && xorriso->status_history_max>0) { + HIST_ENTRY **hl; + int hc,i; + + hl= history_list(); + if(hl!=NULL) { + for(hc= 0;hl[hc]!=NULL;hc++); + if(hc>0) + if(strcmp(hl[hc-1]->line,"-end")==0) + hc--; + if(hc>=xorriso->status_history_max) + i= hc-xorriso->status_history_max; + else + i= 0; + for(;i<hc;i++) { + sprintf(line,"-history %s\n",Text_shellsafe(hl[i]->line,sfe,0)); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + } + } + +#endif /* Xorriso_with_readlinE */ + + is_default= (xorriso->toc_emulation_flag == 0); + sprintf(line,"-rom_toc_scan %s%s\n", + xorriso->toc_emulation_flag & 1 ? "on" : "off", + xorriso->toc_emulation_flag & 2 ? ":emul_off" : ""); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso, filter, fp, flag & 2); + + adr_mode= xorriso->image_start_mode & 0xffff; + if(adr_mode>=0 && adr_mode<=max_load_mode) { + is_default= (adr_mode==0); + sprintf(line,"-load %s ", load_names[adr_mode]); + if(adr_mode==0) + sprintf(line+strlen(line),"''\n"); + else if(adr_mode>=1 && adr_mode<=3) + sprintf(line+strlen(line),"%s\n", xorriso->image_start_value); + else + sprintf(line+strlen(line),"%s\n", + Text_shellsafe(xorriso->image_start_value, sfe, 0)); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + + is_default= (xorriso->do_calm_drive & 1); + sprintf(line,"-calm_drive %s\n", xorriso->do_calm_drive & 1 ? "on" : "off"); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->grow_blindly_msc2<0); + sprintf(sfe, "%d", xorriso->grow_blindly_msc2); + sprintf(line,"-grow_blindly %s\n", + xorriso->grow_blindly_msc2 < 0 ? "off" : sfe); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + Xorriso_get_local_charset(xorriso, &local_charset, 0); + nl_charset= nl_langinfo(CODESET); + is_default= (strcmp(local_charset, nl_charset) == 0); + sprintf(line, "-local_charset %s\n", Text_shellsafe(local_charset, sfe, 0)); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso, filter, fp, flag & 2); + + is_default= (xorriso->out_charset == NULL && xorriso->in_charset == NULL); + in_pt= ""; + if(xorriso->in_charset != NULL) + in_pt= xorriso->in_charset; + out_pt= ""; + if(xorriso->out_charset != NULL) + out_pt= xorriso->out_charset; + do_single= 0; + ret= Xorriso_status_filter(xorriso, filter, "-in_charset", 0); + if(ret <= 0) + ret= Xorriso_status_filter(xorriso, filter, "-out_charset", 0); + if(ret > 0) + do_single= 1; + if(strcmp(in_pt, out_pt) == 0 && !do_single) { + sprintf(line, "-charset %s\n", Text_shellsafe(in_pt, sfe, 0)); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso, filter, fp, flag & 2); + } else { + sprintf(line, "-in_charset %s\n", Text_shellsafe(in_pt, sfe, 0)); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso, filter, fp, flag & 2); + sprintf(line, "-out_charset %s\n", Text_shellsafe(out_pt, sfe, 0)); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso, filter, fp, flag & 2); + } + is_default= ((xorriso->do_aaip & (256 | 512)) == 0); + sprintf(line,"-auto_charset %s\n", (xorriso->do_aaip & 256 ? "on" : "off")); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= ((xorriso->ino_behavior & 31) == 7); + switch (xorriso->ino_behavior & 15) { + case 0: form= "on"; + break; case 8: form= "without_update"; + break; default: form= "off"; + } + sprintf(line,"-hardlinks %s:%s\n", form, + xorriso->ino_behavior & 16 ? + "cheap_sorted_extract" : "normal_extract"); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= ((xorriso->do_aaip & (1 | 4)) == 0); + sprintf(line,"-acl %s\n", (xorriso->do_aaip & 1 ? "on" : "off")); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + is_default= ((xorriso->do_aaip & (2 | 8)) == 0); + sprintf(line,"-xattr %s\n", (xorriso->do_aaip & 4 ? "on" : "off")); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + is_default= ((xorriso->do_aaip & (16 | 32 | 64)) == 0); + sprintf(line,"-disk_dev_ino %s\n", + (xorriso->do_aaip & 16 ? (xorriso->do_aaip & 128 ? "ino_only" : "on" ) + : "off")); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= ((xorriso->do_md5 & 31) == 0); + sprintf(line, "-md5 "); + if(xorriso->do_md5 & 1) { + if((xorriso->do_md5 & (8)) == (8)) { + strcat(line, "all\n"); + } else { + strcat(line, "on"); + if(xorriso->do_md5 & 8) + strcat(line, ":stability_check_on"); + strcat(line, "\n"); + } + } else + strcat(line, "off\n"); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (Xorriso_get_relax_text(xorriso, sfe, 0) == 2); + sprintf(line,"-compliance %s\n", sfe); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= (xorriso->assert_volid[0] == 0); + sprintf(line, "-assert_volid "); + Text_shellsafe(xorriso->assert_volid, line, 1); + strcat(line, " "); + Text_shellsafe(xorriso->assert_volid_sev, line, 1); + strcat(line, "\n"); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + + is_default= 1; + if(xorriso->drive_blacklist != NULL || xorriso->drive_whitelist != NULL || + xorriso->drive_greylist == NULL) + is_default= 0; + if(xorriso->drive_greylist != NULL) { + if(strcmp(Xorriso_get_pattern(xorriso, xorriso->drive_greylist, 0, 0), + "/dev") != 0) + is_default= 0; + if(Xorriso_get_pattern(xorriso, xorriso->drive_greylist, 1, 0) != NULL) + is_default= 0; + } + if(!(is_default && no_defaults)) { + for(s= xorriso->drive_blacklist; s != NULL; s= Xorriso_lst_get_next(s, 0)) { + sprintf(line, "-drive_class 'banned' %s\n", + Text_shellsafe(Xorriso_lst_get_text(s, 0), sfe, 0)); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + for(s= xorriso->drive_greylist; s != NULL; s= Xorriso_lst_get_next(s, 0)) { + sprintf(line, "-drive_class 'caution' %s\n", + Text_shellsafe(Xorriso_lst_get_text(s, 0), sfe, 0)); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + for(s= xorriso->drive_whitelist; s != NULL; s= Xorriso_lst_get_next(s, 0)) { + sprintf(line, "-drive_class 'harmless' %s\n", + Text_shellsafe(Xorriso_lst_get_text(s, 0), sfe, 0)); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + } + + do_single= 0; + ret= Xorriso_status_filter(xorriso, filter, "-indev", 0); + if(ret <= 0) + ret= Xorriso_status_filter(xorriso, filter, "-outdev", 0); + if(ret > 0) + do_single= 1; + if(strcmp(xorriso->indev, xorriso->outdev) == 0 && !do_single) { + sprintf(line,"-dev %s\n", Text_shellsafe(xorriso->indev,sfe,0)); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } else { + sprintf(line,"-indev %s\n", Text_shellsafe(xorriso->indev,sfe,0)); + Xorriso_status_result(xorriso,filter,fp,flag&2); + sprintf(line,"-outdev %s\n", Text_shellsafe(xorriso->outdev,sfe,0)); + Xorriso_status_result(xorriso,filter,fp,flag&2); + } + + return(1); +} + + +/* @param flag bit2= this is a disk_pattern + @return <=0 failure , 1 pattern ok , 2 pattern needed prepended wd */ +int Xorriso_prepare_expansion_pattern(struct XorrisO *xorriso, char *pattern, + int flag) +{ + int ret, prepwd= 0; + + ret= Xorriso_prepare_regex(xorriso, pattern, 1|2|(flag&4)); + if(ret==2) { + ret= Xorriso_prepare_regex(xorriso, pattern, flag&4); + prepwd= 1; + } + if(ret<=0) { + sprintf(xorriso->info_text, + "Cannot compile pattern to regular expression: %s", pattern); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(1+prepwd); +} + + +/* @param flag bit0= count results rather than storing them + bit1= unexpected change of number is a FATAL event + @return <=0 error , 1 is root (end processing) , + 2 is not root (go on processing) +*/ +int Xorriso_check_for_root_pattern(struct XorrisO *xorriso, + int *filec, char **filev, int count_limit, off_t *mem, int flag) +{ + if(xorriso->re_fill!=0) + return(2); + /* This is the empty pattern representing root */ + if(flag&1) { + (*filec)++; + (*mem)+= 8; + } else { + if(*filec >= count_limit) { + sprintf(xorriso->info_text, + "Number of matching files changed unexpectedly (> %d)", + count_limit); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, + (flag&2 ? "FATAL" : "WARNING"), 0); + return(flag&2 ? -1 : 0); + } + filev[*filec]= strdup("/"); + if(filev[*filec]==NULL) { + Xorriso_no_pattern_memory(xorriso, (off_t) 2, 0); + return(-1); + } + (*filec)++; + } + return(1); +} + + +/* @param flag bit0= prepend wd only if name does not begin by '/' + bit1= normalize image path + bit2= prepend wd (automatically done if wd[0]!=0) + bit3= (with bit1) this is an address in the disk world +*/ +int Xorriso_make_abs_adr(struct XorrisO *xorriso, char *wd, char *name, + char adr[], int flag) +{ + char norm_adr[SfileadrL]; + int ret; + + if((wd[0]!=0 || (flag&4)) && !((flag&1) && name[0]=='/')) { + if(strlen(wd)+1>=SfileadrL) + goto much_too_long; + strcpy(adr, wd); + if(name[0]) + if(Sfile_add_to_path(adr, name, 0)<=0) { +much_too_long:; + Xorriso_much_too_long(xorriso, (int) (strlen(adr)+strlen(name)+1), 2); + return(0); + } + } else { + if(strlen(name)+1>=SfileadrL) + goto much_too_long; + strcpy(adr, name); + } + if(flag&2) { + ret= Xorriso_normalize_img_path(xorriso, "", adr, norm_adr, + 1|2|((flag&8)>>1)); + if(ret<=0) + return(ret); + if(norm_adr[0]==0) + strcpy(norm_adr, "/"); + strcpy(adr, norm_adr); + } + return(1); +} + + +/* + @param result Bitfield indicationg type of mismatch + bit11= cannot open regular disk file + bit12= cannot open iso file + bit13= early eof of disk file + bit14= early eof of iso file + bit15= content bytes differ + @param flag bit0= mtimes of both file objects are equal + bit29= do not issue pacifier messages + bit31= do not issue result messages + @return >0 ok , <=0 error +*/ +int Xorriso_compare_2_contents(struct XorrisO *xorriso, char *common_adr, + char *disk_adr, off_t disk_size, + off_t offset, off_t bytes, + char *iso_adr, off_t iso_size, + int *result, int flag) +{ + int fd1= -1, ret, r1, r2, done, wanted, i, was_error= 0, use_md5= 0; + void *stream2= NULL; + off_t r1count= 0, r2count= 0, diffcount= 0, first_diff= -1; + char *respt, buf1[32*1024], buf2[32*1024], offset_text[80]; + char disk_md5[16], iso_md5[16]; + void *ctx= NULL; + + respt= xorriso->result_line; + + fd1= open(disk_adr, O_RDONLY); + if(fd1==-1) { + sprintf(respt, "- %s (DISK) : cannot open() : %s\n", + disk_adr, strerror(errno)); +cannot_address:; + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 2048; + {ret= 0; goto ex;} + } + if(offset>0) + if(lseek(fd1, offset, SEEK_SET)==-1) { + sprintf(respt, "- %s (DISK) : cannot lseek(%.f) : %s\n", + disk_adr, (double) offset, strerror(errno)); + close(fd1); + goto cannot_address; + } + + if(xorriso->do_md5 & 16) { + use_md5= 1; + ret= Xorriso_get_md5(xorriso, NULL, iso_adr, iso_md5, 1); + if(ret <= 0) + use_md5= 0; + else { + ret= Xorriso_md5_start(xorriso, &ctx, 0); + if(ret <= 0) + use_md5= 0; + } + } + if (! use_md5) { + ret= Xorriso_iso_file_open(xorriso, iso_adr, NULL, &stream2, 0); + if(ret<=0) { + sprintf(respt, "- %s (ISO) : cannot open() file in ISO image\n",iso_adr); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + close(fd1); + (*result)|= 4096; + {ret= 0; goto ex;} + } + } + + done= 0; + while(!done) { + + wanted= sizeof(buf1); + if(r1count+offset+wanted>disk_size) + wanted= disk_size-r1count-offset; + if(r1count+wanted>bytes) + wanted= bytes-r1count; + r1= 0; + while(wanted>0) { + ret= read(fd1, buf1, wanted); + if(ret<=0) + break; + wanted-= ret; + r1+= ret; + } + + wanted= sizeof(buf2); + if(r2count+wanted>iso_size) + wanted= iso_size-r2count; +/* + if(r2count+wanted>bytes) + wanted= bytes-r2count; +*/ + if(use_md5) + r2= r1; + else if(wanted>0) + r2= Xorriso_iso_file_read(xorriso, stream2, buf2, wanted, 0); + else + r2= 0; + + if(r1<0 || r2<0) + was_error= 1; + + if(r1<=0 && r2<=0) + break; + if(r1<=0) { + if(r1<0) + r1= 0; + if(disk_size > r1count + r1 + offset) { + sprintf(respt, "- %s (DISK) : early EOF after %.f bytes\n", + disk_adr, (double) r1count); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 8196; + } + (*result)|= (1<<15); + } + r1count+= r1; + if(r2<=0 || r2<r1) { + if(r2<0) + r2= 0; + if(iso_size > r2count + r2) { + sprintf(respt, "- %s (ISO) : early EOF after %.f bytes\n", + iso_adr, (double) r2count); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= (1<<14); + } + (*result)|= (1<<15); + done= 1; + } + if(r2>r1) { + if(disk_size > r1count + r1 + offset) { + sprintf(respt, "- %s (DISK) : early EOF after %.f bytes\n", + disk_adr, (double) r1count); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 8196; + } + (*result)|= (1<<15); + done= 1; + } + r2count+= r2; + if(r1>r2) + r1= r2; + + if(use_md5) { + Xorriso_md5_compute(xorriso, ctx, buf1, r1, 0); + } else { + for(i= 0; i<r1; i++) { + if(buf1[i]!=buf2[i]) { + if(first_diff<0) + first_diff= i; + diffcount++; + } + } + } + if(!(flag&(1<<29))) { + xorriso->pacifier_count+= r1; + xorriso->pacifier_byte_count+= r1; + if(flag&(1<<31)) + Xorriso_pacifier_callback(xorriso, "content bytes read", + xorriso->pacifier_count, 0, "", 0); + else + Xorriso_pacifier_callback(xorriso, "bytes", xorriso->pacifier_count, 0, + "", 1<<6); + } + } + + if(use_md5) { + ret= Xorriso_md5_end(xorriso, &ctx, disk_md5, 0); + if(ret <= 0) { + *result |= (1 << 15); + ret= -1; goto ex; + } + for(i= 0; i < 16; i++) + if(iso_md5[i] != disk_md5[i]) + break; + if(i < 16 ) { + offset_text[0]= 0; + if(offset>0) + sprintf(offset_text, "%.f+", (double) offset); + sprintf(respt, "%s %s : differs by MD5 sums.\n", + common_adr, (flag&1 ? "CONTENT": "content")); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= (1<<15); + } + } else if(diffcount>0 || r1count!=r2count) { + if(first_diff<0) + first_diff= (r1count>r2count ? r2count : r1count); + offset_text[0]= 0; + if(offset>0) + sprintf(offset_text, "%.f+", (double) offset); + sprintf(respt, "%s %s : differs by at least %.f bytes. First at %s%.f\n", + common_adr, (flag&1 ? "CONTENT": "content"), + (double) (diffcount + abs(r1count-r2count)), + offset_text, (double) first_diff); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= (1<<15); + } + if(fd1!=-1) + close(fd1); + if(! use_md5) + Xorriso_iso_file_close(xorriso, &stream2, 0); + if(was_error) + {ret= -1; goto ex;} + ret= 1; +ex:; + if(ctx != NULL) + Xorriso_md5_end(xorriso, &ctx, disk_md5, 0); + return(ret); +} + + +/* + @param result Bitfield indicationg type of mismatch + bit0= disk_adr not existing + bit1= iso_adr not existing + bit2= access permissions + bit3= file type + bit4= user id + bit5= group id + bit6= minor, major with device file + bit7= size + bit8= mtime + bit9= atime + bit10= ctime + bit11= cannot open regular disk file + bit12= cannot open iso file + bit13= early eof of disk file + bit14= early eof of iso file + bit15= content bytes differ + bit16= symbolic link on disk pointing to dir, dir in iso + bit17= file chunks detected and compared + bit18= incomplete chunk collection encountered + bit19= ACL differs (this condition sets also bit2) + bit20= xattr differ + bit21= mismatch of recorded dev,inode + bit22= no recorded dev,inode found in node + bit23= timestamps younger than xorriso->isofs_st_in + bit24= hardlink split + bit25= hardlink fusion + @param flag bit0= compare atime + bit1= compare ctime + bit2= check only existence of both file objects + count one or both missing as "difference" + bit27= for Xorriso_path_is_excluded(): bit0 + bit28= examine eventual disk_path link target rather than link + bit29= do not issue pacifier messages + bit30= omit adr_common_tail in report messages + bit31= do not issue result messages + @return 1=files match properly , 0=difference detected , -1=error +*/ +int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr, + char *iso_adr, char *adr_common_tail, + int *result, int flag) +{ + struct stat s1, s2, stbuf; + int ret, missing= 0, is_split= 0, i, was_error= 0, diff_count= 0; + int content_shortcut= 0; + char *respt; + char a[5*SfileadrL], sfe[5*SfileadrL]; + char ttx1[40], ttx2[40]; + char *a1_acl= NULL, *a2_acl= NULL, *d1_acl= NULL, *d2_acl= NULL; + char *attrlist1= NULL, *attrlist2= NULL; + struct SplitparT *split_parts= NULL; + int split_count= 0; + time_t stamp; + + char part_path[SfileadrL], *part_name; + int partno, total_parts= 0; + off_t offset, bytes, total_bytes; + + *result= 0; + respt= xorriso->result_line; + + if(!(xorriso->disk_excl_mode&8)) { + ret= Xorriso_path_is_excluded(xorriso, disk_adr, 2 | !!(flag&(1<<27))); + if(ret>0) { + sprintf(respt , "? %s (DISK) : exluded by %s\n", + Text_shellsafe(disk_adr, sfe, 0), + (ret==1 ? "-not_paths" : "-not_leaf")); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + missing= 1; + (*result)|= 1; + } + } + if(!missing) { + if(flag&(1<<28)) + ret= stat(disk_adr, &s1); + else + ret= lstat(disk_adr, &s1); + if(ret==-1) { + sprintf(respt , "? %s (DISK) : cannot lstat() : %s\n", + Text_shellsafe(disk_adr, sfe, 0), strerror(errno)); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + missing= 1; + (*result)|= 1; + } + } + if(missing) + strcpy(a, "?"); + else + strcpy(a, Ftypetxt(s1.st_mode, 1)); + strcat(a, " "); + if(adr_common_tail[0]) + strcat(a, Text_shellsafe(adr_common_tail, sfe, 0)); + else { + Text_shellsafe(disk_adr, a+strlen(a), 0); + strcat(a, " (DISK)"); +/* + strcat(a, "'.'"); +*/ + } + strcat(a, " :"); + if(flag&(1<<30)) + a[0]= 0; + + ret= Xorriso_iso_lstat(xorriso, iso_adr, &s2, 0); + if(ret<0) { + sprintf(respt, "? %s (ISO) : cannot find this file in ISO image\n", + Text_shellsafe(iso_adr, sfe, 0)); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + missing= 1; + (*result)|= 2; + } + + if((flag&4)||missing) + {ret= !missing; goto ex;} + + + /* Splitfile parts */ + if((S_ISREG(s1.st_mode) || S_ISBLK(s1.st_mode)) && S_ISDIR(s2.st_mode)) { + is_split= Xorriso_identify_split(xorriso, iso_adr, NULL, &split_parts, + &split_count, &s2, 0); + if(is_split>0) + (*result)|= (1<<17); + else + is_split= 0; + } + + /* Attributes */ + if(s1.st_mode != s2.st_mode) { + if((s1.st_mode&~S_IFMT)!=(s2.st_mode&~S_IFMT)) { + sprintf(respt, "%s st_mode : %7.7o <> %7.7o\n", + a, (unsigned int) (s1.st_mode & ~S_IFMT), + (unsigned int) (s2.st_mode & ~S_IFMT)); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 4; + } + + if((s1.st_mode&S_IFMT)!=(s2.st_mode&S_IFMT)) { + sprintf(respt, "%s type : %s <> %s\n", + a, Ftypetxt(s1.st_mode, 0), Ftypetxt(s2.st_mode, 0)); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 8; + if((s1.st_mode&S_IFMT) == S_IFLNK) { + /* check whether link target type matches */ + ret= stat(disk_adr, &stbuf); + if(ret!=-1) + if(S_ISDIR(stbuf.st_mode) && S_ISDIR(s2.st_mode)) + (*result)|= (1<<16); + } + } + } + + /* ACL */ + if(xorriso->do_aaip & 3) { + Xorriso_local_getfacl(xorriso, disk_adr, &a1_acl, + 16 | ((flag & (1 << 28)) >> 23)); + if(S_ISDIR(s1.st_mode)) + Xorriso_local_getfacl(xorriso, disk_adr, &d1_acl, 1); + ret= Xorriso_getfacl(xorriso, NULL, iso_adr, &a2_acl, 1 | 4 | 16); + if(ret < 0) + goto ex; + if(S_ISDIR(s1.st_mode)) { + ret= Xorriso_getfacl(xorriso, NULL, iso_adr, &d2_acl, 1 | 8); + if(ret < 0) + goto ex; + } + ret= Compare_text_lines(a1_acl, a2_acl, &diff_count, 0); + if(ret < 0) + goto ex; + if(ret == 0) + (*result)|= 4 | (1 << 19); + ret= Compare_text_lines(d1_acl, d2_acl, &diff_count, 1); + if(ret < 0) + goto ex; + if(ret == 0) + (*result)|= 4 | (1 << 19); + if((*result) & (1 << 19)) { + sprintf(respt, "%s ACL : %d difference%s\n", + a, diff_count, diff_count == 1 ? "" : "s"); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + } + } + + /* xattr */ + if(xorriso->do_aaip & 12) { + ret= Xorriso_getfattr(xorriso, NULL, disk_adr, &attrlist1, + 1 | 2 | ((flag & (1 << 28)) >> 23)); + if(ret < 0) + goto ex; + ret= Xorriso_getfattr(xorriso, NULL, iso_adr, &attrlist2, 1); + if(ret < 0) + goto ex; + ret= Compare_text_lines(attrlist1, attrlist2, &diff_count, 0); + if(ret < 0) + goto ex; + if(ret == 0) { + (*result)|= (1 << 20); + sprintf(respt, "%s xattr : %d difference%s\n", + a, diff_count, diff_count == 1 ? "" : "s"); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + } + } + + if(s1.st_uid != s2.st_uid) { + sprintf(respt, "%s st_uid : %d <> %d\n", a, s1.st_uid, s2.st_uid); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 16; + } + if(s1.st_gid != s2.st_gid) { + sprintf(respt, "%s st_gid : %d <> %d\n", a, s1.st_gid, s2.st_gid); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 32; + } + if((S_ISCHR(s1.st_mode) && S_ISCHR(s2.st_mode)) || + (S_ISBLK(s1.st_mode) && S_ISBLK(s2.st_mode))) { + if(s1.st_rdev != s2.st_rdev) { + sprintf(respt, "%s %s st_rdev : %lu <> %lu\n", a, + (S_ISCHR(s1.st_mode) ? "S_IFCHR" : "S_IFBLK"), + (unsigned long) s1.st_rdev, (unsigned long) s1.st_rdev); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 64; + } + } + if((!(xorriso->do_aaip & 32)) && + S_ISREG(s2.st_mode) && s1.st_size != s2.st_size) { + sprintf(respt, "%s st_size : %.f <> %.f diff= %.f\n", + a, (double) s1.st_size, (double) s2.st_size, + ((double) s1.st_size) - (double) s2.st_size); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 128; + } + if(s1.st_mtime != s2.st_mtime) { + sprintf(respt, "%s st_mtime : %s <> %s diff= %.f s\n", + a, Ftimetxt(s1.st_mtime, ttx1, 0), + Ftimetxt(s2.st_mtime, ttx2, 0), + ((double) s1.st_mtime) - (double) s2.st_mtime); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 256; + } + if(flag&1) { + if(s1.st_atime != s2.st_atime) { + sprintf(respt, "%s st_atime : %s <> %s diff= %.f s\n", + a, Ftimetxt(s1.st_atime, ttx1, 0), + Ftimetxt(s2.st_atime, ttx2, 0), + ((double) s1.st_atime) - (double) s2.st_atime); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 512; + } + } + if(flag&2) { + if(s1.st_ctime != s2.st_ctime) { + sprintf(respt, "%s st_ctime : %s <> %s diff= %.f s\n", + a, Ftimetxt(s1.st_ctime, ttx1, 0), + Ftimetxt(s2.st_ctime, ttx2, 0), + ((double) s1.st_ctime) - (double) s2.st_ctime); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= 1024; + } + } + if(xorriso->isofs_st_in > 0 && + (xorriso->isofs_st_in <= s2.st_mtime || + ((flag & 1) && xorriso->isofs_st_in <= s2.st_atime) || + ((flag & 2) && xorriso->isofs_st_in <= s2.st_ctime))) + (*result)|= 1 << 23; + + if((xorriso->do_aaip & 32) || !(xorriso->ino_behavior & 2)) { + /* dev,inode comparison. + For skipping content comparison or for hardlink detection. + */ + ret= Xorriso_record_dev_inode(xorriso, "", s1.st_dev, s1.st_ino, NULL, + iso_adr, 1 | 2 | ((flag & (1 << 28)) >> 23) | (xorriso->do_aaip & 128)); + if(ret < 0) { + ret= -1; goto ex; + } else if(ret == 0) { /* match */ + if((xorriso->do_aaip & 64) && S_ISREG(s1.st_mode) && S_ISREG(s2.st_mode)){ + if(xorriso->do_aaip & 32) + content_shortcut= 1; + if((*result) & (8 | 128 | 256 | 512 | 1024 | (1 << 23))) { + (*result)|= (1 << 15); /* content bytes differ */ + if(((*result) & (1 << 23)) && + !((*result) & (8 | 128 | 256 | 512 | 1024))) { + sprintf(respt, + "%s content : node timestamp younger than image timestamp\n", a); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + stamp= s2.st_mtime; + if((flag & 1) && s2.st_atime >= stamp) + stamp= s2.st_atime; + if((flag & 2) && s2.st_ctime >= stamp) + stamp= s2.st_ctime; + sprintf(respt, "%s content : %s > %s diff= %.f s\n", + a, Ftimetxt(stamp, ttx1, 3 << 1), + Ftimetxt(xorriso->isofs_st_in, ttx2, 3 << 1), + ((double) stamp) - (double) xorriso->isofs_st_in); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + } + sprintf(respt, + "%s content : assuming inequality due to size or timestamps\n", a); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + } + } + } else if(ret == 1) { /* mismatch */ + (*result)|= (1 << 21); + sprintf(respt, "%s dev_ino : differing\n", a); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + + if((xorriso->do_aaip & 64) && S_ISREG(s1.st_mode) && S_ISREG(s2.st_mode)){ + if(xorriso->do_aaip & 32) + content_shortcut= 1; + (*result)|= (1 << 15); /* content bytes differ */ + sprintf(respt, + "%s content : assuming inequality after dev_ino mismatch\n", a); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + } + } else { + sprintf(respt, "%s dev_ino : no dev_ino stored with image node\n", a); + if(!(flag&(1<<31))) + Xorriso_result(xorriso,0); + (*result)|= (1 << 22); + } + } + + if(S_ISREG(s1.st_mode) && S_ISREG(s2.st_mode) && !content_shortcut) { + /* Content */ + if(is_split) { + for(i= 0; i<split_count; i++) { + Splitparts_get(split_parts, i, &part_name, &partno, &total_parts, + &offset, &bytes, &total_bytes, 0); + strcpy(part_path, iso_adr); + if(Sfile_add_to_path(part_path, part_name, 0)<=0) { + Xorriso_much_too_long(xorriso, strlen(iso_adr)+strlen(part_name)+1, + 2); + {ret= -1; goto ex;} + } + ret= Xorriso_iso_lstat(xorriso, part_path, &stbuf, 0); + if(ret<0) + continue; + ret= Xorriso_compare_2_contents(xorriso, a, disk_adr, s1.st_size, + offset, bytes, + part_path, stbuf.st_size, result, + (s1.st_mtime==s2.st_mtime) | (flag&((1<<29)|(1<<31)))); + if(ret<0) + was_error= 1; + } + if(total_parts>0 && split_count!=total_parts) { + sprintf(xorriso->info_text, + "- %s/* (ISO) : Not all split parts present (%d of %d)\n", + iso_adr, split_count, total_parts); + if(!(flag&(1<<31))) + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 1); + (*result)|= 1<<18; + } + } else { + ret= Xorriso_compare_2_contents(xorriso, a, disk_adr, s1.st_size, + (off_t) 0, s1.st_size, + iso_adr, s2.st_size, result, + (s1.st_mtime==s2.st_mtime) | (flag&((1<<29)|(1<<31)))); + if(ret<0) + was_error= 1; + } + + } + if(was_error) + ret= -1; + else + ret= (((*result) & ~((1 << 17) | (1 << 18) | (1 << 23)))==0); +ex:; + if(split_parts!=NULL) + Splitparts_destroy(&split_parts, split_count, 0); + Xorriso_local_getfacl(xorriso, disk_adr, &a1_acl, 1 << 15); + Xorriso_local_getfacl(xorriso, disk_adr, &d1_acl, 1 << 15); + if(a2_acl != NULL) + free(a2_acl); + if(d2_acl != NULL) + free(d2_acl); + return(ret); +} + + +int Xorriso_pfx_disk_path(struct XorrisO *xorriso, char *iso_path, + char *iso_prefix, char *disk_prefix, + char disk_path[SfileadrL], int flag) +{ + int ret; + char adrc[SfileadrL]; + + if(strncmp(iso_path, iso_prefix, strlen(iso_prefix))!=0) + return(-1); + if(strlen(disk_prefix) + strlen(iso_path) - strlen(iso_prefix)+1 >= SfileadrL) + return(-1); + if(iso_path[strlen(iso_prefix)] == '/') + strcpy(adrc, iso_path + strlen(iso_prefix) + 1); + else + strcpy(adrc, iso_path + strlen(iso_prefix)); + ret= Xorriso_make_abs_adr(xorriso, disk_prefix, adrc, disk_path, 4 | 8); + if(ret <= 0) + return(ret); + return(1); +} + + +/* @param boss_iter Opaque handle to be forwarded to actions in ISO image + Set to NULL if calling this function from outside ISO world + @param flag bit0= update rather than compare + bit1= find[ix] is in recursion + @return <=0 error, 1= ok , 2= iso_path was deleted + 3=ok, do not dive into directory (e.g. because it is a split file) +*/ +int Xorriso_find_compare(struct XorrisO *xorriso, void *boss_iter, + char *iso_path, char *iso_prefix, char *disk_prefix, + int flag) +{ + int ret, result, uret, follow_links, deleted= 0; + char disk_path[SfileadrL]; + + ret= Xorriso_pfx_disk_path(xorriso, iso_path, iso_prefix, disk_prefix, + disk_path, 0); + if(ret <= 0) + return(ret); + + /* compare exclusions against disk_path resp. leaf name */ + if(xorriso->disk_excl_mode&8) + ret= Xorriso_path_is_excluded(xorriso, disk_path, !(flag&2)); + else + ret= 0; + if(ret<0) + return(ret); + if(ret>0) + return(3); + + follow_links= (xorriso->do_follow_links || + (xorriso->do_follow_param && !(flag&2))) <<28; + ret= Xorriso_compare_2_files(xorriso, disk_path, iso_path, "", &result, + 2 | follow_links | ((!(flag&2))<<27) | ((flag&1)<<31)); + /* was once: | ((!(flag&1))<<29) */ + if(ret<xorriso->find_compare_result) + xorriso->find_compare_result= ret; + if(flag&1) { + if(ret<=0) { + if(ret<0) + if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0) + return(ret); + uret= Xorriso_update_interpreter(xorriso, boss_iter, result, + disk_path, iso_path, (flag&2)<<1); + if(uret<=0) + ret= 0; + if(uret==2) + deleted= 1; + } + } + if(ret<0) + return(ret); + if(deleted) + return(2); + if(result&(1<<17)) + return(3); + return(ret); +} + + +/* @param flag bit0= count result rather than storing it + bit1= unexpected change of number is a FATAL event +*/ +int Xorriso_register_matched_adr(struct XorrisO *xorriso, + char *adr, int count_limit, + int *filec, char **filev, off_t *mem, int flag) +{ + int l; + + if(flag&1) { + (*filec)++; + l= strlen(adr)+1; + (*mem)+= sizeof(char *)+l; + if(l % sizeof(char *)) + (*mem)+= sizeof(char *)-(l % sizeof(char *)); + } else { + if(*filec >= count_limit) { + sprintf(xorriso->info_text, + "Number of matching files changed unexpectedly (> %d)", + count_limit); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, + (flag&2 ? "FATAL" : "WARNING"), 0); + return(flag&2 ? -1 : 0); + } + filev[*filec]= strdup(adr); + if(filev[*filec]==NULL) { + Xorriso_no_pattern_memory(xorriso, (off_t) (strlen(adr)+1), 0); + return(-1); + } + (*filec)++; + } + return(1); +} + + +/* @param flag bit0= count results rather than storing them + bit1= this is a recursion + bit2= prepend wd (automatically done if wd[0]!=0) + @return <=0 error , 1 ok , 2 could not open directory +*/ +int Xorriso_obtain_pattern_files_x( + struct XorrisO *xorriso, char *wd, char *dir_adr, + int *filec, char **filev, int count_limit, off_t *mem, + int *dive_count, int flag) +{ + int ret, failed_at, follow_mount, follow_links; + struct DirseQ *dirseq= NULL; + struct stat stbuf; + dev_t dir_dev; + char *path; + char *adr= NULL, *name= NULL, *path_data= NULL; + + adr= malloc(SfileadrL); + name= malloc(SfileadrL); + path_data= malloc(SfileadrL); + if(adr==NULL || name==NULL || path_data==NULL) { + Xorriso_no_malloc_memory(xorriso, &adr, 0); + {ret= -1; goto ex;} + } + follow_mount= (xorriso->do_follow_mount || xorriso->do_follow_pattern); + follow_links= (xorriso->do_follow_links || xorriso->do_follow_pattern); + if(!(flag&2)) + *dive_count= 0; + else + (*dive_count)++; + + ret= Xorriso_check_for_root_pattern(xorriso, filec, filev, count_limit, + mem, flag&1); + if(ret!=2) + goto ex; + + if(lstat(dir_adr, &stbuf)==-1) + {ret= 2; goto ex;} + dir_dev= stbuf.st_dev; + if(S_ISLNK(stbuf.st_mode)) { + if(stat(dir_adr, &stbuf)==-1) + {ret= 2; goto ex;} + if(dir_dev != stbuf.st_dev && !follow_mount) + {ret= 2; goto ex;} + } + ret= Dirseq_new(&dirseq, dir_adr, 1); + if(ret<0) { + sprintf(xorriso->info_text, "Cannot obtain disk directory iterator"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + if(ret==0) + {ret= 2; goto ex;} + + while(1) { + ret= Dirseq_next_adr(dirseq,name,0); + if(ret==0) + break; + if(ret<0) { + sprintf(xorriso->info_text,"Failed to obtain next directory entry"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + + ret= Xorriso_make_abs_adr(xorriso, wd, name, adr, flag&4); + if(ret<=0) + goto ex; + + ret= Xorriso_regexec(xorriso, adr, &failed_at, 1); + if(ret>0) { /* no match */ + if(failed_at <= *dive_count) /* no hope for a match */ + continue; + path= adr; + if(adr[0]!='/') { + path= path_data; + ret= Xorriso_make_abs_adr(xorriso, xorriso->wdx, adr, path, 1|4); + if(ret<=0) + goto ex; + } + + if(follow_links) + ret= stat(path,&stbuf); + else + ret= lstat(path,&stbuf); + if(ret==-1) + continue; + if(!S_ISDIR(stbuf.st_mode)) + continue; + if(dir_dev != stbuf.st_dev && !follow_mount) + continue; + + /* dive deeper */ + ret= Xorriso_obtain_pattern_files_x(xorriso, adr, path, + filec, filev, count_limit, mem, dive_count, flag|2); + if(ret<=0) + goto ex; + } else { + ret= Xorriso_register_matched_adr(xorriso, adr, count_limit, + filec, filev, mem, flag&1); + if(ret<0) + goto ex; + if(ret==0) + break; + } + } + ret= 1; +ex:; + if(adr!=NULL) + free(adr); + if(name!=NULL) + free(name); + if(path_data!=NULL) + free(path_data); + Dirseq_destroy(&dirseq,0); + if(flag&2) + (*dive_count)--; + return(ret); +} + + +int Xorriso_eval_nonmatch(struct XorrisO *xorriso, char *pattern, + int *nonconst_mismatches, off_t *mem, int flag) +{ + int k,l; + + /* Is this a constant pattern ? */ + for(k= 0; k<xorriso->re_fill; k++) { + if(xorriso->re_constants[k]==NULL) + break; + if(xorriso->re_constants[k][0]==0) + break; + } + if(k<xorriso->re_fill) + (*nonconst_mismatches)++; /* it is not */ + + l= strlen(pattern)+1; + (*mem)+= sizeof(char *)+l; + if(l % sizeof(char *)) + (*mem)+= sizeof(char *)-(l % sizeof(char *)); + return(1); +} + + +/* @param flag bit0= a match count !=1 is a SORRY event + bit1= a match count !=1 is a FAILURE event +*/ +int Xorriso_check_matchcount(struct XorrisO *xorriso, + int count, int nonconst_mismatches, int num_patterns, + char **patterns, int flag) +{ + char sfe[5*SfileadrL]; + + if((flag&1) && (count!=1 || nonconst_mismatches)){ + if(count-nonconst_mismatches>0) + sprintf(xorriso->info_text, + "Pattern match with more than one file object"); + else + sprintf(xorriso->info_text, "No pattern match with any file object"); + if(num_patterns==1) + sprintf(xorriso->info_text+strlen(xorriso->info_text), ": %s", + Text_shellsafe(patterns[0], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, + (flag&2 ? "FAILURE" : "SORRY"), 0); + return(0); + } + return(1); +} + + +int Xorriso_no_pattern_memory(struct XorrisO *xorriso, off_t mem, int flag) +{ + char mem_text[80]; + + Sfile_scale((double) mem, mem_text,5,1e4,1); + sprintf(xorriso->info_text, + "Cannot allocate enough memory (%s) for pattern expansion", + mem_text); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(1); +} + + +int Xorriso_no_malloc_memory(struct XorrisO *xorriso, char **to_free, int flag) +{ + if(to_free!=NULL) + if(*to_free!=NULL) { + /* Eventual memory sacrifice to get on going */ + free(*to_free); + *to_free= NULL; + } + sprintf(xorriso->info_text, "Out of virtual memory"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "ABORT", 0); + return(1); +} + + +int Xorriso_alloc_pattern_mem(struct XorrisO *xorriso, off_t mem, + int count, char ***filev, int flag) +{ + char mem_text[80], limit_text[80]; + + Sfile_scale((double) mem, mem_text,5,1e4,0); + sprintf(xorriso->info_text, + "Temporary memory needed for pattern expansion : %s", mem_text); + if(!(flag&1)) + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + if(mem > xorriso->temp_mem_limit) { + Sfile_scale((double) xorriso->temp_mem_limit, limit_text,5,1e4,1); + sprintf(xorriso->info_text, + "List of matching file addresses exceeds -temp_mem_limit (%s > %s)", + mem_text, limit_text); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + + (*filev)= (char **) calloc(count, sizeof(char *)); + if(*filev==NULL) { + Xorriso_no_pattern_memory(xorriso, mem, 0); + return(-1); + } + return(1); +} + + +/* @param flag bit0= a match count !=1 is a FAILURE event + bit1= with bit0 tolerate 0 matches if pattern is a constant +*/ +int Xorriso_expand_disk_pattern(struct XorrisO *xorriso, + int num_patterns, char **patterns, int extra_filec, + int *filec, char ***filev, off_t *mem, int flag) +{ + int ret, count= 0, abs_adr= 0, i, was_count, was_filec; + int nonconst_mismatches= 0, dive_count= 0; + char sfe[5*SfileadrL], dir_adr[SfileadrL]; + + *filec= 0; + *filev= NULL; + + xorriso->search_mode= 3; + xorriso->structured_search= 1; + + for(i= 0; i<num_patterns; i++) { + + ret= Xorriso_prepare_expansion_pattern(xorriso, patterns[i], 4); + if(ret<=0) + return(ret); + if(ret==2) + abs_adr= 4; + + if(patterns[i][0]=='/' || abs_adr) { + strcpy(dir_adr, "/"); + abs_adr= 4; + } else { + strcpy(dir_adr, xorriso->wdx); + if(dir_adr[0]==0) + strcpy(dir_adr, "/"); + ret= Sfile_type(dir_adr, 1|4); + if(ret!=2) { + Xorriso_msgs_submit(xorriso, 0, dir_adr, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "Address set by -cdx is not a directory: %s", + Text_shellsafe(dir_adr, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + } + + /* count the matches */ + was_count= count; + ret= Xorriso_obtain_pattern_files_x(xorriso, "", dir_adr, &count, NULL, 0, + mem, &dive_count, 1 | abs_adr); + if(ret<=0) + goto ex; + if(was_count==count && strcmp(patterns[i],"*")!=0 && (flag&3)!=1) { + count++; + ret= Xorriso_eval_nonmatch(xorriso, patterns[i], + &nonconst_mismatches, mem, 0); + if(ret<=0) + goto ex; + } + } + + ret= Xorriso_check_matchcount(xorriso, count, nonconst_mismatches, + num_patterns, patterns, (flag&1)|2); + if(ret<=0) + goto ex; + + count+= extra_filec; + mem+= extra_filec*sizeof(char *); + + if(count<=0) + {ret= 0; goto ex;} + + ret= Xorriso_alloc_pattern_mem(xorriso, *mem, count, filev, 0); + if(ret<=0) + goto ex; + + /* now store addresses */ + for(i= 0; i<num_patterns; i++) { + + ret= Xorriso_prepare_expansion_pattern(xorriso, patterns[i], 4); + if(ret<=0) + return(ret); + + if(patterns[i][0]=='/' || abs_adr) { + strcpy(dir_adr, "/"); + abs_adr= 4; + } else { + strcpy(dir_adr, xorriso->wdx); + if(dir_adr[0]==0) + strcpy(dir_adr, "/"); + } + + was_filec= *filec; + ret= Xorriso_obtain_pattern_files_x(xorriso, "", dir_adr, filec, *filev, + count, mem, &dive_count, abs_adr); + if(ret<=0) + goto ex; + + if(was_filec == *filec && strcmp(patterns[i],"*")!=0) { + (*filev)[*filec]= strdup(patterns[i]); + if((*filev)[*filec]==NULL) { + (*mem)= strlen(patterns[i])+1; + Xorriso_no_pattern_memory(xorriso, *mem, 0); + ret= -1; goto ex; + } + (*filec)++; + } + } + + ret= 1; +ex:; + if(ret<=0) { + if(filev!=NULL) + Sfile_destroy_argv(&count, filev, 0); + *filec= 0; + } + return(ret); +} + + +/* @param flag bit0= command without pattern capability + bit1= disk_pattern rather than iso_rr_pattern +*/ +int Xorriso_warn_of_wildcards(struct XorrisO *xorriso, char *path, int flag) +{ + if(strchr(path,'*')!=NULL || strchr(path,'?')!=NULL || + strchr(path,'[')!=NULL) { + if(flag&1) { + sprintf(xorriso->info_text, + "Pattern expansion of wildcards \"*?[\" does not apply to this command"); + } else { + sprintf(xorriso->info_text, + "Pattern expansion of wildcards \"*?[\" is disabled by command %s", + (flag&2) ? "-disk_pattern or -pathspecs" : "-iso_rr_pattern"); + } + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + sprintf(xorriso->info_text,"Pattern seen: %s\n", path); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + return(1); + } + return(0); +} + + +/* @param flag bit0= do not warn of wildcards + bit1= these are disk_paths +*/ +int Xorriso_end_idx(struct XorrisO *xorriso, + int argc, char **argv, int idx, int flag) +{ + int i, warned= 0; + + for(i= idx; i<argc; i++) { + if(strcmp(argv[i], xorriso->list_delimiter)==0) + break; + if(!((flag&1) || warned)) + warned= Xorriso_warn_of_wildcards(xorriso, argv[i], flag&2); + } + return(i); +} + + +/* Returns a vector of strings which belong to an open ended arg list. + If expansion is enabled, the vector might be allocated, else it is + a pointer into the argv input vector. + Thus the release of that memory is an expert task to be done by this + function only. Use bit8 for that. With bit8 parameter argc MUST be the + same value as with the call which might have allocated memory. + @param xorriso The environment object + @param argc Length of argv + @param argv The vector with arguments, eventual list_delimiter ("--") + and then eventual unrelated words + @param idx Start index in argv of the argument list + @param optc Length of the effective possibly expanded option vector + @param optv The option vector. Maybe a pointer into argv or maybe + an own allocated vector. + @param flag bit0= do not warn of wildcards + bit1= these are disk_paths + bit2= never expand wildcards + bit3= do not expand last argument + bit4= ignore last argument + bit5= demand exactly one match + bit6= with bit5 allow 0 matches if pattern is a constant + bit7= silently tolerate empty argument list + bit8= free the eventually allocated sub_vector +*/ +int Xorriso_opt_args(struct XorrisO *xorriso, char *cmd, + int argc, char **argv, int idx, + int *end_idx, int *optc, char ***optv, int flag) +{ + int i, do_expand, nump, was_empty= 0, filec= 0, ret; + char **filev= NULL, **patterns= NULL; + off_t mem= 0; + + if(flag&2) + do_expand= xorriso->do_disk_pattern==1 && !(flag&4); + else + do_expand= xorriso->do_iso_rr_pattern==1 && !(flag&4); + if(flag&256) { + if(*optv<argv || *optv>=argv+argc) + Sfile_destroy_argv(optc, optv, 0); + return(1); + } + if(idx>=argc) { + *end_idx= argc; + *optc= 0; + *optv= NULL; + sprintf(xorriso->info_text, "%s : Not enough arguments given", cmd); + if((flag & 128)) + return(1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + *end_idx= Xorriso_end_idx(xorriso, argc, argv, idx, + ((flag&1) || do_expand) | (flag&2)); + if(*end_idx<0) + return(*end_idx); + if((flag&16) && (*end_idx)>idx) + (*end_idx)--; + *optc= *end_idx - idx; + *optv= argv+idx; + if(*optc<=0 || !do_expand) + return(1); + patterns= calloc(*optc, sizeof(char *)); + if(patterns==NULL) { +no_memory:; + sprintf(xorriso->info_text, + "%s : Cannot allocate enough memory for pattern expansion", cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + nump= 0; + if(flag&8) { + was_empty= 1; + mem+= strlen(argv[idx + *optc - 1])+1+sizeof(char *); + } + for(i= 0; i<*optc-!!(flag&8); i++) { + if(argv[i + idx][0]==0) { + was_empty++; + mem+= sizeof(char *); /* as upper limit for size of an empty string */ + continue; + } + patterns[nump++]= argv[i + idx]; + } + if(nump<=0) { /* Only empty texts. May the caller get happy with them. */ + free(patterns); + return(1); + } + if(flag&2) + ret= Xorriso_expand_disk_pattern(xorriso, nump, patterns, was_empty, + &filec, &filev, &mem, (flag>>5)&3); + else + ret= Xorriso_expand_pattern(xorriso, nump, patterns, was_empty, + &filec, &filev, &mem, (flag>>5)&3); + if(ret<=0) + {ret= 0; goto ex;} + for(i= 0; i<was_empty; i++) { + if(i==was_empty-1 && (flag&8)) + filev[filec++]= strdup(argv[idx + *optc - 1]); + else + filev[filec++]= strdup(""); + if(filev[filec-1]==NULL) + goto no_memory; + } + +#ifdef Xorriso_verbous_pattern_expansioN +{ int l; + sprintf(xorriso->info_text, "Pattern expansion yields %d items:", filec); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + l= 0; + xorriso->info_text[0]= 0; + for(i= 0; i<filec; i++) { + l= strlen(xorriso->info_text); + if(l>0 && l+1+strlen(filev[i])>60) { + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + xorriso->info_text[0]= 0; + l= 0; + } + sprintf(xorriso->info_text+l, " %s", filev[i]); + } + l= strlen(xorriso->info_text); + if(l>0) + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); +} +#endif /* Xorriso_verbous_pattern_expansioN */ + + ret= 1; +ex:; + if(ret<=0) { + if(patterns!=NULL) + free((char *) patterns); + Sfile_destroy_argv(&filec, &filev, 0); + } else { + *optc= filec; + *optv= filev; + } + return(ret); +} + + +int Xorriso_get_problem_status(struct XorrisO *xorriso, char severity[80], + int flag) +{ + strcpy(severity, xorriso->problem_status_text); + return(xorriso->problem_status); +} + + +int Xorriso_set_problem_status(struct XorrisO *xorriso, char *severity, + int flag) +{ + char *sev_text= "ALL"; + int sev, ret; + + if(severity[0]) + sev_text= severity; + ret= Xorriso__text_to_sev(sev_text, &sev, 0); + if(ret<=0) + return(0); + xorriso->problem_status= sev; + strcpy(xorriso->problem_status_text, sev_text); + if(sev > xorriso->eternal_problem_status) { + xorriso->eternal_problem_status= sev; + strcpy(xorriso->eternal_problem_status_text, sev_text); + } + return(1); +} + + +/* @param flag bit0-7= purpose + 0= ERRFILE + 1= mark line (only to be put out if enabled) +*/ +int Xorriso_process_errfile(struct XorrisO *xorriso, + int error_code, char msg_text[], int os_errno, + int flag) +{ + char ttx[41]; + int purpose; + + if(strlen(msg_text)>SfileadrL) + return(-1); + + purpose= flag&255; + if(purpose==1 && !(xorriso->errfile_mode&1)) + return(2); + if(xorriso->errfile_fp!=NULL) { + if(purpose==1) + fprintf(xorriso->errfile_fp, "----------------- %s %s\n", + msg_text, Ftimetxt(time(0), ttx, 1)); + else + fprintf(xorriso->errfile_fp, "%s\n", msg_text); + fflush(xorriso->errfile_fp); + return(1); + } + if(xorriso->errfile_log[0]==0) + return(1); + if(strcmp(xorriso->errfile_log, "-")==0 || + strcmp(xorriso->errfile_log, "-R")==0) { + if(purpose==1) + sprintf(xorriso->result_line, "----------------- %s %s\n", + msg_text, Ftimetxt(time(0), ttx, 1)); + else + sprintf(xorriso->result_line, "%s\n", msg_text); + Xorriso_result(xorriso, 1); + return(1); + } + if(strcmp(xorriso->errfile_log, "-I")==0) { + if(purpose==1) + sprintf(xorriso->info_text, "ERRFILE_MARK=%s %s\n", + msg_text, Ftimetxt(time(0), ttx, 1)); + else + sprintf(xorriso->info_text, "ERRFILE=%s", msg_text); + Xorriso_info(xorriso, 0); + return(1); + } + return(2); +} + + +/* Note: It is ok to submit xorriso->info_text as msg_text here. */ +/* flag: + bit0= for Xorriso_info() : use pager (as with result) + bit1= for Xorriso_info() : permission to suppress output + bit2..5= name prefix + 0="xorriso" + 1="libisofs" + 2="libburn" + 3="libisoburn" + else: "" + bit6= append carriage return rather than line feed (if not os_errno) + bit7= perform Xorriso_process_msg_queues() first +*/ +int Xorriso_msgs_submit(struct XorrisO *xorriso, + int error_code, char msg_text[], int os_errno, + char severity[], int flag) +{ + int ret, lt, li, sev, i; + char *sev_text= "FATAL", prefix[80]; + static char pfx_list[20][16]= { + "xorriso : ", "libisofs: ", "libburn : ", "libisoburn: ", + "", "", "", "", "", "", "", "", "", "", "", "" }; + + if(flag&128) + Xorriso_process_msg_queues(xorriso, 0); + + if(strcmp(severity, "ERRFILE")==0) + Xorriso_process_errfile(xorriso, error_code, msg_text, os_errno, 0); + + /* Set problem status */ + ret= Xorriso__text_to_sev(severity, &sev, 0); + if(ret<=0) + Xorriso__text_to_sev(sev_text, &sev, 0); + else + sev_text= severity; + if(xorriso->problem_status<sev) { + xorriso->problem_status= sev; + strcpy(xorriso->problem_status_text, sev_text); + } + if(xorriso->eternal_problem_status<sev) { + xorriso->eternal_problem_status= sev; + strcpy(xorriso->eternal_problem_status_text, sev_text); + } + + /* Report problem event */ + if(sev<xorriso->report_about_severity && sev<xorriso->abort_on_severity) + return(2); + sprintf(prefix,"%s%s : ", pfx_list[(flag>>2)&15], sev_text); + li= strlen(prefix); + lt= strlen(msg_text); + if(lt>sizeof(xorriso->info_text)-li-2) + lt= sizeof(xorriso->info_text)-li-2; + if(msg_text==xorriso->info_text) { + for(i= lt; i>=0; i--) + msg_text[i+li]= msg_text[i]; + for(i=0; i<li; i++) + msg_text[i]= prefix[i]; + } else { + strcpy(xorriso->info_text, prefix); + strncpy(xorriso->info_text+li, msg_text, lt); + } + if((flag&64) && os_errno<=0) + xorriso->info_text[li+lt]= '\r'; + else + xorriso->info_text[li+lt]= '\n'; + xorriso->info_text[li+lt+1]= 0; + Xorriso_info(xorriso,4|(flag&3)); + if(os_errno>0) { + sprintf(xorriso->info_text, "%ssys : %s\n", + pfx_list[(flag>>2)&15], strerror(os_errno)); + Xorriso_info(xorriso,4|(flag&3)); + } + return(1); +} + + +/* To be used with isoburn_set_msgs_submit() +*/ +int Xorriso_msgs_submit_void(void *xorriso, + int error_code, char msg_text[], int os_errno, + char severity[], int flag) +{ + int ret; + + ret= Xorriso_msgs_submit((struct XorrisO *) xorriso, error_code, msg_text, + os_errno, severity, flag); + return(ret); +} + + +/** + @param flag bit0= do not issue own event messages + bit1= take xorriso->request_to_abort as reason for abort + @return Gives the advice: + 2= pardon was given, go on + 1= no problem, go on + 0= function failed but xorriso would not abort, go on + <0= do abort + -1 = due to problem_status + -2 = due to xorriso->request_to_abort +*/ +int Xorriso_eval_problem_status(struct XorrisO *xorriso, int ret, int flag) +{ + static int sev= 0; + if(sev==0) + Xorriso__text_to_sev("SORRY", &sev, 0); + + if((flag&2) && xorriso->request_to_abort) + return(-2); + + Xorriso_process_msg_queues(xorriso, 0); + if(ret>0 && xorriso->problem_status <= 0) + return(1); + + if(xorriso->problem_status < xorriso->abort_on_severity && + xorriso->problem_status > 0) { + if(xorriso->problem_status >= sev && !(flag&1)) { + sprintf(xorriso->info_text, + "xorriso : NOTE : Tolerated problem event of severity '%s'\n", + xorriso->problem_status_text); + Xorriso_info(xorriso, 0);/* submit not as problem event */ + } + ret= 2; + } else if(xorriso->problem_status > 0) { + sprintf(xorriso->info_text, + "xorriso : aborting : -abort_on '%s' encountered '%s'\n", + xorriso->abort_on_text, xorriso->problem_status_text); + if(!(flag&1)) + Xorriso_info(xorriso, 0);/* submit not as problem event */ + ret= -1; + } else if(ret>0) + ret= 1; + else + ret= 2; + return(ret); +} + + +int Xorriso_convert_uidstring(struct XorrisO *xorriso, char *uid_string, + uid_t *uid, int flag) +{ + double num; + char text[80]; + struct passwd *pwd; + + sscanf(uid_string, "%lf", &num); + sprintf(text,"%.f",num); + if(strcmp(text,uid_string)==0) { + *uid= num; + return(1); + } + pwd= getpwnam(uid_string); + if(pwd==NULL) { + sprintf(xorriso->info_text, "-uid: Not a known user: '%s'", uid_string); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + *uid= pwd->pw_uid; + return(1); +} + + +int Xorriso_convert_gidstring(struct XorrisO *xorriso, char *gid_string, + gid_t *gid, int flag) +{ + double num; + char text[80]; + struct group *grp; + + sscanf(gid_string, "%lf", &num); + sprintf(text,"%.f",num); + if(strcmp(text,gid_string)==0) { + *gid= num; + return(1); + } + grp= getgrnam(gid_string); + if(grp==NULL) { + sprintf(xorriso->info_text, "-gid: Not a known group: '%s'", gid_string); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + *gid= grp->gr_gid; + return(1); +} + + +int Xorriso_convert_modstring(struct XorrisO *xorriso, char *cmd, char *mode, + mode_t *mode_and, mode_t *mode_or, int flag) +{ + int who_val= 0; + char sfe[5*SfileadrL], *mpt, *vpt, *opt; + unsigned int num= 0; + mode_t mode_val,mask; + + *mode_and= ~0; + *mode_or= 0; + if(mode[0]=='0') { + *mode_and= 0; + sscanf(mode,"%o",&num); + *mode_or= num; + } else if(strchr(mode,'+')!=NULL || strchr(mode,'-')!=NULL + || strchr(mode,'=')!=NULL) { + /* [ugoa][+-][rwxst] */; + for(mpt= mode; mpt!=NULL; mpt= strchr(mpt, ',')) { + if(*mpt==',') + mpt++; + if(strlen(mpt)<2) + goto unrecognizable; + who_val= 0; + for(vpt= mpt; *vpt!='+' && *vpt!='-' && *vpt!='='; vpt++) { + if(*vpt=='u') + who_val|= 4; + else if(*vpt=='g') + who_val|= 2; + else if(*vpt=='o') + who_val|= 1; + else if(*vpt=='a') + who_val|= 7; + else + goto unrecognizable; + } + opt= vpt; + mode_val= 0; + for(vpt= opt+1; *vpt!=0 && *vpt!=','; vpt++) { + if(*vpt=='r') { + if(who_val&4) + mode_val|= S_IRUSR; + if(who_val&2) + mode_val|= S_IRGRP; + if(who_val&1) + mode_val|= S_IROTH; + } else if(*vpt=='w') { + if(who_val&4) + mode_val|= S_IWUSR; + if(who_val&2) + mode_val|= S_IWGRP; + if(who_val&1) + mode_val|= S_IWOTH; + } else if(*vpt=='x') { + if(who_val&4) + mode_val|= S_IXUSR; + if(who_val&2) + mode_val|= S_IXGRP; + if(who_val&1) + mode_val|= S_IXOTH; + } else if(*vpt=='s') { + if(who_val&4) + mode_val|= S_ISUID; + if(who_val&2) + mode_val|= S_ISGID; + } else if(*vpt=='t') { + if(who_val&1) + mode_val|= S_ISVTX; + } else + goto unrecognizable; + } + if(*opt=='+') { + (*mode_or)|= mode_val; + } else if(*opt=='=') { + mask= 0; + if(who_val&1) + mask|= S_IRWXO|S_ISVTX; + if(who_val&2) + mask|= S_IRWXG|S_ISGID; + if(who_val&4) + mask|= S_IRWXU|S_ISUID; + (*mode_and)&= ~(mask); + (*mode_or)= ((*mode_or) & ~mask) | mode_val; + } else if(*opt=='-') { + (*mode_or)&= ~mode_val; + (*mode_and)&= ~mode_val; + } + } + } else { +unrecognizable:; + sprintf(xorriso->info_text, + "%s: Unrecognizable or faulty permission mode %s\n", cmd, + Text_shellsafe(mode, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + return(1); +} + + +int Xorriso_convert_datestring(struct XorrisO *xorriso, char *cmd, + char *time_type, char *timestring, + int *t_type, time_t *t, int flag) +{ + int ret; + + if(strcmp(time_type, "a")==0) + (*t_type)|= 1; + else if(strcmp(time_type, "m")==0) + (*t_type)|= 4; + else if(strcmp(time_type, "b")==0) + (*t_type)|= 5; + else { + sprintf(xorriso->info_text, "%s: Unrecognized type '%s'", cmd, time_type); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + ret= Decode_timestring(timestring, t, 0); + if(ret<=0) { + sprintf(xorriso->info_text, "%s: Cannot decode timestring '%s'", cmd, + timestring); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + sprintf(xorriso->info_text, "Understanding timestring '%s' as: %s", + timestring, ctime(t)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + return(1); +} + + +/* @param flag bit0=path is in source filesystem , bit1= unconditionally */ +int Xorriso_much_too_long(struct XorrisO *xorriso, int len, int flag) +{ + if(len>=SfileadrL || (flag&2)) { + sprintf(xorriso->info_text, + "Path given for %s is much too long (%d)", + ((flag&1) ? "local filesystem" : "ISO image"), len); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(1); +} + + +int Xorriso_no_findjob(struct XorrisO *xorriso, char *cmd, int flag) +{ + sprintf(xorriso->info_text, "%s: cannot create find job object", cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(1); +} + + +/* @param flag bit1= do not report memory usage as DEBUG +*/ +int Xorriso_check_temp_mem_limit(struct XorrisO *xorriso, off_t mem, int flag) +{ + char mem_text[80], limit_text[80]; + + Sfile_scale((double) mem, mem_text,5,1e4,0); + if(!(flag&2)) { + sprintf(xorriso->info_text, + "Temporary memory needed for result sorting : %s", mem_text); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + } + if(mem > xorriso->temp_mem_limit) { + Sfile_scale((double) xorriso->temp_mem_limit,limit_text,5,1e4,1); + sprintf(xorriso->info_text, + "Cannot sort. List of matching files exceeds -temp_mem_limit (%s > %s)", + mem_text, limit_text); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + return(0); + } + return(1); +} + + +/* @param flag bit0= for Xorriso_msgs_submit: use pager + bit1= do not issue warnings +*/ +int Xorriso_hop_link(struct XorrisO *xorriso, char *link_path, + struct LinkiteM **link_stack, struct stat *stbuf, int flag) +{ + int ret; + struct LinkiteM *litm; + char sfe[5*SfileadrL]; + + if(*link_stack != NULL) { + if((*link_stack)->link_count>=xorriso->follow_link_limit) { + sprintf(xorriso->info_text, + "Too many symbolic links in single tree branch at : %s", + Text_shellsafe(link_path, sfe, 0)); + if(!(flag&2)) + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0,"WARNING",flag&1); + return(0); + } + } + ret= stat(link_path, stbuf); + if(ret==-1) + return(0); + ret= Linkitem_find(*link_stack, stbuf->st_dev, stbuf->st_ino, &litm, 0); + if(ret>0) { + sprintf(xorriso->info_text, + "Detected symbolic link loop around : %s", + Text_shellsafe(link_path, sfe, 0)); + if(!(flag&2)) + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", flag&1); + return(0); + } + ret= Linkitem_new(&litm, link_path, stbuf->st_dev, stbuf->st_ino, + *link_stack, 0); + if(ret<=0) { + sprintf(xorriso->info_text, + "Cannot add new item to link loop prevention stack"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", flag&1); + return(-1); + } + *link_stack= litm; + return(1); +} + + +/* @param flag bit0= do not only sum up sizes but also print subdirs + bit1= this is a recursion + @return <=0 error , 1 ok , 2 could not open directory +*/ +int Xorriso_show_dux_subs(struct XorrisO *xorriso, + char *abs_path, char *rel_path, off_t *size, + off_t boss_mem, + struct LinkiteM *link_stack, + int flag) +{ + int i, ret, no_sort= 0, filec= 0, l, j, fc, no_dive, is_link; + char **filev= NULL, *namept; + off_t sub_size, report_size, mem= 0; + struct DirseQ *dirseq= NULL; + struct stat stbuf; + dev_t dir_dev; + struct LinkiteM *own_link_stack; + char *path= NULL, *show_path= NULL, *name= NULL, *sfe= NULL; + + sfe= malloc(5*SfileadrL); + path= malloc(SfileadrL); + show_path= malloc(SfileadrL); + name= malloc(SfileadrL); + if(path==NULL || show_path==NULL || name==NULL || sfe==NULL) { + Xorriso_no_malloc_memory(xorriso, &sfe, 0); + {ret= -1; goto ex;} + } + own_link_stack= link_stack; + namept= name; + *size= 0; + + if(lstat(abs_path, &stbuf)==-1) + {ret= 2; goto ex;} + dir_dev= stbuf.st_dev; + if(S_ISLNK(stbuf.st_mode)) { + if(!(xorriso->do_follow_links || (xorriso->do_follow_param && !(flag&2)))) + {ret= 2; goto ex;} + if(stat(abs_path, &stbuf)==-1) + {ret= 2; goto ex;} + if(dir_dev != stbuf.st_dev && + !(xorriso->do_follow_mount || (xorriso->do_follow_param && !(flag&2)))) + {ret= 2; goto ex;} + } + ret= Dirseq_new(&dirseq, abs_path, 1); + if(ret<0) { + sprintf(xorriso->info_text, "Cannot obtain disk directory iterator"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + if(ret==0) + {ret= 2; goto ex;} + + while(1) { + Linkitem_reset_stack(&own_link_stack, link_stack, 0); + ret= Dirseq_next_adr(dirseq,name,0); + if(ret<0) + goto ex; + if(ret==0) + break; + + sub_size= 0; + strcpy(show_path, rel_path); + if(Sfile_add_to_path(show_path, name, 0)<=0) + goto much_too_long; + + strcpy(path, abs_path); + if(Sfile_add_to_path(path, name, 0)<=0) { +much_too_long:; + Xorriso_much_too_long(xorriso, strlen(path)+strlen(name)+1, 2); + {ret= -1; goto ex;} + } + no_dive= 0; + + ret= lstat(path, &stbuf); + if(ret==-1) + continue; + is_link= S_ISLNK(stbuf.st_mode); + if(is_link && xorriso->do_follow_links) { + ret= Xorriso_hop_link(xorriso, path, &own_link_stack, &stbuf, 1); + if(ret<0) + {ret= -1; goto ex;} + if(ret!=1) + no_dive= 1; + } + if(!S_ISDIR(stbuf.st_mode)) + no_dive= 1; + if(dir_dev != stbuf.st_dev && !xorriso->do_follow_mount) + no_dive= 1; + if(!no_dive) { + filec++; + l= strlen(rel_path)+1; + mem+= l; + if(l % sizeof(char *)) + mem+= sizeof(char *)-(l % sizeof(char *)); + if(flag&1) /* diving and counting is done further below */ + continue; + ret= Xorriso_show_dux_subs(xorriso, path, show_path, &sub_size, boss_mem, + own_link_stack,2); + if(ret<0) + goto ex; + if(ret==0) + continue; + } + +/* + sub_size+= stbuf.st_size+strlen(name)+1; +*/ + sub_size+= stbuf.st_size+2048; + if(sub_size>0) + (*size)+= sub_size; + } + + if(filec<=0 || !(flag&1)) + {ret= 1; goto ex;} + + /* Try to get a sorted list of directory names */ + mem+= (filec+1)*sizeof(char *); + ret= Xorriso_check_temp_mem_limit(xorriso, mem+boss_mem, 2); + if(ret<0) + goto ex; + Dirseq_rewind(dirseq, 0); + if(ret==0) { +no_sort_possible:; + no_sort= 1; + } else { + filev= (char **) calloc(filec+1, sizeof(char *)); + if(filev==NULL) + goto no_sort_possible; + else { + for(i= 0; i<filec; i++) + filev[i]= NULL; + fc= 0; + while(1) { + ret= Dirseq_next_adr(dirseq,name,0); + if(ret<0) + goto ex; + if(ret==0) + break; + strcpy(path, abs_path); + if(Sfile_add_to_path(path, name, 0)<=0) + goto much_too_long; + + ret= lstat(path,&stbuf); + if(ret==-1) + continue; + is_link= S_ISLNK(stbuf.st_mode); + if(is_link && xorriso->do_follow_links) { + ret= stat(path,&stbuf); + if(ret==-1) + continue; + } + if(!S_ISDIR(stbuf.st_mode)) + continue; + if(dir_dev != stbuf.st_dev && !xorriso->do_follow_mount) + continue; + + if(fc>=filec) { /* Number of files changed (or programming error) */ +revoke_sorting:; + for(j=0; j<fc; j++) + free((char *) filev[j]); + free((char *) filev); + filev= NULL; + goto no_sort_possible; + } + + filev[fc]= strdup(name); + if(filev[fc]==NULL) + goto revoke_sorting; + fc++; + } + filec= fc; + if(filec>1) + Sort_argv(filec, filev, 0); + } + } + + for(i= 0; (no_sort || i<filec) && !(xorriso->request_to_abort); i++) { + Linkitem_reset_stack(&own_link_stack, link_stack, 0); + if(no_sort) { + ret= Dirseq_next_adr(dirseq,name,0); + if(ret<0) + goto ex; + if(ret==0) + break; + } else + namept= filev[i]; + + sub_size= 0; + strcpy(show_path, rel_path); + if(Sfile_add_to_path(show_path, namept, 0)<=0) + goto much_too_long; + strcpy(path, abs_path); + if(Sfile_add_to_path(path, namept, 0)<=0) + goto much_too_long; + no_dive= 0; + + ret= lstat(path,&stbuf); + if(ret==-1) + continue; + is_link= S_ISLNK(stbuf.st_mode); + if(is_link && xorriso->do_follow_links) { + ret= Xorriso_hop_link(xorriso, path, &own_link_stack, &stbuf, 1); + if(ret<0) + {ret= -1; goto ex;} + if(ret!=1) + continue; + } + if(!S_ISDIR(stbuf.st_mode)) + continue; + if(dir_dev == stbuf.st_dev || xorriso->do_follow_mount) { + ret= Xorriso_show_dux_subs(xorriso, path, show_path, &sub_size, + boss_mem+mem, own_link_stack, 2|(flag&1)); + if(ret<0) + goto ex; + } + +/* + sub_size+= stbuf.st_size+strlen(namept)+1; +*/ + sub_size+= stbuf.st_size+2048; + if(sub_size>0) + (*size)+= sub_size; + report_size= sub_size/1024; + if(report_size*1024<sub_size) + report_size++; + sprintf(xorriso->result_line, "%7.f ",(double) (report_size)); + sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s\n", + Text_shellsafe(show_path, sfe, 0)); + Xorriso_result(xorriso, 0); + } + + ret= 1; +ex:; + if(sfe!=NULL) + free(sfe); + if(path!=NULL) + free(path); + if(show_path!=NULL) + free(show_path); + if(name!=NULL) + free(name); + Linkitem_reset_stack(&own_link_stack, link_stack, 0); + Dirseq_destroy(&dirseq, 0); + if(filev!=NULL) { + for(i=0; i<filec; i++) + if(filev[i]!=NULL) + free((char *) filev[i]); + free((char *) filev); + } + return(ret); +} + + +/* @param flag bit1= add '+' to perms +*/ +int Xorriso__mode_to_perms(mode_t st_mode, char perms[11], int flag) +{ + strcpy(perms,"--------- "); + if(st_mode&S_IRUSR) perms[0]= 'r'; + if(st_mode&S_IWUSR) perms[1]= 'w'; + if(st_mode&S_IXUSR) perms[2]= 'x'; + if(st_mode&S_ISUID) { + if(st_mode&S_IXUSR) + perms[2]= 's'; + else + perms[2]= 'S'; + } + if(st_mode&S_IRGRP) perms[3]= 'r'; + if(st_mode&S_IWGRP) perms[4]= 'w'; + if(st_mode&S_IXGRP) perms[5]= 'x'; + if(st_mode&S_ISGID) { + if(st_mode&S_IXGRP) + perms[5]= 's'; + else + perms[5]= 'S'; + } + if(st_mode&S_IROTH) perms[6]= 'r'; + if(st_mode&S_IWOTH) perms[7]= 'w'; + if(st_mode&S_IXOTH) perms[8]= 'x'; + if(st_mode&S_ISVTX) { + if(st_mode&S_IXOTH) + perms[8]= 't'; + else + perms[8]= 'T'; + } + if(flag & 2) + perms[9]= '+'; + return(1); +} + + +/* @param flag bit0= recognize Xorriso_IFBOOT as file type + bit1= add '+' to perms +*/ +int Xorriso_format_ls_l(struct XorrisO *xorriso, struct stat *stbuf, int flag) +{ + int show_major_minor= 0, high_shift= 0, high_mask= 0; + char *rpt, perms[11], mm_text[80]; + mode_t st_mode; + dev_t dev, major, minor; + + rpt= xorriso->result_line; + rpt[0]= 0; + st_mode= stbuf->st_mode; + + if(S_ISDIR(st_mode)) + strcat(rpt, "d"); + else if(S_ISREG(st_mode)) + strcat(rpt, "-"); + else if(S_ISLNK(st_mode)) + strcat(rpt, "l"); + else if(S_ISBLK(st_mode)) { + strcat(rpt, "b"); + show_major_minor= 1; + } else if(S_ISCHR(st_mode)) { + strcat(rpt, "c"); + show_major_minor= 1; + } else if(S_ISFIFO(st_mode)) + strcat(rpt, "p"); + else if(S_ISSOCK(st_mode)) + strcat(rpt, "s"); + else if((flag & 1) && (st_mode & S_IFMT) == Xorriso_IFBOOT) + strcat(rpt, "e"); + else + strcat(rpt, "?"); + + Xorriso__mode_to_perms(st_mode, perms, flag & 2); + strcat(rpt, perms); + + sprintf(rpt+strlen(rpt)," %3u ",(unsigned int) stbuf->st_nlink); + + sprintf(rpt+strlen(rpt), "%-8lu ", (unsigned long) stbuf->st_uid); + sprintf(rpt+strlen(rpt), "%-8lu ", (unsigned long) stbuf->st_gid); + if(show_major_minor) { + dev= stbuf->st_rdev; + + /* according to /usr/include/sys/sysmacros.h : gnu_dev_major(),_minor() + >>> but this looks as if it should go to some system dependency + >>> in FreeBSD dev_t is 32 bit + */ + if(sizeof(dev_t) > 4) { + high_shift= 32; + high_mask= ~0xfff; + } + major= (((dev >> 8) & 0xfff) | + ((unsigned int) (dev >> high_shift) & high_mask)) + & 0xffffffff; + minor= (((dev & 0xff) | ((unsigned int) (dev >> 12) & ~0xff))) & 0xffffffff; + + sprintf(mm_text, "%u,%u", (unsigned int) major, (unsigned int) minor); + sprintf(rpt+strlen(rpt), "%8s ", mm_text); + } else + sprintf(rpt+strlen(rpt), "%8.f ", (double) stbuf->st_size); + + Ftimetxt(stbuf->st_mtime, rpt+strlen(rpt), 0); + strcat(rpt, " "); + + return(1); +} + + +struct DirentrY { + char *adr; + struct DirentrY *next; +}; + + +int Xorriso_sorted_dir_x(struct XorrisO *xorriso, char *dir_path, + int *filec, char ***filev, off_t boss_mem, int flag) +{ + int count= 0, ret; + char name[SfileadrL]; + struct DirseQ *dirseq= NULL; + off_t mem; + struct DirentrY *last= NULL, *current= NULL; + + *filec= 0; + *filev= NULL; + mem= boss_mem; + ret= Dirseq_new(&dirseq, dir_path, 1); + if(ret<=0) + goto ex; + while(1) { /* loop over directory content */ + ret= Dirseq_next_adr(dirseq,name,0); + if(ret==0) + break; + if(ret<0) + goto ex; + mem+= strlen(name)+8+sizeof(struct DirentrY)+sizeof(char *); + if(mem>xorriso->temp_mem_limit) + {ret= 0; goto ex;} + + current= (struct DirentrY *) calloc(1, sizeof(struct DirentrY)); + if(current==NULL) + {ret= -1; goto ex;} + current->adr= NULL; + current->next= last; + last= current; + last->adr= strdup(name); + if(last->adr==NULL) + {ret= -1; goto ex;} + count++; + } + *filec= count; + if(count==0) + {ret= 1; goto ex;} + (*filev)= (char **) calloc(count, sizeof(char *)); + if(*filev==NULL) + {ret= -1; goto ex; } + count= 0; + for(current= last; current!=NULL; current= last) { + last= current->next; + (*filev)[count++]= current->adr; + free((char *) current); + } + Sort_argv(*filec, *filev, 0); + ret= 1; +ex:; + for(current= last; current!=NULL; current= last) { + last= current->next; + free(current->adr); + free((char *) current); + } + return(ret); +} + + +/* @param flag bit0= long format + bit1= do not print count of nodes + bit2= du format + bit3= print directories as themselves (ls -d) +*/ +int Xorriso_lsx_filev(struct XorrisO *xorriso, char *wd, + int filec, char **filev, off_t boss_mem, int flag) +{ + int i, ret, was_error= 0, dfilec= 0, pass, passes; + char sfe[5*SfileadrL], sfe2[5*SfileadrL], path[SfileadrL], *acl_text= NULL; + char *rpt, link_target[SfileadrL], **dfilev= NULL; + off_t size; + struct stat stbuf; + + rpt= xorriso->result_line; + + Sort_argv(filec, filev, 0); + + /* Count valid nodes, warn of invalid ones */ + for(i= 0; i<filec; i++) { + ret= Xorriso_make_abs_adr(xorriso, wd, filev[i], path, 1|2|4); + if(ret<=0) { + was_error++; + continue; + } + ret= lstat(path, &stbuf); + if(ret==-1) { + sprintf(xorriso->info_text, "Not found in local filesystem: %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 1); + was_error++; + continue; + } + } + + if((flag&8) && !(flag&(2|4))) { + sprintf(xorriso->info_text,"Valid local files found: %d\n",filec-was_error); + Xorriso_info(xorriso,1); + if(filec-was_error<=0) + return(!was_error); + } + + passes= 1+!(flag&(4|8)); + for(pass= 0; pass<passes; pass++) + for(i= 0; i<filec && !(xorriso->request_to_abort); i++) { + ret= Xorriso_make_abs_adr(xorriso, wd, filev[i], path, 1|2|4); + if(ret<=0) + continue; + ret= lstat(path, &stbuf); + if(ret==-1) + continue; + if(S_ISLNK(stbuf.st_mode) && + (xorriso->do_follow_links || xorriso->do_follow_param)) { + ret= stat(path, &stbuf); + if(ret==-1) + ret= lstat(path, &stbuf); + if(ret==-1) + continue; + } + if(S_ISDIR(stbuf.st_mode) && !(flag&(4|8))) { + if(pass==0) + continue; + if(filec>1) { + strcpy(xorriso->result_line, "\n"); + Xorriso_result(xorriso,0); + sprintf(xorriso->result_line, "%s:\n", Text_shellsafe(filev[i], sfe,0)); + Xorriso_result(xorriso,0); + } + ret= Xorriso_sorted_dir_x(xorriso, path, &dfilec, &dfilev, boss_mem, 0); + if(ret<=0) { + + /* >>> DirseQ loop and single item Xorriso_lsx_filev() */; + + } else { + if(flag&1) { + sprintf(xorriso->result_line, "total %d\n", dfilec); + Xorriso_result(xorriso,0); + } + Xorriso_lsx_filev(xorriso, path, + dfilec, dfilev, boss_mem, (flag&1)|2|8); + } + if(dfilec>0) + Sfile_destroy_argv(&dfilec, &dfilev, 0); + continue; + } else + if(pass>0) + continue; + link_target[0]= 0; + rpt[0]= 0; + if((flag&5)==1) { + Xorriso_local_getfacl(xorriso, path, &acl_text, 16); + ret= Xorriso_format_ls_l(xorriso, &stbuf, (acl_text != NULL) << 1); + Xorriso_local_getfacl(xorriso, path, &acl_text, 1 << 15); + if(ret<=0) + continue; + if(S_ISLNK(stbuf.st_mode)) { + ret= Xorriso_resolve_link(xorriso, path, link_target, 1); + if(ret<=0) + link_target[0]= 0; + } + } else if(flag&4) { /* -du or -dus */ + size= stbuf.st_size; + if(S_ISDIR(stbuf.st_mode)) { + ret= Xorriso_show_dux_subs(xorriso, path, filev[i], &size, boss_mem, + NULL, flag&1); + if(ret<0) + return(-1); + if(ret==0) + continue; + } + sprintf(rpt, "%7.f ",(double) (size/1024)); + } + if(link_target[0]) + sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s -> %s\n", + Text_shellsafe(filev[i], sfe, 0), + Text_shellsafe(link_target, sfe2, 0)); + else + sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s\n", + Text_shellsafe(filev[i], sfe, 0)); + Xorriso_result(xorriso, 0); + } + return(!was_error); +} + + +/* @param flag bit0= path is a directory + bit2= recursion: do not reassure in mode 2 "tree" + bit3= this is for overwriting and not for plain removal +*/ +int Xorriso_reassure_restore(struct XorrisO *xorriso, char *path, int flag) +{ + int ret; + char sfe[5*SfileadrL]; + + while((xorriso->do_reassure==1 || (xorriso->do_reassure==2 && !(flag&4))) + && !xorriso->request_not_to_ask) { + /* ls -ld */ + Xorriso_lsx_filev(xorriso, xorriso->wdx, 1, &path, (off_t) 0, 1|2|8); + if(flag&1) /* du -s */ + Xorriso_lsx_filev(xorriso, xorriso->wdx, 1, &path, (off_t) 0, 2|4); + if(flag&8) + sprintf(xorriso->info_text, + "File exists. Remove ? n= keep old, y= remove, x= abort, @= stop asking\n"); + else + sprintf(xorriso->info_text, + "Remove above file ? n= keep it, y= remove it, x= abort, @= stop asking\n"); + Xorriso_info(xorriso, 4); + ret= Xorriso_request_confirmation(xorriso, 1|2|4|16); + if(ret<=0) + goto ex; + if(xorriso->request_to_abort) { + sprintf(xorriso->info_text, + "Removal operation aborted by user before file: %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + ret= 3; goto ex; + } + if(ret==3) + continue; + if(ret==6) /* yes */ + break; + if(ret==4) { /* yes, do not ask again */ + xorriso->request_not_to_ask= 1; + break; + } + if(ret==1) { /* no */ + sprintf(xorriso->info_text, "Kept in existing state: %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + ret= 3; goto ex; + } + } + ret= 1; +ex: + return(ret); +} + + +/* + @param flag >>> bit0= remove whole sub tree: rm -r + bit1= remove empty directory: rmdir + bit2= recursion: do not reassure in mode 2 "tree" + bit3= this is for overwriting and not for plain removal + bit4= count deleted files in xorriso->pacifier_count + bit5= with bit0 only remove directory content, not the directory + bit6= permission to call Xorriso_make_accessible() + @return <=0 = error + 1 = removed leaf file object + 2 = removed directory or tree + 3 = did not remove on user revocation +*/ +int Xorriso_rmx(struct XorrisO *xorriso, off_t boss_mem, char *path, int flag) +{ + int ret, is_dir= 0, made_accessible= 0; + struct stat victim_stbuf, *victim_node= NULL; + struct DirseQ *dirseq= NULL; + char *sfe= NULL, *sub_path= NULL; + struct PermiteM *perm_stack_mem; + + perm_stack_mem= xorriso->perm_stack; + + /* Avoiding large local memory objects in order to save stack space */ + sfe= malloc(5*SfileadrL); + sub_path= malloc(2*SfileadrL); + if(sfe==NULL || sub_path==NULL) { + Xorriso_no_malloc_memory(xorriso, &sfe, 0); + {ret= -1; goto ex;} + } + + if(Xorriso_much_too_long(xorriso, strlen(path), 0)<=0) + {ret= 0; goto ex;} + + ret= lstat(path, &victim_stbuf); + if(ret==-1) { + if((flag & 64) && errno == EACCES) { + ret= Xorriso_make_accessible(xorriso, path, 0); + if(ret < 0) + goto ex; + made_accessible= 1; + ret= lstat(path, &victim_stbuf); + } + if(ret==-1) { + sprintf(xorriso->info_text, "Cannot lstat(%s)", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + {ret= 0; goto ex;} + } + } + if(strcmp(path, "/")==0) { + sprintf(xorriso->info_text, "May not delete root directory"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + victim_node= &victim_stbuf; + if(S_ISDIR(victim_stbuf.st_mode)) + is_dir= 1; + if(!is_dir) { + if(flag&2) { /* rmdir */ + sprintf(xorriso->info_text, "%s in disk filesystem is not a directory", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + } else { + if(flag&1) { /* rm -r */ + +#ifdef Osirrox_not_yeT + /* >>> */ + + if((xorriso->do_reassure==1 && !xorriso->request_not_to_ask) || + (flag&32)) { + /* Iterate over subordinates and delete them */ + mem= boss_mem; + + ret= Xorriso_findi_iter(xorriso, (IsoDir *) victim_node, &mem, + &iter, &node_array, &node_count, &node_idx, + &node, 1|2); + if(ret<=0) { +cannot_create_iter:; + Xorriso_cannot_create_iter(xorriso, ret, 0); + ret= -1; goto ex; + } + pl= strlen(path); + strcpy(sub_path, path); + if(pl==0 || sub_path[pl-1]!='/') { + sub_path[pl++]= '/'; + sub_path[pl]= 0; + } + sub_name= sub_path+pl; + while(1) { + ret= Xorriso_findi_iter(xorriso, (IsoDir *) victim_node, &mem, &iter, + &node_array, &node_count, &node_idx, &node, 0); + if(ret<0) + goto ex; + if(ret==0 || xorriso->request_to_abort) + break; + name= (char *) iso_node_get_name(node); + if(Xorriso_much_too_long(xorriso, pl+1+strlen(name), 0)<=0) + {ret= 0; goto rm_r_problem_handler;} + strcpy(sub_name, name); + ret= Xorriso_rmi(xorriso, iter, mem, sub_path, (flag&(1|2|8|16))|4); + if(ret==3 || ret<=0 || xorriso->request_to_abort) { +rm_r_problem_handler:; + not_removed= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret<0) + goto dir_not_removed; + } + } + if(flag&32) + {ret= 2; goto ex;} + + if(not_removed) { +dir_not_removed:; + sprintf(xorriso->info_text, "Directory not removed: %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + if(ret>0) + ret= 3; + goto ex; + } + } + +#else /* Osirrox_not_yeT */ + + sprintf(xorriso->info_text, "-rm_rx is not implemented yet"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + +#endif /* !Osirrox_not_yeT */ + + } else { + if(!(flag&2)) { /* not rmdir */ + sprintf(xorriso->info_text, "%s in disk filesystem is a directory", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + ret= Dirseq_new(&dirseq, path, 1); + if(ret>0) { + ret= Dirseq_next_adr(dirseq, sfe, 0); + if(ret>0) { + sprintf(xorriso->info_text, + "Directory not empty on attempt to delete: %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + } + } + } + if(xorriso->request_to_abort) + {ret= 3; goto ex;} + ret= Xorriso_reassure_restore(xorriso, path, (flag&(4|8)) | !!is_dir); + if(ret<=0 || ret==3) + goto ex; + if(is_dir) + ret= rmdir(path); + else + ret= unlink(path); + if(ret == -1) { + if((flag & 64) && errno == EACCES && !made_accessible) { + ret= Xorriso_make_accessible(xorriso, path, 0); + if(ret < 0) + goto ex; + made_accessible= 1; + if(is_dir) + ret= rmdir(path); + else + ret= unlink(path); + } + if(ret == -1) { + sprintf(xorriso->info_text, "Cannot delete from disk filesystem %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + ret= -1; goto ex; + } + } + if(flag&16) + xorriso->pacifier_count++; + ret= 1+!!is_dir; +ex:; + if(made_accessible) + Permstack_pop(&(xorriso->perm_stack), perm_stack_mem, xorriso, 0); + if(sfe!=NULL) + free(sfe); + if(sub_path!=NULL) + free(sub_path); + Dirseq_destroy(&dirseq, 0); + return(ret); +} + + +/* @param flag bit0= recursion +*/ +int Xorriso_findx_action(struct XorrisO *xorriso, struct FindjoB *job, + char *abs_path, char *show_path, int depth, int flag) +{ + int ret= 0, type, action= 0, dpl= 0, compare_result, uret; + uid_t user= 0; + gid_t group= 0; + time_t date= 0; + mode_t mode_or= 0, mode_and= ~1; + char *target, *text_2, sfe[5*SfileadrL], *disk_prefix, iso_path[SfileadrL]; + struct FindjoB *subjob; + struct stat stbuf; + + action= Findjob_get_action_parms(job, &target, &text_2, &user, &group, + &mode_and, &mode_or, &type, &date, &subjob, 0); + if(action<0) + action= 0; + if(action<0) + action= 0; + if(action==15 || action==16 || action==18 || action==19 || action==20) { + /* in_iso , not_in_iso, add_missing , empty_iso_dir , is_full_in_iso */ + Findjob_get_start_path(job, &disk_prefix, 0); + if(strncmp(abs_path, disk_prefix, strlen(disk_prefix))!=0) + {ret= -1; goto ex;} + dpl= strlen(disk_prefix); + if(strlen(target)+strlen(abs_path)-dpl >= SfileadrL) + {ret= -1; goto ex;} + if(abs_path[dpl]=='/') + dpl++; + ret= Xorriso_make_abs_adr(xorriso, target, abs_path+dpl, iso_path, 4); + if(ret<=0) + {goto ex;} + + } + if(action==15) { /* in_iso */ + ret= Xorriso_iso_lstat(xorriso, iso_path, &stbuf, 0); + if(ret<0) + {ret= 1; goto ex;} + sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0)); + Xorriso_result(xorriso, 0); + ret= 1; + } else if(action==16) { /* not_in_iso */ + ret= Xorriso_compare_2_files(xorriso, abs_path, iso_path, abs_path+dpl, + &compare_result, 4); + if(ret<xorriso->find_compare_result) + xorriso->find_compare_result= ret; + if(ret>=0) + ret= 1; + } else if(action==18) { /* add_missing */ + ret= Xorriso_compare_2_files(xorriso, abs_path, iso_path, abs_path+dpl, + &compare_result, 4|(1<<31)); + if(ret<xorriso->find_compare_result) + xorriso->find_compare_result= ret; + if(ret==0) { + uret= Xorriso_update_interpreter(xorriso, NULL, compare_result, + abs_path, iso_path, (flag&1)<<2); + if(uret<=0) + ret= 0; + } + if(ret>=0) + ret= 1; + } else if(action==19) { /* empty_iso_dir */ + ret= Xorriso_iso_lstat(xorriso, iso_path, &stbuf, 0); + if(ret<0) + {ret= 1; goto ex;} + if(!S_ISDIR(stbuf.st_mode)) + {ret= 1; goto ex;} + ret= Xorriso_rmi(xorriso, NULL, (off_t) 0, iso_path, 1|32); + if(ret>0) { + sprintf(xorriso->info_text, "Emptied directory %s", + Text_shellsafe(iso_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0); + } + } else if(action==20) { /* is_full_in_iso */ + ret= Xorriso_iso_lstat(xorriso, iso_path, &stbuf, 0); + if(ret<0) + {ret= 1; goto ex;} + if(!S_ISDIR(stbuf.st_mode)) + {ret= 1; goto ex;} + strcpy(sfe, xorriso->wdi); + strcpy(xorriso->wdi, iso_path); + ret= Xorriso_ls(xorriso, 4|8); + strcpy(xorriso->wdi, sfe); + if(ret>0) { + sprintf(xorriso->result_line, + "d %s (ISO) : non-empty directory (would not match mount point)\n", + Text_shellsafe(iso_path, sfe, 0)); + Xorriso_result(xorriso,0); + } + {ret= 1; goto ex;} + } else { + sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0)); + Xorriso_result(xorriso, 0); + ret= 1; + } +ex:; + if(action==15 || action==16 || action==18 || action==19 || action==20) + if(xorriso->no_volset_present) + xorriso->request_to_abort= 1; /* Need an image. No use to try again. */ + return(ret); +} + + +/* @param flag bit0=recursion +*/ +int Xorriso_findx(struct XorrisO *xorriso, struct FindjoB *job, + char *abs_dir_parm, char *dir_path, + struct stat *dir_stbuf, int depth, + struct LinkiteM *link_stack, int flag) +{ + int ret,is_link, no_dive; + struct DirseQ *dirseq= NULL; + struct stat stbuf; + struct LinkiteM *own_link_stack; + char *abs_dir_path, *namept; + char *name= NULL, *path= NULL, *sfe= NULL; + char *abs_dir_path_data= NULL, *abs_path= NULL; + + if(xorriso->request_to_abort) + {ret= 0; goto ex;} + + sfe= malloc(5*SfileadrL); + name= malloc(SfileadrL); + path= malloc(SfileadrL); + abs_dir_path_data= malloc(SfileadrL); + abs_path= malloc(SfileadrL); + if(name==NULL || sfe==NULL || path==NULL || + abs_dir_path_data==NULL || abs_path==NULL) { + Xorriso_no_malloc_memory(xorriso, &sfe, 0); + {ret= -1; goto ex;} + } + own_link_stack= link_stack; + abs_dir_path= abs_dir_parm; + if(abs_dir_path[0]==0) { + ret= Xorriso_make_abs_adr(xorriso, xorriso->wdx, dir_path, + abs_dir_path_data, 1|2|8); + if(ret<=0) + goto ex; + abs_dir_path= abs_dir_path_data; + ret= Xorriso_path_is_excluded(xorriso, abs_dir_path, !(flag&1)); + if(ret<0) + goto ex; + if(ret>0) + {ret= 0; goto ex;} + ret= lstat(abs_dir_path, dir_stbuf); + if(ret==-1) + {ret= 0; goto ex;} + if(S_ISLNK(dir_stbuf->st_mode) && + (xorriso->do_follow_links || (xorriso->do_follow_param && !(flag&1)))) + if(stat(abs_dir_path, &stbuf)!=-1) + if(dir_stbuf->st_dev == stbuf.st_dev || + (xorriso->do_follow_mount || (xorriso->do_follow_param && !(flag&1)))) + memcpy(dir_stbuf, &stbuf, sizeof(struct stat)); + + namept= strrchr(dir_path, '/'); + if(namept==NULL) + namept= dir_path; + else + namept++; + + ret= Findjob_test_2(xorriso, job, NULL, namept, dir_path, NULL, dir_stbuf, + 0); + if(ret<0) + goto ex; + if(ret>0) { + ret= Xorriso_findx_action(xorriso, job, abs_dir_path, dir_path, depth, + flag&1); + if(xorriso->request_to_abort) + {ret= 0; goto ex;} + if(ret<=0) { + if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0) + goto ex; + } + } + } + if(xorriso->request_to_abort) + {ret= 1; goto ex;} + if(!S_ISDIR(dir_stbuf->st_mode)) + {ret= 2; goto ex;} + + ret= Dirseq_new(&dirseq, abs_dir_path, 1); + if(ret<0) { + sprintf(xorriso->info_text, "Cannot obtain disk directory iterator"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + if(ret==0) + {ret= 2; goto ex;} + + while(!xorriso->request_to_abort) { + Linkitem_reset_stack(&own_link_stack, link_stack, 0); + ret= Dirseq_next_adr(dirseq,name,0); + if(ret==0) + break; + if(ret<0) { + sprintf(xorriso->info_text,"Failed to obtain next directory entry"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + ret= Xorriso_make_abs_adr(xorriso, abs_dir_path, name, abs_path, 1); + if(ret<=0) + goto ex; + ret= Xorriso_make_abs_adr(xorriso, dir_path, name, path, 4); + if(ret<=0) + goto ex; + ret= Xorriso_path_is_excluded(xorriso, abs_path, 0); /* (is never param) */ + if(ret<0) + goto ex; + if(ret>0) + continue; + ret= lstat(abs_path, &stbuf); + if(ret==-1) + continue; + no_dive= 0; + + is_link= S_ISLNK(stbuf.st_mode); + if(is_link && xorriso->do_follow_links) { + ret= Xorriso_hop_link(xorriso, abs_path, &own_link_stack, &stbuf, 2); + if(ret<0) + {ret= -1; goto ex;} + if(ret!=1) + no_dive= 1; + } + + ret= Findjob_test_2(xorriso, job, NULL, name, path, dir_stbuf, &stbuf, 0); + if(ret<0) + goto ex; + if(ret>0) { + ret= Xorriso_findx_action(xorriso, job, abs_path, path, depth, flag&1); + if(xorriso->request_to_abort) + {ret= 0; goto ex;} + if(ret<=0) { + if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0) + goto ex; + } + } + if(!S_ISDIR(stbuf.st_mode)) + no_dive= 1; + if(dir_stbuf->st_dev != stbuf.st_dev && !xorriso->do_follow_mount) + no_dive= 1; + if(!no_dive) { + ret= Xorriso_findx(xorriso, job, abs_path, path, &stbuf, depth+1, + own_link_stack, flag|1); + if(ret<0) + goto ex; + } + } + + ret= 1; +ex:; + if(sfe!=NULL) + free(sfe); + if(name!=NULL) + free(name); + if(path!=NULL) + free(path); + if(abs_dir_path_data!=NULL) + free(abs_dir_path_data); + if(abs_path!=NULL) + free(abs_path); + Dirseq_destroy(&dirseq, 0); + return(ret); +} + + +/* @param flag bit0= a non-existing target of multiple sources is a directory + bit1= all paths except the last one are disk_paths + bit2= the last path is a disk_path + @return <=0 is error, 1= leaf file object, 2= directory +*/ +int Xorriso_cpmv_args(struct XorrisO *xorriso, char *cmd, + int argc, char **argv, int *idx, + int *optc, char ***optv, char eff_dest[SfileadrL], + int flag) +{ + int destc= 0, is_dir=0, end_idx, ret, i; + char **destv= NULL; + char sfe[5*SfileadrL]; + + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, + (xorriso->do_iso_rr_pattern==1)|(flag&2)); + if(end_idx - *idx < 2) { + sprintf(xorriso->info_text, "%s: not enough arguments", cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + {ret= 0; goto ex;} + } + + ret= Xorriso_opt_args(xorriso, cmd, argc, argv, *idx, &end_idx, optc, optv, + (flag&2)|16); /* ignore last argument */ + if(ret<=0) + goto ex; + /* demand one match, or 0 with a constant */ + ret= Xorriso_opt_args(xorriso, cmd, argc, argv, end_idx, &end_idx, &destc, + &destv, ((flag&4)>>1) | 32 | 64); + if(ret<=0) + goto ex; + + /* Evaluate target address */ + if(flag&4) + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, destv[0], eff_dest, + 2|4|16); + else + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, destv[0], eff_dest, + 1); + if(ret<0) + {ret= 0; goto ex;} + if(ret==2 || ((flag&1) && *optc > 1 && ret==0)) { + is_dir= 1; + } else if(*optc > 1) { + for(i= 0; i<*optc; i++) + Xorriso_msgs_submit(xorriso, 0, (*optv)[i], 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "%s: more than one origin given, destination is a non-directory: %s", + cmd, Text_shellsafe(destv[0], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + if(ret==0) { /* compute complete eff_dest */ + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, destv[0], eff_dest, + 2 | (flag&4)); + if(ret<0) + {ret= 0; goto ex;} + } + + ret= 1+is_dir; +ex:; + Xorriso_opt_args(xorriso, cmd, argc, argv, *idx, &end_idx, &destc, &destv, + 256); + (*idx)= end_idx; + return(ret); +} + + +/** @return -1= abort , 0= no , 1= yes +*/ +int Xorriso_reassure(struct XorrisO *xorriso, char *cmd, char *which_will, + int flag) +{ + int ret; + + if(!xorriso->do_reassure) + return(1); + sprintf(xorriso->info_text, "Really perform %s which will %s ? (y/n)\n", + cmd, which_will); + Xorriso_info(xorriso, 4); + do { + ret= Xorriso_request_confirmation(xorriso, 2|4|16); + } while(ret==3); + if(ret==6 || ret==4) { + sprintf(xorriso->info_text, "%s confirmed", cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(1); + } + if(ret==2) { + sprintf(xorriso->info_text, "%s aborted", cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(-1); + } + sprintf(xorriso->info_text, "%s revoked", cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(0); +} + + +/* @param flag bit0+1= what to aquire after giving up outdev + 0=none, 1=indev, 2=outdev, 3=both +*/ +int Xorriso_reaquire_outdev(struct XorrisO *xorriso, int flag) +{ + int ret, aq_flag; + char drive_name[SfileadrL], sfe[5*SfileadrL]; + + aq_flag= flag&3; + strcpy(drive_name, xorriso->outdev); + Xorriso_give_up_drive(xorriso, aq_flag); + if(aq_flag==0) { + sprintf(xorriso->info_text,"Gave up -outdev %s", + Text_shellsafe(xorriso->outdev, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(1); + } + sprintf(xorriso->info_text,"Re-aquiring -outdev %s", + Text_shellsafe(drive_name, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + ret= Xorriso_aquire_drive(xorriso, drive_name, aq_flag); + if(ret<=0) { + sprintf(xorriso->info_text,"Could not re-aquire -outdev %s", + Text_shellsafe(xorriso->outdev, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(ret); + } + return(1); +} + + +/* micro version of cdrskin */ +int Xorriso_cdrskin(struct XorrisO *xorriso, char *whom, int argc, char **argv, + int flag) +{ + int ret, i, k, mem_do_close, aq_ret, eject_ret, msc1, msc2, hflag; + int do_atip= 0, do_checkdrive= 0, do_eject= 0, do_scanbus= 0; + int do_toc= 0, do_verbous= 0, do_version= 0, do_help= 0, do_waiti= 0; + int do_multi= 0, do_msinfo= 0, do_grow= 0, do_isosize= 0; + double write_start_address= -1.0, tsize= -1.0; + char track_source[SfileadrL], sfe[5*SfileadrL], dev_adr[SfileadrL], *cpt; + char mem_report_about_text[80], *report_about= "SORRY", blank_mode[80]; + char speed[80]; + + /* cdrecord 2.01 options which are not scheduled for implementation, yet */ + static char ignored_partial_options[][41]= { + "timeout=", "debug=", "kdebug=", "kd=", "driver=", "ts=", + "pregap=", "defpregap=", "mcn=", "isrc=", "index=", "textfile=", + "pktsize=", "cuefile=", + "gracetime=", "minbuf=", + + "assert_write_lba=", "fifo_start_at=", "dev_translation=", + "drive_scsi_dev_family=", "fallback_program=", "modesty_on_drive=", + "tao_to_sao_tsize=", + + "direct_write_amount=", "msifile=", + + "" + }; + static char ignored_full_options[][41]= { + "-d", "-Verbose", "-V", "-silent", "-s", "-setdropts", "-prcap", + "-reset", "-abort", "-overburn", "-ignsize", "-useinfo", + "-fix", "-nofix", + "-raw", "-raw96p", "-raw16", + "-clone", "-text", "-mode2", "-xa", "-xa1", "-xa2", "-xamix", + "-cdi", "-preemp", "-nopreemp", "-copy", "-nocopy", + "-scms", "-shorttrack", "-noshorttrack", "-packet", "-noclose", + "-media-info", "-minfo", + "-load", "-lock", "-raw96r", "-sao", "-dao", "-swab", + "-tao", "-force", "-format", + + "--adjust_speed_to_drive", "--allow_emulated_drives", "--allow_setuid", + "--allow_untested_media", "--any_track", "--demand_a_drive", + "--fifo_disable", "--fifo_start_empty", "--fill_up_media", + "--list_ignored_options", "--no_rc", "--no_convert_fs_adr", + "--prodvd_cli_compatible", "--single_track", + + "--tell_media_space", + + "" + }; + + static char helptext[][80]= { +"Usage: xorriso -as cdrecord [options|source_addresses]", +"Note: This is not cdrecord. See xorriso -help, xorriso -version, man xorriso", +"Options:", +"\t-version\tprint version information and exit emulation", +"\t--devices\tprint list of available MMC drives and exit emulation", +"\tdev=target\tpseudo-SCSI target to use as CD-Recorder", +"\t-v\t\tincrement verbose level by one", +"\t-checkdrive\tcheck if a driver for the drive is present", +"\t-inq\t\tdo an inquiry for the drive and exit emulation", +"\tspeed=#\t\tset speed of drive", +"\tblank=type\tblank a CD-RW disc (see blank=help)", +"\tfs=#\t\tSet fifo size to # (0 to disable, default is 4 MB)", +"\t-eject\t\teject the disk after doing the work", +"\t-dummy\t\tdo everything with laser turned off", +"\t-msinfo\t\tretrieve multi-session info for mkisofs >= 1.10", +"\t-toc\t\tretrieve and print TOC/PMA data", +"\t-atip\t\tretrieve media state, print \"Is *erasable\"", +"\t-multi\t\tgenerate a TOC that allows multi session", +"\t-waiti\t\twait until input is available before opening SCSI", +"\ttsize=#\t\tannounces exact size of source data", +"\tpadsize=#\tAmount of padding", +"\t-data\t\tSubsequent tracks are CD-ROM data mode 1 (default)", +"\t-isosize\tUse iso9660 file system size for next data track", +"\t-pad\t\tpadsize=30k", +"\t-nopad\t\tDo not pad", +"\t--grow_overwriteable_iso\temulate multi-session on DVD+RW, BD-RE", +"\twrite_start_address=#\t\twrite to byte address on DVD+RW, BD-RE", +"\tstream_recording=on\t\ttry to get full speed on DVD-RAM, BD", +"\t-help\t\tprint this text to stderr and exit emulation", +"Actually this is the integrated ISO RockRidge filesystem manipulator xorriso", +"lending its libburn capabilities to a very limited cdrecord emulation. Only", +"a single data track can be burnt to blank, appendable or overwriteable media.", +"A much more elaborate cdrecord emulator is cdrskin from the same project.", +"@End_of_helptexT@" +}; +/* "\t-scanbus\tscan the SCSI bus and exit emulation", */ + +static char blank_help[][80]= { +"Blanking options:", +"\tall\t\tblank the entire disk", +"\tdisc\t\tblank the entire disk", +"\tdisk\t\tblank the entire disk", +"\tfast\t\tminimally blank the entire disk", +"\tminimal\t\tminimally blank the entire disk", +"\tas_needed\tblank or format media to make it ready for (re-)use", +"\tdeformat\t\tblank a formatted DVD-RW", +"\tdeformat_quickest\tminimally blank a formatted DVD-RW to DAO only", +"\tformat_overwrite\tformat a DVD-RW to \"Restricted Overwrite\"", +"@End_of_helptexT@" +}; + + strcpy(mem_report_about_text, xorriso->report_about_text); + mem_do_close= xorriso->do_close; + + track_source[0]= 0; + dev_adr[0]= 0; + blank_mode[0]= 0; + speed[0]= 0; + + if(xorriso->in_drive_handle != NULL) { + ret= Xorriso_option_dev(xorriso, "", 1|32); /* give up indev */ + if(ret!=1) + return(ret); + } + + + /* Assess plan, make settings */ + for(i= 0; i<argc; i++) { + sprintf(xorriso->info_text, "-as %s: %s", + whom, Text_shellsafe(argv[i], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + + for(k=0;ignored_partial_options[k][0]!=0;k++) { + if(argv[i][0]=='-') + if(strncmp(argv[i]+1,ignored_partial_options[k], + strlen(ignored_partial_options[k]))==0) + goto no_volunteer; + if(strncmp(argv[i],ignored_partial_options[k], + strlen(ignored_partial_options[k]))==0) + goto no_volunteer; + } + for(k=0;ignored_full_options[k][0]!=0;k++) + if(strcmp(argv[i],ignored_full_options[k])==0) + goto no_volunteer; + if(0) { +no_volunteer:; + sprintf(xorriso->info_text, "-as %s: Ignored option %s", + whom, Text_shellsafe(argv[i], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + continue; + } + + if(strcmp(argv[i], "-atip")==0) { + do_atip= 1; + } else if(strcmp(argv[i], "-audio")==0) { + sprintf(xorriso->info_text, "-as %s: Option -audio not supported.", whom); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } else if(strncmp(argv[i], "-blank=", 7)==0 || + strncmp(argv[i], "blank=", 6)==0) { + cpt= strchr(argv[i], '=')+1; + if(strcmp(cpt,"all")==0 || strcmp(cpt,"disc")==0 + || strcmp(cpt,"disk")==0) { + strcpy(blank_mode, "all"); + } else if(strcmp(cpt,"fast")==0 || strcmp(cpt,"minimal")==0) { + strcpy(blank_mode, "fast"); + } else if(strcmp(cpt,"help")==0) { + strcpy(blank_mode, "help"); + } else if(strcmp(cpt,"deformat")==0 || + strcmp(cpt,"deformat_sequential")==0 || + strcmp(cpt,"deformat_quickest")==0 || + strcmp(cpt,"deformat_sequential_quickest")==0) { + strcpy(blank_mode, cpt); + } else if(strcmp(cpt,"format_overwrite")==0) { + strcpy(blank_mode, "format_overwrite"); + } else if(strcmp(cpt,"as_needed")==0) { + strcpy(blank_mode, "as_needed"); + } else { + sprintf(xorriso->info_text, + "-as %s: blank=%s not supported. See blank=help .", + whom, Text_shellsafe(argv[i], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + } else if(strcmp(argv[i], "-checkdrive")==0) { + do_checkdrive= 1; + } else if(strcmp(argv[i], "-data")==0) { + /* ok */; + } else if(strncmp(argv[i], "-dev=", 5)==0 || + strncmp(argv[i], "dev=", 4)==0) { + cpt= strchr(argv[i], '=')+1; + strcpy(dev_adr, cpt); + } else if(strcmp(argv[i], "--devices")==0) { + do_scanbus= 2; + } else if(strncmp(argv[i],"driveropts=", 11)==0 || + strncmp(argv[i],"-driveropts=", 12)==0) { + if(strcmp(argv[i]+11, "help")==0) { + fprintf(stderr,"Driver options:\n"); + fprintf(stderr, + "burnfree\tPrepare writer to use BURN-Free technology\n"); + } + } else if(strcmp(argv[i], "-dummy")==0) { + xorriso->do_dummy= 1; + } else if(strcmp(argv[i], "-eject")==0) { + do_eject= 1; + } else if(strncmp(argv[i], "-fs=", 4)==0 || strncmp(argv[i], "fs=", 3)==0) { + cpt= strchr(argv[i], '=')+1; + ret= Xorriso_option_fs(xorriso, cpt, 0); + if(ret<=0) + goto ex; + } else if(strcmp(argv[i], "--grow_overwriteable_iso")==0) { + do_grow= 1; + } else if(strcmp(argv[i], "-help")==0) { + do_help= 1; + } else if(strcmp(argv[i], "-isosize")==0) { + do_isosize= 1; + } else if(strcmp(argv[i], "-inq")==0) { + do_checkdrive= 2; + } else if(strcmp(argv[i], "-msinfo")==0) { + do_msinfo= 1; + } else if(strcmp(argv[i], "-multi")==0) { + do_multi= 1; + } else if(strcmp(argv[i], "-nopad")==0) { + xorriso->padding= 0; + } else if(strcmp(argv[i], "-pad")==0) { + xorriso->padding= 15*2048; + } else if(strncmp(argv[i], "-padsize=", 9)==0 || + strncmp(argv[i], "padsize=", 8)==0) { + cpt= strchr(argv[i], '=')+1; + ret= Xorriso_option_padding(xorriso, cpt, 0); + if(ret<=0) + goto ex; + } else if(strcmp(argv[i], "-scanbus")==0) { + sprintf(xorriso->info_text, "-as %s: Option -scanbus not supported.", + whom); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + +/* do_scanbus= 1; */ + } else if(strncmp(argv[i], "-speed=", 7)==0 || + strncmp(argv[i], "speed=", 6)==0) { + cpt= strchr(argv[i], '=')+1; + strncpy(speed, cpt, 79); + speed[79]= 0; + + } else if(strncmp(argv[i], "-stream_recording=", 18)==0 || + strncmp(argv[i], "stream_recording=", 17)==0) { + cpt= strchr(argv[i], '=')+1; + Xorriso_option_stream_recording(xorriso, cpt, 0); + + } else if(strcmp(argv[i], "-toc")==0) { + do_toc= 1; + } else if(strncmp(argv[i], "-tsize=", 7)==0 || + strncmp(argv[i], "tsize=", 6)==0) { + cpt= strchr(argv[i], '=')+1; + tsize= Scanf_io_size(cpt, 1); + if(tsize > 1024.0*1024.0*1024.0*1024.0*1024.0) { + sprintf(xorriso->info_text, "-as %s: much too large: %s",whom, argv[i]); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + } else if(strcmp(argv[i], "-v")==0 || strcmp(argv[i],"-verbose")==0) { + do_verbous++; + } else if(strcmp(argv[i], "-vv")==0) { + do_verbous+= 2; + } else if(strcmp(argv[i], "-vvv")==0) { + do_verbous+= 3; + } else if(strcmp(argv[i], "-version")==0) { + do_version= 1; + } else if(strcmp(argv[i], "-waiti")==0) { + do_waiti= 1; + } else if(strncmp(argv[i], "write_start_address=", 20)==0) { + write_start_address= Scanf_io_size(argv[i]+20,0); + } else if(argv[i][0]=='-' && argv[i][1]!=0) { + sprintf(xorriso->info_text, "-as %s: Unknown option %s", + whom, Text_shellsafe(argv[i], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } else { + if(track_source[0]) { + sprintf(xorriso->info_text, "-as %s: Surplus track source %s", + whom, Text_shellsafe(argv[i], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + sprintf(xorriso->info_text, "First and only track source is %s", + Text_shellsafe(track_source, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + ret= 0; goto ex; + } + if(Sfile_str(track_source, argv[i], 0)<=0) + {ret= -1; goto ex;} + } + } + + /* Perform actions */ + Xorriso_option_report_about(xorriso, "NOTE", 0); + if(do_version) { + sprintf(xorriso->result_line, "Cdrecord 2.01-Emulation Copyright (C) 2009 see libburnia-project.org xorriso\n"); + Xorriso_result(xorriso, 1); + Xorriso_option_version(xorriso, 0); + ret= 1; goto ex; + } + if(do_waiti) { + sprintf(xorriso->info_text, + "xorriso: Option -waiti pauses program until input appears at stdin\n"); + Xorriso_info(xorriso,0); + sprintf(xorriso->result_line, "Waiting for data on stdin...\n"); + Xorriso_result(xorriso, 1); + for(ret= 0; ret==0; ) + ret= Wait_for_input(0,1000000,0); + if(ret<0 || feof(stdin)) { + Xorriso_msgs_submit(xorriso, 0, + "stdin produces exception rather than data", 0, "NOTE", 0); + } + sprintf(xorriso->info_text, "xorriso: Option -waiti pausing is done.\n"); + } + if(dev_adr[0]) { + hflag= 2 | 32 | 64; + if(!do_grow) + hflag|= 8; /* consider overwriteables as blank */ + ret= Xorriso_option_dev(xorriso, dev_adr, hflag); + if(ret<=0) + goto ex; + } + + if(do_help) { + for(i= 0; strcmp(helptext[i], "@End_of_helptexT@")!=0; i++) { + sprintf(xorriso->info_text, "%s\n", helptext[i]); + Xorriso_info(xorriso,0); + } + ret= 1; goto ex; + } + if(do_scanbus) { + if(do_scanbus==1) + /* >>> would need -scanbus compatible output and input format */; + else + Xorriso_option_devices(xorriso, 0); + ret= 1; goto ex; + } + if(strcmp(blank_mode, "help")==0) { + for(i= 0; strcmp(blank_help[i], "@End_of_helptexT@")!=0; i++) { + sprintf(xorriso->info_text, "%s\n", blank_help[i]); + Xorriso_info(xorriso,0); + } + ret= 1; goto ex; + } + + if(!(do_checkdrive || do_atip || do_toc || blank_mode[0] || track_source[0] || + do_eject || do_msinfo)) + {ret= 1; goto ex;} + + if(xorriso->out_drive_handle==NULL) { + sprintf(xorriso->info_text, "-as %s: No output drive selected", whom); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + + if(do_msinfo) { + ret= Xorriso_msinfo(xorriso, &msc1, &msc2, 2 | !!do_grow); + if(ret<=0) + goto ex; + sprintf(xorriso->result_line, "%d,%d\n", msc1, msc2); + Xorriso_result(xorriso, 1); + } + + if(speed[0]) { + ret= Xorriso_option_speed(xorriso, speed, 0); + if(ret<=0) + goto ex; + } + + if(do_verbous<=0) + report_about= "SORRY"; + else if(do_verbous<=2) + report_about= "UPDATE"; + else if(do_verbous==3) + report_about= "DEBUG"; + else + report_about= "ALL"; + Xorriso_option_report_about(xorriso, report_about, 0); + + if(do_checkdrive) { + ret= Xorriso_atip(xorriso, 2-(do_checkdrive==2)); + if(ret<=0) + goto ex; + } + if(do_atip) { + ret= Xorriso_atip(xorriso, 0); + if(ret<=0) + goto ex; + } + if(do_toc) { + ret= Xorriso_option_toc(xorriso, 0); + if(ret<=0) + goto ex; + } + if(strcmp(blank_mode, "format_overwrite")==0) { + ret= Xorriso_option_blank(xorriso, "fast", 1); + if(ret<=0) + goto ex; + } else if(blank_mode[0]) { + ret= Xorriso_option_blank(xorriso, blank_mode, 0); + if(ret<=0) + goto ex; + } + if(track_source[0]) { + xorriso->do_close= !do_multi; + ret= Xorriso_burn_track(xorriso, (off_t) write_start_address, + track_source, (off_t) tsize, + (!!do_grow)|((!!do_isosize)<<1)); + aq_ret= Xorriso_reaquire_outdev(xorriso, 2*(ret>0)); + if(ret<=0 && ret<aq_ret) + goto ex; + if(aq_ret<=0) + {ret= aq_ret; goto ex;} + } + + ret= 1; +ex:; + if(do_eject && ret>=0) { + eject_ret= Xorriso_option_eject(xorriso, "out", 0); + if(eject_ret<ret) + ret= eject_ret; + } + if(ret<=0) { + sprintf(xorriso->info_text, "-as %s: Job could not be performed properly.", + whom); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + } + Xorriso_option_report_about(xorriso, mem_report_about_text, 0); + xorriso->do_close= mem_do_close; + return(ret); +} + + +/* @param flag bit0= do not report eventual ignore decision +*/ +int Xorriso_genisofs_ignore(struct XorrisO *xorriso, char *whom, + char **argv, int *i, int flag) +{ + /* mkisofs 2.01 options which are not scheduled for implementation, yet */ + static char ignored_arg0_options[][41]= { + "-allow-leading-dots", "-ldots", "-allow-lowercase", "-allow-multidot", + "-cache-inodes", "-no-cache-inodes", "-check-oldnames", "-d", "-D", + "-joliet-long", "-l", "-L", "-max-iso9660-filenames", "-N", "-nobak", + "-no-bak", "-force-rr", "-r", "-relaxed-filenames", "-T", "-U", + "-no-iso-translate", + "" + }; + static char ignored_arg1_options[][41]= { + "-A", "-biblio", "-check-session", "-p", "-root", + "-old-root", "-sysid", "-table-name", + "" + }; + int k, idx_offset= 0; + char sfe[5*SfileadrL]; + + for(k=0;ignored_arg0_options[k][0]!=0;k++) + if(strcmp(argv[*i],ignored_arg0_options[k])==0) + goto no_volunteer; + for(k=0;ignored_arg1_options[k][0]!=0;k++) + if(strcmp(argv[*i],ignored_arg1_options[k])==0) { + (*i)++; + idx_offset= -1; + goto no_volunteer; + } + return(0); +no_volunteer:; + sprintf(xorriso->info_text, "-as %s: Ignored option %s", + whom, Text_shellsafe(argv[(*i)+idx_offset], sfe, 0)); + if(!(flag & 1)) + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(1); +} + + +/* micro emulation of mkisofs */ +int Xorriso_genisofs(struct XorrisO *xorriso, char *whom, + int argc, char **argv, int flag) +{ + int ret, i, was_path= 0, was_other_option= 0, mem_graft_points, mem; + int do_print_size= 0, fd, idx, iso_level= 0, no_emul_boot= 0; + int option_b= 0, was_failure= 0, fret; + char sfe[5*SfileadrL], adr[SfileadrL+8], ra_text[80], pathspec[2*SfileadrL]; + char *ept, *add_pt, eff_path[SfileadrL], indev[SfileadrL+8], msc[80], *cpt; + + static char helptext[][80]= { +"Usage: xorriso -as mkisofs [options] file...", +"Note: This is not mkisofs. See xorriso -help, xorriso -version, man xorriso", +"Options:", +" -f, -follow-links Follow symbolic links", +" -graft-points Allow to use graft points for filenames", +" -help Print option help", +" -input-charset CHARSET Local input charset for file name conversion", +" -output-charset CHARSET Output charset for file name conversion", +" -iso-level LEVEL Set ISO9660 conformance level (1..3)", +" -J, -joliet Generate Joliet directory information", +" -o FILE, -output FILE Set output file name", +" -m GLOBFILE, -exclude GLOBFILE", +" Exclude file name", +" -exclude-list FILE File with list of file names to exclude", +" -pad Pad output by 300k (default)", +" -no-pad Do not pad output", +" -M FILE, -prev-session FILE Set path to previous session to merge", +" -C PARAMS, -cdrecord-params PARAMS", +" Magic paramters from cdrecord", +" -path-list FILE File with list of pathnames to process", +" --quoted_path_list FILE File with list of quoted pathnames to process", +" -print-size Print estimated filesystem size and exit", +" -quiet Run quietly", +" -R, -rock Generate Rock Ridge directory information", +" --hardlinks Record eventual hard link relations of files", +" --acl Record eventual ACLs of files", +" --xattr Record eventual user space xattr of files", +" --md5 Compute and record MD5 checksums of data files", +" --for_backup Use all options which improve backup fidelity", +" -V ID, -volid ID Set Volume ID", +" -b FILE, -eltorito-boot FILE", +" Set El Torito boot image name", +" -c FILE, -eltorito-catalog FILE", +" Set El Torito boot catalog name", +" -boot-load-size # Set numbers of load sectors", +" -no-emul-boot Boot image is 'no emulation' image", +" -boot-info-table Patch boot image with info table", +" isolinux_mbr=on|auto|off Control eventual isohybrid MBR generation", +" -z, -transparent-compression", +" Enable transparent compression of files", +" -v, -verbose Verbose", +" -version Print the current version", +"@End_of_helptexT@" +}; + + strcpy(ra_text, xorriso->report_about_text); + + adr[0]= indev[0]= msc[0]= 0; + for(i= 0; i<argc; i++) { + ret= Xorriso_genisofs_ignore(xorriso, whom, argv, &i, 1); + if(ret == 1) + continue; + if(strcmp(argv[i], "-version")==0) { + sprintf(xorriso->result_line, +"mkisofs 2.01-Emulation Copyright (C) 2009 see libburnia-project.org xorriso\n" + ); + fd= xorriso->dev_fd_1; + if(fd<0) + fd= 1; + write(fd, xorriso->result_line, strlen(xorriso->result_line)); + fsync(fd); + Xorriso_option_version(xorriso, 0); + + } else if(strcmp(argv[i], "-o")==0 || strcmp(argv[i], "-output")==0) { + if(i+1>=argc) + goto not_enough_args; + i++; + adr[0]= 0; + if(strcmp(argv[i],"-")!=0 && strncmp(argv[i], "stdio:", 6)!=0) + strcpy(adr, "stdio:"); + if(Sfile_str(adr+strlen(adr), argv[i], 0)<=0) + {ret= -1; goto ex;} + } else if(strcmp(argv[i], "-M")==0 || strcmp(argv[i], "-dev")==0 || + strcmp(argv[i], "-prev-session")==0) { + if(i+1>=argc) + goto not_enough_args; + i++; + if(strncmp(argv[i], "stdio:", 6)!=0) + strcpy(indev, "stdio:"); + if(Sfile_str(indev+strlen(indev), argv[i], 0)<=0) + {ret= -1; goto ex;} + } else if(strcmp(argv[i], "-C")==0 || + strcmp(argv[i], "-cdrecord-params")==0) { + if(i+1>=argc) + goto not_enough_args; + i++; + strncpy(msc, argv[i], sizeof(msc)-1); + msc[sizeof(msc)-1]= 0; + } else if(strcmp(argv[i], "-help")==0) { + Xorriso_option_report_about(xorriso, "NOTE", 0); + for(i= 0; strcmp(helptext[i], "@End_of_helptexT@")!=0; i++) { + sprintf(xorriso->info_text, "%s\n", helptext[i]); + Xorriso_info(xorriso, 1); + } + Xorriso_option_report_about(xorriso, ra_text, 0); + } else if(strcmp(argv[i], "-v")==0 || strcmp(argv[i], "-verbose")==0) { + strcpy(ra_text, "UPDATE"); + } else if(strcmp(argv[i], "-quiet")==0) { + strcpy(ra_text, "SORRY"); + } else if(strcmp(argv[i], "-f")==0 || strcmp(argv[i], "-follow-links")==0) { + ret= Xorriso_option_follow(xorriso, "on", 0); + if(ret<=0) + goto problem_handler_1; + } else if(strcmp(argv[i], "-iso-level")==0) { + if(i+1>=argc) + goto not_enough_args; + i++; + sscanf(argv[i], "%d", &iso_level); + if(iso_level < 1 || iso_level > 3) { + sprintf(xorriso->info_text, + "-as %s: unsupported -iso-level '%s' (use one of: 1,2,3)", + whom, argv[i]); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto problem_handler_1; + } + if(iso_level < 3) + xorriso->file_size_limit= + ((off_t) 4) * ((off_t) 1024*1024*1024) - ((off_t) 1); + else + xorriso->file_size_limit= 0; + } else if(strcmp(argv[i], "-no-emul-boot")==0) { + no_emul_boot= 1; + } else if(strcmp(argv[i], "-boot-info-table")==0) { + ; + } else if(strcmp(argv[i], "-b") == 0 || + strcmp(argv[i], "-eltorito-boot") == 0) { + if(i+1>=argc) + goto not_enough_args; + i++; + xorriso->boot_image_bin_path[0]= 0; + if(argv[i][0] != '/') + strcat(xorriso->boot_image_bin_path, "/"); + ret= Sfile_str(xorriso->boot_image_bin_path + + strlen(xorriso->boot_image_bin_path), argv[i], 0); + if(ret <= 0) + goto ex; + option_b= 1; + xorriso->keep_boot_image= 0; + xorriso->patch_isolinux_image= 0; + } else if(strcmp(argv[i], "-c") == 0 || + strcmp(argv[i], "-eltorito-catalog") == 0) { + if(i+1>=argc) + goto not_enough_args; + i++; + xorriso->boot_image_cat_path[0]= 0; + if(argv[i][0] != '/') + strcat(xorriso->boot_image_cat_path, "/"); + ret= Sfile_str(xorriso->boot_image_cat_path + + strlen(xorriso->boot_image_cat_path), argv[i], 0); + if(ret <= 0) + goto ex; + } else if(strcmp(argv[i], "-boot-load-size") == 0) { + if(i+1>=argc) + goto not_enough_args; + i++; + sscanf(argv[i], "%d", &ret); + xorriso->boot_image_load_size= ret * 512; + } else if(strncmp(argv[i], "isolinux_mbr=", 13)==0) { + sprintf(sfe, "isohybrid=%s", argv[i] + 13); + ret= Xorriso_option_boot_image(xorriso, "isolinux", sfe, 0); + if(ret <= 0) + goto problem_handler_1; + } else if(strcmp(argv[i], "-input-charset")==0) { + if(i+1>=argc) + goto not_enough_args; + i++; + /* -local_charset */ + if(strcmp(argv[i], "default") == 0) + ret= Xorriso_option_charset(xorriso, "ISO-8859-1", 4); + else + ret= Xorriso_option_charset(xorriso, argv[i], 4); + if(ret <= 0) + goto problem_handler_1; + } else if(strcmp(argv[i], "-output-charset")==0) { + if(i+1>=argc) + goto not_enough_args; + i++; + /* -charset */ + if(strcmp(argv[i], "default") == 0) + ret= Xorriso_option_charset(xorriso, "ISO-8859-1", 3); + else + ret= Xorriso_option_charset(xorriso, argv[i], 3); + if(ret <= 0) + goto problem_handler_1; + } else if(strcmp(argv[i], "--hardlinks")==0) { + Xorriso_option_hardlinks(xorriso, "on", 0); + } else if(strcmp(argv[i], "--acl")==0) { + Xorriso_option_acl(xorriso, "on", 0); + } else if(strcmp(argv[i], "--xattr")==0) { + Xorriso_option_xattr(xorriso, "on", 0); + } else if(strcmp(argv[i], "--md5")==0) { + Xorriso_option_md5(xorriso, "on", 0); + } else if(strcmp(argv[i], "--for_backup")==0) { + Xorriso_option_hardlinks(xorriso, "on", 0); + Xorriso_option_acl(xorriso, "on", 0); + Xorriso_option_xattr(xorriso, "on", 0); + Xorriso_option_md5(xorriso, "on", 0); + } else if(strcmp(argv[i], "-z")==0 || + strcmp(argv[i], "-transparent-compression")==0) { + Xorriso_option_zisofs(xorriso, "by_magic=on", 0); + } else + was_other_option= 1; + + continue; /* regular bottom of loop */ +problem_handler_1:; + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + goto ex; + } + Xorriso_option_report_about(xorriso, ra_text, 0); + if(adr[0]) { + if(strncmp(adr, "stdio:", 6)==0 && strncmp(adr, "stdio:/dev/fd/", 14)!=0) { + ret= Sfile_type(adr+6, 1); + if(ret==-1) { + /* ok */; + } else if(ret==2 || ret==3) { + sprintf(xorriso->info_text, + "-as %s: Cannot accept %s as target: -o %s", + whom, (ret==3 ? "symbolic link" : "directory"), + Text_shellsafe(adr+6, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + } + /* Regard overwriteable as blank, truncate regular files on write start */ + ret= Xorriso_option_dev(xorriso, adr, 2|8|16); + if(ret<=0) + goto ex; + } + if(option_b && !no_emul_boot) { + xorriso->boot_image_bin_path[0]= 0; + sprintf(xorriso->info_text, + "-as %s: Option -b is supported only if option -no-emul-boot is given", + whom); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + if(was_other_option && xorriso->out_drive_handle==NULL) { + ret= Xorriso_option_dev(xorriso, "-", 2|4); /* set outdev to stdout */ + if(ret<=0) + return(ret); + } + + if(msc[0]) { + cpt= strchr(msc, ','); + if(cpt==NULL) { +illegal_c:; + sprintf(xorriso->info_text, + "-as %s: unusable parameter with option -C: %s", + whom, Text_shellsafe(msc, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } else if(cpt==msc || msc[1]==0) + goto illegal_c; + strncpy(sfe, msc, cpt-msc); + sfe[cpt-msc]= 0; + if(xorriso->in_drive_handle!=NULL && indev[0]) { + /* give up indev before setting the load address */ + ret= Xorriso_option_dev(xorriso, "", 1); + if(ret<=0) + return(ret); + } + /* growisofs submits msc1+16 to avoid a theoretical bug in mkisofs. + Therefore this bug has to be emulated here. Sigh. + */ + ret= Xorriso_option_load(xorriso, "sbsector", sfe, 1); + if(ret<=0) + return(ret); + ret= Xorriso_option_grow_blindly(xorriso, cpt+1, 0); + if(ret<=0) + return(ret); + } + if(indev[0]) { + ret= Xorriso_option_dev(xorriso, indev, 1); + if(ret<=0) + goto ex; + } + + if(!was_other_option) + {ret= 1; goto ex;} + + xorriso->padding= 300*1024; + + for(i= 0; i<argc; i++) { + sprintf(xorriso->info_text, "-as %s: %s", + whom, Text_shellsafe(argv[i], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + ret= Xorriso_genisofs_ignore(xorriso, whom, argv, &i, 0); + if(ret == 1) + continue; + if(strcmp(argv[i], "-version")==0) { + /* was already handled in first argument scan */; + + } else if(strcmp(argv[i], "-R")==0 || strcmp(argv[i], "-rock")==0) { + /* ok */; + } else if(strcmp(argv[i], "-J")==0 || strcmp(argv[i], "-joliet")==0) { + xorriso->do_joliet= 1; + } else if(strcmp(argv[i], "-graft-points")==0) { + xorriso->allow_graft_points= 1; + } else if(strcmp(argv[i], "-path-list")==0 || + strcmp(argv[i], "--quoted_path_list")==0) { + if(i+1>=argc) { +not_enough_args:; + sprintf(xorriso->info_text, "-as %s: Not enough arguments to option %s", + whom, argv[i]); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + i++; + was_path= 1; + xorriso->pacifier_style= 1; + ret= Xorriso_option_path_list(xorriso, argv[i], + (strcmp(argv[i-1], "--quoted_path_list")==0)); + if(ret<=0) + goto problem_handler_2; + } else if(strcmp(argv[i], "-f")==0 || strcmp(argv[i], "-follow-links")==0) { + /* was already handled in first argument scan */; + } else if(strcmp(argv[i], "-pad")==0) { + xorriso->padding= 300*1024; + } else if(strcmp(argv[i], "-no-pad")==0) { + xorriso->padding= 0; + } else if(strcmp(argv[i], "-print-size")==0) { + do_print_size= 1; + } else if(strcmp(argv[i], "-o")==0) { + i++; + /* was already handled in first argument scan */; + } else if(strcmp(argv[i], "-M")==0 || strcmp(argv[i], "-dev")==0) { + i++; + /* was already handled in first argument scan */; + } else if(strcmp(argv[i], "-C")==0) { + i++; + /* was already handled in first argument scan */; + } else if(strcmp(argv[i], "-help")==0) { + /* was already handled in first argument scan */; + } else if(strcmp(argv[i], "-V")==0 || strcmp(argv[i], "-volid")==0) { + if(i+1>=argc) + goto not_enough_args; + i++; + ret= Xorriso_option_volid(xorriso, argv[i], 0); + if(ret<=0) + goto problem_handler_2; + } else if(strcmp(argv[i], "-P")==0 || strcmp(argv[i], "-publisher")==0) { + if(i+1>=argc) + goto not_enough_args; + i++; + ret= Xorriso_option_publisher(xorriso, argv[i], 0); + if(ret<=0) + goto problem_handler_2; + } else if(strcmp(argv[i], "-m")==0 || strcmp(argv[i], "-exclude")==0 || + strcmp(argv[i], "-x")==0 || strcmp(argv[i], "-old-exclude")==0) { + if(i+1>=argc) + goto not_enough_args; + i++; + mem= xorriso->do_disk_pattern; + xorriso->do_disk_pattern= 1; + if(strchr(argv[i], '/')!=NULL) { + idx= i; + ret= Xorriso_option_not_paths(xorriso, i+1, argv, &idx, 0); + } else + ret= Xorriso_option_not_leaf(xorriso, argv[i], 0); + xorriso->do_disk_pattern= mem; + if(ret<=0) + goto problem_handler_2; + } else if(strcmp(argv[i], "-exclude-list")==0) { + if(i+1>=argc) + goto not_enough_args; + i++; + mem= xorriso->do_disk_pattern; + xorriso->do_disk_pattern= 1; + ret= Xorriso_option_not_list(xorriso, argv[i], 0); + xorriso->do_disk_pattern= mem; + if(ret<=0) + goto problem_handler_2; + } else if(strcmp(argv[i], "-v")==0 || strcmp(argv[i], "-quiet")==0) { + /* was already handled in first argument scan */; + + } else if(strcmp(argv[i], "-iso-level")==0) { + i++; + /* was already handled in first argument scan */; + } else if(strcmp(argv[i], "-no-emul-boot")==0) { + /* was already handled in first argument scan */; + } else if(strcmp(argv[i], "-b") == 0 || + strcmp(argv[i], "-eltorito-boot") == 0) { + i++; + /* was already handled in first argument scan */; + } else if(strcmp(argv[i], "-c") == 0 || + strcmp(argv[i], "-eltorito-catalog") == 0) { + i++; + /* was already handled in first argument scan */; + } else if(strncmp(argv[i], "isolinux_mbr=", 13)==0) { + /* was already handled in first argument scan */; + } else if(strcmp(argv[i], "-boot-load-size") == 0) { + i++; + /* was already handled in first argument scan */; + } else if(strcmp(argv[i], "-boot-info-table")==0) { + ; + } else if(strcmp(argv[i], "-input-charset")==0) { + i++; + /* was already handled in first argument scan */; + } else if(strcmp(argv[i], "-output-charset")==0) { + i++; + /* was already handled in first argument scan */; + } else if(strcmp(argv[i], "--hardlinks")==0 || + strcmp(argv[i], "--acl")==0 || + strcmp(argv[i], "--xattr")==0 || + strcmp(argv[i], "--md5")==0 || + strcmp(argv[i], "--for_backup")==0) { + /* was already handled in first argument scan */; + } else if(strcmp(argv[i], "-z")==0 || + strcmp(argv[i], "-transparent-compression")==0) { + /* was already handled in first argument scan */; + } else if(argv[i][0]=='-' && argv[i][1]!=0) { + sprintf(xorriso->info_text, "-as %s: Unknown option %s", + whom, Text_shellsafe(argv[i], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + } else { + int zero= 0; + + /* implementing mkisofs tendency to map single-path pathspecs to / */ + if((!xorriso->allow_graft_points) || + Fileliste__target_source_limit(argv[i], '=', &ept, 0)<=0) { + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, argv[i], + eff_path, 2|4); + if(ret<=0) + goto problem_handler_2; + ret= Sfile_type(eff_path, + 1|((xorriso->do_follow_param||xorriso->do_follow_links)<<2)); + if(ret==2) { + strcpy(pathspec, "/="); + } else { + pathspec[0]= '/'; + pathspec[1]= 0; + ret= Sfile_leafname(eff_path, pathspec+1, 0); + if(ret>0) + strcat(pathspec, "="); + else + pathspec[0]= 0; + } + strcat(pathspec, eff_path); + add_pt= pathspec; + } else + add_pt= argv[i]; + mem_graft_points= xorriso->allow_graft_points; + xorriso->allow_graft_points= 1; + ret= Xorriso_option_add(xorriso, 1, &add_pt, &zero, was_path<<1); + xorriso->allow_graft_points= mem_graft_points; + if(ret<=0) + goto problem_handler_2; + was_path= 1; + xorriso->pacifier_style= 1; + } + continue; /* regular bottom of loop */ +problem_handler_2:; + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + goto ex; + } + if(do_print_size) { + ret= Xorriso_option_print_size(xorriso, 1); + if(ret<=0) + goto ex; + } + + ret= !was_failure; +ex:; + if(was_path && !do_print_size) + Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count, + xorriso->pacifier_total, "", 1); + if(do_print_size && xorriso->volset_change_pending) + Xorriso_option_rollback(xorriso, 0); + return(ret); +} + + +int Xorriso_as_genisofs(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int end_idx, ret, idx_count, old_idx; + + old_idx= *idx; + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1); + (*idx)= end_idx; + idx_count= end_idx-old_idx; + if(end_idx<=0 || old_idx>=argc) + return(1); + ret= Xorriso_genisofs(xorriso, "genisofs", end_idx-old_idx, argv+old_idx, 0); + return(ret); +} + + +int Xorriso_as_cdrskin(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int end_idx, ret, idx_count, old_idx; + + old_idx= *idx; + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1); + (*idx)= end_idx; + idx_count= end_idx-old_idx; + if(end_idx<=0 || old_idx>=argc) + return(1); + ret= Xorriso_cdrskin(xorriso, "cdrskin", end_idx-old_idx, argv+old_idx, 0); + return(ret); +} + + +/* @param boss_iter Opaque handle to be forwarded to actions in ISO image + Set to NULL if calling this function from outside ISO world + @param flag bit0= widen hardlink sibling: + Do not call Xorriso_hardlink_update() + Overwrite exactly if normal mode would not, + else do nothing + bit2= -follow: this is not a command parameter + @return <=0 error, 1= ok , 2= iso_rr_path node object has been deleted , + 3= no action taken +*/ +int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter, + int compare_result, char *disk_path, + char *iso_rr_path, int flag) +{ + int ret, deleted= 0, is_split= 0, i, loop_count, late_hardlink_update= 0; + char sfe[5*SfileadrL]; + struct stat stbuf; + struct SplitparT *split_parts= NULL; + int split_count= 0; + char part_path[SfileadrL], *part_name; + int partno, total_parts, new_total_parts; + off_t offset, bytes, total_bytes, disk_size, first_bytes; + + if((compare_result&3)==3) { + sprintf(xorriso->info_text, "Missing on disk and in ISO: disk_path %s", + Text_shellsafe(disk_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 1); + xorriso->find_compare_result= -1; + ret= 3; goto ex; + } + + if(compare_result&((1<<11)|(1<<13))) { + if(flag & 1) + {ret= 3; goto ex;} + /* cannot open regular disk file, early eof of disk file */ + sprintf(xorriso->info_text, "Problems with reading disk file %s", + Text_shellsafe(disk_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 1); + xorriso->find_compare_result= -1; + ret= 1; goto ex; + } + xorriso->info_text[0]= 0; + is_split= !!(compare_result & (1<<17)); + + if((!(xorriso->ino_behavior & 2)) && (compare_result & (2 | (3 << 21))) && + !(flag & 1)) { + if(compare_result & 2) { + /* File is not yet in image */ + late_hardlink_update= 1; + } else { + /* Hard link relation has changed resp. was not recorded. */ + ret= Xorriso_hardlink_update(xorriso, &compare_result, + disk_path, iso_rr_path, flag & 4); + if(ret < 0) + goto ex; + if(ret == 2) + {ret= 1; goto ex;} + } + } + + if(compare_result&(8|64)) { + /* file type, minor+major with device file */ + if(flag & 1) + {ret= 3; goto ex;} + ret= Xorriso_rmi(xorriso, boss_iter, (off_t) 0, iso_rr_path, 1); /* rm_r */ + if(ret>0) { + deleted= 1; + ret= Xorriso_graft_in(xorriso, boss_iter, disk_path, iso_rr_path, + (off_t) 0, (off_t) 0, 2|(flag&4)); + } + sprintf(xorriso->info_text, "Deleted and re-added "); + + } else if(compare_result&(1)) { +delete:; + /* disk_adr not existing */ + ret= Xorriso_rmi(xorriso, boss_iter, (off_t) 0, iso_rr_path, 1); + deleted= 1; + sprintf(xorriso->info_text, "Deleted "); + + } else if(compare_result&(2|128|(1<<12)|(1<<14)|(1<<15))) { + /* iso_adr not existing, size, cannot open iso file, early eof of iso file + content bytes differ */ + + if(flag & 1) + {ret= 3; goto ex;} +overwrite:; + if(is_split) { + ret= Xorriso_identify_split(xorriso, iso_rr_path, NULL, + &split_parts, &split_count, &stbuf, 0); + if(ret<=0) + {ret= -1; goto ex;} /* (should not happen) */ + ret= lstat(disk_path, &stbuf); + if(ret==-1) + goto delete; + disk_size= stbuf.st_size; + Splitparts_get(split_parts, 0, &part_name, &partno, &total_parts, + &offset, &first_bytes, &total_bytes, 0); + new_total_parts= disk_size/first_bytes; + if(disk_size % first_bytes) + new_total_parts++; + + loop_count= split_count; + /* If disk file grew over part limit and all parts are present: + add new parts */ + if(new_total_parts > total_parts && split_count == total_parts) + loop_count= new_total_parts; + + for(i= 0; i<loop_count; i++) { + if(i<split_count) { + /* Delete old part */ + Splitparts_get(split_parts, i, &part_name, &partno, &total_parts, + &offset, &bytes, &total_bytes, 0); + strcpy(part_path, iso_rr_path); + if(Sfile_add_to_path(part_path, part_name, 0)<=0) { + Xorriso_much_too_long(xorriso, + strlen(iso_rr_path)+strlen(part_path)+1, 2); + {ret= -1; goto ex;} + } + ret= Xorriso_rmi(xorriso, NULL, (off_t) 0, part_path, 1); + if(ret<=0) + goto ex; + deleted= 1; + } else { + partno= i+1; + offset= i*first_bytes; + } + if(disk_size<=offset) + continue; + /* Insert new part */ + if(strlen(part_path)+160>SfileadrL) { + Xorriso_much_too_long(xorriso, strlen(part_path)+160, 2); + ret= 0; goto ex; + } + Splitpart__compose(part_path+strlen(iso_rr_path)+1, partno, + new_total_parts, offset, first_bytes, disk_size, 0); + ret= Xorriso_graft_in(xorriso, boss_iter, disk_path, part_path, + offset, bytes, 2|(flag&4)|8|128); + if(ret<=0) + goto ex; + } + /* Copy file attributes to iso_rr_path, augment r-perms by x-perms */ + ret= Xorriso_copy_properties(xorriso, disk_path, iso_rr_path, 2 | 4); + if(ret<=0) + goto ex; + } else { + ret= Xorriso_graft_in(xorriso, boss_iter, disk_path, iso_rr_path, + (off_t) 0, (off_t) 0, 2|(flag&4)); + if(ret>0 && !(compare_result&2)) + deleted= 1; + } + if(late_hardlink_update) { + /* Handle eventual hardlink siblings of newly created file */ + ret= Xorriso_hardlink_update(xorriso, &compare_result, + disk_path, iso_rr_path, 1 | (flag & 4)); + if(ret < 0) + goto ex; + } + if(flag & 1) + sprintf(xorriso->info_text, "Widened hard link "); + else + sprintf(xorriso->info_text, "Added/overwrote "); + + } else if(compare_result&(4|16|32|256|512|1024|(1<<19)|(1<<20)|(1<<22))) { + /* access permissions, user id, group id, mtime, atime, ctime, ACL, xattr, + dev_ino missing */ + + if(flag & 1) + goto overwrite; + + if(is_split) { + ret= Xorriso_identify_split(xorriso, iso_rr_path, NULL, + &split_parts, &split_count, &stbuf, 0); + if(ret<=0) + {ret= -1; goto ex;} /* (should not happen) */ + for(i= 0; i<split_count; i++) { + Splitparts_get(split_parts, i, &part_name, &partno, &total_parts, + &offset, &bytes, &total_bytes, 0); + strcpy(part_path, iso_rr_path); + if(Sfile_add_to_path(part_path, part_name, 0)<=0) { + Xorriso_much_too_long(xorriso, + strlen(iso_rr_path)+strlen(part_path)+1, 2); + {ret= -1; goto ex;} + } + ret= Xorriso_copy_properties(xorriso, disk_path, part_path, + 4 * !(compare_result & (1<<21))); + /* do not update eventually mismatching dev_ino */ + if(ret<=0) + goto ex; + } + /* Copy file attributes to iso_rr_path, augment r-perms by x-perms */ + ret= Xorriso_copy_properties(xorriso, disk_path, iso_rr_path, 2 | 4); + if(ret<=0) + goto ex; + } else + ret= Xorriso_copy_properties(xorriso, disk_path, iso_rr_path, 4); + sprintf(xorriso->info_text, "Adjusted attributes of "); + + } else if(flag & 1) { + goto overwrite; + } else + ret= 1; + if(ret>0 && xorriso->info_text[0]) { + strcat(xorriso->info_text, Text_shellsafe(iso_rr_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0); + } + ret= 1; +ex:; + if(split_parts!=NULL) + Splitparts_destroy(&split_parts, split_count, 0); + if(ret<=0) + return(ret); + if(deleted) + return(2); + return(ret); +} + + +int Xorriso_write_session_log(struct XorrisO *xorriso, int flag) +{ + FILE *fp= NULL; + char sfe[5*SfileadrL], timetext[40], *rpt, *wpt; + + if(xorriso->session_logfile[0]==0) + return(2); + fp= fopen(xorriso->session_logfile, "a"); + if(fp==0) { + sprintf(xorriso->info_text, "-session_log: Cannot open file %s", + Text_shellsafe(xorriso->session_logfile, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + wpt= sfe; + for(rpt= xorriso->volid; *rpt!=0; rpt++) { + if(*rpt=='\n') { + *(wpt++)= '\\'; + *(wpt++)= 'n'; + } else + *(wpt++)= *rpt; + } + *wpt= 0; + fprintf(fp, "%s %d %d %s\n", + Ftimetxt(time(0), timetext, 2), xorriso->session_lba, + xorriso->session_blocks, sfe); + fclose(fp); + return(1); +} + + +/* @param flag bit0= path is a command parameter +*/ +int Xorriso_path_is_excluded(struct XorrisO *xorriso, char *path, int flag) +{ + int ret; + char sfe[5*SfileadrL]; + + if(!(xorriso->disk_excl_mode&1)) /* exclusion is off */ + return(0); + if((flag&1) && !(xorriso->disk_excl_mode&2)) /* params are exempted */ + return(0); + ret= Exclusions_match(xorriso->disk_exclusions, path, + !!(xorriso->disk_excl_mode&4)); + if(ret<0) { + sprintf(xorriso->info_text, + "Error during disk file exclusion decision"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + } + if(ret>0 && (flag&1)) { + sprintf(xorriso->info_text, "Disk path parameter excluded by %s : %s", + (ret==1 ? "-not_paths" : "-not_leaf"), Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + return(ret); +} + + +/* @param flag bit7= return 4 if restore fails from denied permission + do not issue error message + @return <=0 failure , 1 success , + 4 with bit7: permission to create file was denied +*/ +int Xorriso_make_tmp_path(struct XorrisO *xorriso, char *orig_path, + char *tmp_path, int *fd, int flag) +{ + char *cpt; + + cpt= strrchr(orig_path, '/'); + if(cpt==NULL) + tmp_path[0]= 0; + else { + strncpy(tmp_path, orig_path, cpt+1-orig_path); + tmp_path[cpt+1-orig_path]= 0; + } + strcat(tmp_path, "_tmp_xorriso_restore_XXXXXX"); + *fd= mkstemp(tmp_path); + if(*fd==-1) { + if(errno == EACCES && (flag & 128)) + return(4); + strcpy(xorriso->info_text, "Cannot create temporary file : "); + Text_shellsafe(tmp_path, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + return(0); + } + fchmod(*fd, S_IRUSR|S_IWUSR); + return(1); +} + + +/* @param flag bit0= change regardless of xorriso->do_auto_chmod + bit1= desired is only rx + @return -1=severe error , -2= cannot chmod, 0= nothing to do, 1 = chmoded +*/ +int Xorriso_auto_chmod(struct XorrisO *xorriso, char *disk_path, int flag) +{ + int ret, is_link= 0; + char *path_pt, sfe[5*SfileadrL], link_target[SfileadrL]; + mode_t mode, desired= S_IRUSR | S_IWUSR | S_IXUSR; + struct stat stbuf; + + if(!(xorriso->do_auto_chmod || (flag & 1))) + return(0); + + if(flag & 2) + desired &= ~S_IWUSR; + path_pt= disk_path; + ret= lstat(path_pt, &stbuf); + if(ret==-1) + return(0); + if(S_ISLNK(stbuf.st_mode)) { + is_link= 1; + ret= stat(path_pt, &stbuf); + if(ret==-1) + return(0); + } + if(!S_ISDIR(stbuf.st_mode)) + return(0); + if(is_link) { + ret= Xorriso_resolve_link(xorriso, path_pt, link_target, 0); + if(ret<=0) + return(ret); + path_pt= link_target; + } + if((stbuf.st_mode & desired) == desired) + return(0); + if(stbuf.st_uid!=geteuid()) + return(-2); + + mode= (stbuf.st_mode | desired) & 07777; + ret= chmod(path_pt, mode); + if(ret==-1) { + sprintf(xorriso->info_text, + "Cannot change access permissions of disk directory: chmod %o %s", + (unsigned int) (mode & 07777), Text_shellsafe(path_pt, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "SORRY", 0); + return(-2); + } + ret= Permstack_push(&(xorriso->perm_stack), path_pt, &stbuf, 0); + if(ret<=0) + return(ret); + return(1); +} + + +int Xorriso_make_accessible(struct XorrisO *xorriso, char *disk_path, int flag) +{ + int done= 0, ret, just_rx= 2; + char *npt, *apt, path[SfileadrL], *wpt; + + apt= disk_path; + wpt= path; + for(npt= apt; !done; apt= npt + 1) { + npt= strchr(apt, '/'); + if(npt == NULL) + break; + if(strchr(npt + 1, '/') == NULL) + just_rx= 0; + strncpy(wpt, apt, npt + 1 - apt); + wpt+= npt + 1 - apt; + *wpt= 0; + ret= Xorriso_auto_chmod(xorriso, path, just_rx); + if(ret == -1) + return(-1); + if(ret == -2) + return(0); + } + return(1); +} + + +/* @param flag bit0= prefer to find a match after *img_prefixes + (but deliver img_prefixes if no other can be found) +*/ +int Xorriso_make_restore_path(struct XorrisO *xorriso, + struct Xorriso_lsT **img_prefixes, struct Xorriso_lsT **disk_prefixes, + char img_path[SfileadrL], char disk_path[SfileadrL], int flag) +{ + int li; + struct Xorriso_lsT *s, *d, *found_s= NULL, *found_d= NULL; + char *ipfx, *dpfx; + + /* Obtain disk_path by replacing start piece of img_path */ + + d= *disk_prefixes; + for(s= *img_prefixes; s != NULL; + s= Xorriso_lst_get_next(s, 0), d= Xorriso_lst_get_next(d, 0)) { + + ipfx= Xorriso_lst_get_text(s, 0); + li= strlen(ipfx); + dpfx= Xorriso_lst_get_text(d, 0); + if(strncmp(img_path, ipfx, li) != 0) + continue; + if(img_path[li] != 0 && img_path[li] != '/') + continue; + if(strlen(dpfx) + strlen(img_path) - li + 1 >= SfileadrL) + return(-1); + if(img_path[li]=='/') + sprintf(disk_path, "%s/%s", dpfx, img_path + strlen(ipfx) + 1); + else + strcpy(disk_path, dpfx); + found_s= s; + found_d= d; + if(s != *img_prefixes || !(flag & 1)) + break; + } + *img_prefixes= found_s; + *disk_prefixes= found_d; + return(found_s != NULL); +} + + +/* @param flag bit0=permission to run Xorriso_make_accessible +*/ +int Xorriso_restore_make_hl(struct XorrisO *xorriso, + char *old_path, char *new_path, int flag) +{ + int ret; + struct PermiteM *perm_stack_mem; + + ret= link(old_path, new_path); + if(ret == 0) + return(1); + if(errno == EACCES && (flag & 1)) { + perm_stack_mem= xorriso->perm_stack; + ret= Xorriso_make_accessible(xorriso, new_path, 0); + if(ret > 0) { + ret= link(old_path, new_path); + if(ret == 0) { + Permstack_pop(&(xorriso->perm_stack), perm_stack_mem, xorriso, 0); + return(1); + } + } + Permstack_pop(&(xorriso->perm_stack), perm_stack_mem, xorriso, 0); + } + + sprintf(xorriso->info_text, "Hardlinking failed: "); + Text_shellsafe(new_path, xorriso->info_text, 1); + strcat(xorriso->info_text, " -> "); + Text_shellsafe(old_path, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "WARNING", 0); + return(0); +} + + +/* @param flag bit0= mark untested areas as valid +*/ +int Xorriso_spotlist_to_sectormap(struct XorrisO *xorriso, + struct SpotlisT *spotlist, + int read_chunk, + struct SectorbitmaP **map, + int flag) +{ + struct SectorbitmaP *m; + int map_sectors= -1, map_sector_size= -1; + int list_sectors, list_blocks, sector_size, sector_blocks; + int replace_map= 0, count, i, lba, blocks, quality, ret, pass; + + sector_size= Spotlist_sector_size(spotlist, read_chunk, 0); + sector_blocks= sector_size / 2048; + if(*map != NULL) + Sectorbitmap_get_layout(*map, &map_sectors, &map_sector_size, 0); + + count= Spotlist_count(spotlist, 0); + list_blocks= Spotlist_block_count(spotlist, 0); + + /* >>> ??? insist in list_blocks % sector_blocks == 0 */ + + list_sectors= list_blocks / sector_blocks; + if(list_sectors * sector_blocks < list_blocks) + list_sectors++; + if(*map != NULL && map_sectors * (map_sector_size / 2048) >= list_blocks && + map_sector_size == sector_size) + m= *map; + else { + if(*map != NULL) { + if(((off_t) (*map)->sectors) * ((off_t) (*map)->sector_size) > + ((off_t) list_sectors) * ((off_t) sector_size)) + list_sectors= (((off_t) (*map)->sectors) * + ((off_t) (*map)->sector_size)) / ((off_t) sector_size) + + 1; + } + ret= Sectorbitmap_new(&m, list_sectors, sector_size, 0); + if(ret <= 0) + return(-1); + replace_map= 1; + if(*map != NULL) { + ret= Sectorbitmap_copy(*map, m, 0); + if(ret <= 0) { + Sectorbitmap_destroy(&m, 0); + return(0); + } + } + } + + count= Spotlist_count(spotlist, 0); + /* first set good bits, then eventueally override by bad bits */ + for(pass= 0; pass < 2; pass++) { + for(i= 0; i < count; i++) { + ret= Spotlist_get_item(spotlist, i, &lba, &blocks, &quality, 0); + if(ret <= 0) + continue; + if(quality == Xorriso_read_quality_untesteD && !(flag & 1)) + continue; + if(pass == 0 && quality < Xorriso_read_quality_untesteD) + continue; + else if(pass == 1 && quality >= Xorriso_read_quality_untesteD) + continue; + Sectorbitmap_set_range(m, lba / sector_blocks, blocks / sector_blocks, + quality >= Xorriso_read_quality_untesteD); + } + } + if(replace_map) { + Sectorbitmap_destroy(map, 0); + *map= m; + } + return(1); +} + + +int Xorriso_sectormap_to_spotlist(struct XorrisO *xorriso, + struct CheckmediajoB *job, + struct SpotlisT **spotlist, + int flag) +{ + struct SectorbitmaP *map; + int ret, i, sectors, sector_size, value, old_value= -1, old_start= -1; + + map= job->sector_map; + if(map == NULL) + return(-1); + ret= Spotlist_new(spotlist, 0); + if(ret <= 0) + {ret= -1; goto ex;} + Sectorbitmap_get_layout(map, §ors, §or_size, 0); + sector_size/= 2048; + if(job->max_lba >= 0) + sectors= (job->max_lba + 1) / sector_size; + i= 0; + if(job->min_lba >= 0) + i= job->min_lba / sector_size; + for(; i < sectors; i++) { + value= Sectorbitmap_is_set(map, i, 0); + if(value == old_value) + continue; + if(old_value >= 0) { + ret= Spotlist_add_item(*spotlist, old_start, i * sector_size - old_start, + (old_value ? Xorriso_read_quality_valiD : + Xorriso_read_quality_invaliD), 0); + if(ret <= 0) + goto ex; + if(job->item_limit > 0 && + Spotlist_count(*spotlist, 0) + 1 >= job->item_limit) { + sprintf(xorriso->info_text, "-check_media: Reached item_limit=%d", + job->item_limit); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + if(sectors - i > 1) { + ret= Spotlist_add_item(*spotlist, i * sector_size, + (sectors - i - 1) * sector_size, + Xorriso_read_quality_untesteD, 0); + if(ret <= 0) + goto ex; + } + ret= 2; goto ex; + } + } + old_value= value; + old_start= i * sector_size; + } + if(old_value >= 0) { + ret= Spotlist_add_item(*spotlist, old_start, i * sector_size - old_start, + (old_value ? Xorriso_read_quality_valiD : + Xorriso_read_quality_invaliD), 0); + if(ret <= 0) + goto ex; + } + ret= 1; +ex:; + if(ret <= 0) + Spotlist_destroy(spotlist, 0); + return(ret); +} + + +int Xorriso_afile_fopen(struct XorrisO *xorriso, + char *filename, char *mode, FILE **ret_fp, int flag) +/* + bit0= do not print error message on failure +*/ +{ + FILE *fp= NULL; + + *ret_fp= NULL; + if(strcmp(filename,"-")==0) { + if(mode[0]=='a' || mode[0]=='w' || + (mode[0]=='r' && mode[1]=='+') || + (mode[0]=='r' && mode[1]=='b' && mode[2]=='+')) + fp= stdout; + else { + Xorriso_msgs_submit(xorriso, 0, "Ready for data at standard input", 0, + "NOTE", 0); + fp= stdin; + } + } else if(strncmp(filename,"tcp:",4)==0){ + Xorriso_msgs_submit(xorriso, 0, "TCP/IP service isn't implemented yet.", 0, + "FAILURE", 0); + } else if(strncmp(filename,"file:",5)==0){ + fp= fopen(filename+5,mode); + } else { + fp= fopen(filename,mode); + } + if(fp==NULL){ + if(!(flag&1)) { + sprintf(xorriso->info_text, + "Failed to open file '%s' in %s mode\n", filename, mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + } + return(0); + } + *ret_fp= fp; + return(1); +} + + +/* @param flag bit2=do not try to read ISO heads +*/ +int Xorriso_toc_to_string(struct XorrisO *xorriso, char **toc_text, int flag) +{ + int ret, stack_handle, toc_ret, l; + struct Xorriso_lsT *results= NULL, *infos= NULL, *lpt; + + *toc_text= NULL; + ret= Xorriso_push_outlists(xorriso, &stack_handle, 1); + if(ret <= 0) + goto ex; + toc_ret= Xorriso_toc(xorriso, flag & 4); + ret= Xorriso_pull_outlists(xorriso, stack_handle, &results, &infos, 0); + if(ret <= 0) + goto ex; + if(toc_ret <= 0) + {ret= toc_ret; goto ex;} + l= 0; + for(lpt= results; lpt != NULL; lpt= Xorriso_lst_get_next(lpt, 0)) + l+= strlen(Xorriso_lst_get_text(lpt, 0)); + *toc_text= calloc(l + 1, 1); + l= 0; + for(lpt= results; lpt != NULL; lpt= Xorriso_lst_get_next(lpt, 0)) { + strcpy((*toc_text) + l, Xorriso_lst_get_text(lpt, 0)); + l+= strlen(Xorriso_lst_get_text(lpt, 0)); + } +ex:; + Xorriso_lst_destroy_all(&results, 0); + Xorriso_lst_destroy_all(&infos, 0); + return(ret); +} + + +int Xorriso_open_job_data_to(struct XorrisO *xorriso, + struct CheckmediajoB *job, int flag) +{ + char sfe[5*SfileadrL]; + + if(job->data_to_path[0] == 0) + return(2); + job->data_to_fd= open(job->data_to_path, O_RDWR | O_CREAT, + S_IRUSR | S_IWUSR); + if(job->data_to_fd == -1) { + sprintf(xorriso->info_text, "Cannot open path %s", + Text_shellsafe(job->data_to_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + return(0); + } + return(1); +} + +/* + @param flag bit0= make absolute command paths with known systems + bit1= do not allow prefixes with cmd + bit2= interpret unprefixed cmd as shell: +*/ +int Xorriso_make_mount_cmd(struct XorrisO *xorriso, char *cmd, + int lba, int track, int session, char *volid, + char *devadr, char result[SfileadrL], int flag) +{ + int ret, reg_file= 0, is_safe= 0, sys_code= 0; + char form[6*SfileadrL], session_text[12], track_text[12], lba_text[12]; + char *vars[5][2], sfe[5*SfileadrL], volid_sfe[5*80+1], *cpt, *sysname; + struct stat stbuf; + + if(strlen(cmd) > SfileadrL) { +/* +too_long:; +*/ + Xorriso_msgs_submit(xorriso, 0, "Argument much too long", 0, "FAILURE", 0); + return(0); + } + ret= stat(devadr, &stbuf); + if(ret != -1) + if(S_ISREG(stbuf.st_mode)) + reg_file= 1; + if(strncmp(cmd, "linux:", 6) == 0 && !(flag & 2)) { + cpt= cmd + 6; + sys_code= 1; + } else if(strncmp(cmd, "freebsd:", 8) == 0 && !(flag & 2)) { + cpt= cmd + 8; + sys_code= 2; + } else if(strncmp(cmd, "string:", 7) == 0 && !(flag & 2)) { + cpt= cmd + 7; + strcpy(form, cpt); + } else if(flag & 4) { + cpt= cmd; + strcpy(form, cpt); + } else { + cpt= cmd; + ret= System_uname(&sysname, NULL, NULL, NULL, 0); + if(ret <= 0) { + Xorriso_msgs_submit(xorriso, 0, + "-mount*: Cannot determine current system type", + 0, "FAILURE", 0); + return(0); + } else if(strcmp(sysname, "FreeBSD") == 0) { + sys_code= 2; + } else if(strcmp(sysname, "Linux") == 0) { + sys_code= 1; + } else { + sprintf(xorriso->info_text, "-mount*: Unsupported system type %s", + Text_shellsafe(sysname, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + } + + if(sys_code == 1) { /* Linux */ + sprintf(form, + "%smount -t iso9660 -o %snodev,noexec,nosuid,ro,sbsector=%%sbsector%% %%device%% %s", + (flag & 1 ? "/bin/" : ""), (reg_file ? "loop," : ""), + Text_shellsafe(cpt, sfe, 0)); + is_safe= 1; + } else if(sys_code == 2) { /* FreeBSD */ + if(reg_file) { + +/* <<< Considered to create vnode as of + J.R. Oldroyd <fbsd@opal.com>, 20 Nov 2008 + but for now refraining from creating that persistent file object + + strcpy(form, "n=$(mdconfig -a -t vnode -f %device%)"); + sprintf(form + strlen(form), + " && mount -t cd9660 -o noexec,nosuid -s %%sbsector%% /dev/\"$n\" %s", + Text_shellsafe(cmd+8, sfe, 0)); +*/ + + Xorriso_msgs_submit(xorriso, 0, + "Detected regular file as mount device with FreeBSD style command.", + 0, "FAILURE", 0); + Xorriso_msgs_submit(xorriso, 0, +"Command mdconfig -a -t vnode -f can create a device node which uses the file", + 0, "HINT", 0); + return(0); + } else + sprintf(form, + "%smount -t cd9660 -o noexec,nosuid -s %%sbsector%% %%device%% %s", + (flag & 1 ? "/sbin/" : ""), Text_shellsafe(cmd+8, sfe, 0)); + is_safe= 1; + } + sprintf(session_text, "%d", session); + sprintf(track_text, "%d", track); + sprintf(lba_text, "%d", lba); + vars[0][0]= "sbsector"; + vars[0][1]= lba_text; + vars[1][0]= "track"; + vars[1][1]= track_text; + vars[2][0]= "session"; + vars[2][1]= session_text; + vars[3][0]= "volid"; + vars[3][1]= Text_shellsafe(volid, volid_sfe, 0); + vars[4][0]= "device"; + vars[4][1]= Text_shellsafe(devadr, sfe, 0); + ret= Sregex_resolve_var(form, vars, 5, "%", "%", "%", result, SfileadrL, 0); + if(ret <= 0) + return(ret); + return(1 + is_safe); +} + + +int Xorriso_decode_load_adr(struct XorrisO *xorriso, char *cmd, + char *adr_mode, char *adr_value, + int *entity_code, char entity_id[81], + int flag) +{ + double num; + int l; + + if(strcmp(adr_mode, "auto")==0) + *entity_code= 0; + else if(strcmp(adr_mode, "session")==0) + *entity_code= 1; + else if(strcmp(adr_mode, "track")==0) + *entity_code= 2; + else if(strcmp(adr_mode, "lba")==0 || strcmp(adr_mode, "sbsector")==0) + *entity_code= 3 | ((flag&1) << 16); + else if(strcmp(adr_mode, "volid")==0) + *entity_code= 4; + else { + sprintf(xorriso->info_text, "%s: unknown address mode '%s'", cmd, adr_mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + l= strlen(adr_value); + if(l==0) + *entity_code= 0; + + if(*entity_code>=1 && *entity_code<= 3) { + num= Scanf_io_size(adr_value, 0); + if(*entity_code==3 && + (adr_value[l-1]<'0' || adr_value[l-1]>'9')) + num/= 2048.0; + sprintf(entity_id, "%.f", num); + } else { + if(strlen(adr_value)>80) { + sprintf(xorriso->info_text, "%s: address value too long (80 < %d)", + cmd, (int) strlen(adr_value)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + strcpy(entity_id, adr_value); + } + return(1); +} + + +/* + @param flag bit0= use env_path to find the desired program +return: + <=0 : error + 1 : done +*/ +int Xorriso_execv(struct XorrisO *xorriso, char *cmd, char *env_path, + int *status, int flag) +{ + int ret, argc= 0; + char **argv= NULL, *pathlist= NULL, *cpt, *npt, prog[SfileadrL]; + char sfe[5*SfileadrL]; + pid_t child_pid; + struct stat stbuf; + + wait3(NULL,WNOHANG,NULL); /* just to remove any old dead child */ + + ret= Sfile_make_argv("", cmd, &argc, &argv, 1|4|128); + if(ret <= 0) + goto ex; + if(argc < 1) + {ret= 0; goto ex;} + + strcpy(prog, argv[0]); + if((flag & 1) && strchr(argv[0], '/') == NULL) { + if(env_path == NULL) + env_path= "/bin:/sbin"; + else if(env_path[0] == 0) + env_path= "/bin:/sbin"; + if(Sregex_string(&pathlist, env_path, 0) <= 0) + {ret= -1; goto ex;} + for(cpt= npt= pathlist; npt != NULL; cpt= npt + 1) { + npt= strchr(cpt, ':'); + if(npt != NULL) + *npt= 0; + if(strlen(cpt) + strlen(argv[0]) + 1 >= SfileadrL) + {ret= -1; goto ex;} + sprintf(prog, "%s/%s", cpt, argv[0]); + ret= stat(prog, &stbuf); + if(ret != -1) + break; + prog[0]= 0; + } + if(prog[0] == 0) { + sprintf(xorriso->info_text, "Cannot find external program %s", + Text_shellsafe(argv[0], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + } + + child_pid= fork(); + if(child_pid==-1) + return(-1); + + if(child_pid==0) { + /* this is the child process */ + + sprintf(xorriso->info_text, "Executing external program %s", + Text_shellsafe(prog, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + + execv(prog, argv); /* should never come back */ + fprintf(stderr,"--- execution of shell command failed:\n"); + fprintf(stderr," %s\n",cmd); + exit(127); + } + + + /* this is the original process waiting for child to exit */ + do { + /* try to read and print the reply */; + ret= waitpid(child_pid,status,WNOHANG); + if(ret==-1) { + if(errno!=EINTR) + ret= 0; goto ex; + } else if(ret==0) { + +#ifdef NIX + + /* >>> An interrupt key would be nice. */ + + if((flag&4)) { + ret= Asqueue_event_is_pending(agent->queue,0,0); + if(ret>0) { + Asagent_stderr(agent,"--- shell command interrupted",1); + kill(child_pid,SIGTERM); + ret= 2; goto ex; + } + } +#endif /* NIX */ + + continue; + } else { + break; + } + } while(1); + ret= 1; +ex: + Sfile_make_argv("", "", &argc, &argv, 2); + Sregex_string(&pathlist, NULL, 0); + return(ret); +} + + +/* Normalize ACL and sort apart "access" ACL from "default" ACL. + */ +int Xorriso_normalize_acl_text(struct XorrisO *xorriso, char *in_text, + char **access_acl_text, char **default_acl_text, int flag) +{ + int ret, access_count= 0, default_count= 0, pass, is_default, line_len; + int was_error= 0, line_count= 0, perms; + char *acl_text= NULL, *cpt, *npt, *access_wpt= NULL, *default_wpt= NULL; + char *dpt, *ddpt, **wpt, *ppt; + + if(in_text[0] == 0 || strcmp(in_text, "clear") == 0 || + strcmp(in_text, "--remove-all") == 0) { + *access_acl_text= *default_acl_text= NULL; + return(1); + } else if (strcmp(in_text, "--remove-default") == 0) { + + /* >>> protect Access-ACL and delete Default-ACL */; + + /* <<< */ + return(0); + + } + + acl_text= strdup(in_text); + if(acl_text == NULL) { + Xorriso_no_malloc_memory(xorriso, NULL, 0); + {ret= -1; goto ex;} + } + + /* From comma to newline */ + for(cpt= strchr(acl_text, ','); cpt != NULL; cpt= strchr(cpt + 1, ',')) + *cpt= '\n'; + + /* Normalize to long text form + and sort apart "access" ACL from "default" ACL */; + for(pass= 0; pass < 2; pass++) { + line_count= 0; + for(cpt= acl_text; cpt != NULL; cpt= npt) { + line_count++; + npt= strchr(cpt, '\n'); + if(npt != NULL) + npt++; + if(*cpt == '#' || *cpt == '\n' || *cpt == 0) + continue; + + is_default= 0; + wpt= &access_wpt; + if(*cpt == 'd') { + is_default= 1; + if(pass == 1) + wpt= &default_wpt; + cpt= strchr(cpt, ':'); + if(cpt == NULL) { + was_error= line_count; + continue; + } + cpt++; + } + + line_len= 0; + dpt= strchr(cpt, ':'); + if(dpt != NULL) + ddpt= strchr(dpt + 1, ':'); + if(dpt == NULL || ddpt == NULL) { + was_error= line_count; + continue; + } + if(*cpt == 'u') { + if(pass == 0) { + line_len+= 5; + line_len+= ddpt - dpt; + } else { + strcpy(*wpt, "user:"); + strncpy(*wpt + 5, dpt + 1, ddpt - dpt); + (*wpt)+= 5 + (ddpt - dpt); + } + } else if(*cpt == 'g') { + if(pass == 0) { + line_len+= 6 + (ddpt - dpt); + } else { + strcpy(*wpt, "group:"); + strncpy(*wpt + 6, dpt + 1, ddpt - dpt); + (*wpt)+= 6 + (ddpt - dpt); + } + } else if(*cpt == 'o') { + if(pass == 0) { + if(ddpt - dpt > 1) { + was_error= line_count; + continue; + } + line_len+= 6 + (ddpt - dpt); + } else { + strcpy(*wpt, "other:"); + strncpy(*wpt + 6, dpt + 1, ddpt - dpt); + (*wpt)+= 6 + (ddpt - dpt); + } + } else if(*cpt == 'm') { + if(pass == 0) { + if(ddpt - dpt > 1) { + was_error= line_count; + continue; + } + line_len+= 5 + (ddpt - dpt); + } else { + strcpy(*wpt, "mask:"); + strncpy(*wpt + 5, dpt + 1, ddpt - dpt); + (*wpt)+= 5 + (ddpt - dpt); + } + + } else { + /* Unknown tag type */ + was_error= line_count; + continue; + } + + /* Examine permissions at ddpt + 1 */; + perms= 0; + for(ppt= ddpt + 1; *ppt != 0 && *ppt != '\n'; ppt++) { + if(*ppt == 'r') + perms|= 4; + else if(*ppt == 'w') + perms|= 2; + else if(*ppt == 'x') + perms|= 1; + else if(*ppt == '-' || *ppt == ' ' || *ppt == '\t') + ; + else if(*ppt == '#') + break; + else { + was_error= line_count; + break; + } + } + if(pass == 0) { + line_len+= 4; + } else { + sprintf(*wpt, "%c%c%c\n", + perms & 4 ? 'r' : '-', perms & 2 ? 'w' : '-', perms & 1 ? 'x' : '-'); + (*wpt)+= 4; + } + + if(pass == 0) { + if(is_default) + default_count+= line_len; + else + access_count+= line_len; + } + } + + if(pass == 0) { + *access_acl_text= calloc(access_count + 1, 1); + *default_acl_text= calloc(default_count + 1, 1); + if(access_acl_text == NULL || *default_acl_text == NULL) { + Xorriso_no_malloc_memory(xorriso, access_acl_text, 0); + {ret= -1; goto ex;} + } + access_wpt= *access_acl_text; + default_wpt= *default_acl_text; + } else { + *access_wpt= 0; + *default_wpt= 0; + } + } + + ret= 1; +ex:; + if(acl_text != NULL) + free(acl_text); + if(was_error) { + sprintf(xorriso->info_text, + "Malformed ACL entries encountered. Last one in line number %d.", + was_error); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(ret); +} + + +int Xorriso_perform_acl_from_list(struct XorrisO *xorriso, char *file_path, + char *uid, char *gid, char *acl, int flag) +{ + int ret, zero= 0; + uid_t uid_number; + gid_t gid_number; + + /* Set group and owner */ + if(gid[0]) { + ret= Xorriso_convert_gidstring(xorriso, gid, &gid_number, 0); + if(ret<=0) + return(ret); + ret= Xorriso_set_gid(xorriso, file_path, gid_number, 0); + if(ret<=0) + return(ret); + } + if(uid[0]) { + ret= Xorriso_convert_uidstring(xorriso, uid, &uid_number, 0); + if(ret<=0) + return(ret); + ret= Xorriso_set_uid(xorriso, file_path, uid_number, 0); + if(ret<=0) + return(ret); + } + ret= Xorriso_option_setfacli(xorriso, acl, 1, &file_path, &zero, 0); + if(ret <= 0) + return(ret); + return(1); +} + + +/* + @param flag bit0= do not perform setfattr but only check input +*/ +int Xorriso_path_setfattr(struct XorrisO *xorriso, void *in_node, char *path, + char *name, size_t value_length, char *value, int flag) +{ + int ret, hflag; + size_t num_attrs= 1; + char *name_pt; + + hflag= 2; + name_pt= name; + if(name[0] == 0) { + sprintf(xorriso->info_text, + "-setfattr: Empty attribute name is not allowed"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } else if(strcmp(name, "--remove-all") == 0) { + if(value[0]) { + sprintf(xorriso->info_text, + "-setfattr: Value is not empty with pseudo name --remove-all"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + num_attrs= 0; + hflag= 0; + } else if(name[0] == '-') { + name_pt++; + hflag|= 4; + } else if(name[0] == '=' || name[0] == '+') { + name_pt++; + } + if(flag & 1) + return(1); + ret= Xorriso_setfattr(xorriso, in_node, path, + num_attrs, &name_pt, &value_length, &value, hflag); + return(ret); +} + + +/* Warning: The text content of lst gets mangled by 0s and unescaping. +*/ +int Xorriso_perform_attr_from_list(struct XorrisO *xorriso, char *path, + struct Xorriso_lsT *lst_start, int flag) +{ + int ret, eaten; + char *valuept, *ept, *line, **names= NULL, **values= NULL; + size_t num_attr= 0, *value_lengths= NULL, v_len; + struct Xorriso_lsT *lst; + + for(lst= lst_start; lst != NULL; lst= Xorriso_lst_get_next(lst, 0)) + num_attr++; + if(num_attr == 0) { + ret= Xorriso_setfattr(xorriso, NULL, path, num_attr, NULL, NULL, NULL, 0); + goto ex; + } + + names= calloc(num_attr, sizeof(char *)); + if(names == NULL) { + Xorriso_no_malloc_memory(xorriso, NULL, 0); + ret= -1; goto ex; + } + value_lengths= calloc(num_attr, sizeof(size_t)); + if(value_lengths== NULL) { + free(names); + Xorriso_no_malloc_memory(xorriso, NULL, 0); + ret= -1; goto ex; + } + values= calloc(num_attr, sizeof(char *)); + if(values== NULL) { + free(names); + free(value_lengths); + Xorriso_no_malloc_memory(xorriso, NULL, 0); + ret= -1; goto ex; + } + + num_attr= 0; + for(lst= lst_start; lst != NULL; lst= Xorriso_lst_get_next(lst, 0)) { + line= Xorriso_lst_get_text(lst, 0); + ept= strchr(line, '='); + if(ept == NULL) + continue; + /* Split into name and content */; + *ept= 0; + valuept= ept + 1; + + /* Strip quotes from value */ + v_len= strlen(valuept); + if(v_len < 2 || *valuept != '"' || *(valuept + v_len - 1) != '"') + continue; + *valuept= 0; + *(valuept + v_len - 1)= 0; + valuept++; + v_len-= 2; + + /* Unescape backslashes , values eventually with 0-bytes */ + ret= Sfile_bsl_interpreter(line, strlen(line), &eaten, 0); + if(ret <= 0) + continue; + ret= Sfile_bsl_interpreter(valuept, (int) v_len, &eaten, 2); + if(ret <= 0) + continue; + + names[num_attr]= line; + values[num_attr]= valuept; + value_lengths[num_attr]= v_len - eaten; + num_attr++; + } + ret= Xorriso_setfattr(xorriso, NULL, path, num_attr, names, + value_lengths, values, 0); +ex:; + if(names != NULL) + free(names); + if(value_lengths != NULL) + free(value_lengths); + if(values != NULL) + free(values); + return(ret); +} + + +/* @param flag bit0= no hardlink reconstruction + bit1= do not set xorriso->node_*_prefixes + bit5= -extract_single: eventually do not insert directory tree +*/ +int Xorriso_restore_sorted(struct XorrisO *xorriso, int count, + char **src_array, char **tgt_array, int flag) +{ + int i, ret, with_node_array= 0, hflag= 0, hret; + + if(!(((xorriso->ino_behavior & 16) && xorriso->do_restore_sort_lba) || + (xorriso->ino_behavior & 4) || (flag & 1))) { + ret= Xorriso_make_hln_array(xorriso, 0); + if(ret<=0) + goto ex; + } + if(xorriso->do_restore_sort_lba) { + /* Count affected nodes */ + Xorriso_destroy_node_array(xorriso, 0); + for(i= 0; i < count; i++) { + if(src_array[i] == NULL || tgt_array[i] == NULL) + continue; + /* sort_lba : Make directories plus node_array and then + run array extractor (with eventual hardlink detection) + */ + hflag= (1 << 7) | ((!!(flag & 2)) << 9); + ret= Xorriso_restore(xorriso, src_array[i], tgt_array[i], + (off_t) 0, (off_t) 0, hflag); + if(ret <= 0) { + hret= Xorriso_eval_problem_status(xorriso, ret, 0); + if(ret < 0) + goto ex; + } + with_node_array= 1; + } + } + + if(with_node_array) { + /* Allocate and fill node array */ + if(xorriso->node_counter <= 0) + {ret= 2; goto ex;} + ret= Xorriso_new_node_array(xorriso, xorriso->temp_mem_limit, 0, + !xorriso->do_restore_sort_lba); + if(ret<=0) + goto ex; + for(i= 0; i < count; i++) { + if(src_array[i] == NULL || tgt_array[i] == NULL) + continue; + ret= Xorriso_restore(xorriso, src_array[i], tgt_array[i], + (off_t) 0, (off_t) 0, 2 << 7); + if(ret <= 0) { + hret= Xorriso_eval_problem_status(xorriso, ret, 0); + if(ret < 0) + goto ex; + } + } + } + + /* Perform restore operations */ + if(xorriso->do_restore_sort_lba) { + ret= Xorriso_restore_node_array(xorriso, 0); + if(ret <= 0) + goto ex; + } else { + for(i= 0; i < count; i++) { + if(src_array[i] == NULL || tgt_array[i] == NULL) + continue; + ret= Xorriso_restore(xorriso, src_array[i], tgt_array[i], + (off_t) 0, (off_t) 0, 0); + if(ret <= 0) { + hret= Xorriso_eval_problem_status(xorriso, ret, flag & 32); + if(ret < 0) + goto ex; + } + } + } + + ret= 1; +ex:; + return(ret); +} + + +int Xorriso_report_md5_outcome(struct XorrisO *xorriso, char *severity, + int flag) +{ + int has_md5; + + has_md5= Xorriso_image_has_md5(xorriso, 0); + if(xorriso->find_check_md5_result & 1) { + sprintf(xorriso->result_line, + "Mismatch detected between file contents and MD5 checksums.\n"); + } else if(xorriso->find_check_md5_result & 8) { + sprintf(xorriso->result_line, + "File contents and their MD5 checksums match.\n"); + } else { + sprintf(xorriso->result_line, + "Not a single file with MD5 checksum was found."); + if(has_md5 <= 0) + strcat(xorriso->result_line, + " (There is no MD5 checksum array loaded.)\n"); + else + strcat(xorriso->result_line, "\n"); + } + Xorriso_result(xorriso,0); + if(xorriso->find_check_md5_result & 2) { + sprintf(xorriso->result_line, + "Encountered errors other than non-match during MD5 checking.\n"); + Xorriso_result(xorriso,0); + } + if((xorriso->find_check_md5_result & 4) && has_md5) { + sprintf(xorriso->result_line, + "There were data files which have no MD5 and thus could not be checked.\n"); + Xorriso_result(xorriso,0); + } + if((xorriso->find_check_md5_result & 3) && strcmp(severity, "ALL") != 0) { + sprintf(xorriso->info_text, "Event triggered by MD5 comparison mismatch"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, severity, 0); + } + return(1); +} + + +/* ---------------------------- Options API ------------------------ */ + + +/* Option -abort_on */ +int Xorriso_option_abort_on(struct XorrisO *xorriso, char *severity, int flag) +{ + int ret, sev; + char sfe[5*SfileadrL]; + + ret= Xorriso__text_to_sev(severity, &sev, 0); + if(ret<=0) { + sprintf(xorriso->info_text, + "-abort_on: Not a known severity name : %s", + Text_shellsafe(severity, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(ret); + } + if(Sfile_str(xorriso->abort_on_text,severity,0)<=0) + return(-1); + xorriso->abort_on_severity= sev; + Xorriso_set_abort_severity(xorriso, 0); + return(1); +} + + +/* Option -acl "on"|"off" */ +int Xorriso_option_acl(struct XorrisO *xorriso, char *mode, int flag) +{ + int ret; + + if(strcmp(mode, "off")==0) + xorriso->do_aaip&= ~3; + else if(strcmp(mode, "on")==0) + xorriso->do_aaip|= (1 | 2); + else { + sprintf(xorriso->info_text, "-acl: unknown mode '%s'", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + ret= Xorriso_set_ignore_aclea(xorriso, 0); + if(ret <= 0) + return(ret); + return(1); +} + + +/* Option -add */ +/* @param flag bit0=do not report the added item + bit1=do not reset pacifier, no final pacifier message +*/ +int Xorriso_option_add(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int i, end_idx, ret, was_failure= 0, fret, optc= 0, split; + char target[SfileadrL], source[SfileadrL], *ept, eff_path[SfileadrL]; + char **optv= NULL, *rpt, *wpt; + + ret= Xorriso_opt_args(xorriso, "-add", argc, argv, *idx, &end_idx, + &optc, &optv, ((!!xorriso->allow_graft_points)<<2)|2); + if(ret<=0) + goto ex; + + if(!(flag&2)) + Xorriso_pacifier_reset(xorriso, 0); + for(i= 0; i<optc; i++) { + if(Sfile_str(target,optv[i],0)<=0) + {ret= -1; goto ex;} + strcpy(source, optv[i]); + split= 0; + if(xorriso->allow_graft_points) { + ret= Fileliste__target_source_limit(target, '=', &ept, 0); + if(ret>0) { + *ept= 0; + strcpy(source, ept+1); + split= 1; + } + /* unescape \= */; + if(split) + rpt= wpt= target; + else + rpt= wpt= source; + for(; *rpt!=0; rpt++) { + if(*rpt=='\\') + if(*(rpt+1)=='=') + continue; + *(wpt++)= *rpt; + } + *wpt= 0; + } + if(split==0) { + strcpy(target, source); + } else if(target[0]!='/') { + ret= Sfile_prepend_path(xorriso->wdi, target, 0); + if(ret<=0) + goto problem_handler; + } + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, target, eff_path, 2); + if(ret<=0) + goto problem_handler; + strcpy(target, eff_path); + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, source,eff_path,2|4); + if(ret<=0) + goto problem_handler; + strcpy(source, eff_path); + + ret= Xorriso_graft_in(xorriso, NULL, source, target, (off_t)0, (off_t)0, 0); + if(ret<=0 || xorriso->request_to_abort) + goto problem_handler; + sprintf(xorriso->info_text, "Added to ISO image: %s '%s'='%s'\n", + (ret>1 ? "directory" : "file"), (target[0] ? target : "/"), source); + if(!(flag&1)) + Xorriso_info(xorriso, 0); + + continue; /* regular bottom of loop */ +problem_handler:; + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + goto ex; + } + if(!(flag&2)) + Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count, + xorriso->pacifier_total, "", 1); + ret= 1; +ex:; + (*idx)= end_idx; + Xorriso_opt_args(xorriso, "-add", argc, argv, *idx, &end_idx, &optc, &optv, + 256); + if(ret<=0) + return(ret); + return(!was_failure); +} + + +/* Option -add_plainly "none"|"unknown" */ +int Xorriso_option_add_plainly(struct XorrisO *xorriso, char *mode,int flag) +{ + if(strcmp(mode, "none")==0) + xorriso->add_plainly= 0; + if(strcmp(mode, "unknown")==0) + xorriso->add_plainly= 1; + else if(strcmp(mode, "dashed")==0) + xorriso->add_plainly= 2; + else if(strcmp(mode, "any")==0) + xorriso->add_plainly= 3; + else { + sprintf(xorriso->info_text, "-add_plainly: unknown mode '%s'", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(1); +} + + +/* Option -alter_date , -alter_date_r */ +/* @param flag bit0=recursive (-alter_date_r) +*/ +int Xorriso_option_alter_date(struct XorrisO *xorriso, + char *time_type, char *timestring, + int argc, char **argv, int *idx, int flag) +{ + int i, ret, was_failure= 0, t_type= 0, end_idx, fret; + time_t t; + int optc= 0; + char **optv= NULL; + struct FindjoB *job= NULL; + struct stat dir_stbuf; + + ret= Xorriso_opt_args(xorriso, "-alter_date", argc, argv, *idx, &end_idx, + &optc, &optv, 0); + if(ret<=0) + goto ex; + ret= Xorriso_convert_datestring(xorriso, "-alter_date", time_type, timestring, + &t_type, &t, 0); + if(ret<=0) + goto ex; + for(i= 0; i<optc; i++) { + if(flag&1) { + ret= Findjob_new(&job, optv[i], 0); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-alter_date", 0); + {ret= -1; goto ex;} + } + Findjob_set_action_ad(job, t_type, t, 0); + ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0, + NULL, optv[i], &dir_stbuf, 0, 0); + Findjob_destroy(&job, 0); + } else + ret= Xorriso_set_time(xorriso, optv[i], t, t_type); + if(ret>0 && !xorriso->request_to_abort) + continue; /* regular bottom of loop */ + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + goto ex; + } + ret= 1; +ex:; + (*idx)= end_idx; + Xorriso_opt_args(xorriso, "-alter_date", argc, argv, *idx, &end_idx, &optc, + &optv, 256); + Findjob_destroy(&job, 0); + if(ret<=0) + return(ret); + return(!was_failure); +} + + +/* Option -application_id */ +int Xorriso_option_application_id(struct XorrisO *xorriso, char *name, + int flag) +{ + if(strlen(name)>=sizeof(xorriso->application_id)) { + sprintf(xorriso->info_text, + "Name too long with option -application_id (%d > %d)", + (int) strlen(name), (int) sizeof(xorriso->application_id)-1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + if(Sfile_str(xorriso->application_id,name,0)<=0) + return(-1); + return(1); +} + + +/* Option -as */ +/* @param flag bit0=do not report the added item + bit1=do not reset pacifier, no final pacifier message +*/ +int Xorriso_option_as(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int end_idx, ret, idx_count; + + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1); + idx_count= end_idx-(*idx); + if(end_idx<=0 || (*idx)>=argc) { + if(idx_count<1) + sprintf(xorriso->info_text, + "-as : Not enough arguments given. Needed: whom do_what %s", + xorriso->list_delimiter); + else + sprintf(xorriso->info_text, + "-as %s : Not enough arguments given. Needed: do_what %s", + argv[*idx], xorriso->list_delimiter); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + if(strcmp(argv[*idx], "cdrecord")==0 || strcmp(argv[*idx], "wodim")==0 || + strcmp(argv[*idx], "cdrskin")==0 || strcmp(argv[*idx], "xorrecord")==0) { + ret= Xorriso_cdrskin(xorriso, argv[*idx], end_idx-(*idx)-1, argv+(*idx)+1, + 0); + if(ret<=0) + goto ex; + } else if(strcmp(argv[*idx], "mkisofs")==0 || + strcmp(argv[*idx], "genisoimage")==0 || + strcmp(argv[*idx], "genisofs")==0 || + strcmp(argv[*idx], "xorrisofs")==0) { + ret= Xorriso_genisofs(xorriso, argv[*idx], end_idx-(*idx)-1, argv+(*idx)+1, + 0); + if(ret<=0) + goto ex; + } else { + sprintf(xorriso->info_text, + "-as : Not a known emulation personality: '%s'", argv[*idx]); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + + ret= 1; +ex:; + (*idx)= end_idx; + return(ret); +} + + +/* Option -assert_volid */ +int Xorriso_option_assert_volid(struct XorrisO *xorriso, char *pattern, + char *severity, int flag) +{ + int ret, sev; + char *sev_text= ""; + + if(strlen(pattern)>=sizeof(xorriso->assert_volid)) { + sprintf(xorriso->info_text, + "Name too long with option -application_id (%d > %d)", + (int) strlen(pattern), (int) sizeof(xorriso->assert_volid)-1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + if(pattern[0]) { + ret= Sregex_match(pattern, "", 1); + if(ret <= 0) { + sprintf(xorriso->info_text, "-assert_volid: Cannot use given pattern."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + } + if(severity[0] != 0 || pattern[0] != 0) { + if(severity[0] == 0) + sev_text= xorriso->abort_on_text; + else + sev_text= severity; + if(strcmp(sev_text, "NEVER") == 0) + sev_text= "ABORT"; + ret= Xorriso__text_to_sev(sev_text, &sev, 0); + if(ret<=0) { + sprintf(xorriso->info_text, "-assert_volid: Not a known severity name : "); + Text_shellsafe(severity, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(ret); + } + } + if(Sfile_str(xorriso->assert_volid, pattern,0) <= 0) + return(-1); + strcpy(xorriso->assert_volid_sev, sev_text); + return(1); +} + + +/* Option -auto_charset "on"|"off" */ +int Xorriso_option_auto_charset(struct XorrisO *xorriso, char *mode, int flag) +{ + if(strcmp(mode, "off")==0) + xorriso->do_aaip&= ~(256 | 512); + else if(strcmp(mode, "on")==0) + xorriso->do_aaip|= (256 | 512); + else { + sprintf(xorriso->info_text, "-auto_charset: unknown mode '%s'", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(1); +} + + +/* Option -backslash_codes */ +int Xorriso_option_backslash_codes(struct XorrisO *xorriso, char *mode, + int flag) +{ + char *npt, *cpt; + int l, was; + + was= xorriso->bsl_interpretation; + xorriso->bsl_interpretation= 0; + npt= cpt= mode; + for(; npt!=NULL; cpt= npt+1) { + npt= strchr(cpt,':'); + if(npt==NULL) + l= strlen(cpt); + else + l= npt-cpt; + if(l == 0) + continue; + if(l == 3 && strncmp(cpt, "off", l)==0) { + xorriso->bsl_interpretation= 0; + } else if(l == 16 && strncmp(cpt, "in_double_quotes", l)==0) { + xorriso->bsl_interpretation= (xorriso->bsl_interpretation & ~3) | 1; + } else if(l == 9 && strncmp(cpt, "in_quotes", l)==0) { + xorriso->bsl_interpretation= (xorriso->bsl_interpretation & ~3) | 2; + } else if(l == 17 && strncmp(cpt, "with_quoted_input", l)==0) { + xorriso->bsl_interpretation= (xorriso->bsl_interpretation & ~3) | 3; + } else if(l == 22 && strncmp(cpt, "with_program_arguments", l)==0) { + xorriso->bsl_interpretation= xorriso->bsl_interpretation | 16; + } else if(l == 13 && strncmp(cpt, "encode_output", l)==0) { + xorriso->bsl_interpretation= xorriso->bsl_interpretation | 32 | 64; + } else if(l == 14 && strncmp(cpt, "encode_results", l)==0) { + xorriso->bsl_interpretation= xorriso->bsl_interpretation | 32; + } else if(l == 12 && strncmp(cpt, "encode_infos", l)==0) { + xorriso->bsl_interpretation= xorriso->bsl_interpretation | 64; + } else if(l == 2 && strncmp(cpt, "on", l)==0) { + xorriso->bsl_interpretation= 3 | 16 | 32 | 64; + } else { + if(l<SfileadrL) + sprintf(xorriso->info_text, "-backslash_codes: unknown mode '%s'", cpt); + else + sprintf(xorriso->info_text, + "-backslash_codes: oversized mode parameter (%d)", l); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + xorriso->bsl_interpretation= was; + return(0); + } + } + return(1); +} + + +/* Option -ban_stdio_write */ +int Xorriso_option_ban_stdio_write(struct XorrisO *xorriso, int flag) +{ + xorriso->ban_stdio_write= 1; + return(1); +} + + +/* Option -blank and -format */ +/* @param flag bit0= format rather than blank + @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_blank(struct XorrisO *xorriso, char *mode, int flag) +{ + char drive_name[SfileadrL], *cmd= "-blank"; + int aq_ret, ret, aq_flag= 2, mode_flag= 0, as_needed= 0, idx; + off_t size= 0; + + if(flag&1) + cmd= "-format"; + if(xorriso->out_drive_handle == NULL) { + sprintf(xorriso->info_text, + "%s: No output drive set by -dev -or -outdev", cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if(xorriso->in_drive_handle == xorriso->out_drive_handle) { + if(xorriso->volset_change_pending) { + sprintf(xorriso->info_text, + "%s: Image changes pending. -commit or -rollback first.", cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + aq_flag= 3; + } + ret= Xorriso_reassure(xorriso, cmd, + "possibly make unreadable data on outdev", 0); + if(ret<=0) + return(2); + + if(strcmp(mode, "as_needed")==0 || mode[0]==0) + as_needed= 1; + else if(strcmp(mode, "all")==0 || strcmp(mode, "full")==0) + mode_flag= 0; + else if((strcmp(mode, "deformat")==0 || + strcmp(mode, "deformat_sequential")==0) && !(flag&1)) + mode_flag= 2; + else if((strcmp(mode, "deformat_quickest")==0 || + strcmp(mode, "deformat_sequential_quickest")==0) && !(flag&1)) + mode_flag= 3; + else if(strcmp(mode, "fast")==0) + mode_flag= 1; + else if(strncmp(mode, "by_index_", 9)==0 && (flag&1)) { + mode_flag= 128; + idx= -1; + if(strlen(mode)>9) + sscanf(mode+9, "%d", &idx); + if(idx<0 || idx>255) { +unusable_index:; + sprintf(xorriso->info_text, + "-format: mode '%s' provides unusable index number", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + mode_flag|= (idx<<8); + } else if(strncmp(mode, "fast_by_index_", 14)==0 && (flag&1)) { + mode_flag= 1 | 128; + idx= -1; + if(strlen(mode)>14) + sscanf(mode+14, "%d", &idx); + if(idx<0 || idx>255) + goto unusable_index; + mode_flag|= (idx<<8); + } else if(strncmp(mode, "by_size_", 8) == 0 && (flag & 1)) { + size= (off_t) Scanf_io_size(mode + 8, 0); + if(size <= 0) { +unusable_size:; + sprintf(xorriso->info_text, + "-format: mode '%s' provides unusable size value", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + mode_flag= 2; + } else if(strncmp(mode, "fast_by_size_", 13) == 0 && (flag & 1)) { + size= (off_t) Scanf_io_size(mode + 13, 0); + if(size <= 0) + goto unusable_size; + mode_flag= 3; + } else { + sprintf(xorriso->info_text, + "%s: Unknown %s mode '%s'", + cmd, ((flag&1) ? "-format" : "-blank"), mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if(as_needed) + ret= Xorriso_blank_as_needed(xorriso, (flag&1)<<2); + else if(flag&1) + ret= Xorriso_format_media(xorriso, size, mode_flag & 0xff83); + else + ret= Xorriso_blank_media(xorriso, mode_flag&3); + if(ret==0) + return(ret); + strcpy(drive_name, xorriso->outdev); + if(ret <= 0) { /* in case of success, above functions will have re-aquired */ + aq_ret= Xorriso_reaquire_outdev(xorriso, 0); /* actually give up drive */ + if(ret<aq_ret) + return(ret); + if(aq_ret<=0) + return(aq_ret); + } + return(1); +} + + +/* Option -boot_image */ +int Xorriso_option_boot_image(struct XorrisO *xorriso, char *form, + char *treatment, int flag) +{ + int was_ok= 1, ret; + char *formpt, *treatpt; + double num; + + formpt= form; + if(formpt[0]=='-') + formpt++; + treatpt= treatment; + if(treatpt[0]=='-') + treatpt++; + if(strcmp(formpt, "any")==0) { + if(strcmp(treatpt, "keep")==0) { + xorriso->keep_boot_image= 1; + xorriso->patch_isolinux_image= 0; + xorriso->boot_image_bin_path[0]= 0; + } else if(strcmp(treatpt, "discard")==0) { + xorriso->keep_boot_image= 0; + xorriso->patch_isolinux_image= 0; + xorriso->boot_image_bin_path[0]= 0; + } else if(strcmp(treatpt, "show_status")==0) { +show_status:; + sprintf(xorriso->result_line, "------------------------------------\n"); + Xorriso_result(xorriso, 0); + sprintf(xorriso->result_line, "Status of loaded boot image :\n"); + Xorriso_result(xorriso, 0); + sprintf(xorriso->result_line, "------------------------------------\n"); + Xorriso_result(xorriso, 0); + Xorriso_show_boot_info(xorriso, 0); + sprintf(xorriso->result_line, "------------------------------------\n"); + Xorriso_result(xorriso, 0); + sprintf(xorriso->result_line, "Boot image settings for next commit:\n"); + Xorriso_result(xorriso, 0); + sprintf(xorriso->result_line, "------------------------------------\n"); + Xorriso_result(xorriso, 0); + Xorriso_status(xorriso, "-boot_image", NULL, 0); + sprintf(xorriso->result_line, "------------------------------------\n"); + Xorriso_result(xorriso, 0); + } else + was_ok= 0; + } else if(strcmp(formpt, "isolinux")==0) { + if(strcmp(treatpt, "patch")==0 || + strcmp(treatpt, "keep")==0) { /* no real "keep" with ISOLINUX */ + xorriso->keep_boot_image= 1; + xorriso->patch_isolinux_image= 1; + xorriso->boot_image_bin_path[0]= 0; + } else if(strcmp(treatpt, "discard")==0) { + xorriso->keep_boot_image= 0; + xorriso->patch_isolinux_image= 0; + xorriso->boot_image_bin_path[0]= 0; + } else if(strcmp(treatpt, "show_status")==0) { + goto show_status; + } else if(strncmp(treatpt, "dir=", 4) == 0) { + /* The three locations mentioned in http://syslinux.zytor.com/iso.php */ + if(strcmp(treatpt + 4, "/") == 0) + strcpy(xorriso->boot_image_bin_path, "/"); + else if(strcmp(treatpt + 4, "isolinux") == 0 + || strcmp(treatpt + 4, "/isolinux") == 0) + strcpy(xorriso->boot_image_bin_path, "/isolinux/"); + else if(strcmp(treatpt + 4, "boot/isolinux") == 0 + || strcmp(treatpt + 4, "/boot/isolinux") == 0 + || strcmp(treatpt + 4, "boot") == 0 + || strcmp(treatpt + 4, "/boot") == 0) + strcpy(xorriso->boot_image_bin_path, "/boot/isolinux/"); + else { + sprintf(xorriso->info_text, + "Unrecognized keyword with -boot_image %s %s", + form, treatment); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + sprintf(xorriso->info_text, + "Allowed with dir= are / , /isolinux . /boot/isolinux"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0); + return(0); + } + strcpy(xorriso->boot_image_cat_path, xorriso->boot_image_bin_path); + strcat(xorriso->boot_image_bin_path, "isolinux.bin"); + strcat(xorriso->boot_image_cat_path, "boot.cat"); + xorriso->boot_image_load_size= 4 * 512; + xorriso->keep_boot_image= 0; + xorriso->patch_isolinux_image= 0; + } else if(strncmp(treatpt, "bin_path=", 9) == 0) { + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, treatpt + 9, + xorriso->boot_image_bin_path, 2); + if(ret <= 0) + return(ret); + xorriso->keep_boot_image= 0; + xorriso->patch_isolinux_image= 0; + if(xorriso->boot_image_bin_path[0]) + xorriso->boot_image_load_size= 4 * 512; + } else if(strncmp(treatpt, "cat_path=", 9) == 0) { + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, treatpt + 9, + xorriso->boot_image_cat_path, 2); + if(ret <= 0) + return(ret); + } else if(strncmp(treatpt, "load_size=", 10) == 0) { + num= Scanf_io_size(treatpt + 10, 0); + if(num < 512) { + sprintf(xorriso->info_text, + "-boot_image isolinux : load_size too small (%s < 512)", + treatpt + 10); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + xorriso->boot_image_load_size= num; + } else if(strncmp(treatpt, "isohybrid=", 10) == 0) { + if(strcmp(treatpt + 10, "off") == 0) + xorriso->boot_image_isohybrid= 0; + else if(strcmp(treatpt + 10, "auto") == 0) + xorriso->boot_image_isohybrid= 1; + else if(strcmp(treatpt + 10, "on") == 0) + xorriso->boot_image_isohybrid= 2; + else if(strcmp(treatpt + 10, "force") == 0) + xorriso->boot_image_isohybrid= 3; + else { + sprintf(xorriso->info_text, + "Unrecognized keyword with -boot_image %s %s", + form, treatment); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + sprintf(xorriso->info_text, + "Allowed with isohybrid= are: off , auto , on , force"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0); + return(0); + + } + } else + was_ok= 0; + } else + was_ok= 0; + + /* >>> BOOT : check whether directories and/or files exist: + bin_path , dirname(cat_path), + isolinux.cfg in / , /isolinux , or /boot/isolinux + */ + + if(!was_ok) { + sprintf(xorriso->info_text, "Unrecognized options with -boot_image: %s %s", + form, treatment); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(1); +} + + +/* Option -calm_drive */ +int Xorriso_option_calm_drive(struct XorrisO *xorriso, char *which, int flag) +{ + int gu_flag= 4, ret; + + if(strncmp(which,"in",2)==0) + gu_flag|= 1; + else if(strncmp(which,"out",3)==0) + gu_flag|= 2; + else if(strncmp(which,"on",2)==0) { + xorriso->do_calm_drive|= 1; + } else if(strncmp(which,"off",3)==0) { + xorriso->do_calm_drive&= ~1; + } else if(strncmp(which,"off",3)==0) { + } else + gu_flag|= 3; + ret= Xorriso_drive_snooze(xorriso, gu_flag); + return(ret); +} + + +/* Option -cd alias -cdi */ +int Xorriso_option_cdi(struct XorrisO *xorriso, char *iso_rr_path, int flag) +{ + char sfe[5*SfileadrL], path[SfileadrL], eff_path[SfileadrL]; + int ret; + + if (strlen(iso_rr_path)>sizeof(xorriso->wdi)) { + sprintf(xorriso->info_text,"-cdi: iso_rr_path too long (%d > %d)", + (int) strlen(iso_rr_path), (int) sizeof(xorriso->wdi)-1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + Xorriso_warn_of_wildcards(xorriso, iso_rr_path, 1); + sprintf(xorriso->info_text,"previous working directory:\n"); + Xorriso_info(xorriso,0); + sprintf(xorriso->result_line,"%s/\n",Text_shellsafe(xorriso->wdi, sfe, 0)); + Xorriso_result(xorriso,0); + if(strcmp(iso_rr_path,"/")==0 || iso_rr_path[0]==0) { + strcpy(xorriso->wdi,""); + Xorriso_option_pwdi(xorriso, 0); + return(1); + } else if(iso_rr_path[0]!='/') { + strcpy(path, xorriso->wdi); + if(Sfile_add_to_path(path,iso_rr_path,0)<=0) + return(-1); + } else { + if(Sfile_str(path,iso_rr_path,0)<=0) + return(-1); + } + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 1); + if(ret<0) + return(ret); + if(ret==0) { + sprintf(xorriso->info_text, "-cdi: not existing yet in ISO image : %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 2); + if(ret<=0) + return(ret); + } else if(ret!=2) { + sprintf(xorriso->info_text, "-cdi: not a directory : %s", + Text_shellsafe(eff_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + strcpy(xorriso->wdi, eff_path); + + Xorriso_option_pwdi(xorriso, 0); + return(1); +} + + +/* Option -cdx */ +int Xorriso_option_cdx(struct XorrisO *xorriso, char *disk_path, int flag) +{ + char sfe[5*SfileadrL], path[SfileadrL], eff_path[SfileadrL]; + int ret; + + if (strlen(disk_path)>sizeof(xorriso->wdx)) { + sprintf(xorriso->info_text,"-cdx: disk_path too long (%d > %d)", + (int) strlen(disk_path), (int) sizeof(xorriso->wdx)-1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + Xorriso_warn_of_wildcards(xorriso, disk_path, 1|2); + sprintf(xorriso->info_text,"previous working directory on hard disk:\n"); + Xorriso_info(xorriso,0); + sprintf(xorriso->result_line,"%s/\n",Text_shellsafe(xorriso->wdx, sfe, 0)); + Xorriso_result(xorriso,0); + if(strcmp(disk_path,"/")==0) { + strcpy(xorriso->wdx,""); + Xorriso_option_pwdx(xorriso, 0); + return(1); + } else if(disk_path[0]!='/') { + strcpy(path, xorriso->wdx); + if(Sfile_add_to_path(path,disk_path,0)<=0) + return(-1); + } else { + if(Sfile_str(path,disk_path,0)<=0) + return(-1); + } + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, path, eff_path, 2|4); + if(ret<=0) + return(ret); + if(eff_path[0]) { + ret= Sfile_type(eff_path,1|4|8); + if(ret<0) { + Xorriso_msgs_submit(xorriso, 0, eff_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text,"-cdx: file not found : %s", + Text_shellsafe(eff_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if(ret!=2) { + Xorriso_msgs_submit(xorriso, 0, eff_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "-cdx: not a directory : %s", + Text_shellsafe(eff_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + } + if(Sfile_str(xorriso->wdx,eff_path,0)<=0) + return(-1); + Xorriso_option_pwdx(xorriso, 0); + return(1); +} + + +/* Option -charset */ +/* @param flag bit0= set in_charset + bit1= set out_charset + bit2= set local_charset +*/ +int Xorriso_option_charset(struct XorrisO *xorriso, char *name, int flag) +{ + int ret; + char *name_pt= NULL, sfe[5 * SfileadrL], *local_charset; + iconv_t iconv_ret= (iconv_t) -1; + + if(name != NULL) + if(name[0] != 0) + name_pt= name; + if(flag & 4) { + ret= Xorriso_set_local_charset(xorriso, name_pt, 0); + if(ret <= 0) + return(ret); + } + if(flag & 1) { + if(name_pt != NULL) { + Xorriso_get_local_charset(xorriso, &local_charset, 0); + iconv_ret= iconv_open(local_charset, name_pt); + if(iconv_ret == (iconv_t) -1) { + sprintf(xorriso->info_text, + "-%scharset: Cannot convert from character set %s", + flag & 2 ? "" : "in_", Text_shellsafe(name_pt, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", + 0); + return(0); + } else + iconv_close(iconv_ret); + } + if(Sregex_string(&(xorriso->in_charset), name_pt, 0) <= 0) { + Xorriso_no_malloc_memory(xorriso, NULL, 0); + return(-1); + } + } + if(flag & 2) { + if(name_pt != NULL) { + Xorriso_get_local_charset(xorriso, &local_charset, 0); + iconv_ret= iconv_open(local_charset, name_pt); + if(iconv_ret == (iconv_t) -1) { + sprintf(xorriso->info_text, "-%scharset: Cannot convert to charset %s", + flag & 1 ? "" : "out_", Text_shellsafe(name_pt, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", + 0); + return(0); + } else + iconv_close(iconv_ret); + } + if(Sregex_string(&(xorriso->out_charset), name_pt, 0) <= 0) { + Xorriso_no_malloc_memory(xorriso, NULL, 0); + return(-1); + } + } + if(flag & 3) { + if(name_pt == NULL) + Xorriso_get_local_charset(xorriso, &name_pt, 0); + sprintf(xorriso->info_text, "Character set for %sconversion is now: %s", + (flag & 3) == 1 ? "input " : (flag & 3) == 2 ? "output " : "", + Text_shellsafe(name_pt, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + return(1); +} + + +/* Options -check_md5 and -check_md5_r + @param flag bit0= issue summary message + bit1= do not reset pacifier, no final pacifier message + >>> bit2= do not issue pacifier messages at all + bit3= recursive: -check_md5_r +*/ +int Xorriso_option_check_md5(struct XorrisO *xorriso, + int argc, char **argv, int *idx, int flag) +{ + int ret, i, mem_pci, end_idx, fret, sev, do_report= 0; + int optc= 0; + char **optv= NULL, *cpt, *severity= "ALL"; + struct FindjoB *job= NULL; + double mem_lut= 0.0; + + mem_pci= xorriso->pacifier_interval; + + ret= Xorriso_opt_args(xorriso, "-check_md5", argc, argv, *idx + 1, + &end_idx, &optc, &optv, 128); + if(ret<=0) + goto ex; + + /* Interpret argv[*idx] as severity */ + if(argc <= *idx) { + sprintf(xorriso->info_text, + "-check_md5: No event severity given for case of mismatch"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + severity= argv[*idx]; + ret= Xorriso__text_to_sev(severity, &sev, 0); + if(ret<=0) { + sprintf(xorriso->info_text, "-check_md5: Not a known severity name : "); + Text_shellsafe(severity, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + goto ex; + } + + if(!(flag & (2 | 4))) { + Xorriso_pacifier_reset(xorriso, 0); + mem_lut= xorriso->last_update_time; + } + xorriso->pacifier_interval= 5.0; + + xorriso->find_check_md5_result= 0; + + if(optc == 0) { + ret= Xorriso_check_session_md5(xorriso, severity, 0); + do_report= 1; + goto ex; + } + + for(i= 0; i < optc; i++) { + if(flag & 8) { + ret= Findjob_new(&job, optv[i], 0); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-check_md5_r", 0); + {ret= -1; goto ex;} + } + Findjob_set_action_target(job, 35, severity, 0); + cpt= optv[i]; + ret= Xorriso_findi_sorted(xorriso, job, (off_t) 0, 1, &cpt, 0); + Findjob_destroy(&job, 0); + if(ret > 0) + ret= xorriso->find_compare_result; + else { + ret= -1; + xorriso->find_check_md5_result|= 2; + } + } else { + ret= Xorriso_check_md5(xorriso, NULL, optv[i], 4); + if(ret < 0) + xorriso->find_check_md5_result|= 2; + else if(ret == 0) + xorriso->find_check_md5_result|= 1; + else if(ret == 1) + xorriso->find_check_md5_result|= 8; + else if(ret == 2) + xorriso->find_check_md5_result|= 4; + } + if(ret>0 && !xorriso->request_to_abort) + continue; /* regular bottom of loop */ + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + ret= 0; goto report_outcome; + } + ret= 1; + +report_outcome:; + do_report= 1; + +ex:; + if(!(flag & (2 | 4))) { + xorriso->pacifier_interval= mem_pci; + if(mem_lut!=xorriso->last_update_time && !(flag&2)) + Xorriso_pacifier_callback(xorriso, "content bytes read", + xorriso->pacifier_count, 0, "", 1); + } + if(do_report) { + if(optc == 0) { + if(ret <= 0) { + sprintf(xorriso->result_line, + "MD5 MISMATCH WITH DATA OF LOADED SESSION !\n"); + Xorriso_result(xorriso,0); + if(strcmp(severity, "ALL") != 0) { + sprintf(xorriso->info_text, + "Event triggered by MD5 comparison mismatch"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, severity, 0); + } + } else { + sprintf(xorriso->result_line, "Ok, session data match recorded md5.\n"); + Xorriso_result(xorriso,0); + } + } else { + Xorriso_report_md5_outcome(xorriso, severity, 0); + } + } + (*idx)= end_idx; + Xorriso_opt_args(xorriso, "-getfacl", argc, argv, *idx, &end_idx, + &optc, &optv, 256); + Findjob_destroy(&job, 0); + if(ret <= 0) + return(ret); + return((xorriso->find_check_md5_result & 3) == 0); +} + + +/* Option -check_media */ +int Xorriso_option_check_media(struct XorrisO *xorriso, + int argc, char **argv, int *idx, int flag) +{ + int ret, i, count, lba, blocks, quality, pass, was_md5= 0, was_event= 0; + int end_idx, old_idx, os_errno; + char quality_name[80], head_buffer[64*1024]; + struct SpotlisT *spotlist= NULL; + struct CheckmediajoB *job= NULL; + struct FindjoB *findjob= NULL; + struct stat dir_stbuf; + + old_idx= *idx; + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1); + (*idx)= end_idx; + + ret= Checkmediajob_new(&job, 0); + if(ret <= 0) + goto ex; + ret= Xorriso_check_media_setup_job(xorriso, job, argv, old_idx, end_idx, 0); + if(ret <= 0) + goto ex; + + if((job->report_mode == 1 || job->report_mode == 2) && job->use_dev == 1) { + sprintf(xorriso->info_text, + "-check_media: cannot report=*files while use=outdef"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + if(job->patch_lba0 && job->data_to_path[0] == 0) { + sprintf(xorriso->info_text, + "-check_media: cannot apply patch_lba0= while data_to= has empty value"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + + if(job->use_dev == 2) { + if(job->sector_map_path[0] == 0) { + sprintf(xorriso->info_text, + "-check_media: option use=sector_map but sector_map=''"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + ret= Sectorbitmap_from_file(&(job->sector_map), job->sector_map_path, + xorriso->info_text, &os_errno, 0); + if(ret <= 0) { + if(xorriso->info_text[0]) + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, os_errno, + "FAILURE", 0); + goto ex; + } + ret= Xorriso_sectormap_to_spotlist(xorriso, job, &spotlist, 0); + if(ret <= 0) + goto ex; + Sectorbitmap_destroy(&(xorriso->in_sector_map), 0); + ret= Sectorbitmap_clone(job->sector_map, &(xorriso->in_sector_map), 0); + if(ret <= 0) + goto ex; + } else { + ret= Xorriso_check_media(xorriso, &spotlist, job, 0); + if(ret <= 0) + goto ex; + } + + if(job->patch_lba0) { + ret= Xorriso_open_job_data_to(xorriso, job, 0); + if(ret <= 0) + goto ex; + if(ret == 1) { + ret= Xorriso_update_iso_lba0(xorriso, job->patch_lba0_msc1, 0, + head_buffer, job, + (8 * (job->patch_lba0 == 1)) | + 4 | (job->patch_lba0_msc1 < 0)); + if(ret <= 0) + goto ex; + } + } + + if(job->report_mode == 0 || job->report_mode == 2) { /* report blocks */ + for(pass= 0; pass < 2; pass++) { + if(pass == 0) { + sprintf(xorriso->result_line, + "Media checks : lba , size , quality\n"); + } else { + if(!was_md5) + break; + sprintf(xorriso->result_line, + "MD5 checks : lba , size , result\n"); + } + Xorriso_result(xorriso,0); + count= Spotlist_count(spotlist, 0); + for(i= 0; i < count; i++) { + ret= Spotlist_get_item(spotlist, i, &lba, &blocks, &quality, 0); + if(ret <= 0) + continue; + if(pass == 0) { + if(quality == Xorriso_read_quality_md5_mismatcH || + quality == Xorriso_read_quality_unreadablE) { + was_event= 1; + } + if(quality == Xorriso_read_quality_md5_matcH || + quality == Xorriso_read_quality_md5_mismatcH) { + was_md5= 1; + continue; + } + } + else if(pass == 1 && !(quality == Xorriso_read_quality_md5_matcH || + quality == Xorriso_read_quality_md5_mismatcH)) + continue; + sprintf(xorriso->result_line, "%s: %10d , %10d , %s\n", + pass == 0 ? "Media region " : "MD5 tag range", + lba, blocks, Spotlist__quality_name(quality, quality_name, 0)); + Xorriso_result(xorriso,0); + } + } + } + if(job->report_mode == 1 || job->report_mode == 2) { /* report files */ + ret= Findjob_new(&findjob, "/", 0); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-check_media report=files", 0); + {ret= -1; goto ex;} + } + Findjob_set_damage_filter(findjob, 1, 0); + Findjob_set_action_target(findjob, 21, NULL, 0); + ret= Xorriso_findi(xorriso, findjob, NULL, (off_t) 0, + NULL, "/", &dir_stbuf, 0, 0); + Findjob_destroy(&findjob, 0); + if(ret <= 0) + goto ex; + } + ret= 1; +ex:; + if(was_event && strcmp(job->event_severity, "ALL") != 0) { + sprintf(xorriso->info_text, + "Event triggered by media read error or MD5 comparison mismatch"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, job->event_severity, + 0); + } + Spotlist_destroy(&spotlist, 0); + Checkmediajob_destroy(&job, 0); + return(ret); +} + + +/* Option -check_media_defaults */ +int Xorriso_option_check_media_defaults(struct XorrisO *xorriso, + int argc, char **argv, int *idx, int flag) +{ + int ret, old_idx, end_idx; + struct CheckmediajoB *job= NULL; + + old_idx= *idx; + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1); + (*idx)= end_idx; + + ret= Checkmediajob_new(&job, 0); + if(ret <= 0) + goto ex; + ret= Xorriso_check_media_setup_job(xorriso, job, argv, old_idx, end_idx, 0); + if(ret <= 0) + goto ex; + Checkmediajob_destroy(&(xorriso->check_media_default), 0); + xorriso->check_media_default= job; + job= NULL; + ret= 1; +ex:; + Checkmediajob_destroy(&job, 0); + return(ret); +} + + +/* Option -chgrp alias -chgrpi , chgrp_r alias chgrpi */ +/* @param flag bit0=recursive (-chgrp_r) +*/ +int Xorriso_option_chgrpi(struct XorrisO *xorriso, char *gid, + int argc, char **argv, int *idx, int flag) +{ + int i, ret, was_failure= 0, end_idx, fret; + gid_t gid_number; + int optc= 0; + char **optv= NULL; + struct FindjoB *job= NULL; + struct stat dir_stbuf; + + ret= Xorriso_opt_args(xorriso, "-chgrpi", argc, argv, *idx, &end_idx, &optc, + &optv, 0); + if(ret<=0) + goto ex; + ret= Xorriso_convert_gidstring(xorriso, gid, &gid_number, 0); + if(ret<=0) + goto ex; + for(i= 0; i<optc; i++) { + if(flag&1) { + ret= Findjob_new(&job, optv[i], 0); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-chgrp_r", 0); + {ret= -1; goto ex;} + } + Findjob_set_action_chgrp(job, gid_number, 0); + ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0, + NULL, optv[i], &dir_stbuf, 0, 0); + Findjob_destroy(&job, 0); + } else + ret= Xorriso_set_gid(xorriso, optv[i], gid_number, 0); + if(ret>0 && !xorriso->request_to_abort) + continue; /* regular bottom of loop */ + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + goto ex; + } + ret= 1; +ex:; + (*idx)= end_idx; + Xorriso_opt_args(xorriso, "-chgrpi", argc, argv, *idx, &end_idx, &optc, &optv, + 256); /* clean up */ + if(ret<=0) + return(ret); + Findjob_destroy(&job, 0); + return(!was_failure); +} + + +/* Option -chmod alias -chmodi , -chmod_r alias chmod_ri */ +/* @param flag bit0=recursive (-chmod_r) +*/ +int Xorriso_option_chmodi(struct XorrisO *xorriso, char *mode, + int argc, char **argv, int *idx, int flag) +{ + int i, ret, was_failure= 0, end_idx, fret; + mode_t mode_and= ~0, mode_or= 0; + int optc= 0; + char **optv= NULL; + struct FindjoB *job= NULL; + struct stat dir_stbuf; + + ret= Xorriso_opt_args(xorriso, "-chmodi", argc, argv, *idx, &end_idx, &optc, + &optv, 0); + if(ret<=0) + goto ex; + ret= Xorriso_convert_modstring(xorriso, "-chmodi", + mode, &mode_and, &mode_or, 0); + if(ret<=0) + goto ex; + for(i= 0; i<optc; i++) { + if(flag&1) { + ret= Findjob_new(&job, optv[i], 0); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-chmod_r", 0); + {ret= -1; goto ex;} + } + Findjob_set_action_chmod(job, mode_and, mode_or, 0); + ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0, + NULL, optv[i], &dir_stbuf, 0, 0); + Findjob_destroy(&job, 0); + } else { + ret= Xorriso_set_st_mode(xorriso, optv[i], mode_and, mode_or, 0); + } + if(ret>0 && !xorriso->request_to_abort) + continue; /* regular bottom of loop */ + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + ret= 0; goto ex; + } + ret= 1; +ex:; + (*idx)= end_idx; + Xorriso_opt_args(xorriso, "-chmodi", argc, argv, *idx, &end_idx, &optc, &optv, + 256); + Findjob_destroy(&job, 0); + if(ret<=0) + return(ret); + return(!was_failure); +} + + +/* Option -chown alias -chowni , chown_r alias chown_ri */ +/* @param flag bit0=recursive (-chown_r) +*/ +int Xorriso_option_chowni(struct XorrisO *xorriso, char *uid, + int argc, char **argv, int *idx, int flag) +{ + int i, ret, was_failure= 0, end_idx, fret; + uid_t uid_number; + int optc= 0; + char **optv= NULL; + struct FindjoB *job= NULL; + struct stat dir_stbuf; + + ret= Xorriso_opt_args(xorriso, "-chowni", argc, argv, *idx, &end_idx, + &optc, &optv, 0); + if(ret<=0) + goto ex; + ret= Xorriso_convert_uidstring(xorriso, uid, &uid_number, 0); + if(ret<=0) + goto ex; + for(i= 0; i<optc; i++) { + if(flag&1) { + ret= Findjob_new(&job, optv[i], 0); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-chown_r", 0); + {ret= -1; goto ex;} + } + Findjob_set_action_chown(job, uid_number, 0); + ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0, + NULL, optv[i], &dir_stbuf, 0, 0); + Findjob_destroy(&job, 0); + } else + ret= Xorriso_set_uid(xorriso, optv[i], uid_number, 0); + if(ret>0 && !xorriso->request_to_abort) + continue; /* regular bottom of loop */ + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + ret= 0; goto ex; + } + ret= 1; +ex:; + (*idx)= end_idx; + Xorriso_opt_args(xorriso, "-chowni", argc, argv, *idx, &end_idx, + &optc, &optv, 256); + Findjob_destroy(&job, 0); + if(ret<=0) + return(ret); + return(!was_failure); +} + + +/* Option -close "on"|"off" */ +int Xorriso_option_close(struct XorrisO *xorriso, char *mode, int flag) +{ + xorriso->do_close= !!strcmp(mode, "off"); + return(1); +} + + +/* Option -close_filter_list */ +int Xorriso_option_close_filter_list(struct XorrisO *xorriso, int flag) +{ + xorriso->filter_list_closed= 1; + return(1); +} + + +/* Option -commit */ +/* @param flag bit0= leave indrive and outdrive aquired as they were, + i.e. do not aquire outdrive as new in-out-drive + bit1= do not perform eventual -reassure + @return <=0 error , 1 success, 2 revoked by -reassure , 3 no change pending +*/ +int Xorriso_option_commit(struct XorrisO *xorriso, int flag) +{ + int ret; + char newdev[SfileadrL]; + + if(!xorriso->volset_change_pending) { + sprintf(xorriso->info_text, "-commit: No image modifications pending"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + return(3); + } + if(!(flag&2)) { + ret= Xorriso_reassure(xorriso, "-commit", + "write the pending image changes to media", 0); + if(ret<=0) + return(2); + } + Xorriso_process_errfile(xorriso, 0, "burn session start", 0, 1); + ret= Xorriso_write_session(xorriso, 0); + Xorriso_process_errfile(xorriso, 0, "burn session end", 0, 1); + if(ret<=0) + return(ret); + Xorriso_write_session_log(xorriso, 0); + xorriso->volset_change_pending= 0; + xorriso->no_volset_present= 0; + if(flag&1) + return(1); + if(Sregex_string(&(xorriso->in_charset), xorriso->out_charset, 0) <= 0) + return(-1); + strcpy(newdev, xorriso->outdev); + if(xorriso->grow_blindly_msc2>=0) + ret= Xorriso_option_dev(xorriso, "", 3|4); + else + ret= Xorriso_option_dev(xorriso, newdev, 3|4); + return(ret); +} + + +/* Option -commit_eject */ +/* @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_commit_eject(struct XorrisO *xorriso, char *which, int flag) +{ + int ret, eret; + + ret= Xorriso_option_commit(xorriso, 1); + if(ret<=0 || ret==2 || ret==3) + return(ret); + if(strcmp(which, "none")==0) + eret= 1; + else + eret= Xorriso_option_eject(xorriso, which, 1); + ret= Xorriso_option_dev(xorriso, "", 3|4); + if(eret<ret) + return(eret); + return(ret); +} + + +/* Options -compare and -compare_r + @param flag bit0= issue summary message + bit1= do not reset pacifier, no final pacifier message + bit2= do not issue pacifier messages at all + bit3= recursive: -compare_r +*/ +int Xorriso_option_compare(struct XorrisO *xorriso, char *disk_path, + char *iso_path, int flag) +{ + int ret, mem_pci, zero= 0, result, follow_links; + double mem_lut= 0.0; + char *ipth, *argv[6], eff_origin[SfileadrL], eff_dest[SfileadrL]; + + ipth= iso_path; + if(ipth[0]==0) + ipth= disk_path; + if(disk_path[0]==0) { + sprintf(xorriso->info_text, "-compare: Empty disk_path given"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 1); + return(0); + } + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, disk_path, eff_origin, + 2|4|8); + if(ret<=0) + return(ret); + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, ipth, eff_dest, 2|8); + if(ret<=0) + return(ret); + + if(xorriso->disk_excl_mode&8) + ret= Xorriso_path_is_excluded(xorriso, eff_origin, 1); + else + ret= 0; + if(ret!=0) + goto report_outcome; + if(!(flag&2)) { + Xorriso_pacifier_reset(xorriso, 0); + mem_lut= xorriso->last_update_time; + } + mem_pci= xorriso->pacifier_interval; + xorriso->pacifier_interval= 5.0; + + if(flag&8) { + xorriso->find_compare_result= 1; + argv[0]= eff_dest; + argv[1]= "-exec"; + argv[2]= "compare"; + argv[3]= eff_origin; + zero= 0; + ret= Xorriso_option_find(xorriso, 4, argv, &zero, 2); /* -findi */ + if(ret>0) { + argv[0]= eff_origin; + argv[1]= "-exec"; + argv[2]= "not_in_iso"; + argv[3]= eff_dest; + zero= 0; + ret= Xorriso_option_find(xorriso, 4, argv, &zero, 1|2); /* -findx */ + if(ret>0 && !xorriso->do_follow_mount) { + argv[0]= eff_origin; + argv[1]= "-type"; + argv[2]= "m"; + argv[3]= "-exec"; + argv[4]= "is_full_in_iso"; + argv[5]= eff_dest; + zero= 0; + ret= Xorriso_option_find(xorriso, 6, argv, &zero, 1|2); /* -findx */ + } + if(ret>0) + ret= xorriso->find_compare_result; + else + ret= -1; + } else + ret= -1; + } else { + follow_links= (xorriso->do_follow_links || xorriso->do_follow_param) << 28; + ret= Xorriso_compare_2_files(xorriso, eff_origin, eff_dest, "", &result, + 2 | follow_links | ((flag&4)<<27) | (1<<30)); + } + + xorriso->pacifier_interval= mem_pci; + if(mem_lut!=xorriso->last_update_time && !(flag&2)) + Xorriso_pacifier_callback(xorriso, "content bytes read", + xorriso->pacifier_count, 0, "", 1); +report_outcome:; + if(ret>0) { + sprintf(xorriso->result_line, + "Both file objects match as far as expectable.\n"); + } else if(ret==0) { + sprintf(xorriso->result_line, "Differences detected.\n"); + } else { + sprintf(xorriso->result_line, "Comparison failed due to error.\n"); + } + if(flag&1) + Xorriso_result(xorriso,0); + if(ret<0) + return(ret); + return(1); +} + + +/* Option -compliance */ +int Xorriso_option_compliance(struct XorrisO *xorriso, char *mode, + int flag) +{ + return(Xorriso_relax_compliance(xorriso, mode, 0)); +} + + +/* Option -cpr alias -cpri */ +int Xorriso_option_cpri(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int i, ret, is_dir= 0, was_failure= 0, fret, end_idx_dummy; + char eff_origin[SfileadrL], eff_dest[SfileadrL]; + char dest_dir[SfileadrL], leafname[SfileadrL]; + int optc= 0; + char **optv= NULL; + + ret= Xorriso_cpmv_args(xorriso, "-cpri", argc, argv, idx, + &optc, &optv, eff_dest, 1|2); + if(ret<=0) + goto ex; + if(ret==2) { + is_dir= 1; + strcpy(dest_dir, eff_dest); + } + + /* Perform graft-ins */ + Xorriso_pacifier_reset(xorriso, 0); + for(i= 0; i<optc && !xorriso->request_to_abort; i++) { + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, optv[i], eff_origin, + 2|4); + if(ret<=0 || xorriso->request_to_abort) + goto problem_handler; + if(is_dir) { + ret= Sfile_leafname(eff_origin, leafname, 0); + if(ret<=0) + goto problem_handler; + strcpy(eff_dest, dest_dir); + ret= Sfile_add_to_path(eff_dest, leafname, 0); + if(ret<=0) { + sprintf(xorriso->info_text, "Effective path gets much too long (%d)", + (int) (strlen(eff_dest)+ strlen(leafname)+1)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + goto problem_handler; + } + } + ret= Xorriso_graft_in(xorriso, NULL, eff_origin, eff_dest, + (off_t) 0, (off_t) 0, 0); + if(ret<=0 || xorriso->request_to_abort) + goto problem_handler; + sprintf(xorriso->info_text, "Added to ISO image: %s '%s'='%s'\n", + (ret>1 ? "directory" : "file"), (eff_dest[0] ? eff_dest : "/"), + eff_origin); + if(!(flag&1)) + Xorriso_info(xorriso, 0); + continue; /* regular bottom of loop */ +problem_handler:; + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + goto ex; + } + Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count, + xorriso->pacifier_total, "", 1); + ret= !was_failure; +ex:; + Xorriso_opt_args(xorriso, "-cpri", + argc, argv, *idx, &end_idx_dummy, &optc, &optv, 256); + return(ret); +} + + +/* Options -cpx , -cpax, -cp_rx , -cp_rax */ +/* @param flag bit0= recursive (-cp_rx, -cp_rax) + bit1= full property restore (-cpax, -cp_rax) +*/ +int Xorriso_option_cpx(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int i, ret, is_dir= 0, was_failure= 0, fret, end_idx_dummy; + char eff_origin[SfileadrL], eff_dest[SfileadrL]; + char dest_dir[SfileadrL], leafname[SfileadrL], sfe[5*SfileadrL]; + char **eff_src_array= NULL, **eff_tgt_array= NULL; + + int optc= 0; + char **optv= NULL; + struct stat stbuf; + + ret= Xorriso_cpmv_args(xorriso, "-cp*x", argc, argv, idx, + &optc, &optv, eff_dest, 1|4); + if(ret<=0) + goto ex; + if(ret==2) { + is_dir= 1; + strcpy(dest_dir, eff_dest); + } + if(xorriso->allow_restore <= 0) { + sprintf(xorriso->info_text, + "-cpx: image-to-disk copies are not enabled by option -osirrox"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + + if(xorriso->do_restore_sort_lba || !(xorriso->ino_behavior & 4)) { + eff_src_array= calloc(optc, sizeof(char *)); + eff_tgt_array= calloc(optc, sizeof(char *)); + if(eff_src_array == NULL || eff_tgt_array == NULL) { + Xorriso_no_malloc_memory(xorriso, NULL, 0); + ret= -1; goto ex; + } + for(i= 0; i < optc; i++) + eff_src_array[i]= eff_tgt_array[i]= NULL; + } + + /* Perform copying */ + Xorriso_pacifier_reset(xorriso, 0); + for(i= 0; i<optc && !xorriso->request_to_abort; i++) { + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, optv[i], eff_origin, + 2|8); + if(ret<=0 || xorriso->request_to_abort) + goto problem_handler; + + ret= Xorriso_iso_lstat(xorriso, eff_origin, &stbuf, 2|4); + if(ret==-1) + goto problem_handler; + if(S_ISDIR(stbuf.st_mode) && !(flag&1)) { + /* only allow directories if they actually represent split data files */ + ret= 0; + if(xorriso->do_concat_split) + ret= Xorriso_is_split(xorriso, eff_origin, NULL, 2); + if(ret<0) + goto problem_handler; + if(ret==0) { + sprintf(xorriso->info_text, "-cpx: May not copy directory %s", + Text_shellsafe(eff_origin, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto problem_handler; + } + } + + if(is_dir && strcmp(eff_origin, "/")!=0) { + ret= Sfile_leafname(eff_origin, leafname, 0); + if(ret<=0) + goto problem_handler; + strcpy(eff_dest, dest_dir); + ret= Sfile_add_to_path(eff_dest, leafname, 0); + if(ret<=0) { + sprintf(xorriso->info_text, "Effective path gets much too long (%d)", + (int) (strlen(eff_dest)+strlen(leafname)+1)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + goto problem_handler; + } + } + if(eff_src_array != NULL) { + eff_src_array[i]= strdup(eff_origin); + eff_tgt_array[i]= strdup(eff_dest); + if(eff_src_array[i] == NULL || eff_tgt_array[i] == NULL) { + Xorriso_no_malloc_memory(xorriso, &(eff_src_array[i]), 0); + ret= -1; goto ex; + } + } else { + ret= Xorriso_restore(xorriso, eff_origin, eff_dest, (off_t) 0, (off_t) 0, + 16 | ((!(flag&2))<<6)); + if(ret<=0 || xorriso->request_to_abort) + goto problem_handler; + if(ret==3 || (flag&1)) + continue; + sprintf(xorriso->info_text, + "Copied from ISO image to disk: %s '%s' = '%s'\n", + (ret>1 ? "directory" : "file"), eff_origin, eff_dest); + Xorriso_info(xorriso, 0); + } + continue; /* regular bottom of loop */ +problem_handler:; + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + goto ex; + } + + if(eff_src_array != NULL) { + ret= Xorriso_restore_sorted(xorriso, optc, eff_src_array, eff_tgt_array, 0); + if(ret <= 0) + was_failure= 1; + } + if(xorriso->pacifier_count>0) + Xorriso_pacifier_callback(xorriso, "files restored",xorriso->pacifier_count, + xorriso->pacifier_total, "", 1|4); + ret= !was_failure; +ex:; + i= optc; + Sfile_destroy_argv(&i, &eff_src_array, 0); + i= optc; + Sfile_destroy_argv(&i, &eff_tgt_array, 0); + Xorriso_opt_args(xorriso, "-cp*x", + argc, argv, *idx, &end_idx_dummy, &optc, &optv, 256); + return(ret); +} + + +/* Option -cut_out */ +int Xorriso_option_cut_out(struct XorrisO *xorriso, char *disk_path, + char *start, char *count, char *iso_rr_path, int flag) +{ + int ret; + double num; + off_t startbyte, bytecount; + + num= Scanf_io_size(start, 0); + if(num<0 || num > 1.0e18) { /* 10^18 = 10^3 ^ 6 < 2^10 ^ 6 = 2^60 */ + sprintf(xorriso->info_text, + "-cut_out: startbyte address negative or much too large (%s)", start); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + startbyte= num; + num= Scanf_io_size(count, 0); + if(num<=0 || num > 1.0e18) { + sprintf(xorriso->info_text, + "-cut_out: bytecount zero, negative or much too large (%s)", count); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + bytecount= num; + sprintf(xorriso->info_text, + "-cut_out from %s , byte %.f to %.f, and graft as %s", + disk_path, (double) startbyte, (double) (startbyte+bytecount), + iso_rr_path); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + + ret= Xorriso_cut_out(xorriso, disk_path, startbyte, bytecount, + iso_rr_path, 0); + return(ret); +} + + +/* Options -dev , -indev, -outdev */ +/** @param flag bit0= use as indev + bit1= use as outdev + bit2= do not -reassure + bit3= regard overwriteable media as blank + bit4= if the drive is a regular disk file: truncate it to + the write start address + bit5= do not print toc of aquired drive + bit6= do not calm down drive after aquiring it + @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_dev(struct XorrisO *xorriso, char *in_adr, int flag) +{ + int ret; + char sfe[5*SfileadrL], *adr; + + adr= in_adr; + if(strcmp(in_adr, "-")==0) + adr= "stdio:/dev/fd/1"; + if(strncmp(adr, "stdio:", 6)==0) { + if(strlen(adr)==6 || strcmp(adr, "stdio:/")==0 || + strcmp(adr, "stdio:.")==0 || strcmp(adr, "stdio:..")==0 || + strcmp(adr, "stdio:-")==0) { + sprintf(xorriso->info_text, + "No suitable path given by device address '%s'", adr); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + } + + if(xorriso->volset_change_pending && (flag&1)) { + sprintf(xorriso->info_text, + "%s: Image changes pending. -commit or -rollback first", + (flag&2) ? "-dev" : "-indev"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if((flag&1) && (xorriso->in_drive_handle != NULL || adr[0]) && !(flag&4)) { + ret= Xorriso_reassure(xorriso, (flag&2) ? "-dev" : "-indev", + "eventually discard the current image", 0); + if(ret<=0) + return(2); + } + + if(adr[0]==0) { + if((flag&1) && xorriso->in_drive_handle != NULL) { + if(xorriso->in_drive_handle == xorriso->out_drive_handle) + sprintf(xorriso->info_text,"Giving up -dev %s", + Text_shellsafe(xorriso->indev, sfe, 0)); + else + sprintf(xorriso->info_text,"Giving up -indev %s", + Text_shellsafe(xorriso->indev, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + if((flag&2) && xorriso->out_drive_handle != NULL && + xorriso->in_drive_handle != xorriso->out_drive_handle) { + sprintf(xorriso->info_text,"Giving up -outdev %s", + Text_shellsafe(xorriso->outdev, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + ret= Xorriso_give_up_drive(xorriso, (flag&3)|((flag&32)>>2)); + } else + ret= Xorriso_aquire_drive(xorriso, adr, + (flag & (3 | 32 | 64)) | (((flag & (8 | 16)) >> 1))); + if(ret<=0) + return(ret); + if(xorriso->in_drive_handle == NULL) + xorriso->image_start_mode= 0; /* session setting is invalid by now */ + return(1); +} + + +/* Option -devices */ +/* @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_devices(struct XorrisO *xorriso, int flag) +{ + int ret; + char sfe[5*SfileadrL]; + + if(xorriso->volset_change_pending) { + sprintf(xorriso->info_text, + "-devices: Image changes pending. -commit or -rollback first"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + ret= Xorriso_reassure(xorriso, "-devices", + "eventually discard the current image", 0); + if(ret<=0) + return(2); + xorriso->info_text[0]= 0; + if(xorriso->in_drive_handle!=NULL || xorriso->out_drive_handle!=NULL) { + if(xorriso->in_drive_handle == xorriso->out_drive_handle) { + sprintf(xorriso->info_text, "Gave up -dev %s", + Text_shellsafe(xorriso->indev, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + }else { + if(xorriso->in_drive_handle!=NULL) { + sprintf(xorriso->info_text, "Gave up -indev %s", + Text_shellsafe(xorriso->indev, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + if(xorriso->out_drive_handle!=NULL) { + sprintf(xorriso->info_text, "Gave up -outdev %s", + Text_shellsafe(xorriso->outdev, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + } + Xorriso_give_up_drive(xorriso, 3); + } + ret= Xorriso_show_devices(xorriso, 0); + return(ret); +} + + +/* Option -dialog "on"|"single_line"|"off" */ +int Xorriso_option_dialog(struct XorrisO *xorriso, char *mode, int flag) +{ + if(strcmp(mode, "on") == 0 || strcmp(mode, "multi_line") == 0) + xorriso->dialog= 2; + else if(strcmp(mode, "single_line") == 0) + xorriso->dialog= 2; + else if(strcmp(mode, "off") == 0) + xorriso->dialog= 0; + else { + sprintf(xorriso->info_text, "-dialog: unknown mode '%s'", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + return(1); +} + + +/* Option -disk_dev_ino "on"|"ino_only"|"off" */ +int Xorriso_option_disk_dev_ino(struct XorrisO *xorriso, char *mode, int flag) +{ + if(strcmp(mode, "on") == 0) + xorriso->do_aaip= (xorriso->do_aaip & ~128) | 16 | 32 | 64; + else if(strcmp(mode, "ino_only") == 0) + xorriso->do_aaip|= 16 | 32 | 64 | 128; + else if(strcmp(mode, "off") == 0) + xorriso->do_aaip &= ~(16 | 32 | 64 | 128); + else { + sprintf(xorriso->info_text, "-disk_dev_ino: unknown mode '%s'", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + return(1); +} + + +/* Option -disk_pattern "on"|"ls"|"off" */ +int Xorriso_option_disk_pattern(struct XorrisO *xorriso, char *mode, int flag) +{ + if(strcmp(mode, "off")==0) + xorriso->do_disk_pattern= 0; + else if(strcmp(mode, "on")==0) + xorriso->do_disk_pattern= 1; + else if(strcmp(mode, "ls")==0) + xorriso->do_disk_pattern= 2; + else { + sprintf(xorriso->info_text, "-disk_pattern: unknown mode '%s'", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(1); +} + + +/* Option -drive_class */ +int Xorriso_option_drive_class(struct XorrisO *xorriso, + char *d_class, char *pattern, int flag) +{ + int ret= 1; + + if(strcmp(d_class, "banned") == 0) { + ret= Xorriso_lst_new(&(xorriso->drive_blacklist), pattern, + xorriso->drive_blacklist, 1); + } else if(strcmp(d_class, "caution") == 0) { + ret= Xorriso_lst_new(&(xorriso->drive_greylist), pattern, + xorriso->drive_greylist, 1); + } else if (strcmp(d_class, "harmless") == 0) { + ret= Xorriso_lst_new(&(xorriso->drive_whitelist), pattern, + xorriso->drive_whitelist, 1); + } else if (strcmp(d_class, "clear_list") == 0) { + if(strcmp(pattern, "banned") == 0) + Xorriso_lst_destroy_all(&(xorriso->drive_blacklist), 0); + else if(strcmp(pattern, "caution") == 0) + Xorriso_lst_destroy_all(&(xorriso->drive_greylist), 0); + else if(strcmp(pattern, "harmless") == 0) + Xorriso_lst_destroy_all(&(xorriso->drive_whitelist), 0); + else if(strcmp(pattern, "all") == 0) { + Xorriso_lst_destroy_all(&(xorriso->drive_blacklist), 0); + Xorriso_lst_destroy_all(&(xorriso->drive_greylist), 0); + Xorriso_lst_destroy_all(&(xorriso->drive_whitelist), 0); + } else { + sprintf(xorriso->info_text, "-drive_class clear : unknown class '%s'", + pattern); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + ret= 1; + } else { + sprintf(xorriso->info_text, "-drive_class: unknown class '%s'", d_class); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(ret); +} + + +/* Option -dummy "on"|"off" */ +int Xorriso_option_dummy(struct XorrisO *xorriso, char *mode, int flag) +{ + xorriso->do_dummy= !!strcmp(mode, "off"); + return(1); +} + + +/* Option -eject */ +/* @param flag bit0=do not report toc of eventually remaining drives +*/ +int Xorriso_option_eject(struct XorrisO *xorriso, char *which, int flag) +{ + int gu_flag= 4, ret; + + if(strncmp(which,"in",2)==0) + gu_flag|= 1; + else if(strncmp(which,"out",3)==0) + gu_flag|= 2; + else + gu_flag|= 3; + if((gu_flag&1) && xorriso->volset_change_pending) { + sprintf(xorriso->info_text, + "-eject: Image changes pending. -commit or -rollback first"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if(flag&1) + gu_flag|= 8; + ret= Xorriso_give_up_drive(xorriso, gu_flag); + return(ret); +} + + +/* Options -end , and -rollback_end */ +/* @param flag bit0= discard pending changes + bit1= do not -reassure + @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_end(struct XorrisO *xorriso, int flag) +{ + int ret; + char *cmd, *which_will; + + if(flag&1) + cmd= "-rollback_end"; + else + cmd= "-end"; + if(xorriso->volset_change_pending) { + if(flag&1) + which_will= "end the program discarding image changes"; + else + which_will= "commit image changes and then end the program"; + } else { + which_will= "end the program"; + } + if(!(flag&2)) { + ret= Xorriso_reassure(xorriso, cmd, which_will, 0); + if(ret<=0) + return(2); + } + + if(xorriso->volset_change_pending) { + if(flag&1) { + xorriso->volset_change_pending= 0; + } else { + ret= Xorriso_option_commit(xorriso, 1); + xorriso->volset_change_pending= 0; /* no further tries to commit */ + if(ret<=0) + return(ret); + } + } + ret= Xorriso_give_up_drive(xorriso, 3); + if(ret<=0) + return(ret); + return(1); +} + + +/* Option -errfile_log marked|plain path|-|"" */ +int Xorriso_option_errfile_log(struct XorrisO *xorriso, + char *mode, char *path, int flag) +{ + int ret, mode_word; + FILE *fp= NULL; + char sfe[5*SfileadrL]; + + if(path[0]==0 || path[0]=='-') { + /* ok */; + } else { + fp= fopen(path, "a"); + if(fp==0) { + sprintf(xorriso->info_text, "-errfile_log: Cannot open file %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + } + mode_word= xorriso->errfile_mode; + if(strcmp(mode, "marked")==0) + mode_word|= 1; + else if(strcmp(mode, "plain")==0) + mode_word&= ~1; + else { + sprintf(xorriso->info_text, "-errfile_log: Unknown mode %s", + Text_shellsafe(mode, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + + Xorriso_process_errfile(xorriso, 0, "log end", 0, 1); + if(xorriso->errfile_fp!=NULL) + fclose(xorriso->errfile_fp); + xorriso->errfile_fp= fp; + xorriso->errfile_mode= mode_word; + ret= Sfile_str(xorriso->errfile_log, path, 0); + if(ret>0) + ret= Xorriso_process_errfile(xorriso, 0, "log start", 0, 1); + if(ret<=0) + return(ret); + return(1); +} + + +/* Option -error_behavior */ +int Xorriso_option_error_behavior(struct XorrisO *xorriso, + char *occasion, char *behavior, int flag) +{ + if(strcmp(occasion, "image_loading")==0) { + if(strcmp(behavior, "best_effort")==0) + xorriso->img_read_error_mode= 0; + else if(strcmp(behavior, "failure")==0 || strcmp(behavior, "FAILURE")==0) + xorriso->img_read_error_mode= 1; + else if(strcmp(behavior, "fatal")==0 || strcmp(behavior, "FATAL")==0) + xorriso->img_read_error_mode= 2; + else { +unknown_behavior:; + sprintf(xorriso->info_text, + "-error_behavior: with '%s': unknown behavior '%s'", + occasion, behavior); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + } else if(strcmp(occasion, "file_extraction")==0) { + if(strcmp(behavior, "best_effort")==0) + xorriso->extract_error_mode= 0; + else if(strcmp(behavior, "keep")==0) + xorriso->extract_error_mode= 1; + else if(strcmp(behavior, "delete")==0) + xorriso->extract_error_mode= 2; + else + goto unknown_behavior; + } else { + sprintf(xorriso->info_text, "-error_behavior: unknown occasion '%s'", + occasion); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(1); +} + + +/* Option -external_filter */ +int Xorriso_option_external_filter(struct XorrisO *xorriso, + int argc, char **argv, int *idx, int flag) +{ + int ret, start_idx, end_idx; + + start_idx= *idx; + end_idx= Xorriso_end_idx(xorriso, argc, argv, start_idx, 1); + (*idx)= end_idx; + if(end_idx - start_idx < 3) { + sprintf(xorriso->info_text, + "-external_filter : Not enough arguments given. Needed: name options path %s", + xorriso->list_delimiter); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + ret= Xorriso_external_filter(xorriso, argv[start_idx], + argv[start_idx + 1], argv[start_idx + 2], + end_idx - start_idx - 3, argv + start_idx + 3, 0); + return(ret); +} + + +/* Options -extract , -extract_single */ +/* @param flag bit0=do not report the restored item + bit1=do not reset pacifier, no final pacifier message + bit2= do not make lba-sorted node array for hardlink detection + bit5= -extract_single: eventually do not insert directory tree +*/ +int Xorriso_option_extract(struct XorrisO *xorriso, char *iso_path, + char *disk_path, int flag) +{ + int ret; + char eff_origin[SfileadrL], eff_dest[SfileadrL], *ipth, *eopt[1], *edpt[1]; + + if(xorriso->allow_restore <= 0) { + sprintf(xorriso->info_text, + "-extract: image-to-disk copies are not enabled by option -osirrox"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + if(!(flag&2)) + Xorriso_pacifier_reset(xorriso, 0); + + ipth= iso_path; + if(ipth[0]==0) + ipth= disk_path; + if(disk_path[0]==0) { + sprintf(xorriso->info_text, "-extract: Empty disk_path given"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 1); + ret= 0; goto ex; + } + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, disk_path, eff_dest, + 2|4); + if(ret<=0) + goto ex; + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, ipth, eff_origin, 2|8); + if(ret<=0) + goto ex; + + eopt[0]= eff_origin; + edpt[0]= eff_dest; + ret= Xorriso_restore_sorted(xorriso, 1, eopt, edpt, (flag & 32 ? 33 : 0)); + + if(!(flag&2)) + Xorriso_pacifier_callback(xorriso, "files restored",xorriso->pacifier_count, + xorriso->pacifier_total, "", 1|4); + if(ret<=0) + goto ex; + + if(!(flag&1)) { + sprintf(xorriso->info_text, "Extracted from ISO image: %s '%s'='%s'\n", + (ret>1 ? "directory" : "file"), eff_origin, eff_dest); + Xorriso_info(xorriso,0); + } + ret= 1; +ex:; + if(!(flag & (4 | 32))) + Xorriso_destroy_node_array(xorriso, 0); + return(ret); +} + + +/* Option -extract_cut */ +int Xorriso_option_extract_cut(struct XorrisO *xorriso, char *iso_rr_path, + char *start, char *count, char *disk_path, int flag) +{ + int ret; + double num; + off_t startbyte, bytecount; + + num= Scanf_io_size(start, 0); + if(num<0 || num > 1.0e18) { /* 10^18 = 10^3 ^ 6 < 2^10 ^ 6 = 2^60 */ + sprintf(xorriso->info_text, + "-extract_cut: startbyte address negative or much too large (%s)", + start); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + startbyte= num; + num= Scanf_io_size(count, 0); + if(num<=0 || num > 1.0e18) { + sprintf(xorriso->info_text, + "-extract_cut: bytecount zero, negative or much too large (%s)", + count); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + bytecount= num; + sprintf(xorriso->info_text, + "-extract_cut from %s , byte %.f to %.f, and store as %s", + iso_rr_path, (double) startbyte, (double) (startbyte+bytecount), + disk_path); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + + ret= Xorriso_extract_cut(xorriso, iso_rr_path, disk_path, + startbyte, bytecount, 0); + return(ret); +} + + +/* Option -file_size_limit */ +int Xorriso_option_file_size_limit(struct XorrisO *xorriso, + int argc, char **argv, int *idx, int flag) +{ + int ret, i, end_idx; + off_t new_limit= 0; + + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1); + if(*idx >= end_idx) + {ret= 2; goto ex;} + if(*idx + 1 == end_idx && strcmp(argv[*idx], "off") == 0) { + xorriso->file_size_limit= 0; + ret= 1; goto ex; + } + for(i= *idx; i < end_idx; i++) + new_limit+= Scanf_io_size(argv[i], 0); + if(new_limit <= 0) { + sprintf(xorriso->info_text, "-file_size_limit: values sum up to %.f", + (double) new_limit); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 1); + ret= 0; goto ex; + } + xorriso->file_size_limit= new_limit; + ret= 1; +ex:; + (*idx)= end_idx; + if(ret > 0) { + if(xorriso->file_size_limit > 0) + sprintf(xorriso->info_text, "-file_size_limit now at %.f\n", + (double) xorriso->file_size_limit); + else + sprintf(xorriso->info_text, "-file_size_limit now off\n"); + Xorriso_info(xorriso,0); + } + return(ret); +} + + +/* Option -find alias -findi, and -findx */ +/* @param flag bit0= -findx rather than -findi + bit1= do not reset pacifier, no final pacifier message + do not reset find_compare_result + bit2= do not count deleted files with rm and rm_r + bit3= use Xorriso_findi_sorted() rather than Xorriso_findi() + (this can also be ordered by test -sort_lba) +*/ +int Xorriso_option_find(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int ret, i, end_idx, type= 0, action, deleter= 0, start_lba, count; + struct FindjoB *job, *first_job= NULL, *new_job; + char *start_path, sfe[5*SfileadrL], *cpt, other_path_start[SfileadrL]; + char *access_acl_text= NULL, *default_acl_text= NULL; + + struct stat dir_stbuf; + uid_t user= 0; + gid_t group= 0; + time_t date= 0; + mode_t mode_or= 0, mode_and= ~1; + double mem_lut= 0.0; + + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1); + start_path= "."; + if(end_idx > *idx && start_path[0]!=0) + start_path= argv[*idx]; + ret= Findjob_new(&first_job, start_path, 0); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-find[ix]", 0); + {ret= -1; goto ex;} + } + job= first_job; + if(!(flag&2)) + xorriso->find_compare_result= 1; + for(i= *idx+1; i<end_idx; i++) { + if(strcmp(argv[i], "-name")==0) { + if(i+1>=end_idx) { +not_enough_arguments:; + sprintf(xorriso->info_text, + "-find[ix]: not enough arguments with test %s", + Text_shellsafe(argv[i], sfe, 0)); + goto sorry_ex; + } + i++; + ret= Findjob_set_name_expr(job, argv[i], 0); + if(ret<=0) { + sprintf(xorriso->info_text, "-find[ix]: cannot set -name expression %s", + Text_shellsafe(argv[i], sfe, 0)); + goto sorry_ex; + } + } else if(strcmp(argv[i], "-wholename")==0) { + if(i+1>=end_idx) + goto not_enough_arguments; + i++; + ret= Findjob_set_name_expr(job, argv[i], 1); + if(ret<=0) { + sprintf(xorriso->info_text, + "-find[ix]: cannot set -wholename expression %s", + Text_shellsafe(argv[i], sfe, 0)); + goto sorry_ex; + } + } else if(strcmp(argv[i], "-type")==0) { + if(i+1>=end_idx) + goto not_enough_arguments; + i++; + ret= Findjob_set_file_type(job, argv[i][0], 0); + if(ret<=0) { + sprintf(xorriso->info_text, "-find[ix]: unknown -type '%c'",argv[i][0]); + goto sorry_ex; + } + } else if(strcmp(argv[i], "-damaged")==0) { + Findjob_set_damage_filter(job, 1, 0); + } else if(strcmp(argv[i], "-undamaged")==0) { + Findjob_set_damage_filter(job, -1, 0); + } else if(strcmp(argv[i], "-lba_range")==0) { + if(i+2>=end_idx) + goto not_enough_arguments; + i+= 2; + sscanf(argv[i-1], "%d", &start_lba); + sscanf(argv[i], "%d", &count); + Findjob_set_lba_range(job, start_lba, count, 0); + } else if(strcmp(argv[i], "-pending_data")==0) { + Findjob_set_commit_filter_2(job, 0); + } else if(strcmp(argv[i], "-has_acl")==0) { + Findjob_set_acl_filter(job, 1, 0); + } else if(strcmp(argv[i], "-has_no_acl")==0) { + Findjob_set_acl_filter(job, -1, 0); + } else if(strcmp(argv[i], "-has_xattr")==0) { + Findjob_set_xattr_filter(job, 1, 0); + } else if(strcmp(argv[i], "-has_any_xattr")==0) { + Findjob_set_xattr_filter(job, 1, 1); + } else if(strcmp(argv[i], "-has_no_xattr")==0) { + Findjob_set_xattr_filter(job, -1, 0); + } else if(strcmp(argv[i], "-has_aaip")==0) { + Findjob_set_aaip_filter(job, 1, 0); + } else if(strcmp(argv[i], "-has_no_aaip")==0) { + Findjob_set_aaip_filter(job, -1, 0); + } else if(strcmp(argv[i], "-has_filter")==0) { + Findjob_set_filter_filter(job, 1, 0); + } else if(strcmp(argv[i], "-has_no_filter")==0) { + Findjob_set_filter_filter(job, -1, 0); + } else if(strcmp(argv[i], "-has_md5")==0) { + Findjob_set_prop_filter(job, 15, 1, 0); + } else if(strcmp(argv[i], "-true") == 0) { + ret= Findjob_set_false(job, -1, 0); + } else if(strcmp(argv[i], "-false") == 0) { + ret= Findjob_set_false(job, 1, 0); + } else if(strcmp(argv[i], "-decision") == 0) { + if(i+1>=end_idx) + goto not_enough_arguments; + i++; + ret= Findjob_set_decision(job, argv[i], 0); + } else if(strcmp(argv[i], "-prune") == 0) { + ret= Findjob_set_prune(job, 0); + } else if(strcmp(argv[i], "-sub") == 0 || strcmp(argv[i], "(") == 0) { + ret= Findjob_open_bracket(job, 0); + } else if(strcmp(argv[i], "-subend") == 0 || strcmp(argv[i], ")") == 0) { + ret= Findjob_close_bracket(job, 0); + } else if(strcmp(argv[i], "-not") == 0 || strcmp(argv[i], "!") == 0) { + ret= Findjob_not(job, 0); + } else if(strcmp(argv[i], "-and") == 0 || strcmp(argv[i], "-a") == 0) { + ret= Findjob_and(job, 0); + } else if(strcmp(argv[i], "-or") == 0 || strcmp(argv[i], "-o") == 0) { + ret= Findjob_or(job, 0); + } else if(strcmp(argv[i], "-if") == 0) { + ret= Findjob_if(job, 0); + } else if(strcmp(argv[i], "-then") == 0) { + ret= Findjob_then(job, 0); + } else if(strcmp(argv[i], "-else") == 0) { + ret= Findjob_else(job, 0); + } else if(strcmp(argv[i], "-elseif") == 0) { + ret= Findjob_elseif(job, 0); + } else if(strcmp(argv[i], "-endif") == 0) { + ret= Findjob_endif(job, 0); + } else if(strcmp(argv[i], "-sort_lba") == 0) { + flag|= 8; + /* If an operator is open: insert a -true test, else do nothing */ + ret= Findjob_set_false(job, -1, 1); + if(ret == 2) + ret= 1; + } else if(strcmp(argv[i], "-exec")==0) { + if(i+1>=end_idx) { +not_enough_exec_arguments:; + sprintf(xorriso->info_text, + "-find[ix]: not enough arguments with -exec %s", + Text_shellsafe(argv[i], sfe, 0)); + goto sorry_ex; + } + i++; + cpt= argv[i]; + if(*cpt=='-') + cpt++; + if(strcmp(cpt, "echo")==0) { + Findjob_set_action_target(job, 0, NULL, 0); + } else if(strcmp(cpt, "rm")==0) { + Findjob_set_action_target(job, 1, NULL, 0); + deleter= 1; + } else if(strcmp(cpt, "rm_r")==0) { + Findjob_set_action_target(job, 2, NULL, 0); + deleter= 1; + +#ifdef NIX +/* >>> not implemented yet */; + } else if(strcmp(cpt, "mv")==0) { + if(i+1>=end_idx) + goto not_enough_exec_arguments; + i++; + Findjob_set_action_target(job, 3, argv[i], 0); +#endif + + } else if(strcmp(cpt, "chown")==0 || strcmp(cpt, "chown_r")==0) { + if(i+1>=end_idx) + goto not_enough_exec_arguments; + i++; + ret= Xorriso_convert_uidstring(xorriso, argv[i], &user, 0); + if(ret<=0) + goto ex; + ret= Findjob_set_action_chown(job, user, strlen(cpt)>5); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-find -exec chown_r", 0); + goto ex; + } + } else if(strcmp(cpt, "chgrp")==0 || strcmp(cpt, "chgrp_r")==0) { + if(i+1>=end_idx) + goto not_enough_exec_arguments; + i++; + ret= Xorriso_convert_gidstring(xorriso, argv[i], &group, 0); + if(ret<=0) + goto ex; + ret= Findjob_set_action_chgrp(job, group, strlen(cpt)>5); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-find -exec chgrp_r", 0); + goto ex; + } + } else if(strcmp(cpt, "chmod")==0 || strcmp(cpt, "chmod_r")==0) { + if(i+1>=end_idx) + goto not_enough_exec_arguments; + i++; + ret= Xorriso_convert_modstring(xorriso, "-find -exec chmod", + argv[i], &mode_and, &mode_or, 0); + if(ret<=0) + goto ex; + ret= Findjob_set_action_chmod(job, mode_and, mode_or, strlen(cpt)>5); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-find -exec chmod_r", 0); + goto ex; + } + } else if(strcmp(cpt, "alter_date")==0 || strcmp(cpt, "alter_date_r")==0){ + if(i+2>=end_idx) + goto not_enough_exec_arguments; + i+= 2; + ret= Xorriso_convert_datestring(xorriso, "-find -exec alter_date", + argv[i-1], argv[i], &type, &date, 0); + if(ret<=0) + goto ex; + ret= Findjob_set_action_ad(job, type, date, strlen(cpt)>10); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-find -exec alter_date_r", 0); + goto ex; + } + } else if(strcmp(cpt, "lsdl")==0) { + Findjob_set_action_target(job, 8, NULL, 0); + + } else if(strcmp(cpt, "find")==0) { + ret= Findjob_new(&new_job, "", 0); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-find[ix]", 0); + {ret= -1; goto ex;} + } + Findjob_set_action_subjob(job, 13, new_job, 0); + job= new_job; + + } else if(strcmp(cpt, "compare")==0 || strcmp(cpt, "update")==0 || + strcmp(cpt, "widen_hardlinks")==0) { + if(i+1>=end_idx) + goto not_enough_exec_arguments; + i++; + action= 14; + if(strcmp(cpt, "update")==0) + action= 17; + if(strcmp(cpt, "widen_hardlinks")==0) + action= 32; + ret= Xorriso_make_abs_adr(xorriso, xorriso->wdx, argv[i], + other_path_start, 1|2|4|8); + if(ret<=0) + goto ex; + Findjob_set_action_target(job, action, other_path_start, 0); + ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, start_path,sfe, 1|2|4); + if(ret<=0) + goto ex; + Findjob_set_start_path(job, sfe, 0); + if(!(flag&2)) { + Xorriso_pacifier_reset(xorriso, 0); + mem_lut= xorriso->last_update_time; + } + } else if(strcmp(cpt, "in_iso")==0 || + strcmp(cpt, "not_in_iso")==0 || + strcmp(cpt, "add_missing")==0 || + strcmp(cpt, "empty_iso_dir")==0 || + strcmp(cpt, "is_full_in_iso")==0) { + if(i+1>=end_idx) + goto not_enough_exec_arguments; + i++; + ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, argv[i], + other_path_start, 1|2|4); + if(ret<=0) + goto ex; + if(strcmp(cpt, "in_iso")==0) + action= 15; + else if(strcmp(cpt, "add_missing")==0) + action= 18; + else if(strcmp(cpt, "empty_iso_dir")==0) + action= 19; + else if(strcmp(cpt, "is_full_in_iso")==0) + action= 20; + else + action= 16; + Findjob_set_action_target(job, action, other_path_start, 0); + ret= Xorriso_make_abs_adr(xorriso, xorriso->wdx, start_path, sfe, + 1|2|4|8); + if(ret<=0) + goto ex; + Findjob_set_start_path(job, sfe, 0); + + } else if(strcmp(cpt, "report_damage")==0) { + Findjob_set_action_target(job, 21, NULL, 0); + } else if(strcmp(cpt, "report_lba")==0) { + Findjob_set_action_target(job, 22, NULL, 0); + } else if(strcmp(cpt, "getfacl")==0) { + Findjob_set_action_target(job, 24, NULL, 0); + } else if(strcmp(cpt, "setfacl")==0) { + if(i+1>=end_idx) + goto not_enough_exec_arguments; + i++; + ret= Xorriso_normalize_acl_text(xorriso, argv[i], + &access_acl_text, &default_acl_text, 0); + if(ret <= 0) + goto ex; + Findjob_set_action_text_2(job, 25, access_acl_text, default_acl_text, + 0); + } else if(strcmp(cpt, "getfattr")==0) { + Findjob_set_action_target(job, 26, NULL, 0); + } else if(strcmp(cpt, "setfattr")==0) { + if(i + 2 >= end_idx) + goto not_enough_exec_arguments; + i+= 2; + /* check input */ + ret= Xorriso_path_setfattr(xorriso, NULL, "", argv[i - 1], + strlen(argv[i]), argv[i], 1); + if(ret <= 0) + goto ex; + Findjob_set_action_text_2(job, 27, argv[i - 1], argv[i], 0); + } else if(strcmp(cpt, "set_filter")==0) { + if(i + 1 >= end_idx) + goto not_enough_exec_arguments; + i+= 1; + Findjob_set_action_target(job, 28, argv[i], 0); + if(!(flag&2)) { + Xorriso_pacifier_reset(xorriso, 0); + mem_lut= xorriso->last_update_time; + } + } else if(strcmp(cpt, "show_stream")==0) { + Findjob_set_action_target(job, 29, NULL, 0); + } else if(strcmp(cpt, "get_any_xattr")==0) { + Findjob_set_action_target(job, 33, NULL, 0); + } else if(strcmp(cpt, "get_md5")==0) { + Findjob_set_action_target(job, 34, NULL, 0); + } else if(strcmp(cpt, "check_md5")==0) { + if(i + 1 >= end_idx) + goto not_enough_exec_arguments; + i+= 1; + Findjob_set_action_target(job, 35, argv[i], 0); + flag|= 8; + if(!(flag&2)) { + Xorriso_pacifier_reset(xorriso, 0); + mem_lut= xorriso->last_update_time; + } + if(!(flag & 1)) + xorriso->find_check_md5_result= 0; + } else if(strcmp(cpt, "make_md5")==0) { + Findjob_set_action_target(job, 36, NULL, 0); + flag|= 8; + if(!(flag&2)) { + Xorriso_pacifier_reset(xorriso, 0); + mem_lut= xorriso->last_update_time; + } + } else { + sprintf(xorriso->info_text, "-find -exec: unknown action %s", + Text_shellsafe(argv[i], sfe, 0)); + goto sorry_ex; + } + } else { + sprintf(xorriso->info_text, "-find[ix]: unknown option %s", + Text_shellsafe(argv[i], sfe, 0)); +sorry_ex:; + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + } + if(flag&1) + ret= Xorriso_findx(xorriso, first_job, "", start_path, &dir_stbuf, 0, NULL, + 0); + else if(flag & 8) { + cpt= start_path; + ret= Xorriso_findi_sorted(xorriso, first_job, (off_t) 0, 1, &cpt, 0); + } else + ret= Xorriso_findi(xorriso, first_job, NULL, (off_t) 0, NULL, + start_path, &dir_stbuf, 0, (flag&4)>>1); +ex:; + if(deleter && !(flag&2)) + Xorriso_pacifier_callback(xorriso, "iso_rr_paths deleted", + xorriso->pacifier_count, 0, "", 1|2); + else if(first_job->action == 28 && !(flag&2)) + Xorriso_pacifier_callback(xorriso, "file filters processed", + xorriso->pacifier_count, 0, "", 1 | 2); + else if(mem_lut!=xorriso->last_update_time && mem_lut!=0.0 && !(flag&2)) + Xorriso_pacifier_callback(xorriso, "content bytes read", + xorriso->pacifier_count, 0, "", 1); + if(first_job->action == 35 && !(flag & 1)) + Xorriso_report_md5_outcome(xorriso, first_job->target, 0); + if(access_acl_text != NULL) + free(access_acl_text); + if(default_acl_text != NULL) + free(default_acl_text); + Findjob_destroy(&first_job, 0); + (*idx)= end_idx; + return(ret); +} + + +/* Option -follow */ +int Xorriso_option_follow(struct XorrisO *xorriso, char *mode, int flag) +{ + int was_fl, was_fm, was_fpr, was_fpt, l; + double num; + char *cpt, *npt; + + was_fpt= xorriso->do_follow_pattern; + was_fpr= xorriso->do_follow_param; + was_fl= xorriso->do_follow_links; + was_fm= xorriso->do_follow_mount; + xorriso->do_follow_pattern= 0; + xorriso->do_follow_param= 0; + xorriso->do_follow_links= 0; + xorriso->do_follow_mount= 0; + npt= cpt= mode; + for(cpt= mode; npt!=NULL; cpt= npt+1) { + npt= strchr(cpt,':'); + if(npt==NULL) + l= strlen(cpt); + else + l= npt-cpt; + if(l==0) + goto unknown_mode; + if(strncmp(cpt, "off", l)==0) { + xorriso->do_follow_pattern= 0; + xorriso->do_follow_param= 0; + xorriso->do_follow_links= 0; + xorriso->do_follow_mount= 0; + } else if(strncmp(cpt, "on", l)==0) { + xorriso->do_follow_pattern= 1; + xorriso->do_follow_param= 1; + xorriso->do_follow_links= 1; + xorriso->do_follow_mount= 1; + } else if(strncmp(cpt, "default", l)==0) { + xorriso->do_follow_pattern= 1; + xorriso->do_follow_param= 0; + xorriso->do_follow_links= 0; + xorriso->do_follow_mount= 1; + xorriso->follow_link_limit= 100; + } else if(strncmp(cpt, "link", l)==0 || strncmp(cpt,"links", l)==0) { + xorriso->do_follow_links= 1; + } else if(strncmp(cpt, "mount", l)==0) { + xorriso->do_follow_mount= 1; + } else if(strncmp(cpt,"param", l)==0) { + xorriso->do_follow_param= 1; + } else if(strncmp(cpt, "pattern", l)==0) { + xorriso->do_follow_pattern= 1; + } else if(strncmp(cpt, "limit=", 6)==0) { + sscanf(cpt+6, "%lf", &num); + if(num<=0 || num>1.0e6) { + sprintf(xorriso->info_text, "-follow: Value too %s with '%s'", + num<=0 ? "small" : "large", cpt+6); + goto sorry_ex; + } + xorriso->follow_link_limit= num; + } else { +unknown_mode:; + if(l<SfileadrL) + sprintf(xorriso->info_text, "-follow: unknown mode '%s'", cpt); + else + sprintf(xorriso->info_text, "-follow: oversized mode parameter (%d)",l); +sorry_ex: + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + xorriso->do_follow_pattern= was_fpt; + xorriso->do_follow_param= was_fpr; + xorriso->do_follow_links= was_fl; + xorriso->do_follow_mount= was_fm; + return(0); + } + } + return(1); +} + + +/* Option -fs */ +int Xorriso_option_fs(struct XorrisO *xorriso, char *size, int flag) +{ + double num; + + num= Scanf_io_size(size, 0); + if(num < 64*1024 || num > 1024.0 * 1024.0 * 1024.0) { + sprintf(xorriso->info_text, "-fs: wrong size %.f (allowed: %.f - %.f)", + num, 64.0 * 1024.0, 1024.0 * 1024.0 * 1024.0); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + xorriso->fs= num / 2048.0; + if(xorriso->fs * 2048 < num) + xorriso->fs++; + return(1); +} + + +/* Optionis -getfacl alias -getfacli, -getfacl_r alias -getfacl_ri + -getfattr alias getfattri +*/ +/* @param flag bit0= recursive -getfacl_r + bit1= getfattr rather than getfacl + bit3= with bit1: do not ignore eventual non-user attributes +*/ +int Xorriso_option_getfacli(struct XorrisO *xorriso, + int argc, char **argv, int *idx, int flag) +{ + int i, ret, was_failure= 0, end_idx, fret; + int optc= 0; + char **optv= NULL; + struct FindjoB *job= NULL; + struct stat dir_stbuf; + + ret= Xorriso_opt_args(xorriso, "-getfacl", argc, argv, *idx, &end_idx, &optc, + &optv, 0); + if(ret<=0) + goto ex; + for(i= 0; i<optc; i++) { + if(flag&1) { + ret= Findjob_new(&job, optv[i], 0); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-getfacl_r", 0); + {ret= -1; goto ex;} + } + if(flag & 2) { + Findjob_set_action_target(job, 26, NULL, 0); + } else + Findjob_set_action_target(job, 24, NULL, 0); + ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0, + NULL, optv[i], &dir_stbuf, 0, 0); + Findjob_destroy(&job, 0); + } else { + if(flag & 2) + ret= Xorriso_getfattr(xorriso, NULL, optv[i], NULL, flag & 8); + else + ret= Xorriso_getfacl(xorriso, NULL, optv[i], NULL, 0); + } + if(ret>0 && !xorriso->request_to_abort) + continue; /* regular bottom of loop */ + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + ret= 0; goto ex; + } + ret= 1; +ex:; + (*idx)= end_idx; + Xorriso_opt_args(xorriso, "-getfacl", argc, argv, *idx, &end_idx, + &optc, &optv, 256); + Findjob_destroy(&job, 0); + if(ret<=0) + return(ret); + return(!was_failure); +} + + +/* Option -gid */ +int Xorriso_option_gid(struct XorrisO *xorriso, char *gid, int flag) +{ + int ret; + + xorriso->do_global_gid= 0; + if(gid[0]==0 || strcmp(gid,"-")==0) + return(1); + ret= Xorriso_convert_gidstring(xorriso, gid, &(xorriso->global_gid), 0); + if(ret>0) + xorriso->do_global_gid= 1; + return(ret); +} + + +/* Option -grow_blindly */ +int Xorriso_option_grow_blindly(struct XorrisO *xorriso, char *msc2, int flag) +{ + double num; + int l; + + if(msc2[0]==0 || msc2[0]=='-' || strcmp(msc2, "off")==0) { + xorriso->grow_blindly_msc2= -1; + return(1); + } + num= Scanf_io_size(msc2, 0); + l= strlen(msc2); + if(msc2[l-1]<'0' || msc2[l-1]>'9') + num/= 2048.0; + xorriso->grow_blindly_msc2= num; + return(1); +} + + +/* Option -hardlinks "on"|"off" */ +int Xorriso_option_hardlinks(struct XorrisO *xorriso, char *mode, int flag) +{ + int ret; + char what_data[SfileadrL], *what, *what_next; + + if(Sfile_str(what_data, mode, 0)<=0) { + sprintf(xorriso->info_text, + "-hardlinks: mode string is much too long (%d)", + (int) strlen(mode)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + for(what= what_data; what != NULL; what= what_next) { + what_next= strchr(what, ':'); + if(what_next != NULL) { + *what_next= 0; + what_next++; + } + if(strcmp(what, "off") == 0) { + Xorriso_finish_hl_update(xorriso, 0); + xorriso->ino_behavior|= 1 | 2 | 4; + xorriso->ino_behavior&= ~8; + } else if(strcmp(what, "on") == 0) { + xorriso->ino_behavior&= ~(1 | 2 | 4 | 8); + } else if(strcmp(what, "without_update") == 0) { + Xorriso_finish_hl_update(xorriso, 0); + xorriso->ino_behavior&= ~(1 | 2 | 4); + xorriso->ino_behavior|= 8; + } else if(strcmp(what, "start_update") == 0) { + xorriso->ino_behavior&= ~(1 | 2 | 4 | 8); + ret= Xorriso_make_di_array(xorriso, 1); + if(ret <= 0) + return(ret); + } else if(strcmp(what, "end_update") == 0) { + Xorriso_finish_hl_update(xorriso, 0); + } else if(strcmp(what, "perform_update") == 0) { + Xorriso_finish_hl_update(xorriso, 0); + } else if(strcmp(what, "start_extract") == 0) { + xorriso->ino_behavior&= ~(1 | 2 | 4); + ret= Xorriso_make_hln_array(xorriso, 1); + if(ret <= 0) + return(ret); + } else if(strcmp(what, "end_extract") == 0) { + Xorriso_destroy_hln_array(xorriso, 0); + } else if(strcmp(what, "discard_extract") == 0) { + Xorriso_destroy_hln_array(xorriso, 0); + } else if(strcmp(what, "normal_extract") == 0) { + xorriso->ino_behavior&= ~16; + } else if(strcmp(what, "cheap_sorted_extract") == 0) { + xorriso->ino_behavior|= 16; + } else { + sprintf(xorriso->info_text, "-hardlinks: unknown mode '%s' in '%s'", + what, mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + } + if(xorriso->ino_behavior & 2) + Xorriso_option_compliance(xorriso, "new_rr", 0); + + return(1); +} + + +/* Option -help and part of -prog_help */ +int Xorriso_option_help(struct XorrisO *xorriso, int flag) +{ + static char text[][80]={ + +#ifdef Xorriso_no_helP + +"This binary program does not contain a help text.", +"If available, read: man 1 xorriso", + +#else + +"This program creates, loads, manipulates and writes ISO 9660 filesystem", +"images with Rock Ridge extensions. Write targets can be drives with optical", +"media or local filesystem objects.", +"", +"Preparation options:", +"Drive addresses are either /dev/... as listed with option -devices or", +"disk files, eventually with prefix \"stdio:\" if non-CD-drive in /dev tree.", +"E.g. /dev/sr0 , /tmp/pseudo_drive , stdio:/dev/sdc", +" -dev address Set input and output drive and load eventual ISO image.", +" Set the image expansion method to growing.", +" -indev address Set input drive and load eventual ISO image. Use expansion", +" methods modifying or blind growing.", +" -outdev address", +" Set output drive and use modifying or blind growing.", +" -drive_class \"harmless\"|\"banned\"|\"risky\"|\"clear_list\" disk_pattern", +" Add a drive path pattern to one of the safety lists or make", +" those lists empty. Defaulty entry in \"risky\" is \"/dev\".", +" -grow_blindly \"off\"|predicted_nwa", +" Switch between modifying and blind growing.", +" -load \"session\"|\"track\"|\"lba\"|\"sbsector\"|\"volid\"|\"auto\" id", +" Load a particular (outdated) ISO image from a -dev or", +" -indev which hosts more than one session.", +" -rom_toc_scan \"on\"|\"off\"[:\"emul_on\"|\"emul_off\"]", +" Enable scanning for ISO sessions on read-only drives/media", +" resp. on overwriteable media with emulated TOC.", +" -calm_drive \"in\"|\"out\"|\"all\"|\"on\"|\"off\"", +" Reduce drive noise until it gets actually used again.", +" -assert_volid pattern severity", +" Accept input image only if its volume id matches pattern.", +" -charset name Set the character set name to be used for file name", +" conversion from and to media.", +" -in_charset name", +" Like -charset but only for conversion from media.", +" -auto_charset \"on\"|\"off\"", +" Enable writing and reading of character set name in image.", +" -out_charset name", +" Like -charset but only for conversion to media.", +" -local_charset name", +" Override system assumption of the local character set name.", +" -hardlinks mode[:mode ...]", +" Enable resp. disable recording and restoring of hard links.", +" Modes are \"on\", \"off\", \"perform_update\",", +" \"without_update\", \"discard_extract\",", +" \"cheap_sorted_extract\", \"normal_extract\"", +" -acl \"on\"|\"off\"", +" Enable resp. disable reading and writing of ACLs.", +" -xattr \"on\"|\"off\"", +" Enable resp. disable reading and writing of xattr.", +" -for_backup", +" Shortcut for: -hardlinks on -acl on -xattr on -md5 on", +" -disk_dev_ino \"on\"|\"ino_only\"|\"off\"", +" Enable resp. disable recording of disk file dev_t and ino_t", +" and their use in file comparison.", +" -md5 \"on\"|\"all\"|\"off\"", +" Enable resp. disable processing of MD5 checksums.", +" -ban_stdio_write", +" Allow for writing only the usage of optical drives.", +" -blank \"fast\"|\"all\"|\"deformat\"|\"deformat_quickest\"", +" Blank media resp. invalidate ISO image on media.", +" -format \"as_needed\"|\"full\"|\"fast\"|\"by_index_#\"|\"by_size_#\"", +" Format BD-RE, BD-R, DVD-RAM, DVD-RW, DVD+RW.", +" -volid volume_id", +" Specifies the volume ID text. (32 chars out of [A-Z0-9_])", +" -publisher name", +" Specifies the publisher name. (128 chars)", +" -application_id name", +" Specifies the application id. (128 chars)", +" -joliet \"on\"|\"off\"", +" Generate Joliet info additional to Rock Ridge info.", +" -compliance rule[:rule...]", +" Allow more or less harmless deviations from strict standards", +" compliance.", +" -boot_image \"any\"|\"isolinux\" \"discard\"|\"keep\"|\"patch\"|\"dir=\"", +" \"bin_path=\"|\"cat_path=\"|\"load_size=\"", +" Whether to discard or keep an exiting El Torito boot image.", +" ISOLINUX can be made bootable by dir=/ or dir=/isolinux", +" or dir=/boot/isolinux or by bin_path=... and cat_path=...", +" The ISOLINUX files need to be added to the ISO image by", +" help of the usual commands like -map or -add.", +"", +" -uid uid User id to be used for the whole multi-session ISO image.", +" -gid gid Group id for the same purpose.", +"", +" -devices Show list of available optical drives and their addresses.", +"", +" -toc Show media specific table of content (sessions).", +"", +" -mount_cmd drive entity id path", +" Print to result channel a command suitable to mount the", +" depicted entity (see -load) at the given directory path.", +" -session_string drive entity id \"linux:\"path|\"freebsd:\"path|form", +" Print foreign OS command or custom line.", +"", +" -list_formats Show media specific list of format descriptors.", +"", +" -list_profiles \"in\"|\"out\"|\"all\"", +" Show list of media types supported by indev resp. outdev.", +" -print_size Print the foreseeable consumption by next -commit.", +"", +" -tell_media_space", +" Print foreseeable available space on output media", +"", +"Options with variable length path list [...] need the list delimiter text", +"as end mark if they are followed by another option. By default this delimiter", +"is \"--\". In dialog and with options read from files, the line end serves", +"as such a mark. With program arguments this mark can be omitted only with", +"the last option in the list of arguments.", +"For brevity the list delimiter is referred as \"--\" throughout this text.", +"", +" -list_delimiter text Set the list delimiter to be used instead of \"--\"", +" It has to be a single word, must not be empty, not longer", +" than 80 characters, may mot contain quotation marks.", +"", +"Manipulation options:", +"disk_path is a path to an object in the local filesystem tree.", +"iso_rr_path is the Rock Ridge name of a file object in the ISO image.", +"pathspec is either a disk_path or (if allowed) a pair: iso_rr_path=disk_path", +"Options marked by [***] have variable argument length and perform pattern", +"expansion if enabled by -iso_rr_pattern resp. -disk_pattern.", +"", +" -pathspecs \"on\"|\"off\" Allow or disallow pathspecs of form ", +" iso_rr_path=disk_path . Only \"off\" allows eventual", +" -disk_pattern expansion.", +" -add pathspec [...] | disk_path [***]", +" Insert the given files or directory trees from", +" filesystem into the ISO image. Much like mkisofs.", +" -add_plainly \"none\"|\"unknown\"|\"dashed\"|\"any\"", +" Whether to add lonely arguments as pathspec resp. disk_path.", +" -path_list disk_path", +" Like -add but read the pathspecs from file disk_path.", +" -quoted_path_list disk_path", +" Like -path_list but with line rules as -dialog \"on\".", +"", +" -map disk_path iso_rr_path", +" Insert disk file object at the given iso_rr_path.", +" -map_single disk_path iso_rr_path", +" Like -map but with directory do not insert its sub tree.", +" -map_l disk_prefix iso_rr_prefix disk_path [***]", +" Performs -map with each disk_path.", +" -update disk_path iso_rr_path", +" Compare both file objects and do what is necessary to make", +" iso_rr_path a matching copy of disk_path.", +" -update_r disk_path iso_rr_path", +" Like -update but affecting all files below directories.", +" -update_l disk_prefix iso_rr_prefix disk_path [***]", +" Performs -update_r with each disk_path.", +" -cut_out disk_path byte_offset byte_count iso_rr_path", +" Map a byte interval of a regular disk file into a regular", +" file in the ISO image.", +"", +" -cpr disk_path [***] iso_rr_path", +" Insert the given files or directory trees from filesystem", +" into the ISO image, according to the rules of cp -r.", +"", +" -rm iso_rr_path [***]", +" Delete the given files from the ISO image.", +" -rm_r iso_rr_path [***]", +" Delete the given directory trees from ISO image.", +" -mv iso_rr_path [***] iso_rr_path", +" Rename the given file objects in the ISO tree to the last", +" argument in the list.", +" -chown uid iso_rr_path [***]", +" Equivalent to chown in the ISO image.", +" -chown_r uid iso_rr_path [***]", +" Like -chown but affecting all files below directories.", +" -chgrp gid iso_rr_path [***]", +" Equivalent to chgrp in the ISO image.", +" -chgrp_r gid iso_rr_path [***]", +" Like -chgrp but affecting all files below directories.", +" -chmod mode iso_rr_path [***]", +" Equivalent to chmod in the ISO image.", +" -chmod_r mode iso_rr_path [***]", +" Like -chmod but affecting all files below directories.", +" -setfacl acl_text iso_rr_path [***]", +" Replace the permissions and eventual ACL of the given files", +" in the ISO image by the ACL which is defined by acl_text.", +" -setfacl_r acl_text iso_rr_path [***]", +" Like -setfacl but affecting all files below directories.", +" -setfacl_list disk_path", +" Read output of getfacl from file disk_path. Set owner,", +" group and ACL of the iso_rr_path given by line \"# file:\".", +" -setfattr [-]name value iso_rr_path [***]", +" Set xattr pair with the given name to the given value, or", +" delete pair if name is prefixed with \"-\" and value is", +" an empty text.", +" -setfattr_r [-]name value iso_rr_path [***]", +" Like -setfattr but affecting all files below directories.", +" -setfattr_list disk_path", +" Read output of getfattr from file disk_path. Replace the", +" xattr of the iso_rr_path given by line \"# file:\".", +" -alter_date type timestring iso_rr_path [***]", +" Alter the date entries of a file in the ISO image. type is", +" one of \"a\", \"m\", \"b\" for:", +" access time, modification time, both times.", +" -alter_date_r type timestring iso_rr_path [***]", +" Like -alter_date but affecting all files below directories.", +" -find iso_rr_path [test [op] [test ...]] [-exec action [params]]", +" performs an action on files below the given directory in", +" the ISO image. Tests:", +" -name pattern, -wholename pattern, -type b|c|d|p|f|l|s|e,", +" -pending_data, -lba_range start count, -damaged,", +" -has_acl, -has_xattr, -has_aaip, -has_filter, -has_md5", +" -has_any_xattr, -prune, -decision yes|no, -true, -false", +" Operators: -not, -or, -and, -sub, (, -subend, ),", +" -if, -then, -elseif, -else, -endif", +" Action may be one of: echo, chown, chown_r, chgrp, chgrp_r", +" chmod, chmod_r, alter_date, alter_date_r, lsdl, compare,", +" rm, rm_r, compare, update, report_damage, report_lba,", +" getfacl, setfacl, getfattr, setfattr, get_any_xattr,", +" get_md5, check_md5, make_md5, set_filter, show_stream,", +" find.", +" params are their arguments except iso_rr_path.", +" -mkdir iso_rr_path [...]", +" Create empty directories if they do not exist yet.", +" -rmdir iso_rr_path [***]", +" Delete empty directories.", +" -- Default list delimiter marking the end of action argument", +" list. It may be changed by option -list_delimiter.", +"", +" -not_paths disk_path [***]", +" Add the given paths to the list of excluded absolute paths.", +" -not_leaf pattern", +" Add the given pattern to the list of leafname exclusions.", +" -not_list disk_path", +" Read lines from disk_path and use as -not_paths (with \"/\")", +" or as -not_leaf (without \"/\").", +" -quoted_not_list disk_path", +" Like -not_list but with line rules as -dialog \"on\".", +" -not_mgt \"reset\"|\"on\"|\"off\"|\"param_on\"|\"subtree_on\"|\"ignore_on\"", +" Control effect of exclusion lists.", +" -follow \"on\"|\"pattern:param:link:mount:limit=#\"|\"default\"|\"off\"", +" Follow symbolic links and mount points within disk_path.", +" -overwrite \"on\"|\"nondir\"|\"off\"", +" Allow or disallow to overwrite existing files in ISO image.", +" -split_size number[\"k\"|\"m\"]", +" Set the threshold for automatic splitting of regular files.", +" -reassure \"on\"|\"tree\"|\"off\"", +" If \"on\" then ask the user for \"y\" or \"n\" with any", +" file before deleting or overwriting it in the ISO image.", +"", +"Filter options:", +"External filter processes may produce synthetic file content by reading the", +"original content from stdin and writing to stdout whatever they want.", + +#ifdef Xorriso_allow_external_filterS + +" -external_filter name option[:option] program_path [arguments] --", +" Define an external filter. Options are: suffix=...: ", +" remove_suffix:if_nonempty:if_reduction:if_block_reduction.", +" -unregister_filter name", +" Undefine an external filter.", +" -close_filter_list", +" Irrevocably ban -external_filter and -unregister_filter.", + +#else + +"Sorry: The use of external filters was not enabled at compile time.", +" E.g. by ./configure option --enable-external-filters", + +#endif /* ! Xorriso_allow_external_filterS */ + +" -set_filter name iso_rr_path [***]", +" Apply a defined filter to the given data files.", +" Special name \"--remove-all-filters\" revokes filtering.", +" Builtin filters are --gzip , --gunzip, --zisofs .", +" -set_filter_r name iso_rr_path [***]", +" Like -set_filter but affecting all files below directories.", +"", +"zisofs is a compression format which is recognized by some Linux kernels.", +"xorriso supports it by builtin filter \"--zisofs\" which is to be applied by", +"the user, and by \"--zisofs-decode\" which is applied automatically when", +"compressed content is detected with a file in the ISO image.", +" -zisofs option[:options]", +" Set global zisofs parameters:", +" level=0|...|9 , block_size=32k|64k|128k , by_magic=on|off", +"", +"Write-to-media options:", +" -rollback Discard the manipulated ISO image and reload it.", +"", +" -commit Perform the write operation and then perform -dev outdrive.", +" Hint: To perform a final write operation with no new -dev", +" and no new loading of image, execute option -end.", +" -commit_eject \"in\"|\"out\"|\"all\"|\"none\"", +" Like -commit but rather eject than load image from outdrive.", +" Give up any unejected drive afterwards.", +" -close \"on\"|\"off\"", +" If \"on\" then mark the written media as not appendable.", +" -padding number[\"k\"|\"m\"]", +" Append extra bytes to image stream. (Default is 300k)", +" -dummy \"on\"|\"off\"", +" If \"on\" simulate burning. Refuse if media cannot simulate.", +" -speed number[\"k/s\"|\"m/s\"|\"[x]CD\"|\"[x]DVD\"|\"[x]BD\"]", +" Set the burn speed. Default is 0 = maximum speed.", +" -stream_recording \"on\"|\"off\"", +" Try to circumvent slow checkread on DVD-RAM, BD-RE, BD-R.", +" -fs number[\"k\"|\"m\"]", +" Set the size of the fifo buffer. (Default is 4m)", +" -eject \"in\"|\"out\"|\"all\"", +" Immediately eject the media in -indev, resp. -outdev,", +" resp. both.", +"", +"Navigation options:", +"", +" -cd iso_rr_path Change working directory in the ISO image. iso_rr_paths", +" which do not begin with '/' will be inserted beginning at", +" the path given with -cd. -ls patterns will eventually", +" looked up at this path.", +" -cdi disk_path Same as -cd disk_path", +" -cdx disk_path Change the current working directory in the local", +" filesystem. disk_paths which do not begin with '/'", +" will be looked up beginning at the path given with -cdx.", +" -lsx patterns will eventually be looked up at this path.", +" -pwd tells the current working directory in the ISO image.", +" -pwdi same as -pwd.", +" -pwdx tells the current working directory in the local filesystem.", +"", +" -iso_rr_pattern \"on\"|\"ls\"|\"off\"", +" Enable or disable pattern expansions for ISO image commands", +" marked by [***]. \"ls\" restricts it to -ls and -du.", +" -disk_pattern \"on\"|\"ls\"|\"off\"", +" Enable or disable pattern expansions for local filesystem", +" commands marked by [***]. \"ls\" restricts to -ls*x and -du*x.", +"", +" -ls pattern [***] lists files of the ISO image which match one of the", +" given shell parser patterns. (I.e. wildcards '*' '?').", +" Directories are listed by their content.", +" -lsd pattern [***] like -ls but listing directories as single items.", +" -lsl pattern [***] like -ls but also telling some file attributes.", +" -lsdl pattern [***] like -lsd but also telling some file attributes.", +"", +" -lsx pattern [***] lists files of the local filesystem which match one", +" of the patterns. Directories are listed by their content.", +" -lsdx pattern [***] like -lsx but listing directories as single items.", +" -lslx pattern [***] like -lsx but also telling some file attributes.", +" -lsdlx pattern [***] like -lsdx but also telling some file attributes.", +" -getfacl pattern [***] list eventual ACLs of the given files.", +" -getfacl_r pattern [***] like -getfacl but listing whole file trees.", +" -getfattr pattern [***] list eventual xattr of the given files.", +" -getfxattr_r pattern [***] like -getfxattr but listing whole file trees.", +"", +" -du pattern [***] recursively lists sizes of files or directories in the", +" ISO image which match one of the shell parser patterns.", +" -dux pattern [***] recursively lists sizes of files or directories in the", +" local filesystem which match one of the shell parser", +" patterns.", +" -dus pattern [***] like -du but summing up subdirectories without", +" listing them explicitely.", +" -dusx pattern [***] like -dux but summing up subdirectories without", +" listing them explicitely.", +"", +" -findx disk_path [-name pattern] [-type t] [-exec action [params]]", +" Like -find but operating on local filesystem. Most -exec", +" actions are defaulted to action echo. Supported actions are:", +" in_iso, not_in_iso, is_full_in_iso, add_missing,", +" empty_iso_dir", +"", +" -compare disk_path iso_rr_path", +" compare attributes and in case of regular data files the", +" content of filesystem object and ISO object.", +" -compare_r disk_path iso_rr_path", +" Like -compare but affecting all files below directories.", +" -compare_l disk_prefix iso_rr_prefix disk_path [***]", +" Performs -compare_r with each disk_path.", +"", +" -show_stream iso_rr_path [***]", +" Show content stream chain of data files in the ISO image.", +" -show_stream_r iso_rr_path [***]", +" Like -show_stream but affecting all files below directories.", +"", +"Restore options which copy file objects from ISO image to disk filesystem:", +" -osirrox \"on\"|\"device_files\"|\"off\"|\"banned\"", +" [:\"concat_split_on\"|\"concat_split_off\"]", +" [:\"auto_chmod_on\"|\"auto_chmod_off\"]", +" [:\"sort_lba_on\"|\"sort_lba_off\"]", +" By default \"off\" the inverse operation of xorriso from ISO", +" image to disk filesystem is disabled. \"on\" allows xorriso", +" to create, overwrite, delete files in the disk filesystem.", +" \"banned\" is irrevocably \"off\".", +" -extract iso_rr_path disk_path", +" Copy tree under iso_rr_path onto disk address disk_path.", +" This avoids the pitfalls of cp -r addressing rules.", +" -extract_l iso_rr_prefix disk_prefix iso_rr_path [***]", +" Perform -extract with each iso_rr_path.", +" -extract_single iso_rr_path disk_path", +" Like -extract but with directory do not restore sub tree.", +" -extract_cut iso_rr_path byte_offset byte_count disk_path", +" Copy a byte interval from iso_rr_path to disk_path.", +" This is governed in part by -check_media_defaults.", +" -cpx iso_rr_path [***] disk_path", +" Copy leaf file objects from ISO image to disk filesystem.", +" -cpax iso_rr_path [***] disk_path", +" Like -cpx but trying to restore timestamps and ownership.", +" -cp_rx iso_rr_path [***] disk_path", +" Copy directory trees from ISO image to disk filesystem.", +" -cp_rax iso_rr_path [***] disk_path", +" Like -cp_rx but trying to restore timestamps and ownership.", +" -paste_in iso_rr_path disk_path byte_offset byte_count", +" Copy ISO file content into a byte interval of a disk file.", +" -mount drive entity id path", +" Like -mount_cmd but actually performing that command if", +" not setuid or setgid is active.", +"", +"Evaluation of readability:", +" -check_media [options] --", +" Try to read data blocks from media and report about the", +" outcome. Several options modify the behavior:", +" use=indev|outdev , what=track|session ,", +" min_lba=blockadr , max_lba=blockadr ,", +" abort_file=path , time_limit=seconds , item_limit=number ,", +" retry=on|off|default , data_to=filepath ,", +" sector_map=filepath , map_with_volid=on|off ,", +" patch_lba0=on|off|force|blockadr[:force] ,", +" report=blocks|files|blocks_files event=severity", +" -check_media_defaults [options] --", +" Preset options for runs of -check_media and -extract_cut.", +"", +"Compatibility emulation (argument list may be ended by list delimiter --):", +" -as mkisofs [-help|-version|-o|-R|-J|-V|-P|-f|-m|-exclude-list|-no-pad|", +" -M|-C|-graft-points|-path-list|pathspecs|-z|", +" -no-emul-boot|-b|-c|-boot-info-table|-boot-load-size]", +" Perform some mkisofs gestures, understand pathspecs as mkisofs", +" does. Commit happens outside emulation at usual occasions.", +" -as cdrecord [-help|-v|dev=|speed=|blank=|fs=|-eject|-atip|padsize=|-multi]", +" path|-", +" Perform some cdrecord gestures, eventually write at most one", +" data track to blank, appendable or overwriteable media.", +" -pacifier \"xorriso\"|\"cdrecord\"|\"mkisofs\"", +" Choose format of UPDATE pacifier during write operations.", +"", +"General options:", +" -help Print this text", +" -abort_on severity Set the threshhold for events to abort the program.", +" Useful severities: NEVER, ABORT, FATAL, FAILURE, SORRY, WARNING", +" -return_with severity exit_value Set the threshhold for events to return", +" at program end the given exit_value even if not aborted.", +" exit_value may be 0 or 32 to 63.", +" -report_about severity Set the threshhold for events to be reported.", +" Use -abort_on severities or: HINT, NOTE, UPDATE, DEBUG, ALL", +" -error_behavior \"image_loading\"|\"file_extraction\" behavior", +" Behavior \"best_effort\" is most endurant but may produce", +" results which are correct only on the first glimpse.", +" -dialog \"on\"|\"off\"|\"single_line\"", +" After all arguments are processed, enter dialog mode.", +" \"single_line\" does not support newline characters within", +" open quotation marks and no line continuation by trailing \\.", +" -page len width Prompt user after len output lines (0=no prompt).", +" width (default 80) can adjust line number computation", +" to the output terminal's line width.", +#ifdef Xorriso_with_readlinE +" -use_stdin Use raw standard input even if libreadline is available", +" -use_readline Use libreadline for dialog if available", +" -history text Copy text into libreadline history. This command", +" itself is not copied to the history list.", +#endif /* Xorriso_with_readlinE */ +" -backslash_codes \"on\"|\"off\"|", +" \"in_double_quotes\"|\"in_quotes\"|\"with_quoted_input\"", +" [:\"with_program_arguments\"][:\"encode_output\"]", +" Disable or enable interpretation of \\a \\b \\e \\f \\n \\r \\t \\v", +" \\\\ \\NNN \\xNN \\cC in input or program arguments.", +" -pkt_output \"on\"|\"off\" Direct output to stdout and prefix each line", +" by a short header which tells channel id and a mode number.", +" Each such output packet is finalized by a newline.", +" Channel ids are 'R:' for result lines, 'I:' for notes", +" and error messages, 'M:' for -mark texts. Bit 0 of the", +" mode number tells whether the newline is also part of the", +" packet payload. Example of a info message with newline:", +" I:1: enter option text :", +" -pkt_output:on is intended for use by frontend programs.", +" -logfile channel fileaddress Copy output of a channel to the given file.", +" channel may be 'R','I','M' as with -pkt_output or '.'", +" for the consolidated -pkt_output stream.", +" -mark text If text is not empty it will get put out each time an", +" option is completed.", +" -temp_mem_limit number[\"k\"|\"m\"]", +" Set the maximum size for pattern expansion. (Default is 16m)", +" -prog text Use text as this program's name in subsequent messages", +" -prog_help text Use text as this program's name and perform -help", +" -status mode|filter Report the current settings of persistent options.", +" Modes:", +" short... print only important or altered options", +" long ... print options even if they have default settings", +" long_history like long plus -history: lines", +" Filters begin with '-' and are compared literally against the", +" output lines of -status long_history. A line is put out only", +" if its start matches the filter.", +" -status_history_max number Maximum number of history lines to be reported", +" with -status:long_history", +" -options_from_file fileaddress", +" Reads lines from the given file and executes them as program", +" options.", +" -no_rc Only if used as first command line argument this option", +" prevents reading and interpretation of startup files.", +" -print text", +" Print a text to result channel.", +" -prompt text", +" Wait for Enter key resp. for a line of input at stdin.", +" -errfile_log mode path|channel", +" Log disk paths of files involved in problem events.", +" -session_log path", +" Set path of a file where a log record gets appended after", +" each session. Form: timestamp start_lba size volume-id", +" # any text Is ignored. In dialog mode the input line will be stored in", +" the eventual readline history, nevertheless.", +" -version Tell program and version number", +" -end End program. Commit eventual pending changes.", +" -rollback_end", +" End program. Discard pending changes.", +"", +"", +"Option -page causes a user prompt after the given number of result lines.", +"Empty input resumes output until the next prompt. Other input may be:", +" @ suppresses paging until the current action is done", +" @@ suppresses further result output but continues the action", +" @@@ aborts the current action", +" other aborts the current action and executes input as new", +" option", +"", + +#endif /* ! Xorriso_no_helP */ + +"@ENDE_OF_HELPTEXT_(HOPEFULLY_UNIQUELY_SILLY_TEXT)@" + }; + + char *tpt= NULL; + int i,pass; + + Xorriso_restxt(xorriso,"\n"); + sprintf(xorriso->result_line,"usage: %s [settings|actions]\n", + xorriso->progname); + Xorriso_result(xorriso,0); + Xorriso_restxt(xorriso,"\n"); + for(pass=0;pass<1;pass++) { + for(i=0;1;i++) { + if(pass==0) + tpt= text[i]; + + if(strcmp(tpt,"@ENDE_OF_HELPTEXT_(HOPEFULLY_UNIQUELY_SILLY_TEXT)@")==0) + break; + sprintf(xorriso->result_line,"%s\n",tpt); + Xorriso_result(xorriso,0); + if(xorriso->request_to_abort) + return(1); + } + } + Xorriso_restxt(xorriso,"\n"); + return(1); +} + + +/* Option -history */ +int Xorriso_option_history(struct XorrisO *xorriso, char *line, int flag) +{ + Xorriso_dialog_input(xorriso,line,strlen(line)+1,2); + return(1); +} + + +/* Option -iso_rr_pattern "on"|"ls"|"off" */ +int Xorriso_option_iso_rr_pattern(struct XorrisO *xorriso, char *mode,int flag) +{ + if(strcmp(mode, "off")==0) + xorriso->do_iso_rr_pattern= 0; + else if(strcmp(mode, "on")==0) + xorriso->do_iso_rr_pattern= 1; + else if(strcmp(mode, "ls")==0) + xorriso->do_iso_rr_pattern= 2; + else { + sprintf(xorriso->info_text, "-iso_rr_pattern: unknown mode '%s'", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(1); +} + + +/* Option -joliet "on"|"off" */ +int Xorriso_option_joliet(struct XorrisO *xorriso, char *mode, int flag) +{ + if(strcmp(mode, "off")==0) + xorriso->do_joliet= 0; + else if(strcmp(mode, "on")==0) + xorriso->do_joliet= 1; + else { + sprintf(xorriso->info_text, "-joliet: unknown mode '%s'", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(1); +} + + +/* Option -list_delimiter */ +int Xorriso_option_list_delimiter(struct XorrisO *xorriso, char *text, + int flag) +{ + int ret, argc; + char **argv= NULL; + + if(text[0] == 0) { + sprintf(xorriso->info_text, + "-list_delimiter: New delimiter text is empty"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if(strlen(text) > 80) { + sprintf(xorriso->info_text, + "-list_delimiter: New delimiter text is too long"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + ret= Sfile_make_argv(xorriso->progname, text, &argc, &argv, 4); + if(ret > 0) { + if(argc > 2) { + sprintf(xorriso->info_text, + "-list_delimiter: New delimiter text contains more than one word"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + } + Sfile_make_argv(xorriso->progname, text, &argc, &argv, 2); + if(argc > 2) + return(0); + } + if(strchr(text, '"') != NULL || strchr(text, '\'') != NULL) { + sprintf(xorriso->info_text, + "-list_delimiter: New delimiter text contains quotation marks"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + strcpy(xorriso->list_delimiter, text); + return(1); +} + + +/* Option -list_formats */ +int Xorriso_option_list_formats(struct XorrisO *xorriso, int flag) +{ + int ret; + + ret= Xorriso_list_formats(xorriso, 0); + return(ret); +} + + +/* Option -list_profiles */ +int Xorriso_option_list_profiles(struct XorrisO *xorriso, char *which, + int flag) +{ + int ret; + int mode= 0; + + if(strncmp(which,"in",2)==0) + mode|= 1; + else if(strncmp(which,"out",3)==0) + mode|= 2; + else + mode|= 3; + if(mode & 1) { + ret= Xorriso_toc(xorriso, 1 | 16 | 32); + if(ret > 0) + Xorriso_list_profiles(xorriso, 0); + } + if((mode & 2) && xorriso->in_drive_handle != xorriso->out_drive_handle) { + ret= Xorriso_toc(xorriso, 1 | 2 | 16 | 32); + if(ret > 0) + Xorriso_list_profiles(xorriso, 2); + } + return(1); +} + + +/* Option -load session|track|sbsector value */ +/* @param flag bit0= with adr_mode sbsector: adr_value is possibly 16 too high + @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_load(struct XorrisO *xorriso, char *adr_mode, + char *adr_value, int flag) +{ + int ret; + + if(xorriso->volset_change_pending) { + sprintf(xorriso->info_text, + "-load: Image changes pending. -commit or -rollback first"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + ret= Xorriso_reassure(xorriso, "-load", "loads an alternative image", 0); + if(ret<=0) + return(2); + ret= Xorriso_decode_load_adr(xorriso, "-load", adr_mode, adr_value, + &(xorriso->image_start_mode), + xorriso->image_start_value, flag & 1); + if(ret <= 0) + return(ret); + xorriso->image_start_mode|= (1<<30); /* enable non-default msc1 processing */ + if(strlen(xorriso->indev)>0) { + ret= Xorriso_option_rollback(xorriso, 1); /* Load image, no -reassure */ + if(ret<=0) + return(ret); + } + return(1); +} + + +/* Option -logfile */ +int Xorriso_option_logfile(struct XorrisO *xorriso, char *channel, + char *fileadr, int flag) +{ + int hflag,channel_no= 0, ret; + + if(channel[0]==0) { +logfile_wrong_form:; + sprintf(xorriso->info_text,"Wrong form. Correct would be: -logfile \".\"|\"R\"|\"I\"|\"M\" file_address"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + hflag= 2; + if(channel[0]=='R') + channel_no= 1; + else if(channel[0]=='I') + channel_no= 2; + else if(channel[0]=='M') + channel_no= 3; + else if(channel[0]=='.') + hflag= 4; + else + goto logfile_wrong_form; + if(strcmp(fileadr,"-")==0 || fileadr[0]==0) + hflag|= (1<<15); + xorriso->logfile[channel_no][0]= 0; + ret= Xorriso_write_to_channel(xorriso, fileadr, channel_no, hflag); + if(ret<=0) { + sprintf(xorriso->info_text, "Cannot open logfile: %s", fileadr); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + } else if(!(hflag&(1<<15))) + if(Sfile_str(xorriso->logfile[channel_no], fileadr, 0)<=0) + return(-1); + return(ret>0); +} + + +/* Options -ls alias -lsi and -lsl alias -lsli + and -lsd alias -lsdi and -lsdl alias -lsdli + and -du alias -dui and -dus alias -dusi + @param flag bit0= long format (-lsl , -du) + bit1= do not expand patterns but use literally + bit2= du rather than ls + bit3= list directories as themselves (ls -d) +*/ +int Xorriso_option_lsi(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int ret, end_idx, filec= 0, nump, i; + char **filev= NULL, **patterns= NULL; + off_t mem= 0; + struct stat stbuf; + + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1); + if(xorriso->do_iso_rr_pattern==0) + flag|= 2; + + nump= end_idx - *idx; + if((flag&2) && nump>0 ) { + ; + } else if(nump <= 0) { + if(Xorriso_iso_lstat(xorriso, xorriso->wdi, &stbuf, 0)<0) { + sprintf(xorriso->info_text, + "Current -cd path does not yet exist in the ISO image"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + {ret= 0; goto ex;} + } + if(!S_ISDIR(stbuf.st_mode)) { + sprintf(xorriso->info_text, + "Current -cd meanwhile points to a non-directory in ISO image"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + {ret= 0; goto ex;} + } + patterns= calloc(1, sizeof(char *)); + if(patterns == NULL) { +no_memory:; + sprintf(xorriso->info_text, + "Cannot allocate enough memory for pattern expansion"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + nump= 1; + if(flag&8) + patterns[0]= "."; + else + patterns[0]= "*"; + flag&= ~2; + } else { + patterns= calloc(nump, sizeof(char *)); + if(patterns==NULL) + goto no_memory; + for(i= 0; i<nump; i++) { + if(argv[i + *idx][0]==0) + patterns[i]= "*"; + else + patterns[i]= argv[i + *idx]; + } + } + + if((flag & 1) && !(xorriso->ino_behavior & 1)) { + ret= Xorriso_make_hln_array(xorriso, 0); /* for stbuf.st_nlink */ + if(ret < 0) + return(ret); + } + if(flag&2) { + ret= Xorriso_ls_filev(xorriso, xorriso->wdi, nump, argv + (*idx), mem, + flag&(1|4|8)); + } else if(nump==1 && strcmp(patterns[0],"*")==0 && !(flag&4)){ + /* save temporary memory by calling simpler function */ + ret= Xorriso_ls(xorriso, (flag&1)|4); + } else { + ret= Xorriso_expand_pattern(xorriso, nump, patterns, 0, &filec, &filev, + &mem, 0); + if(ret<=0) + {ret= 0; goto ex;} + ret= Xorriso_ls_filev(xorriso, xorriso->wdi, filec, filev, mem, + flag&(1|4|8)); + } + if(ret<=0) + {ret= 0; goto ex;} + + ret= 1; +ex:; + if(patterns!=NULL) + free((char *) patterns); + Sfile_destroy_argv(&filec, &filev, 0); + (*idx)= end_idx; + return(ret); +} + + +/* Options -lsx, -lslx, -lsdx , -lsdlx , -dux , -dusx + @param flag bit0= long format (-lslx , -dux) + bit1= do not expand patterns but use literally + bit2= du rather than ls + bit3= list directories as themselves (ls -d) +*/ +int Xorriso_option_lsx(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int ret, end_idx, filec= 0, nump, i; + char **filev= NULL, **patterns= NULL; + off_t mem= 0; + + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1|2); + if(xorriso->do_disk_pattern==0) + flag|= 2; + + nump= end_idx - *idx; + if((flag&2) && nump>0) { + ; + } else if(nump <= 0) { + patterns= calloc(1, sizeof(char *)); + if(patterns == NULL) { +no_memory:; + sprintf(xorriso->info_text, + "Cannot allocate enough memory for pattern expansion"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + nump= 1; + if(flag&8) + patterns[0]= "."; + else + patterns[0]= "*"; + flag&= ~2; + } else { + patterns= calloc(nump, sizeof(char *)); + if(patterns==NULL) + goto no_memory; + for(i= 0; i<nump; i++) { + if(argv[i + *idx][0]==0) + patterns[i]= "*"; + else + patterns[i]= argv[i + *idx]; + } + } + if(flag&2) { + ret= Xorriso_lsx_filev(xorriso, xorriso->wdx, + nump, argv + (*idx), mem, flag&(1|4|8)); + +#ifdef Not_yeT + } else if(nump==1 && strcmp(patterns[0],"*")==0 && !(flag&4)){ + /* save temporary memory by calling simpler function */ + ret= Xorriso_ls(xorriso, (flag&1)|4); +#endif + + } else { + ret= Xorriso_expand_disk_pattern(xorriso, nump, patterns, 0, &filec, &filev, + &mem, 0); + if(ret<=0) + {ret= 0; goto ex;} + ret= Xorriso_lsx_filev(xorriso, xorriso->wdx, filec, filev, mem, + flag&(1|4|8)); + } + if(ret<=0) + {ret= 0; goto ex;} + + ret= 1; +ex:; + if(patterns!=NULL) + free((char *) patterns); + Sfile_destroy_argv(&filec, &filev, 0); + (*idx)= end_idx; + return(ret); +} + + +/* Option -map , -map_single */ +/* @param flag bit0=do not report the added item + bit1=do not reset pacifier, no final pacifier message + bit5=eventually do not insert directory tree +*/ +int Xorriso_option_map(struct XorrisO *xorriso, char *disk_path, + char *iso_path, int flag) +{ + int ret; + char eff_origin[SfileadrL], eff_dest[SfileadrL], *ipth; + + if(!(flag&2)) + Xorriso_pacifier_reset(xorriso, 0); + + ipth= iso_path; + if(ipth[0]==0) + ipth= disk_path; + if(disk_path[0]==0) { + sprintf(xorriso->info_text, "-map: Empty disk_path given"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 1); + return(0); + } + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, disk_path, eff_origin, + 2|4); + if(ret<=0) + return(ret); + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, ipth, eff_dest, 2); + if(ret<=0) + return(ret); + ret= Xorriso_graft_in(xorriso, NULL, eff_origin, eff_dest, + (off_t) 0, (off_t) 0, 2|(flag&32)); + if(!(flag&2)) + Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count, + xorriso->pacifier_total, "", 1); + if(ret<=0) + return(ret); + + if(!(flag&1)) { + sprintf(xorriso->info_text, "Added to ISO image: %s '%s'='%s'\n", + (ret>1 ? "directory" : "file"), (eff_dest[0] ? eff_dest : "/"), + eff_origin); + Xorriso_info(xorriso,0); + } + return(1); +} + + +/* Options -map_l , -compare_l , -update_l , -extract_l */ +/* @param flag bit4= do not establish and dispose xorriso->di_array + for update_l + bit8-11= mode 0= -map_l + 1= -compare_l + 2= -update_l + 3= -extract_l +*/ +int Xorriso_option_map_l(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int ret, end_idx, optc= 0, was_failure= 1, i, fret, mode; + int ns_flag= 2|4, nt_flag= 2, opt_args_flag= 2, made_di_array= 0; + char source_prefix[SfileadrL], target_prefix[SfileadrL], *cmd, **optv= NULL; + char eff_source[SfileadrL], eff_target[SfileadrL], *source_pt, *s_wd, *t_wd; + char sfe[5*SfileadrL], **eff_src_array= NULL, **eff_tgt_array= NULL; + + cmd= "-map_l"; + s_wd= xorriso->wdx; + t_wd= xorriso->wdi; + Xorriso_pacifier_reset(xorriso, 0); + mode= (flag>>8) & 15; + + if(mode==1) + cmd= "-compare_l"; + else if(mode==2) + cmd= "-update_l"; + else if(mode==3) { + cmd= "-extract_l"; + ns_flag= 2; + s_wd= xorriso->wdi; + nt_flag= 2|4; + t_wd= xorriso->wdx; + opt_args_flag= 0; + } + + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1|2); + if(end_idx - (*idx) < 3) { + sprintf(xorriso->info_text, "%s: Not enough arguments given (%d < 3)", cmd, + end_idx - (*idx)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 1); + ret= 0; goto ex; + } + ret= Xorriso_normalize_img_path(xorriso, s_wd, argv[*idx], + source_prefix, ns_flag | 64); + if(ret<=0) + goto ex; + ret= Xorriso_normalize_img_path(xorriso, t_wd, argv[(*idx)+1], + target_prefix, nt_flag); + if(ret<=0) + goto ex; + ret= Xorriso_opt_args(xorriso, cmd, argc, argv, (*idx)+2, &end_idx, + &optc, &optv, opt_args_flag); + if(ret<=0) + goto ex; + + + if(mode == 3 && + (xorriso->do_restore_sort_lba || !(xorriso->ino_behavior & 4))) { + eff_src_array= calloc(optc, sizeof(char *)); + eff_tgt_array= calloc(optc, sizeof(char *)); + if(eff_src_array == NULL || eff_tgt_array == NULL) { + Xorriso_no_malloc_memory(xorriso, NULL, 0); + ret= -1; goto ex; + } + for(i= 0; i < optc; i++) + eff_src_array[i]= eff_tgt_array[i]= NULL; + } + if(mode == 2 && !((xorriso->ino_behavior & 2) || (flag & 16) || + xorriso->di_array != NULL)) { + /* Create all-image node array sorted by isofs.di */ + ret= Xorriso_make_di_array(xorriso, 0); + if(ret <= 0) + goto ex; + made_di_array= 1; + } + + for(i= 0; i<optc; i++) { + ret= Xorriso_normalize_img_path(xorriso, s_wd, optv[i], + eff_source, ns_flag); + if(ret<=0) + goto ex; + strcpy(eff_target, target_prefix); + source_pt= eff_source; + if(source_prefix[0]) { + if(strncmp(source_prefix, eff_source, strlen(source_prefix))!=0) { + sprintf(xorriso->info_text, + "%s: disk_path %s does not begin with disk_prefix ", cmd, + Text_shellsafe(eff_source, sfe, 0)); + Text_shellsafe(source_prefix, + xorriso->info_text+strlen(xorriso->info_text), 0); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 1); + ret= 0; goto ex; + } + source_pt+= strlen(source_prefix); + } + strcat(eff_target, source_pt); + + if(mode==0) + ret= Xorriso_option_map(xorriso, eff_source, eff_target, 2); + else if(mode==1) + ret= Xorriso_option_compare(xorriso, eff_source, eff_target, 2|8); + else if(mode==2) + ret= Xorriso_option_update(xorriso, eff_source, eff_target, 2 | 8 | 16); + else if(mode==3) { + if(eff_src_array != NULL) { + eff_src_array[i]= strdup(eff_source); + eff_tgt_array[i]= strdup(eff_target); + if(eff_src_array[i] == NULL || eff_tgt_array[i] == NULL) { + Xorriso_no_malloc_memory(xorriso, &(eff_src_array[i]), 0); + ret= -1; goto ex; + } + } else { + ret= Xorriso_option_extract(xorriso, eff_source, eff_target, 2 | 4); + } + } + + if(ret>0 && !xorriso->request_to_abort) + continue; /* regular bottom of loop */ + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 2); + if(fret>=0) + continue; + goto ex; + } + + ret= 1; + if(mode == 3 && eff_src_array != NULL) { + ret= Xorriso_lst_append_binary(&(xorriso->node_disk_prefixes), + target_prefix, strlen(target_prefix) + 1, 0); + if(ret <= 0) + goto ex; + ret= Xorriso_lst_append_binary(&(xorriso->node_img_prefixes), + source_prefix, strlen(source_prefix) + 1, 0); + if(ret <= 0) + goto ex; + ret= Xorriso_restore_sorted(xorriso, optc, eff_src_array, eff_tgt_array, 0); + } + if(mode==0) + Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count, + xorriso->pacifier_total, "", 1); + else if(mode==1 || mode==2) + Xorriso_pacifier_callback(xorriso, "content bytes read", + xorriso->pacifier_count, 0, "", 1); + else if(mode==3) + Xorriso_pacifier_callback(xorriso, "files restored",xorriso->pacifier_count, + xorriso->pacifier_total, "", 1|4); +ex:; + Xorriso_destroy_node_array(xorriso, 0); + i= optc; + Sfile_destroy_argv(&i, &eff_src_array, 0); + i= optc; + Sfile_destroy_argv(&i, &eff_tgt_array, 0); + (*idx)= end_idx; + Xorriso_opt_args(xorriso, cmd, argc, argv, *idx, &end_idx, &optc, &optv, 256); + if(ret<=0) + return(ret); + return(!was_failure); +} + + +/* Option -mark */ +int Xorriso_option_mark(struct XorrisO *xorriso, char *mark, int flag) +{ + if(mark[0]==0) + xorriso->mark_text[0]= 0; + else + strncpy(xorriso->mark_text,mark,sizeof(xorriso->mark_text)-1); + xorriso->mark_text[sizeof(xorriso->mark_text)-1]= 0; + return(1); +} + + +/* Option -md5 "on"|"all"|"off" */ +int Xorriso_option_md5(struct XorrisO *xorriso, char *mode, int flag) +{ + char *npt, *cpt; + int l; + + npt= cpt= mode; + for(; npt!=NULL; cpt= npt+1) { + npt= strchr(cpt,':'); + if(npt==NULL) + l= strlen(cpt); + else + l= npt-cpt; + if(l == 0) + continue; + if(l == 3 && strncmp(cpt, "off", l) == 0) + xorriso->do_md5&= ~31; + else if(l == 2 && strncmp(cpt, "on", l) == 0) + xorriso->do_md5= (xorriso->do_md5 & ~31) | 7 | 16; + else if(l == 3 && strncmp(cpt, "all", l) == 0) + xorriso->do_md5|= 31; + else if(l == 18 && strncmp(cpt, "stability_check_on", l) == 0) + xorriso->do_md5|= 8; + else if(l == 19 && strncmp(cpt, "stability_check_off", l) == 0) + xorriso->do_md5&= ~8; + else { + sprintf(xorriso->info_text, "-md5: unknown mode "); + Text_shellsafe(cpt, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + } + return(1); +} + + +/* Option -mkdir alias -mkdiri */ +int Xorriso_option_mkdiri(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int i, end_idx, ret, was_failure= 0, fret; + + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0); + + for(i= *idx; i<end_idx; i++) { + ret= Xorriso_mkdir(xorriso, argv[i], 0); + if(ret>0 && !xorriso->request_to_abort) + continue; /* regular bottom of loop */ + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + goto ex; + } + ret= 1; +ex:; + (*idx)= end_idx; + if(ret<=0) + return(ret); + return(!was_failure); +} + + +/* Options -mount , -mount_cmd , -session_string */ +/* @param bit0= -mount_cmd: print mount command to result channel rather + than performing it + bit1= preform -session_string rather than -mount_cmd +*/ +int Xorriso_option_mount(struct XorrisO *xorriso, char *dev, char *adr_mode, + char *adr, char *cmd, int flag) +{ + int ret, entity_code= 0, m_flag; + char entity_id[81], *mnt; + + if(flag & 1) + mnt= "-mount_cmd"; + else if(flag & 2) + mnt= "-session_string"; + else { + mnt= "-mount"; + if(xorriso->allow_restore <= 0) { + sprintf(xorriso->info_text, + "-mount: image-to-disk features are not enabled by option -osirrox"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if(xorriso->volset_change_pending) { + sprintf(xorriso->info_text, + "%s: Image changes pending. -commit or -rollback first", mnt); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + } + ret= Xorriso_decode_load_adr(xorriso, mnt, adr_mode, adr, + &entity_code, entity_id, 0); + if(ret <= 0) + return(ret); + if(flag & 2) + m_flag= 1 | 4; + else + m_flag= (flag & 1) | 2; + ret= Xorriso_mount(xorriso, dev, entity_code, entity_id, cmd, m_flag); + return(ret); +} + + +/* Option -mv alias -mvi */ +int Xorriso_option_mvi(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int i, end_idx_dummy, ret, is_dir= 0, was_failure= 0, fret; + char sfe[5*SfileadrL], sfe2[5*SfileadrL]; + char eff_origin[SfileadrL], eff_dest[SfileadrL], dest_dir[SfileadrL]; + char leafname[SfileadrL]; + int optc= 0; + char **optv= NULL; + + ret= Xorriso_cpmv_args(xorriso, "-mvi", argc, argv, idx, + &optc, &optv, eff_dest, 0); + if(ret<=0) + goto ex; + if(ret==2) { + is_dir= 1; + strcpy(dest_dir, eff_dest); + } + /* Perform movements */ + for(i= 0; i<optc; i++) { + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi,optv[i],eff_origin,0); + if(ret<=0 || xorriso->request_to_abort) + goto problem_handler; + if(is_dir) { + ret= Sfile_leafname(eff_origin, leafname, 0); + if(ret<=0) + goto problem_handler; + strcpy(eff_dest, dest_dir); + ret= Sfile_add_to_path(eff_dest, leafname, 0); + if(ret<=0) { + sprintf(xorriso->info_text, "Effective path gets much too long (%d)", + (int) (strlen(eff_dest)+strlen(leafname)+1)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + goto problem_handler; + } + } + ret= Xorriso_rename(xorriso, NULL, eff_origin, eff_dest, 0); + if(ret<=0 || xorriso->request_to_abort) + goto problem_handler; + sprintf(xorriso->info_text, "Renamed in ISO image: %s to %s\n", + Text_shellsafe(eff_origin,sfe,0),Text_shellsafe(eff_dest,sfe2,0)); + Xorriso_info(xorriso, 0); + + continue; /* regular bottom of loop */ +problem_handler:; + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + goto ex; + } + ret= !was_failure; +ex:; + Xorriso_opt_args(xorriso, "-mvi", + argc, argv, *idx, &end_idx_dummy, &optc, &optv, 256); + return(ret); +} + + +/* Option -no_rc */ +int Xorriso_option_no_rc(struct XorrisO *xorriso, int flag) +{ + xorriso->no_rc= 1; + return(1); +} + + +/* Option -not_leaf */ +int Xorriso_option_not_leaf(struct XorrisO *xorriso, char *pattern, int flag) +{ + regex_t re; + char regexpr[2*SfileadrL+2], sfe[5*SfileadrL]; + int ret= 0; + + if(pattern[0]==0) + {ret= 0; goto cannot_add;} + Xorriso__bourne_to_reg(pattern, regexpr, 0); + if(regcomp(&re, regexpr, 0)!=0) + {ret= 0; goto cannot_add;} + ret= Exclusions_add_not_leafs(xorriso->disk_exclusions, pattern, &re, 0); + if(ret<=0) { +cannot_add:; + sprintf(xorriso->info_text,"Cannot add pattern: -not_leaf %s", + Text_shellsafe(pattern, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(ret); + } + return(1); +} + + +/* Option -not_list , -quoted_not_list */ +/* @param flag bit0= -quoted_not_list */ +int Xorriso_option_not_list(struct XorrisO *xorriso, char *adr, int flag) +{ + int ret, linecount= 0, insertcount= 0, null= 0, argc= 0, i; + FILE *fp= NULL; + char sfe[5*SfileadrL], **argv= NULL; + + Xorriso_pacifier_reset(xorriso, 0); + if(adr[0]==0) { + sprintf(xorriso->info_text, "Empty file name given with %s", + (flag & 1) ? "-quoted_not_list" : "-not_list"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + ret= Xorriso_afile_fopen(xorriso, adr, "rb", &fp, 0); + if(ret <= 0) + return(0); + while(1) { + ret= Xorriso_read_lines(xorriso, fp, &linecount, &argc, &argv, + 4 | (flag & 1) ); + if(ret <= 0) + goto ex; + if(ret == 2) + break; + for(i= 0; i < argc; i++) { + if(argv[i][0] == 0) + continue; + if(strchr(argv[i], '/')!=NULL) { + null= 0; + ret= Xorriso_option_not_paths(xorriso, 1, argv + i, &null, 0); + } else + ret= Xorriso_option_not_leaf(xorriso, argv[i], 0); + if(ret<=0) + goto ex; + insertcount++; + } + } + ret= 1; +ex:; + if(fp != NULL && fp != stdin) + fclose(fp); + Xorriso_read_lines(xorriso, fp, &linecount, &argc, &argv, 2); + if(ret<=0) { + sprintf(xorriso->info_text, "Aborted reading of file %s in line number %d", + Text_shellsafe(adr, sfe, 0), linecount); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + } + sprintf(xorriso->info_text, "Added %d exclusion list items from file %s\n", + insertcount, Text_shellsafe(adr, sfe, 0)); + Xorriso_info(xorriso,0); + return(ret); +} + + +/* Option -not_mgt */ +int Xorriso_option_not_mgt(struct XorrisO *xorriso, char *setting, int flag) +{ + int ret; + char what_data[SfileadrL], *what, *what_next; + + if(Sfile_str(what_data, setting, 0)<=0) { + sprintf(xorriso->info_text, + "-not_mgt: setting string is much too long (%d)", + (int) strlen(setting)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + for(what= what_data; what!=NULL; what= what_next) { + what_next= strchr(what, ':'); + if(what_next!=NULL) { + *what_next= 0; + what_next++; + } + + if(strcmp(what, "reset")==0 || strcmp(what, "erase")==0) { + if(strcmp(what, "reset")==0) + xorriso->disk_excl_mode= 1; + Exclusions_destroy(&(xorriso->disk_exclusions), 0); + ret= Exclusions_new(&(xorriso->disk_exclusions), 0); + if(ret<=0) { + Xorriso_no_malloc_memory(xorriso, NULL, 0); + return(ret); + } + } else if(strcmp(what, "on")==0) { + xorriso->disk_excl_mode|= 1; + } else if(strcmp(what, "off")==0) { + xorriso->disk_excl_mode&= ~1; + } else if(strcmp(what, "param_on")==0) { + xorriso->disk_excl_mode|= 2; + } else if(strcmp(what, "param_off")==0) { + xorriso->disk_excl_mode&= ~2; + } else if(strcmp(what, "subtree_on")==0) { + xorriso->disk_excl_mode|= 4; + } else if(strcmp(what, "subtree_off")==0) { + xorriso->disk_excl_mode&= ~4; + } else if(strcmp(what, "ignore_on")==0) { + xorriso->disk_excl_mode|= 8; + } else if(strcmp(what, "ignore_off")==0) { + xorriso->disk_excl_mode&= ~8; + } else { + sprintf(xorriso->info_text, "-not_mgt: unknown setting '%s'", what); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + } + return(1); +} + + +/* Option -not_paths */ +int Xorriso_option_not_paths(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int ret, end_idx, num_descr, dummy, optc= 0, i; + char **descr= NULL, **optv= NULL, sfe[5*SfileadrL], eff_path[SfileadrL]; + + + end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, + (xorriso->do_disk_pattern==1) | 2); + if(end_idx<=0) + return(end_idx); + num_descr= end_idx - *idx; + if(num_descr<=0) + {ret= 1; goto ex;} + + /* produce absolute patterns */ + descr= TSOB_FELD(char *, num_descr); + if(descr==NULL) { +no_memory:; + Xorriso_no_pattern_memory(xorriso, sizeof(char *) * (off_t) num_descr, 0); + ret= -1; goto ex; + } + for(i= 0; i<num_descr; i++) + descr[i]= NULL; + for(i= 0; i<num_descr; i++) { + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, argv[i+*idx], + eff_path, 2|4); + if(ret<=0) + goto ex; + descr[i]= strdup(eff_path); + if(descr[i]==NULL) + goto no_memory; + } + + ret= Xorriso_opt_args(xorriso, "-not_paths", + num_descr, descr, 0, &dummy, &optc, &optv, 2); + if(ret<=0) + goto ex; + ret= Exclusions_add_not_paths(xorriso->disk_exclusions, + num_descr, descr, optc, optv, 0); + if(ret<=0) { + sprintf(xorriso->info_text,"Cannot add path list: -not_paths %s%s %s", + Text_shellsafe(argv[*idx], sfe, 0), (num_descr>1 ? " ..." : ""), + xorriso->list_delimiter); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + } +ex:; + (*idx)= end_idx; + Xorriso_opt_args(xorriso, "-not_paths", + num_descr, descr, 0, &dummy, &optc, &optv, 256); + if(descr!=NULL) { + for(i= 0; i<num_descr; i++) + if(descr[i]!=NULL) + free(descr[i]); + free((char *) descr); + descr= NULL; + } + return(ret); +} + + +/* Option -options_from_file */ +int Xorriso_option_options_from_file(struct XorrisO *xorriso, char *adr, + int flag) +/* + bit0= called from Xorriso_prescan_args, + therefore execute via that same function +*/ +/* +return: + <=0 error , 1 = success , 3 = end program run +*/ +{ + int ret,linecount= 0, argc= 0, was_failure= 0, fret; + FILE *fp= NULL; + char shellsafe[5*SfileadrL]; + char **argv= NULL; + int linec= 0; + char *line= NULL, **linev= NULL; + + if(adr[0]==0) { + sprintf(xorriso->info_text,"Empty file name given with -options_from_file"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + Text_shellsafe(adr,shellsafe,0); + if(xorriso->is_dialog) { + sprintf(xorriso->info_text,"+ performing command lines from file %s :\n", + shellsafe); + Xorriso_info(xorriso,1); + } + ret= Xorriso_afile_fopen(xorriso, adr, "rb", &fp, 0); + if(ret <= 0) + return(0); + while(1) { + ret= Xorriso_read_lines(xorriso, fp, &linecount, &linec, &linev, 1 | 8); + if(ret <= 0) + goto ex; /* no problem_handler because there is no sense in going on */ + if(ret == 2) + break; + line= linev[0]; + if(line[0]==0 || line[0]=='#') + continue; + + if(flag&1) { + ret= Sfile_make_argv(xorriso->progname, line, &argc, &argv, + 4 | 8 | ((xorriso->bsl_interpretation & 3) << 5)); + if(ret<=0) + goto problem_handler; + ret= Xorriso_prescan_args(xorriso,argc,argv,1); + if(ret==0) + {ret= 3; goto ex;} + if(ret<0) + goto problem_handler; + } else { + if(xorriso->is_dialog) { + sprintf(xorriso->info_text,"+ %d: %s\n",linecount,line); + Xorriso_info(xorriso,1); + } + ret= Xorriso_execute_option(xorriso,line,1|(1<<16)); + if(ret==3) + goto ex; + if(ret<=0) + goto problem_handler; + } + + continue; /* regular bottom of loop */ +problem_handler:; + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1); + if(fret>=0) + continue; + goto ex; + } + ret= 1; +ex:; + Sfile_make_argv("", "", &argc, &argv, 2); /* release memory */ + Xorriso_read_lines(xorriso, fp, &linecount, &linec, &linev, 2); + Xorriso_reset_counters(xorriso,0); + if(fp != NULL && fp != stdin) + fclose(fp); + if(ret<=0) { + sprintf(xorriso->info_text, + "error triggered by line %d of file:\n %s\n", + linecount,shellsafe); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 1); + } + if(ret!=1) + return(ret); + return(!was_failure); +} + + +/* Option -osirrox "on"|"off" */ +int Xorriso_option_osirrox(struct XorrisO *xorriso, char *mode, int flag) +{ + int l, allow_restore; + char *npt, *cpt; + + allow_restore= xorriso->allow_restore; + + npt= cpt= mode; + for(cpt= mode; npt!=NULL; cpt= npt+1) { + npt= strchr(cpt,':'); + if(npt==NULL) + l= strlen(cpt); + else + l= npt-cpt; + if(l==0 && mode[0]!=0) + goto unknown_mode; + if(strncmp(cpt, "off", l)==0) + allow_restore= 0; + else if(strncmp(cpt, "banned", l)==0) + allow_restore= -1; + else if(strncmp(cpt, "device_files", l)==0) + allow_restore= 2; + else if(strncmp(cpt, "on", l)==0 || mode[0]==0) + allow_restore= 1; + else if(strncmp(cpt, "concat_split_on", l)==0) + xorriso->do_concat_split= 1; + else if(strncmp(cpt, "concat_split_off", l)==0) + xorriso->do_concat_split= 0; + else if(strncmp(cpt, "auto_chmod_on", l)==0) + xorriso->do_auto_chmod= 1; + else if(strncmp(cpt, "auto_chmod_off", l)==0) + xorriso->do_auto_chmod= 0; + else if(strncmp(cpt, "sort_lba_on", l)==0) + xorriso->do_restore_sort_lba= 1; + else if(strncmp(cpt, "sort_lba_off", l)==0) + xorriso->do_restore_sort_lba= 0; + else { +unknown_mode:; + sprintf(xorriso->info_text, "-osirrox: unknown mode '%s'", cpt); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + } + if(allow_restore > 0 && xorriso->allow_restore == -1) { + sprintf(xorriso->info_text, + "-osirrox: was already permanently disabled by setting 'banned'"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if(xorriso->allow_restore != -1) + xorriso->allow_restore= allow_restore; + sprintf(xorriso->info_text, + "Copying of file objects from ISO image to disk filesystem is: %s\n", + xorriso->allow_restore > 0 ? "Enabled" : "Disabled"); + Xorriso_info(xorriso, 0); + return(1); +} + + +/* Option -overwrite "on"|"nondir"|"off" */ +int Xorriso_option_overwrite(struct XorrisO *xorriso, char *mode, int flag) +{ + if(strcmp(mode, "off")==0) + xorriso->do_overwrite= 0; + else if(strcmp(mode, "on")==0) + xorriso->do_overwrite= 1; + else if(strcmp(mode, "nondir")==0) + xorriso->do_overwrite= 2; + else { + sprintf(xorriso->info_text, "-overwrite: unknown mode '%s'", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(1); +} + + +/* Option -pacifier */ +int Xorriso_option_pacifier(struct XorrisO *xorriso, char *style, int flag) +{ + if(strcmp(style, "xorriso")==0 || strcmp(style, "default")==0) + xorriso->pacifier_style= 0; + else if(strcmp(style, "mkisofs")==0 || strcmp(style, "genisofs")==0 || + strcmp(style, "genisoimage")==0 || strcmp(style, "xorrisofs")==0) + xorriso->pacifier_style= 1; + else if(strcmp(style, "cdrecord")==0 || strcmp(style, "cdrskin")==0 || + strcmp(style, "wodim")==0 || strcmp(style, "xorrecord")==0) + xorriso->pacifier_style= 2; + else { + sprintf(xorriso->info_text, "-pacifier: unknown behavior code '%s'", style); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + return(1); +} + + +/* Option -padding */ +int Xorriso_option_padding(struct XorrisO *xorriso, char *size, int flag) +{ + double num; + + num= Scanf_io_size(size, 0); + if(num < 0 || num > 1024.0 * 1024.0 * 1024.0) { + sprintf(xorriso->info_text, "-padding: wrong size %.f (allowed: %.f - %.f)", + num, 0.0, 1024.0 * 1024.0 * 1024.0); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + xorriso->padding= num; + if(xorriso->padding/2048 != num/2048.0) + xorriso->padding++; + return(1); +} + + +/* Option -page */ +int Xorriso_option_page(struct XorrisO *xorriso, int len, int width, int flag) +{ + if(len<0 || width<=0) { + sprintf(xorriso->info_text, + "Improper numeric value of arguments of -page: %d %d", + len, width); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + xorriso->result_page_length= len; + xorriso->result_page_width= width; + return(1); +} + + +/* Option -paste_in */ +int Xorriso_option_paste_in(struct XorrisO *xorriso, char *iso_rr_path, + char *disk_path, char *start, char *count, int flag) +{ + int ret; + double num; + off_t startbyte, bytecount; + + num= Scanf_io_size(start, 0); + if(num<0 || num > 1.0e18) { /* 10^18 = 10^3 ^ 6 < 2^10 ^ 6 = 2^60 */ + sprintf(xorriso->info_text, + "-paste_in: startbyte address negative or much too large (%s)", start); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + startbyte= num; + num= Scanf_io_size(count, 0); + if(num<=0 || num > 1.0e18) { + sprintf(xorriso->info_text, + "-paste_in : bytecount zero, negative or much too large (%s)", count); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + bytecount= num; + sprintf(xorriso->info_text, "-paste_in from %s to %s, byte %.f to %.f", + disk_path, iso_rr_path, + (double) startbyte, (double) (startbyte+bytecount)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + + ret= Xorriso_paste_in(xorriso, disk_path, startbyte, bytecount, + iso_rr_path, 0); + return(ret); +} + + +/* Option -path_list , -quoted_path_list */ +/* @param flag bit0= -quoted_path_list */ +int Xorriso_option_path_list(struct XorrisO *xorriso, char *adr, int flag) +{ + int ret,linecount= 0, insertcount= 0, null= 0, was_failure= 0, fret= 0; + int was_ferror= 0, argc= 0, i; + FILE *fp= NULL; + char sfe[5*SfileadrL], **argv= NULL; + + Xorriso_pacifier_reset(xorriso, 0); + if(adr[0]==0) { + sprintf(xorriso->info_text,"Empty file name given with %s", + flag & 1 ? "-quoted_path_list" : "-path_list"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + return(0); + } + ret= Xorriso_afile_fopen(xorriso, adr, "rb", &fp, 0); + if(ret <= 0) + return(0); + while(1) { + ret= Xorriso_read_lines(xorriso, fp, &linecount, &argc, &argv, + 4 | (flag & 1) ); + if(ret <= 0) + goto ex; + if(ret == 2) + break; + for(i= 0; i < argc; i++) { + if(argv[i][0] == 0) + continue; + null= 0; + ret= Xorriso_option_add(xorriso, 1, argv + i, &null, 1|2); + if(ret<=0 || xorriso->request_to_abort) + goto problem_handler; + insertcount++; + } + + continue; /* regular bottom of loop */ +problem_handler:; + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + goto ex; + } + ret= 1; +ex:; + if(flag & 1) + Xorriso_read_lines(xorriso, fp, &linecount, &argc, &argv, 2); + + if(fp != NULL && fp != stdin) + fclose(fp); + Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count, + xorriso->pacifier_total, "", 1); + if(ret<=0) { + sprintf(xorriso->info_text, "Aborted reading of file %s in line number %d", + Text_shellsafe(adr, sfe, 0), linecount); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, + (fret==-2 ? "NOTE" : "FAILURE"), 0); + } else + ret= !was_ferror; + sprintf(xorriso->info_text, "Added %d items from file %s\n", + insertcount, Text_shellsafe(adr, sfe, 0)); + Xorriso_info(xorriso,0); + if(ret<=0) + return(ret); + return(!was_failure); +} + + +/* Option -pathspecs */ +int Xorriso_option_pathspecs(struct XorrisO *xorriso, char *mode, int flag) +{ + if(strcmp(mode, "off")==0) + xorriso->allow_graft_points= 0; + else if(strcmp(mode, "on")==0) + xorriso->allow_graft_points= 1; + else { + sprintf(xorriso->info_text, "-pathspecs: unknown mode '%s'", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(1); +} + + +/* Option -pkt_output */ +int Xorriso_option_pkt_output(struct XorrisO *xorriso, char *mode, int flag) +{ + if(strcmp(mode,"off")==0) + xorriso->packet_output= 0; + else + xorriso->packet_output= 1; + return(1); +} + + +/* Option -print */ +int Xorriso_option_print(struct XorrisO *xorriso, char *text, int flag) +{ + sprintf(xorriso->result_line,"%s\n",text); + Xorriso_result(xorriso,1); + return(1); +} + + +/* Option -print_size + @param flag bit0= report in mkisofs compatible form on real stdout +*/ +int Xorriso_option_print_size(struct XorrisO *xorriso, int flag) +{ + int ret, fd; + + if(!xorriso->volset_change_pending) { + sprintf(xorriso->info_text,"-print_size: No image modifications pending"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + sprintf(xorriso->result_line,"Image size : 0s\n"); + Xorriso_result(xorriso,0); + return(2); + } + ret= Xorriso_write_session(xorriso, 1); + if(ret<=0) { + sprintf(xorriso->info_text,"-print_size: Failed to set up virtual -commit"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + if(flag&1) { + sprintf(xorriso->result_line,"%d\n", ret); + fd= xorriso->dev_fd_1; + if(fd<0) + fd= 1; + write(fd, xorriso->result_line, strlen(xorriso->result_line)); + fsync(fd); + } else { + sprintf(xorriso->result_line,"Image size : %ds\n", ret); + Xorriso_result(xorriso,0); + } + return(1); +} + + +/* Option -prog */ +int Xorriso_option_prog(struct XorrisO *xorriso, char *name, int flag) +{ + if(strlen(name)>=sizeof(xorriso->progname)) { + sprintf(xorriso->info_text, + "Name too long with option -prog (%d > %d)", + (int) strlen(name), (int) sizeof(xorriso->progname)-1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + if(Sfile_str(xorriso->progname,name,0)<=0) + return(-1); + return(1); +} + + +/* Option -prog_help */ +int Xorriso_option_prog_help(struct XorrisO *xorriso, char *name, int flag) +{ + int ret; + + ret= Xorriso_option_prog(xorriso, name, 0); + if(ret<=0) + return(ret); + ret= Xorriso_option_help(xorriso, 0); + return(ret); +} + + +/* Option -prompt */ +int Xorriso_option_prompt(struct XorrisO *xorriso, char *text, int flag) +{ + int ret; + char line[80]; + + strncpy(xorriso->result_line,text,sizeof(xorriso->result_line)-1); + xorriso->result_line[sizeof(xorriso->result_line)-1]= 0; + Xorriso_result(xorriso,0); + ret= Xorriso_dialog_input(xorriso, line, sizeof(line),1); + return(ret); +} + + +/* Option -publisher */ +int Xorriso_option_publisher(struct XorrisO *xorriso, char *name, int flag) +{ + if(strlen(name)>=sizeof(xorriso->publisher)) { + sprintf(xorriso->info_text, + "Name too long with option -publisher (%d > %d)", + (int) strlen(name), (int) sizeof(xorriso->publisher)-1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + if(Sfile_str(xorriso->publisher,name,0)<=0) + return(-1); + return(1); +} + + +/* Option -pwd alias -pwdi */ +int Xorriso_option_pwdi(struct XorrisO *xorriso, int flag) +{ + char sfe[5 * SfileadrL]; + + sprintf(xorriso->info_text,"current working directory in ISO image:\n"); + Xorriso_info(xorriso,0); + sprintf(xorriso->result_line,"%s/\n", Text_shellsafe(xorriso->wdi, sfe, 0)); + Xorriso_result(xorriso,0); + return(1); +} + + +/* Option -pwdx */ +int Xorriso_option_pwdx(struct XorrisO *xorriso, int flag) +{ + sprintf(xorriso->info_text,"current working directory on hard disk:\n"); + Xorriso_info(xorriso,0); + sprintf(xorriso->result_line,"%s/\n",xorriso->wdx); + Xorriso_result(xorriso,0); + return(1); +} + + +/* Option -reassure "on"|"tree"|"off" */ +int Xorriso_option_reassure(struct XorrisO *xorriso, char *mode, int flag) +{ + if(strcmp(mode, "off")==0) + xorriso->do_reassure= 0; + else if(strcmp(mode, "on")==0) + xorriso->do_reassure= 1; + else if(strcmp(mode, "tree")==0) + xorriso->do_reassure= 2; + else { + sprintf(xorriso->info_text, "-reassure: unknown mode '%s'", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + return(1); +} + + +/* Option -unregister_filter */ +int Xorriso_option_unregister_filter(struct XorrisO *xorriso, char *name, + int flag) +{ + int ret; + + ret= Xorriso_external_filter(xorriso, name, "", "", 0, NULL, 1); + return(ret); +} + + +/* Option -report_about */ +int Xorriso_option_report_about(struct XorrisO *xorriso, char *severity, + int flag) +{ + int ret, sev; + char sfe[5*SfileadrL]; + + ret= Xorriso__text_to_sev(severity, &sev, 0); + if(ret<=0) { + sprintf(xorriso->info_text, + "-report_about: Not a known severity name : %s", + Text_shellsafe(severity, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + return(ret); + } + if(Sfile_str(xorriso->report_about_text,severity,0)<=0) + return(-1); + xorriso->report_about_severity= sev; + return(1); +} + + +/* Option -return_with */ +int Xorriso_option_return_with(struct XorrisO *xorriso, char *severity, + int exit_value, int flag) +{ + int ret, sev; + char sfe[5*SfileadrL]; + + ret= Xorriso__text_to_sev(severity, &sev, 0); + if(ret<=0) { + sprintf(xorriso->info_text, + "-return_with: Not a known severity name : %s", + Text_shellsafe(severity, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(ret); + } + if(exit_value && (exit_value < 32 || exit_value > 63)) { + sprintf(xorriso->info_text, + "-return_with: Not an allowed exit_value. Use 0, or 32 to 63."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if(Sfile_str(xorriso->return_with_text,severity,0)<=0) + return(-1); + xorriso->return_with_severity= sev; + xorriso->return_with_value= exit_value; + return(1); +} + + +/* Options -rm alias -rmi , -rm_r alias -rm_ri , -rmdir alias -rmdiri */ +/* @param flag bit0=recursive , bit1= remove empty directory: rmdir */ +int Xorriso_option_rmi(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag) +{ + int i, ret, end_idx, was_failure= 0, fret; + char path[SfileadrL], eff_path[SfileadrL], sfe[5*SfileadrL]; + int optc= 0; + char **optv= NULL; + + ret= Xorriso_opt_args(xorriso, "-rm*i", + argc, argv, *idx, &end_idx, &optc, &optv, 0); + if(ret<=0) + goto ex; + for(i= 0; i<optc; i++) { + if(Sfile_str(path,optv[i],0)<=0) + {ret= -1; goto problem_handler;} + if(path[0]!='/') { + ret= Sfile_prepend_path(xorriso->wdi, path, 0); + if(ret<=0) + goto problem_handler; + } + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 1); + if(ret<0) + goto problem_handler; + if(ret==0) { + sprintf(xorriso->info_text, + "Cannot find path %s in loaded ISO image for removal", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + goto problem_handler; + } + strcpy(path, eff_path); + + ret= Xorriso_rmi(xorriso, NULL, (off_t) 0, path, flag&(1|2)); + if(ret<=0 || xorriso->request_to_abort) + goto problem_handler; + if(ret<3) { + sprintf(xorriso->info_text, "Removed from ISO image: %s '%s'\n", + ((flag&2) ? "directory" : (ret>1 ? "subtree" : "file")), path); + Xorriso_info(xorriso, 0); + } + + continue; /* regular bottom of loop */ +problem_handler:; + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + goto ex; + } + ret= 1; +ex:; + (*idx)= end_idx; + Xorriso_opt_args(xorriso, "-rm*i", + argc, argv, *idx, &end_idx, &optc, &optv, 256); + if(ret<=0) + return(ret); + return(!was_failure); +} + + +/* Option -rollback */ +/* @param flag bit0= do not -reassure + @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_rollback(struct XorrisO *xorriso, int flag) +{ + int ret; + char indev[SfileadrL], *which_will; + + if(xorriso->volset_change_pending) + which_will= "revoke the pending image changes"; + else + which_will= "reload the image"; + if(!(flag&1)) { + ret= Xorriso_reassure(xorriso, "-rollback", which_will, 0); + if(ret<=0) + return(2); + } + + if(Sfile_str(indev, xorriso->indev, 0)<=0) + return(-1); + ret= Xorriso_give_up_drive(xorriso, 1|8); + if(ret<=0) + return(ret); + xorriso->image_start_mode&= ~(1<<31); /* reactivate eventual -load address */ + ret= Xorriso_option_dev(xorriso, indev, 1|4); + return(ret); +} + + +/* Option -rom_toc_scan */ +int Xorriso_option_rom_toc_scan(struct XorrisO *xorriso, char *mode, int flag) +{ + int l; + char *cpt, *npt; + + xorriso->toc_emulation_flag= 0; + npt= cpt= mode; + for(cpt= mode; npt != NULL; cpt= npt + 1) { + npt= strchr(cpt,':'); + if(npt==NULL) + l= strlen(cpt); + else + l= npt-cpt; + if(l==0) + goto unknown_mode; + if(strncmp(cpt, "off", l) == 0) + xorriso->toc_emulation_flag&= ~1; + else if(strncmp(cpt, "on", l) == 0) + xorriso->toc_emulation_flag|= 1; + else if(strncmp(cpt, "emul_off", l) == 0) + xorriso->toc_emulation_flag|= 2; + else if(strncmp(cpt, "emul_on", l) == 0) + xorriso->toc_emulation_flag&= ~2; + else { +unknown_mode:; + sprintf(xorriso->info_text, "-rom_toc_scan: unknown mode in '%s'", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + } + return(1); +} + + +/* Option -session_log */ +int Xorriso_option_session_log(struct XorrisO *xorriso, char *path, int flag) +{ + if(Sfile_str(xorriso->session_logfile, path, 0)<=0) + return(-1); + return(1); +} + + +/* Option -setfacl_list alias -setfacl_listi */ +int Xorriso_option_setfacl_listi(struct XorrisO *xorriso, char *path, int flag) +{ + int ret, eaten; + size_t buf_size= 0, buf_add= 64 * 1024, l, linecount= 0; + char line[SfileadrL * 4], *buf= NULL, *wpt, *new_buf, limit_text[80]; + char file_path[SfileadrL], uid[161], gid[161]; + FILE *fp= NULL; + + Xorriso_pacifier_reset(xorriso, 0); + if(path[0]==0) { + sprintf(xorriso->info_text, "Empty file name given with -setfacl_list"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + ret= Xorriso_afile_fopen(xorriso, path, "rb", &fp, 0); + if(ret <= 0) + return(0); + + buf_size= buf_add; + buf= calloc(buf_size, 1); + if(buf == NULL) + goto out_of_mem; + wpt= buf; + *wpt= 0; + uid[0]= gid[0]= 0; + + while(1) { + if(Sfile_fgets_n(line, sizeof(line), fp, 0) == NULL) + break; + linecount++; + if(strncmp(line, "# file: ", 8) ==0) { + if(wpt != buf && file_path[0]) { + /* Commit previous list */ + ret= Xorriso_perform_acl_from_list(xorriso, file_path, + uid, gid, buf, 0); + if(ret<=0) + goto ex; + wpt= buf; + *wpt= 0; + file_path[0]= uid[0]= gid[0]= 0; + } + /* Unescape line and register as file path */ + Sfile_bsl_interpreter(line + 8, strlen(line + 8), &eaten, 0); + if(strlen(line + 8) >= SfileadrL) { + sprintf(xorriso->info_text, "-setfacl_list: Oversized file path"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + strcpy(file_path, line + 8); + continue; + } else if(strncmp(line, "# owner: ", 9) == 0) { + if(strlen(line + 9) > 160) { + sprintf(xorriso->info_text, "-setfacl_list: Oversized owner id"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + strcpy(uid, line + 9); + continue; + } else if(strncmp(line, "# group: ", 9) == 0) { + if(strlen(line + 9) > 160) { + sprintf(xorriso->info_text, "-setfacl_list: Oversized group id"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + strcpy(gid, line + 9); + continue; + } else if(line[0] == '#' || line[0] == 0) { + continue; + } else if(strcmp(line, "@") == 0) { + Xorriso_msgs_submit(xorriso, 0, + "-setfacl_list input ended by '@'", 0, "NOTE", 0); + break; + } else if(strcmp(line, "@@@") == 0) { + Xorriso_msgs_submit(xorriso, 0, + "-setfacl_list aborted by input line '@@@'", 0, "WARNING", 0); + ret= 0; goto ex; + } + + /* Register ACL entry */ + l= strlen(line); + if(wpt + l + 2 - buf > buf_size) { + if(buf_size + buf_add > xorriso->temp_mem_limit) { + Sfile_scale((double) xorriso->temp_mem_limit, limit_text,5,1e4,1); + sprintf(xorriso->info_text, + "-setfacl_list: List entry for a single file exceeds -temp_mem_limit %s", + limit_text); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + buf_size+= buf_add; + new_buf= realloc(buf, buf_size); + if(new_buf == NULL) + goto out_of_mem; + buf= new_buf; + } + memcpy(wpt, line, l); + *(wpt + l)= '\n'; + wpt+= l + 1; + *wpt= 0; + } + if(wpt != buf && file_path[0]) { + /* Commit last list */ + ret= Xorriso_perform_acl_from_list(xorriso, file_path, uid, gid, buf, 0); + if(ret<=0) + goto ex; + } else { + sprintf(xorriso->info_text, "-setfacl_list: Unexpected end of file "); + Text_shellsafe(path, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + } + ret= 1; +ex:; + if(buf != NULL) + free(buf); + if(fp != NULL && fp != stdin) + fclose(fp); + if(ret <= 0) { + sprintf(xorriso->info_text, "-setfacl_list "); + Text_shellsafe(path, xorriso->info_text, 1); + sprintf(xorriso->info_text + strlen(xorriso->info_text), + " aborted in line %.f\n", (double) linecount); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + } + return(ret); +out_of_mem:; + Xorriso_no_malloc_memory(xorriso, &buf, 0); + ret= -1; + goto ex; +} + + +/* Options -setfacl alias -setfacli, -setfacl_r alias -setfacl_ri */ +/* @param flag bit0=recursive -setfacl_r +*/ +int Xorriso_option_setfacli(struct XorrisO *xorriso, char *acl_text, + int argc, char **argv, int *idx, int flag) +{ + int i, ret, was_failure= 0, end_idx, fret; + int optc= 0; + char **optv= NULL, *access_acl_text= NULL, *default_acl_text= NULL; + struct FindjoB *job= NULL; + struct stat dir_stbuf; + + ret= Xorriso_opt_args(xorriso, "-setfacl", argc, argv, *idx, &end_idx, &optc, + &optv, 0); + if(ret <= 0) + goto ex; + + ret= Xorriso_normalize_acl_text(xorriso, acl_text, + &access_acl_text, &default_acl_text, 0); + if(access_acl_text != NULL && default_acl_text != NULL) { + sprintf(xorriso->info_text, "Access-ACL :\n%s", access_acl_text); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + sprintf(xorriso->info_text, "Default-ACL :\n%s", default_acl_text); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + } else if(access_acl_text == NULL && default_acl_text == NULL) { + sprintf(xorriso->info_text, "Will delete Access-ACL and Default-ACL"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + } + if(ret <= 0) + goto ex; + + for(i= 0; i<optc; i++) { + if(flag&1) { + ret= Findjob_new(&job, optv[i], 0); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-setfacl_r", 0); + {ret= -1; goto ex;} + } + Findjob_set_action_text_2(job, 25, access_acl_text, default_acl_text, 0); + ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0, + NULL, optv[i], &dir_stbuf, 0, 0); + Findjob_destroy(&job, 0); + } else { + ret= 1; + if(access_acl_text == NULL || access_acl_text[0] || + default_acl_text == NULL || default_acl_text[0]) + ret= Xorriso_setfacl(xorriso, NULL, optv[i], + access_acl_text, default_acl_text, 0); + } + if(ret>0 && !xorriso->request_to_abort) + continue; /* regular bottom of loop */ + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + ret= 0; goto ex; + } + ret= 1; +ex:; + (*idx)= end_idx; + Xorriso_opt_args(xorriso, "-setfacl", argc, argv, *idx, &end_idx, + &optc, &optv, 256); + Findjob_destroy(&job, 0); + if(access_acl_text != NULL) + free(access_acl_text); + if(default_acl_text != NULL) + free(default_acl_text); + if(ret<=0) + return(ret); + return(!was_failure); +} + + +/* Options -setfattr alias -setfattri, -setfattr_r alias -setfattr_ri */ +/* @param flag bit0=recursive -setfattr_r +*/ +int Xorriso_option_setfattri(struct XorrisO *xorriso, char *name, char *value, + int argc, char **argv, int *idx, int flag) +{ + int i, ret, was_failure= 0, end_idx, fret; + int optc= 0; + char **optv= NULL; + struct FindjoB *job= NULL; + struct stat dir_stbuf; + + ret= Xorriso_opt_args(xorriso, "-setfattr", argc, argv, *idx, &end_idx, &optc, + &optv, 0); + if(ret <= 0) + goto ex; + + /* check input */ + ret= Xorriso_path_setfattr(xorriso, NULL, "", name, strlen(value), value, 1); + if(ret <= 0) + goto ex; + + for(i= 0; i<optc; i++) { + if(flag&1) { + ret= Findjob_new(&job, optv[i], 0); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "-setfattr_r", 0); + {ret= -1; goto ex;} + } + Findjob_set_action_text_2(job, 27, name, value, 0); + ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0, + NULL, optv[i], &dir_stbuf, 0, 0); + Findjob_destroy(&job, 0); + } else { + ret= 1; + ret= Xorriso_path_setfattr(xorriso, NULL, optv[i], + name, strlen(value), value, 0); + } + if(ret>0 && !xorriso->request_to_abort) + continue; /* regular bottom of loop */ + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + ret= 0; goto ex; + } + ret= 1; +ex:; + (*idx)= end_idx; + Xorriso_opt_args(xorriso, "-setfattr", argc, argv, *idx, &end_idx, + &optc, &optv, 256); + Findjob_destroy(&job, 0); + if(ret<=0) + return(ret); + return(!was_failure); +} + + +/* Option -setfattr_list alias -setfattr_listi */ +int Xorriso_option_setfattr_listi(struct XorrisO *xorriso, char *path, + int flag) +{ + int ret, eaten; + size_t linecount= 0, mem_used= 0, num_attr= 0, v_len; + char line[SfileadrL * 4], limit_text[80], *ept, *valuept; + char file_path[SfileadrL]; + FILE *fp= NULL; + struct Xorriso_lsT *lst_curr= NULL, *lst_start= NULL; + + Xorriso_pacifier_reset(xorriso, 0); + if(path[0]==0) { + sprintf(xorriso->info_text, "Empty file name given with -setfattr_list"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + ret= Xorriso_afile_fopen(xorriso, path, "rb", &fp, 0); + if(ret <= 0) + return(0); + + while(1) { + if(Sfile_fgets_n(line, sizeof(line), fp, 0) == NULL) + break; + linecount++; + if(strncmp(line, "# file: ", 8) ==0) { + if(num_attr > 0 && file_path[0]) { + /* Commit previous list */ + ret= Xorriso_perform_attr_from_list(xorriso, file_path, lst_start, 0); + if(ret<=0) + goto ex; + num_attr= 0; + file_path[0]= 0; + Xorriso_lst_destroy_all(&lst_start, 0); + lst_curr= NULL; + } + /* Unescape line and register as file path */ + Sfile_bsl_interpreter(line + 8, strlen(line + 8), &eaten, 0); + if(strlen(line + 8) >= SfileadrL) { + sprintf(xorriso->info_text, "-setfattr_list: Oversized file path"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + strcpy(file_path, line + 8); + continue; + } else if(line[0] == '#' || line[0] == 0) { + continue; + } else if(strcmp(line, "@") == 0) { + Xorriso_msgs_submit(xorriso, 0, + "-setfattr_list input ended by '@'", 0, "NOTE", 0); + break; + } else if(strcmp(line, "@@@") == 0) { + Xorriso_msgs_submit(xorriso, 0, + "-setfattr_list aborted by input line '@@@'", 0, "WARNING", 0); + ret= 1; goto ex; + } + mem_used+= strlen(line) + 1; + if(mem_used > xorriso->temp_mem_limit) { + Sfile_scale((double) xorriso->temp_mem_limit, limit_text,5,1e4,1); + sprintf(xorriso->info_text, + "-setfattr_list: List entry for a single file exceeds -temp_mem_limit %s", + limit_text); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + + /* Register attr pair */ + + ept= strchr(line, '='); + if(ept == NULL) { + sprintf(xorriso->info_text, "-setfattr_list: "); + Text_shellsafe(path, xorriso->info_text, 1); + sprintf(xorriso->info_text + strlen(xorriso->info_text), + " : Line %.f : No separator '=' found", + (double) linecount); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + continue; + } + valuept= ept + 1; + v_len= strlen(valuept); + for(ept= valuept + v_len - 1; ept > valuept; ept--) + if(isspace(*ept)) + *ept= 0; + else + break; + v_len= strlen(valuept); + if(v_len < 2 || *valuept != '"' || *(valuept + v_len -1) != '"') { + sprintf(xorriso->info_text, "-setfattr_list: "); + Text_shellsafe(path, xorriso->info_text, 1); + sprintf(xorriso->info_text + strlen(xorriso->info_text), + " : Line %.f : Value not enclosed in quotes", + (double) linecount); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + + continue; + } + + ret= Xorriso_lst_new(&lst_curr, line, lst_curr, 0); + if(ret <= 0) + goto out_of_mem; + if(lst_start == NULL) + lst_start= lst_curr; + num_attr++; + } + + if(file_path[0]) { + /* Commit last list */ + ret= Xorriso_perform_attr_from_list(xorriso, file_path, lst_start, 0); + if(ret<=0) + goto ex; + } else { + sprintf(xorriso->info_text, "-setfattr_list: Unexpected end of file "); + Text_shellsafe(path, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + } + ret= 1; +ex:; + if(fp != NULL && fp != stdin) + fclose(fp); + Xorriso_lst_destroy_all(&lst_start, 0); + if(ret <= 0) { + sprintf(xorriso->info_text, "-setfattr_list "); + Text_shellsafe(path, xorriso->info_text, 1); + sprintf(xorriso->info_text + strlen(xorriso->info_text), + " aborted in line %.f\n", (double) linecount); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + } + return(ret); +out_of_mem:; + Xorriso_no_malloc_memory(xorriso, NULL, 0); + ret= -1; + goto ex; +} + + +/* Options -set_filter , -set_filter_r , -show_stream , -show_stream_r */ +/* @param flag bit0=recursive -set_filter_r + bit1= do not reset pacifier, no final pacifier message + bit2= -show_stream rather than -set_filter +*/ +int Xorriso_option_set_filter(struct XorrisO *xorriso, char *name, + int argc, char **argv, int *idx, int flag) +{ + int i, ret, was_failure= 0, end_idx, fret; + int optc= 0; + char **optv= NULL; + struct FindjoB *job= NULL; + struct stat dir_stbuf; + char *cmd= "-set_filter"; + + switch(flag & 5) { + case 0: cmd= "-set_filter"; + break; case 1: cmd= "-set_filter_r"; + break; case 4: cmd= "-show_stream"; + break; case 5: cmd= "-show_stream_r"; + } + + ret= Xorriso_opt_args(xorriso, cmd, + argc, argv, *idx, &end_idx, &optc, &optv, 0); + if(ret <= 0) + goto ex; + if(!(flag&2)) + Xorriso_pacifier_reset(xorriso, 0); + + for(i= 0; i<optc; i++) { + if(flag&1) { + ret= Findjob_new(&job, optv[i], 0); + if(ret<=0) { + Xorriso_no_findjob(xorriso, cmd, 0); + {ret= -1; goto ex;} + } + Findjob_set_action_target(job, ((flag & 4) ? 29 : 28), name, 0); + Findjob_set_file_type(job, 'f', 0); + ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0, + NULL, optv[i], &dir_stbuf, 0, 0); + Findjob_destroy(&job, 0); + } else { + ret= 1; + if(flag & 4) + ret= Xorriso_show_stream(xorriso, NULL, optv[i], 0); + else + ret= Xorriso_set_filter(xorriso, NULL, optv[i], name, 0); + } + if(ret>0 && !xorriso->request_to_abort) + continue; /* regular bottom of loop */ + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret>=0) + continue; + ret= 0; goto ex; + } + if(!(flag&2)) + Xorriso_pacifier_callback(xorriso, "file filters processed", + xorriso->pacifier_count, 0, "", 1); + ret= 1; +ex:; + (*idx)= end_idx; + Xorriso_opt_args(xorriso, cmd, argc, argv, *idx, &end_idx, + &optc, &optv, 256); + Findjob_destroy(&job, 0); + if(ret<=0) + return(ret); + return(!was_failure); +} + + +/* Option -speed */ +int Xorriso_option_speed(struct XorrisO *xorriso, char *speed, int flag) +{ + int is_cd= 1, unit_found= 0, ret, profile_number; + double num; + char *cpt, profile_name[80]; + + if(speed[0]==0 || strcmp(speed, "any")==0) { + xorriso->speed= 0; /* full speed */ + return(1); + } + + sscanf(speed,"%lf",&num); + for(cpt= speed+strlen(speed)-1; cpt>=speed; cpt--) + if(isdigit(*cpt) || *cpt=='.') + break; + cpt++; + + if(*cpt=='k' || *cpt=='K') { + /* is merchand kilobyte, stays merchand kilobyte */ + unit_found= 1; + } else if(*cpt=='m' || *cpt=='M') { + num*= 1000; + unit_found= 1; + } else if(*cpt=='x' || *cpt=='X') + cpt++; + + if (unit_found) { + ; + } else if(*cpt=='c' || *cpt=='C') { +cd_speed:; + num*= 176.4; + } else if(*cpt=='d' || *cpt=='D') { +dvd_speed:; + num*= 1385; + } else if(*cpt=='b' || *cpt=='B') { +bd_speed:; + num*= 4495.625; + } else { + ret= Xorriso_get_profile(xorriso, &profile_number, profile_name, 2); + is_cd= (ret==2); + if(is_cd) + goto cd_speed; + else if (ret == 3) + goto bd_speed; + else + goto dvd_speed; + } + + if(num> 2.0e9) { + sprintf(xorriso->info_text, + "-speed: Value too large or not recognizable: '%s'", speed); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + xorriso->speed= num; + if(xorriso->speed<num) + xorriso->speed++; + return(1); +} + + +/* Option -split_size */ +int Xorriso_option_split_size(struct XorrisO *xorriso, char *size, int flag) +{ + double num; + + num= Scanf_io_size(size, 0); + if(num > xorriso->file_size_limit && xorriso->file_size_limit > 0) { + sprintf(xorriso->info_text, "-split_size: too large %.f (allowed: %.f)", + num, (double) xorriso->file_size_limit); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } else if(num < 0) + num= 0.0; + xorriso->split_size= num; + return(1); +} + + +/* Option -status */ +int Xorriso_option_status(struct XorrisO *xorriso, char *mode, int flag) +{ + if(strcmp(mode,"short")==0) + Xorriso_status(xorriso,NULL,NULL,1); + else if(strcmp(mode,"long")==0) + Xorriso_status(xorriso,NULL,NULL,0); + else if(strcmp(mode,"long_history")==0) + Xorriso_status(xorriso,NULL,NULL,8); + else if(mode[0]=='-') + Xorriso_status(xorriso,mode,NULL,8); + else + Xorriso_status(xorriso,NULL,NULL,1); + return(1); +} + + +/* Option -status_history_max */ +int Xorriso_option_status_history_max(struct XorrisO *xorriso, int num, + int flag) +{ + if(num>=0 && num<1000000) + xorriso->status_history_max= num; + return(1); +} + + +/* Option -stream_recording */ +int Xorriso_option_stream_recording(struct XorrisO *xorriso, char *mode, + int flag) +{ + double num; + + if(strcmp(mode,"on")==0 || mode[0]==0) + xorriso->do_stream_recording= 32; + else if(strcmp(mode,"full")==0) + xorriso->do_stream_recording= 1; + else if(strcmp(mode,"data")==0) + xorriso->do_stream_recording= 2; + else if(mode[0] >= '0' && mode[0] <= '9') { + num= Scanf_io_size(mode, 0); + num/= 2048.0; + if(num >= 16 && num <= 0x7FFFFFFF) + xorriso->do_stream_recording= num; + else + xorriso->do_stream_recording= 0; + } else + xorriso->do_stream_recording= 0; + return(1); +} + + +/* Option -tell_media_space */ +int Xorriso_option_tell_media_space(struct XorrisO *xorriso, int flag) +{ + int ret, free_space= 0, media_space= 0; + + ret= Xorriso_tell_media_space(xorriso, &media_space, &free_space, 0); + if(ret<=0) { + sprintf(xorriso->info_text, "Cannot -tell_media_space"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + if(free_space<0) { + sprintf(xorriso->info_text, + "Pending image size larger than free space on media"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + } + sprintf(xorriso->result_line, "Media space : %ds\n", media_space); + Xorriso_result(xorriso, 0); + sprintf(xorriso->result_line, "After commit : %ds\n", free_space); + Xorriso_result(xorriso, 0); + return(1); +} + + +/* Option -temp_mem_limit */ +int Xorriso_option_temp_mem_limit(struct XorrisO *xorriso, char *size, + int flag) +{ + double num; + + num= Scanf_io_size(size, 0); + if(num < 64.0 * 1024.0 || num > 1024.0 * 1024.0 * 1024.0) { + sprintf(xorriso->info_text, + "-temp_mem_limit: wrong size %.f (allowed: %.f - %.f)", + num, 64.0 * 1024.0, 1024.0 * 1024.0 * 1024.0); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + xorriso->temp_mem_limit= num; + return(1); +} + + +/* Option -toc */ +int Xorriso_option_toc(struct XorrisO *xorriso, int flag) +{ + int ret, in_ret= 1000; + + if(strcmp(xorriso->indev,xorriso->outdev)==0) + ret= Xorriso_toc(xorriso, 0); + else { + if(xorriso->indev[0]!=0) + in_ret= Xorriso_toc(xorriso, 0); + if(xorriso->indev[0]!=0 && xorriso->outdev[0]!=0) { + strcpy(xorriso->result_line, "-------------: ---------------------------------------------------------------\n"); + Xorriso_result(xorriso,0); + } + ret= 1; + if(xorriso->outdev[0]!=0) + ret= Xorriso_toc(xorriso, 2); + if(in_ret<ret) + ret= in_ret; + } + return(ret); +} + + +/* Option -uid */ +int Xorriso_option_uid(struct XorrisO *xorriso, char *uid, int flag) +{ + int ret; + + xorriso->do_global_uid= 0; + if(uid[0]==0 || strcmp(uid,"-")==0) + return(1); + ret= Xorriso_convert_uidstring(xorriso, uid, &(xorriso->global_uid), 0); + if(ret>0) + xorriso->do_global_uid= 1; + return(ret); +} + + +/* Options -update and -update_r + @param flag bit0= issue start and summary message + bit1= do not reset pacifier, no final pacifier message + bit2= do not issue pacifier messages at all + bit3= recursive: -update_r + bit4= do not establish and dispose xorriso->di_array +*/ +int Xorriso_option_update(struct XorrisO *xorriso, char *disk_path, + char *iso_path, int flag) +{ + int ret, mem_pci, zero= 0, result, uret, follow_links, do_register= 1; + int not_in_iso= 0, not_on_disk= 0, made_di_array= 0; + double mem_lut= 0.0, start_time; + char *ipth, *argv[6], sfe[5*SfileadrL]; + char eff_origin[SfileadrL], eff_dest[SfileadrL]; + struct stat stbuf; + + start_time= Sfile_microtime(0); + + ipth= iso_path; + if(ipth[0]==0) + ipth= disk_path; + if(disk_path[0]==0) { + sprintf(xorriso->info_text, "-update: Empty disk_path given"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 1); + return(0); + } + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, disk_path, eff_origin, + 2|4|8); + if(ret<=0) + return(ret); + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, ipth, eff_dest, 2|8); + if(ret<=0) + return(ret); + + if(!(flag&2)) { + Xorriso_pacifier_reset(xorriso, 0); + mem_lut= xorriso->last_update_time; + } + mem_pci= xorriso->pacifier_interval; + xorriso->pacifier_interval= 5.0; + + if(flag&1) { + sprintf(xorriso->info_text, "Updating %s to", + Text_shellsafe(eff_origin, sfe, 0)); + sprintf(xorriso->info_text+strlen(xorriso->info_text), " %s\n", + Text_shellsafe(eff_dest, sfe, 0)); + Xorriso_info(xorriso,0); + } + if(xorriso->disk_excl_mode&8) + ret= Xorriso_path_is_excluded(xorriso, eff_origin, 1); + else + ret= 0; + if(ret!=0) + goto report_outcome; + + if(!(xorriso->ino_behavior & 2)) { + if(!(xorriso->di_array != NULL || (flag & 16))) { + /* Create all-image node array sorted by isofs.di */ + made_di_array= 1; + ret= Xorriso_make_di_array(xorriso, 0); + if(ret <= 0) + goto ex; + } + if(xorriso->di_array != NULL) { + if(!(flag & 8)) { + /* If directory with -update : do not register di_*_paths */ + ret= lstat(eff_origin, &stbuf); + if(ret != -1) + if(S_ISDIR(stbuf.st_mode)) + do_register= 0; + } + if(do_register) { + ret= Xorriso_lst_new(&(xorriso->di_disk_paths), eff_origin, + xorriso->di_disk_paths, 1); + if(ret <= 0) + goto ex; + ret= Xorriso_lst_new(&(xorriso->di_iso_paths), eff_dest, + xorriso->di_iso_paths, 1); + if(ret <= 0) + goto ex; + } + } + } + + if(flag&8) { + xorriso->find_compare_result= 1; + ret= Xorriso_iso_lstat(xorriso, eff_dest, &stbuf, 0); + if(ret >= 0) { + argv[0]= eff_dest; + argv[1]= "-exec"; + argv[2]= "update"; + argv[3]= eff_origin; + zero= 0; + ret= Xorriso_option_find(xorriso, 4, argv, &zero, + 2 | (8 * !((xorriso->do_aaip & 96) == 96))); /* -findi */ + } else if(ret==-2) { /* severe error (e.g. lack of image) */ + ret= -1; + goto report_outcome; + } else { + not_in_iso= 1; + ret= 1; + } + if(ret>0) { + ret= lstat(eff_origin, &stbuf); + if(ret != -1) { + argv[0]= eff_origin; + argv[1]= "-exec"; + argv[2]= "add_missing"; + argv[3]= eff_dest; + zero= 0; + ret= Xorriso_option_find(xorriso, 4, argv, &zero, 1|2); /* -findx */ + if(ret>0 && !xorriso->do_follow_mount) { + argv[0]= eff_origin; + argv[1]= "-type"; + argv[2]= "m"; + argv[3]= "-exec"; + argv[4]= "empty_iso_dir"; + argv[5]= eff_dest; + zero= 0; + ret= Xorriso_option_find(xorriso, 6, argv, &zero, 1|2); /* -findx */ + } + if(ret>0) + ret= xorriso->find_compare_result; + else + ret= -1; + } else { + ret= xorriso->find_compare_result; + not_on_disk= 1; + } + } else + ret= -1; + if(not_on_disk && not_in_iso) { + sprintf(xorriso->info_text, "Missing on disk and in ISO: disk_path %s", + Text_shellsafe(disk_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 1); + ret= -1; + } + } else { + /* compare ctime too, no filename reporting, eventually silent */ + follow_links= (xorriso->do_follow_links || xorriso->do_follow_param) <<28; + ret= Xorriso_compare_2_files(xorriso, eff_origin, eff_dest, "", &result, + 2 | follow_links | ((flag&4)<<27) | (3<<30)); + if(ret==0) { + uret= Xorriso_update_interpreter(xorriso, NULL, result, eff_origin, + eff_dest, 0); + if(uret<=0) + ret= -1; + if(uret==3) + ret= -1; + } + } + xorriso->pacifier_interval= mem_pci; + if(mem_lut!=xorriso->last_update_time && !(flag&2)) + Xorriso_pacifier_callback(xorriso, "content bytes read", + xorriso->pacifier_count, 0, "", 1); +report_outcome:; + if(ret>0) { + sprintf(xorriso->info_text, + "No file object needed update."); + } else if(ret==0) { + sprintf(xorriso->info_text, "Differences detected and updated."); + } else { + sprintf(xorriso->info_text, + "Not ok. Comparison or update failed due to error."); + } + sprintf(xorriso->info_text+strlen(xorriso->info_text), + " (runtime %.1f s)\n", Sfile_microtime(0)-start_time); + if(flag&1) + Xorriso_info(xorriso,0); + +ex:; + if(ret < 0) + return(ret); + return(1); +} + + +/* Option -use_readline */ +int Xorriso_option_use_readline(struct XorrisO *xorriso, char *mode, int flag) +{ + if(strcmp(mode,"off")==0) + xorriso->use_stdin= 1; + else + xorriso->use_stdin= 0; + return(1); +} + + +/* Option -version */ +int Xorriso_option_version(struct XorrisO *xorriso, int flag) +{ + sprintf(xorriso->result_line, + "xorriso %s : RockRidge filesystem manipulator and burn program\n", + Xorriso_program_versioN); + sprintf(xorriso->result_line+strlen(xorriso->result_line), +"Copyright (C) 2009, Thomas Schmitt <scdbackup@gmx.net>, libburnia project\n"); + Xorriso_result(xorriso, 0); + sprintf(xorriso->result_line, + "xorriso version : %s\n", Xorriso_program_versioN); + sprintf(xorriso->result_line+strlen(xorriso->result_line), + "Version timestamp : %s\n",Xorriso_timestamP); + sprintf(xorriso->result_line+strlen(xorriso->result_line), + "Build timestamp : %s\n",Xorriso_build_timestamP); + Xorriso_result(xorriso, 0); + Xorriso_report_lib_versions(xorriso, 0); + return(1); +} + + +/* Option -volid */ +int Xorriso_option_volid(struct XorrisO *xorriso, char *volid, int flag) +{ + int warn_shell= 0, warn_ecma= 0, i, ret; + static char shell_chars[]= { + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-+=:.,~@"}; + static char ecma_chars[]= {"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"}; + + for(i=0; volid[i]!=0; i++) { + if(strchr(shell_chars, volid[i])==NULL) + warn_shell= 1; + if(strchr(ecma_chars, volid[i])==NULL) + warn_ecma= 1; + } + if(i>32) { + sprintf(xorriso->info_text, "-volid: Text too long (%d > 32)", i); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if(warn_shell) { + sprintf(xorriso->info_text, + "-volid text problematic as automatic mount point name"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + } + if(xorriso->do_joliet && strlen(volid)>16) { + sprintf(xorriso->info_text, + "-volid text is too long for Joliet (%d > 16)",(int) strlen(volid)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + } + if(warn_ecma) { + sprintf(xorriso->info_text, + "-volid text does not comply to ISO 9660 / ECMA 119 rules"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + } + strcpy(xorriso->volid, volid); + ret= Xorriso_set_volid(xorriso, volid, 0); + if(ret<=0) + return(ret); + xorriso->volid_default= (strcmp(xorriso->volid, "ISOIMAGE")==0 || + xorriso->volid[0]==0); + return(1); +} + + +/* Option -xattr "on"|"off" */ +int Xorriso_option_xattr(struct XorrisO *xorriso, char *mode, int flag) +{ + int ret; + + if(strcmp(mode, "off")==0) + xorriso->do_aaip&= ~12; + else if(strcmp(mode, "on")==0) + xorriso->do_aaip|= (4 | 8); + else { + sprintf(xorriso->info_text, "-xattr: unknown mode '%s'", mode); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + ret= Xorriso_set_ignore_aclea(xorriso, 0); + if(ret <= 0) + return(ret); + return(1); +} + + +/* Option -zisofs */ +int Xorriso_option_zisofs(struct XorrisO *xorriso, char *mode, int flag) +{ + int was_level, was_blocksize, ret, l; + double num; + char *cpt, *npt, text[16]; + + was_level= xorriso->zlib_level; + was_blocksize= xorriso->zisofs_block_size; + npt= cpt= mode; + for(cpt= mode; npt!=NULL; cpt= npt+1) { + npt= strchr(cpt,':'); + if(npt==NULL) + l= strlen(cpt); + else + l= npt-cpt; + if(l==0) + goto unknown_mode; + + if(strncmp(cpt, "level=", 6) == 0) { + sscanf(cpt + 6, "%lf", &num); + if(num < 0 || num > 9) { + sprintf(xorriso->info_text, + "-zisofs: Wrong zlib compression level '%s' (allowed 0...9)", + cpt + 6); + goto sorry_ex; + } + xorriso->zlib_level= num; + + } else if(strncmp(cpt, "ziso_used=", 10) == 0 || + strncmp(cpt, "osiz_used=", 10) == 0) { + /* (ignored info from -status) */; + + } else if(strncmp(cpt, "block_size=", 11)==0) { + num= 0.0; + if(l > 11 && l < 27) { + strncpy(text, cpt + 11, l - 11); + text[l - 11]= 0; + num= Scanf_io_size(text, 0); + } + if (num != (1 << 15) && num != (1 << 16) && num != (1 << 17)) { + sprintf(xorriso->info_text, + "-zisofs: Unsupported block size (allowed 32k, 64k, 128k)"); + goto sorry_ex; + } + xorriso->zisofs_block_size= num; + + } else if(strncmp(cpt, "by_magic=", 8)==0) { + if(strncmp(cpt + 9, "on", l - 9) == 0) + xorriso->zisofs_by_magic= 1; + else + xorriso->zisofs_by_magic= 0; + + } else if(strncmp(cpt, "default", l)==0) { + xorriso->zlib_level= xorriso->zlib_level_default; + xorriso->zisofs_block_size= xorriso->zisofs_block_size_default; + xorriso->zisofs_by_magic= 0; + + } else { +unknown_mode:; + if(l<SfileadrL) + sprintf(xorriso->info_text, "-zisofs: unknown mode '%s'", cpt); + else + sprintf(xorriso->info_text, "-zisofs: oversized mode parameter (%d)",l); +sorry_ex: + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + xorriso->zlib_level= was_level; + xorriso->zisofs_block_size= was_blocksize; + return(0); + } + } + ret= Xorriso_set_zisofs_params(xorriso, 0); + return(ret); +} + + +/* ---------------------------- End Options API ------------------------ */ + + +/* @return <0 error , >=0 number of skipped dashes +*/ +int Xorriso_normalize_command(struct XorrisO *xorriso, char *original_cmd, + int argno, char *cmd_data, int sizeof_cmd_data, + char **cmd, int flag) +{ + int was_dashed= 0; + char *dash_pt; + + if(strlen(original_cmd)>= sizeof_cmd_data) { + if(argno>=0) + sprintf(xorriso->info_text, "Oversized argument #%d (length %d)\n", + argno, (int) strlen(original_cmd)); + else + sprintf(xorriso->info_text, "Oversized option (length %d)\n", + (int) strlen(original_cmd)); + return(-1); + } + strcpy(cmd_data, original_cmd); + *cmd= cmd_data; + if(strcmp(*cmd, xorriso->list_delimiter)==0) + return(1); + while((*cmd)[0]=='-') { + if((*cmd)[1]==0) + break; + was_dashed++; + (*cmd)++; + } + for(dash_pt= *cmd; *dash_pt!=0; dash_pt++) + if(*dash_pt=='-') + *dash_pt= '_'; + return(was_dashed); +} + + +/* @param flag bit0= do not warn of unknown option + @return <=0 error, + 1=count is valid, 2=dashed unknown, 3=undashed unknown +*/ +int Xorriso_count_args(struct XorrisO *xorriso, int argc, char **argv, + int *count, int flag) +{ + int ret, was_dashed= 0, i; + char *cmd, cmd_data[2*SfileadrL]; + static char arg0_commands[][40]= { + "ban_stdio_write","close_filter_list","commit","devices","end", + "for_backup", "help", + "list_formats","no_rc","print_size","pwd","pwdi","pwdx", + "rollback","rollback_end","tell_media_space","toc","version", + "" + }; + static char arg1_commands[][40]= { + "abort_on","acl","add_plainly","application_id","auto_charset", + "backslash_codes","blank", + "calm_drive","cd","cdi","cdx","charset","close", + "commit_eject","compliance", + "dev","dialog","disk_dev_ino","disk_pattern","dummy","eject", + "iso_rr_pattern","follow","format","fs","gid","grow_blindly","hardlinks", + "history","indev","in_charset","joliet", + "list_delimiter","list_profiles","local_charset", + "mark","md5","not_leaf","not_list","not_mgt", + "options_from_file","osirrox","outdev","out_charset","overwrite", + "pacifier","padding","path_list","pathspecs","pkt_output","print","prompt", + "prog","prog_help","publisher","quoted_not_list","quoted_path_list", + "reassure","report_about","rom_toc_scan", + "session_log","speed","split_size","status","status_history_max", + "stream_recording","temp_mem_limit", + "uid","unregister_filter","use_readline","volid","xattr","zisofs", + "" + }; + static char arg2_commands[][40]= { + "assert_volid","boot_image","compare","compare_r","drive_class", + "errfile_log","error_behavior","extract","extract_single", + "load","logfile", + "map","map_single","page","return_with","update","update_r", + "" + }; + static char arg4_commands[][40]= { + "cut_out","extract_cut","mount","mount_cmd","paste_in","session_string", + "" + }; + static char argn_commands[][40]= { + "add","alter_date","alter_date_r","as", + "check_md5","check_md5_r","check_media","check_media_defaults", + "chgrp","chgrpi","chgrp_r","chgrp_ri","chmod","chmodi", + "chmod_r","chmod_ri","chown","chowni","chown_r","chown_ri", + "compare_l","cpr","cpri","cp_rax","cp_rx","cpax","cpx", + "du","dui","dus","dusi","dux","dusx","external_filter","extract_l", + "file_size_limit","find","findi","finds","findx", + "getfacl","getfacli","getfacl_r","getfacl_ri", + "getfattr","getfattri","getfattr_r","getfattr_ri", + "ls","lsi","lsl","lsli","lsd","lsdi","lsdl","lsdli", + "lsx","lslx","lsdx","lsdlx","map_l","mv","mvi","mkdir","mkdiri", + "not_paths","rm","rmi","rm_r","rm_ri","rmdir","rmdiri","update_l", + "setfacl","setfacli","setfacl_list","setfacl_listi", + "setfacl_r","setfacl_ri","setfattr","setfattri", + "setfattr_list","setfattr_listi","setfattr_r","setfattr_ri", + "set_filter","set_filter_r","show_stream","show_stream_r", + "" + }; + + *count= 0; + if(argc<=0) + return(-1); + ret= Xorriso_normalize_command(xorriso, argv[0], -1, + cmd_data, sizeof(cmd_data), &cmd, 0); + if(ret<0) + return(ret); + was_dashed= (ret>0); + if(cmd[0]=='#' || cmd[0]==0 || strcmp(cmd, xorriso->list_delimiter) == 0) { + /* ignore: comment line , empty option , orphaned list delimiter */ + return(1); + } + for(i=0; arg0_commands[i][0]!=0; i++) + if(strcmp(arg0_commands[i], cmd)==0) + return(1); + *count= 1; + for(i=0; arg1_commands[i][0]!=0; i++) + if(strcmp(arg1_commands[i], cmd)==0) + return(1); + *count= 2; + for(i=0; arg2_commands[i][0]!=0; i++) + if(strcmp(arg2_commands[i], cmd)==0) + return(1); + *count= 4; + for(i=0; arg4_commands[i][0]!=0; i++) + if(strcmp(arg4_commands[i], cmd)==0) + return(1); + *count= 0; + for(i=0; argn_commands[i][0]!=0; i++) + if(strcmp(argn_commands[i], cmd)==0) { + ret= Xorriso_end_idx(xorriso, argc, argv, 1, 1); + if(ret<1) + return(ret); + *count= ret-1; + return(1); + } + + if(!(flag&1)) { + sprintf(xorriso->info_text, "Unknown option : '%s'", argv[0]); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + } + + return(2+!was_dashed); +} + + +/* @param flag bit0= recursion + bit1= these are command line arguments + (for xorriso->argument_emulation) +*/ +int Xorriso_interpreter(struct XorrisO *xorriso, + int argc, char **argv, int *idx, int flag) +/* +return: + <=0 error , 1 = success , 2 = problem event ignored , 3 = end program run +*/ +{ + int ret, was_dashed, end_ret, num1, num2; + char *cmd, *original_cmd, cmd_data[2*SfileadrL], *arg1, *arg2; + + if(xorriso==NULL) + return(0); + if(xorriso->is_dialog) { + xorriso->result_line_counter= xorriso->result_page_counter= 0; + if(xorriso->result_page_length<0) + xorriso->result_page_length= -xorriso->result_page_length; + } + +next_command:; + if(flag&2) { + ret= 1; + if(xorriso->argument_emulation==1) + ret= Xorriso_as_genisofs(xorriso, argc, argv, idx, 0); + else if(xorriso->argument_emulation==2) + ret= Xorriso_as_cdrskin(xorriso, argc, argv, idx, 0); + if(xorriso->argument_emulation>0) { + xorriso->argument_emulation= 0; + if(ret<=0) + goto eval_any_problems; + if((*idx)>=argc) + {ret= 1; goto ex;} + } + } + + xorriso->prepended_wd= 0; + xorriso->request_to_abort= xorriso->request_not_to_ask= 0; + Xorriso_set_problem_status(xorriso, "", 0); + if((*idx)<argc) + original_cmd= cmd= argv[*idx]; + else + original_cmd= cmd= ""; + if(xorriso->add_plainly==3 && cmd[0] && !xorriso->is_dialog) { + (*idx)++; + goto add_plain_argument; + } + was_dashed= 0; + + ret= Xorriso_normalize_command(xorriso, original_cmd, -1, + cmd_data, sizeof(cmd_data), &cmd, 0); + if(ret<0) + goto eval_any_problems; + was_dashed= ret; + + (*idx)++; + if((*idx)<argc) + arg1= argv[(*idx)]; + else + arg1= ""; + if((*idx)+1<argc) + arg2= argv[(*idx)+1]; + else + arg2= ""; + + ret= 1; + if(cmd[0]=='#' || cmd[0]==0) { + /* ignore comment line and empty option */; + + } else if(strcmp(cmd,"abort_on")==0) { + (*idx)++; + ret= Xorriso_option_abort_on(xorriso, arg1, 0); + + } else if(strcmp(cmd,"acl")==0) { + (*idx)++; + ret= Xorriso_option_acl(xorriso, arg1, 0); + + } else if(strcmp(cmd,"add")==0) { + ret= Xorriso_option_add(xorriso, argc, argv, idx, 0); + + } else if(strcmp(cmd,"add_plainly")==0) { + (*idx)++; + ret= Xorriso_option_add_plainly(xorriso, arg1, 0); + + } else if(strcmp(cmd,"alter_date")==0 || strcmp(cmd,"alter_date_r")==0) { + (*idx)+= 2; + ret= Xorriso_option_alter_date(xorriso, arg1, arg2, argc, argv, idx, + strlen(cmd)>10); + + } else if(strcmp(cmd,"application_id")==0) { + (*idx)++; + ret= Xorriso_option_application_id(xorriso, arg1, 0); + + } else if(strcmp(cmd,"as")==0) { + ret= Xorriso_option_as(xorriso, argc, argv, idx, 0); + + } else if(strcmp(cmd,"assert_volid")==0) { + (*idx)+= 2; + ret= Xorriso_option_assert_volid(xorriso, arg1, arg2, 0); + + } else if(strcmp(cmd,"auto_charset")==0) { + (*idx)++; + ret= Xorriso_option_auto_charset(xorriso, arg1, 0); + + } else if(strcmp(cmd,"backslash_codes")==0) { + (*idx)++; + ret= Xorriso_option_backslash_codes(xorriso, arg1, 0); + + } else if(strcmp(cmd,"ban_stdio_write")==0) { + ret= Xorriso_option_ban_stdio_write(xorriso, 0); + + } else if(strcmp(cmd,"blank")==0) { + (*idx)++; + ret= Xorriso_option_blank(xorriso, arg1, 0); + + } else if(strcmp(cmd,"boot_image")==0) { + (*idx)+= 2; + ret= Xorriso_option_boot_image(xorriso, arg1, arg2, 0); + + } else if(strcmp(cmd,"calm_drive")==0) { + (*idx)++; + ret= Xorriso_option_calm_drive(xorriso, arg1, 0); + + } else if(strcmp(cmd,"cd")==0 || strcmp(cmd,"cdi")==0) { + (*idx)++; + ret= Xorriso_option_cdi(xorriso, arg1, 0); + + } else if(strcmp(cmd,"cdx")==0) { + (*idx)++; + ret= Xorriso_option_cdx(xorriso, arg1, 0); + + } else if(strcmp(cmd,"charset")==0) { + (*idx)++; + ret= Xorriso_option_charset(xorriso, arg1, 3); + + } else if(strcmp(cmd,"check_md5")==0) { + ret= Xorriso_option_check_md5(xorriso, argc, argv, idx, 0); + + } else if(strcmp(cmd,"check_md5_r")==0) { + ret= Xorriso_option_check_md5(xorriso, argc, argv, idx, 8); + + } else if(strcmp(cmd,"check_media")==0) { + ret= Xorriso_option_check_media(xorriso, argc, argv, idx, 0); + + } else if(strcmp(cmd,"check_media_defaults")==0) { + ret= Xorriso_option_check_media_defaults(xorriso, argc, argv, idx, 0); + + } else if(strcmp(cmd,"chgrp")==0 || strcmp(cmd,"chgrpi")==0) { + (*idx)+= 1; + ret= Xorriso_option_chgrpi(xorriso, arg1, argc, argv, idx, 0); + + } else if(strcmp(cmd,"chgrp_r")==0 || strcmp(cmd,"chgrp_ri")==0) { + (*idx)+= 1; + ret= Xorriso_option_chgrpi(xorriso, arg1, argc, argv, idx, 1); + + } else if(strcmp(cmd,"chmod")==0 || strcmp(cmd,"chmodi")==0) { + (*idx)+= 1; + ret= Xorriso_option_chmodi(xorriso, arg1, argc, argv, idx, 0); + + } else if(strcmp(cmd,"chmod_r")==0 || strcmp(cmd,"chmod_ri")==0) { + (*idx)+= 1; + ret= Xorriso_option_chmodi(xorriso, arg1, argc, argv, idx, 1); + + } else if(strcmp(cmd,"chown_r")==0 || strcmp(cmd,"chown_ri")==0) { + (*idx)+= 1; + ret= Xorriso_option_chowni(xorriso, arg1, argc, argv, idx, 1); + + } else if(strcmp(cmd,"chown")==0 || strcmp(cmd,"chowni")==0) { + (*idx)+= 1; + ret= Xorriso_option_chowni(xorriso, arg1, argc, argv, idx, 0); + + } else if(strcmp(cmd,"close")==0) { + (*idx)++; + ret= Xorriso_option_close(xorriso, arg1, 0); + + } else if(strcmp(cmd,"close_filter_list")==0) { + ret= Xorriso_option_close_filter_list(xorriso, 0); + + } else if(strcmp(cmd,"commit")==0) { + ret= Xorriso_option_commit(xorriso, 0); + + } else if(strcmp(cmd,"commit_eject")==0) { + (*idx)++; + ret= Xorriso_option_commit_eject(xorriso, arg1, 0); + + } else if(strcmp(cmd,"compare")==0) { + (*idx)+= 2; + ret= Xorriso_option_compare(xorriso, arg1, arg2, 1); + + } else if(strcmp(cmd,"compare_l")==0) { + ret= Xorriso_option_map_l(xorriso, argc, argv, idx, 1<<8); + + } else if(strcmp(cmd,"compare_r")==0) { + (*idx)+= 2; + ret= Xorriso_option_compare(xorriso, arg1, arg2, 1|8); + + } else if(strcmp(cmd,"compliance")==0) { + (*idx)++; + Xorriso_option_compliance(xorriso, arg1, 0); + + } else if(strcmp(cmd,"cpr")==0 || strcmp(cmd,"cpri")==0) { + ret= Xorriso_option_cpri(xorriso, argc, argv, idx, 0); + + } else if(strcmp(cmd,"cp_rx")==0 || strcmp(cmd,"cp_rax")==0) { + ret= Xorriso_option_cpx(xorriso, argc, argv, idx, + 1|((strcmp(cmd,"cp_rax")==0)<<1)); + + } else if(strcmp(cmd,"cpx")==0 || strcmp(cmd,"cpax")==0) { + ret= Xorriso_option_cpx(xorriso, argc, argv, idx, + (strcmp(cmd,"cpax")==0)<<1); + + } else if(strcmp(cmd,"cut_out")==0) { + (*idx)+= 4; + if((*idx)>argc) { + sprintf(xorriso->info_text, + "-cut_out: Not enough arguments. Needed are: disk_path start count so_rr_path"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; + } else + ret= Xorriso_option_cut_out(xorriso, arg1, arg2, + argv[(*idx)-2], argv[(*idx)-1], 0); + + } else if(strcmp(cmd,"dev")==0) { + (*idx)++; + ret= Xorriso_option_dev(xorriso, arg1, 3); + + } else if(strcmp(cmd,"devices")==0) { + ret= Xorriso_option_devices(xorriso, 0); + + } else if(strcmp(cmd,"dialog")==0) { + (*idx)++; + ret= Xorriso_option_dialog(xorriso, arg1, 0); + + } else if(strcmp(cmd,"disk_dev_ino")==0) { + (*idx)++; + ret= Xorriso_option_disk_dev_ino(xorriso, arg1, 0); + + } else if(strcmp(cmd,"disk_pattern")==0) { + (*idx)++; + ret= Xorriso_option_disk_pattern(xorriso, arg1, 0); + + } else if(strcmp(cmd,"drive_class")==0) { + (*idx)+= 2; + ret= Xorriso_option_drive_class(xorriso, arg1, arg2, 0); + + } else if(strcmp(cmd,"du")==0 || strcmp(cmd,"dui")==0 || + strcmp(cmd,"dus")==0 || strcmp(cmd,"dusi")==0) { + ret= Xorriso_option_lsi(xorriso, argc, argv, idx, (cmd[2]!='s')|4); + + } else if(strcmp(cmd,"dummy")==0) { + (*idx)++; + ret= Xorriso_option_dummy(xorriso, arg1, 0); + + } else if(strcmp(cmd,"dux")==0 || strcmp(cmd,"dusx")==0) { + ret= Xorriso_option_lsx(xorriso, argc, argv, idx, (cmd[2]!='s')|4); + + } else if(strcmp(cmd,"eject")==0) { + (*idx)++; + ret= Xorriso_option_eject(xorriso, arg1, 0); + + } else if(strcmp(cmd,"end")==0) { + end_ret= Xorriso_option_end(xorriso, 0); + ret= Xorriso_eval_problem_status(xorriso, ret, 0); + if(ret<0) + return(ret); + if(end_ret!=2) + {ret= 3; goto ex;} + + } else if(strcmp(cmd,"errfile_log")==0) { + (*idx)+= 2; + ret= Xorriso_option_errfile_log(xorriso, arg1, arg2, 0); + + } else if(strcmp(cmd,"error_behavior")==0) { + (*idx)+= 2; + ret= Xorriso_option_error_behavior(xorriso, arg1, arg2, 0); + + } else if(strcmp(cmd,"external_filter")==0) { + ret= Xorriso_option_external_filter(xorriso, argc, argv, idx, 0); + + } else if(strcmp(cmd,"extract")==0) { + (*idx)+= 2; + ret= Xorriso_option_extract(xorriso, arg1, arg2, 0); + + } else if(strcmp(cmd,"extract_cut")==0) { + (*idx)+= 4; + if((*idx)>argc) { + sprintf(xorriso->info_text, + "-extract_cut: Not enough arguments. Needed are: disk_path start count so_rr_path"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; + } else + ret= Xorriso_option_extract_cut(xorriso, arg1, arg2, + argv[(*idx)-2], argv[(*idx)-1], 0); + + } else if(strcmp(cmd,"extract_l")==0) { + ret= Xorriso_option_map_l(xorriso, argc, argv, idx, 3<<8); + + } else if(strcmp(cmd,"extract_single")==0) { + (*idx)+= 2; + ret= Xorriso_option_extract(xorriso, arg1, arg2, 32); + + } else if(strcmp(cmd,"file_size_limit")==0) { + ret= Xorriso_option_file_size_limit(xorriso, argc, argv, idx, 0); + + } else if(strcmp(cmd,"find")==0 || strcmp(cmd,"findi")==0) { + ret= Xorriso_option_find(xorriso, argc, argv, idx, 0); + + } else if(strcmp(cmd,"findx")==0) { + ret= Xorriso_option_find(xorriso, argc, argv, idx, 1); + + } else if(strcmp(cmd,"follow")==0) { + (*idx)++; + ret= Xorriso_option_follow(xorriso, arg1, 0); + + } else if(strcmp(cmd,"for_backup")==0) { + ret= Xorriso_option_hardlinks(xorriso, "on", 0); + if(ret > 0) + ret= Xorriso_option_acl(xorriso, "on", 0); + if(ret > 0) + ret= Xorriso_option_xattr(xorriso, "on", 0); + if(ret > 0) + ret= Xorriso_option_md5(xorriso, "on", 0); + + } else if(strcmp(cmd,"format")==0) { + (*idx)++; + ret= Xorriso_option_blank(xorriso, arg1, 1); + + } else if(strcmp(cmd,"fs")==0) { + (*idx)++; + ret= Xorriso_option_fs(xorriso, arg1, 0); + + } else if(strcmp(cmd,"getfacl")==0 || strcmp(cmd,"getfacli")==0) { + ret= Xorriso_option_getfacli(xorriso, argc, argv, idx, 0); + + } else if(strcmp(cmd,"getfacl_r")==0 || strcmp(cmd,"getfacl_ri")==0) { + ret= Xorriso_option_getfacli(xorriso, argc, argv, idx, 1); + + } else if(strcmp(cmd,"getfattr")==0 || strcmp(cmd,"getfattri")==0) { + ret= Xorriso_option_getfacli(xorriso, argc, argv, idx, 2); + + } else if(strcmp(cmd,"getfattr_r")==0 || strcmp(cmd,"getfattr_ri")==0) { + ret= Xorriso_option_getfacli(xorriso, argc, argv, idx, 1 | 2); + + } else if(strcmp(cmd,"gid")==0) { + (*idx)++; + ret= Xorriso_option_gid(xorriso,arg1,0); + + } else if(strcmp(cmd,"grow_blindly")==0) { + (*idx)++; + ret= Xorriso_option_grow_blindly(xorriso,arg1,0); + + } else if(strcmp(cmd,"hardlinks")==0) { + (*idx)++; + ret= Xorriso_option_hardlinks(xorriso, arg1, 0); + + } else if(strcmp(cmd,"help")==0) { + Xorriso_option_help(xorriso,0); + + } else if(strcmp(cmd,"history")==0) { + /* add to readline history */ + (*idx)++; + ret= Xorriso_option_history(xorriso, arg1, 0); + + } else if(strcmp(cmd,"indev")==0) { + (*idx)++; + ret= Xorriso_option_dev(xorriso, arg1, 1); + + } else if(strcmp(cmd,"in_charset")==0) { + (*idx)++; + ret= Xorriso_option_charset(xorriso, arg1, 1); + + } else if(strcmp(cmd,"iso_rr_pattern")==0) { + (*idx)++; + ret= Xorriso_option_iso_rr_pattern(xorriso, arg1, 0); + + } else if(strcmp(cmd,"joliet")==0) { + (*idx)++; + ret= Xorriso_option_joliet(xorriso, arg1, 0); + + } else if(strcmp(cmd, "list_delimiter") == 0) { + (*idx)++; + ret= Xorriso_option_list_delimiter(xorriso, arg1, 0); + + } else if(strcmp(cmd,"list_formats")==0) { + ret= Xorriso_option_list_formats(xorriso, 0); + + } else if(strcmp(cmd,"list_profiles")==0) { + (*idx)++; + ret= Xorriso_option_list_profiles(xorriso, arg1, 0); + + } else if(strcmp(cmd,"load")==0) { + (*idx)+= 2; + ret= Xorriso_option_load(xorriso, arg1, arg2, 0); + + } else if(strcmp(cmd,"local_charset")==0) { + (*idx)++; + ret= Xorriso_option_charset(xorriso, arg1, 4); + + } else if(strcmp(cmd,"logfile")==0) { + (*idx)+= 2; + ret= Xorriso_option_logfile(xorriso, arg1, arg2, 0); + + } else if(strcmp(cmd,"ls")==0 || strcmp(cmd,"lsi")==0 || + strcmp(cmd,"lsl")==0 || strcmp(cmd,"lsli")==0) { + ret= Xorriso_option_lsi(xorriso, argc, argv, idx, (cmd[2]=='l')); + + } else if(strcmp(cmd,"lsd")==0 || strcmp(cmd,"lsdi")==0 || + strcmp(cmd,"lsdl")==0 || strcmp(cmd,"lsdli")==0) { + ret= Xorriso_option_lsi(xorriso, argc, argv, idx, (cmd[3]=='l')|8); + + } else if(strcmp(cmd,"lsdx")==0 || strcmp(cmd,"lsdlx")==0) { + ret= Xorriso_option_lsx(xorriso, argc, argv, idx, (cmd[3]=='l')|8); + + } else if(strcmp(cmd,"lsx")==0 || strcmp(cmd,"lslx")==0) { + ret= Xorriso_option_lsx(xorriso, argc, argv, idx, (cmd[2]=='l')); + + } else if(strcmp(cmd,"map")==0) { + (*idx)+= 2; + ret= Xorriso_option_map(xorriso, arg1, arg2, 0); + + } else if(strcmp(cmd,"map_l")==0) { + ret= Xorriso_option_map_l(xorriso, argc, argv, idx, 0); + + } else if(strcmp(cmd,"map_single")==0) { + (*idx)+= 2; + ret= Xorriso_option_map(xorriso, arg1, arg2, 32); + + } else if(strcmp(cmd,"mark")==0) { + (*idx)++; + ret= Xorriso_option_mark(xorriso, arg1, 0); + + } else if(strcmp(cmd, "md5")==0) { + (*idx)++; + ret= Xorriso_option_md5(xorriso, arg1, 0); + + } else if(strcmp(cmd, "mount") == 0 || strcmp(cmd, "mount_cmd") == 0) { + (*idx)+= 4; + if((*idx)>argc) { + sprintf(xorriso->info_text, + "-%s: Not enough arguments. Needed are: device entity id command", + cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; + } else + ret= Xorriso_option_mount(xorriso, arg1, arg2, + argv[(*idx)-2], argv[(*idx)-1], + (strcmp(cmd, "mount_cmd") == 0)); + + } else if(strcmp(cmd,"mv")==0 || strcmp(cmd,"mvi")==0) { + ret= Xorriso_option_mvi(xorriso, argc, argv, idx, 0); + + } else if(strcmp(cmd,"mkdir")==0 || strcmp(cmd,"mkdiri")==0) { + ret= Xorriso_option_mkdiri(xorriso, argc, argv, idx, 0); + + } else if(strcmp(cmd,"no_rc")==0) { + ret= Xorriso_option_no_rc(xorriso, 0); + + } else if(strcmp(cmd,"not_leaf")==0) { + (*idx)++; + ret= Xorriso_option_not_leaf(xorriso, arg1, 0); + + } else if(strcmp(cmd,"not_list")==0) { + (*idx)++; + ret= Xorriso_option_not_list(xorriso, arg1, 0); + + } else if(strcmp(cmd,"not_mgt")==0) { + (*idx)++; + ret= Xorriso_option_not_mgt(xorriso, arg1, 0); + + } else if(strcmp(cmd,"not_paths")==0) { + ret= Xorriso_option_not_paths(xorriso, argc, argv, idx, 0); + + } else if(strcmp(cmd,"options_from_file")==0) { + (*idx)++; + ret= Xorriso_option_options_from_file(xorriso,arg1,0); + if(ret==3) + goto ex; + + } else if(strcmp(cmd,"osirrox")==0) { + (*idx)++; + ret= Xorriso_option_osirrox(xorriso,arg1,0); + + } else if(strcmp(cmd,"outdev")==0) { + (*idx)++; + ret= Xorriso_option_dev(xorriso, arg1, 2); + + } else if(strcmp(cmd,"out_charset")==0) { + (*idx)++; + ret= Xorriso_option_charset(xorriso, arg1, 2); + + } else if(strcmp(cmd,"overwrite")==0) { + (*idx)++; + ret= Xorriso_option_overwrite(xorriso,arg1,0); + + } else if(strcmp(cmd,"pacifier")==0) { + (*idx)++; + ret= Xorriso_option_pacifier(xorriso, arg1, 0); + + } else if(strcmp(cmd,"padding")==0) { + (*idx)++; + ret= Xorriso_option_padding(xorriso, arg1, 0); + + } else if(strcmp(cmd,"page")==0) { + (*idx)+= 2; + num1= num2= 0; + sscanf(arg1,"%d",&num1); + sscanf(arg2,"%d",&num2); + if(num1<0) + num1= 0; + if(arg1[0]==0) + num1= 16; + if(num2<=0) + num2= 80; + ret= Xorriso_option_page(xorriso, num1, num2, 0); + + } else if(strcmp(cmd,"paste_in")==0) { + (*idx)+= 4; + if((*idx)>argc) { + sprintf(xorriso->info_text, + "-paste_in: Not enough arguments. Needed are: disk_path start count so_rr_path"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; + } else + ret= Xorriso_option_paste_in(xorriso, arg1, arg2, + argv[(*idx)-2], argv[(*idx)-1], 0); + + } else if(strcmp(cmd,"path-list")==0 || strcmp(cmd,"path_list")==0) { + (*idx)++; + ret= Xorriso_option_path_list(xorriso, arg1, 0); + + } else if(strcmp(cmd,"pathspecs")==0) { + (*idx)++; + ret= Xorriso_option_pathspecs(xorriso, arg1, 0); + + } else if(strcmp(cmd,"pkt_output")==0) { + (*idx)++; + ret= Xorriso_option_pkt_output(xorriso, arg1, 0); + + } else if(strcmp(cmd,"print")==0) { + (*idx)++; + ret= Xorriso_option_print(xorriso, arg1, 0); + + } else if(strcmp(cmd,"print_size")==0) { + Xorriso_option_print_size(xorriso, 0); + + } else if(strcmp(cmd,"prompt")==0) { + (*idx)++; + ret= Xorriso_option_prompt(xorriso, arg1, 0); + + } else if(strcmp(cmd,"prog")==0) { + (*idx)++; + ret= Xorriso_option_prog(xorriso, arg1, 0); + + } else if(strcmp(cmd,"publisher")==0) { + (*idx)++; + Xorriso_option_publisher(xorriso, arg1, 0); + + } else if(strcmp(cmd,"pwd")==0 || strcmp(cmd,"pwdi")==0) { + Xorriso_option_pwdi(xorriso, 0); + + } else if(strcmp(cmd,"pwdx")==0) { + Xorriso_option_pwdx(xorriso, 0); + + } else if(strcmp(cmd,"quoted_not_list")==0) { + (*idx)++; + ret= Xorriso_option_not_list(xorriso, arg1, 1); + + } else if(strcmp(cmd,"quoted_path_list")==0) { + (*idx)++; + ret= Xorriso_option_path_list(xorriso, arg1, 1); + + } else if(strcmp(cmd,"reassure")==0) { + (*idx)++; + ret= Xorriso_option_reassure(xorriso, arg1, 0); + + } else if(strcmp(cmd,"report_about")==0) { + (*idx)++; + ret= Xorriso_option_report_about(xorriso, arg1, 0); + + } else if(strcmp(cmd,"return_with")==0) { + (*idx)+= 2; + num2= 0; + sscanf(arg2,"%d",&num2); + ret= Xorriso_option_return_with(xorriso, arg1, num2, 0); + + } else if(strcmp(cmd,"rm")==0 || strcmp(cmd,"rmi")==0) { + ret= Xorriso_option_rmi(xorriso, argc, argv, idx, 0); + + } else if(strcmp(cmd,"rm_r")==0 || strcmp(cmd,"rm_ri")==0) { + ret= Xorriso_option_rmi(xorriso, argc, argv, idx, 1); + + } else if(strcmp(cmd,"rmdir")==0 || strcmp(cmd,"rmdiri")==0) { + ret= Xorriso_option_rmi(xorriso, argc, argv, idx, 2); + + } else if(strcmp(cmd,"rollback")==0) { + ret= Xorriso_option_rollback(xorriso, 0); + + } else if(strcmp(cmd,"rollback_end")==0) { + end_ret= Xorriso_option_end(xorriso, 1); + ret= Xorriso_eval_problem_status(xorriso, ret, 0); + if(ret<0) + return(ret); + if(end_ret!=2) + {ret= 3; goto ex;} + + } else if(strcmp(cmd,"rom_toc_scan")==0) { + (*idx)++; + Xorriso_option_rom_toc_scan(xorriso, arg1, 0); + + } else if(strcmp(cmd,"session_log")==0) { + (*idx)++; + ret= Xorriso_option_session_log(xorriso, arg1, 0); + + } else if(strcmp(cmd, "session_string") == 0) { + (*idx)+= 4; + if((*idx)>argc) { + sprintf(xorriso->info_text, + "-%s: Not enough arguments. Needed are: device entity id command", + cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; + } else + ret= Xorriso_option_mount(xorriso, arg1, arg2, + argv[(*idx)-2], argv[(*idx)-1], 2); + + } else if(strcmp(cmd,"setfacl")==0 || strcmp(cmd,"setfacli")==0) { + (*idx)+= 1; + ret= Xorriso_option_setfacli(xorriso, arg1, argc, argv, idx, 0); + + } else if(strcmp(cmd,"setfacl_list")==0 || strcmp(cmd,"setfacl_listi")==0) { + (*idx)+= 1; + ret= Xorriso_option_setfacl_listi(xorriso, arg1, 0); + + } else if(strcmp(cmd,"setfacl_r")==0 || strcmp(cmd,"setfacl_ri")==0) { + (*idx)+= 1; + ret= Xorriso_option_setfacli(xorriso, arg1, argc, argv, idx, 1); + + } else if(strcmp(cmd,"setfattr")==0 || strcmp(cmd,"setfattri")==0) { + (*idx)+= 2; + ret= Xorriso_option_setfattri(xorriso, arg1, arg2, argc, argv, idx, 0); + + } else if(strcmp(cmd,"setfattr_list")==0 || strcmp(cmd,"setfattr_listi")==0) { + (*idx)+= 1; + ret= Xorriso_option_setfattr_listi(xorriso, arg1, 0); + + } else if(strcmp(cmd,"setfattr_r")==0 || strcmp(cmd,"setfattr_ri")==0) { + (*idx)+= 2; + ret= Xorriso_option_setfattri(xorriso, arg1, arg2, argc, argv, idx, 1); + + } else if(strcmp(cmd,"set_filter")==0 || strcmp(cmd,"set_filter_r")==0) { + (*idx)+= 1; + ret= Xorriso_option_set_filter(xorriso, arg1, argc, argv, idx, + strcmp(cmd,"set_filter_r")==0); + + } else if(strcmp(cmd,"show_stream")==0 || strcmp(cmd,"show_stream_r")==0) { + ret= Xorriso_option_set_filter(xorriso, "", argc, argv, idx, + (strcmp(cmd,"show_stream_r")==0) | 2 | 4); + + } else if(strcmp(cmd,"speed")==0) { + (*idx)++; + ret= Xorriso_option_speed(xorriso, arg1, 0); + + } else if(strcmp(cmd,"split_size")==0) { + (*idx)++; + ret= Xorriso_option_split_size(xorriso, arg1, 0); + + } else if(strcmp(cmd,"status")==0) { + (*idx)++; + ret= Xorriso_option_status(xorriso, arg1, 0); + + } else if(strcmp(cmd,"status_history_max")==0) { + (*idx)++; + sscanf(arg1,"%d",&num1); + ret= Xorriso_option_status_history_max(xorriso, num1, 0); + + } else if(strcmp(cmd,"stream_recording")==0) { + (*idx)++; + ret= Xorriso_option_stream_recording(xorriso, arg1, 0); + + } else if(strcmp(cmd,"tell_media_space")==0) { + Xorriso_option_tell_media_space(xorriso, 0); + + } else if(strcmp(cmd,"temp_mem_limit")==0) { + (*idx)++; + ret= Xorriso_option_temp_mem_limit(xorriso, arg1, 0); + + } else if(strcmp(cmd,"test")==0) { /* This option does not exist. */ + + /* install temporary test code here */; + + } else if(strcmp(cmd,"toc")==0) { + Xorriso_option_toc(xorriso, 0); + + } else if(strcmp(cmd,"uid")==0) { + (*idx)++; + ret= Xorriso_option_uid(xorriso,arg1,0); + + } else if(strcmp(cmd,"unregister_filter")==0) { + (*idx)++; + ret= Xorriso_option_unregister_filter(xorriso, arg1, 0); + + } else if(strcmp(cmd,"update")==0) { + (*idx)+= 2; + ret= Xorriso_option_update(xorriso, arg1, arg2, 1); + + } else if(strcmp(cmd,"update_l")==0) { + ret= Xorriso_option_map_l(xorriso, argc, argv, idx, 2<<8); + + } else if(strcmp(cmd,"update_r")==0) { + (*idx)+= 2; + ret= Xorriso_option_update(xorriso, arg1, arg2, 1|8); + + } else if(strcmp(cmd,"use_readline")==0) { + (*idx)++; + ret= Xorriso_option_use_readline(xorriso, arg1, 0); + + } else if(strcmp(cmd,"version")==0){ + ret= Xorriso_option_version(xorriso, 0); + + } else if(strcmp(cmd,"volid")==0) { + (*idx)++; + ret= Xorriso_option_volid(xorriso,arg1,0); + + } else if(strcmp(cmd,"xattr")==0) { + (*idx)++; + ret= Xorriso_option_xattr(xorriso, arg1, 0); + + } else if(strcmp(cmd,"zisofs")==0) { + (*idx)++; + ret= Xorriso_option_zisofs(xorriso, arg1, 0); + + } else if(strcmp(cmd, xorriso->list_delimiter)==0){ + /* tis ok */; + + } else if(was_dashed) { + if(xorriso->add_plainly>1) + goto add_plain_argument; +unknown_option:; + sprintf(xorriso->info_text, "Not a known option: '%s'\n", + original_cmd); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto eval_any_problems;} + + } else { + if(xorriso->add_plainly<=0) + goto unknown_option; +add_plain_argument:; + (*idx)--; + ret= Xorriso_option_add(xorriso, (*idx)+1, argv, idx, 0); + (*idx)++; + + } + +eval_any_problems: + ret= Xorriso_eval_problem_status(xorriso, ret, 0); + if(ret<0) + return(ret); + + if(*idx<argc) + goto next_command; + +ex:; + if((!xorriso->is_dialog) && !(flag&1)) + Xorriso_mark(xorriso,0); + fflush(stdout); + return(ret); +} + + +int Xorriso_execute_option(struct XorrisO *xorriso, char *line, int flag) +/* + bit0-bit15 are forwarded to Xorriso_interpreter + + bit16= no pageing of info lines + bit17= print === bar even if xorriso->found<0 +*/ +{ + int ret,argc= 0, idx= 1; + char **argv= NULL; + double tdiff; + struct timeval tv; + struct timezone tz; + + gettimeofday(&tv,&tz); + Xorriso_reset_counters(xorriso,0); + xorriso->idle_time= 0.0; + tdiff= tv.tv_sec+(1.e-6*(double) tv.tv_usec); + + /* parse line into args */ + ret= Sfile_make_argv(xorriso->progname, line, &argc, &argv, + 4 | ((xorriso->bsl_interpretation & 3) << 5)); + if(ret < 0) { + Xorriso_msgs_submit(xorriso, 0, + "Severe lack of resources during command line parsing", 0, "FATAL", 0); + goto ex; + } + if(ret == 0) { + sprintf(xorriso->info_text, "Incomplete quotation in command line: %s", + line); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + goto ex; + } + if(argc<2) + {ret= 1; goto ex;} + if(argv[1][0]=='#') + {ret= 1; goto ex;} + + ret= Xorriso_interpreter(xorriso, argc, argv, &idx, flag&0xffff); + if(ret<0) + goto ex; + gettimeofday(&tv,&tz); + tdiff= tv.tv_sec+(1.e-6*(double) tv.tv_usec)-tdiff-xorriso->idle_time; + if(tdiff<0.001) + tdiff= 0.001; + if(xorriso->error_count>0) { + sprintf(xorriso->info_text, + "----------------------------- %7.f errors encountered\n", + xorriso->error_count); + Xorriso_info(xorriso,!(flag&(1<<16))); + } + + /* ??? >>> print elapsed time tdiff ? */; + + if((flag&(1<<17)) && !xorriso->bar_is_fresh) { + sprintf(xorriso->info_text,"============================\n"); + Xorriso_info(xorriso,0); + xorriso->bar_is_fresh= 1; + } + Xorriso_reset_counters(xorriso,0); +ex:; + Sfile_make_argv("", "", &argc, &argv, 2); /* release memory */ + return(ret); +} + + +int Xorriso_dialog(struct XorrisO *xorriso, int flag) +{ + int ret,first_round; + char line[2*SfileadrL]; + + if(!xorriso->dialog) + return(1); + xorriso->is_dialog= 1; + for(first_round= 1;1;first_round= 0) { + if(xorriso->pending_option[0]!=0) { + Xorriso_mark(xorriso,0); + strcpy(line,xorriso->pending_option); + xorriso->pending_option[0]= 0; + } else { + if(!xorriso->bar_is_fresh) { + sprintf(xorriso->info_text,"============================\n"); + Xorriso_info(xorriso,0); + xorriso->bar_is_fresh= 1; + } + sprintf(xorriso->info_text,"enter option and arguments :\n"); + Xorriso_info(xorriso,0); + Xorriso_mark(xorriso,0); + ret= Xorriso_dialog_input(xorriso,line,sizeof(line),4); + if(ret<=0) + break; + } + sprintf(xorriso->info_text, + "==============================================================\n"); + Xorriso_info(xorriso,0); + + ret= Xorriso_execute_option(xorriso,line,1<<17); + if(ret<0) + goto ex; + if(ret==3) + goto ex; + xorriso->did_something_useful= 1; + xorriso->no_volset_present= 0; /* Re-enable "No ISO image present." */ + } + ret= 1; +ex:; + xorriso->is_dialog= 0; + return(ret); +} + + +int Xorriso_change_is_pending(struct XorrisO *xorriso, int flag) +{ + return(!!xorriso->volset_change_pending); +} + + +int Xorriso_protect_stdout(struct XorrisO *xorriso, int flag) +{ + if(xorriso->dev_fd_1>=0) + return(2); + xorriso->dev_fd_1= dup(1); + close(1); + dup2(2,1); + return(1); +} + + +int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv, + int flag) +/* + bit0= do not interpret argv[1] +*/ +/* + return: + <0 error + 0 end program + 1 ok, go on +*/ +{ + int i, ret, was_dashed, num2, arg_count; + int was_report_about= 0, was_abort_on= 0, was_return_with= 0; + char *cmd, *original_cmd, cmd_data[5*SfileadrL], *arg1, *arg2; + char mem_list_delimiter[81]; + + strcpy(mem_list_delimiter, xorriso->list_delimiter); + for(i=1+(flag&1);i<argc;i++) { + original_cmd= cmd= argv[i]; + was_dashed= 0; + + was_dashed= Xorriso_normalize_command(xorriso, original_cmd, i, + cmd_data, sizeof(cmd_data), &cmd, 0); + if(was_dashed<0) + {ret= -1; goto ex;} + + arg1= ""; + if(i+1<argc) + arg1= argv[i+1]; + arg2= ""; + if(i+2<argc) + arg2= argv[2+1]; + if(i>1) + xorriso->did_something_useful= 1; + if(i==1 && argc==2) { + if(strcmp(cmd,"prog_help")==0) { + i++; + Xorriso_option_prog_help(xorriso,arg1,0); + xorriso->did_something_useful= 1; + {ret= 0; goto ex;} + } else if(strcmp(cmd,"help")==0) { + Xorriso_option_help(xorriso,0); + xorriso->did_something_useful= 1; + {ret= 0; goto ex;} + } + } else if(i==1 && strcmp(cmd,"no_rc")==0) { + ret= Xorriso_option_no_rc(xorriso, 0); + if(ret<=0) + goto ex; + + } else if((strcmp(cmd,"dev")==0 || strcmp(cmd,"outdev")==0 || + strcmp(cmd,"indev")==0) && + (strcmp(arg1,"stdio:/dev/fd/1")==0 || strcmp(arg1,"-")==0) && + xorriso->dev_fd_1<0) { + /* Detach fd 1 from externally perceived stdout and attach it to stderr. + Keep dev_fd_1 connected to external stdout. dev_fd_1 is to be used when + "stdio:/dev/fd/1" is interpreted as drive address. + */ +protect_stdout:; + Xorriso_protect_stdout(xorriso, 0); + sprintf(xorriso->info_text, + "Encountered - or stdio:/dev/fd/1 as possible write target."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + sprintf(xorriso->info_text, + "Redirecting nearly all text message output to stderr."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + sprintf(xorriso->info_text, "Disabling use of libreadline."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + + } else if(strcmp(cmd,"abort_on")==0 && was_dashed) { + i++; + if(!was_abort_on) + Xorriso_option_abort_on(xorriso, arg1, 0); + was_abort_on= 1; + + } else if(strcmp(cmd,"report_about")==0 && was_dashed) { + i++; + if(!was_report_about) + Xorriso_option_report_about(xorriso, arg1, 0); + was_report_about= 1; + + } else if(strcmp(cmd,"return_with")==0 && was_dashed) { + i+= 2; + num2= 0; + sscanf(arg2,"%d",&num2); + if(!was_return_with) + Xorriso_option_return_with(xorriso, arg1, num2, 0); + was_return_with= 1; + + } else if(strcmp(cmd,"as")==0 && was_dashed) { + if(strcmp(arg1, "mkisofs")==0 || strcmp(arg1, "genisoimage")==0 || + strcmp(arg1, "genisofs")==0 || strcmp(arg1, "xorrisofs")==0) + goto protect_stdout; + + } else if(strcmp(cmd, "list_delimiter") == 0) { + /* Needed for interpreting other args. Gets reset after prescan. */ + i++; + ret= Xorriso_option_list_delimiter(xorriso, arg1, 0); + if(ret <= 0) + goto ex; + + } else { + ret= Xorriso_count_args(xorriso, argc-i, argv+i, &arg_count, 1); + if(ret==1) + i+= arg_count; + } + } + ret= 1; +ex:; + strcpy(xorriso->list_delimiter, mem_list_delimiter); + return(ret); +} + + +int Xorriso_read_rc(struct XorrisO *xorriso, int flag) +{ + int ret,i,was_failure= 0,fret; + + if(xorriso->no_rc) + return(1); + i= xorriso->rc_filename_count-1; + Sfile_home_adr_s(".xorrisorc", xorriso->rc_filenames[i], + sizeof(xorriso->rc_filenames[i]),0); + for(i=0;i<xorriso->rc_filename_count;i++) { + ret= Sfile_type(xorriso->rc_filenames[i],1|8); + if(ret!=1) + continue; + ret= Xorriso_option_options_from_file(xorriso,xorriso->rc_filenames[i],0); + if(ret>1) + return(ret); + if(ret==1) + continue; /* regular bottom of loop */ + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1); + if(fret>=0) + continue; + return(ret); + } + return(!was_failure); +} + + +int Xorriso_make_return_value(struct XorrisO *xorriso, int flag) +{ + int exit_value= 0; + + if(xorriso->eternal_problem_status >= xorriso->return_with_severity) + exit_value= xorriso->return_with_value; + if(exit_value) { + sprintf(xorriso->info_text, + "-return_with %s %d triggered by problem severity %s", + xorriso->return_with_text, exit_value, + xorriso->eternal_problem_status_text); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + return(exit_value); +} + + +int Xorriso_program_arg_bsl(struct XorrisO *xorriso, int argc, char ***argv, + int flag) +{ + int ret; + + if(!(xorriso->bsl_interpretation & 16)) + return(1); + ret= Sfile_argv_bsl(argc, argv, 0); + return(ret); +} + + +char *Xorriso__get_version_text(int flag) +{ + return(Xorriso_program_versioN); +} + + + +#endif /* ! Xorriso_without_subS */ + + + +#ifdef Xorriso_with_maiN + + +#ifdef Xorriso_without_subS + +/* xorriso consists only of a main() stub which has an own version to match + the version of libxorriso header and runtime code. +*/ +#define Xorriso_main_program_versioN "0.4.1" + +#else /* Xorriso_without_subS */ + +/* Make sure that both version tests always match. */ +#define Xorriso_main_program_versioN Xorriso_program_versioN + +#endif /* ! Xorriso_without_subS */ + + +static void yell_xorriso() +{ + fprintf(stderr, + "xorriso %s : RockRidge filesystem manipulator, libburnia project.\n\n", + Xorriso_main_program_versioN); +} + + +int main(int argc, char **argv) +{ + int ret, i; + struct XorrisO *xorriso= NULL; + + if(strcmp(Xorriso_main_program_versioN, Xorriso_program_versioN)) { + yell_xorriso(); + fprintf(stderr, + "xorriso : FATAL : libxorriso compile time version mismatch. Found %s\n\n", + Xorriso_program_versioN); + exit(4); + } + if(strcmp(Xorriso_program_versioN, Xorriso__get_version_text(0))) { + yell_xorriso(); + fprintf(stderr, + "xorriso : FATAL : libxorriso runtime version mismatch. Found %s\n\n", + Xorriso__get_version_text(0)); + exit(4); + } + + if(argc < 2) { + yell_xorriso(); + fprintf(stderr,"usage : %s [options]\n", argv[0]); + fprintf(stderr, " More is told by option -help\n"); + exit(2); + } + setlocale(LC_CTYPE, ""); + ret= Xorriso_new(&xorriso, argv[0], 0); + if(ret <= 0) { + fprintf(stderr,"Creation of XorrisO object failed. (not enough memory ?)\n"); + exit(3); + } + + /* The prescan of arguments performs actions which have to happen before + the normal processing of startup files and arguments. + */ + ret= Xorriso_prescan_args(xorriso,argc,argv,0); + if(ret == 0) + goto end_sucessfully; + if(ret < 0) + exit(5); + + yell_xorriso(); + + /* The following functions are allowed only after this initialization */ + ret= Xorriso_startup_libraries(xorriso, 0); + if(ret <= 0) + exit(4); + Xorriso_process_msg_queues(xorriso, 0); + + /* Interpret startup files */ + ret= Xorriso_read_rc(xorriso, 0); + if(ret == 3) + goto end_sucessfully; + if(ret <= 0) + exit(5); + + /* Interpret program arguments */ + ret= Xorriso_program_arg_bsl(xorriso, argc, &argv, 0); + if(ret <= 0) + exit(5); + i= 1; + ret= Xorriso_interpreter(xorriso, argc, argv, &i, 2); + if(ret == 3) + goto end_sucessfully; + if(ret <= 0) + exit(5); + + /* Enter dialog mode if it has been activated meanwhile */ + ret= Xorriso_dialog(xorriso, 0); + if(ret <= 0) + exit(6); + +end_sucessfully:; + Xorriso_process_msg_queues(xorriso, 0); + if(Xorriso_change_is_pending(xorriso, 0)) + Xorriso_option_end(xorriso, 2); + Xorriso_process_msg_queues(xorriso, 0); + ret= Xorriso_make_return_value(xorriso, 0); + Xorriso_process_errfile(xorriso, 0, "xorriso end", 0, 1); + Xorriso_destroy(&xorriso, 1); + exit(ret); +} + +#endif /* Xorriso_with_maiN */ + + diff --git a/libisoburn/branches/ZeroFourTwo/xorriso/xorriso.h b/libisoburn/branches/ZeroFourTwo/xorriso/xorriso.h new file mode 100644 index 00000000..8f061bd4 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/xorriso/xorriso.h @@ -0,0 +1,948 @@ + +/* Command line oriented batch and dialog tool which creates, loads, + manipulates and burns ISO 9660 filesystem images. + + Copyright 2007-2009 Thomas Schmitt, <scdbackup@gmx.net> + + Provided under GPL version 2. + + This file contains the public option interface of xorriso. +*/ + +#ifndef Xorriso_includeD +#define Xorriso_includeD yes + +/** Opaque handle of the xorriso runtime context */ +struct XorrisO; + + +#define Xorriso_program_versioN "0.4.1" + + +/* --------------------- Fundamental Management ------------------- */ + + +/* Get the version text (e.g. "0.4.1") of the program code. + @param flag unused yet, submit 0 + @return readonly character string +*/ +char *Xorriso__get_version_text(int flag); + + +/* Mandatory call: + Create a new xorriso object and tell it the program name to be used + with messages and for decision of special behavior. + @param xorriso returns the newly created XorrisO object + @param progname typically argv[0] of main(). Some leafnames of the progname + path have special meaning and trigger special behavior: + "osirrox" allows image-to-disk copying: -osirrox "on" + "xorrisofs" activates permanent mkisofs emulation + "genisofs" alias of "xorrisofs" + "mkisofs" alias of "xorrisofs" + "genisoimage" alias of "xorrisofs" + @param flag unused yet, submit 0 + @return >0 success , <=0 failure, no object created +*/ +int Xorriso_new(struct XorrisO ** xorriso, char *progname, int flag); + + +/* Interpret certain commands which shall get into effect before the + libraries get initialized: + -abort_on , -report_about , -return_with , -list_delimiter + Some commands get executed only if they are the only command in argv: + -prog_help , -help , -no_rc + Some get examined for the need to redirect stdout messages + -dev , -outdev , -indev , -as + @param xorriso The context object in which to perform the commands. + @param argc Number of arguments. + @param argv The arguments. argv[0] contains the program name. + argv[1] to argv[argc-1] contain commands and parameters. + @param idx Argument cursor. When this function is called, *idx must + be at least 1, argv[*idx] must be to a command. + *idx will iterate over commands and parameters until this + function aborts or until argc is reached. + @param flag bit0= do not interpret argv[1] + @return <0 error + 0 end program + 1 ok, go on +*/ +int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv, + int flag); + + +/* Mandatory call: + It has to be made before calling any function listed below this point. + + Make global library initializations. + This must be done with the first xorriso object that gets created and + with the first xorriso object that gets created after Xorriso_destroy(,1). + @param xorriso The context object. + @param flag unused yet, submit 0 + @return <=0 error , >0 success +*/ +int Xorriso_startup_libraries(struct XorrisO *xorriso, int flag); + + +/* Read and interpret commands from eventual startup files as listed in + man xorriso. + @param xorriso The context object in which to perform the commands. + @param flag unused yet, submit 0 + @return <=0 = error + 1 = success + 3 = end program run (e.g. because command -end was encountered) +*/ +int Xorriso_read_rc(struct XorrisO *xorriso, int flag); + + +/* Check whether program arguments shall be backslash decoded and eventually + replace *argv by a new argument vector. The old one will not be freed + by this call. If it is dynamic memory then you need to keep a copy of + the pointer and free it yourself after this call. + @param xorriso The context object + @param argc Number of arguments. + @param argv The arguments. (*argv)[0] contains the program name. + (*argv)[1] to (*argv)[argc-1] contain commands and parameters + @param flag unused yet, submit 0 + @return <= 0 error , > 0 success +*/ +int Xorriso_program_arg_bsl(struct XorrisO *xorriso, int argc, char ***argv, + int flag); + + +/* Interpret argv as xorriso command options and their parameters. + (An alternative is to call functions of the options API directly and to + perform own error status evaluation. See below: Options API.) + After the first command and its parameters there may be more commands and + parameters. All parameters must be given in the same call as their command. + @param xorriso The context object in which to perform the commands. + @param argc Number of arguments. + @param argv The arguments. argv[0] contains the program name. + argv[1] to argv[argc-1] contain commands and parameters. + @param idx Argument cursor. When this function is called, *idx must + be at least 1, argv[*idx] must be a command. + *idx will iterate over commands and parameters until this + function aborts or until argc is reached. + @param flag bit0= recursion + bit1= these are the main() program start arguments + @return <=0 = error + 1 = success + 2 = problem event ignored + 3 = end program run (e.g. because command -end was encountered) +*/ +int Xorriso_interpreter(struct XorrisO *xorriso, + int argc, char **argv, int *idx, int flag); + + +/* Parse a command line into words and use them as argv for a call of + Xorriso_interpreter(). Put out some info lines about the outcome. + @param xorriso The context object in which to perform the commands. + @param line A text of one or more words according to man xorriso + paragraph "Command processing" up to and including + "Backslash Interpretation". + @param flag bit0 to bit15 are forwarded to Xorriso_interpreter() + bit16= no pageing of info lines + bit17= print === bar even if xorriso->found<0 + @return see return of Xorriso_interpreter() +*/ +int Xorriso_execute_option(struct XorrisO *xorriso, char *line, int flag); + + +/* Enter xorriso command line dialog mode, eventually using libreadline. + This call returns immediately if not option -dialog "on" was performed + before. + @param xorriso The context object in which to perform the commands. + @param flag unused yet, submit 0 + @return <=0 error, 1= dialog mode ended normally , + 3= dialog mode ended normally,interpreter asks to end program +*/ +int Xorriso_dialog(struct XorrisO *xorriso, int flag); + + +/* Inquire whether option -commit would make sense. + @param xorriso The context object to inquire. + @param flag unused yet, submit 0 + @return 0= -commit would have nothing to do + 1= a new image session would emerge at -commit +*/ +int Xorriso_change_is_pending(struct XorrisO *xorriso, int flag); + + +/* Compute the exit value from the recorded maximum event severity. + @param xorriso The context object to inquire. + @param flag unused yet, submit 0 + @return The computed exit value +*/ +int Xorriso_make_return_value(struct XorrisO *xorriso, int flag); + + +/* Mandatory call: + Destroy xorriso object when it is no longer needed. + @param xorriso The context object to destroy. *xorriso will become NULL. + @param flag bit0= Perform global library shutdown. + Use only with last xorriso object to be destroyed. + @return <=0 error, >0 success +*/ +int Xorriso_destroy(struct XorrisO **xorriso, int flag); + + +/* --------------------- Problem Status and Message API ------------------- */ + + +/** Submit a problem message to the xorriso problem reporting and handling + system. This will eventually increase problem status rank, which may + at certain stages in the program be pardoned and reset to 0. + The pardon is governed by Xorriso_option_abort_on() and by the anger + of the affected program part. If no pardon has been given, then the problem + status reaches the caller of option functions. + Problem status should be inquired by Xorriso_eval_problem_status() and be + reset before next option execution by Xorriso_set_problem_status(). + The problem status itself does not cause the failure of option functions. + But in case of failures for other reasons, a remnant overly severe problem + status can cause overly harsh program reactions. + @param xorriso The environment handle + @param error_code The unique error code of your message. + Submit 0 if you do not have reserved error codes within + the libburnia project. + @param msg_text Not more than 8196 characters of message text. + A final newline character gets appended automatically. + @param os_errno Eventual errno related to the message. Submit 0 if + the message is not related to a operating system error. + @param severity One of "ABORT", "FATAL", "SORRY", "WARNING", "HINT", + "NOTE", "UPDATE", "DEBUG". Defaults to "FATAL". + @param flag Bitfield for control purposes + bit0= use pager (as with result) + bit1= permission to suppress output + @return 1 if message was delivered, <=0 if failure +*/ +int Xorriso_msgs_submit(struct XorrisO *xorriso, + int error_code, char msg_text[], int os_errno, + char severity[], int flag); + +/** Alternative call interface of Xorriso_msgs_submit with void* instead + of struct XorrisO* +*/ +int Xorriso_msgs_submit_void(void *xorriso, + int error_code, char msg_text[], int os_errno, + char severity[], int flag); + + +/** Evaluate an advise whether to abort or whether to go on with option + processing. This should be called after any option function was processed. + It updates the problem status by processing the library message queues + and then it uses this status and the submitted return value ot the + option function to evaluate the situation. + @param xorriso The environment handle + @param ret The return value of the previously called option function + @param flag bit0= do not issue own event messages + bit1= take xorriso->request_to_abort as reason for abort + @return Gives the advice: + 2= pardon was given, go on + 1= no problem, go on + 0= function failed but xorriso would not abort, go on + <0= do abort + -1 = due to xorriso->problem_status + or due to ret<0 + -2 = due to xorriso->request_to_abort +*/ +int Xorriso_eval_problem_status(struct XorrisO *xorriso, int ret, int flag); + + +/** Set the current problem status of the xorriso handle. + @param xorriso The environment handle + @param severity A severity text. Empty text resets to "No Problem". + @param flag Unused yet. Submit 0. + @return <=0 failure (e.g. wrong severity text), 1 success. +*/ +int Xorriso_set_problem_status(struct XorrisO *xorriso, char *severity, + int flag); + + +/* The next two functions are part of Xorriso_eval_problem_status(). + You may use them to build an own advisor function or to drain the + library message queues more frequently. +*/ + +/** Obtain the current problem status of the xorriso handle. + @param xorriso The environment handle + @param severity The severity text matching the current problem status + @param flag Unused yet. Submit 0. + @return The severity rank number. 0= no problem occured. +*/ +int Xorriso_get_problem_status(struct XorrisO *xorriso, char severity[80], + int flag); + + +/** Forward any pending messages from the library message queues to the + xorriso message system which puts out on info channel. This registers + the severity of the library events like the severity of a message submitted + via Xorriso_msgs_submit(). + xorriso sets the message queues of the libraries to queuing "ALL". + So it is essential that they get drained regularly. + @param xorriso The environment handle + @param flag Unused yet. Submit 0. + @return 1 on success, <=0 if failure +*/ +int Xorriso_process_msg_queues(struct XorrisO *xorriso, int flag); + + +/** Write a message for option -errfile_log. + @param xorriso The environment handle + @param error_code The unique error code of your message. + Submit 0 if you do not have reserved error codes within + the libburnia project. + @param msg_text Not more than 8196 characters of message text. + @param os_errno Eventual errno related to the message. Submit 0 if + the message is not related to a operating system error. + @param flag bit0-7= meaning of msg_text + ( 0= ERRFILE path , for internal use mainly ) + 1= mark line text (only to be put out if enabled) + @return <=0 error , >0 success +*/ +int Xorriso_process_errfile(struct XorrisO *xorriso, + int error_code, char msg_text[], int os_errno, + int flag); + + +/* The outlist stack allows to redirect the info and result messages from + their normal channels into a pair of string lists which can at some + later time be retrieved by the application. + These redirection caches can be stacked to allow stacked applications. + xorriso itself uses them for internal purposes. +*/ + +/* A list item able of forming double chained lists */ +struct Xorriso_lsT; + +/** Maximum number of stacked redirections */ +#define Xorriso_max_outlist_stacK 32 + +/** Enable a new redirection of info and/or result channel. The normal message + output and eventual older redirections will not see new messages until + the redirection is ended by a call to Xorriso_pull_outlists() with the + stack_handle value returned by this call. + Redirected output is not written to the files of Xorriso_option_logfile() + and the Xorriso_option_pkt_output() protocol will not be applied. + @param xorriso The environment handle + @param stack_handle returns an id number which is unique as long as + its redirection is stacked. It may be re-used after + its redirection was pulled from the stack. + @param flag Bitfield for control purposes + bit0= redirect result channel + bit1= redirect info channel + If bit0 and bit1 are 0, both channels get redirected. + @return 1 on success, <=0 if failure +*/ +int Xorriso_push_outlists(struct XorrisO *xorriso, int *stack_handle, + int flag); + + +/** Disable the redirection given by stack_handle. If it was the current + receiver of messages then switch output to the next older redirection + resp. to the normal channels if no redirections are stacked any more. + The messages collected by the disabled redirection are handed out as + two lists. Both lists have to be disposed via Xorriso_lst_destroy_all() + when they are no longer needed. + The message lists are either NULL or represented by their first + Xorriso_lsT item. + @param xorriso The environment handle + @param stack_handle The id number returned by Xorriso_push_outlists() + @param result_list Result and mark messages (usually directed to stdout) + @param info_list Info and mark messages (usually directed to stderr) + @param flag unused yet, submit 0 + @return 1 on success, <=0 if failure +*/ +int Xorriso_pull_outlists(struct XorrisO *xorriso, int stack_handle, + struct Xorriso_lsT **result_list, + struct Xorriso_lsT **info_list, int flag); + + +/** Obtain the text message from the current list item. + @param entry The current list item + @param flag unused yet, submit 0 + @return Pointer to the text content of the list item. + This pointer does not have to be freed. +*/ +char *Xorriso_lst_get_text(struct Xorriso_lsT *entry, int flag); + + +/** Obtain the address of the next item in the chain of messages. + An iteration over the output of Xorriso_pull_outlists() starts at the + returned result_list resp. info_list and ends when this function returns + NULL. + @param entry The current list item + @param flag unused yet, submit 0 + @return Pointer to the next list item or NULL if end of list. + This pointer does not have to be freed. +*/ +struct Xorriso_lsT *Xorriso_lst_get_next(struct Xorriso_lsT *entry, int flag); + + +/** Obtain the address of the previous item in the chain of messages. + @param entry The current list item + @param flag unused yet, submit 0 + @return Pointer to the previous list item or NULL if start of list. + This pointer does not have to be freed. +*/ +struct Xorriso_lsT *Xorriso_lst_get_prev(struct Xorriso_lsT *entry, int flag); + + +/** Destroy all list items which are directly or indirectly connected to + the given link item. + Apply this to each of the two list handles obtained by + Xorriso_pull_outlists() when the lists are no longer needed. + @param lstring *lstring will be freed and set to NULL. + It is not dangerous to submit a pointer to a NULL-pointer. + @param flag unused yet, submit 0 + @return -1= lstring was NULL (i.e. wrong use of this call), + 0= *lstring was already NULL, + 1= item actually disposed +*/ +int Xorriso_lst_destroy_all(struct Xorriso_lsT **lstring, int flag); + + + +/* ---------------------------- Options API ------------------------ */ +/* See man 1 xorriso for explanation of the particular options */ +/* + Before each call to an option function, there should happen: + Xorriso_set_problem_status() with empty severity text. + + After each call to an option function, there should happen: + Xorriso_eval_problem_status() + One should follow its eventual advice to abort. + + Options with a varying number of arguments get them passed like + Xorriso_interpreter(). E.g.: + int Xorriso_option_add(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag); + They begin to read the arguments at position *idx and will see the list + end either at the next argv which contains the -list_delimiter text or + at argv[argc-1]. After the call, *idx will be the index of the first not + yet interpreted argv. + +*/ + + +/* Option -abort_on */ +int Xorriso_option_abort_on(struct XorrisO *xorriso, char *severity, int flag); + + +/* Option -acl "on"|"off" */ +int Xorriso_option_acl(struct XorrisO *xorriso, char *mode, int flag); + + +/* Option -add */ +/* @param flag bit0=do not report the added item + bit1=do not reset pacifier, no final pacifier message +*/ +int Xorriso_option_add(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag); + +/* Option -add_plainly "on"|"off" */ +int Xorriso_option_add_plainly(struct XorrisO *xorriso, char *mode, + int flag); + + +/* Option -alter_date, alter_date_r */ +/* @param flag bit0=recursive (-alter_date_r) +*/ +int Xorriso_option_alter_date(struct XorrisO *xorriso, + char *time_type, char *timestring, + int argc, char **argv, int *idx, int flag); + +/* Option -application_id */ +int Xorriso_option_application_id(struct XorrisO *xorriso, char *name, + int flag); + +/* Option -as */ +/* @param flag bit0=do not report the added item + bit1=do not reset pacifier, no final pacifier message +*/ +int Xorriso_option_as(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag); + +/* Option -assert_volid */ +int Xorriso_option_assert_volid(struct XorrisO *xorriso, char *pattern, + char *severity, int flag); + +/* Option -auto_charset "on"|"off" */ +int Xorriso_option_auto_charset(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -backslash_codes */ +int Xorriso_option_backslash_codes(struct XorrisO *xorriso, char *mode, + int flag); + +/* Option -ban_stdio_write */ +int Xorriso_option_ban_stdio_write(struct XorrisO *xorriso, int flag); + +/* Option -blank and -format */ +/* @param flag bit0= format rather than blank + @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_blank(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -boot_image */ +int Xorriso_option_boot_image(struct XorrisO *xorriso, char *form, + char *treatment, int flag); + +/* Option -cd alias -cdi */ +int Xorriso_option_cdi(struct XorrisO *xorriso, char *iso_rr_path, int flag); + +/* Option -cdx */ +int Xorriso_option_cdx(struct XorrisO *xorriso, char *disk_path, int flag); + +/* Option -charset */ +/* @param flag bit0= set in_charset + bit1= set out_charset +*/ +int Xorriso_option_charset(struct XorrisO *xorriso, char *name, int flag); + +/* Options -check_md5 and -check_md5_r + @param flag bit0= issue summary message + bit1= do not reset pacifier, no final pacifier message + bit2= do not issue pacifier messages at all + bit3= recursive: -check_md5_r +*/ +int Xorriso_option_check_md5(struct XorrisO *xorriso, + int argc, char **argv, int *idx, int flag); + +/* Option -check_media */ +int Xorriso_option_check_media(struct XorrisO *xorriso, + int argc, char **argv, int *idx, int flag); + +/* Option -check_media_defaults */ +int Xorriso_option_check_media_defaults(struct XorrisO *xorriso, + int argc, char **argv, int *idx, int flag); + +/* Option -chgrp alias -chgrpi , chgrp_r alias chgrpi */ +/* @param flag bit0=recursive (-chgrp_r) +*/ +int Xorriso_option_chgrpi(struct XorrisO *xorriso, char *gid, + int argc, char **argv, int *idx, int flag); + +/* Option -chmod alias -chmodi , -chmod_r alias chmod_ri */ +/* @param flag bit0=recursive (-chmod_r) +*/ +int Xorriso_option_chmodi(struct XorrisO *xorriso, char *mode, + int argc, char **argv, int *idx, int flag); + +/* Option -chown alias -chowni , chown_r alias chown_ri */ +/* @param flag bit0=recursive (-chown_r) +*/ +int Xorriso_option_chowni(struct XorrisO *xorriso, char *uid, + int argc, char **argv, int *idx, int flag); + +/* Option -close "on"|"off" */ +int Xorriso_option_close(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -commit */ +/* @param flag bit0= leave indrive and outdrive aquired as they were, + i.e. do not aquire outdrive as new in-out-drive + bit1= do not perform eventual -reassure + @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_commit(struct XorrisO *xorriso, int flag); + +/* Option -commit_eject */ +/* @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_commit_eject(struct XorrisO *xorriso, char *which, int flag); + +/* Option -compare and -compare_r + @param flag bit0= issue summary message + bit1= do not reset pacifier, no final pacifier message + bit2= do not issue pacifier messages at all + bit3= recursive: -compare_r +*/ +int Xorriso_option_compare(struct XorrisO *xorriso, char *disk_path, + char *iso_path, int flag); + +/* Option -cpr alias -cpri */ +int Xorriso_option_cpri( struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag); + +/* Options -cpx , -cpax, -cp_rx , -cp_rax */ +/* @param flag bit0= recursive (-cp_rx, -cp_rax) + bit1= full property restore (-cpax, -cp_rax) +*/ +int Xorriso_option_cpx(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag); + +/* Option -cut_out */ +int Xorriso_option_cut_out(struct XorrisO *xorriso, char *disk_path, + char *start, char *count, char *iso_rr_path, int flag); + +/* Options -dev , -indev, -outdev */ +/* @param flag bit0=use as indev , bit1= use as outdev + @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_dev(struct XorrisO *xorriso, char *adr, int flag); + +/* Option -devices */ +/* @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_devices(struct XorrisO *xorriso, int flag); + +/* Option -dialog "on"|"off" */ +int Xorriso_option_dialog(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -disk_dev_ino "on"|"off" */ +int Xorriso_option_disk_dev_ino(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -disk_pattern "on"|"ls"|"off" */ +int Xorriso_option_disk_pattern(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -drive_class */ +int Xorriso_option_drive_class(struct XorrisO *xorriso, + char *d_class, char *pattern, int flag); + +/* Option -dummy "on"|"off" */ +int Xorriso_option_dummy(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -eject */ +/* @param flag bit0=do not report toc of eventually remaining drives +*/ +int Xorriso_option_eject(struct XorrisO *xorriso, char *which, int flag); + +/* Options -end , and -rollback_end */ +/* @param flag bit0= discard pending changes + @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_end(struct XorrisO *xorriso, int flag); + +/* Option -errfile_log marked|plain path|-|"" */ +int Xorriso_option_errfile_log(struct XorrisO *xorriso, + char *mode, char *path, int flag); + +/* Option -error_behavior */ +int Xorriso_option_error_behavior(struct XorrisO *xorriso, + char *occasion, char *behavior, int flag); + +/* Option -external_filter */ +int Xorriso_option_external_filter(struct XorrisO *xorriso, + int argc, char **argv, int *idx, int flag); + +/* Options -extract , -extract_single */ +/* @param flag bit0=do not report the restored item + bit1=do not reset pacifier, no final pacifier message + bit5= -extract_single: eventually do not insert directory tree +*/ +int Xorriso_option_extract(struct XorrisO *xorriso, char *disk_path, + char *iso_path, int flag); + +/* Option -extract_cut */ +int Xorriso_option_extract_cut(struct XorrisO *xorriso, char *iso_rr_path, + char *start, char *count, char *disk_path, int flag); + +/* Option -follow */ +int Xorriso_option_follow(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -find alias -findi, and -findx */ +/* @param flag bit0= -findx rather than -findi + bit1= do not reset pacifier, no final pacifier message + do not reset find_compare_result +*/ +int Xorriso_option_find(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag); + +/* Option -fs */ +int Xorriso_option_fs(struct XorrisO *xorriso, char *size, int flag); + +/* Option -getfacl alias -getfacli, -getfacl_r alias -getfacl_ri */ +/* @param flag bit0=recursive -getfacl_r +*/ +int Xorriso_option_getfacli(struct XorrisO *xorriso, + int argc, char **argv, int *idx, int flag); + +/* Option -gid */ +int Xorriso_option_gid(struct XorrisO *xorriso, char *gid, int flag); + +/* Option -grow_blindly */ +int Xorriso_option_grow_blindly(struct XorrisO *xorriso, char *msc2, int flag); + +/* Option -hardlinks "on"|"off" */ +int Xorriso_option_hardlinks(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -help and part of -prog_help */ +int Xorriso_option_help(struct XorrisO *xorriso, int flag); + +/* Option -history */ +int Xorriso_option_history(struct XorrisO *xorriso, char *line, int flag); + +/* Option -iso_rr_pattern "on"|"ls"|"off" */ +int Xorriso_option_iso_rr_pattern(struct XorrisO *xorriso, char *mode, + int flag); + +/* Option -joliet "on"|"off" */ +int Xorriso_option_joliet(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -list_delimiter */ +int Xorriso_option_list_delimiter(struct XorrisO *xorriso, char *text, + int flag); + +/* Option -list_formats */ +int Xorriso_option_list_formats(struct XorrisO *xorriso, int flag); + +/* Option -load session|track|sbsector value */ +/* @param flag bit0= with adr_mode sbsector: adr_value is possibly 16 too high + @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_load(struct XorrisO *xorriso, char *adr_mode, + char *adr_value, int flag); + +/* Option -logfile */ +int Xorriso_option_logfile(struct XorrisO *xorriso, char *channel, + char *fileadr, int flag); + +/* Options -ls alias -lsi and -lsl alias -lsli + and -lsd alias -lsdi and -lsdl alias -lsdli + and -du alias -dui and -dus alias -dusi + @param flag bit0= long format (-lsl , -du) + bit1= do not expand patterns but use literally + bit2= du rather than ls + bit3= list directories as themselves (ls -d) +*/ +int Xorriso_option_lsi(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag); + +/* Options -lsx, -lslx, -lsdx , -lsdlx , -dux , -dusx + @param flag bit0= long format (-lslx , -dux) + bit1= do not expand patterns but use literally + bit2= du rather than ls + bit3= list directories as themselves (ls -d) +*/ +int Xorriso_option_lsx(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag); + +/* Option -map */ +/* @param flag bit0=do not report the added item + bit1=do not reset pacifier, no final pacifier message +*/ +int Xorriso_option_map(struct XorrisO *xorriso, char *disk_path, + char *iso_path, int flag); + +/* Options -map_l , -compare_l , -update_l , -extract_l */ +/* @param flag bit8-11= mode 0= -map_l + 1= -compare_l + 2= -update_l + 3= -extract_l +*/ +int Xorriso_option_map_l(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag); + +/* Option -mark */ +int Xorriso_option_mark(struct XorrisO *xorriso, char *mark, int flag); + +/* Option -md5 */ +int Xorriso_option_md5(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -mkdir alias -mkdiri */ +int Xorriso_option_mkdiri(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag); + +/* Option -mount */ +/* @param bit0= print mount command to result channel rather than performing it +*/ +int Xorriso_option_mount(struct XorrisO *xorriso, char *dev, char *adr_mode, + char *adr, char *cmd, int flag); + + +/* Option -mv alias -mvi */ +int Xorriso_option_mvi(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag); + +/* Option -no_rc */ +int Xorriso_option_no_rc(struct XorrisO *xorriso, int flag); + +/* Option -not_leaf */ +int Xorriso_option_not_leaf(struct XorrisO *xorriso, char *pattern, int flag); + +/* Option -not_list , -quoted_not_list */ +/* @param flag bit0= -quoted_not_list */ +int Xorriso_option_not_list(struct XorrisO *xorriso, char *adr, int flag); + +/* Option -not_paths */ +int Xorriso_option_not_paths(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag); + +/* Option -options_from_file */ +/* @return <=0 error , 1 = success , 3 = request to end program run */ +int Xorriso_option_options_from_file(struct XorrisO *xorriso, char *adr, + int flag); + +/* Option -osirrox "on"|"off" */ +int Xorriso_option_osirrox(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -overwrite "on"|"nondir"|"off" */ +int Xorriso_option_overwrite(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -pacifier */ +int Xorriso_option_pacifier(struct XorrisO *xorriso, char *style, int flag); + +/* Option -padding */ +int Xorriso_option_padding(struct XorrisO *xorriso, char *size, int flag); + +/* Option -page */ +int Xorriso_option_page(struct XorrisO *xorriso, int len, int width, int flag); + +/* Option -paste_in */ +int Xorriso_option_paste_in(struct XorrisO *xorriso, char *iso_rr_path, + char *disk_path, char *start, char *count, int flag); + +/* Option -path_list , -quoted_path_list */ +/* @param flag bit0= -quoted_path_list */ +int Xorriso_option_path_list(struct XorrisO *xorriso, char *adr, int flag); + +/* Option -pathspecs */ +int Xorriso_option_pathspecs(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -pkt_output */ +int Xorriso_option_pkt_output(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -print */ +int Xorriso_option_print(struct XorrisO *xorriso, char *text, int flag); + +/* Option -print_size + @param flag bit0= report in mkisofs compatible form on real stdout +*/ +int Xorriso_option_print_size(struct XorrisO *xorriso, int flag); + +/* Option -prog */ +int Xorriso_option_prog(struct XorrisO *xorriso, char *name, int flag); + +/* Option -prog_help */ +int Xorriso_option_prog_help(struct XorrisO *xorriso, char *name, int flag); + +/* Option -publisher */ +int Xorriso_option_publisher(struct XorrisO *xorriso, char *name, int flag); + +/* Option -pwd alias -pwdi */ +int Xorriso_option_pwdi(struct XorrisO *xorriso, int flag); + +/* Option -pwdx */ +int Xorriso_option_pwdx(struct XorrisO *xorriso, int flag); + +/* Option -reassure "on"|"tree"|"off" */ +int Xorriso_option_reassure(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -relax_compliance */ +int Xorriso_option_relax_compliance(struct XorrisO *xorriso, char *mode, + int flag); + +/* Option -report_about */ +int Xorriso_option_report_about(struct XorrisO *xorriso, char *severity, + int flag); + +/* Option -return_with */ +int Xorriso_option_return_with(struct XorrisO *xorriso, char *severity, + int exit_value, int flag); + +/* Option -revoke_exclusions */ +int Xorriso_option_revoke_exclusions(struct XorrisO *xorriso, int flag); + +/* Options -rm alias -rmi , -rm_r alias -rm_ri , -rmdir alias -rmdiri */ +/* @param flag bit0=recursive , bit2= remove empty directory: rmdir */ +int Xorriso_option_rmi(struct XorrisO *xorriso, int argc, char **argv, + int *idx, int flag); + +/* Option -rollback */ +/* @param flag bit0= do not -reassure + @return <=0 error , 1 success, 2 revoked by -reassure +*/ +int Xorriso_option_rollback(struct XorrisO *xorriso, int flag); + +/* Option -rom_toc_scan */ +int Xorriso_option_rom_toc_scan(struct XorrisO *xorriso, char *mode, + int flag); + +/* Option -session_log */ +int Xorriso_option_session_log(struct XorrisO *xorriso, char *path, int flag); + +/* Option -setfacl_list alias -setfacl_listi */ +int Xorriso_option_setfacl_listi(struct XorrisO *xorriso, char *disk_path, + int flag); + +/* Option -setfacl alias -setfacli , -setfacl_r alias -setfacl_ri */ +/* @param flag bit0=recursive -setfacl_r +*/ +int Xorriso_option_setfacli(struct XorrisO *xorriso, char *acl_text, + int argc, char **argv, int *idx, int flag); + +/* Options -setfattr alias -setfattri, -setfattr_r alias -setfattr_ri */ +/* @param flag bit0=recursive -setfattr_r +*/ +int Xorriso_option_setfattri(struct XorrisO *xorriso, char *name, char *value, + int argc, char **argv, int *idx, int flag); + +/* Option -setfattr_list alias -setfattr_listi */ +int Xorriso_option_setfattr_listi(struct XorrisO *xorriso, char *path, + int flag); + +/* Options -set_filter , -set_filter_r */ +/* @param flag bit0=recursive -set_filter_r +*/ +int Xorriso_option_set_filter(struct XorrisO *xorriso, char *name, + int argc, char **argv, int *idx, int flag); + +/* Option -speed */ +int Xorriso_option_speed(struct XorrisO *xorriso, char *speed, int flag); + +/* Option -split_size */ +int Xorriso_option_split_size(struct XorrisO *xorriso, char *s, int flag); + +/* Option -status */ +int Xorriso_option_status(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -status_history_max */ +int Xorriso_option_status_history_max(struct XorrisO *xorriso, int num1, + int flag); + +/* Option -stream_recording */ +int Xorriso_option_stream_recording(struct XorrisO *xorriso, char *mode, + int flag); + +/* Option -tell_media_space */ +int Xorriso_option_tell_media_space(struct XorrisO *xorriso, int flag); + +/* Option -temp_mem_limit */ +int Xorriso_option_temp_mem_limit(struct XorrisO *xorriso, char *size, + int flag); + +/* Option -toc */ +int Xorriso_option_toc(struct XorrisO *xorriso, int flag); + +/* Option -uid */ +int Xorriso_option_uid(struct XorrisO *xorriso, char *uid, int flag); + +/* Option -unregister_filter */ +int Xorriso_option_unregister_filter(struct XorrisO *xorriso, char *name, + int flag); + +/* Options -update and -update_r + @param flag bit0= issue summary message + bit1= do not reset pacifier, no final pacifier message + bit2= do not issue pacifier messages at all + bit3= recursive: -update_r +*/ +int Xorriso_option_update(struct XorrisO *xorriso, char *disk_path, + char *iso_path, int flag); + +/* Option -use_readline */ +int Xorriso_option_use_readline(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -version */ +int Xorriso_option_version(struct XorrisO *xorriso, int flag); + +/* Option -volid */ +int Xorriso_option_volid(struct XorrisO *xorriso, char *volid, int flag); + +/* Option -xattr "on"|"off" */ +int Xorriso_option_xattr(struct XorrisO *xorriso, char *mode, int flag); + +/* Option -zisofs */ +int Xorriso_option_zisofs(struct XorrisO *xorriso, char *mode, int flag); + + +#endif /* Xorriso_includeD */ + + diff --git a/libisoburn/branches/ZeroFourTwo/xorriso/xorriso_buildstamp.h b/libisoburn/branches/ZeroFourTwo/xorriso/xorriso_buildstamp.h new file mode 100644 index 00000000..f2d17a20 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/xorriso/xorriso_buildstamp.h @@ -0,0 +1,3 @@ +#ifndef Xorriso_build_timestamP +#define Xorriso_build_timestamP "-none-given-" +#endif diff --git a/libisoburn/branches/ZeroFourTwo/xorriso/xorriso_buildstamp_none.h b/libisoburn/branches/ZeroFourTwo/xorriso/xorriso_buildstamp_none.h new file mode 100644 index 00000000..f2d17a20 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/xorriso/xorriso_buildstamp_none.h @@ -0,0 +1,3 @@ +#ifndef Xorriso_build_timestamP +#define Xorriso_build_timestamP "-none-given-" +#endif diff --git a/libisoburn/branches/ZeroFourTwo/xorriso/xorriso_eng.html b/libisoburn/branches/ZeroFourTwo/xorriso/xorriso_eng.html new file mode 100644 index 00000000..78395ed6 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/xorriso/xorriso_eng.html @@ -0,0 +1,642 @@ +<HTML> + +<HEAD> +<META NAME="description" CONTENT="xorriso, creates, loads, manipulates and writes ISO 9660 filesystem images with Rock Ridge extensions"> +<META NAME="keywords" CONTENT="xorriso, libburn, libburnia, burn, CD, DVD, ISO, ISO 9660, RockRidge, Rock Ridge, Linux, FreeBSD, recording, burning, CD-R, CD-RW, DVD-R, DVD-RW, DVD+RW, DVD+R, DVD+R DL, BD-RE, BD-R, scdbackup"> +<META NAME="robots" CONTENT="follow"> +<TITLE>xorriso homepage english + + + + + +
+

Homepage of

+

xorriso

+ +

ISO 9660 Rock Ridge Filesystem Manipulator for Linux and FreeBSD

+
+ +

+

Purpose:

+xorriso copies file objects from POSIX compliant filesystems +into Rock Ridge enhanced ISO 9660 filesystems and allows +session-wise manipulation of such filesystems. It can load the management +information of existing ISO images and it writes the session results to +optical media or to filesystem objects. +
+Vice versa xorriso is able to restore file objects from ISO 9660 filesystems. +

+

+ +


+ +Direct hop to download links -> + +

+

Hardware requirements:

+A CD/DVD/BD recorder suitable for +http://libburnia-project.org
+(SCSI , ATA , USB , or SATA writers compliant to standard MMC-3 for CD +and to MMC-5 for DVD or BD). +
+

+ +

+

Software requirements :

+
+
Linux with kernel 2.4 or higher, libc, libpthread :
+
With kernel 2.4 an ATA drive has to be under ide-scsi emulation.
+
With kernel 2.6 the drive should not be under ide-scsi.
+
or FreeBSD, libc, libpthread :
+
ATAPI/CAM support has to be enabled in the kernel, see atapicam(4).
+
libcam has to be installed.
+
libiconv has to be installed.
+
or some other X/Open system, libc, libpthread :
+
+There will be no direct operation of optical drives, but only POSIX i/o +with objects of the local filesystem. +
+
+Might work with DVD-RAM, DVD+RW, BD-RE +but rather not with CD, DVD-R, DVD+R, BD-R. +
+
+ +

Optional supporting software:

+
+
libreadline and libreadline-dev
+
eventually make dialog more convenient.
+
libacl and libacl-devel
+
eventually allow on Linux to get and set ACLs.
+
zlib and zlib-devel
+
eventually allow zisofs and gzip compression.
+
+

+ +

+This program has been tested on Linux, FreeBSD, and Solaris systems.
+For ports to other usable systems contact us. +

+ +
+ +

+

Special features:

+
    +
  • +ISO 9660 formatter and burner for CD, DVD, BD are fixely integrated. +
  • +
  • +Operates on an existing ISO image or creates a new one. +
  • +
  • +Copies files from filesystem into the ISO image and vice versa. +
  • +
  • +Changes file properties, renames or deletes file objects in the ISO image. +
  • +
  • +Updates ISO subtrees incrementally to match given disk subtrees. +
  • +
  • +Can record and restore hard link relations, ACL, and xattr. +
  • +
  • +File content may get zisofs or gzip compressed or filtered by external +processes. +
  • +
  • +Writes result as completely new image or as add-on session +to optical media or filesystem objects. +
  • +
  • +Can activate ISOLINUX boot images by El Torito boot record. +
  • +
  • +Can perform multi-session tasks as emulation of mkisofs and cdrecord. +
  • +
  • +Can issue commands to mount older sessions on Linux or FreeBSD. +
  • +
  • +Can check media for damages and copy readable blocks to disk. +
  • +
  • +Scans for optical drives, blanks re-useable optical media, formats media. +
  • +
  • +Suitable for: +CD-R, CD-RW, DVD-R, DVD-RW, DVD+R, DVD+R DL, DVD+RW, DVD-RAM, BD-R, BD-RE. +
  • +
  • +Reads its instructions from command line arguments, dialog, and batch files. +
  • +
  • +Provides navigation commands for interactive ISO image manipulation. +
  • + +
+

+ +

+

Command Examples:

+
+ +
Get an overview of drives and their addresses
+
# xorriso -devices
+
...
+
0 -dev '/dev/sr0' rwrw-- : 'TSSTcorp' 'CDDVDW SH-S203B'
+
1 -dev '/dev/scd1' rwrw-- : 'PHILIPS ' 'SPD3300L'
+
2 -dev '/dev/hda' rwrw-- : 'HL-DT-ST' 'DVD-ROM GDR8162B'
+
...
+
Being superuser avoids permission problems with /dev/srN resp. /dev/hdX . +
+
Ordinary users should then get granted rw access to the /dev files +as listed by option -devices.
+
 
+ +
Options are either performed as program arguments or as dialog input. +Some options have a parameter list of variable length. This list has to +be terminated by word '--' or by the end of the input line. Option -add +may accept pathspecs of form target=source as known from program mkisofs.
+ +
+ +
Get info about a particular drive and loaded media:
+
$ xorriso -indev /dev/sr0 -du / -- -toc 2>&1 | less
+ +
Make re-usable media writable again, delete any ISO 9660 image, +eventually prepare yet unused BD-RE:
+
$ xorriso -outdev /dev/sr0 -blank as_needed -eject all
+ +
+
+
+ +
Write some directories into a new or existing ISO 9660 image:
+
$ xorriso -dev /dev/sr0 -add /home/me/sounds /home/me/pictures +
+ +
Have a look at the result:
+
$ xorriso -indev /dev/sr0 -du / -- -toc 2>&1 | less
+ +
+
+
+ +
Create new ISO-9660 filesystem image, compose content, +adjust permissions to make it publicly read-only, +write it to media and immediately eject media without +previously reloading the written image. +
+
$ cd /home/me
+
$ xorriso -outdev /dev/sr0 -blank as_needed \
+
  -map /home/me/sounds /sounds \
+
  -map /home/me/pictures /pictures \
+
  -rm_r /sounds/indecent '/pictures/*private*' -- \
+
  -cd / \
+
  -add pictures/private/horses* -- \
+
  -chmod_r a+r,a-w / -- \
+
  -find / -type d -exec chmod a+x -- \
+
  -volid SOUNDS_PICS_2008_01_16 \
+
  -commit_eject all
+
+
+
+ +
Load the previous session from media, +remove (i.e. hide) directory /sounds, +rename /pictures/private/horses, +add new directory trees /sounds and /movies, +disallow any access for group and others. +Finally write as additional session to media and eject:
+
$ xorriso -dev /dev/sr0 \
+
  -rm_r /sounds -- \
+
  -mv /pictures/private/horses /horse_show -- \
+
  -map /home/me/prepared_for_dvd/sounds_dummy /sounds \
+
  -map /home/me/prepared_for_dvd/movies /movies \
+
  -chmod_r go-rwx / -- \
+
  -volid SOUNDS_PICS_2008_01_17 \
+
  -commit_eject all
+
+
+
+ +
Merge the various sessions from old readable media into a single session +on new writeable media, +cleaning out all invalidated files and session overhead. +Touch / in order to mark the image as worth to be written. +
+Important: -indev and -outdev have to be different drives. +
+
$ xorriso -indev /dev/dvd \
+
  -alter_date a +0 / -- \
+
  -outdev /dev/sr0 -blank fast \
+
  -commit_eject all
+ +
+
+
+ +
Dialog mode accepts one or more options per line. An option and all its +arguments have to be given in one single line. Backslash may be used to mark +a line as incomplete so it gets continued by the next input line. +
+Command -end stops the program run. It will write eventually pending changes +to media, if that has not already been done by a previous -commit.
+
$ xorriso -dialog on
+
enter option and arguments :
+
-dev /dev/sr0
+
enter option and arguments :
+
-map /home/me/prepared_for_dvd/sounds_dummy /sounds
+
enter option and arguments :
+
-map /home/me/prepared_for_dvd/movies \
+
Trailing backslash : Enter rest of line (or @@@ to clear it) : +
+
/movies
+
Available navigation commands: -cd, -ls, -du, -find
+
enter option and arguments :
+
-commit
+
... perform further commands and finally do:
+
enter option and arguments :
+
-end
+ +
+
+
+ +
The following command performs incremental backup. +It can be run on blank media to create a copy of the mentioned disk +directory trees, and it can be run on appendable media to perform a +minimal set of change operations which update the old ISO copies +to match the new disk trees. +Older states can be retrieved by help of mount options like "sbsector=" +or by help of xorriso option -mount. +
+Eventual ACL or xattr will be recorded. Data reading will be avoided by +accelerator option -disk_dev_ino. +Only blank media or media with volume id "PROJECTS_MAIL_..." will be accepted. +Files with names ending by ".o" or ".swp" are excluded by options -not_leaf. +
+
$ xorriso -acl on -xattr on -disk_dev_ino on \
+
   -assert_volid 'PROJECTS_MAIL_*' FATAL \
+
   -dev /dev/sr0 \
+
   -volid PROJECTS_MAIL_"$(date '+%Y_%m_%d_%H%M%S')" \
+
   -not_leaf '*.o' -not_leaf '*.swp' \
+
   -update_r /home/thomas/open_source_projects /open_source_projects \
+
   -update_r /home/thomas/personal_mail /personal_mail \
+
   -commit -toc -eject all
+ +
+To apply zisofs compression to those data files which get newly copied from +the local filesystem, perform immediately before -commit : +
+   -find / -type f -pending_data -exec set_filter --zisofs -- \
+ + + +
+
+
+ +
+Operating systems usually mount the most recent session on media. +xorriso can issue the appropriate mount commands for older sessions. +First get an overview of the sessions on the media: +
+
$ xorriso -outdev /dev/sr0 -toc
+
+TOC layout   : Idx ,  sbsector ,       Size , Volume Id
+ISO session  :   1 ,         0 ,    104719s , PROJECTS_MAIL_2008_08_10_231435
+ISO session  :   2 ,    106928 ,      6785s , PROJECTS_MAIL_2008_08_14_184548
+...
+ISO session  :  76 ,    820384 ,     11035s , PROJECTS_MAIL_2009_01_04_191150
+
+ +
+Then become superuser and let xorriso mount the session of August 14, 2008 +to directory /mnt: +
+
# + xorriso -osirrox on -mount /dev/sr0 volid '*_2008_08_14_*' /mnt +
+
+To be later unmounted by: umount /mnt +
+ +
+
+
+ +
+After the user has already created a suitable file tree on disk +and copied the ISOLINUX files into subdirectory ./boot/isolinux of +that tree, xorriso can burn an El Torito bootable media: +
+
$ xorriso -outdev /dev/sr0 -blank as_needed \
+
   -map /home/me/ISOLINUX_prepared_tree / \
+
   -boot_image isolinux dir=/boot/isolinux
+
+An additional MBR is generated if the file isolinux.bin is modern enough +(syslinux version 3.72) and ready for "isohybrid". An MBR enables booting +from hard disk or USB stick. +
+
+ +
ISO images may not only be stored on optical media but also in +regular disk files or block devices for full multi-session operation. +
+
$ xorriso -dev /tmp/regular_file ...other.options...
+
+A default setting for safety reasons requires that files below /dev/ +need prefix "stdio:" if they do not lead to MMC burner devices. +Be cautious not to overwrite your hard disk instead of your USB stick: +
+
$ xorriso -dev stdio:/dev/sdb ...other.options...
+ +
Other file types are suitable only for writing but not for reading:
+
$ xorriso -outdev /tmp/named_pipe ...other.options...
+ +
In batch mode it is possible to operate xorriso in a pipeline +with an external consumer of the generated ISO image. Any message +output will be redirected to stderr in this case. +Examples for consumers are cdrecord or growisofs on operating systems +where xorriso cannot operate the burner drive directly, +or a ssh pipe to another system which has the desired drive +and a suitable burn program.
+
$ xorriso -outdev - ...other.options... | consumer
+ + +
+
+
+ +
+Let xorriso serve underneath growisofs via its alias name "xorrisofs" +which enables mkisofs emulation: +
+
$ export MKISOFS="xorrisofs"
+
$ growisofs -Z /dev/dvd /some/files
+
$ growisofs -M /dev/dvd /more/files
+
+One may switch from mkisofs emulation to xorriso's own command mode: +
+
$ growisofs -M /dev/dvd -- outdev - -update_r /my/files /files +
+ +
+
+
+ +
If for any reason the reading operating system mishandles the ISO image +or some files in it, one may enable reverse operation of xorriso and copy +files or trees to disk: +
$ xorriso -acl on -xattr on \
+
   -indev /dev/sr0 \
+
   -osirrox on \
+
   -cpx '/pictures/private/horses*/*buttercup*' \
+
       /home/her/buttercup_dir -- \ +
   -extract /sounds /home/her/sounds_from_me
+ +
Consider to enter dialog mode and use commands like +-cd , -du , -lsl , -find. +
+
+
+ + +
Get overview of the options:
+
$ xorriso -help
+ +
Read the detailed manual page:
+
$ man xorriso
+
+ +

+ +
+ +

+

+

Download as source code (see README):

+
xorriso-0.4.0.pl01.tar.gz +(1270 KB). +
+
(Released 20 Jul 2009)
+
+ + +
Documentation:
+
README about installation and drive setup
+
xorriso -help gives an overview of options
+
man xorriso is the manual page
+
+ +
Contact:
+
Thomas Schmitt, scdbackup@gmx.net
+
libburn development mailing list, +libburn-hackers@pykix.org
+
+
License:
+
GPL version 2, +an Open Source approved license
+
 
+
+

+ +
+ +

+Bug fixes towards xorriso-0.3.8.pl00: +

    +
  • SIGSEGV by dereferencing NULL with option -status and no search string
  • +
  • -load volid did not perform pattern search
  • + + +
+ +

+ +

+Bug fix towards xorriso-0.4.0.pl00: +

    +
  • xorriso -as mkisofs did not understand the -C option of growisofs any more +
  • +
+ +

+ +

+Enhancements towards previous stable version xorriso-0.3.8.pl00: +

    +
  • New option -hardlinks for recording and restoring of hard link relations +
  • +
  • New option -for_backup as shortcut for -acl -xattr -hardlinks +
  • +
  • Improved read performance with -update_r +
  • +
  • Improved read performance with -extract by -osirrox sort_lba +
  • +
  • Operators with option -find : -not, -or, -and, (, ), -if, -then, -else
  • +
  • New -find tests -wholename, -prune, -sort_lba
  • + + +
+

+ +
+ +

+

+Library copies included in xorriso tarballs: +

+
+
libburn-0.6.7
+
reads and writes data from and to CD, DVD, BD.
+
(founded by Derek Foreman and Ben Jansens, +developed and maintained since August 2006 by +Thomas Schmitt from team of libburnia-project.org)
+
libisofs-0.6.21
+
operates on ISO 9660 filesystem images.
+
(By Vreixo Formoso, Mario Danic and Thomas Schmitt +from team of libburnia-project.org)
+
libisoburn-0.4.0
+
coordinates libburn and libisofs, emulates multi-session where needed.
+
(By Vreixo Formoso and Thomas Schmitt +from team of libburnia-project.org)
+
 
+
The source code of this software is independent of +cdrecord and mkisofs.
+
+

+ +
+ +

+

+

Development snapshot, version 0.4.1 :

+
Bug fixes towards xorriso-0.4.0.pl00: +
    +
  • xorriso -as mkisofs did not understand the -C option of growisofs any more +
  • + +
+
+
Enhancements towards stable version 0.4.0.pl01: +
    +
  • Options -lsl and -lsdl now display correct link counts if -hardlinks is on +
  • +
  • New option -md5, new -as mkisofs option --md5
  • +
  • New options -check_md5, -check_md5_r
  • +
  • New find actions check_md5 get_md5, get_any_xattr
  • +
  • New find tests -has_md5, -has_any_xattr
  • + + +
+
+
 
+
README 0.4.1 +
xorriso_0.4.1 -help
+
man xorriso (as of 0.4.1)
+
 
+
If you want to distribute development versions of xorriso, then use +this tarball which produces static linking between xorriso and the +libburnia libraries. +
+
Source (./bootstrap is already applied, build tested, +installation see README) +
+
+xorriso-0.4.1.tar.gz +(1280 KB). +
+
A dynamically linked development version of xorriso can be obtained +from repositories of + libburnia-project.org. +xorriso is part of libisoburn/trunk and will get built by its "make". +
+
Be warned that the libraries in SVN and bzr are development versions with +possibly unstable API/ABI enhancements. Do not distribute development +versions for dynamic linking. Only release versions are safe for that. +
+
Download: svn co http://svn.libburnia-project.org/libburn/trunk libburn +
+
Install: cd libburn ; ./bootstrap ; ./configure --prefix /usr ; make ; make install +
+
Download: +bzr branch lp:~libburnia-team/libisofs/scdbackup +
+
Install: cd libisofs ; ./bootstrap ; ./configure --prefix /usr ; make ; make install +
+
Download: svn co http://svn.libburnia-project.org/libisoburn/trunk libisoburn +
+
Install: cd libisoburn ; ./bootstrap ; ./configure --prefix /usr ; make ; make install +
+
Build of SVN versions needs +autotools of at least version 1.7 installed. +But after the run of ./bootstrap, only +vanilla tools like make and gcc are needed. +
+
 
+
+

+ +
+ +

+Many thanks to Derek Foreman and Ben Jansens for starting libburn. +
+Very special thanks to Andy Polyakov whose +dvd+rw-tools +provide the libburnia project with invaluable examples on how to deal +with DVD media and how to emulate multi-session on overwriteable media. +

+
+ + +
+ +

+Enjoying free Open Source hosting by www.webframe.org
+ +100 % Microsoft free
+and by sourceforge.net
+ +SourceForge Logo + +

+Enjoying a FreeBSD shell account with the opportunity to +build, install and test xorriso at
+free-shells.com.ar +

+
+
+
+
Links to my other published software projects :
+
+cdrskin, a cdrecord emulator
+
+scdbackup, multi volume CD backup
+
+(a second source of above)
+
Some Tools for Image Collectors
+
+pppoem, a DSL throughput monitor (mainly for Linux kernel 2.4)
+
+

+Legal statement: This website does not serve any commercial purpose.
+

+
+ + diff --git a/libisoburn/branches/ZeroFourTwo/xorriso/xorriso_makefile_am.txt b/libisoburn/branches/ZeroFourTwo/xorriso/xorriso_makefile_am.txt new file mode 100644 index 00000000..d79f440b --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/xorriso/xorriso_makefile_am.txt @@ -0,0 +1,252 @@ + +# ts A90315 : LIBBURNIA_PKGCONFDIR is defined OS specific in acinclude.m4 +# was: pkgconfigdir=$(libdir)/pkgconfig +pkgconfigdir=$(LIBBURNIA_PKGCONFDIR) + +libincludedir= + +lib_LTLIBRARIES = + +## ========================================================================= ## + +libinclude_HEADERS = + +## ========================================================================= ## + +bin_PROGRAMS = \ + xorriso/xorriso + +xorriso_xorriso_CPPFLAGS = -I./libburn -I./libisofs -I./libisoburn -I./xorriso + +# No readline in the vanilla version because the necessary headers +# are in a separate readline-development package. +xorriso_xorriso_CFLAGS = -DXorriso_standalonE -DXorriso_with_maiN \ + $(READLINE_DEF) $(LIBACL_DEF) $(XATTR_DEF) \ + $(EXTF_DEF) $(EXTF_SUID_DEF) $(ZLIB_DEF) + +xorriso_xorriso_LDADD = $(THREAD_LIBS) $(LIBBURN_ARCH_LIBS) + + +# This looks quite ugly with make install: xorriso.c is compiled twice again +# +# Trying to create a build timestamp file +# +# BUILT_SOURCES = xorriso/xorriso_buildstamp.h +# phony targets get rebuilt every time +# .PHONY: xorriso/xorriso_buildstamp.h +# xorriso/xorriso_buildstamp.h: +# date -u '+#define Xorriso_build_timestamP "%Y.%m.%d.%H%M%S"' >xorriso/xorriso_buildstamp.h +# cat xorriso/xorriso_buildstamp.h + + +xorriso_xorriso_SOURCES = \ + \ + xorriso/xorriso.h \ + xorriso/xorriso_private.h \ + xorriso/xorriso.c \ + xorriso/xorrisoburn.h \ + xorriso/xorrisoburn.c \ + xorriso/xorriso_timestamp.h \ + xorriso/xorriso_buildstamp.h \ + \ + libisoburn/libisoburn.h \ + libisoburn/isoburn.h \ + libisoburn/isoburn.c \ + libisoburn/isofs_wrap.c \ + libisoburn/burn_wrap.c \ + libisoburn/data_source.c \ + \ + libisofs/libisofs.h \ + libisofs/builder.h \ + libisofs/builder.c \ + libisofs/node.h \ + libisofs/node.c \ + libisofs/tree.h \ + libisofs/tree.c \ + libisofs/image.h \ + libisofs/image.c \ + libisofs/iso1999.h \ + libisofs/iso1999.c \ + libisofs/fsource.h \ + libisofs/fsource.c \ + libisofs/fs_local.c \ + libisofs/fs_image.c \ + libisofs/messages.h \ + libisofs/messages.c \ + libisofs/libiso_msgs.h \ + libisofs/libiso_msgs.c \ + libisofs/stream.h \ + libisofs/stream.c \ + libisofs/util.h \ + libisofs/util.c \ + libisofs/util_rbtree.c \ + libisofs/util_htable.c \ + libisofs/filesrc.h \ + libisofs/filesrc.c \ + libisofs/ecma119.h \ + libisofs/ecma119.c \ + libisofs/ecma119_tree.h \ + libisofs/ecma119_tree.c \ + libisofs/writer.h \ + libisofs/buffer.h \ + libisofs/buffer.c \ + libisofs/rockridge.h \ + libisofs/rockridge.c \ + libisofs/rockridge_read.c \ + libisofs/joliet.h \ + libisofs/joliet.c \ + libisofs/eltorito.h \ + libisofs/eltorito.c \ + libisofs/data_source.c \ + libisofs/find.c \ + libisofs/filter.h \ + libisofs/filter.c \ + libisofs/filters/external.c \ + libisofs/filters/zisofs.c \ + libisofs/filters/gzip.c \ + libisofs/system_area.h \ + libisofs/system_area.c \ + libisofs/make_isohybrid_mbr.c \ + libisofs/aaip_0_2.h \ + libisofs/aaip_0_2.c \ + libisofs/md5.h \ + libisofs/md5.c \ + \ + libburn/async.c \ + libburn/async.h \ + libburn/back_hacks.h \ + libburn/cleanup.c \ + libburn/cleanup.h \ + libburn/crc.c \ + libburn/crc.h \ + libburn/debug.c \ + libburn/debug.h \ + libburn/drive.c \ + libburn/drive.h \ + libburn/error.h \ + libburn/file.c \ + libburn/file.h \ + libburn/init.c \ + libburn/init.h \ + libburn/lec.c \ + libburn/lec.h \ + libburn/libburn.h \ + libburn/libdax_audioxtr.h \ + libburn/libdax_audioxtr.c \ + libburn/libdax_msgs.h \ + libburn/libdax_msgs.c \ + libburn/mmc.c \ + libburn/mmc.h \ + libburn/null.c \ + libburn/null.h \ + libburn/options.c \ + libburn/options.h \ + libburn/os.h \ + libburn/read.c \ + libburn/read.h \ + libburn/sbc.c \ + libburn/sbc.h \ + libburn/sector.c \ + libburn/sector.h \ + libburn/sg.c \ + libburn/sg.h \ + libburn/source.h \ + libburn/source.c \ + libburn/spc.c \ + libburn/spc.h \ + libburn/structure.c \ + libburn/structure.h \ + libburn/toc.c \ + libburn/toc.h \ + libburn/transport.h \ + libburn/util.c \ + libburn/util.h \ + libburn/write.c \ + libburn/write.h \ + \ + version.h + +noinst_PROGRAMS = \ + test/compare_file + +# A program to compare two trees of files in mounted filesystems +# To compare tree /media/dvd and /original/dir : +# find /media/dvd -exec test/compare_file '{}' /media/dvd /original/dir ';' +# +test_compare_file_CPPFLAGS = +test_compare_file_CFLAGS = +test_compare_file_LDADD = +test_compare_file_SOURCES = test/compare_file.c + + +# Install symbolic links to the xorriso binary +# +install-exec-hook: + if test -e "$(DESTDIR)$(bindir)"/xorrisofs ; then rm "$(DESTDIR)$(bindir)"/xorrisofs ; else echo ; fi + ln -s xorriso "$(DESTDIR)$(bindir)"/xorrisofs + if test -e "$(DESTDIR)$(bindir)"/osirrox ; then rm "$(DESTDIR)$(bindir)"/osirrox ; else echo ; fi + ln -s xorriso "$(DESTDIR)$(bindir)"/osirrox + if test -e "$(DESTDIR)$(bindir)"/xorrecord ; then rm "$(DESTDIR)$(bindir)"/xorrecord ; else echo ; fi + ln -s xorriso "$(DESTDIR)$(bindir)"/xorrecord + + + +# Alternative to the disabled .PHONY above. +# Trying to create a build timestamp file semi-manually: make buildstamped +# +buildstamp: + date -u '+#define Xorriso_build_timestamP "%Y.%m.%d.%H%M%S"' >xorriso/xorriso_buildstamp.h + cat xorriso/xorriso_buildstamp.h + +# For now make buildstamped has to be performed manually. +buildstamped: buildstamp + make + + +## ========================================================================= ## + +# Indent source files +indent_files = + + +indent: $(indent_files) + indent -bad -bap -nbbb -nbbo -nbc -bli0 -br -bls \ + -cdw -ce -cli0 -ncs -nbfda -i8 -l79 -lc79 \ + -lp -saf -sai -nprs -npsl -saw -sob -ss -ut \ + -sbi0 -nsc -ts8 -npcs -ncdb -fca \ + $^ + +.PHONY: indent + +## ========================================================================= ## + +# Extra things +# nodist_pkgconfig_DATA = \ +# xorriso.pc + +man_MANS = xorriso/xorriso.1 + +EXTRA_DIST = \ + xorriso.pc.in \ + version.h.in \ + README \ + AUTHORS \ + CONTRIBUTORS \ + COPYRIGHT \ + COPYING \ + INSTALL \ + xorriso/changelog.txt \ + xorriso/xorriso_buildstamp_none.h \ + $(man_MANS) \ + doc/susp_aaip_2_0.txt \ + doc/susp_aaip_isofs_names.txt \ + doc/zisofs_format.txt \ + libisofs/aaip-os-dummy.c \ + libisofs/aaip-os-linux.c \ + libisofs/aaip-os-freebsd.c \ + libburn/os-dummy.h \ + libburn/os-freebsd.h \ + libburn/os-linux.h \ + libburn/sg-dummy.c \ + libburn/sg-freebsd.c \ + libburn/sg-linux.c diff --git a/libisoburn/branches/ZeroFourTwo/xorriso/xorriso_pc_in.txt b/libisoburn/branches/ZeroFourTwo/xorriso/xorriso_pc_in.txt new file mode 100644 index 00000000..5e35e873 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/xorriso/xorriso_pc_in.txt @@ -0,0 +1,12 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: xorriso +Description: ISO 9660 filesystem image manipulator +Version: @VERSION@ +Requires: +Libs: -L${libdir} -lpthread +Cflags: + diff --git a/libisoburn/branches/ZeroFourTwo/xorriso/xorriso_private.h b/libisoburn/branches/ZeroFourTwo/xorriso/xorriso_private.h new file mode 100644 index 00000000..69fb5d68 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/xorriso/xorriso_private.h @@ -0,0 +1,1288 @@ + +/* Command line oriented batch and dialog tool which creates, loads, + manipulates and burns ISO 9660 filesystem images. + + Copyright 2007-2009 Thomas Schmitt, + + Provided under GPL version 2. + + This file contains inner declarations of xorriso. + The public interface is in xorriso.h +*/ + + +/* For now, #ifdef Xorriso_is_xorriso_selF has no meaning. + But it is already now to be set only by the xorriso.c module. +*/ + +#ifndef Xorriso_private_includeD +#define Xorriso_private_includeD yes + +/** The source code release timestamp */ +#include "xorriso_timestamp.h" +#ifndef Xorriso_timestamP +#define Xorriso_timestamP "-none-given-" +#endif + +/** The binary build timestamp is to be set externally by the compiler + or by a macro definition in xorriso_buildstamp.h. +*/ +#include "xorriso_buildstamp.h" +#ifndef Xorriso_build_timestamP +#define Xorriso_build_timestamP "-none-given-" +#endif + +#include + + +#define Smem_malloC malloc +#define Smem_freE free +#define SfileadrL 4096 + +struct LinkiteM; /* Trace of hops during symbolic link resolution */ +struct ExclusionS; /* List of -not_* conditions */ +struct PermiteM; /* Stack of temporarily altered access permissions */ +struct SpotlisT; /* List of intervals with different read qualities */ +struct CheckmediajoB; /* Parameters for Xorriso_check_media() */ +struct SectorbitmaP; /* Distiniction between valid and invalid sectors */ + + +/* maximum number of history lines to be reported with -status:long_history */ +#define Xorriso_status_history_maX 100 + +/* <<< ??? */ +/* try to catch signals and ignore them during abort handling */ +#define Xorriso_abort_handler_defaulT (1|(2<<4)) + + +/** The list of startup file names */ +#define Xorriso_rc_nuM 4 + + +/* Default setting for the size limit of single data files: + 100 extents with 4 GB - 2 kB each = 400 GB - 200 kB +*/ +#define Xorriso_default_file_size_limiT \ + (((off_t) 400) * ((off_t) 1024*1024*1024) - (off_t) 204800) + + +struct XorrisO { /* the global context of xorriso */ + + int libs_are_started; + + /* source */ + char progname[SfileadrL]; + char initial_wdx[SfileadrL]; + int no_rc; + + /* Command line argument emulations: + 0=xorriso mode + 1=mkisofs mode + 2=cdrecord mode + */ + int argument_emulation; + + /** List of startupfiles */ + char rc_filenames[Xorriso_rc_nuM][SfileadrL]; + int rc_filename_count; + + char wdi[SfileadrL]; + char wdx[SfileadrL]; + int did_something_useful; + + int add_plainly; + off_t split_size; + + char list_delimiter[81]; + + /* >>> put libisofs aspects here <<< */ + + int ino_behavior; /* bit0= at image load time: + Do not load PX inode numbers but generate new + unique ones for all loaded IsoNode. + bit1= at image generation time: + Do not consolidate suitable nodes to hardlinks. + bit2= at restore-to-disk time: + Do not consolidate suitable nodes to hardlinks. + bit3= with update: + Do not try to detect hardlink splits and joinings. + bit4= with extract: + Do not create or use hln arrays if sort_lba_on + */ + + int do_joliet; + + int do_aaip; /* bit0= ACL in + bit1= ACL out + bit2= EA in + bit3= EA out + bit4= record dev,inode per node, isofs_st_out in root + bit5= check dev,inode,isofs_st_in + bit6= omit content check if bit5 check is conclusive + bit7= omit dev check with bit5 + bit8= store output charset in xattr "isofs.cs" + bit9= allow to set input charset from xattr "isofs.cs" + */ + + int do_md5; /* bit0= read MD5 array + bit1= write session MD5 + bit2= write MD5 for each data file + bit3= make file content stability check by double reading + bit4= use recorded MD5 as proxy of ISO file + */ + + int relax_compliance; /* opaque bitfield to be set by xorrisoburn */ + int do_follow_pattern; + int do_follow_param; + int do_follow_links; + int follow_link_limit; + int do_follow_mount; + int do_global_uid; + uid_t global_uid; + int do_global_gid; + gid_t global_gid; + int do_global_mode; + mode_t global_dir_mode; + mode_t global_file_mode; + + struct Xorriso_lsT *filters; + int filter_list_closed; + + int zlib_level; + int zlib_level_default; + int zisofs_block_size; + int zisofs_block_size_default; + int zisofs_by_magic; + + int do_overwrite; /* 0=off, 1=on, 2=nondir */ + int do_reassure; /* 0=off, 1=on, 2=tree */ + + char volid[33]; + int volid_default; + char loaded_volid[33]; + char assert_volid[SfileadrL]; + char assert_volid_sev[80]; + + char publisher[129]; + char application_id[129]; + + char session_logfile[SfileadrL]; + int session_lba; + int session_blocks; + + /* >>> put libburn/isoburn aspects here */ + + struct Xorriso_lsT *drive_blacklist; + struct Xorriso_lsT *drive_greylist; + struct Xorriso_lsT *drive_whitelist; + + int toc_emulation_flag; /* bit0= bit3 for isoburn_drive_aquire() + scan -ROM profiles for ISO sessions + bit1= bit4 for isoburn_drive_aquire() + do not emulate TOC on overwriteable media + */ + + int image_start_mode; /* From what address to load the ISO image + bit0-15= addressing mode + 0= automatic lba as deduced from media + 1= value is session number + 2= value is track number + 3= value is lba + bit16= with mode 3 : value is possibly 16 too high. + Let isoburn_set_msc1() adjust it. + bit30= interference with normal msc1 processing + is enabled. Without this bit, + isoburn_set_msc1() will not be called. + bit31= image loading has happened, + setting is kept for rollback only. + Always apply as 0=auto. + */ + char image_start_value[81]; /* value according image_start_mode */ + + int do_calm_drive; /* bit0= calm down drive after aquiring it */ + + char indev[SfileadrL]; + void *in_drive_handle; /* interpreted only by xorrisoburn.c */ + void *in_volset_handle; /* interpreted only by xorrisoburn.c */ + char *in_charset; /* The charset to interpret the filename bytes */ + time_t isofs_st_out; /* A time point at least 1 second before image + composition began. To be stored with image as + xattr "isofs.st". */ + time_t isofs_st_in; /* That time point as read from "isofs.st" of the + loaded image. */ + + int volset_change_pending; /* whether -commit would make sense */ + int no_volset_present; /* set to 1 on first failure */ + + struct CheckmediajoB *check_media_default; + struct SectorbitmaP *in_sector_map; /* eventual sector validity bitmap */ + + + char outdev[SfileadrL]; + void *out_drive_handle; /* interpreted only by xorrisoburn.c */ + char *out_charset; /* The charset to produce the filename bytes for */ + int dev_fd_1; /* The fd which substitutes for /dev/fd/1 and is + connected to externaly perveived stdout. + */ + + int grow_blindly_msc2; /* if >= 0 this causes growing from drive to drive. + The value is used as block address offset for + image generation. Like in: mkisofs -C msc1,msc2 + */ + + int ban_stdio_write; + int do_dummy; + int do_close; + int speed; /* in libburn units : 1000 bytes/second , 0 = Max, -1 = Min */ + int fs; /* fifo size in 2048 byte chunks : at most 1 GB */ + int padding; /* number of bytes to add after ISO 9660 image */ + + int alignment; /* if > 0 : image size alignment in 2048 byt blocks */ + /* <<< not sure whether to keep this after libisofs will have + learned to pad up MBR images to full MB */ + + int do_stream_recording; /* 0=no, 1=yes, 2=for data, not for dir + >=16 means yes with number as start LBA */ + + int keep_boot_image; + int patch_isolinux_image; + char boot_image_bin_path[SfileadrL]; + int boot_image_emul; /* 0=no emulation + (1=emulation as hard disk) + (2=emulation as floppy) + */ + char boot_image_cat_path[SfileadrL]; + off_t boot_image_load_size; + int boot_image_isohybrid; /* 0=off , 1=auto , 2=on , 3=force */ + + /* LBA of boot image after image loading */ + int loaded_boot_bin_lba; + /* Path of the catalog node after image loading */ + char loaded_boot_cat_path[SfileadrL]; + + /* XORRISO options */ + int allow_graft_points; + + int allow_restore; /* -1=permanently disallowed + 0=disallowed, 1=allowed, 2=device files allowed */ + int do_concat_split; /* 1= restore complete split file directories as + regular files + */ + int do_auto_chmod; /* 1= eventually temporarily open access permissions + of self-owned directories during restore + */ + int do_restore_sort_lba; /* 1= restore via node_array rather than via + tree traversal. Better read performance, + no directory mtime restore, needs do_auto_chmod + */ + + int dialog; /* 0=off , 1=single-line , 2=multi-line */ + + int bsl_interpretation; + /* whether to run input through Sfile_bsl_interpreter(): + bit0-1= dialog and quoted file reading + 0= no interpretation, leave unchanged + 1= only inside double quotes + 2= outside single quotes + 3= everywhere + bit2-3= reserved as future expansion of bit0-1 + bit4= interpretation within program start arguments + bit5= perform backslash encoding with results + bit6= perform backslash encoding with info texts + */ + + /* Pattern matching facility. It still carries legacy from scdbackup/askme.c + but is fully functional for xorriso. + */ + int search_mode; + /* 0= start text + 1= fgrep , + 2= regular expression + 3= (eventually structured) shell parser expression + 4= shell parser expression for leaf name + */ + + int structured_search; + /* 0= flat text search + 1= '/' is a significant separator that cannot be matched by wildcards + ( 2= like 1 : but report only occurence in tree, no payload, no location ) + ( 3= like 2 : but report first content level of matching directories ) + 4= actually not structured but unique find mode (with search_mode 4) + */ + + int do_iso_rr_pattern; /* 0=off, 1=on, 2=ls */ + int do_disk_pattern; /* 0=off, 1=on, 2=ls */ + + int temp_mem_limit; + + off_t file_size_limit; + + struct ExclusionS *disk_exclusions; + int disk_excl_mode; /* bit0= on (else off) + bit1= parameter too (else rekursion only) + bit2= whole subtree banned (else only exact path) + bit3= when comparing ignore excluded files rather + than to treat them as truely missing on disk + */ + + int use_stdin; /* use raw stdin even if readline support is compiled */ + int result_page_length; + int result_page_width; + char mark_text[SfileadrL]; /* ( stdout+stderr, M: ) */ + int packet_output; + char logfile[4][SfileadrL]; + FILE *logfile_fp[4]; + FILE *pktlog_fp; + struct Xorriso_lsT *result_msglists[Xorriso_max_outlist_stacK]; + struct Xorriso_lsT *info_msglists[Xorriso_max_outlist_stacK]; + int msglist_flags[Xorriso_max_outlist_stacK]; /* bit0= result is redirected + bit1= info is redirected + */ + int msglist_stackfill; + + int status_history_max; /* for -status long_history */ + + + char report_about_text[20]; + int report_about_severity; + int library_msg_direct_print; + char abort_on_text[20]; + int abort_on_severity; /* A severity rank number as threshold */ + int problem_status; /* Severity rank number. 0= no abort condition present */ + char problem_status_text[20]; + + char errfile_log[SfileadrL]; /* for -errfile_log */ + int errfile_mode; /* bit0= marked */ + FILE *errfile_fp; + + int img_read_error_mode; /* 0=best_effort , 1=failure , 2=fatal */ + int extract_error_mode; /* 0=best_effort , 1=keep , 2=delete */ + + char return_with_text[20]; + int return_with_severity; + int return_with_value; + int eternal_problem_status; + char eternal_problem_status_text[20]; + + /* temporary search facilities */ + regex_t *re; + regmatch_t match[1]; + char **re_constants; + int re_count; + int re_fill; + char reg_expr[2*SfileadrL]; + + /* run state */ + int run_state; /* 0=preparing , 1=writing image */ + int is_dialog; + int bar_is_fresh; + char pending_option[SfileadrL]; /* eventual option entered at page prompt */ + int request_to_abort; /* abort a single operation like -ls, not the program */ + int request_not_to_ask; /* suppress reassure and pager */ + double idle_time; + int re_failed_at; /* mismatch position with structured_search */ + int prepended_wd; + double insert_count; + double insert_bytes; + double error_count; /* double will not roll over */ + + /* pacifiers */ + int pacifier_style; /* 0= xorriso, 1=mkisofs 2=cdrecord */ + double pacifier_interval; + double start_time; + double last_update_time; + /* optional global counters for brain reduced callback functions */ + off_t pacifier_count; + off_t pacifier_total; + off_t pacifier_byte_count; /* auxiliary counter for data bytes */ + + void *pacifier_fifo; + + int find_compare_result; /* 1=everything matches , 0=mismatch , -1=error */ + int find_check_md5_result; /* bit0= seen mismatch + bit1= seen error + bit2= seen data file without MD5 + bit3= seen match + */ + + /* Tree node collection and LBA sorting facility */ + int node_counter; + int node_array_size; + void **node_array; + struct Xorriso_lsT *node_disk_prefixes; + struct Xorriso_lsT *node_img_prefixes; + + /* Hardlink matching at restore time memorizes hardlink target paths. + Array of nodes sorted by LBA. */ + int hln_count; + void **hln_array; + void **hln_targets; + int hln_change_pending; /* whether a change was made since hln creation */ + + /* >>> this should count all temp_mem and thus change its name */ + off_t node_targets_availmem; + + /* Hardlink matching at update time: + Array of all nodes in the tree, sorted by disk dev,ino. + Bitmap of nodes which possibly got new hardlink siblings. + List of involved disk-iso path pairs. */ + int di_count; + void **di_array; + char *di_do_widen; + struct Xorriso_lsT *di_disk_paths; + struct Xorriso_lsT *di_iso_paths; + + struct PermiteM *perm_stack; /* Temporarily altered dir access permissions */ + + /* result (stdout, R: ) */ + char result_line[10*SfileadrL]; + int result_line_counter; + int result_page_counter; + int result_open_line_len; + + + /* info (stderr, I:) */ + char info_text[10*SfileadrL]; + +}; + + +/* @param flag bit0= do not set hln_change_pending */ +int Xorriso_set_change_pending(struct XorrisO *xorriso, int flag); + +int Xorriso_prepare_regex(struct XorrisO *xorriso, char *adr, int flag); + +int Xorriso_result(struct XorrisO *xorriso, int flag); + +int Xorriso_info(struct XorrisO *xorriso, int flag); + +int Xorriso_request_confirmation(struct XorrisO *xorriso, int flag); + +/* @return 0=match , else no match +*/ +int Xorriso_regexec(struct XorrisO *xorriso, char *to_match, int *failed_at, + int flag); + +int Xorriso_prepare_expansion_pattern(struct XorrisO *xorriso, char *pattern, + int flag); + +int Xorriso__mode_to_perms(mode_t st_mode, char perms[11], int flag); + +int Xorriso_much_too_long(struct XorrisO *xorriso, int len, int flag); + +int Xorriso_check_temp_mem_limit(struct XorrisO *xorriso, off_t mem, int flag); + +int Xorriso_eval_nonmatch(struct XorrisO *xorriso, char *pattern, + int *nonconst_mismatches, off_t *mem, int flag); + +/* @param flag bit0= a match count !=1 is a SORRY event +*/ +int Xorriso_check_matchcount(struct XorrisO *xorriso, + int count, int nonconst_mismatches, int num_patterns, + char **patterns, int flag); + +int Xorriso_no_pattern_memory(struct XorrisO *xorriso, off_t mem, int flag); + +int Xorriso_alloc_pattern_mem(struct XorrisO *xorriso, off_t mem, + int count, char ***filev, int flag); + +/* @param flag bit0= count results rather than storing them + @return <=0 error , 1 is root (end processing) , + 2 is not root (go on processing) +*/ +int Xorriso_check_for_root_pattern(struct XorrisO *xorriso, + int *filec, char **filev, int count_limit, off_t *mem, int flag); + +/* @param flag bit0= prepend wd only if name does not begin by '/' + bit2= prepend wd (automatically done if wd[0]!=0) +*/ +int Xorriso_make_abs_adr(struct XorrisO *xorriso, char *wd, char *name, + char adr[], int flag); + +/* @param flag bit0= count result rather than storing it + bit1= unexpected change of number is a FATAL event +*/ +int Xorriso_register_matched_adr(struct XorrisO *xorriso, + char *adr, int count_limit, + int *filec, char **filev, off_t *mem, int flag); + +int Xorriso_format_ls_l(struct XorrisO *xorriso, struct stat *stbuf, int flag); + +/* @param flag bit0= simple readlink(): no normalization, no multi-hop +*/ +int Xorriso_resolve_link(struct XorrisO *xorriso, + char *link_path, char result_path[SfileadrL], int flag); + +/* @param flag bit0= for Xorriso_msgs_submit: use pager +*/ +int Xorriso_hop_link(struct XorrisO *xorriso, char *link_path, + struct LinkiteM **link_stack, struct stat *stbuf, int flag); + +/* reg_expr should be twice as large as bourne_expr ( + 2 to be exact) */ +/* return: 2= bourne_expr is surely a constant */ +int Xorriso__bourne_to_reg(char bourne_expr[], char reg_expr[], int flag); + +int Xorriso_no_malloc_memory(struct XorrisO *xorriso, char **to_free, + int flag); + +int Xorriso_pacifier_reset(struct XorrisO *xorriso, int flag); + +/* This call is to be issued by long running workers in short intervals. + It will check whether enough time has elapsed since the last pacifier + message and eventually issue an update message. + @param what_done A sparse description of the action, preferrably in past + tense. E.g. "done" , "files added". + @param count The number of objects processed so far. + Is ignored if <=0. + @param todo The number of objects to be done in total. + Is ignored if <=0. + @param current_object A string telling the object currently processed. + Ignored if "". + @param flag bit0= report unconditionally, no time check +*/ +int Xorriso_pacifier_callback(struct XorrisO *xorriso, char *what_done, + off_t count, off_t todo, char *current_object, + int flag); + +int Xorriso_pfx_disk_path(struct XorrisO *xorriso, char *iso_path, + char *iso_prefix, char *disk_prefix, + char disk_path[SfileadrL], int flag); + +/* @param boss_iter Opaque handle to be forwarded to actions in ISO image + Set to NULL if calling this function from outside ISO world + @param flag bit0= update rather than compare +*/ +int Xorriso_find_compare(struct XorrisO *xorriso, void *boss_iter, + char *iso_path, char *iso_prefix, char *disk_prefix, + int flag); + +/* @param boss_iter Opaque handle to be forwarded to actions in ISO image + Set to NULL if calling this function from outside ISO world +*/ +int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter, + int compare_result, char *disk_path, + char *iso_rr_path, int flag); + +int Xorriso_path_is_excluded(struct XorrisO *xorriso, char *path, int flag); + +/* @param flag bit0= long format + bit1= do not print count of nodes + bit2= du format + bit3= print directories as themselves (ls -d) +*/ +int Xorriso_lsx_filev(struct XorrisO *xorriso, char *wd, + int filec, char **filev, off_t boss_mem, int flag); + +/* + @param flag >>> bit0= remove whole sub tree: rm -r + bit1= remove empty directory: rmdir + bit2= recursion: do not reassure in mode 2 "tree" + bit3= this is for overwriting and not for plain removal + bit4= count deleted files in xorriso->pacifier_count + bit5= with bit0 only remove directory content, not the directory + @return <=0 = error + 1 = removed leaf file object + 2 = removed directory or tree + 3 = did not remove on user revocation +*/ +int Xorriso_rmx(struct XorrisO *xorriso, off_t boss_mem, char *path, int flag); + + +/* @param flag bit7= return 4 if restore fails from denied permission + do not issue error message + @return <=0 failure , 1 success , + 4 with bit7: permission to create file was denied +*/ +int Xorriso_make_tmp_path(struct XorrisO *xorriso, char *orig_path, + char *tmp_path, int *fd, int flag); + +/* @param flag bit0= path is a directory + bit2= recursion: do not reassure in mode 2 "tree" + bit3= this is for overwriting and not for plain removal +*/ +int Xorriso_reassure_restore(struct XorrisO *xorriso, char *path, int flag); + + +/* @param flag bit0= change regardless of xorriso->do_auto_chmod + bit1= desired is only rx +*/ +int Xorriso_auto_chmod(struct XorrisO *xorriso, char *disk_path, int flag); + +int Xorriso_make_accessible(struct XorrisO *xorriso, char *disk_path,int flag); + +/* @param flag bit0= prefer to find a match after *img_prefixes + (but deliver img_prefixes if no other can be found) +*/ +int Xorriso_make_restore_path(struct XorrisO *xorriso, + struct Xorriso_lsT **img_prefixes, struct Xorriso_lsT **disk_prefixes, + char img_path[SfileadrL], char disk_path[SfileadrL], int flag); + +int Xorriso_restore_make_hl(struct XorrisO *xorriso, + char *old_path, char *new_path, int flag); + + +int Xorriso_protect_stdout(struct XorrisO *xorriso, int flag); + + +/* @param flag bit0= mark untested areas as valid +*/ +int Xorriso_spotlist_to_sectormap(struct XorrisO *xorriso, + struct SpotlisT *spotlist, + int read_chunk, + struct SectorbitmaP **map, + int flag); + +int Xorriso_toc_to_string(struct XorrisO *xorriso, char **toc_text, int flag); + + +/* @param flag bit0+1= what to aquire after giving up outdev + 0=none, 1=indev, 2=outdev, 3=both +*/ +int Xorriso_reaquire_outdev(struct XorrisO *xorriso, int flag); + + +/* Opens the -check_media data copy in for reading and writing +*/ +int Xorriso_open_job_data_to(struct XorrisO *xorriso, + struct CheckmediajoB *job, int flag); + +int Xorriso_no_findjob(struct XorrisO *xorriso, char *cmd, int flag); + + +int Xorriso_make_mount_cmd(struct XorrisO *xorriso, char *cmd, + int lba, int track, int session, char *volid, + char *devadr, char result[SfileadrL], int flag); + + +/* @param flag bit0= use env_path to find the desired program +*/ +int Xorriso_execv(struct XorrisO *xorriso, char *cmd, char *env_path, + int *status, int flag); + +int Xorriso_is_in_patternlist(struct XorrisO *xorriso, + struct Xorriso_lsT *patternlist, char *path, int flag); + +char *Xorriso_get_pattern(struct XorrisO *xorriso, + struct Xorriso_lsT *patternlist, int index, int flag); + + +/* Normalize ACL and sort apart "access" ACL from "default" ACL. + */ +int Xorriso_normalize_acl_text(struct XorrisO *xorriso, char *in_text, + char **access_acl_text, char **default_acl_text, 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_status_result(struct XorrisO *xorriso, char *filter, FILE *fp, + int flag); + +int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr, + char *iso_adr, char *adr_common_tail, + int *result, int flag); + +int Xorriso_report_md5_outcome(struct XorrisO *xorriso, char *severity, + int flag); + + +int Sfile_str(char target[SfileadrL], char *source, int flag); + +double Sfile_microtime(int flag); + +int Sfile_add_to_path(char path[SfileadrL], char *addon, int flag); + +int Sfile_scale(double value, char *result, int siz, double thresh, int flag); + +int Sfile_destroy_argv(int *argc, char ***argv, int flag); + +/* + bit0= do not ignore trailing slash + bit1= do not ignore empty components (other than the empty root name) +*/ +int Sfile_count_components(char *path, int flag); + +/* + @param flag + bit0= return -1 if file is missing + bit1= return a hardlink with siblings as type 5 + bit2= evaluate eventual link target rather than the link object itself + bit3= return a socket or a char device as types 7 or 8 rather than 0 + @return + 0=unknown + 1=regular + 2=directory + 3=symbolic link + 4=named pipe + 5=multiple hardlink (with bit1) + 6=block device + 7=socket (with bit3) + 8=character device (with bit3) +*/ +int Sfile_type(char *filename, int flag); + +/* @param flag bit0= only encode inside quotes + bit1= encode < 32 outside quotes except 7, 8, 9, 10, 12, 13 + bit2= encode in any case above 126 + bit3= encode in any case shellsafe: + <=42 , 59, 60, 62, 63, 92, 94, 96, >=123 +*/ +int Sfile_bsl_encoder(char **result, char *text, size_t text_len, int flag); + +int Sfile_argv_bsl(int argc, char ***argv, int flag); + + +struct Xorriso_lsT { + char *text; + struct Xorriso_lsT *prev,*next; +}; + +/** Create a new list item with arbitrary byte content. + @param lstring The newly created object or NULL on failure + @param data An array of bytes to be copied into the new object + @param data_len Number of bytes to be copied + @param link Xorriso_lsT object to which the new object shall be linked + @param flag Bitfield for control purposes + bit0= insert before link rather than after it + bit1= do not copy data (e.g. because *data is invalid) + bit2= attach data directly by pointer rather than by copying + @return <=0 error, 1 ok +*/ +int Xorriso_lst_new_binary(struct Xorriso_lsT **lstring, char *data, + int data_len, struct Xorriso_lsT *link, int flag); + + +/** Create a new list item with a 0-terminated text as content. + @param lstring The newly created object or NULL on failure + @param text A 0-terminated array of bytes + @param link Xorriso_lsT object to which the new object shall be linked + @param flag see Xorriso_lst_new_binary + @return <=0 error, 1 ok +*/ +int Xorriso_lst_new(struct Xorriso_lsT **lstring, char *text, + struct Xorriso_lsT *link, int flag); + + +/** Create a new list item at the end of a given list. + @param entry Contains as input a pointer to a pointer to any existing + list item. As output this list item pointer may be + changed to the address of the new list item: + if ((*entry == 0) || (flag & 1)) + @param data An array of bytes to be copied into the new object + @param data_len Number of bytes to be copied + @param flag Bitfield for control purposes + bit0= Return new object address in *entry + bit1= do not copy data (e.g. because *data is invalid) + bit2= attach data directly by pointer rather than by copying + @return <=0 error, 1 ok +*/ +int Xorriso_lst_append_binary(struct Xorriso_lsT **entry, + char *data, int data_len, int flag); + + +/** Destroy a single list item and connect its eventual list neighbors. + @param lstring pointer to the pointer to be freed and set to NULL + @param flag unused yet, submit 0 + @return 0= *lstring was alredy NULL, 1= ok +*/ +int Xorriso_lst_destroy(struct Xorriso_lsT **lstring, int flag); + + +struct Xorriso_lsT *Xorriso_lst_get_next(struct Xorriso_lsT *entry, int flag); + +struct Xorriso_lsT *Xorriso_lst_get_prev(struct Xorriso_lsT *entry, int flag); + +char *Xorriso_lst_get_text(struct Xorriso_lsT *entry, int flag); + +int Xorriso_lst_detach_text(struct Xorriso_lsT *entry, int flag); + + +char *Text_shellsafe(char *in_text, char *out_text, int flag); + +int Sort_argv(int argc, char **argv, int flag); + +/* @param flag bit0= single letters */ +char *Ftypetxt(mode_t st_mode, int flag); + +/* @param flag bit0=with year and seconds + bit1=timestamp format YYYY.MM.DD.hhmmss +*/ +char *Ftimetxt(time_t t, char timetext[40], int flag); + +int System_uname(char **sysname, char **release, char **version, + char **machine, int flag); + + +struct DirseQ; + +int Dirseq_new(struct DirseQ **o, char *adr, int flag); + +int Dirseq_destroy(struct DirseQ **o, int flag); + +int Dirseq_next_adr(struct DirseQ *o, char reply[SfileadrL], int flag); + + +int Linkitem_reset_stack(struct LinkiteM **o, struct LinkiteM *to, int flag); + + + + +#define Xorriso_findjob_on_expR yes + +#ifdef Xorriso_findjob_on_expR + +/* + A single Testnode. +*/ +struct ExprtesT { + + struct FindjoB *boss; + + int invert; /* 0=normal 1=invert result */ + + /* + 0= -false (with invert : -true) + 1= -name char *arg1 (regex_t in *arg2) + 2= -type char *arg1 + 3= -damaged + 4= -lba_range int *arg1 int *arg2 + 5= -has_acl + 6= -has_xattr + 7= -has_aaip + 8= -has_filter + 9= -wanted_node IsoNode *arg1 (for internal use, arg1 not allocated) + 10= -pending_data + 11= -decision char *arg1 ("yes", "no") + 12= -prune + 13= -wholename char *arg1 (regex_t in *arg2) + 14= -has_any_xattr + 15= -has_md5 + */ + int test_type; + + void *arg1; + void *arg2; + +}; + + +/* + A computational node. + A tree of these nodes forms the expression. + Sequences of AND/OR operations form branches, brackets spawn new branches, + NOT inverts node's test resp. subtree result. +*/ +struct ExprnodE { + + struct ExprnodE *up; + + char origin[8]; + + /* Operators */ + int invert; /* 0=normal 1=invert own result (subtree or test, but not op) */ + + int assoc; /* + 0= left : compute own value, combine with left value, + compute right value, combine with current value + 1= right: compute own value, compute right value, + combine own and right, combine with left value + */ + + int use_shortcuts; /* 0= evaluate all tests of -and and -or, + 1= evaluate only until the combined result is known + */ + + struct ExprnodE *left; + int left_op; /* 0=OR , 1=AND */ + + struct ExprnodE *right; + int right_op; /* see left_op */ + + /* Brackets : a pointer to the first node in a subchain */ + struct ExprnodE *sub; + + int is_if_then_else; + struct ExprnodE *true_branch; + struct ExprnodE *false_branch; + + /* elementary test : if sub!=NULL , test is ignored */ + struct ExprtesT *test; + + /* Result */ + int own_value; + int composed_value; + +}; + + +struct FindjoB { + + char *start_path; + + struct ExprnodE *test_tree; + + struct ExprnodE *cursor; + int invert; /* 0=normal 1=set invert-property for next new test node */ + int use_shortcuts; + + /* 0= echo + 1= rm (also rmdir) + 2= rm_r +>>> 3= mv target + 4= chown user + 5= chgrp group + 6= chmod mode_and mode_or + 7= alter_date type date + 8= lsdl + 9= chown_r user + 10= chgrp_r group + 11= chmod_r mode_and mode_or + 12= alter_date_r type date + 13= find + 14= compare disk_equivalent_of_start_path + 15= in_iso iso_rr_equivalent_of_start_path + 16= not_in_iso iso_rr_equiv + 17= update disk_equiv + 18= add_missing iso_rr_equiv + 19= empty_iso_dir iso_rr_equiv + 20= is_full_in_iso iso_rr_equiv + 21= report_damage + 22= report_lba + 23= internal: memorize path of last matching node in found_path + 24= getfacl + 25= setfacl access_acl default_acl + 26= getfattr + 27= setfattr + 28= set_filter name + 29= show_stream + 30= internal: count by xorriso->node_counter + 31= internal: register in xorriso->node_array + 32= internal: widen_hardlinks disk_equiv: update nodes marked in di_do_widen + 33= get_any_xattr + 34= get_md5 + 35= check_md5 + 36= make_md5 + */ + int action; + int prune; + + /* action specific parameters */ + char *target; + char *text_2; + uid_t user; + gid_t group; + mode_t mode_and, mode_or; + int type; /* see Xorriso_set_time flag */ + time_t date; + char *found_path; + struct FindjoB *subjob; + + /* Errors */ + char errmsg[4096]; + int errn; /* + >0 = UNIX errno + -1 = close_bracket: no bracket open + -2 = binary operator or closing bracket expected + -3 = unexpected binary operator or closing bracket + -4 = unsupported command + -5 = -then -elseif -else -endif without -if or at wrong place + */ +}; + + +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 Exprnode_destroy(struct ExprnodE **fnode, int flag); + +int Exprnode_tree_value(struct XorrisO *xorriso, struct ExprnodE *fnode, + int left_value, void *node, char *name, char *path, + struct stat *boss_stbuf, struct stat *stbuf, int flag); + + +int Findjob_new(struct FindjoB **o, char *start_path, int flag); + +int Findjob_destroy(struct FindjoB **o, int flag); + +int Findjob_set_start_path(struct FindjoB *o, char *start_path, int flag); + +int Findjob_get_start_path(struct FindjoB *o, char **start_path, int flag); + +int Findjob_set_commit_filter_2(struct FindjoB *o, int flag); + +int Findjob_set_lba_range(struct FindjoB *o, int start_lba, int count, + int flag); + +int Findjob_set_wanted_node(struct FindjoB *o, void *wanted_node, int flag); + +int Findjob_set_decision(struct FindjoB *o, char *decision, int flag); + +int Findjob_open_bracket(struct FindjoB *job, int flag); + +int Findjob_close_bracket(struct FindjoB *job, int flag); + +int Findjob_not(struct FindjoB *job, int flag); + +int Findjob_and(struct FindjoB *job, int flag); + +int Findjob_or(struct FindjoB *job, int flag); + +int Findjob_if(struct FindjoB *job, int flag); + +int Findjob_then(struct FindjoB *job, int flag); + +int Findjob_else(struct FindjoB *job, int flag); + +int Findjob_elseif(struct FindjoB *job, int flag); + +int Findjob_endif(struct FindjoB *job, int flag); + +int Findjob_test_2(struct XorrisO *xorriso, struct FindjoB *o, + void *node, char *name, char *path, + struct stat *boss_stbuf, struct stat *stbuf, int flag); + +int Findjob_set_action_found_path(struct FindjoB *o, int flag); + +/* @param flag bit0= recursive +*/ +int Findjob_set_action_target(struct FindjoB *o, int action, char *target, + int flag); +int Findjob_get_action(struct FindjoB *o, int flag); + +int Findjob_get_action_parms(struct FindjoB *o, char **target, char **text_2, + uid_t *user, gid_t *group, + mode_t *mode_and, mode_t *mode_or, + int *type, time_t *date, struct FindjoB **subjob, + int flag); + +int Findjob_set_found_path(struct FindjoB *o, char *path, int flag); + +int Findjob_get_found_path(struct FindjoB *o, char **path, int flag); + +#else /* Xorriso_findjob_on_expR */ + + +struct FindjoB; + + +int Findjob_new(struct FindjoB **o, char *start_path, int flag); + +int Findjob_destroy(struct FindjoB **job, int flag); + + +/* @return 0=no match , 1=match , <0 = error +*/ +int Findjob_test(struct FindjoB *job, char *name, + struct stat *boss_stbuf, struct stat *stbuf, + int depth, int flag); + +/* @return <0 error, >=0 see xorriso.c struct FindjoB.action +*/ +int Findjob_get_action(struct FindjoB *o, int flag); + +/* @return <0 error, >=0 see xorriso.c struct FindjoB.action +*/ +int Findjob_get_action_parms(struct FindjoB *o, char **target, char **text_2, + uid_t *user, gid_t *group, + mode_t *mode_and, mode_t *mode_or, + int *type, time_t *date, struct FindjoB **subjob, + int flag); + +/* @param flag bit0= recursive +*/ +int Findjob_set_action_target(struct FindjoB *o, int action, char *target, + int flag); + +/* @param flag bit0= recursive +*/ +int Findjob_set_action_chgrp(struct FindjoB *o, gid_t group, int flag); + +/* @param flag bit0= recursive +*/ +int Findjob_set_action_chmod(struct FindjoB *o, + mode_t mode_and, mode_t mode_or, int flag); + +/* @param flag bit0= recursive +*/ +int Findjob_set_action_ad(struct FindjoB *o, int type, time_t date, int flag); + +int Findjob_set_start_path(struct FindjoB *o, char *start_path, int flag); + +int Findjob_set_action_found_path(struct FindjoB *o, int flag); + +int Findjob_get_start_path(struct FindjoB *o, char **start_path, int flag); + +int Findjob_set_lba_range(struct FindjoB *o, int start_lba, int count, + int flag); + +int Findjob_get_lba_damage_filter(struct FindjoB *o, int *start_lba, + int *end_lba, int *damage_filter, int flag); + +int Findjob_get_commit_filter(struct FindjoB *o, int *commit_filter, int flag); + +int Findjob_get_acl_filter(struct FindjoB *o, int *acl_filter, int flag); + +int Findjob_get_xattr_filter(struct FindjoB *o, int *xattr_filter, int flag); + +int Findjob_get_aaip_filter(struct FindjoB *o, int *aaip_filter, int flag); + +int Findjob_get_filter_filter(struct FindjoB *o, int *value, int flag); + +int Findjob_set_wanted_node(struct FindjoB *o, void *wanted_node, int flag); + +int Findjob_get_wanted_node(struct FindjoB *o, void **wanted_node, int flag); + +int Findjob_set_found_path(struct FindjoB *o, char *path, int flag); + +int Findjob_get_found_path(struct FindjoB *o, char **path, int flag); + +#endif /* ! Xorriso_findjob_on_expR */ + + +struct SplitparT; + +int Splitparts_new(struct SplitparT **o, int count, int flag); + +int Splitparts_destroy(struct SplitparT **o, int count, int flag); + +int Splitparts_set(struct SplitparT *o, int idx, + char *name, int partno, int total_parts, + off_t offset, off_t bytes, off_t total_bytes, int flag); + +int Splitparts_get(struct SplitparT *o, int idx, char **name, int *partno, + int *total_parts, off_t *offset, off_t *bytes, + off_t *total_bytes, int flag); + +int Splitpart__parse(char *name, int *partno, int *total_parts, + off_t *offset, off_t *bytes, off_t *total_bytes, int flag); + +int Splitpart__compose(char *adr, int partno, int total_parts, + off_t offset, off_t bytes, off_t total_bytes, int flag); + +int Splitparts_sort(struct SplitparT *o, int count, int flag); + + +int Permstack_push(struct PermiteM **o, char *disk_path, struct stat *stbuf, + int flag); + +int Permstack_pop(struct PermiteM **o, struct PermiteM *stopper, + struct XorrisO *xorriso, int flag); + + +int Spotlist_new(struct SpotlisT **o, int flag); + +int Spotlist_destroy(struct SpotlisT **o, int flag); + +int Spotlist_add_item(struct SpotlisT *o, int start_lba, int blocks, + int quality, int flag); + +int Spotlist_count(struct SpotlisT *o, int flag); + +int Spotlist_block_count(struct SpotlisT *o, int flag); + +int Spotlist_sector_size(struct SpotlisT *o, int read_chunk, int flag); + +int Spotlist_get_item(struct SpotlisT *o, int idx, + int *start_lba, int *blocks, int *quality, int flag); + +char *Spotlist__quality_name(int quality, char name[80], int flag); + + +#define Xorriso_read_quality_gooD 0x7fffffff +#define Xorriso_read_quality_md5_matcH 0x70000000 +#define Xorriso_read_quality_sloW 0x60000000 +#define Xorriso_read_quality_partiaL 0x50000000 +#define Xorriso_read_quality_valiD 0x40000000 +#define Xorriso_read_quality_untesteD 0x3fffffff +#define Xorriso_read_quality_invaliD 0x3ffffffe +#define Xorriso_read_quality_tao_enD 0x28000000 +#define Xorriso_read_quality_off_tracK 0x20000000 +#define Xorriso_read_quality_md5_mismatcH 0x10000000 +#define Xorriso_read_quality_unreadablE 0x00000000 + + +struct CheckmediajoB { + int use_dev; /* 0= use indev , 1= use outdev , 2= use sector map*/ + + int min_lba; /* if >=0 : begin checking at this address */ + int max_lba; /* if >=0 : read up to this address, else use mode */ + + int min_block_size; /* >>> not yet implemented: + granularity desired by user + */ + int mode; /* 0= track by track + 1= single sweep over libisoburn media capacity + >>> 2= single sweep over libburn media capacity + */ + time_t start_time; + int time_limit; /* Number of seconds after which to abort */ + + int item_limit; /* Maximum number of media check list items as result */ + + char abort_file_path[SfileadrL]; + + char data_to_path[SfileadrL]; + int data_to_fd; + off_t data_to_offset; /* usually 0 with image copy, negative with file copy */ + off_t data_to_limit; /* used with file copy */ + int patch_lba0; + int patch_lba0_msc1; + + char sector_map_path[SfileadrL]; + struct SectorbitmaP *sector_map; + int map_with_volid; /* 0=add quick toc to map file, + 1=read ISO heads for toc + */ + + int retry; /* -1= only try full read_chunk, 1=retry with 2k blocks + 0= retry with CD, full chunk else + */ + + int report_mode; /* 0= print MCL items + 1= print damaged files + */ + + char event_severity[20]; /* If not "ALL": trigger event of given severity + at the end of a check job if bad blocks were + discovered. + */ + +}; + +int Checkmediajob_new(struct CheckmediajoB **o, int flag); + +int Checkmediajob_destroy(struct CheckmediajoB **o, int flag); + +int Checkmediajob_copy(struct CheckmediajoB *from, struct CheckmediajoB *to, + int flag); + +int Sectorbitmap_new(struct SectorbitmaP **o, int sectors, int sector_size, + int flag); +int Sectorbitmap_destroy(struct SectorbitmaP **o, int flag); +int Sectorbitmap_from_file(struct SectorbitmaP **o, char *path, char *msg, + int *os_errno, int flag); +int Sectorbitmap_to_file(struct SectorbitmaP *o, char *path, char *info, + char *msg, int *os_errno, int flag); +int Sectorbitmap_set(struct SectorbitmaP *o, int sector, int flag); +int Sectorbitmap_set_range(struct SectorbitmaP *o, + int start_sector, int sectors, int flag); +int Sectorbitmap_is_set(struct SectorbitmaP *o, int sector, int flag); +int Sectorbitmap_bytes_are_set(struct SectorbitmaP *o, + off_t start_byte, off_t end_byte, int flag); + +int Sectorbitmap_get_layout(struct SectorbitmaP *o, + int *sectors, int *sector_size, int flag); + +int Sectorbitmap_copy(struct SectorbitmaP *from, struct SectorbitmaP *to, + int flag); + +/* bit0= append (text!=NULL) */ +int Sregex_string(char **handle, char *text, int flag); + +/* @param flag bit0= only test expression whether compilable +*/ +int Sregex_match(char *pattern, char *text, int flag); + +#endif /* Xorriso_private_includeD */ + diff --git a/libisoburn/branches/ZeroFourTwo/xorriso/xorriso_timestamp.h b/libisoburn/branches/ZeroFourTwo/xorriso/xorriso_timestamp.h new file mode 100644 index 00000000..fc6dc0d8 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/xorriso/xorriso_timestamp.h @@ -0,0 +1 @@ +#define Xorriso_timestamP "2009.08.28.112825" diff --git a/libisoburn/branches/ZeroFourTwo/xorriso/xorrisoburn.c b/libisoburn/branches/ZeroFourTwo/xorriso/xorrisoburn.c new file mode 100644 index 00000000..06168f59 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/xorriso/xorrisoburn.c @@ -0,0 +1,12652 @@ + + +/* Adapter to libisoburn, libisofs and libburn for xorriso, + a command line oriented batch and dialog tool which creates, loads, + manipulates and burns ISO 9660 filesystem images. + + Copyright 2007-2009 Thomas Schmitt, + + Provided under GPL version 2. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* for -charset */ +#include +#include + + +/* ------------------------------------------------------------------------ */ + +#ifndef Xorriso_standalonE + +/* The library which does the ISO 9660 / RockRidge manipulations */ +#include + +/* The library which does MMC optical drive operations */ +#include + +/* The library which enhances overwriteable media with ISO 9660 multi-session + capabilities via the method invented by Andy Polyakov for growisofs */ +#include + +/* The official xorriso options API. "No shortcuts" */ +#include "xorriso.h" + +/* The inner description of XorrisO */ +#include "xorriso_private.h" + +/* The inner isofs- and burn-library interface */ +#include "xorrisoburn.h" + +#else /* ! Xorriso_standalonE */ + +#include "../libisofs/libisofs.h" +#include "../libburn/libburn.h" +#include "../libisoburn/libisoburn.h" +#include "xorriso.h" +#include "xorriso_private.h" +#include "xorrisoburn.h" + +#endif /* Xorriso_standalonE */ + + +/* Some private in advance declarations */ +int Xorriso_pacifier_loop(struct XorrisO *xorriso, struct burn_drive *drive, + int flag); + +int Xorriso__read_pacifier(IsoImage *image, IsoFileSource *filesource); + +int Xorriso_tree_graft_node(struct XorrisO *xorriso, IsoImage *volume, + IsoDir *dir, char *disk_path, char *img_name, + char *nominal_source, char *nominal_target, + off_t offset, off_t cut_size, + IsoNode **node, int flag); + +int Xorriso_findi_iter(struct XorrisO *xorriso, IsoDir *dir_node, off_t *mem, + IsoDirIter **iter, + IsoNode ***node_array, int *node_count, int *node_idx, + IsoNode **iterated_node, int flag); + +int Xorriso__file_start_lba(IsoNode *node, int *lba, int flag); + +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); + +int Xorriso_path_from_node(struct XorrisO *xorriso, IsoNode *in_node, + char path[SfileadrL], int flag); + +int Xorriso_node_from_path(struct XorrisO *xorriso, IsoImage *volume, + char *path, IsoNode **node, int flag); + +int Xorriso_path_from_lba(struct XorrisO *xorriso, IsoNode *node, int lba, + char path[SfileadrL], int flag); + +int Xorriso__node_lba_cmp(const void *node1, const void *node2); + +int Xorriso_search_hardlinks(struct XorrisO *xorriso, IsoNode *node, + int *node_idx, int *min_hl, int *max_hl, int flag); + + +#define LIBISO_ISDIR(node) (iso_node_get_type(node) == LIBISO_DIR) +#define LIBISO_ISREG(node) (iso_node_get_type(node) == LIBISO_FILE) +#define LIBISO_ISLNK(node) (iso_node_get_type(node) == LIBISO_SYMLINK) +#define LIBISO_ISCHR(node) (iso_node_get_type(node) == LIBISO_SPECIAL && \ + S_ISCHR(iso_node_get_mode(node))) +#define LIBISO_ISBLK(node) (iso_node_get_type(node) == LIBISO_SPECIAL && \ + S_ISBLK(iso_node_get_mode(node))) +#define LIBISO_ISFIFO(node) (iso_node_get_type(node) == LIBISO_SPECIAL && \ + S_ISFIFO(iso_node_get_mode(node))) +#define LIBISO_ISSOCK(node) (iso_node_get_type(node) == LIBISO_SPECIAL && \ + S_ISSOCK(iso_node_get_mode(node))) +#define LIBISO_ISBOOT(node) (iso_node_get_type(node) == LIBISO_BOOT) + + +/* CD specs say one shall not write tracks < 600 kiB */ +#define Xorriso_cd_min_track_sizE 300 + + +/* Default setting for -compliance */ +#define Xorriso_relax_compliance_defaulT \ + (isoburn_igopt_allow_deep_paths | isoburn_igopt_allow_longer_paths | \ + isoburn_igopt_always_gmt | \ + isoburn_igopt_rrip_version_1_10 | isoburn_igopt_aaip_susp_1_10 ) + +#ifdef NIX +/* <<< */ +unsigned long Xorriso_get_di_counteR= 0; +#endif /* NIX */ + + +/* ------------------------------------------------------------------------ */ + + +int Xorriso_destroy_node_array(struct XorrisO *xorriso, int flag) +{ + int i; + + if(xorriso->node_array != NULL) { + for(i= 0; i < xorriso->node_counter; i++) + iso_node_unref((IsoNode *) xorriso->node_array[i]); + free(xorriso->node_array); + } + xorriso->node_array= NULL; + xorriso->node_counter= xorriso->node_array_size= 0; + Xorriso_lst_destroy_all(&(xorriso->node_disk_prefixes), 0); + Xorriso_lst_destroy_all(&(xorriso->node_img_prefixes), 0); + return(1); +} + + +/* @param flag bit0= do not destroy hln_array but only hln_targets +*/ +int Xorriso_destroy_hln_array(struct XorrisO *xorriso, int flag) +{ + int i; + + + if(xorriso->hln_array != NULL && !(flag & 1)) { + for(i= 0; i < xorriso->hln_count; i++) + iso_node_unref((IsoNode *) xorriso->hln_array[i]); + free(xorriso->hln_array); + xorriso->hln_array= NULL; + xorriso->hln_count= 0; + } + if(xorriso->hln_targets != NULL) { + for(i= 0; i < xorriso->hln_count; i++) + if(xorriso->hln_targets[i] != NULL) + free(xorriso->hln_targets[i]); + free(xorriso->hln_targets); + xorriso->hln_targets= NULL; + } + xorriso->node_targets_availmem= 0; + return(1); +} + + +int Xorriso_destroy_di_array(struct XorrisO *xorriso, int flag) +{ + int i; + + if(xorriso->di_array != NULL) { + for(i= 0; i < xorriso->di_count; i++) + if(xorriso->di_array[i] != NULL) + iso_node_unref((IsoNode *) xorriso->di_array[i]); + free(xorriso->di_array); + xorriso->di_array= NULL; + } + if(xorriso->di_do_widen != NULL) { + free(xorriso->di_do_widen); + xorriso->di_do_widen= NULL; + } + Xorriso_lst_destroy_all(&(xorriso->di_disk_paths), 0); + Xorriso_lst_destroy_all(&(xorriso->di_iso_paths), 0); + xorriso->di_count= 0; + +#ifdef NIX + /* <<< */ + fprintf(stderr, "xorriso_DEBUG: get_di_count= %lu\n", + Xorriso_get_di_counteR); +#endif /* NIX */ + + return(1); +} + + +int Xorriso_new_node_array(struct XorrisO *xorriso, off_t mem_limit, + int addon_nodes, int flag) +{ + int i; + + if(xorriso->node_counter <= 0) + return(1); + + xorriso->node_array= calloc(xorriso->node_counter + addon_nodes, + sizeof(IsoNode *)); + if(xorriso->node_array == NULL) { + Xorriso_no_malloc_memory(xorriso, NULL, 0); + return(-1); + } + for(i= 0; i < xorriso->node_counter + addon_nodes; i++) + xorriso->node_array[i]= NULL; + xorriso->node_array_size= xorriso->node_counter + addon_nodes; + xorriso->node_counter= 0; + return(1); +} + + +/* @param flag bit0= do not allocate hln_array but only hln_targets +*/ +int Xorriso_new_hln_array(struct XorrisO *xorriso, off_t mem_limit, int flag) +{ + int i; + + Xorriso_destroy_hln_array(xorriso, flag & 1); + if(xorriso->hln_count <= 0) + return(1); + + if(!(flag & 1)) { + xorriso->hln_array= calloc(xorriso->hln_count, sizeof(char *)); + if(xorriso->hln_array == NULL) { + Xorriso_no_malloc_memory(xorriso, NULL, 0); + return(-1); + } + for(i= 0; i < xorriso->hln_count; i++) + xorriso->hln_array[i]= NULL; + } + + xorriso->hln_targets= calloc(xorriso->hln_count, sizeof(char *)); + if(xorriso->hln_targets == NULL) { + if(!(flag & 1)) { + free(xorriso->hln_array); + xorriso->hln_array= NULL; + } + Xorriso_no_malloc_memory(xorriso, NULL, 0); + return(-1); + } + for(i= 0; i < xorriso->hln_count; i++) + xorriso->hln_targets[i]= NULL; + xorriso->node_targets_availmem= mem_limit + - xorriso->hln_count * sizeof(void *) + - xorriso->hln_count * sizeof(char *); + if(xorriso->node_targets_availmem < 0) + xorriso->node_targets_availmem= 0; + return(1); +} + + +int Xorriso__findi_sorted_ino_cmp(const void *p1, const void *p2) +{ + int ret; + IsoNode *n1, *n2; + + n1= *((IsoNode **) p1); + n2= *((IsoNode **) p2); + + ret= Xorriso__node_lba_cmp(&n1, &n2); + if(ret) + return (ret > 0 ? 1 : -1); + ret= iso_node_cmp_ino(n1, n2, 0); + return(ret); +} + + +/* Not suitable for qsort() but for cross-array comparisons. + p1 and p2 are actually IsoNode *p1, IsoNode *p2 +*/ +int Xorriso__hln_cmp(const void *p1, const void *p2) +{ + int ret; + + ret= Xorriso__findi_sorted_ino_cmp(&p1, &p2); + if(ret) + return (ret > 0 ? 1 : -1); + if(p1 != p2) + return(p1 < p2 ? -1 : 1); + return(0); +} + + +/* + p1 and p2 are actually IsoNode **p1, IsoNode **p2 +*/ +int Xorriso__findi_sorted_cmp(const void *p1, const void *p2) +{ + int ret; + + ret= Xorriso__findi_sorted_ino_cmp(p1, p2); + if(ret) + return (ret > 0 ? 1 : -1); + if(p1 != p2) + return(p1 < p2 ? -1 : 1); + return(0); +} + + +int Xorriso_sort_node_array(struct XorrisO *xorriso, int flag) +{ + if(xorriso->node_counter <= 0) + return(0); + qsort(xorriso->node_array, xorriso->node_counter, sizeof(IsoNode *), + Xorriso__findi_sorted_cmp); + return(1); +} + + +int Xorriso__search_node(void *node_array[], int n, + int (*cmp)(const void *p1, const void *p2), + void *node, int *idx, int flag) +{ + int ret, l, r, p, pos; + + if(n == 0) + return(0); + l= 0; + r= n + 1; + while(1) { + p= (r - l) / 2; + if(p == 0) + break; + p+= l; + + /* NULL elements may indicate invalid nodes. Their first valid right neigbor + will serve as proxy. If none exists, then the test pushes leftwards. + */ + for(pos= p - 1; pos < n; pos++) + if(node_array[pos] != NULL) + break; + if(pos < n) + ret= (*cmp)(&(node_array[pos]), &node); + else + ret= 1; + + if(ret < 0) + l= p; + else if(ret > 0) + r= p; + else { + *idx= pos; + return(1); + } + } + return(0); +} + + +int Xorriso_search_in_hln_array(struct XorrisO *xorriso, + void *node, int *idx, int flag) +{ + int ret; + + if(xorriso->hln_array == NULL || xorriso->hln_count <= 0) + return(0); + ret= Xorriso__search_node(xorriso->hln_array, xorriso->hln_count, + Xorriso__findi_sorted_ino_cmp, node, idx, 0); + return ret; +} + + +int Xorriso__get_di(IsoNode *node, dev_t *dev, ino_t *ino, int flag) +{ + int ret, i, i_end, imgid, error_code; + size_t value_length= 0; + char *value= NULL, msg[ISO_MSGS_MESSAGE_LEN], severity[80]; + unsigned char *vpt; + static char *name= "isofs.di"; + +#ifdef NIX + /* <<< */ + Xorriso_get_di_counteR++; +#endif /* NIX */ + + *dev= 0; + *ino= 0; + ret= iso_node_lookup_attr(node, name, &value_length, &value, 0); + if(ret <= 0) { + /* Drop any pending messages because there is no xorriso to take them */ + iso_obtain_msgs("NEVER", &error_code, &imgid, msg, severity); + return(ret); + } + vpt= (unsigned char *) value; + for(i= 1; i <= vpt[0] && i < value_length; i++) + *dev= ((*dev) << 8) | vpt[i]; + i_end= i + vpt[i] + 1; + for(i++; i < i_end && i < value_length; i++) + *ino= ((*ino) << 8) | vpt[i]; + free(value); + return(1); +} + + +int Xorriso__di_ino_cmp(const void *p1, const void *p2) +{ + int ret; + IsoNode *n1, *n2; + dev_t d1, d2; + ino_t i1, i2; + + n1= *((IsoNode **) p1); + n2= *((IsoNode **) p2); + + ret= Xorriso__get_di(n1, &d1, &i1, 0); + if(ret <= 0) + {d1= 0; i1= 0;} + ret= Xorriso__get_di(n2, &d2, &i2, 0); + if(ret <= 0) + {d2= 0; i2= 0;} + + if(d1 < d2) + return(-1); + if(d1 > d2) + return(1); + if(i1 < i2) + return(-1); + if(i1 > i2) + return(1); + if(d1 == 0 && i1 == 0 && n1 != n2) + return(n1 < n2 ? -1 : 1); + return(0); +} + + +int Xorriso__di_cmp(const void *p1, const void *p2) +{ + int ret; + IsoNode *n1, *n2; + + ret= Xorriso__di_ino_cmp(p1, p2); + if(ret) + return(ret); + n1= *((IsoNode **) p1); + n2= *((IsoNode **) p2); + if(n1 != n2) + return(n1 < n2 ? -1 : 1); + return(0); +} + + +int Xorriso__sort_di(void *node_array[], int count, int flag) +{ + if(count <= 0) + return(0); + qsort(node_array, count, sizeof(IsoNode *), Xorriso__di_cmp); + return(1); +} + + +int Xorriso_invalidate_di_item(struct XorrisO *xorriso, IsoNode *node, + int flag) +{ + int ret, idx; + + if(xorriso->di_array == NULL) + return(1); + ret= Xorriso__search_node(xorriso->di_array, xorriso->di_count, + Xorriso__di_cmp, node, &idx, 0); + if(ret <= 0) + return(ret == 0); + if(xorriso->di_array[idx] != NULL) + iso_node_unref(xorriso->di_array[idx]); + xorriso->di_array[idx]= NULL; + return(1); +} + + +/* @param flag bit0= return 1 even if matching nodes were found but node is + not among them + bit1= use Xorriso__di_cmp() rather than Xorriso__di_ino_cmp() +*/ +int Xorriso_search_di_range(struct XorrisO *xorriso, IsoNode *node, + int *idx, int *low, int *high, int flag) +{ + int ret, i, found; + int (*cmp)(const void *p1, const void *p2)= Xorriso__di_ino_cmp; + + if(flag & 2) + cmp= Xorriso__di_cmp; + + *high= *low= *idx= -1; + ret= Xorriso__search_node(xorriso->di_array, xorriso->di_count, + cmp, node, &found, 0); + if(ret <= 0) + return(0); + *low= *high= found; + for(i= found + 1; i < xorriso->di_count; i++) + if(xorriso->di_array[i] != NULL) { + if((*cmp)(&node, &(xorriso->di_array[i])) != 0) + break; + *high= i; + } + for(i= found - 1; i >= 0; i--) + if(xorriso->di_array[i] != NULL) { + if((*cmp)(&node, &(xorriso->di_array[i])) != 0) + break; + *low= i; + } + for(i= *low; i <= *high; i++) + if(xorriso->di_array[i] == node) { + *idx= i; + break; + } + return(*idx >= 0 || (flag & 1)); +} + + +/* ------------------------------------------------------------------------ */ + + +int Xorriso_startup_libraries(struct XorrisO *xorriso, int flag) +{ + int ret, major, minor, micro; + char *handler_prefix= NULL; + char *queue_sev, *print_sev, reason[1024]; + struct iso_zisofs_ctrl zisofs_ctrl= {0, 6, 15}; + + +/* First an ugly compile time check for header version compatibility. + If everthing matches, then no C code is produced. In case of mismatch, + intentionally faulty C code will be inserted. +*/ + +/* The minimum requirement of xorriso towards the libisoburn header + at compile time is defined in xorriso/xorrisoburn.h + xorriso_libisoburn_req_major + xorriso_libisoburn_req_minor + xorriso_libisoburn_req_micro + It gets compared against the version macros in libburn/libburn.h : + isoburn_header_version_major + isoburn_header_version_minor + isoburn_header_version_micro + If the header is too old then the following code shall cause failure of + cdrskin compilation rather than to allow production of a program with + unpredictable bugs or memory corruption. + The compiler messages supposed to appear in this case are: + error: 'LIBISOBURN_MISCONFIGURATION' undeclared (first use in this function) + error: 'INTENTIONAL_ABORT_OF_COMPILATION__HEADERFILE_libisoburn_dot_h_TOO_OLD__SEE_xorrisoburn_dot_c' undeclared (first use in this function) + error: 'LIBISOBURN_MISCONFIGURATION_' undeclared (first use in this function) +*/ +/* The indendation is an advise of man gcc to help old compilers ignoring */ + #if xorriso_libisoburn_req_major > isoburn_header_version_major + #define Isoburn_libisoburn_dot_h_too_olD 1 + #endif + #if xorriso_libisoburn_req_major == isoburn_header_version_major && xorriso_libisoburn_req_minor > isoburn_header_version_minor + #define Isoburn_libisoburn_dot_h_too_olD 1 + #endif + #if xorriso_libisoburn_req_minor == isoburn_header_version_minor && xorriso_libisoburn_req_micro > isoburn_header_version_micro + #define Isoburn_libisoburn_dot_h_too_olD 1 + #endif + +#ifdef Isoburn_libisoburn_dot_h_too_olD +LIBISOBURN_MISCONFIGURATION = 0; +INTENTIONAL_ABORT_OF_COMPILATION__HEADERFILE_libisoburn_dot_h_TOO_OLD__SEE_xorrisoburn_dot_c = 0; +LIBISOBURN_MISCONFIGURATION_ = 0; +#endif + +/* End of ugly compile time test (scroll up for explanation) */ + + handler_prefix= calloc(strlen(xorriso->progname)+3+1, 1); + if(handler_prefix==NULL) { + sprintf(xorriso->info_text, + "Cannot allocate memory for initializing libraries"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(-1); + } + reason[0]= 0; + ret= isoburn_initialize(reason, 0); + if(ret==0) { + sprintf(xorriso->info_text, "Cannot initialize libraries"); + if(reason[0]) + sprintf(xorriso->info_text+strlen(xorriso->info_text), + ". Reason given:\n%s", reason); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + free(handler_prefix); + return(0); + } + ret= isoburn_is_compatible(isoburn_header_version_major, + isoburn_header_version_minor, + isoburn_header_version_micro, 0); + if(ret<=0) { + isoburn_version(&major, &minor, µ); + sprintf(xorriso->info_text, + "libisoburn version too old: %d.%d.%d . Need at least: %d.%d.%d .\n", + major, minor, micro, + isoburn_header_version_major, isoburn_header_version_minor, + isoburn_header_version_micro); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(-1); + } + + xorriso->libs_are_started= 1; + + queue_sev= "ALL"; + if(xorriso->library_msg_direct_print) { + + /* >>> need option for controlling this in XorrisO. + See also Xorriso_msgs_submit */; + + print_sev= xorriso->report_about_text; + } else + print_sev= "NEVER"; + + iso_set_msgs_severities(queue_sev, print_sev, "libsofs : "); + burn_msgs_set_severities(queue_sev, print_sev, "libburn : "); + + /* ??? >>> do we want united queues ? */ + /* burn_set_messenger(iso_get_messenger()); */ + + isoburn_set_msgs_submit(Xorriso_msgs_submit_void, (void *) xorriso, + (3<<2) | 128 , 0); + + sprintf(handler_prefix, "%s : ", xorriso->progname); + burn_set_signal_handling(handler_prefix, NULL, 0); + + ret = iso_zisofs_get_params(&zisofs_ctrl, 0); + if (ret == 1) { + xorriso->zisofs_block_size= xorriso->zisofs_block_size_default= + (1 << zisofs_ctrl.block_size_log2); + xorriso->zlib_level= xorriso->zlib_level_default= + zisofs_ctrl.compression_level; + } + + Xorriso_process_msg_queues(xorriso,0); + if(reason[0]) { + sprintf(xorriso->info_text, "%s", reason); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + } + free(handler_prefix); + return(1); +} + + +/* @param flag bit0= global shutdown of libraries */ +int Xorriso_detach_libraries(struct XorrisO *xorriso, int flag) +{ + Xorriso_give_up_drive(xorriso, 3); + if(xorriso->in_volset_handle!=NULL) { /* standalone image */ + iso_image_unref((IsoImage *) xorriso->in_volset_handle); + xorriso->in_volset_handle= NULL; + Sectorbitmap_destroy(&(xorriso->in_sector_map), 0); + Xorriso_destroy_di_array(xorriso, 0); + Xorriso_destroy_hln_array(xorriso, 0); + } + if(flag&1) { + if(xorriso->libs_are_started==0) + return(0); + isoburn_finish(); + } + return(1); +} + + +/* @param flag + bit0= if not MMC drive print NOTE and return 2 + bit1= obtain outdrive, else indrive + bit4= do not report failure +*/ +int Xorriso_get_drive_handles(struct XorrisO *xorriso, + struct burn_drive_info **dinfo, + struct burn_drive **drive, + char *attempt, int flag) +{ + int ret; + + if(flag&2) + *dinfo= (struct burn_drive_info *) xorriso->out_drive_handle; + else + *dinfo= (struct burn_drive_info *) xorriso->in_drive_handle; + if(*dinfo==NULL && !(flag & 16)) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, "No %s drive aquired %s", + (flag&2 ? "output" : "input"), attempt); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + } + if(*dinfo==NULL) + return(0); + *drive= (*dinfo)[0].drive; + if(flag & 1) { + ret= burn_drive_get_drive_role(*drive); + if(ret != 1) { + sprintf(xorriso->info_text, + "Output device is not an MMC drive. Desired operation does not apply"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(2); + } + } + return((*drive)!=NULL); +} + + +int Xorriso__sev_to_text(int severity, char **severity_name, + int flag) +{ + int ret; + + ret= iso_sev_to_text(severity, severity_name); + if(ret>0) + return(ret); + ret= burn_sev_to_text(severity, severity_name, 0); + if(ret>0) + return(ret); + *severity_name= ""; + return(0); +} + + +int Xorriso__text_to_sev(char *severity_name, int *severity_number, int flag) +{ + int ret= 1; + + ret= iso_text_to_sev(severity_name, severity_number); + if(ret>0) + return(ret); + ret= burn_text_to_sev(severity_name, severity_number, 0); + return(ret); +} + + +/* @param flag bit0= report libisofs error text + bit1= victim is disk_path + bit2= do not inquire libisofs, report msg_text and min_severity +*/ +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) +{ + int error_code, iso_sev, min_sev, ret; + char *sev_text_pt, *msg_text_pt= NULL; + char sfe[6*SfileadrL]; + static int sorry_sev= -1; + + if(sorry_sev<0) + Xorriso__text_to_sev("SORRY", &sorry_sev, 0); + + if(flag&4) { + error_code= 0x00050000; + Xorriso__text_to_sev(min_severity, &iso_sev, 0); + } else { + error_code= iso_error_get_code(iso_error_code); + if(error_code < 0x00030000 || error_code >= 0x00040000) + error_code= (error_code & 0xffff) | 0x00050000; + if(flag&1) + msg_text_pt= (char *) iso_error_to_msg(iso_error_code); + iso_sev= iso_error_get_severity(iso_error_code); + } + if(msg_text_pt==NULL) + msg_text_pt= msg_text; + + if(iso_sev >= sorry_sev && (flag & 2) && victim[0]) + Xorriso_msgs_submit(xorriso, 0, victim, 0, "ERRFILE", 0); + sev_text_pt= min_severity; + Xorriso__text_to_sev(min_severity, &min_sev, 0); + if(min_sev < iso_sev && !(flag&4)) + Xorriso__sev_to_text(iso_sev, &sev_text_pt, 0); + strcpy(sfe, msg_text_pt); + if(victim[0]) { + strcat(sfe, ": "); + Text_shellsafe(victim, sfe+strlen(sfe), 0); + } + ret= Xorriso_msgs_submit(xorriso, error_code, sfe, os_errno, sev_text_pt, 4); + return(ret); +} + + +/* @param flag bit0= suppress messages below UPDATE + bit1= suppress messages below FAILURE +*/ +int Xorriso_set_image_severities(struct XorrisO *xorriso, int flag) +{ + char *queue_sev, *print_sev; + + if(flag&2) + queue_sev= "FAILURE"; + else if(flag&1) + queue_sev= "UPDATE"; + else + queue_sev= "ALL"; + if(xorriso->library_msg_direct_print) + print_sev= xorriso->report_about_text; + else + print_sev= "NEVER"; + iso_set_msgs_severities(queue_sev, print_sev, "libisofs : "); + return(1); +} + + +int Xorriso_update_volid(struct XorrisO *xorriso, int flag) +{ + int gret, sret= 1; + + gret= Xorriso_get_volid(xorriso, xorriso->loaded_volid, 0); + if(gret<=0 || (!xorriso->volid_default) || xorriso->loaded_volid[0]==0) + sret= Xorriso_set_volid(xorriso, xorriso->volid, 1); + return(gret>0 && sret>0); +} + + +int Xorriso_create_empty_iso(struct XorrisO *xorriso, int flag) +{ + int ret; + IsoImage *volset; + struct isoburn_read_opts *ropts; + struct burn_drive_info *dinfo= NULL; + struct burn_drive *drive= NULL; + + if(xorriso->out_drive_handle != NULL) { + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to attach volset to drive", 2); + if(ret<=0) + return(ret); + } + if(xorriso->in_volset_handle!=NULL) { + iso_image_unref((IsoImage *) xorriso->in_volset_handle); + xorriso->in_volset_handle= NULL; + Sectorbitmap_destroy(&(xorriso->in_sector_map), 0); + Xorriso_destroy_di_array(xorriso, 0); + Xorriso_destroy_hln_array(xorriso, 0); + xorriso->loaded_volid[0]= 0; + xorriso->volset_change_pending= 0; + xorriso->no_volset_present= 0; + } + + ret= isoburn_ropt_new(&ropts, 0); + if(ret<=0) + return(ret); + /* Note: no return before isoburn_ropt_destroy() */ + isoburn_ropt_set_extensions(ropts, isoburn_ropt_pretend_blank); + isoburn_ropt_set_input_charset(ropts, xorriso->in_charset); + isoburn_set_read_pacifier(drive, NULL, NULL); + ret= isoburn_read_image(drive, ropts, &volset); + Xorriso_process_msg_queues(xorriso,0); + isoburn_ropt_destroy(&ropts, 0); + if(ret<=0) { + sprintf(xorriso->info_text, "Failed to create new empty ISO image object"); + Xorriso_report_iso_error(xorriso, "", ret, xorriso->info_text, 0, "FATAL", + 0); + return(-1); + } + xorriso->in_volset_handle= (void *) volset; + xorriso->in_sector_map= NULL; + Xorriso_update_volid(xorriso, 0); + xorriso->volset_change_pending= 0; + xorriso->no_volset_present= 0; + return(1); +} + + +int Xorriso_record_boot_info(struct XorrisO *xorriso, int flag) +{ + int ret; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + IsoImage *image; + ElToritoBootImage *bootimg; + IsoFile *bootimg_node; + IsoBoot *bootcat_node; + + xorriso->loaded_boot_bin_lba= -1; + xorriso->loaded_boot_cat_path[0]= 0; + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to record boot LBAs", 0); + if(ret<=0) + return(0); + image= isoburn_get_attached_image(drive); + if(image == NULL) + return(0); + ret= iso_image_get_boot_image(image, &bootimg, + &bootimg_node, &bootcat_node); + iso_image_unref(image); /* release obtained reference */ + if(ret != 1) + return(0); + if(bootimg_node != NULL) + Xorriso__file_start_lba((IsoNode *) bootimg_node, + &(xorriso->loaded_boot_bin_lba), 0); + if(bootcat_node != NULL) + Xorriso_path_from_lba(xorriso, (IsoNode *) bootcat_node, 0, + xorriso->loaded_boot_cat_path, 0); + return(1); +} + + +int Xorriso_assert_volid(struct XorrisO *xorriso, int msc1, int flag) +{ + int ret, image_blocks; + char volid[33]; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + + if(xorriso->assert_volid[0] == 0) + return(1); + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to perform -assert_volid", 0); + if(ret<=0) + return(0); + ret= isoburn_read_iso_head(drive, msc1, &image_blocks, volid, 1); + Xorriso_process_msg_queues(xorriso,0); + if(ret <= 0) { + sprintf(xorriso->info_text, + "-assert_volid: Cannot determine Volume Id at LBA %d.", msc1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, + xorriso->assert_volid_sev, 0); + return(0); + } + ret= Sregex_match(xorriso->assert_volid, volid, 0); + if(ret < 0) + return(2); + if(ret == 0) { + strcpy(xorriso->info_text, + "-assert_volid: Volume id does not match pattern: "); + Text_shellsafe(xorriso->assert_volid, xorriso->info_text, 1); + strcat(xorriso->info_text, " <> "); + Text_shellsafe(volid, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, + xorriso->assert_volid_sev, 0); + return(0); + } + return(ret); +} + + +/* @param flag bit0= aquire as isoburn input drive + bit1= aquire as libburn output drive (as isoburn drive if bit0) + bit2= regard overwriteable media as blank + bit3= if the drive is a regular disk file: truncate it to + the write start address + bit5= do not print toc + bit6= do not calm down drive after aquiring it + @return <=0 failure , 1= ok + 2=success, but not writeable with bit1 + 3=success, but not blank and not ISO with bit0 +*/ +int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag) +{ + int ret, hret, not_writeable= 0, has_what, aquire_flag, load_lba, ext; + int lba, track, session, params_flag, adr_mode, read_ret; + uint32_t size; + struct burn_drive_info *dinfo= NULL, *out_dinfo, *in_dinfo; + struct burn_drive *drive, *out_drive, *in_drive; + enum burn_disc_status state; + IsoImage *volset = NULL; + IsoNode *root_node; + struct isoburn_read_opts *ropts= NULL; + char libburn_adr[SfileadrL], *boot_fate, *sev; + size_t value_length; + char *value= NULL; + double num; + char volid[33], adr_data[163], *adr_pt; + + if((flag&3)==0) { + sprintf(xorriso->info_text, + "XORRISOBURN program error : Xorriso_aquire_drive bit0+bit1 not set"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(-1); + } + ret= Xorriso_give_up_drive(xorriso, (flag&3)|8); + if(ret<=0) + return(ret); + if(flag & 1) + xorriso->isofs_st_out= time(0) - 1; + + ret= Xorriso_auto_driveadr(xorriso, adr, libburn_adr, 0); + if(ret <= 0) + return(ret); + if(strcmp(libburn_adr,"stdio:/dev/fd/1")==0) { + if(xorriso->dev_fd_1<0) { + sprintf(xorriso->info_text, + "-*dev \"stdio:/dev/fd/1\" was not a start argument. Cannot use it now."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } else { + sprintf(libburn_adr, "stdio:/dev/fd/%d", xorriso->dev_fd_1); + } + } + + if((flag&3)==1 && xorriso->out_drive_handle!=NULL) { + ret= Xorriso_get_drive_handles(xorriso, &out_dinfo, &out_drive, + "on attempt to compare new indev with outdev", 2); + if(ret<=0) + goto ex; + ret= burn_drive_equals_adr(out_drive, libburn_adr, 1); + if(ret==1) + dinfo= out_dinfo; + } else if((flag&3)==2 && xorriso->in_drive_handle!=NULL) { + ret= Xorriso_get_drive_handles(xorriso, &in_dinfo, &in_drive, + "on attempt to compare new outdev with indev", 0); + if(ret<=0) + goto ex; + ret= burn_drive_equals_adr(in_drive, libburn_adr, 1); + if(ret==1) + dinfo= in_dinfo; + } + + if(dinfo==NULL) { + aquire_flag= 1 | ((flag&(8|4))>>1) | ((xorriso->toc_emulation_flag & 3)<<3); + if(!(xorriso->do_aaip & 1)) + aquire_flag|= 32; + if((xorriso->ino_behavior & (1 | 2)) && !(xorriso->do_aaip & (4 | 32))) + aquire_flag|= 64; + ret= isoburn_drive_aquire(&dinfo, libburn_adr, aquire_flag); + Xorriso_process_msg_queues(xorriso,0); + if(ret<=0) { + sprintf(xorriso->info_text,"Cannot aquire drive '%s'", adr); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + if(flag&1) + if(xorriso->image_start_mode&(1<<31)) /* used up setting */ + xorriso->image_start_mode= 0; /* no need to perform auto setting */ + } + drive= dinfo[0].drive; + if(flag&1) { + if(xorriso->image_start_mode&(1<<31)) /* used up setting */ + xorriso->image_start_mode&= ~0xffff; /* perform auto setting */ + if((xorriso->image_start_mode&(1<<30))) { /* if enabled at all */ + adr_pt= xorriso->image_start_value; + adr_mode= xorriso->image_start_mode & 0xffff; + if(adr_mode == 4 && strlen(adr_pt) <= 80) { + /* Convert volid search expression into lba */ + params_flag= 0; + ret= Xorriso__bourne_to_reg(xorriso->image_start_value, adr_data, 0); + if(ret == 1) + params_flag|= 4; + ret= isoburn_get_mount_params(drive, 4, adr_data, &lba, &track, + &session, volid, params_flag); + Xorriso_process_msg_queues(xorriso,0); + if(ret <= 0) + goto ex; + if(session <= 0 || track <= 0 || ret == 2) { + Xorriso_msgs_submit(xorriso, 0, + "-load : Given address does not point to an ISO 9660 session", + 0, "FAILURE", 0); + ret= 0; goto ex; + } + sprintf(volid, "%d", lba); + adr_pt= volid; + adr_mode= 3; + } + ret= isoburn_set_msc1(drive, adr_mode, adr_pt, + !!(xorriso->image_start_mode & (1<<16))); + if(ret<=0) + goto ex; + if(xorriso->image_start_mode&(1<<31)) + xorriso->image_start_mode= 0; /* disable msc1 setting completely */ + else + xorriso->image_start_mode|= (1<<31); /* mark as used up */ + } + } + state= isoburn_disc_get_status(drive); + Xorriso_process_msg_queues(xorriso,0); + if(flag&1) { + volset= isoburn_get_attached_image(drive); + if(volset != NULL) { /* The image object is already created */ + iso_image_unref(volset); + } + } + + if(flag&2) { + xorriso->out_drive_handle= dinfo; + if(Sfile_str(xorriso->outdev, adr, 0)<=0) + {ret= -1; goto ex;} + if(state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE) { + sprintf(xorriso->info_text, "Disc status unsuitable for writing"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + not_writeable= 1; + } + } + if(flag&1) { + xorriso->in_drive_handle= dinfo; + if(Sfile_str(xorriso->indev, adr, 0)<=0) + {ret= -1; goto ex;} + } else if(flag&2) { + if(xorriso->in_volset_handle==NULL) { + /* No volume loaded: create empty one */ + ret= Xorriso_create_empty_iso(xorriso, 0); + if(ret<=0) + goto ex; + } else { + iso_image_ref((IsoImage *) xorriso->in_volset_handle); + ret= isoburn_attach_image(drive, (IsoImage *) xorriso->in_volset_handle); + if(ret<=0) { + sprintf(xorriso->info_text, + "Failed to attach ISO image object to outdev"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + } + if(!(flag&32)) + Xorriso_toc(xorriso, 1 | 2 | 8); + {ret= 1+not_writeable; goto ex;} + } + + if(xorriso->in_volset_handle!=NULL) + iso_image_unref((IsoImage *) xorriso->in_volset_handle); + xorriso->in_volset_handle= NULL; + Sectorbitmap_destroy(&(xorriso->in_sector_map), 0); + Xorriso_destroy_hln_array(xorriso, 0); + Xorriso_destroy_di_array(xorriso, 0); + + /* check for invalid state */ + if(state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE && + state != BURN_DISC_FULL) { + sprintf(xorriso->info_text, + "Disc status not blank and unsuitable for reading"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + {ret= 0; goto ex;} + } + /* fill read opts */ + ret= isoburn_ropt_new(&ropts, 0); + if(ret<=0) + goto ex; + + ext= isoburn_ropt_noiso1999; + if((xorriso->ino_behavior & (1 | 2)) && !(xorriso->do_aaip & (1 | 4 | 32)) + && !(xorriso->do_md5 & 1)) + ext|= isoburn_ropt_noaaip; + if(!(xorriso->do_aaip & 1)) + ext|= isoburn_ropt_noacl; + if(!(xorriso->do_aaip & 4)) + ext|= isoburn_ropt_noea; + if(xorriso->ino_behavior & 1) + ext|= isoburn_ropt_noino; + +#ifdef isoburn_ropt_nomd5 + if(!(xorriso->do_md5 & 1)) + ext|= isoburn_ropt_nomd5; +#endif + + isoburn_ropt_set_extensions(ropts, ext); + + isoburn_ropt_set_default_perms(ropts, (uid_t) 0, (gid_t) 0, (mode_t) 0555); + isoburn_ropt_set_input_charset(ropts, xorriso->in_charset); + isoburn_ropt_set_auto_incharset(ropts, !!(xorriso->do_aaip & 512)); + + Xorriso_set_image_severities(xorriso, 1); /* No DEBUG messages */ + Xorriso_pacifier_reset(xorriso, 0); + isoburn_set_read_pacifier(drive, Xorriso__read_pacifier, (void *) xorriso); + + /* <<< Trying to work around too much tolerance on bad image trees. + Better would be a chance to instruct libisofs what to do in + case of image read errors. There is a risk to mistake other SORRYs. + */ + if(xorriso->img_read_error_mode>0) + iso_set_abort_severity("SORRY"); + + if(state != BURN_DISC_BLANK) { + ret= isoburn_disc_get_msc1(drive, &load_lba); + if(ret > 0) { + sprintf(xorriso->info_text, + "Loading ISO image tree from LBA %d", load_lba); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + ret= Xorriso_assert_volid(xorriso, load_lba, 0); + if(ret <= 0) + goto ex; + } + + read_ret= ret= isoburn_read_image(drive, ropts, &volset); + + /* <<< Resetting to normal thresholds */ + if(xorriso->img_read_error_mode>0) + Xorriso_set_abort_severity(xorriso, 0); + + if(ret<=0) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_set_image_severities(xorriso, 0); + Xorriso_give_up_drive(xorriso, 1|((flag&32)>>2)); + sprintf(xorriso->info_text,"Cannot read ISO image tree"); + sev= "FAILURE"; + if(xorriso->img_read_error_mode==2) + sev= "FATAL"; + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, sev, 0); + if(read_ret == ISO_SB_TREE_CORRUPTED && (xorriso->do_md5 & 1)) { + Xorriso_msgs_submit(xorriso, 0, + "You might get a questionable ISO image tree by option -md5 'off'.", + 0, "HINT", 0); + } else if(xorriso->img_read_error_mode!=0) { + 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.", + 0, "HINT", 0); + } + + + ret= 3; goto ex; + } + Xorriso_pacifier_callback(xorriso, "nodes read", xorriso->pacifier_count, 0, + "", 1); /* report end count */ + xorriso->in_volset_handle= (void *) volset; + xorriso->in_sector_map= NULL; + Xorriso_set_image_severities(xorriso, 0); + Xorriso_update_volid(xorriso, 0); + + if(xorriso->out_drive_handle != NULL && + xorriso->out_drive_handle != xorriso->in_drive_handle) { + ret= Xorriso_get_drive_handles(xorriso, &out_dinfo, &out_drive, + "on attempt to attach ISO image volset to outdev", 2); + if(ret<=0) + goto ex; + iso_image_ref((IsoImage *) xorriso->in_volset_handle); + isoburn_attach_image(out_drive, xorriso->in_volset_handle); + } + Xorriso_process_msg_queues(xorriso,0); + isoburn_ropt_get_size_what(ropts, &size, &has_what); + if(has_what & isoburn_ropt_has_el_torito) { + if(xorriso->boot_image_bin_path[0]) + boot_fate= "replaced by an isolinux image"; + else if(xorriso->patch_isolinux_image) + boot_fate= "patched as isolinux image"; + else if(xorriso->keep_boot_image) + boot_fate= "kept unchanged"; + else + boot_fate= "discarded"; + sprintf(xorriso->info_text, + "Detected El-Torito boot information which currently is set to be %s", + boot_fate); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + Xorriso_record_boot_info(xorriso, 0); + } + + if(flag & 1) { + /* Look for isofs.st and put it into xorriso->isofs_st_in */; + root_node= (IsoNode *) iso_image_get_root(volset); + ret= iso_node_lookup_attr(root_node, "isofs.st", &value_length, &value, 0); + if(ret > 0) { + if(value_length > 0) { + sscanf(value, "%lf", &num); + if(num > 0) + xorriso->isofs_st_in= num; + } + free(value); + } + } + + if(!(flag&32)) { + Xorriso_toc(xorriso, 1 | 8); + if(xorriso->loaded_volid[0]!=0) { + sprintf(xorriso->info_text,"Volume id : '%s'\n", + xorriso->loaded_volid); + Xorriso_info(xorriso, 0); + if(strcmp(xorriso->loaded_volid, xorriso->volid) != 0 && + !xorriso->volid_default) { + sprintf(xorriso->info_text, "New volume id: '%s'\n", xorriso->volid); + Xorriso_info(xorriso, 0); + } + } + } + if((xorriso->do_calm_drive & 1) && !(flag & 64)) + burn_drive_snooze(drive, 0); /* No need to make noise from start */ + + ret= 1+not_writeable; +ex: + Xorriso_process_msg_queues(xorriso,0); + if(ret<=0) { + hret= Xorriso_give_up_drive(xorriso, (flag&3)|((flag&32)>>2)); + if(hretin_drive_handle == xorriso->out_drive_handle); + if((flag&4) && in_is_out_too && (flag&(1|2))) { + if((flag&3)!=3) { + sprintf(xorriso->info_text,"Giving up for -eject whole -dev %s", + Text_shellsafe(xorriso->indev, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + flag|= 3; /* give up in/out drive to eject it */ + } + + if((flag&1) && xorriso->in_drive_handle != NULL) { + Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to give up drive", 0); + + if(!in_is_out_too) { + if(drive!=NULL) + isoburn_drive_release(drive,!!(flag&4)); + if(dinfo!=NULL) + burn_drive_info_free(dinfo); + } + xorriso->in_drive_handle= NULL; + xorriso->indev[0]= 0; + + if(xorriso->in_volset_handle!=NULL) + iso_image_unref((IsoImage *) xorriso->in_volset_handle); + xorriso->in_volset_handle= NULL; + Sectorbitmap_destroy(&(xorriso->in_sector_map), 0); + Xorriso_destroy_di_array(xorriso, 0); + Xorriso_destroy_hln_array(xorriso, 0); + xorriso->loaded_volid[0]= 0; + xorriso->isofs_st_out= time(0) - 1; + xorriso->isofs_st_in= 0; + xorriso->volset_change_pending= 0; + xorriso->no_volset_present= 0; + xorriso->loaded_boot_bin_lba= 0; + xorriso->loaded_boot_cat_path[0]= 0; + in_is_out_too= 0; + } + if((flag&2) && xorriso->out_drive_handle!=NULL) { + Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to give up drive", 2); + if(!in_is_out_too) { + if(drive!=NULL) + isoburn_drive_release(drive,!!(flag&4)); + if(dinfo!=NULL) + burn_drive_info_free(dinfo); + } + xorriso->out_drive_handle= NULL; + xorriso->outdev[0]= 0; + } else if((flag&1) && xorriso->out_drive_handle!=NULL) { + ret= Xorriso_create_empty_iso(xorriso, 0); + if(ret<=0) + return(ret); + if(!(flag&8)) { + sprintf(xorriso->info_text, + "Only the output drive remains. Created empty ISO image.\n"); + Xorriso_info(xorriso, 0); + Xorriso_toc(xorriso, 1 | 2 | 8); + } + } + Xorriso_process_msg_queues(xorriso,0); + return(1); +} + + +int Xorriso_make_write_options( + struct XorrisO *xorriso, struct burn_drive *drive, + struct burn_write_opts **burn_options, int flag) +{ + int drive_role, stream_mode= 0; + + *burn_options= burn_write_opts_new(drive); + if(*burn_options==NULL) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text,"Cannot allocate option set"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + burn_write_opts_set_simulate(*burn_options, !!xorriso->do_dummy); + drive_role= burn_drive_get_drive_role(drive); + burn_write_opts_set_multi(*burn_options, + !(xorriso->do_close || drive_role==0 || drive_role==3)); + burn_drive_set_speed(drive, xorriso->speed, xorriso->speed); + if(xorriso->do_stream_recording == 1) + stream_mode= 1; + else if(xorriso->do_stream_recording == 2) + stream_mode= 51200; /* 100 MB */ + else if(xorriso->do_stream_recording >= 16) + stream_mode= xorriso->do_stream_recording; + burn_write_opts_set_stream_recording(*burn_options, stream_mode); + burn_write_opts_set_underrun_proof(*burn_options, 1); + return(1); +} + + +/* @param flag bit0= do not write but only prepare and return size in sectors + bit1= do not use isoburn wrappers +*/ +int Xorriso_sanitize_image_size(struct XorrisO *xorriso, + struct burn_drive *drive, struct burn_disc *disc, + struct burn_write_opts *burn_options, int flag) +{ + int ret, img_sectors, num_sessions= 0, num_tracks= 0, padding= 0, profile; + int media_space, lba, nwa; + char profile_name[80]; + struct burn_session **sessions; + struct burn_track **tracks; + + img_sectors= burn_disc_get_sectors(disc); + + sessions= burn_disc_get_sessions(disc, &num_sessions); + if(sessions==NULL || num_sessions < 1) { +no_track:; + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text,"Program error : no track in prepared disc"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + tracks= burn_session_get_tracks(sessions[0], &num_tracks); + if(tracks==NULL || num_tracks < 1) + goto no_track; + + padding= 0; + ret= burn_disc_get_profile(drive, &profile, profile_name); + padding= xorriso->padding / 2048; + if(xorriso->padding > padding * 2048) + padding++; + if(img_sectors>0 && ret>0 && + (profile==0x09 || profile==0x0a)) { /* CD-R , CD-RW */ + if(img_sectors + padding < Xorriso_cd_min_track_sizE) { + padding= Xorriso_cd_min_track_sizE - img_sectors; + sprintf(xorriso->info_text, + "Expanded track to minimum size of %d sectors", + Xorriso_cd_min_track_sizE); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + } + if(xorriso->alignment > 0) { + if(img_sectors > 0) { + ret= isoburn_disc_track_lba_nwa(drive, burn_options, 0, &lba, &nwa); + if(ret <= 0) + nwa= 0; + lba= (nwa + img_sectors + padding) % xorriso->alignment; + if(lba > 0) + padding+= xorriso->alignment - lba; + } else if(padding < xorriso->alignment) + padding= xorriso->alignment; + } + burn_track_define_data(tracks[0], 0, padding * 2048, 0, BURN_MODE1); + Xorriso_process_msg_queues(xorriso,0); + + if(flag&2) + media_space= burn_disc_available_space(drive, burn_options) / + (off_t) 2048; + else + media_space= isoburn_disc_available_space(drive, burn_options) / + (off_t) 2048; + if(media_space < img_sectors + padding) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text,"Image size %ds exceeds free space on media %ds", + img_sectors + padding, media_space); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + if(flag&1) { + ret= img_sectors+padding; + } else + ret= 1; +ex:; + return(ret); +} + + +/* @return <0 yes , 0 no , <0 error */ +int Xorriso_is_isohybrid(struct XorrisO *xorriso, IsoFile *bootimg_node, + int flag) +{ + int ret; + unsigned char buf[68]; + void *data_stream= NULL; + + ret= Xorriso_iso_file_open(xorriso, "", (void *) bootimg_node, + &data_stream, 1); + if(ret <= 0) + return(-1); + ret= Xorriso_iso_file_read(xorriso, data_stream, (char *) buf, 68, 0); + Xorriso_iso_file_close(xorriso, &data_stream, 0); + if(ret <= 0) + return(0); + if(buf[64] == 0xfb && buf[65] == 0xc0 && buf[66] == 0x78 && buf[67] == 0x70) + return(1); + return(0); +} + + +int Xorriso_set_isolinux_options(struct XorrisO *xorriso, + IsoImage *image, int flag) +{ + int make_isohybrid_mbr= 0, ret; + ElToritoBootImage *bootimg; + IsoFile *bootimg_node; + + ret= iso_image_get_boot_image(image, &bootimg, &bootimg_node, NULL); + if(ret != 1) { + sprintf(xorriso->info_text, "Programming error: No boot image available in Xorriso_set_isolinux_options()"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(-1); + } + + if(xorriso->boot_image_isohybrid == 0) { + ret= el_torito_set_isolinux_options(bootimg, 1, 0); + return(ret == 1); + } + if(xorriso->boot_image_isohybrid == 3) { + make_isohybrid_mbr= 1; + } else { + ret= Xorriso_is_isohybrid(xorriso, bootimg_node, 0); + if(ret < 0) + return(0); + if(ret > 0) + make_isohybrid_mbr= 1; + } + + if(xorriso->boot_image_isohybrid == 2 && !make_isohybrid_mbr) { + sprintf(xorriso->info_text, + "Isohybrid signature is demanded but not found in boot image file."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if(make_isohybrid_mbr) { + sprintf(xorriso->info_text, "Will write isohybrid MBR."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + xorriso->alignment= 512; + } + + ret= el_torito_set_isolinux_options(bootimg, 1 | (make_isohybrid_mbr << 1),0); + return(ret == 1); +} + + +int Xorriso_auto_format(struct XorrisO *xorriso, int flag) +{ + int ret, profile, status, num_formats; + char profile_name[80]; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + off_t size; + unsigned dummy; + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to autoformat", 2); + if(ret<=0) + return(0); + ret= burn_disc_get_profile(drive, &profile, profile_name); + if(ret>0 && (profile==0x12 || profile==0x43)) { /* DVD-RAM or BD-RE */ + ret= burn_disc_get_formats(drive, &status, &size, &dummy, &num_formats); + if(ret>0 && status==BURN_FORMAT_IS_UNFORMATTED) { + sprintf(xorriso->info_text, + "Unformatted %s media detected. Trying -format fast.", + profile_name); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + ret= Xorriso_format_media(xorriso, (off_t) 0, 1 | 4); + if(ret<=0) { + sprintf(xorriso->info_text, "Automatic formatting of %s failed", + profile_name); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(ret); + } + } + } + return(1); +} + + +#define Xorriso_with_make_isohybrid_mbR 1 + + +/* @param flag bit0= do not write but only prepare and return size in sectors +*/ +int Xorriso_write_session(struct XorrisO *xorriso, int flag) +{ + int ret, relax= 0, i, pacifier_speed= 0, data_lba, ext; + int major, minor, micro; + char xorriso_id[256], *img_id, sfe[5*SfileadrL], *cpt, *out_cs; + struct isoburn_imgen_opts *sopts= NULL; + struct burn_drive_info *dinfo, *source_dinfo; + struct burn_drive *drive, *source_drive; + struct burn_disc *disc= NULL; + struct burn_write_opts *burn_options; + off_t readcounter= 0,writecounter= 0; + int num_sessions= 0, num_tracks= 0; + struct burn_session **sessions; + struct burn_track **tracks; + enum burn_disc_status s; + IsoImage *image= NULL; + IsoNode *node, *root_node; + ElToritoBootImage *bootimg; + enum eltorito_boot_media_type emul_type= ELTORITO_NO_EMUL; + int profile_number; + char profile_name[80]; + + ret= Xorriso_finish_hl_update(xorriso, 0); + if(ret <= 0) + return(ret); + + out_cs= xorriso->out_charset; + if(out_cs == NULL) + Xorriso_get_local_charset(xorriso, &out_cs, 0); + + if(!(flag & 1)) { + ret= Xorriso_auto_format(xorriso, 0); + if(ret <=0 ) + return(0); + } + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to write", 2); + if(ret<=0) + return(0); + if(xorriso->out_drive_handle == xorriso->in_drive_handle) { + source_drive= drive; + } else { + if(xorriso->in_drive_handle == NULL) { + source_drive= drive; + } else { + ret= Xorriso_get_drive_handles(xorriso, &source_dinfo, &source_drive, + "on attempt to get source for write", 0); + if(ret<=0) + goto ex; + } + s= isoburn_disc_get_status(drive); + if(s!=BURN_DISC_BLANK) { + s= burn_disc_get_status(drive); + if(s!=BURN_DISC_BLANK) + sprintf(xorriso->info_text, + "-indev differs from -outdev and -outdev media is not blank"); + else + sprintf(xorriso->info_text, + "-indev differs from -outdev and -outdev media holds non-zero data"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + } + ret= Xorriso_get_profile(xorriso, &profile_number, profile_name, 2); + if(ret == 2) + pacifier_speed= 1; + else if(ret == 3) + pacifier_speed= 2; + + ret= isoburn_igopt_new(&sopts, 0); + if(ret<=0) { + Xorriso_process_msg_queues(xorriso, 0); + return(ret); + } + relax= xorriso->relax_compliance; + + xorriso->alignment= 0; + image= isoburn_get_attached_image(source_drive); + if(image != NULL) { + iso_image_set_application_id(image, xorriso->application_id); + iso_image_set_publisher_id(image, xorriso->publisher); + } + + if((xorriso->do_aaip & 256) && out_cs != NULL) { + static char *names = "isofs.cs"; + size_t value_lengths[1]; + + value_lengths[0]= strlen(out_cs); + ret= Xorriso_setfattr(xorriso, NULL, "/", + (size_t) 1, &names, value_lengths, &out_cs, 2 | 8); + if(ret<=0) + goto ex; + } + + /* Activate, adjust or discard boot image */ + /* >>> ??? move down to libisoburn ? */ + if(image!=NULL && !(flag&1)) { + ret= iso_image_get_boot_image(image, &bootimg, NULL, NULL); + + if(xorriso->boot_image_bin_path[0]) { + /* discard old boot image, set new one */ + if(ret == 1) + iso_image_remove_boot_image(image); + if(xorriso->boot_image_emul == 1) + emul_type= ELTORITO_HARD_DISC_EMUL; + else if(xorriso->boot_image_emul == 2) + emul_type= ELTORITO_FLOPPY_EMUL; + if(xorriso->boot_image_cat_path[0] == 0) { + strcpy(xorriso->boot_image_cat_path, xorriso->boot_image_bin_path); + cpt= strrchr(xorriso->boot_image_cat_path, '/'); + if(cpt == NULL) + cpt= xorriso->boot_image_cat_path; + else + cpt++; + strcpy(cpt, "boot.cat"); + } + sprintf(xorriso->info_text, "Activating alleged isolinux boot image %s", + Text_shellsafe(xorriso->boot_image_bin_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + sprintf(xorriso->info_text, "Creating El Torito boot catalog file %s", + Text_shellsafe(xorriso->boot_image_cat_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + + ret= Xorriso_node_from_path(xorriso, image, xorriso->boot_image_bin_path, + &node, 1); + if(ret <= 0) { + sprintf(xorriso->info_text, + "Cannot find in ISO image: -boot_image ... bin_path=%s", + Text_shellsafe(xorriso->boot_image_bin_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + ret= Xorriso_node_from_path(xorriso, image, xorriso->boot_image_cat_path, + &node, 1); + if(ret > 0) { + if(!xorriso->do_overwrite) { + sprintf(xorriso->info_text, + "May not overwite existing -boot_image ... cat_path=%s", + Text_shellsafe(xorriso->boot_image_cat_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + ret= Xorriso_rmi(xorriso, NULL, (off_t) 0, xorriso->boot_image_cat_path, + 8 | (xorriso->do_overwrite == 1)); + if(ret != 1) { + sprintf(xorriso->info_text, + "Could not remove existing -boot_image cat_path=%s", + Text_shellsafe(xorriso->boot_image_cat_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + } + + ret= iso_image_set_boot_image(image, xorriso->boot_image_bin_path, + emul_type, xorriso->boot_image_cat_path, + &bootimg); + if(ret < 0) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_report_iso_error(xorriso, "", ret, + "Error when attaching El-Torito boot image to ISO 9660 image", + 0, "FAILURE", 1); + sprintf(xorriso->info_text, + "Could not attach El-Torito boot image to ISO 9660 image"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + el_torito_set_load_size(bootimg, xorriso->boot_image_load_size / 512); + +#ifdef Xorriso_with_make_isohybrid_mbR + + ret= Xorriso_set_isolinux_options(xorriso, image, 0); + if(ret <= 0) + goto ex; + +#else + el_torito_patch_isolinux_image(bootimg); +#endif + + } else if(xorriso->patch_isolinux_image) { + if(ret==1) { + relax|= isoburn_igopt_allow_full_ascii; + sprintf(xorriso->info_text, "Patching alleged isolinux boot image"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + + ret= Xorriso_path_from_lba(xorriso, NULL, xorriso->loaded_boot_bin_lba, + sfe, 1); + if(ret < 0) + goto ex; + if(ret == 0) { + sprintf(xorriso->info_text, + "Cannot patch boot image: no file found for its LBA."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + sprintf(xorriso->info_text, + "Probably the loaded boot image file was deleted in this session."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + sprintf(xorriso->info_text, + "Use -boot_image \"any\" \"discard\" or set new boot image"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0); + goto ex; + } + +#ifdef Xorriso_with_make_isohybrid_mbR + + ret= Xorriso_set_isolinux_options(xorriso, image, 0); + if(ret <= 0) + goto ex; + +#else + el_torito_patch_isolinux_image(bootimg); +#endif + + } else { + sprintf(xorriso->info_text, + "Could not find any boot image for -boot_image isolinux patch"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + } + } else if(xorriso->keep_boot_image && ret==1) { + relax|= isoburn_igopt_allow_full_ascii; + sprintf(xorriso->info_text, "Keeping boot image unchanged"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } else if(ret==1) { + iso_image_remove_boot_image(image); + sprintf(xorriso->info_text, "Discarded boot image from old session"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + } + + if((xorriso->do_aaip & 16) || !(xorriso->ino_behavior & 2)) { + /* Overwrite isofs.st of root node by xorriso->isofs_st_out */ + char *name= "isofs.st"; + char timestamp[16], *value= timestamp; + size_t value_length; + + sprintf(timestamp, "%.f", (double) xorriso->isofs_st_out); + value_length= strlen(timestamp); + Xorriso_setfattr(xorriso, NULL, "/", (size_t) 1, &name, + &value_length, &value, 2 | 8); + } + + isoburn_igopt_set_level(sopts, 3); + ext= isoburn_igopt_rockridge | + ((!!xorriso->do_joliet) * isoburn_igopt_joliet) | + (( !(xorriso->ino_behavior & 2)) * isoburn_igopt_hardlinks) | + (( (!(xorriso->ino_behavior & 2)) || + (xorriso->do_aaip & (2 | 8 | 16 | 256)) || + (xorriso->do_md5 & (2 | 4)) + ) * isoburn_igopt_aaip) | + ((!!(xorriso->do_md5 & 2)) * isoburn_igopt_session_md5) | + ((!!(xorriso->do_md5 & 4)) * isoburn_igopt_file_md5) | + ((!!(xorriso->do_md5 & 8)) * isoburn_igopt_file_stability); + isoburn_igopt_set_extensions(sopts, ext); + isoburn_igopt_set_relaxed(sopts, relax); + isoburn_igopt_set_sort_files(sopts, 1); + isoburn_igopt_set_over_mode(sopts, 0, 0, (mode_t) 0, (mode_t) 0); + isoburn_igopt_set_over_ugid(sopts, 0, 0, (uid_t) 0, (gid_t) 0); + isoburn_igopt_set_out_charset(sopts, out_cs); + isoburn_igopt_set_fifo_size(sopts, xorriso->fs * 2048); + + if(image!=NULL && + strlen(Xorriso_program_versioN)+strlen(Xorriso_timestamP)<80) { + sprintf(xorriso_id, "XORRISO-%s %s", + Xorriso_program_versioN, Xorriso_timestamP); + isoburn_version(&major, &minor, µ); + if(strlen(xorriso_id)<80) + sprintf(xorriso_id+strlen(xorriso_id), + ", LIBISOBURN-%d.%d.%d", major, minor, micro); + iso_lib_version(&major, &minor, µ); + if(strlen(xorriso_id)<80) + sprintf(xorriso_id+strlen(xorriso_id), + ", LIBISOFS-%d.%d.%d", major, minor, micro); + burn_version(&major, &minor, µ); + if(strlen(xorriso_id)<80) + sprintf(xorriso_id+strlen(xorriso_id), + ", LIBBURN-%d.%d.%d", major, minor, micro); + xorriso_id[128]= 0; + img_id= (char *) iso_image_get_data_preparer_id(image); + if(img_id!=NULL) { + for(i= strlen(img_id)-1; i>=0 && img_id[i]==' '; i--); + if(i>0) { + sprintf(xorriso->info_text, "Overwrote previous preparer id '%s'", + img_id); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + } + } + iso_image_set_data_preparer_id(image, xorriso_id); + } + + /* Make final abort check before starting expensive activities */ + ret= Xorriso_eval_problem_status(xorriso, 1, 0); + if(ret<0) + {ret= 0; goto ex;} + + if(xorriso->zisofs_by_magic) { + sprintf(xorriso->info_text, + "Checking disk file content for zisofs compression headers."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0); + root_node= (IsoNode *) iso_image_get_root(image); + ret= iso_node_zf_by_magic(root_node, + (xorriso->out_drive_handle == xorriso->in_drive_handle) | 2 | 16); + if(ret<0) { + Xorriso_report_iso_error(xorriso, "", ret, + "Error when examining file content for zisofs headers", + 0, "FAILURE", 1); + } + ret= Xorriso_eval_problem_status(xorriso, 1, 0); + if(ret<0) + {ret= 0; goto ex;} + sprintf(xorriso->info_text, + "Check for zisofs compression headers done."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0); + } + + /* >>> omit iso_image_update_sizes if the image was filled up very quickly */; + + ret= iso_image_update_sizes(image); + if(ret < 0) { + Xorriso_process_msg_queues(xorriso, 0); + if(ret<0) { + Xorriso_report_iso_error(xorriso, "", ret, + "Error when updating file sizes", + 0, "FAILURE", 1); + } + ret= Xorriso_eval_problem_status(xorriso, 1, 0); + if(ret<0) + {ret= 0; goto ex;} + } + + Xorriso_set_abort_severity(xorriso, 1); + if (xorriso->grow_blindly_msc2 >= 0 && + xorriso->out_drive_handle != xorriso->in_drive_handle) { + ret= isoburn_prepare_blind_grow(source_drive, &disc, sopts, drive, + xorriso->grow_blindly_msc2); + if(ret>0) { + /* Allow the consumer of output to access the input drive */ + source_drive= NULL; + ret= Xorriso_give_up_drive(xorriso, 1|8); + if(ret<=0) + goto ex; + } + } else if(xorriso->out_drive_handle == xorriso->in_drive_handle || + xorriso->in_drive_handle == NULL) { + ret= isoburn_prepare_disc(source_drive, &disc, sopts); + } else { + ret= isoburn_prepare_new_image(source_drive, &disc, sopts, drive); + } + if(ret <= 0) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text,"Failed to prepare session write run"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + + ret= Xorriso_make_write_options(xorriso, drive, &burn_options, 0); + if(ret<=0) + goto ex; + isoburn_igopt_get_effective_lba(sopts, &(xorriso->session_lba)); + if(xorriso->do_stream_recording == 2) { + ret= isoburn_igopt_get_data_start(sopts, &data_lba); + if(ret > 0 && data_lba >= 16) + burn_write_opts_set_stream_recording(burn_options, data_lba); + } + + ret= Xorriso_sanitize_image_size(xorriso, drive, disc, burn_options, flag&1); + if(ret<=0 || (flag&1)) { + Xorriso_process_msg_queues(xorriso,0); + if(flag&1) /* set queue severity to FAILURE */ + Xorriso_set_image_severities(xorriso, 2); + isoburn_cancel_prepared_write(source_drive, drive, 0); + if(flag&1) /* reset queue severity */ + Xorriso_set_image_severities(xorriso, 0); + goto ex; + } + + xorriso->run_state= 1; /* Indicate that burning has started */ + isoburn_disc_write(burn_options, disc); + burn_write_opts_free(burn_options); + + ret= Xorriso_pacifier_loop(xorriso, drive, pacifier_speed << 4); + if(ret<=0) + goto ex; + if(!isoburn_drive_wrote_well(drive)) { + isoburn_cancel_prepared_write(source_drive, drive, 0); + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "libburn indicates failure with writing."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + + sessions= burn_disc_get_sessions(disc, &num_sessions); + if(num_sessions>0) { + tracks= burn_session_get_tracks(sessions[0], &num_tracks); + if(tracks!=NULL && num_tracks>0) { + burn_track_get_counters(tracks[0],&readcounter,&writecounter); + xorriso->session_blocks= (int) (writecounter/ (off_t) 2048); + sprintf(xorriso->info_text, + "ISO image produced: %d sectors\nWritten to media : %d sectors at LBA %d\n", + (int) (readcounter/ (off_t) 2048), + xorriso->session_blocks, xorriso->session_lba); + Xorriso_info(xorriso, 0); + } + } + ret= isoburn_activate_session(drive); + Xorriso_process_msg_queues(xorriso,0); + if(ret<=0) { + sprintf(xorriso->info_text, + "Could not write new set of volume descriptors"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + goto ex; + } + /* Done early to free any reference to the libisofs resources via disc */ + if(disc!=NULL) + burn_disc_free(disc); + disc= NULL; + /* To wait for the end of the libisofs threads and their messages. */ + isoburn_sync_after_write(source_drive, drive, 0); + Xorriso_process_msg_queues(xorriso,0); + + sprintf(xorriso->info_text, "Writing to %s completed sucessfully.\n\n", + Text_shellsafe(xorriso->outdev,sfe,0)); + Xorriso_info(xorriso, 0); + ret= 1; +ex:; + xorriso->run_state= 0; /* Indicate that burning has ended */ + Xorriso_set_abort_severity(xorriso, 0); + + if(ret<=0) { + + /* >>> ??? revive discarded boot image */; + + } + if(disc!=NULL) + burn_disc_free(disc); + if(image != NULL) + iso_image_unref(image); + isoburn_igopt_destroy(&sopts, 0); + Xorriso_process_msg_queues(xorriso,0); + return(ret); +} + + +int Xorriso_check_burn_abort(struct XorrisO *xorriso, int flag) +{ + int ret; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + + if(xorriso->run_state!=1) + return(0); + ret= Xorriso_eval_problem_status(xorriso, 1, 1); + if(ret>=0) + return(0); + sprintf(xorriso->info_text, + "-abort_on '%s' encountered '%s' during image writing", + xorriso->abort_on_text, xorriso->problem_status_text); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, + xorriso->problem_status_text, 0); + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to abort burn run", 2); + if(ret<=0) + return(0); + + burn_drive_cancel(drive); + sprintf(xorriso->info_text, + "libburn has now been urged to cancel its operation"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(1); +} + + +/* This loop watches burn runs until they end. + It issues pacifying update messages to the user. + @param flag bit0-3 = emulation mode + 0= xorriso + 1= mkisofs + 2= cdrecord + bit4= report speed in CD units + bit5= report speed in BD units +*/ +int Xorriso_pacifier_loop(struct XorrisO *xorriso, struct burn_drive *drive, + int flag) +{ + int ret, size, free_bytes, i, aborting= 0, emul, buffer_fill= 50, last_sector; + struct burn_progress progress; + char *status_text, date_text[80], *speed_unit, mem_text[8]; + enum burn_drive_status drive_status; + double start_time, current_time, last_time, base_time= 0.0, base_count= 0.0; + double next_base_time= 0.0, next_base_count= 0.0, first_base_time= 0.0; + double first_base_count= 0.0, norm= 0.0, now_time, fract_offset= 0.0; + double measured_speed, speed_factor= 1385000, quot; + time_t time_prediction; + + start_time= Sfile_microtime(0); + while(burn_drive_get_status(drive, NULL) == BURN_DRIVE_SPAWNING) + usleep(100002); + + emul= flag&15; + fract_offset= 0.2 * (double) emul - ((int) (0.2 * (double) emul)); + if(emul==0) + emul= xorriso->pacifier_style; + speed_unit= "D"; + if(flag&16) { + speed_factor= 150.0*1024; + speed_unit= "C"; + } else if(flag & 32) { + speed_factor= 4495625; + speed_unit= "B"; + } + progress.sector= 0; + current_time= Sfile_microtime(0); + measured_speed= 0.0; + while(1) { + last_time= current_time; + last_sector= progress.sector; + drive_status= burn_drive_get_status(drive, &progress); + if(drive_status == BURN_DRIVE_IDLE) + break; + current_time= Sfile_microtime(0); + if(drive_status == BURN_DRIVE_WRITING && progress.sectors > 0) { + if(current_time-last_time>0.2) + measured_speed= (progress.sector - last_sector) * 2048.0 / + (current_time - last_time); + buffer_fill= 50; + if(progress.buffer_capacity>0) + buffer_fill= (double) (progress.buffer_capacity + - progress.buffer_available) * 100.0 + / (double) progress.buffer_capacity; + if(emul==2) { + if(progress.sector<=progress.sectors) + sprintf(xorriso->info_text, "%4d of %4d MB written", + progress.sector / 512, progress.sectors / 512); + else + sprintf(xorriso->info_text, "%4d MB written", + progress.sector / 512); + + if(xorriso->pacifier_fifo!=NULL) + ret= burn_fifo_inquire_status(xorriso->pacifier_fifo, + &size, &free_bytes, &status_text); + else + ret= isoburn_get_fifo_status(drive, &size, &free_bytes, &status_text); + if(ret>0 ) + sprintf(xorriso->info_text+strlen(xorriso->info_text), + " (fifo %2d%%)", + (int) (100.0-100.0*((double) free_bytes)/(double) size)); + + sprintf(xorriso->info_text+strlen(xorriso->info_text), " [buf %3d%%]", + buffer_fill); + + if(current_time-last_time>0.2) + sprintf(xorriso->info_text+strlen(xorriso->info_text), " %4.1fx.", + measured_speed/speed_factor); + + } else if(emul == 1 && + progress.sectors > 0 && progress.sector <= progress.sectors) { + /* "37.87% done, estimate finish Tue Jul 15 18:55:07 2008" */ + + quot= ((double) progress.sector) / ((double) progress.sectors); + sprintf(xorriso->info_text, " %2.2f%% done", quot*100.0); + if(current_time - start_time >= 2 && quot > 0.0 && + (quot >= 0.02 || progress.sector >= 5*1024)) { + if(base_time == 0.0 && progress.sector >= 16*1024) { + first_base_time= base_time= next_base_time= current_time; + first_base_count= next_base_count= progress.sector; + } else if(next_base_time > 0 && current_time - next_base_time >= 10) { + base_time= next_base_time; + base_count= next_base_count; + next_base_time= current_time; + next_base_count= progress.sector; + } + if(first_base_time > 0 && + current_time - first_base_time >= 10 && + progress.sectors > first_base_count && + progress.sector > first_base_count) { + norm= (1.0 - quot); + if(norm < 0.0001) + norm= 0.0001; + quot= ((double) progress.sector - first_base_count) + / ((double) progress.sectors - first_base_count); + time_prediction= norm * (1.0 - quot) / quot + * (current_time - first_base_time); + } else { + time_prediction= (1.0 - quot) / quot * (current_time - start_time); + norm= 1.0; + } + if(base_time > 0 && + current_time - base_time >= 10 && progress.sectors > base_count) { + quot= ((double) progress.sector - base_count) + / ((double) progress.sectors - base_count); + time_prediction+= (1.0 - quot) / quot * (current_time - base_time); + norm+= 1.0; + } + time_prediction/= norm; + if(time_prediction < 30*86400 && time_prediction > 0) { + time_prediction+= current_time + 1; + Ftimetxt(time_prediction, date_text, 4); + sprintf(xorriso->info_text+strlen(xorriso->info_text), + ", estimate finish %s", date_text); + } + } + } else { + if(progress.sector<=progress.sectors) { + if(progress.sectors <= 0) + strcpy(mem_text, " 99.9"); + else + sprintf(mem_text, "%5.1f", + 100.0 * ((double) progress.sector) / ((double) progress.sectors)); + mem_text[5]= 0; + sprintf(xorriso->info_text, "Writing: %10ds %s%% ", + progress.sector, mem_text); + } else { + Sfile_scale(2048.0 * (double) progress.sector, mem_text, 5, 1e4, 1); + sprintf(xorriso->info_text, "Writing: %10ds %s ", + progress.sector, mem_text); + } + ret= isoburn_get_fifo_status(drive, &size, &free_bytes, &status_text); + if(ret>0 ) + sprintf(xorriso->info_text+strlen(xorriso->info_text), + " fifo %3d%% buf %3d%%", + (int) (100.0-100.0*((double) free_bytes)/(double) size), + buffer_fill); + if(current_time-last_time>0.2) + sprintf(xorriso->info_text+strlen(xorriso->info_text), " %5.1fx%s ", + measured_speed/speed_factor, speed_unit); + } + } else if(drive_status == BURN_DRIVE_CLOSING_SESSION || + drive_status == BURN_DRIVE_CLOSING_TRACK) + sprintf(xorriso->info_text, + "Closing track/session. Working since %.f seconds", + current_time-start_time); + else if(drive_status == BURN_DRIVE_FORMATTING) + sprintf(xorriso->info_text, "Formatting. Working since %.f seconds", + current_time-start_time); + else + sprintf(xorriso->info_text, + "Thank you for being patient. Working since %.f seconds.", + current_time-start_time); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0); + + for(i= 0; i<12; i++) { /* 2 usleeps more than supposed to be needed */ + Xorriso_process_msg_queues(xorriso, 0); + if(aborting<=0) + aborting= Xorriso_check_burn_abort(xorriso, 0); + usleep(100000); + now_time= Sfile_microtime(0); + if(((time_t) now_time) - ((time_t) current_time) >= 1 && + now_time - ((time_t) now_time) >= fract_offset) + break; + } + } + return(1); +} + + +int Xorriso__read_pacifier(IsoImage *image, IsoFileSource *filesource) +{ + struct XorrisO *xorriso; + + xorriso= (struct XorrisO *) iso_image_get_attached_data(image); + if(xorriso==NULL) + return(1); + Xorriso_process_msg_queues(xorriso,0); + xorriso->pacifier_count++; + if(xorriso->pacifier_count%10) + return(1); + Xorriso_pacifier_callback(xorriso, "nodes read", xorriso->pacifier_count, 0, + "", 0); + return(1); +} + +/* @param flag bit0=silently return 0 if no volume/image is present +*/ +int Xorriso_get_volume(struct XorrisO *xorriso, IsoImage **volume, + int flag) +{ + if(xorriso->in_volset_handle==NULL) { + if(flag & 1) + return(0); + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text,"No ISO image present."); + if(xorriso->indev[0]==0 && xorriso->outdev[0]==0) + sprintf(xorriso->info_text+strlen(xorriso->info_text), + " No -dev, -indev, or -outdev selected."); + else + sprintf(xorriso->info_text+strlen(xorriso->info_text), + " Possible program error with drive '%s'.", xorriso->indev); + + if(!xorriso->no_volset_present) + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + xorriso->no_volset_present= 1; + return(0); + } + *volume= (IsoImage *) xorriso->in_volset_handle; + xorriso->no_volset_present= 0; + return(*volume != NULL); +} + + +/* @param flag bit0=do not complain about non existent node */ +int Xorriso_node_from_path(struct XorrisO *xorriso, IsoImage *volume, + char *path, IsoNode **node, int flag) +{ + int ret; + char sfe[5*SfileadrL], *path_pt; + + path_pt= path; + if(path[0]==0) + path_pt= "/"; + if(volume == NULL) { + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret <= 0) + return(ret); + } + *node= NULL; + ret= iso_tree_path_to_node(volume, path_pt, node); + Xorriso_process_msg_queues(xorriso,0); + if(ret<=0 || (*node)==NULL) { + if(!(flag&1)) { + sprintf(xorriso->info_text, "Cannot find path %s in loaded ISO image", + Text_shellsafe(path_pt, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + } + return(0); + } + return(1); +} + + +/* @param eff_path returns resulting effective path. + Must provide at least SfileadrL bytes of storage. + @param flag bit0= do not produce problem events (unless faulty path format) + bit1= work purely literally, do not use libisofs + bit2= (with bit1) this is an address in the disk world + bit3= return root directory as "/" and not as "" + bit4= (with bit2) determine type of disk file eff_path + and return 0 if not existing + bit5= (with bit3) this is not a parameter + bit6= insist in having an ISO image, even with bits1+2 + @return -1 = faulty path format, 0 = not found , + 1 = found simple node , 2 = found directory +*/ +int Xorriso_normalize_img_path(struct XorrisO *xorriso, char *wd, + char *img_path, char eff_path[], int flag) +{ + int ret, is_dir= 0, done= 0; + IsoImage *volume; + IsoDir *dir= NULL; + IsoNode *node= NULL; + char path[SfileadrL], *apt, *npt, sfe[5*SfileadrL], *cpt; + + if((flag&64) || !(flag&2)) { + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(ret); + } + + eff_path[0]= 0; + if(img_path[0]==0) { + if(flag&8) + strcpy(eff_path, "/"); + return(2); /* root directory */ + } + + apt= npt= path; + if(img_path[0]!='/') { + strcpy(path, wd); + ret= Sfile_add_to_path(path, img_path, 0); + if(ret<=0) + goto much_too_long; + } else + if(Sfile_str(path, img_path, 0)<=0) + return(-1); + + if(path[0]!='/') { + sprintf(xorriso->info_text, + "Internal error: Unresolvable relative addressing in iso_rr_path '%s'", + img_path); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FATAL", 0); + return(-1); + } else if(path[1]==0) { + if(flag&8) + strcpy(eff_path, "/"); + return(2); /* root directory */ + } + + for(npt= apt; !done; apt= npt+1) { + npt= strchr(apt, '/'); + if(npt==NULL) { + npt= apt+strlen(apt); + done= 1; + } else + *npt= 0; + if(*apt==0) { + *apt= '/'; + apt++; + if(done) + break; + continue; + } + if(strcmp(apt,".")==0) { + is_dir= 1; + continue; + } + if(strcmp(apt,"..")==0) { + if(!(flag&2)) { + node= (IsoNode *) dir; + if(node==NULL) { +bonked_root:; + sprintf(xorriso->info_text, + "Relative addressing in path exceeds root directory: %s", + Text_shellsafe(img_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(-1); + } + dir= iso_node_get_parent(node); + } + /* truncate eff_path */; + cpt= strrchr(eff_path, '/'); + if(cpt==NULL) /* ??? if not flag&2 then this is a bug */ + goto bonked_root; + *cpt= 0; + is_dir= 1; + continue; + } + ret= Sfile_add_to_path(eff_path, apt, 0); + if(ret<=0) { +much_too_long:; + sprintf(xorriso->info_text, "Effective path gets much too long (%d)", + (int) (strlen(eff_path)+strlen(apt)+1)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(-1); + } + if(!(flag&2)) { + dir= (IsoDir *) node; + ret= Xorriso_node_from_path(xorriso, volume, eff_path, &node, flag&1); + if(ret<=0) + return(0); + if(dir==NULL) /* could be false with "/dir/.." */ + dir= iso_node_get_parent(node); + is_dir= LIBISO_ISDIR(node); + } + } + if(flag&16) { + ret= Sfile_type(eff_path, + 1|(4*(xorriso->do_follow_links || (xorriso->do_follow_param && !(flag&32))) + )); + if(ret<0) + return(0); + if(ret==2) + is_dir= 1; + } + return(1+!!is_dir); +} + + +int Xorriso_get_node_by_path(struct XorrisO *xorriso, + char *in_path, char *eff_path, + IsoNode **node, int flag) +{ + int ret; + char path[SfileadrL]; + IsoImage *volume; + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, in_path, path, 0); + if(ret<=0) + return(ret); + if(eff_path!=NULL) + strcpy(eff_path, path); + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(ret); + ret= Xorriso_node_from_path(xorriso, volume, path, node, 0); + if(ret<=0) + return(0); + return(1); +} + + +/* @param flag +*/ +int Xorriso_node_get_dev(struct XorrisO *xorriso, IsoNode *node, + char *path, dev_t *dev, int flag) +{ + *dev= iso_special_get_dev((IsoSpecial *) node); + return(1); +} + + +/* @param flag bit0= *node is already valid + bit1= add extra block for size estimation + bit2= complain loudely if path is missing in image + bit3= stbuf is to be used without eventual ACL + bit4= try to obtain a better st_nlink count if hardlinks + are enabled +*/ +int Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf, + IsoNode **node, int flag) +{ + int ret, min_hl, max_hl, node_idx, i; + IsoImage *volume; + + memset((char *) stbuf, 0, sizeof(struct stat)); + if(!(flag&1)) { + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(-1); + ret= Xorriso_node_from_path(xorriso, volume, path, node, !(flag&4)); + if(ret<=0) + *node= NULL; + } + if(*node==NULL) + return(0); + + /* >>> stbuf->st_dev */ + /* >>> stbuf->st_ino */ + + if(flag & 8) + stbuf->st_mode= iso_node_get_perms_wo_acl(*node) & 07777; + else + stbuf->st_mode= iso_node_get_permissions(*node) & 07777; + if(LIBISO_ISDIR(*node)) + stbuf->st_mode|= S_IFDIR; + else if(LIBISO_ISREG(*node)) + stbuf->st_mode|= S_IFREG; + else if(LIBISO_ISLNK(*node)) + stbuf->st_mode|= S_IFLNK; + else if(LIBISO_ISCHR(*node)) { + stbuf->st_mode|= S_IFCHR; + Xorriso_node_get_dev(xorriso, *node, path, &(stbuf->st_rdev), 0); + } else if(LIBISO_ISBLK(*node)) { + stbuf->st_mode|= S_IFBLK; + Xorriso_node_get_dev(xorriso, *node, path, &(stbuf->st_rdev), 0); + } else if(LIBISO_ISFIFO(*node)) + stbuf->st_mode|= S_IFIFO; + else if(LIBISO_ISSOCK(*node)) + stbuf->st_mode|= S_IFSOCK; + else if(LIBISO_ISBOOT(*node)) + stbuf->st_mode|= Xorriso_IFBOOT; + + /* >>> With directories this should be : number of subdirs + 2 */ + /* >>> ??? How to obtain RR hardlink number for other types ? */ + /* This may get overriden farther down */ + stbuf->st_nlink= 1; + + stbuf->st_uid= iso_node_get_uid(*node); + stbuf->st_gid= iso_node_get_gid(*node); + + if(LIBISO_ISREG(*node)) + stbuf->st_size= iso_file_get_size((IsoFile *) *node)+ (2048 * !!(flag&2)); + else + stbuf->st_size= 0; + + stbuf->st_blksize= 2048; + stbuf->st_blocks= stbuf->st_size / (off_t) 2048; + if(stbuf->st_blocks * (off_t) 2048 != stbuf->st_size) + stbuf->st_blocks++; + + stbuf->st_atime= iso_node_get_atime(*node); + stbuf->st_mtime= iso_node_get_mtime(*node); + stbuf->st_ctime= iso_node_get_ctime(*node); + + if(LIBISO_ISDIR(*node) || (xorriso->ino_behavior & 1) || (!(flag & 16)) || + xorriso->hln_array == NULL) + return(1); + + /* Try to obtain a better link count */ + ret= Xorriso_search_hardlinks(xorriso, *node, &node_idx, &min_hl, &max_hl, 0); + if(ret < 0) + return(ret); + if(ret > 0 && node_idx >= 0) { + for(i= min_hl; i <= max_hl; i++) { + if(i == node_idx) + continue; + /* Check whether node is still valid */ + if(iso_node_get_parent(xorriso->hln_array[i]) != NULL) + stbuf->st_nlink++; + } + } + return(1); +} + + +/* @param flag >>> bit0= follow links (i.e. stat() rather than lstat() + bit1= do not return -2 on severe errors + bit2= complain loudely if path is missing in image +*/ +int Xorriso_iso_lstat(struct XorrisO *xorriso, char *path, struct stat *stbuf, + int flag) +{ + int ret; + IsoNode *node; + + if(flag&1) { + + /* >>> follow link in ISO image */; + + } + + ret= Xorriso_fake_stbuf(xorriso, path, stbuf, &node, flag&4); + if(ret>0) + return(0); + if(ret<0 && !(flag&2)) + return(-2); + return(-1); +} + + +/* @param flag bit0= give directory x-permission where is r-permission + bit1= do not transfer ACL or xattr + bit2= record dev,inode (only if enabled by xorriso) + bit5= transfer ACL or xattr from eventual link target +*/ +int Xorriso_transfer_properties(struct XorrisO *xorriso, struct stat *stbuf, + char *disk_path, IsoNode *node, int flag) +{ + mode_t mode; + int ret= 1; + size_t num_attrs= 0, *value_lengths= NULL; + char **names= NULL, **values= NULL; + + mode= stbuf->st_mode; + + if((!(flag & 2)) && !(xorriso->do_aaip & 1)) + /* Will drop ACL. Update mode S_IRWXG by eventual group:: ACL entry */ + iso_local_get_perms_wo_acl(disk_path, &mode, flag & 32); + + if((flag&1) && S_ISDIR(mode)) { + if(mode&S_IRUSR) + mode|= S_IXUSR; + if(mode&S_IRGRP) + mode|= S_IXGRP; + if(mode&S_IROTH) + mode|= S_IXOTH; + } + iso_node_set_permissions(node, mode & 07777); + iso_node_set_uid(node, stbuf->st_uid); + iso_node_set_gid(node, stbuf->st_gid); + iso_node_set_atime(node, stbuf->st_atime); + iso_node_set_mtime(node, stbuf->st_mtime); + iso_node_set_ctime(node, stbuf->st_ctime); + + if((xorriso->do_aaip & 5) && !(flag & 2)) { + ret= iso_local_get_attrs(disk_path, &num_attrs, &names, &value_lengths, + &values, ((xorriso->do_aaip & 1) && !(flag & 2)) + | ((!(xorriso->do_aaip & 4)) << 2) + | (flag & 32)); + if(ret < 0) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_report_iso_error(xorriso, disk_path, ret, + "Error when obtaining local ACL and xattr", 0, + "FAILURE", 1 | 2); + ret= 0; goto ex; + } + ret= iso_node_set_attrs(node, num_attrs, names, value_lengths, values, + 1 | 8); + if(ret < 0) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_report_iso_error(xorriso, "", ret, + "Error when setting ACL and xattr to image node", + 0, "FAILURE", 1); + ret= 0; goto ex; + } + } + + if((flag & 4) && ((xorriso->do_aaip & 16) || !(xorriso->ino_behavior & 2))) { + ret= Xorriso_record_dev_inode(xorriso, disk_path, (dev_t) 0, (ino_t) 0, + (void *) node, "", flag & 32); + if(ret <= 0) + goto ex; + } + + ret= 1; +ex:; + Xorriso_process_msg_queues(xorriso,0); + iso_local_get_attrs(disk_path, &num_attrs, &names, &value_lengths, + &values, 1 << 15); /* free memory */ + return(ret); +} + + +int Xorriso_graft_split(struct XorrisO *xorriso, IsoImage *volume, + IsoDir *dir, char *disk_path, char *img_name, + char *nominal_source, char *nominal_target, + off_t size, IsoNode **node, int flag) +{ + int ret; + IsoDir *new_dir= NULL; + IsoNode *part_node; + int partno, total_parts; + off_t offset; + char part_name[SfileadrL], sfe[5*SfileadrL]; + + ret= iso_tree_add_new_dir(dir, img_name, &new_dir); + if(ret<0) + return(ret); + *node= (IsoNode *) new_dir; + + total_parts= size / xorriso->split_size; + if(size % xorriso->split_size) + total_parts++; + for(partno= 1; partno<=total_parts; partno++) { + offset = xorriso->split_size * (off_t) (partno-1); + Splitpart__compose(part_name, partno, total_parts, offset, + xorriso->split_size, size, 0); + ret= Xorriso_tree_graft_node(xorriso, volume, + new_dir, disk_path, part_name, + nominal_source, nominal_target, + offset, xorriso->split_size, + &part_node, 8); + if(ret<=0) + return(0); + } + sprintf(xorriso->info_text, "Split into %d parts: %s", + total_parts, Text_shellsafe(nominal_target, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(1); +} + + +/* + @param flag bit3= cut_out_node: offset and size are valid +*/ +int Xorriso_tree_graft_node(struct XorrisO *xorriso, IsoImage *volume, + IsoDir *dir, char *disk_path, char *img_name, + char *nominal_source, char *nominal_target, + off_t offset, off_t cut_size, + IsoNode **node, int flag) +{ + int ret, stbuf_valid= 0; + struct stat stbuf; + char sfe[5*SfileadrL]; + off_t size= 0; + + if(lstat(disk_path, &stbuf) != -1) { + stbuf_valid= 1; + if(S_ISREG(stbuf.st_mode)) + size= stbuf.st_size; + } + if(flag&8) { + if(cut_size > xorriso->file_size_limit && xorriso->file_size_limit > 0) { + sprintf(xorriso->info_text, + "File piece exceeds size limit of %.f bytes: %.f from %s\n", + (double) xorriso->file_size_limit, (double) cut_size, + Text_shellsafe(disk_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + ret= iso_tree_add_new_cut_out_node(volume, dir, img_name, disk_path, + offset, cut_size, node); + if(ret<0) + goto ex; + } else { + if(xorriso->split_size > 0 && size > xorriso->split_size) { + ret= Xorriso_graft_split(xorriso, volume, dir, disk_path, img_name, + nominal_source, nominal_target, size, + node, 0); + if(ret<=0) + goto ex; + return(1); + } else if(size > xorriso->file_size_limit && xorriso->file_size_limit > 0) { + sprintf(xorriso->info_text, + "File exceeds size limit of %.f bytes: %s\n", + (double) xorriso->file_size_limit, + Text_shellsafe(disk_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + ret= iso_tree_add_new_node(volume, dir, img_name, disk_path, node); + if(ret<0) + goto ex; + } + + if(stbuf_valid && ((xorriso->do_aaip & 16) || !(xorriso->ino_behavior & 2))) { + ret= Xorriso_record_dev_inode(xorriso, disk_path, + stbuf.st_dev, stbuf.st_ino, (void *) *node, "", 1); + if(ret <= 0) + goto ex; + } + +ex:; + if(ret<0) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_report_iso_error(xorriso, nominal_source, ret, + "Cannot add node to tree", 0, "FAILURE", 1|2); + return(ret); + } + if(LIBISO_ISREG(*node)) + xorriso->pacifier_byte_count+= iso_file_get_size((IsoFile *) *node); + return(1); +} + + +/* @param flag bit0= recursion is active + bit1= do not report added files + bit6= do not delete eventually existing node from di_array +*/ +int Xorriso_add_tree(struct XorrisO *xorriso, IsoDir *dir, + char *img_dir_path, char *disk_dir_path, + struct LinkiteM *link_stack, int flag) +{ + IsoImage *volume; + IsoNode *node; + int ret, target_is_dir, source_is_dir, source_is_link, fret, was_failure= 0; + int do_not_dive, target_is_split= 0; + struct DirseQ *dirseq= NULL; + char *name, *img_name, *srcpt, *stbuf_src= ""; + struct stat stbuf, hstbuf; + dev_t dir_dev; + struct LinkiteM *own_link_stack; + char *sfe= NULL, *sfe2= NULL; + char *disk_path= NULL, *img_path= NULL, *link_target= NULL; + + /* Avoiding large local memory objects in order to save stack space */ + sfe= malloc(5*SfileadrL); + sfe2= malloc(5*SfileadrL); + disk_path= malloc(2*SfileadrL); + img_path= malloc(2*SfileadrL); + link_target= calloc(SfileadrL, 1); + if(sfe==NULL || sfe2==NULL || disk_path==NULL || img_path==NULL || + link_target==NULL) { + Xorriso_no_malloc_memory(xorriso, &sfe, 0); + {ret= -1; goto ex;} + } + + own_link_stack= link_stack; + + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + goto ex; + + stbuf_src= disk_dir_path; + if(lstat(disk_dir_path, &stbuf)==-1) + goto cannot_open_dir; + dir_dev= stbuf.st_dev; + if(S_ISLNK(stbuf.st_mode)) { + if(!(xorriso->do_follow_links || (xorriso->do_follow_param && !(flag&1)))) + {ret= 2; goto ex;} + stbuf_src= disk_dir_path; + if(stat(disk_dir_path, &stbuf)==-1) + goto cannot_open_dir; + if(dir_dev != stbuf.st_dev && + !(xorriso->do_follow_mount || (xorriso->do_follow_param && !(flag&1)))) + {ret= 2; goto ex;} + } + ret= Dirseq_new(&dirseq, disk_dir_path, 1); + if(ret<0) { + sprintf(xorriso->info_text,"Failed to create source filesystem iterator"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + if(ret==0) { +cannot_open_dir:; + Xorriso_msgs_submit(xorriso, 0, disk_dir_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text,"Cannot open as source directory: %s", + Text_shellsafe(disk_dir_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + + if(Sfile_str(disk_path, disk_dir_path,0)<=0) + {ret= -1; goto ex;} + if(disk_path[0]==0 || disk_path[strlen(disk_path)-1]!='/') + strcat(disk_path,"/"); + name= disk_path+strlen(disk_path); + if(Sfile_str(img_path, img_dir_path, 0)<=0) + {ret= -1; goto ex;} + if(img_path[0] || img_path[strlen(img_path)-1]!='/') + strcat(img_path,"/"); + img_name= img_path+strlen(img_path); + + while(1) { /* loop over directory content */ + stbuf_src= ""; + Linkitem_reset_stack(&own_link_stack, link_stack, 0); + srcpt= disk_path; + Xorriso_process_msg_queues(xorriso,0); + ret= Dirseq_next_adr(dirseq,name,0); /* name is a pointer into disk_path */ + if(ret==0) + break; + if(ret<0) { + sprintf(xorriso->info_text,"Failed to obtain next directory entry"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + + /* compare exclusions against disk_path resp. name */ + ret= Xorriso_path_is_excluded(xorriso, disk_path, 0); /* (is never param) */ + if(ret<0) + {ret= -1; goto ex;} + if(ret>0) + continue; + + strcpy(img_name, name); + if(Xorriso_much_too_long(xorriso, strlen(img_path), 0)<=0) + {ret= 0; goto was_problem;} + if(Xorriso_much_too_long(xorriso, strlen(srcpt), 0)<=0) + {ret= 0; goto was_problem;} + stbuf_src= srcpt; + if(lstat(srcpt, &stbuf)==-1) { +cannot_lstat:; + Xorriso_msgs_submit(xorriso, 0, srcpt, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "Cannot determine attributes of source file %s", + Text_shellsafe(srcpt, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + ret= 0; goto was_problem; + } + source_is_dir= 0; + source_is_link= S_ISLNK(stbuf.st_mode); + if(xorriso->do_follow_links && source_is_link) { + /* Xorriso_hop_link checks for wide link loops */ + ret= Xorriso_hop_link(xorriso, srcpt, &own_link_stack, &hstbuf, 0); + if(ret<0) + goto was_problem; + if(ret==1) { + ret= Xorriso_resolve_link(xorriso, srcpt, link_target, 0); + if(ret<=0) + goto was_problem; + srcpt= link_target; + stbuf_src= srcpt; + if(lstat(srcpt, &stbuf)==-1) + goto cannot_lstat; + } else { + if(Xorriso_eval_problem_status(xorriso, 0, 1|2)<0) + {ret= 0; goto was_problem;} + ret= Xorriso_resolve_link(xorriso, srcpt, link_target, 1); + if(ret<=0) + goto was_problem; + } + } else if (S_ISLNK(stbuf.st_mode)) { + ret= Xorriso_resolve_link(xorriso, srcpt, link_target, 1); + if(ret<=0) + goto was_problem; + } + do_not_dive= 0; + if(S_ISDIR(stbuf.st_mode)) { + source_is_dir= 1; + if(dir_dev != stbuf.st_dev && !xorriso->do_follow_mount) + do_not_dive= 1; + } + + /* does a node exist with this name ? */ + node= NULL; + ret= Xorriso_node_from_path(xorriso, volume, img_path, &node, 1); + if(ret>0) { + target_is_dir= LIBISO_ISDIR(node); + target_is_split= 0; + if(target_is_dir) + target_is_split= Xorriso_is_split(xorriso, "", (void *) node, 1); + + if(!((target_is_dir && !target_is_split) && source_is_dir)) { + Xorriso_process_msg_queues(xorriso,0); + + /* handle overwrite situation */; + if(xorriso->do_overwrite==1 || + (xorriso->do_overwrite==2 && !(target_is_dir && !target_is_split))) { + ret= Xorriso_rmi(xorriso, NULL, (off_t) 0, img_path, + 1 | 8 | (flag & 64)); + if(ret<=0) + goto was_problem; + if(ret==3) { + sprintf(xorriso->info_text, "User revoked adding of: %s", + Text_shellsafe(img_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + ret= 0; goto was_problem; + } + node= NULL; + } else { + Xorriso_msgs_submit(xorriso, 0, srcpt, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "While grafting %s : file object exists and may not be overwritten by %s", + Text_shellsafe(img_path,sfe,0), Text_shellsafe(stbuf_src,sfe2,0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto was_problem; + } + } + } + + if(node==NULL) { + ret= Xorriso_tree_graft_node(xorriso, volume, dir, srcpt, img_name, + "", img_path, (off_t) 0, (off_t) 0, + &node, 0); + } + if(node==NULL) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_msgs_submit(xorriso, 0, stbuf_src, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, "Grafting failed: %s = %s", + Text_shellsafe(img_path,sfe,0), Text_shellsafe(stbuf_src,sfe2,0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto was_problem; + } + + xorriso->pacifier_count++; + if((xorriso->pacifier_count%100)==0) + Xorriso_pacifier_callback(xorriso, "files added", xorriso->pacifier_count, + xorriso->pacifier_total, "", 0); + + Xorriso_set_change_pending(xorriso, 0); + if(source_is_dir) { + if(do_not_dive) { + sprintf(xorriso->info_text, "Did not follow mount point : %s", + Text_shellsafe(disk_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } else { + ret= Xorriso_add_tree(xorriso, (IsoDir *) node, + img_path, disk_path, own_link_stack, + 1 | (flag & (2 | 64))); + } + if(ret<=0) + goto was_problem; + } + + continue; /* regular bottom of loop */ +was_problem:; + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret<0) + goto ex; + } + + ret= 1; +ex: + if(sfe!=NULL) + free(sfe); + if(sfe2!=NULL) + free(sfe2); + if(disk_path!=NULL) + free(disk_path); + if(img_path!=NULL) + free(img_path); + if(link_target!=NULL) + free(link_target); + Xorriso_process_msg_queues(xorriso,0); + Linkitem_reset_stack(&own_link_stack, link_stack, 0); + Dirseq_destroy(&dirseq, 0); + if(ret<=0) + return(ret); + return(!was_failure); +} + + +/* @param flag bit0= cut_out mode : base on leaf parent directory +*/ +int Xorriso_copy_implicit_properties(struct XorrisO *xorriso, IsoDir *dir, + char *full_img_path, char *img_path, char *full_disk_path, int flag) +{ + int ret, nfic, nic, nfdc, d, i; + char nfi[SfileadrL], ni[SfileadrL], nfd[SfileadrL], *cpt; + char sfe[5*SfileadrL]; + struct stat stbuf; + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, full_img_path, nfi, + 1|2); + if(ret<=0) + return(ret); + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, img_path, ni, 1|2); + if(ret<=0) + return(ret); + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, full_disk_path, nfd, + 1|2|4); + if(ret<=0) + return(ret); + nfic= Sfile_count_components(nfi, 0); + nic= Sfile_count_components(ni, 0); + nfdc= Sfile_count_components(nfd, 0); + d= nfic-(flag&1)-nic; + if(d<0) + return(-1); + if(d>nfdc) + return(0); + for(i= 0; iinfo_text, + "Copied properties for %s", Text_shellsafe(ni, sfe, 0)); + sprintf(xorriso->info_text+strlen(xorriso->info_text), + " from %s", Text_shellsafe(nfd, sfe, 0)); + if(!((flag&1) && d==0)) + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + return(1); +} + + +/* @param bit0= copy link target properties rather than link properties + bit1= give directory x-permission where is r-permission + bit2= record dev,inode (only if enabled by xorriso) +*/ +int Xorriso_copy_properties(struct XorrisO *xorriso, + char *disk_path, char *img_path, int flag) +{ + int ret; + IsoNode *node; + struct stat stbuf; + + ret= Xorriso_get_node_by_path(xorriso, img_path, NULL, &node, 0); + if(ret<=0) + return(ret); + if(flag & 1) { + if(stat(disk_path, &stbuf)==-1) + return(0); + } else { + if(lstat(disk_path, &stbuf)==-1) + return(0); + } + Xorriso_transfer_properties(xorriso, &stbuf, disk_path, node, + ((flag & 2) >> 1) | ((flag & 1) << 5) | (flag & 4)); + Xorriso_set_change_pending(xorriso, 0); + return(1); +} + + +/* @param boss_iter Opaque handle to be forwarded to actions in ISO image + Set to NULL if calling this function from outside ISO world + @param flag bit0= mkdir: graft in as empty directory, not as copy from disk + bit1= do not report added files + bit2= -follow, -not_*: this is not a command parameter + bit3= use offset and cut_size for cut_out_node + bit4= return 3 on rejection by exclusion or user + bit5= if directory then do not add sub tree + bit6= do not delete eventually existing node from di_array + bit7= no special handling of split file directories + @return <=0 = error , 1 = added simple node , 2 = added directory , + 3 = rejected +*/ +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) +{ + IsoImage *volume; + char path[SfileadrL], *apt, *npt, *cpt, sfe[5*SfileadrL], sfe2[5*SfileadrL]; + char *disk_path_pt, resolved_disk_path[SfileadrL]; + IsoDir *dir, *hdir; + IsoNode *node; + int done= 0, is_dir= 0, l, ret, target_is_dir, source_is_dir, resolve_link= 0; + int target_is_split; + struct stat stbuf; + + ret= Xorriso_path_is_excluded(xorriso, disk_path, !(flag&4)); + if(ret<0) + return(ret); + if(ret>0) + return(3*!!(flag&16)); + + for(cpt= img_path; 1; cpt++) { + cpt= strstr(cpt,"/."); + if(cpt==NULL) + break; + if(cpt[2]=='.') { + if(cpt[3]=='/' || cpt[3]==0) + break; + } else if(cpt[2]=='/' || cpt[2]==0) + break; + } + if(cpt!=NULL) { + Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "Unsupported relative addressing in iso_rr_path %s (disk: %s)", + Text_shellsafe(img_path, sfe, 0), Text_shellsafe(disk_path, sfe2, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + return(0); + } + + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(ret); + + strncpy(path, img_path, sizeof(path)-1); + path[sizeof(path)-1]= 0; + apt= npt= path; + + if(!(flag&1)) { + ret= lstat(disk_path, &stbuf); + if(ret!=-1) { + if(S_ISDIR(stbuf.st_mode)) + is_dir= 1; + else if((stbuf.st_mode&S_IFMT)==S_IFLNK && + (xorriso->do_follow_links || + (xorriso->do_follow_param && !(flag&4)))) { + resolve_link= 1; + ret= stat(disk_path, &stbuf); + if(ret!=-1) { + if(S_ISDIR(stbuf.st_mode)) + is_dir= 1; + } + } + } + if(ret == -1) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "Cannot determine attributes of source file %s", + Text_shellsafe(disk_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + return(0); + } + if(S_ISDIR(stbuf.st_mode)) { + is_dir= 1; + } else { + l= strlen(img_path); + if(l>0) + if(img_path[l-1]=='/') + l= 0; + if(l==0) { + Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "Source '%s' is not a directory. Target '%s' would be.", + Text_shellsafe(disk_path, sfe, 0), Text_shellsafe(img_path, sfe2, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + } + } + + dir= iso_image_get_root(volume); + if(dir==NULL) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "While grafting '%s' : no root node available", img_path); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(0); + } + for(npt= apt; !done; apt= npt+1) { + npt= strchr(apt, '/'); + if(npt==NULL) { + npt= apt+strlen(apt); + done= 1; + } else + *npt= 0; + if(*apt==0) { + *apt= '/'; + apt++; + if(done) + goto attach_source; + continue; + } + source_is_dir= (is_dir || (flag&1) || !done); + ret= Xorriso_node_from_path(xorriso, volume, path, &node, 1); + if(ret>0) { + target_is_dir= LIBISO_ISDIR(node); + + target_is_split= 0; + if(target_is_dir && !(flag&128)) + target_is_split= Xorriso_is_split(xorriso, "", (void *) node, 1); + + if(!((target_is_dir && !target_is_split) && source_is_dir)) { + Xorriso_process_msg_queues(xorriso,0); + + /* handle overwrite situation */; + if(xorriso->do_overwrite==1 || + (xorriso->do_overwrite==2 && !(target_is_dir && !target_is_split))) { + ret= Xorriso_rmi(xorriso, boss_iter, (off_t) 0, path, + 1 | 8 | (flag & 64)); + if(ret<=0) + return(ret); + if(ret==3) { + sprintf(xorriso->info_text, "User revoked adding of: %s", + Text_shellsafe(disk_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(3*!!(flag&16)); + } + node= NULL; + goto handle_path_node; + } + + Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "While grafting '%s' : '%s' exists and may not be overwritten", + img_path, path); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + dir= (IsoDir *) node; + } + +handle_path_node:; + if(node==NULL && source_is_dir) { /* make a directory */ + ret= iso_tree_add_new_dir(dir, apt, &hdir); + if(ret<0) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0); + Xorriso_report_iso_error(xorriso, img_path, ret, + "Cannot create directory", 0, "FAILURE", 1); + sprintf(xorriso->info_text, + "While grafting '%s' : could not insert '%s'", img_path, path); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + dir= hdir; + Xorriso_set_change_pending(xorriso, 0); + iso_node_set_ctime((IsoNode *) dir, time(NULL)); + iso_node_set_uid((IsoNode *) dir, geteuid()); + iso_node_set_gid((IsoNode *) dir, getegid()); + + if(disk_path!=NULL && !done) + Xorriso_copy_implicit_properties(xorriso, dir, img_path, path, disk_path, + !!(flag&8)); + + } + if(done) { +attach_source:; + if(flag&1) { + /* directory node was created above */; + + } else if(is_dir) { + Xorriso_transfer_properties(xorriso, &stbuf, disk_path, + (IsoNode *) dir, 4 | 32); + if(!(flag&32)) { + ret= Xorriso_add_tree(xorriso, dir, img_path, disk_path, NULL, + flag & (2 | 64)); + if(ret<=0) + return(ret); + } + } else { + if(resolve_link) { + ret= Xorriso_resolve_link(xorriso, disk_path, resolved_disk_path, 0); + if(ret<=0) + return(ret); + disk_path_pt= resolved_disk_path; + } else + disk_path_pt= disk_path; + + ret= Xorriso_tree_graft_node(xorriso, volume, dir, disk_path_pt, apt, + disk_path, img_path, + offset, cut_size, &node, flag&8); + if(ret<=0) { + sprintf(xorriso->info_text, "Grafting failed: %s = %s", + Text_shellsafe(img_path,sfe,0), Text_shellsafe(disk_path,sfe2,0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + Xorriso_set_change_pending(xorriso, 0); + iso_node_set_name(node, apt); + + xorriso->pacifier_count++; + if(xorriso->pacifier_count%100 && !(flag&2)) + Xorriso_pacifier_callback(xorriso, "files added", + xorriso->pacifier_count, + xorriso->pacifier_total, "", 0); + } + } else + *npt= '/'; + } + Xorriso_process_msg_queues(xorriso,0); + return(1+!!is_dir); +} + + +/* @param flag bit0= -follow: disk_path is not a command parameter +*/ +int Xorriso_cut_out(struct XorrisO *xorriso, char *disk_path, + off_t startbyte, off_t bytecount, char *iso_rr_path, int flag) +{ + int ret; + char eff_source[SfileadrL], eff_dest[SfileadrL], sfe[SfileadrL*5]; + struct stat stbuf; + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, disk_path, eff_source, + 2|4); + if(ret<=0) + return(ret); + ret= Xorriso_path_is_excluded(xorriso, disk_path, !(flag&1)); + if(ret!=0) + return(0); + + if(lstat(eff_source, &stbuf)==-1) { + Xorriso_msgs_submit(xorriso, 0, eff_source, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, "-cut_out: Cannot determine type of %s", + Text_shellsafe(eff_source, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + return(0); + } + + if((stbuf.st_mode&S_IFMT) == S_IFLNK) { + if(!(xorriso->do_follow_links || (xorriso->do_follow_param && !(flag&1)))) + goto unsupported_type; + if(stat(eff_source, &stbuf)==-1) { + Xorriso_msgs_submit(xorriso, 0, eff_source, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "-cut_out: Cannot determine link target type of %s", + Text_shellsafe(eff_source, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0); + return(0); + } + } + if(S_ISREG(stbuf.st_mode)) { + if(stbuf.st_sizeinfo_text, + "-cut_out: Byte offset %.f larger than file size %.f", + (double) startbyte, (double) stbuf.st_size); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "SORRY", 0); + return(0); + } + } else { +unsupported_type:; + Xorriso_msgs_submit(xorriso, 0, eff_source, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, "-cut_out: Unsupported file type (%s) with %s", + Ftypetxt(stbuf.st_mode, 0), Text_shellsafe(eff_source, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + return(0); + } + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, iso_rr_path, eff_dest, + 2); + if(ret<=0) + return(ret); + + ret= Xorriso_graft_in(xorriso, NULL, eff_source, eff_dest, + startbyte, bytecount, 8); + return(ret); +} + + +/* @param flag bit0= in_node is valid, do not resolve img_path + bit1= test mode: print DEBUG messages + @return <0 = error, + 0 = surely not identical regular files , + 1 = surely identical + 2 = potentially depending on unknown disk file (e.g. -cut_out) +*/ +int Xorriso_restore_is_identical(struct XorrisO *xorriso, void *in_node, + char *img_path, char *disk_path, + char type_text[5], int flag) +{ + int ret; + unsigned int fs_id; + dev_t dev_id; + ino_t ino_id; + IsoStream *stream; + IsoImage *volume; + IsoNode *node; + struct stat stbuf; + int dummy; + + memset(type_text, 0, 5); + if(!xorriso->volset_change_pending) + return(0); + if(flag&1) { + node= (IsoNode *) in_node; + } else { + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(-1); + ret= Xorriso_node_from_path(xorriso, volume, img_path, &node, 1); + if(ret<=0) + return(-1); + } + ret= Xorriso__file_start_lba(node, &dummy, 0); + if(ret != 0) { + Xorriso_process_msg_queues(xorriso, 0); + return(0); + } + if(!LIBISO_ISREG(node)) + return(0); + stream= iso_file_get_stream((IsoFile *) node); + memcpy(type_text, stream->class->type, 4); + iso_stream_get_id(stream, &fs_id, &dev_id, &ino_id); + if(flag&2) { + sprintf(xorriso->info_text, "%s : fs=%d dev=%.f ino=%.f (%s)", + img_path, fs_id, (double) dev_id, (double) ino_id, type_text); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + } + ret= stat(disk_path, &stbuf); + if(ret==-1) + return(0); + if(flag&2) { + sprintf(xorriso->info_text, "%s : dev=%.f ino=%.f", + disk_path, (double) stbuf.st_dev, (double) stbuf.st_ino); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + } + if(fs_id!=1) + return(2); + + /* >>> obtain underlying dev_t ino_t of type "cout" */; + + if(strcmp(type_text, "fsrc")!=0) + return(2); + if(stbuf.st_dev==dev_id && stbuf.st_ino==ino_id) + return(1); + return(0); +} + + +/* @param flag bit0= minimal transfer: access permissions only + bit1= keep directory open: keep owner, allow rwx for owner + and push directory onto xorriso->perm_stack +*/ +int Xorriso_restore_properties(struct XorrisO *xorriso, char *disk_path, + IsoNode *node, int flag) +{ + int ret, is_dir= 0; + mode_t mode; + uid_t uid; + gid_t gid; + struct utimbuf utime_buffer; + char sfe[5*SfileadrL]; + struct stat stbuf; + size_t num_attrs= 0, *value_lengths= NULL; + char **names= NULL, **values= NULL; + + ret= lstat(disk_path, &stbuf); + if(ret==-1) { + sprintf(xorriso->info_text, + "Cannot obtain properties of disk file %s", + Text_shellsafe(disk_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + {ret= 0; goto ex;} + } + uid= stbuf.st_uid; + + is_dir= S_ISDIR(stbuf.st_mode); + + mode= iso_node_get_permissions(node); + + if(xorriso->do_aaip & (2 | 8 | 16)) { + ret= iso_node_get_attrs(node, &num_attrs, &names, &value_lengths, &values, + (!!(xorriso->do_aaip & 2)) | (!(xorriso->do_aaip & (8 | 16))) << 2); + if (ret < 0) { + strcpy(xorriso->info_text, "Error with obtaining ACL and xattr for "); + Text_shellsafe(disk_path, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + if(num_attrs > 0) { + ret= iso_local_set_attrs(disk_path, num_attrs, names, value_lengths, + values, 0); + if(ret < 0) { + sprintf(xorriso->info_text, + "Cannot change ACL or xattr of disk file %s", + Text_shellsafe(disk_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0); + {ret= 0; goto ex;} + } + } + Xorriso_process_msg_queues(xorriso,0); + } + if(!(xorriso->do_aaip & 2)) + mode= iso_node_get_perms_wo_acl(node); + + if(is_dir && (flag&2)) { + ret= Xorriso_fake_stbuf(xorriso, "", &stbuf, &node, + 1 | ((!!(xorriso->do_aaip & 2)) << 3)); + if(ret<=0) + {ret= 0; goto ex;} + ret= Permstack_push(&(xorriso->perm_stack), disk_path, &stbuf, 0); + if(ret<=0) { + Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0); + strcpy(xorriso->info_text, + "Cannot memorize permissions for disk directory"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + {ret= -1; goto ex;} + } + mode|= S_IRUSR|S_IWUSR|S_IXUSR; + } + ret= chmod(disk_path, mode); + if(ret==-1) { + sprintf(xorriso->info_text, + "Cannot change access permissions of disk file %s", + Text_shellsafe(disk_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + {ret= 0; goto ex;} + } + + if(flag&1) + {ret= 1; goto ex;} + + gid= iso_node_get_gid(node); + if(!(S_ISDIR(stbuf.st_mode) && (flag&2))) + uid= iso_node_get_uid(node); + chown(disk_path, uid, gid); /* don't complain if it fails */ + utime_buffer.actime= iso_node_get_atime(node); + utime_buffer.modtime= iso_node_get_mtime(node); + ret= utime(disk_path,&utime_buffer); + if(ret==-1) { + sprintf(xorriso->info_text, + "Cannot change atime, mtime of disk file %s", + Text_shellsafe(disk_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + {ret= 0; goto ex;} + } + ret= 1; +ex:; + iso_node_get_attrs(node, &num_attrs, &names, &value_lengths, &values,1 << 15); + return(ret); +} + + +/* @param flag + bit1= minimal transfer: access permissions only + bit2= keep directory open: keep owner, allow rwx for owner + push to xorriso->perm_stack +*/ +int Xorriso_restore_implicit_properties(struct XorrisO *xorriso, + char *full_disk_path, char *disk_path, char *full_img_path, int flag) +{ + int ret, nfic, ndc, nfdc, d, i; + char nfi[SfileadrL], nd[SfileadrL], nfd[SfileadrL], *cpt; + char sfe[5*SfileadrL]; + struct stat stbuf; + IsoNode *node; + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, full_disk_path, nfd, + 1|2|4); + if(ret<=0) + return(ret); + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, disk_path, nd, 1|2); + if(ret<=0) + return(ret); + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, full_img_path, nfi, + 1|2); + if(ret<=0) + return(ret); + nfdc= Sfile_count_components(nfd, 0); + ndc= Sfile_count_components(nd, 0); + nfic= Sfile_count_components(nfi, 0); + d= nfdc-ndc; + if(d<0) + return(-1); + if(d>nfic) + return(0); + for(i= 0; i>1)&3)); + if(ret<=0) + return(ret); + sprintf(xorriso->info_text, + "Restored properties for %s", Text_shellsafe(nd, sfe, 0)); + sprintf(xorriso->info_text+strlen(xorriso->info_text), + " from %s", Text_shellsafe(nfi, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + return(1); +} + + +int Xorriso_is_plain_image_file(struct XorrisO *xorriso, IsoNode *node, + int flag) +{ + int ret, lba; + IsoStream *stream; + + ret= Xorriso__file_start_lba(node, &lba, 0); + if(ret > 0) { /* Stream source is from loaded image */ + stream= iso_file_get_stream((IsoFile *) node); + if(stream != NULL) + if(iso_stream_get_input_stream(stream, 0) == NULL) + return(1); + } + return(0); +} + + +/* @param flag bit0= Minimal transfer: access permissions only + bit1= *_offset and bytes are valid for writing to regular file + bit2= This is not a parameter. Do not report if ignored + bit3= do not restore properties + bit4= issue pacifier messages with long lasting copying + bit7= return 4 if restore fails from denied permission + do not issue error message + @return <0 severe error , 0 failure , 1 success , + 2 regularly not installed (disallowed device, UNIX domain socket) + 4 with bit7: permission to restore was denied +*/ +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) +{ + int ret= 0, write_fd= -1, wanted, wret, open_flags, l_errno= 0; + int target_deleted= 0; + char *what= "[unknown filetype]", sfe[5*SfileadrL], sfe2[5*SfileadrL]; + char buf[32*1024], type_text[5], temp_path[SfileadrL], *buf_pt; + char *link_target, *open_path_pt= NULL; + off_t todo= 0, size, seek_ret, last_p_count= 0, already_done, read_count= 0; + void *data_stream= NULL; + mode_t mode; + dev_t dev= 0; + struct stat stbuf; + struct utimbuf utime_buffer; + + if(LIBISO_ISDIR(node)) { + what= "directory"; + ret= mkdir(disk_path, 0777); + l_errno= errno; + + } else if(LIBISO_ISREG(node)) { + what= "regular file"; + ret= Xorriso_iso_file_open(xorriso, img_path, (void *) node, &data_stream, + 1); + if(ret<=0) + goto ex; + open_path_pt= disk_path; + ret= stat(open_path_pt, &stbuf); + if(ret == -1 && errno == EACCES && (flag & 128)) + {ret= 4; goto ex;} + if(flag&2) { + if(ret!=-1 && !S_ISREG(stbuf.st_mode)) { + sprintf(xorriso->info_text, + "Restore offset demanded. But filesystem path leads to non-data file %s", + Text_shellsafe(disk_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0); + l_errno= 0; + goto cannot_restore; + } + } else { + /* If source and target are the same disk file then do not copy content */ + ret= Xorriso_restore_is_identical(xorriso, (void *) node, img_path, + disk_path, type_text, 1); + if(ret<0) + goto ex; + if(ret==1) { + /* preliminarily emulate touch (might get overridden later) */ + utime_buffer.actime= stbuf.st_atime; + utime_buffer.modtime= time(0); + utime(disk_path,&utime_buffer); + goto restore_properties; + } + if(ret==2) { + /* Extract to temporary file and rename only after copying */ + ret= Xorriso_make_tmp_path(xorriso, disk_path, temp_path, &write_fd, + 128); + if(ret <= 0 || ret == 4) + goto ex; + open_path_pt= temp_path; + } + } + if(write_fd==-1) { + open_flags= O_WRONLY|O_CREAT; + if(disk_offset==0 || !(flag&2)) + open_flags|= O_EXCL; + write_fd= open(open_path_pt, open_flags, S_IRUSR|S_IWUSR); + l_errno= errno; + if(write_fd == -1 && errno == EACCES && (flag & 128)) + {ret= 4; goto ex;} + if(write_fd==-1) + goto cannot_restore; + } + todo= size= iso_file_get_size((IsoFile *) node); + if(flag&2) { + if(bytesinfo_text, + "Cannot address byte %.f in filesystem path %s", + (double) disk_offset, Text_shellsafe(open_path_pt, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0); + goto cannot_restore; + } + } + while(todo>0) { + wanted= sizeof(buf); + if(wanted>todo) + wanted= todo; + ret= Xorriso_iso_file_read(xorriso, data_stream, buf, wanted, 0); + if(ret<=0) { + if(xorriso->extract_error_mode == 0 && + Xorriso_is_plain_image_file(xorriso, node, 0)) { + close(write_fd); + write_fd= -1; + already_done= (size - todo) / (off_t) 2048; + already_done*= (off_t) 2048; + sprintf(xorriso->info_text, + "Starting best_effort handling on ISO file %s at byte %.f", + Text_shellsafe(img_path, sfe, 0), (double) already_done); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + ret= Xorriso_read_file_data(xorriso, node, img_path, open_path_pt, + already_done, already_done, size - already_done, 2); + if(ret >= 0) + xorriso->pacifier_byte_count+= todo; + if(ret > 0) + todo= 0; + else + todo= -1; + } + if(ret <= 0) { + sprintf(xorriso->info_text, "Cannot read all bytes from ISO file %s", + Text_shellsafe(img_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + } + break; + } + read_count+= ret; + buf_pt= buf; + + if(img_offset > read_count - ret) { + /* skip the desired amount of bytes */ + if(read_count <= img_offset) + continue; + buf_pt= buf + (img_offset - (read_count - ret)); + ret= read_count - img_offset; + } + + wret= write(write_fd, buf_pt, ret); + if(wret>=0) { + todo-= wret; + xorriso->pacifier_byte_count+= wret; + if((flag&16) && + xorriso->pacifier_byte_count - last_p_count >= 128*1024) { + Xorriso_pacifier_callback(xorriso, "files restored", + xorriso->pacifier_count, + xorriso->pacifier_total, "", 2|4); + last_p_count= xorriso->pacifier_byte_count; + } + } + if(wret != ret) { + sprintf(xorriso->info_text, + "Cannot write all bytes to disk filesystem path %s", + Text_shellsafe(open_path_pt, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0); + break; + } + } + if(write_fd > 0) + close(write_fd); + write_fd= -1; + if(todo > 0 && xorriso->extract_error_mode == 2 && open_path_pt != NULL) { + unlink(open_path_pt); + target_deleted= 1; + } + Xorriso_iso_file_close(xorriso, &data_stream, 0); + data_stream= NULL; + if(temp_path==open_path_pt && !target_deleted) { + ret= rename(temp_path, disk_path); + if(ret==-1) { + sprintf(xorriso->info_text, + "Cannot rename temporary path %s to final disk path %s", + Text_shellsafe(temp_path, sfe, 0), + Text_shellsafe(disk_path, sfe2, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0); + unlink(temp_path); + ret= 0; goto ex; + } + } + ret= -(todo > 0); + l_errno= 0; + + } else if(LIBISO_ISLNK(node)) { + what= "symbolic link"; + link_target= (char *) iso_symlink_get_dest((IsoSymlink *) node); + ret= symlink(link_target, disk_path); + l_errno= errno; + + } else if(LIBISO_ISCHR(node)) { + what= "character device"; + if(xorriso->allow_restore!=2) { +ignored:; + if(!(flag&4)) { + sprintf(xorriso->info_text, "Ignored file type: %s %s = %s", what, + Text_shellsafe(img_path,sfe,0), Text_shellsafe(disk_path,sfe2,0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + {ret= 2; goto ex;} + } + mode= S_IFCHR | 0777; + ret= Xorriso_node_get_dev(xorriso, node, img_path, &dev, 0); + if(ret<=0) + goto ex; + if(dev == (dev_t) 1) { +probably_damaged:; + sprintf(xorriso->info_text, + "Most probably damaged device file not restored: mknod %s %s 0 1", + Text_shellsafe(disk_path, sfe, 0), LIBISO_ISCHR(node) ? "c" : "b"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + ret= 0; goto ex; + } + ret= mknod(disk_path, mode, dev); + l_errno= errno; + + } else if(LIBISO_ISBLK(node)) { + what= "block device"; + if(xorriso->allow_restore!=2) + goto ignored; + mode= S_IFBLK | 0777; + ret= Xorriso_node_get_dev(xorriso, node, img_path, &dev, 0); + if(ret<=0) + goto ex; + if(dev == (dev_t) 1) + goto probably_damaged; + ret= mknod(disk_path, mode, dev); + l_errno= errno; + + } else if(LIBISO_ISFIFO(node)) { + what= "named pipe"; + mode= S_IFIFO | 0777; + ret= mknod(disk_path, mode, dev); + l_errno= errno; + + } else if(LIBISO_ISSOCK(node)) { + what= "unix socket"; + /* Restoring a socket file is not possible. One rather needs to restart + the service which temporarily created the socket. */ + goto ignored; + + } else { + sprintf(xorriso->info_text, "Cannot restore file type '%s'", what); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + ret= 0; goto ex; + } + if(ret == -1 && l_errno == EACCES && (flag & 128)) + {ret= 4; goto ex;} + if(ret==-1) { +cannot_restore:; + sprintf(xorriso->info_text, + "Cannot restore %s to disk filesystem: %s", + what, Text_shellsafe(img_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, l_errno, "FAILURE", 0); + ret= 0; goto ex; + } + +restore_properties:; + if((flag&8) || LIBISO_ISLNK(node)) + ret= 1; + else + ret= Xorriso_restore_properties(xorriso, disk_path, node, flag&1); + if(todo < 0) + ret= 0; +ex:; + if(write_fd >= 0) { + close(write_fd); + if(ret <= 0 && xorriso->extract_error_mode == 2 && open_path_pt != NULL) + unlink(open_path_pt); + } + if(data_stream!=NULL) + Xorriso_iso_file_close(xorriso, &data_stream, 0); + return(ret); +} + + +/* Handle overwrite situation in disk filesystem. + @param node intended source of overwriting or NULL + @param flag + bit4= return 3 on rejection by exclusion or user + bit6= permission to call Xorriso_make_accessible() +*/ +int Xorriso_restore_overwrite(struct XorrisO *xorriso, + IsoNode *node, char *img_path, + char *path, char *nominal_path, + struct stat *stbuf, int flag) +{ + int ret; + char sfe[5*SfileadrL], sfe2[5*SfileadrL], type_text[5]; + + Xorriso_process_msg_queues(xorriso,0); + if(xorriso->do_overwrite==1 || + (xorriso->do_overwrite==2 && !S_ISDIR(stbuf->st_mode))) { + + ret= Xorriso_restore_is_identical(xorriso, (void *) node, img_path, + path, type_text, (node!=NULL)); + if(ret<0) + return(ret); + if(ret>0) /* will be handled properly by restore functions */ + ret= Xorriso_reassure_restore(xorriso, path, 8); + else + ret= Xorriso_rmx(xorriso, (off_t) 0, path, 8 | (flag & 64)); + if(ret<=0) + return(ret); + if(ret==3) { + sprintf(xorriso->info_text, "User revoked restoring of (ISO) file: %s", + Text_shellsafe(img_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(3*!!(flag&16)); + } + return(1); + } + Xorriso_msgs_submit(xorriso, 0, nominal_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "While restoring %s : %s exists and may not be overwritten", + Text_shellsafe(nominal_path, sfe, 0), strcmp(nominal_path, path)==0 ? + "file object" : Text_shellsafe(path, sfe2, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); +} + + +/* @param flag bit0= do not accept hln_targets[i] != NULL as *node_idx + bit1= use *node_idx as found index rather than searching it + bit2= with bit1: use xorriso->node_array rather than hln_array +*/ +int Xorriso_search_hardlinks(struct XorrisO *xorriso, IsoNode *node, + int *node_idx, int *min_hl, int *max_hl, int flag) +{ + int idx, ret, i, node_count; + void *np, **node_array; + + node_array= xorriso->hln_array; + node_count= xorriso->hln_count; + *min_hl= *max_hl= -1; + np= node; + if(flag & 2) { + idx= *node_idx; + if(flag & 4) { + node_array= xorriso->node_array; + node_count= xorriso->node_counter; + } + } else { + *node_idx= -1; + ret= Xorriso_search_in_hln_array(xorriso, np, &idx, 0); + if(ret <= 0) + return(ret); + } + for(i= idx - 1; i >= 0 ; i--) + if(Xorriso__findi_sorted_ino_cmp(&(node_array[i]), &np) != 0) + break; + *min_hl= i + 1; + for(i= idx + 1; i < node_count; i++) + if(Xorriso__findi_sorted_ino_cmp(&(node_array[i]), &np) != 0) + break; + *max_hl= i - 1; + + /* Search for *node_idx */ + if(flag & 2) + return(1); + for(i= *min_hl; i <= *max_hl; i++) + if(node_array[i] == np) { + if((flag & 1) && xorriso->hln_targets != NULL && !(flag & 4)) + if(xorriso->hln_targets[i] != NULL) + continue; + *node_idx= i; + break; + } + return(1); +} + + +/* + @return <0 error, + bit0= hardlink created + bit1= siblings with target NULL found + bit2= siblings with non-NULL target found +*/ +int Xorriso_restore_target_hl(struct XorrisO *xorriso, IsoNode *node, + char *disk_path, int *node_idx, int flag) +{ + int ret, min_hl, max_hl, i, null_target_sibling= 0, link_sibling= 0; + + if(xorriso->hln_targets == NULL) + return(0); + ret= Xorriso_search_hardlinks(xorriso, node, node_idx, &min_hl, &max_hl, 1); + if(ret < 0) + return(ret); + if(ret == 0 || *node_idx < 0 || min_hl == max_hl) + return(0); + for(i= min_hl; i <= max_hl; i++) { + if(xorriso->hln_targets[i] == NULL) { + if(i != *node_idx) + null_target_sibling= 1; + continue; + } + link_sibling= 1; + ret= Xorriso_restore_make_hl(xorriso, xorriso->hln_targets[i], disk_path, + !!xorriso->do_auto_chmod); + if(ret > 0) + return(1); + } + return((null_target_sibling << 1) | (link_sibling << 2)); +} + + +/* + @return <0 error, + bit0= hardlink created + bit2= siblings lower index found +*/ +int Xorriso_restore_prefix_hl(struct XorrisO *xorriso, IsoNode *node, + char *disk_path, int node_idx, int flag) +{ + int ret, min_hl, max_hl, i, link_sibling= 0, hflag; + char old_path[SfileadrL], img_path[SfileadrL]; + struct Xorriso_lsT *img_prefixes= NULL, *disk_prefixes= NULL; + + ret= Xorriso_search_hardlinks(xorriso, node, &node_idx, &min_hl, &max_hl, + 2 | 4); + if(ret < 0) + return(ret); + if(ret == 0 || min_hl == max_hl) + return(0); + + for(i= min_hl; i < node_idx; i++) { + link_sibling= 1; + ret= Xorriso_path_from_node(xorriso, xorriso->node_array[i], img_path, 0); + if(ret < 0) + return(ret); + if(ret == 0) + continue; /* Node is deleted from tree (Should not happen here) */ + hflag= 1; + if(i == min_hl) { + hflag= 0; + } else if(xorriso->node_array[i] != xorriso->node_array[i - 1]) { + hflag= 0; + } + if(hflag == 0) { + img_prefixes= xorriso->node_img_prefixes; + disk_prefixes= xorriso->node_disk_prefixes; + } + ret= Xorriso_make_restore_path(xorriso, &img_prefixes, &disk_prefixes, + img_path, old_path, hflag); + if(ret <= 0) + return(ret); + ret= Xorriso_restore_make_hl(xorriso, old_path, disk_path, + !!xorriso->do_auto_chmod); + if(ret > 0) + return(1); + } + return(link_sibling << 2); +} + + +/* @return <0 = error , 0 = availmem exhausted first time , 1 = ok + 2 = availmem exhausted repeated +*/ +int Xorriso_register_node_target(struct XorrisO *xorriso, int node_idx, + char *disk_path, int flag) +{ + int l; + + if(xorriso->node_targets_availmem == 0) + return(2); + if(xorriso->hln_targets == NULL || node_idx < 0 || + node_idx >= xorriso->hln_count) + return(0); + if(xorriso->hln_targets[node_idx] != NULL) { + xorriso->node_targets_availmem+= strlen(xorriso->hln_targets[node_idx]) +1; + free(xorriso->hln_targets[node_idx]); + } + l= strlen(disk_path); + if(xorriso->node_targets_availmem <= l + 1) { + sprintf(xorriso->info_text, + "Hardlink target buffer exceeds -temp_mem_limit. Hardlinks may get divided."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + xorriso->node_targets_availmem= 0; + return(0); + } + xorriso->hln_targets[node_idx]= strdup(disk_path); + if(xorriso->hln_targets[node_idx] == NULL) { + Xorriso_no_malloc_memory(xorriso, NULL, 0); + return(-1); + } + xorriso->node_targets_availmem-= (l + 1); + return(1); +} + + +/* + @param flag bit0= offset and bytes is valid for writing to regular file + bit1= do not report copied files + bit2= -follow, -not_*: this is not a command parameter + bit3= keep directory open: keep owner, allow rwx for owner + bit4= do not look for hardlinks even if enabled + bit6= this is a copy action: do not fake times and ownership + bit7= return 4 if restore fails from denied permission + do not issue error message + @return <=0 = error , 1 = added leaf file object , 2 = added directory , + 3= regularly not installed (disallowed device, UNIX domain socket) + 4 = with bit7: permission to restore was denied +*/ +int Xorriso_restore_disk_object(struct XorrisO *xorriso, + char *img_path, IsoNode *node, + char *disk_path, + off_t offset, off_t bytes, int flag) +{ + int ret, i, split_count= 0, partno, total_parts, leaf_is_split= 0; + int record_hl_path= 0, node_idx, cannot_register= 0; + off_t total_bytes, was_byte_count; + char *part_name, part_path[SfileadrL], *img_path_pt; + char sfe[5*SfileadrL], sfe2[5*SfileadrL]; + IsoImage *volume; + IsoNode *part_node, *first_part_node= NULL; + struct SplitparT *split_parts= NULL; + struct stat stbuf; + + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + goto ex; + + was_byte_count= xorriso->pacifier_byte_count; + + if(LIBISO_ISDIR(node) && xorriso->do_concat_split) + leaf_is_split= Xorriso_identify_split(xorriso, img_path, node, + &split_parts, &split_count, &stbuf, 1|2); + if(leaf_is_split) { + /* map all files in directory img_path into regular file disk_path */ + + for(i=0 ; itotal_bytes) + bytes= total_bytes-offset; + ret= Xorriso_tree_restore_node(xorriso, part_node, part_path, (off_t) 0, + disk_path, offset, bytes, + (!!(flag&64)) | 2 | (flag & (4 | 128)) | 8 | ( 16 * !(flag&2))); + if(ret<=0) + goto restoring_failed; + if(ret == 4) + goto ex; + } + if(first_part_node!=NULL) + Xorriso_restore_properties(xorriso, disk_path, first_part_node, + !!(flag&64)); + goto went_well; + } + +#ifdef Osirrox_not_yeT + + if(resolve_link) { + ret= Xorriso_resolve_link(xorriso, disk_path, resolved_disk_path, 0); + if(ret<=0) + goto ex; + disk_path_pt= resolved_disk_path; + } else + +#endif /* Osirrox_not_yeT */ + + img_path_pt= img_path; + + if(!((xorriso->ino_behavior & 4) || (flag & (1 | 16)) || LIBISO_ISDIR(node))){ + /* Try to restore as hardlink */ + ret= Xorriso_restore_target_hl(xorriso, node, disk_path, &node_idx, + !!xorriso->do_auto_chmod); + if(ret < 0) { + goto ex; + } else if(ret & 1) { + /* Success, hardlink was created */ + goto went_well; + } else if(ret & 2) { + /* Did not establish hardlink. Hardlink siblings with target NULL found.*/ + record_hl_path= 1; + } + if(ret & 4) { + /* Found siblings with non-NULL target, but did not link. */ + ret= Xorriso_eval_problem_status(xorriso, 1, 0); + if(ret < 0) + {ret= 0; goto ex;} + } + } + + ret= Xorriso_tree_restore_node(xorriso, node, img_path_pt, (off_t) 0, + disk_path, offset, bytes, + (flag&(4 | 8 | 128)) | (!!(flag&64)) | ((flag&1)<<1) | ( 16 * !(flag&2))); + if(ret == 4) + goto ex; + if(ret>0 && (flag&8)) + ret= Xorriso_restore_properties(xorriso, disk_path, node, 2 | !!(flag&64)); + if(ret<=0) { +restoring_failed:; + sprintf(xorriso->info_text, "Restoring failed: %s = %s", + Text_shellsafe(img_path,sfe,0), Text_shellsafe(disk_path,sfe2,0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + if(ret==2) + {ret= 3; goto ex;} + if(record_hl_path) { /* Start of a disk hardlink family */ + ret= Xorriso_register_node_target(xorriso, node_idx, disk_path, 0); + if(ret < 0) + goto ex; + if(ret == 0) + cannot_register= 1; + } + +went_well:; + xorriso->pacifier_count++; + if(!(flag&2)) + Xorriso_pacifier_callback(xorriso, "files restored", + xorriso->pacifier_count, + xorriso->pacifier_total, "", 4); + ret= 1; +ex:; + if(split_parts!=NULL) + Splitparts_destroy(&split_parts, split_count, 0); + if(ret > 0 && cannot_register) + ret= 0; + return(ret); +} + + +/* @param flag bit0= source is a directory and not to be restored as split file + >>> bit6= permission to call Xorriso_make_accessible() + @return <=0 error , 1=collision handled , 2=no collision , 3=revoked by user +*/ +int Xorriso_handle_collision(struct XorrisO *xorriso, + IsoNode *node, char *img_path, + char *disk_path, char *nominal_disk_path, + int *stbuf_ret, int flag) +{ + int ret, target_is_dir= 0, target_is_link= 0, stat_ret, made_accessible= 0; + struct stat target_stbuf, lt_stbuf; + struct PermiteM *perm_stack_mem; + + perm_stack_mem= xorriso->perm_stack; + + /* does a disk file exist with this name ? */ + *stbuf_ret= lstat(disk_path, &target_stbuf); + if(*stbuf_ret==-1) { + if((flag & 64) && errno == EACCES) { + ret= Xorriso_make_accessible(xorriso, disk_path, 0); + if(ret < 0) + goto ex; + made_accessible= 1; + *stbuf_ret= lstat(disk_path, &target_stbuf); + } + if(*stbuf_ret==-1) + {ret= 2; goto ex;} + } + target_is_link= S_ISLNK(target_stbuf.st_mode); + if(target_is_link) { + stat_ret= stat(disk_path, <_stbuf); + if(stat_ret == -1) { + if((flag & 64) && errno == EACCES && !made_accessible) { + ret= Xorriso_make_accessible(xorriso, disk_path, 0); + if(ret < 0) + goto ex; + made_accessible= 1; + stat_ret= stat(disk_path, <_stbuf); + } + } + if(stat_ret != -1) + target_is_dir= S_ISDIR(lt_stbuf.st_mode); + } else { + target_is_dir= S_ISDIR(target_stbuf.st_mode); + } + if(target_is_dir && (!target_is_link) && !(flag&1)) { + strcpy(xorriso->info_text, "Attempt to replace DISK directory "); + Text_shellsafe(nominal_disk_path, + xorriso->info_text+strlen(xorriso->info_text), 0); + strcat(xorriso->info_text, " by ISO file "); + Text_shellsafe(img_path, xorriso->info_text+strlen(xorriso->info_text), 0); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + + if(!(target_is_dir && (flag&1))) { + Xorriso_process_msg_queues(xorriso,0); + ret= Xorriso_restore_overwrite(xorriso, node, img_path, disk_path, + nominal_disk_path, &target_stbuf, 16 | (flag & 64)); + if(ret==3) + {ret= 3; goto ex;} + if(ret<=0) + goto ex; + *stbuf_ret= -1; /* It might still exist but will be handled properly */ + } + ret= 1; +ex:; + if(made_accessible) + Permstack_pop(&(xorriso->perm_stack), perm_stack_mem, xorriso, 0); + return(ret); +} + + +/* @param flag bit0= recursion is active + bit1= do not report restored files + bit6= this is a copy action: do not fake times and ownership + bit8= only register non-directory nodes in xorriso->node_array + bit7+8= + 0= direct operation + 1= create only directories, + count nodes in xorriso->node_counter + 2= only register non-directory nodes in + xorriso->node_array + 3= count nodes in xorriso->node_counter, + create no directory +*/ +int Xorriso_restore_tree(struct XorrisO *xorriso, IsoDir *dir, + char *img_dir_path, char *disk_dir_path, + off_t boss_mem, + struct LinkiteM *link_stack, int flag) +{ + IsoImage *volume; + IsoNode *node; + IsoDirIter *iter= NULL; + IsoNode **node_array= NULL; + int node_count, node_idx; + int ret, source_is_dir, source_is_link, fret, was_failure= 0; + int do_not_dive, source_is_split= 0, len_dp, len_ip, stbuf_ret, hflag, hret; + char *name, *disk_name, *leaf_name, *srcpt, *stbuf_src= ""; + struct LinkiteM *own_link_stack; + char *sfe= NULL, *sfe2= NULL; + char *disk_path= NULL, *img_path= NULL, *link_target= NULL; + off_t mem; + struct PermiteM *perm_stack_mem; + struct stat stbuf; + int dir_create= 0, node_register= 0, do_node_count= 0, normal_mode= 0; + + perm_stack_mem= xorriso->perm_stack; + switch((flag >> 7) & 3) { + case 0: normal_mode= 1; + break; case 1: dir_create= 1; + break; case 2: node_register= 1; + break; case 3: do_node_count= 1; + } + + /* Avoiding large local memory objects in order to save stack space */ + sfe= malloc(5*SfileadrL); + sfe2= malloc(5*SfileadrL); + disk_path= malloc(2*SfileadrL); + img_path= malloc(2*SfileadrL); + link_target= malloc(SfileadrL); + if(sfe==NULL || sfe2==NULL || disk_path==NULL || img_path==NULL || + link_target==NULL) { + Xorriso_no_malloc_memory(xorriso, &sfe, 0); + {ret= -1; goto ex;} + } + + own_link_stack= link_stack; + + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + goto ex; + + stbuf_src= img_dir_path; + node= (IsoNode *) dir; + ret= Xorriso_fake_stbuf(xorriso, stbuf_src, &stbuf, &node, 1); + if(ret<=0) { + Xorriso_msgs_submit(xorriso, 0, disk_dir_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text,"Cannot open as (ISO) source directory: %s", + Text_shellsafe(img_dir_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + +#ifdef Osirrox_not_yeT + + dev_t dir_dev; + dir_dev= stbuf.st_dev; + + if(S_ISLNK(stbuf.st_mode)) { + if(!(xorriso->do_follow_links || (xorriso->do_follow_param && !(flag&1)))) + {ret= 2; goto ex;} + stbuf_src= disk_dir_path; + if(stat(disk_dir_path, &stbuf)==-1) + goto cannot_open_dir; + if(dir_dev != stbuf.st_dev && + !(xorriso->do_follow_mount || (xorriso->do_follow_param && !(flag&1)))) + {ret= 2; goto ex;} + } + +#endif /* Osirrox_not_yeT */ + + if(!S_ISDIR(stbuf.st_mode)) { + Xorriso_msgs_submit(xorriso, 0, disk_dir_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text,"Is not a directory in ISO image: %s", + Text_shellsafe(img_dir_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + + mem= boss_mem; + ret= Xorriso_findi_iter(xorriso, dir, &mem, &iter, &node_array, &node_count, + &node_idx, &node, + 1 | 4 * (normal_mode && (xorriso->ino_behavior & 4))); + if(ret<=0) + goto ex; + + if(Sfile_str(img_path, img_dir_path,0)<=0) { +much_too_long:; + Xorriso_much_too_long(xorriso, SfileadrL, 2); + {ret= 0; goto ex;} + } + if(img_path[0]==0 || img_path[strlen(img_path)-1]!='/') + strcat(img_path,"/"); + name= img_path+strlen(img_path); + if(Sfile_str(disk_path, disk_dir_path, 0)<=0) + goto much_too_long; + if(disk_path[0]==0 || disk_path[strlen(disk_path)-1]!='/') + strcat(disk_path,"/"); + disk_name= disk_path+strlen(disk_path); + + len_dp= strlen(disk_path); + len_ip= strlen(img_path); + + while(1) { /* loop over ISO directory content */ + stbuf_src= ""; + +#ifdef Osirrox_not_yeT + + Linkitem_reset_stack(&own_link_stack, link_stack, 0); + +#endif + + srcpt= img_path; + Xorriso_process_msg_queues(xorriso,0); + ret= Xorriso_findi_iter(xorriso, dir, &mem, &iter, &node_array, &node_count, + &node_idx, &node, 0); + if(ret<0) + goto ex; + if(ret==0 || xorriso->request_to_abort) + break; + leaf_name= (char *) iso_node_get_name(node); + if(Xorriso_much_too_long(xorriso, len_dp + strlen(leaf_name)+1, 0)<=0) + {ret= 0; goto was_problem;} + if(Xorriso_much_too_long(xorriso, len_ip + strlen(leaf_name)+1, 0)<=0) + {ret= 0; goto was_problem;} + /* name is a pointer into img_path */ + strcpy(name, leaf_name); + strcpy(disk_name, leaf_name); + + stbuf_src= srcpt; + ret= Xorriso_fake_stbuf(xorriso, img_path, &stbuf, &node, 1); + if(ret<=0) + goto was_problem; + source_is_dir= 0; + source_is_link= S_ISLNK(stbuf.st_mode); + +#ifdef Osirrox_not_yeT + + /* ??? Link following in the image would cause severe problems + with Xorriso_path_from_node() */ + + if(xorriso->do_follow_links && source_is_link) { + /* Xorriso_hop_link checks for wide link loops */ + ret= Xorriso_hop_link(xorriso, srcpt, &own_link_stack, &hstbuf, 0); + if(ret<0) + goto was_problem; + if(ret==1) { + ret= Xorriso_resolve_link(xorriso, srcpt, link_target, 0); + if(ret<=0) + goto was_problem; + srcpt= link_target; + stbuf_src= srcpt; + if(lstat(srcpt, &stbuf)==-1) + goto cannot_lstat; + } else { + if(Xorriso_eval_problem_status(xorriso, 0, 1|2)<0) + {ret= 0; goto was_problem;} + } + } else if (S_ISLNK(stbuf.st_mode)) { + ret= Xorriso_resolve_link(xorriso, srcpt, link_target, 1); + if(ret<=0) + goto was_problem; + } + +#endif /* Osirrox_not_yeT */ + + do_not_dive= 0; + if(S_ISDIR(stbuf.st_mode)) + source_is_dir= 1; + source_is_split= 0; + if(source_is_dir) + source_is_split= Xorriso_is_split(xorriso, img_path, node, 1|2); + if(source_is_split) + do_not_dive= 1; + + if(source_is_dir || !(dir_create || do_node_count || node_register)) { + ret= Xorriso_handle_collision(xorriso, node, img_path, + disk_path, disk_path, &stbuf_ret, + (source_is_dir && !source_is_split)); + if(ret<=0 || ret==3) + goto was_problem; + } else { + stbuf_ret= -1; + } + + if(stbuf_ret!=-1) { /* (Can only happen with directory) */ + Xorriso_auto_chmod(xorriso, disk_path, 0); + } else { + hflag= 4 | (flag & (2|64)); + if(source_is_dir && !do_not_dive) + hflag|= 8; /* keep directory open for user */ + if((dir_create || do_node_count) && !source_is_dir) { + xorriso->node_counter++; + } else if(node_register && !source_is_dir) { + if(xorriso->node_counter < xorriso->node_array_size) { + xorriso->node_array[xorriso->node_counter++]= (void *) node; + iso_node_ref(node); + } + } else if(node_register || do_node_count) { + ret= 1; + } else { + ret= Xorriso_restore_disk_object(xorriso, img_path, node, disk_path, + (off_t) 0, (off_t) 0, hflag); + } + if(ret<=0) + goto was_problem; + } + if(source_is_dir && !do_not_dive) { + ret= Xorriso_restore_tree(xorriso, (IsoDir *) node, + img_path, disk_path, mem, + own_link_stack, 1 | (flag & (2 | (3 << 7)))); + /* eventually restore exact access permissions of directory */ + hret= Permstack_pop(&(xorriso->perm_stack), perm_stack_mem, xorriso, + !!(flag&64)); + if(hret<=0 && hretperm_stack), perm_stack_mem, xorriso, !!(flag&64)); + } + + ret= 1; +ex: + Permstack_pop(&(xorriso->perm_stack), perm_stack_mem, xorriso, !!(flag&64)); + if(sfe!=NULL) + free(sfe); + if(sfe2!=NULL) + free(sfe2); + if(disk_path!=NULL) + free(disk_path); + if(img_path!=NULL) + free(img_path); + if(link_target!=NULL) + free(link_target); + Xorriso_findi_iter(xorriso, dir, &mem, &iter, &node_array, &node_count, + &node_idx, &node, (1<<31)); + + Xorriso_process_msg_queues(xorriso,0); + +#ifdef Osirrox_not_yeT + + Linkitem_reset_stack(&own_link_stack, link_stack, 0); + +#endif + + if(ret<=0) + return(ret); + return(!was_failure); +} + + +/* + @param flag + >>> bit0= mkdir: graft in as empty directory, not as copy from iso + bit1= do not report copied files + bit2= -follow, -not_*: this is not a command parameter + bit3= use offset and cut_size for -paste_in + bit4= return 3 on rejection by exclusion or user + bit5= if directory then do not add sub tree + bit6= this is a copy action: do not fake times and ownership + bit7+8= operation mode + 0= direct operation + 1= create only directories, + count nodes in xorriso->node_counter + 2= only register non-directory nodes in + xorriso->node_array + 3= count nodes in xorriso->node_counter, + create no directory + bit9= with operation mode 1 do net register prefixes + @return <=0 = error , 1 = added leaf file object , 2 = added directory , + 3 = rejected +*/ +int Xorriso_restore(struct XorrisO *xorriso, + char *img_path, char *disk_path, + off_t offset, off_t bytes, int flag) +{ + IsoImage *volume; + char path[SfileadrL], *apt, *npt, sfe[5*SfileadrL]; + IsoNode *node= NULL; + int done= 0, is_dir= 0, ret, source_is_dir, stbuf_ret, hret; + int dir_create= 0, node_count= 0, node_register= 0; + int leaf_is_split= 0, source_is_split= 0, new_dir_made= 0; + struct stat stbuf; + struct PermiteM *perm_stack_mem; + + perm_stack_mem= xorriso->perm_stack; + switch((flag >> 7) & 3) { + case 1: dir_create= 1; + break; case 2: node_register= 1; + break; case 3: node_count= 1; + } + + if(dir_create && !(flag & (1 << 9))) { + ret= Xorriso_lst_append_binary(&(xorriso->node_disk_prefixes), + disk_path, strlen(disk_path) + 1, 0); + if(ret <= 0) + goto ex; + ret= Xorriso_lst_append_binary(&(xorriso->node_img_prefixes), + img_path, strlen(img_path) + 1, 0); + if(ret <= 0) + goto ex; + } + + ret= Xorriso_path_is_excluded(xorriso, disk_path, !(flag&4)); + if(ret<0) + goto ex; + if(ret>0) + {ret= 3*!!(flag&16); goto ex;} + + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + goto ex; + + strncpy(path, disk_path, sizeof(path)-1); + path[sizeof(path)-1]= 0; + apt= npt= path; + + if(!(flag&1)) { + ret= Xorriso_fake_stbuf(xorriso, img_path, &stbuf, &node, 0); + if(ret>0) { + if(S_ISDIR(stbuf.st_mode)) + is_dir= 1; + +#ifdef Osirrox_not_yeT + + /* ??? this would cause severe problems with Xorriso_path_from_node() */ + + else if((stbuf.st_mode&S_IFMT)==S_IFLNK && + (xorriso->do_follow_links || + (xorriso->do_follow_param && !(flag&4)))) { + resolve_link= 1; + ret= Xorriso_iso_lstat(xorriso, img_path, &stbuf, 1|2); + if(ret!=-1) { + if(S_ISDIR(stbuf.st_mode)) + is_dir= 1; + } + } +#endif /* Osirrox_not_yeT */ + + } else { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "Cannot determine attributes of (ISO) source file %s", + Text_shellsafe(img_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + ret= 0; goto ex; + } + if(is_dir && xorriso->do_concat_split) + leaf_is_split= Xorriso_is_split(xorriso, img_path, node, 1|2); + } + for(npt= apt; !done; apt= npt+1) { + npt= strchr(apt, '/'); + if(npt==NULL) { + npt= apt+strlen(apt); + done= 1; + } else + *npt= 0; + if(*apt==0) { + *apt= '/'; + apt++; + if(done) + goto attach_source; + continue; + } + source_is_dir= (is_dir || (flag&1) || !done); + source_is_split= done && leaf_is_split; + + stbuf_ret= -1; + if((flag&8) && done) { + + /* ??? move down from Xorriso_paste_in() : + check whether target does not exist or both are regular */; + + } else if(source_is_dir || !(dir_create || node_count || node_register)) { + ret= Xorriso_handle_collision(xorriso, node, img_path, path, disk_path, + &stbuf_ret, (source_is_dir && !source_is_split)); + if(ret<=0 || ret==3) + goto ex; + } + + new_dir_made= 0; + if(stbuf_ret==-1 && (source_is_dir && !source_is_split) && + !(node_count || node_register)) { + /* make a directory */ + ret= mkdir(path, 0777); + if(ret==-1) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "While restoring '%s' : could not insert '%s'", disk_path, path); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0); + {ret= 0; goto ex;} + } + if(!done) { + /* keep rwx for the owner */ + Xorriso_restore_implicit_properties(xorriso, disk_path, path, + img_path, 4); + } + new_dir_made= 1; + } else if((source_is_dir && !source_is_split)) { + if(!(node_count || node_register)) + Xorriso_auto_chmod(xorriso, path, 0); + } + if(done) { +attach_source:; + + if(flag&1) { + /* directory was created above */; + + } else if(is_dir && !source_is_split) { + + if(!node_register) { + if(new_dir_made) /* keep open and push to Permstack */ + Xorriso_restore_properties(xorriso, disk_path, node, + 2 | !!(flag&64)); + } + if(!(flag&32)) { + ret= Xorriso_restore_tree(xorriso, (IsoDir *) node, img_path, path, + (off_t) 0, NULL, flag & (2 | 64 | (3 << 7))); + if(ret<=0) + goto ex; + if(new_dir_made && !(flag&64)) + /* set timestamps which Permstack_pop() will not set */ + Xorriso_restore_properties(xorriso, disk_path, node, 2); + } + } else { + if(dir_create || node_count) { + xorriso->node_counter++; + } else if(node_register) { + if(xorriso->node_counter < xorriso->node_array_size) { + xorriso->node_array[xorriso->node_counter++]= (void *) node; + iso_node_ref(node); + } + } else { + ret= Xorriso_restore_disk_object(xorriso, img_path, node, path, + offset, bytes, (flag & (2|4|64)) | !!(flag&8)); + if(ret<=0) + goto ex; + } + } + } else + *npt= '/'; + } + Xorriso_process_msg_queues(xorriso,0); + ret= 1 + (is_dir && !leaf_is_split); +ex:; + /* restore exact access permissions of stacked paths */ + hret= Permstack_pop(&(xorriso->perm_stack), perm_stack_mem, xorriso, + 2 | !!(flag&64)); + if(hret<=0 && hretperm_stack; + + Xorriso_sort_node_array(xorriso, 0); + + disk_path[0]= 0; + for(i= 0; i < xorriso->node_counter; i++) { + node= (IsoNode *) xorriso->node_array[i]; + ret= Xorriso_path_from_node(xorriso, node, img_path, 0); + if(ret < 0) + goto ex; + if(ret == 0) + continue; /* Node is deleted from tree (Should not happen here) */ + hflag= 1; + if(i == 0) { + hflag= 0; + } else if(node != xorriso->node_array[i - 1]) { + hflag= 0; + } + if(hflag == 0) { + img_prefixes= xorriso->node_img_prefixes; + disk_prefixes= xorriso->node_disk_prefixes; + } + ret= Xorriso_make_restore_path(xorriso, &img_prefixes, &disk_prefixes, + img_path, disk_path, hflag); + if(ret<=0) + goto was_problem; + + ret= Xorriso_handle_collision(xorriso, node, img_path, disk_path, disk_path, + &stbuf_ret, 64); + if(ret<=0 || ret==3) + goto was_problem; + if(xorriso->hln_array != NULL && !(xorriso->ino_behavior & 16)) { + /* Eventual lookup of hardlinks will be done in + Xorriso_restore_disk_object() */; + } else if(i > 0 && !(xorriso->ino_behavior & 4)) { + if(Xorriso__findi_sorted_ino_cmp(&(xorriso->node_array[i-1]), + &(xorriso->node_array[i])) == 0) { + if(faulty_family) { + sprintf(xorriso->info_text, "Hardlinking omitted with "); + Text_shellsafe(disk_path, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + } else { + /* Try to install hardlink to a sibling */ + ret= Xorriso_restore_prefix_hl(xorriso, node, disk_path, i, 0); + if(ret < 0) { + goto was_problem; + } else if(ret & 1) { + /* Success, hardlink was created */ + xorriso->pacifier_count++; + continue; + } + if(ret & 4) { + /* Found elder siblings, but did not link. */ + ret= Xorriso_eval_problem_status(xorriso, 1, 0); + if(ret < 0) + {ret= 0; goto ex;} + } + } + } else + faulty_family= 0; + } + + ret= Xorriso_restore_disk_object(xorriso, img_path, node, disk_path, + (off_t) 0, (off_t) 0, + 4 | (xorriso->ino_behavior & 16) | 128); + if(ret<=0) + goto was_problem; + if(ret == 4) { + /* Failed from lack of permission */ + ret= Xorriso_make_accessible(xorriso, disk_path, 0); + if(ret < 0) + goto ex; + ret= Xorriso_restore_disk_object(xorriso, img_path, node, disk_path, + (off_t) 0, (off_t) 0, 4 | (xorriso->ino_behavior & 16)); + if(ret<=0) + goto was_problem; + Permstack_pop(&(xorriso->perm_stack), perm_stack_mem, xorriso, 0); + } + + continue; /* regular bottom of loop */ +was_problem:; + faulty_family= 1; + was_failure= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret<0) + goto ex; + Permstack_pop(&(xorriso->perm_stack), perm_stack_mem, xorriso, 0); + } + ret= 1; +ex:; + Permstack_pop(&(xorriso->perm_stack), perm_stack_mem, xorriso, 0); + return(ret); +} + + +/* @param flag bit0= -follow, -not: disk_path is not a command parameter +*/ +int Xorriso_paste_in(struct XorrisO *xorriso, char *disk_path, + off_t startbyte, off_t bytecount, char *iso_rr_path, int flag) +{ + int ret; + char eff_source[SfileadrL], eff_dest[SfileadrL], sfe[SfileadrL*5]; + struct stat stbuf; + IsoNode *node; + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, disk_path, eff_dest, + 2|4); + if(ret<=0) + return(ret); + ret= Xorriso_path_is_excluded(xorriso, disk_path, !(flag&1)); + if(ret!=0) + return(0); + ret= stat(eff_dest, &stbuf); + if(ret!=-1 && !S_ISREG(stbuf.st_mode)) { + Xorriso_msgs_submit(xorriso, 0, eff_dest, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, + "-paste_in: DISK file %s exists and is not a data file", + Text_shellsafe(eff_source, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + return(0); + } + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, iso_rr_path, + eff_source, 2); + if(ret<=0) + return(ret); + ret= Xorriso_fake_stbuf(xorriso, eff_source, &stbuf, &node, 4); + if(ret<=0) + return(0); + if(!S_ISREG(stbuf.st_mode)) { + Xorriso_msgs_submit(xorriso, 0, eff_dest, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, "-paste_in: ISO file %s is not a data file", + Text_shellsafe(eff_source, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + return(0); + } + + /* >>> eventually obtain parameters from file name */; + + ret= Xorriso_restore(xorriso, eff_source, eff_dest, startbyte, bytecount, 8); + return(ret); +} + + +int Xorriso_process_msg_queues(struct XorrisO *xorriso, int flag) +{ + int ret, error_code= 0, os_errno= 0, count= 0, pass, imgid, tunneled; + char severity[80]; + + if(!xorriso->libs_are_started) + return(1); + for(pass= 0; pass< 2; pass++) { + while(1) { + tunneled= 0; + if(pass==0) + ret= iso_obtain_msgs("ALL", &error_code, &imgid, + xorriso->info_text, severity); + else { + ret= burn_msgs_obtain("ALL", &error_code, xorriso->info_text, &os_errno, + severity); + if((error_code>=0x00030000 && error_code<0x00040000) || + (error_code>=0x00050000 && error_code<0x00060000)) + tunneled= -1; /* "libisofs:" */ + else if(error_code>=0x00060000 && error_code<0x00070000) + tunneled= 1; /* "libisoburn:" */ + } + if(ret<=0) + break; + + /* <<< tunneled MISHAP from libisoburn through libburn + or well known error codes of MISHAP events + With libburn-0.4.4 this is not necessary */ + if(error_code==0x5ff73 || error_code==0x3ff73 || + error_code==0x3feb9 || error_code==0x3feb2) + strcpy(severity, "MISHAP"); + else if(error_code==0x51001) + strcpy(severity, "ERRFILE"); + + Xorriso_msgs_submit(xorriso, error_code, xorriso->info_text, os_errno, + severity, ((pass+tunneled)+1)<<2); + count++; + } + } + if(xorriso->library_msg_direct_print && count>0) { + sprintf(xorriso->info_text," (%d library messages repeated by xorriso)\n", + count); + Xorriso_info(xorriso, 0); + } + return(1); +} + + +/* @param flag + bit3=report to info channel (else to result channel) +*/ +int Xorriso_toc_line(struct XorrisO *xorriso, int flag) +{ + if(!(flag & 8)) { + Xorriso_result(xorriso,0); + return(1); + } + strcpy(xorriso->info_text, xorriso->result_line); + Xorriso_info(xorriso, 0); + return(1); +} + + +/* @param flag bit0= no output if no boot record was found + bit1= short form + bit3= report to info channel (else to result channel) +*/ +int Xorriso_show_boot_info(struct XorrisO *xorriso, int flag) +{ + int ret, bin_path_valid= 0,has_isolinux_mbr= 0, i; + unsigned int mbr_lba= 0; + off_t lb0_count; + char *respt, sfe[5*SfileadrL], path[SfileadrL]; + unsigned char lb0[2048]; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + IsoImage *image= NULL; + ElToritoBootImage *bootimg; + IsoFile *bootimg_node; + IsoBoot *bootcat_node; + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to print boot info", 0); + if(ret<=0) + return(0); + respt= xorriso->result_line; + image= isoburn_get_attached_image(drive); + if(image == NULL) { + ret= 0; +no_boot:; + if(!(flag & 1)) { + sprintf(respt, "Boot record : none\n"); + Xorriso_toc_line(xorriso, flag & 8); + } + return(ret); + } + /* Important: no return before iso_image_unref(image); */ + + /* Using the nodes with extreme care . They might be deleted meanwhile. */ + ret= iso_image_get_boot_image(image, &bootimg, &bootimg_node, &bootcat_node); + iso_image_unref(image); /* release obtained reference */ + image= NULL; + if(ret != 1) + goto no_boot; + ret= Xorriso_path_from_lba(xorriso, NULL, xorriso->loaded_boot_bin_lba, + path, 1); + if(ret > 0) + bin_path_valid= 1; + sprintf(respt, "Boot record : El Torito"); + if(bin_path_valid) + ret= Xorriso_is_isohybrid(xorriso, bootimg_node, 0); + else + ret= 0; + if(ret > 0) { + /* Load and examine potential MBR */ + ret= burn_read_data(drive, (off_t) 0, (char *) lb0, (off_t) 2048, + &lb0_count, 2); + if(ret > 0) { + has_isolinux_mbr= 1; + if(lb0[510] != 0x55 || lb0[511] != 0xaa) + has_isolinux_mbr= 0; + mbr_lba= lb0[432] | (lb0[433] << 8) | (lb0[434] << 16) | (lb0[435] << 24); + mbr_lba/= 4; + if(mbr_lba != xorriso->loaded_boot_bin_lba) + has_isolinux_mbr= 0; + if(has_isolinux_mbr) { + for(i= 0; i < 426; i++) + if(strncmp((char *) (lb0 + i), "isolinux", 8) == 0) + break; + if(i >= 426) + has_isolinux_mbr= 0; + } + for(i= 462; i < 510; i++) + if(lb0[i]) + break; + if(i < 510) + has_isolinux_mbr= 0; + } + if(has_isolinux_mbr) + strcat(respt, " , ISOLINUX isohybrid MBR pointing to boot image"); + else + strcat(respt, " , ISOLINUX boot image capable of isohybrid"); + } + strcat(respt, "\n"); + Xorriso_toc_line(xorriso, flag & 8); + if(flag & 2) + return(1); + if(bin_path_valid) + sprintf(respt, "Boot bin_path: %s\n", Text_shellsafe(path, sfe, 0)); + else if(xorriso->loaded_boot_bin_lba <= 0) + sprintf(respt, "Boot bin_path: -not-found-at-load-time-\n"); + else + sprintf(respt, "Boot bin_path: -not-found-any-more-by-lba=%d\n", + xorriso->loaded_boot_bin_lba); + Xorriso_toc_line(xorriso, flag & 8); + if(xorriso->loaded_boot_cat_path[0]) + sprintf(respt, "Boot cat_path: %s\n", + Text_shellsafe(xorriso->loaded_boot_cat_path, sfe, 0)); + else + sprintf(respt, "Boot cat_path: -not-found-at-load-time-\n"); + Xorriso_toc_line(xorriso, flag & 8); + return(1); +} + + +/* @param flag bit0=short report form + bit1=report about output drive + bit2=do not try to read ISO heads + bit3=report to info channel (else to result channel) + bit4=do no report failure if no drive aquired + bit5=only report "Drive current" and "Drive type" +*/ +int Xorriso_toc(struct XorrisO *xorriso, int flag) +{ + int num_sessions= 0, num_tracks= 0, lba= 0, nwa= -1, pmin, psec, pframe, ret; + int track_count= 0, session_no, track_no, profile_no= -1, track_size; + int last_track_start= 0, last_track_size= -1, num_data= 0, is_data= 0; + int is_inout_drive= 0, drive_role, status, num_formats, emul_lba; + int num_payload= 0, num_wasted= 0, num_nondata= 0; + char profile_name[80],*respt,*devadr, *typetext= ""; + struct burn_toc_entry toc_entry; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + enum burn_disc_status s; + char mem_text[80]; + off_t start_byte= 0, num_free= 0, size; + unsigned dummy; + struct isoburn_toc_disc *disc= NULL; + struct isoburn_toc_session **sessions; + struct isoburn_toc_track **tracks; + int image_blocks; + char volume_id[33]; + struct burn_toc_entry next_toc_entry; + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to print Table Of Content", + flag & (2 | 16)); + if(ret<=0) + return(0); + + respt= xorriso->result_line; + + if(strcmp(xorriso->indev, xorriso->outdev)==0) + is_inout_drive= 1; + if(flag&2) + devadr= xorriso->outdev; + else + devadr= xorriso->indev; + sprintf(respt, "Drive current: %s '%s'\n", + (is_inout_drive ? "-dev" : (flag&2 ? "-outdev" : "-indev")), + devadr); + Xorriso_toc_line(xorriso, flag & 8); + sprintf(respt, "Drive type : vendor '%s' product '%s' revision '%s'\n", + dinfo[0].vendor, dinfo[0].product, dinfo[0].revision); + if((flag & 32) | !(flag & 1)) + Xorriso_toc_line(xorriso, flag & 8); + if(flag & 32) + return(1); + + ret= burn_disc_get_profile(drive, &profile_no, profile_name); + s= isoburn_disc_get_status(drive); + if(profile_no == 0x0002 && s == BURN_DISC_EMPTY) + profile_no= 0; + sprintf(respt, "Media current: "); + if (profile_no > 0 && ret > 0) { + if (profile_name[0]) + sprintf(respt+strlen(respt), "%s", profile_name); + else + sprintf(respt+strlen(respt), "%4.4Xh", profile_no); + drive_role= burn_drive_get_drive_role(drive); + if(drive_role==2) + sprintf(respt+strlen(respt), ", overwriteable"); + else if(drive_role==0 || drive_role==3) + sprintf(respt+strlen(respt), ", sequential"); + strcat(respt, "\n"); + } else + sprintf(respt+strlen(respt), "is not recognizable\n"); + Xorriso_toc_line(xorriso, flag & 8); + + sprintf(respt, "Media status : "); + if (s == BURN_DISC_FULL) { + sprintf(respt+strlen(respt), "is written , is closed\n"); + } else if (s == BURN_DISC_APPENDABLE) { + sprintf(respt+strlen(respt), "is written , is appendable\n"); + } else if (s == BURN_DISC_BLANK) { + sprintf(respt+strlen(respt), "is blank\n"); + } else if (s == BURN_DISC_EMPTY) + sprintf(respt+strlen(respt), "is not present\n"); + else + sprintf(respt+strlen(respt), "is not recognizable\n"); + Xorriso_toc_line(xorriso, flag & 8); + + if(s == BURN_DISC_BLANK) { + sprintf(respt, "Media summary: 0 sessions, 0 data blocks, 0 data"); + num_free= isoburn_disc_available_space(drive, NULL); + Sfile_scale((double) num_free, mem_text,5,1e4,1); + sprintf(respt+strlen(respt), ", %s free\n", mem_text); + Xorriso_toc_line(xorriso, flag & 8); + } + if(s != BURN_DISC_FULL && s != BURN_DISC_APPENDABLE) + return(1); + if(xorriso->request_to_abort) + return(1); + + if(!(flag & 2)) + Xorriso_show_boot_info(xorriso, 1 | (flag & 8) | ((flag & 1) << 1)); + + disc= isoburn_toc_drive_get_disc(drive); + if(flag & 4) + sprintf(respt, "TOC layout : %3s , %9s , %10s\n", + "Idx", "sbsector", "Size"); + else + sprintf(respt, "TOC layout : %3s , %9s , %10s , %s\n", + "Idx", "sbsector", "Size", "Volume Id"); + if(!(flag&1)) + Xorriso_toc_line(xorriso, flag & 8); + + if (disc==NULL) { + Xorriso_process_msg_queues(xorriso,0); + ret= isoburn_get_min_start_byte(drive, &start_byte, 0); + nwa= start_byte / 2048; + if(ret<=0) { + Xorriso_process_msg_queues(xorriso,0); + if(flag&1) + return(0); + sprintf(xorriso->info_text, "Cannot obtain Table Of Content"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + + /* fabricate TOC */ + typetext= "Other session"; + if(flag & 4) { + ret= 0; + typetext= "Session "; + } else + ret= isoburn_read_iso_head(drive, 0, &image_blocks, volume_id, 1); + if(ret>0) { + sprintf(respt, "ISO session : %3d , %9d , %9ds , %s\n", + 1, 0, image_blocks, volume_id); + nwa= image_blocks; + } else { + nwa= 0; + ret= burn_disc_get_formats(drive, &status, &size, &dummy, + &num_formats); + if(ret>0 && status==BURN_FORMAT_IS_FORMATTED) + nwa= size/2048; + sprintf(respt, "%13s: %3d , %9d , %9ds , \n", + typetext, 1, 0, nwa); + } + if(!(flag&1)) + Xorriso_toc_line(xorriso, flag & 8); + last_track_start= lba; + num_payload= num_data= last_track_size= nwa; + num_sessions= 1; + } else { + sessions= isoburn_toc_disc_get_sessions(disc, &num_sessions); + for (session_no= 0; session_norequest_to_abort); + session_no++) { + tracks= isoburn_toc_session_get_tracks(sessions[session_no], &num_tracks); + if (tracks==NULL) + continue; + for(track_no= 0; track_norequest_to_abort); + track_no++) { + track_count++; + is_data= 0; + isoburn_toc_track_get_entry(tracks[track_no], &toc_entry); + if (toc_entry.extensions_valid & 1) { + /* DVD extension valid */ + lba= toc_entry.start_lba; + track_size= toc_entry.track_blocks; + } else { + lba= burn_msf_to_lba(toc_entry.pmin, toc_entry.psec, + toc_entry.pframe); + if(track_no==num_tracks-1) { + isoburn_toc_session_get_leadout_entry(sessions[session_no], + &next_toc_entry); + } else { + isoburn_toc_track_get_entry(tracks[track_no+1], &next_toc_entry); + } + track_size= burn_msf_to_lba(next_toc_entry.pmin, next_toc_entry.psec, + next_toc_entry.pframe) - lba; + } + if(flag&(1|4)) + ret= 0; + else { + ret= isoburn_toc_track_get_emul(tracks[track_no], &emul_lba, + &image_blocks, volume_id, 0); + if(ret <= 0) + ret= isoburn_read_iso_head(drive, lba, &image_blocks, volume_id, 1); + if(image_blocks > track_size) { + sprintf(xorriso->info_text, + "Session %d bears ISO image size %ds larger than track size %ds", + session_no + 1, image_blocks, track_size); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", + 0); + image_blocks= track_size; + } + } + if(ret>0 && track_no==0) { + sprintf(respt, "ISO session : %3d , %9d , %9ds , %s\n", + session_no+1, lba, image_blocks , volume_id); + } else if(ret>0) { + sprintf(respt, "ISO track : %3d , %9d , %9ds , %s\n", + track_count, lba, image_blocks , volume_id); + } else if(track_no==0) { + typetext= "Other session"; + if(flag & 4) + typetext= "Session "; + sprintf(respt, "%13s: %3d , %9d , %9ds , \n", + typetext, session_no+1, lba, track_size); + } else { + typetext= "Other track "; + if(flag & 4) + typetext= "Track "; + sprintf(respt, "%13s: %3d , %9d , %9ds , \n", + typetext, track_count, lba, track_size); + } + if(!(flag&1)) + Xorriso_toc_line(xorriso, flag & 8); + if(track_no>0) + num_payload+= lba - last_track_start; + last_track_start= lba; + if((toc_entry.control&7)>=4) /* data track */ + is_data= 1; + } + isoburn_toc_session_get_leadout_entry(sessions[session_no], &toc_entry); + if (toc_entry.extensions_valid & 1) { + lba= toc_entry.start_lba; + burn_lba_to_msf(lba, &pmin, &psec, &pframe); + } else { + lba= burn_msf_to_lba(pmin, psec, pframe); + lba= burn_msf_to_lba(toc_entry.pmin, toc_entry.psec, toc_entry.pframe); + } + last_track_size= lba - last_track_start; + num_payload+= last_track_size; + if(is_data) + num_data+= last_track_size; + } + } + if(xorriso->request_to_abort) + return(1); + num_wasted= lba - num_payload; + num_nondata= lba - num_data; + Sfile_scale(((double) num_data) * 2048.0, mem_text,5,1e4,1); + + sprintf(respt, "Media summary: %d session%s, %d data blocks, %s data", + num_sessions, (num_sessions==1 ? "" : "s"), num_data, mem_text); + num_free= isoburn_disc_available_space(drive, NULL); + Sfile_scale((double) num_free, mem_text,5,1e4,1); + sprintf(respt+strlen(respt), ", %s free", mem_text); + + sprintf(respt+strlen(respt), "\n"); + Xorriso_toc_line(xorriso, flag & 8); + + if (s==BURN_DISC_APPENDABLE && nwa!=0) { + ret= isoburn_disc_track_lba_nwa(drive, NULL, 0, &lba, &nwa); + if(ret>0) { + sprintf(respt, "Media nwa : %ds\n", nwa); + if(!(flag&1)) + Xorriso_toc_line(xorriso, flag & 8); + } + } + + if (disc!=NULL) + isoburn_toc_disc_free(disc); + Xorriso_process_msg_queues(xorriso,0); + return(1); +} + + +int Xorriso_show_devices(struct XorrisO *xorriso, int flag) +{ + char adr[BURN_DRIVE_ADR_LEN]; + int i, j, max_dev_len= 1, pad; + struct burn_drive_info *drive_list= NULL; + unsigned int drive_count; + char *respt, perms[8]; + struct stat stbuf; + + sprintf(xorriso->info_text, "Beginning to scan for devices ...\n"); + Xorriso_info(xorriso,0); + + burn_drive_clear_whitelist(); + while(!burn_drive_scan(&drive_list, &drive_count)) { + Xorriso_process_msg_queues(xorriso,0); + usleep(100000); + } + Xorriso_process_msg_queues(xorriso,0); + if(drive_count <= 0) { + + /* >>> was a drive_list created at all ? */ + /* >>> must it be freed ? */ + + sprintf(xorriso->info_text, "No drives found"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + sprintf(xorriso->info_text, "Full drive scan done\n"); + Xorriso_info(xorriso,0); + + sprintf(xorriso->info_text, "-----------------------------------------------------------------------------\n"); + Xorriso_info(xorriso,0); + respt= xorriso->result_line; + for(i= 0; i < drive_count && !(xorriso->request_to_abort); i++) { + if(burn_drive_get_adr(&(drive_list[i]), adr)<=0) + strcpy(adr, "-get_adr_failed-"); + Xorriso_process_msg_queues(xorriso,0); + if(strlen(adr)>max_dev_len) + max_dev_len= strlen(adr); + } + for(i= 0; i < drive_count && !(xorriso->request_to_abort); i++) { + if(burn_drive_get_adr(&(drive_list[i]), adr)<=0) + strcpy(adr, "-get_adr_failed-"); + Xorriso_process_msg_queues(xorriso,0); + if(stat(adr,&stbuf)==-1) { + sprintf(perms,"errno=%d",errno); + } else { + strcpy(perms,"------"); + if(stbuf.st_mode&S_IRUSR) perms[0]= 'r'; + if(stbuf.st_mode&S_IWUSR) perms[1]= 'w'; + if(stbuf.st_mode&S_IRGRP) perms[2]= 'r'; + if(stbuf.st_mode&S_IWGRP) perms[3]= 'w'; + if(stbuf.st_mode&S_IROTH) perms[4]= 'r'; + if(stbuf.st_mode&S_IWOTH) perms[5]= 'w'; + } + sprintf(respt, "%d -dev '%s' ", i, adr); + pad= max_dev_len-strlen(adr); + if(pad>0) + for(j= 0; jinfo_text, "-----------------------------------------------------------------------------\n"); + Xorriso_info(xorriso,0); + + burn_drive_info_free(drive_list); + Xorriso_process_msg_queues(xorriso,0); + return(1); +} + + +int Xorriso_tell_media_space(struct XorrisO *xorriso, + int *media_space, int *free_space, int flag) +{ + int ret; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + struct burn_write_opts *burn_options; + + (*free_space)= (*media_space)= 0; + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to -tell_media_space", 2); + if(ret<=0) + return(0); + + ret= Xorriso_make_write_options(xorriso, drive, &burn_options, 0); + if(ret<=0) + return(-1); + (*free_space)= (*media_space)= + isoburn_disc_available_space(drive, burn_options) / (off_t) 2048; + burn_write_opts_free(burn_options); + + if(xorriso->volset_change_pending) { + ret= Xorriso_write_session(xorriso, 1); + if(ret>0) + (*free_space)-= ret; + } + Xorriso_process_msg_queues(xorriso,0); + return(1); +} + + +/* @param flag bit0= fast + bit1= deformat + bit2= do not re-aquire drive + @return 0=failure, did not touch media , -1=failure, altered media + 1=success, altered media , 2=success, did not touch media +*/ +int Xorriso_blank_media(struct XorrisO *xorriso, int flag) +{ + int ret, do_deformat= 0; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + enum burn_disc_status disc_state; + struct burn_progress p; + double percent = 1.0; + int current_profile; + char current_profile_name[80]; + time_t start_time; + char mode_names[4][80]= {"all", "fast", "deformat", "deformat_quickest"}; + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to -blank", 2); + if(ret<=0) + return(0); + + burn_disc_get_profile(drive, ¤t_profile, current_profile_name); + + disc_state = isoburn_disc_get_status(drive); + if(current_profile == 0x13) { /* overwriteable DVD-RW */ + /* Depending on flag bit1 formatted DVD-RW will get blanked to sequential + state or pseudo blanked by invalidating an eventual ISO image. */ + if(flag&2) + do_deformat= 1; + } else if(current_profile == 0x14) { /* sequential DVD-RW */ + if((flag&1) && !(flag&2)) { + sprintf(xorriso->info_text, + "-blank: DVD-RW present. Mode 'fast' defaulted to mode 'all'."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + sprintf(xorriso->info_text, + "Mode 'deformat_quickest' produces single-session-only media."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0); + flag&= ~1; + } + } else if(disc_state == BURN_DISC_BLANK) { + sprintf(xorriso->info_text,"Blank media detected. Will leave it untouched"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return 2; + } else if(disc_state==BURN_DISC_FULL || disc_state==BURN_DISC_APPENDABLE) { + ; + } else if(disc_state == BURN_DISC_EMPTY) { + sprintf(xorriso->info_text,"No media detected in drive"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return 0; + } else { + sprintf(xorriso->info_text, "Unsuitable drive and media state"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return 0; + } + if(!isoburn_disc_erasable(drive)) { + sprintf(xorriso->info_text, "Media is not of erasable type"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return 0; + } + if(xorriso->do_dummy) { + sprintf(xorriso->info_text, + "-dummy mode prevents blanking of media in mode '%s'.", + mode_names[flag&3]); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(1); + } + sprintf(xorriso->info_text, "Beginning to blank media in mode '%s'.\n", + mode_names[flag&3]); + Xorriso_info(xorriso,0); + + if(do_deformat) + burn_disc_erase(drive, (flag&1)); + else + isoburn_disc_erase(drive, (flag&1)); + start_time= time(0); + usleep(1000000); + while (burn_drive_get_status(drive, &p) != BURN_DRIVE_IDLE) { + Xorriso_process_msg_queues(xorriso,0); + if(p.sectors>0 && p.sector>=0) /* display 1 to 99 percent */ + percent = 1.0 + ((double) p.sector+1.0) / ((double) p.sectors) * 98.0; + sprintf(xorriso->info_text, "Blanking ( %.1f%% done in %d seconds )", + percent, (int) (time(0) - start_time)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0); + usleep(1000000); + } + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, "Blanking done\n"); + Xorriso_info(xorriso,0); + if(!(flag & 4)) { + ret= Xorriso_reaquire_outdev(xorriso, + 2 + (xorriso->in_drive_handle == xorriso->out_drive_handle)); + if(ret <= 0) + return(-1); + } + return(1); +} + + +/* @param flag bit0= try to achieve faster formatting + bit1= use parameter size (else use default size) + bit2= do not re-aquire drive + bit7= by_index mode: + bit8 to bit15 contain the index of the format to use. + @return 0=failure, did not touch media , -1=failure, altered media + 1=success, altered media , 2=success, did not touch media +*/ +int Xorriso_format_media(struct XorrisO *xorriso, off_t in_size, int flag) +{ + int ret, mode_flag= 0, index, status, num_formats; + unsigned dummy; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + struct burn_progress p; + double percent = 1.0; + int current_profile; + char current_profile_name[80]; + off_t size= 0; + time_t start_time; + enum burn_disc_status disc_state; + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to -format", 2); + if(ret<=0) + return(0); + + if(flag & 2) { + mode_flag= 0; /* format to given size */ + } else { + mode_flag= 4; /* format to full size */ + } + burn_disc_get_profile(drive, ¤t_profile, current_profile_name); + + if(flag&128) { /* by_index */ + index= (flag>>8) & 0xff; + ret= burn_disc_get_formats(drive, &status, &size, &dummy, &num_formats); + if(ret<=0) + num_formats= 0; + if(ret<=0 || index<0 || index>=num_formats) { + if(num_formats>0) + sprintf(xorriso->info_text, + "-format by_index_%d: format descriptors range from index 0 to %d", + index, num_formats-1); + else + sprintf(xorriso->info_text, + "-format by_index_%d: no format descriptors available", index); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + mode_flag|= (flag & 0xff80); + if(flag&1) + mode_flag|= (1<<6); + + } else if(current_profile == 0x12) { /* DVD+RAM */ + if(!(flag & 2)) + mode_flag= 6; /* format to default payload size */ + if(flag&1) + mode_flag|= (1<<6); + + } else if(current_profile == 0x13) { /* DVD-RW */ + if(flag&1) { + sprintf(xorriso->info_text, + "Detected formatted DVD-RW. Thus omitting desired fast format run."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(2); + } + + } else if(current_profile == 0x14) { /* DVD-RW sequential */ + if(flag & 1) { + size= 128*1024*1024; + mode_flag= 1; /* format to size, then write size of zeros */ + } else + mode_flag= 4; + + } else if(current_profile == 0x1a) { /* DVD+RW */ + if(flag&1) { + sprintf(xorriso->info_text, + "Detected DVD+RW. Thus omitting desired fast format run."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(2); + } + + } else if(current_profile == 0x41) { /* BD-R SRM */ + if(!(flag & 2)) + mode_flag= 6; /* format to default payload size */ + if(flag&1) + mode_flag|= (1<<6); + + } else if(current_profile == 0x43) { /* BD-RE */ + if(!(flag & 2)) + mode_flag= 6; /* format to default payload size */ + if(flag&1) + mode_flag|= (1<<6); + + } else { + sprintf(xorriso->info_text, + "-format: Unsuitable media detected."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + sprintf(xorriso->info_text,"Media current: %s (%4.4xh)", + current_profile_name, current_profile); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(0); + } + if(!(flag & 1)) + mode_flag|= 16; /* enable re-formatting */ + + if(xorriso->do_dummy) { + sprintf(xorriso->info_text, "-dummy mode prevents formatting of media."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(1); + } + sprintf(xorriso->info_text, "Beginning to format media.\n"); + Xorriso_info(xorriso, 0); + if(flag & 2) + size= in_size; + burn_disc_format(drive, size, mode_flag); + + start_time= time(0); + usleep(1000000); + while (burn_drive_get_status(drive, &p) != BURN_DRIVE_IDLE) { + Xorriso_process_msg_queues(xorriso,0); + if(p.sectors>0 && p.sector>=0) /* display 1 to 99 percent */ + percent = 1.0 + ((double) p.sector+1.0) / ((double) p.sectors) * 98.0; + sprintf(xorriso->info_text, "Formatting ( %.1f%% done in %d seconds )", + percent, (int) (time(0) - start_time)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0); + usleep(1000000); + } + + Xorriso_process_msg_queues(xorriso,0); + + if(burn_drive_wrote_well(drive)) { + sprintf(xorriso->info_text, "Formatting done\n"); + Xorriso_info(xorriso,0); + } else { + sprintf(xorriso->info_text, + "libburn indicates failure with formatting."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(-1); + } + + if(!(flag & 4)) { + ret= Xorriso_reaquire_outdev(xorriso, + 2 + (xorriso->in_drive_handle == xorriso->out_drive_handle)); + if(ret <= 0) + return(-1); + } + disc_state = isoburn_disc_get_status(drive); + if(disc_state==BURN_DISC_FULL && !(flag&1)) { + /* Blank because full format certification pattern might be non-zero */ + ret= Xorriso_blank_media(xorriso, 1); + if(ret <= 0) + return(0); + } + return(1); +} + + +/* @param flag bit2= formatting rather than blanking + @return 0=failure, did not touch media , -1=failure, altered media + 1=success, altered media , 2=success, did not touch media +*/ +int Xorriso_blank_as_needed(struct XorrisO *xorriso, int flag) +{ + int ret, is_formatted= -1, status, num_formats, did_work= 0; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + enum burn_disc_status disc_state; + unsigned dummy; + int current_profile; + char current_profile_name[80]; + off_t size; + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to blank or format", 2); + if(ret<=0) + return(0); + + burn_disc_get_profile(drive, ¤t_profile, current_profile_name); + + ret= burn_disc_get_formats(drive, &status, &size, &dummy, &num_formats); + if(ret>0) { + if(status==BURN_FORMAT_IS_FORMATTED) + is_formatted= 1; + else if(status == BURN_FORMAT_IS_UNFORMATTED) + is_formatted= 0; + } + if(current_profile == 0x12 || current_profile == 0x43) { /* DVD+RAM , BD-RE */ + if(is_formatted<0) { + sprintf(xorriso->info_text, + "-blank or -format: Unclear formatting status of %s", + current_profile_name); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if(!is_formatted) { + ret= Xorriso_format_media(xorriso, (off_t) 0, (current_profile == 0x43)); + if(ret <= 0) + return(ret); + did_work= (ret == 1); + } + } else if(current_profile == 0x14 && (flag&4)) { /* DVD-RW sequential */ + ret= Xorriso_format_media(xorriso, (off_t) 0, 0); + if(ret <= 0) + return(ret); + did_work= (ret == 1); + } else if(current_profile == 0x41) { /* BD-R SRM */ + if(!is_formatted) { + ret= Xorriso_format_media(xorriso, (off_t) 0, 1); + if(ret <= 0) + return(ret); + did_work= (ret == 1); + } + } + + disc_state = isoburn_disc_get_status(drive); + if(disc_state != BURN_DISC_BLANK && !(flag&4)) { + ret= Xorriso_blank_media(xorriso, 1); + return(ret); + } + if(did_work) + return(1); + sprintf(xorriso->info_text, "%s as_needed: no need for action detected", + (flag&4) ? "-format" : "-blank"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(2); +} + + +/* @return <=0 error, 1 success +*/ +int Xorriso_list_formats(struct XorrisO *xorriso, int flag) +{ + int ret, i, status, num_formats, profile_no, type; + off_t size; + unsigned dummy; + char status_text[80], profile_name[90], *respt; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + + respt= xorriso->result_line; + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to obtain format descriptor list", 1 | 2); + if(ret<=0) + return(0); + if(ret == 2) + goto ex; + +#ifdef NIX + /* <<< obsoleted by bit0 of Xorriso_get_drive_handles */ + ret= burn_drive_get_drive_role(drive); + if(ret!=1) { + sprintf(xorriso->info_text, + "output device is not an MMC drive. -list_format does not apply"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + ret= 2; goto ex; + } +#endif /* NIX */ + + ret = burn_disc_get_formats(drive, &status, &size, &dummy, + &num_formats); + if(ret<=0) { + sprintf(xorriso->info_text, "Cannot obtain format list info"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + ret= Xorriso_toc(xorriso, 3); + if(ret<=0) + goto ex; + ret= burn_disc_get_profile(drive, &profile_no, profile_name); + if(ret<=0) + goto ex; + + if(status == BURN_FORMAT_IS_UNFORMATTED) + sprintf(status_text, "unformatted, up to %.1f MiB", + ((double) size) / 1024.0 / 1024.0); + else if(status == BURN_FORMAT_IS_FORMATTED) { + if(profile_no==0x12 || profile_no==0x13 || profile_no==0x1a || + profile_no==0x43) + sprintf(status_text, "formatted, with %.1f MiB", + ((double) size) / 1024.0 / 1024.0); + else + sprintf(status_text, "written, with %.1f MiB", + ((double) size) / 1024.0 / 1024.0); + } else if(status == BURN_FORMAT_IS_UNKNOWN) { + if (profile_no > 0) + sprintf(status_text, "intermediate or unknown"); + else + sprintf(status_text, "no media or unknown media"); + } else + sprintf(status_text, "illegal status according to MMC-5"); + sprintf(respt, "Format status: %s\n", status_text); + Xorriso_result(xorriso,0); + + for (i= 0; i < num_formats; i++) { + ret= burn_disc_get_format_descr(drive, i, &type, &size, &dummy); + if (ret <= 0) + continue; + sprintf(respt, "Format idx %-2d: %2.2Xh , %.fs , %.1f MiB\n", + i, type, ((double) size) / 2048.0, ((double) size) / 1024.0/1024.0); + Xorriso_result(xorriso,0); + } + ret= 1; +ex:; + return(ret); +} + + +/* @param flag bit0= cdrecord style + bit1= obtain outdrive, else indrive + @return <=0 error, 1 success +*/ +int Xorriso_list_profiles(struct XorrisO *xorriso, int flag) +{ + int ret, i; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + int num_profiles, profiles[64]; + char is_current[64], profile_name[90], *respt; + + respt= xorriso->result_line; + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to obtain profile list", 1 | (flag & 2)); + if(ret<=0) + return(0); + burn_drive_get_all_profiles(drive, &num_profiles, profiles, is_current); + for(i= 0; i < num_profiles; i++) { + ret= burn_obtain_profile_name(profiles[i], profile_name); + if(ret <= 0) + strcpy(profile_name, "unknown"); + sprintf(respt, "%s 0x%4.4X (%s)%s\n", + flag & 1 ? "Profile:" : "Profile :", + (unsigned int) profiles[i], + profile_name, is_current[i] ? " (current)" : ""); + Xorriso_result(xorriso,0); + } + return(1); +} + + +int Xorriso_cannot_create_iter(struct XorrisO *xorriso, int iso_error,int flag) +{ + Xorriso_process_msg_queues(xorriso,0); + Xorriso_report_iso_error(xorriso, "", iso_error, "Cannot create iter", 0, + "FATAL", 1); + sprintf(xorriso->info_text, "Cannot create IsoDirIter object"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(1); +} + + +int Xorriso__node_lba_cmp(const void *node1, const void *node2) +{ + int ret; + int lba1= 0, lba2= 0; + + ret= Xorriso__file_start_lba(*((IsoNode **) node1), &lba1, 0); + if(ret!=1) + lba1= 0; + ret= Xorriso__file_start_lba(*((IsoNode **) node2), &lba2, 0); + if(ret!=1) + lba2= 0; + return(lba1-lba2); +} + +/* The caller shall make no assumptions about the meaning of iter, node_array, + node_count, node_idx ! They are just opaque handles for which the caller + provides the memory of proper type. + @param flag bit0= initialize iteration + bit1= action needs full freedom of object manipulation + bit2= action needs LBA sorted iteration + bit31= end iteration (mandatory !) +*/ +int Xorriso_findi_iter(struct XorrisO *xorriso, IsoDir *dir_node, off_t *mem, + IsoDirIter **iter, + IsoNode ***node_array, int *node_count, int *node_idx, + IsoNode **iterated_node, int flag) +{ + int ret, i; + IsoNode *node; + off_t new_mem= 0; + char mem_text[80], limit_text[80]; + + if(flag&1) { + *node_array= NULL; + *node_count= -1; + *node_idx= 0; + *iter= NULL; + ret= iso_dir_get_children(dir_node, iter); + if(ret<0) { +cannot_iter:; + Xorriso_cannot_create_iter(xorriso, ret, 0); + return(-1); + } + if((flag&2)|(flag&4)) { + /* copy list of nodes and prepare soft iterator */ + *node_count= 0; + while(iso_dir_iter_next(*iter, &node) == 1) + (*node_count)++; + iso_dir_iter_free(*iter); + *iter= NULL; + + new_mem= ((*node_count)+1) * sizeof(IsoNode *); + if(new_mem > xorriso->temp_mem_limit) { + Sfile_scale((double) new_mem, mem_text, 5,1e4, 0); + Sfile_scale((double) xorriso->temp_mem_limit, limit_text, 5,1e4, 0); + sprintf(xorriso->info_text, + "Stacked directory snapshots exceed -temp_mem_limit (%s > %s)", + mem_text, limit_text); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + *node_count= -1; + return(-1); + } + (*node_array)= (IsoNode **) calloc((*node_count)+1, sizeof(IsoNode *)); + if(*node_array == NULL) { + sprintf(xorriso->info_text, + "Could not allocate inode list of %.f bytes", + ((double) (*node_count)+1) * (double) sizeof(IsoNode *)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + *node_count= -1; + return(-1); + } + *mem= new_mem; + ret= iso_dir_get_children(dir_node, iter); + if(ret<0) + goto cannot_iter; + while(iso_dir_iter_next(*iter, &node) == 1 && *node_idx < *node_count) { + (*node_array)[*node_idx]= node; + iso_node_ref(node); + (*node_idx)++; + } + iso_dir_iter_free(*iter); + *iter= NULL; + *node_count= *node_idx; + *node_idx= 0; + if((flag&4) && *node_count>1) + qsort(*node_array, *node_count, sizeof(IsoNode *), + Xorriso__node_lba_cmp); + } + } + + if(flag&(1<<31)) { + if(*node_count>=0 && *node_array!=NULL) { + for(i= 0; i<*node_count; i++) + iso_node_unref((*node_array)[i]); + free(*node_array); + *node_array= NULL; + *node_count= -1; + *node_idx= 0; + } else { + if(*iter!=NULL) + iso_dir_iter_free(*iter); + *iter= NULL; + } + } + + if(flag&(1|(1<<31))) + return(1); + if(*node_count>=0) { + /* return next node_array element */ + if(*node_idx>=*node_count) + return(0); + *iterated_node= (*node_array)[*node_idx]; + (*node_idx)++; + } else { + ret= iso_dir_iter_next(*iter, iterated_node); + return(ret == 1); + } + return(1); +} + + +/* @param boss_iter If not NULL then this is an iterator suitable for + iso_dir_iter_remove() which is then to be used instead + of iso_node_remove(). + @param flag bit0= remove whole sub tree: rm -r + bit1= remove empty directory: rmdir + bit2= recursion: do not reassure in mode 2 "tree" + bit3= this is for overwriting and not for plain removal + bit4= count deleted files in xorriso->pacifier_count + bit5= with bit0 only remove directory content, not the directory + bit6= do not delete eventually existing node from di_array + @return <=0 = error + 1 = removed simple node + 2 = removed directory or tree + 3 = did not remove on user revocation +*/ +int Xorriso_rmi(struct XorrisO *xorriso, void *boss_iter, off_t boss_mem, + char *path, int flag) +{ + int ret, is_dir= 0, pl, not_removed= 0, fret; + IsoNode *victim_node, *node; + IsoDir *boss_node, *root_dir; + IsoDirIter *iter= NULL; + IsoImage *volume; + char *sub_name, *name; + char *sfe= NULL, *sub_path= NULL; + off_t mem; + IsoNode **node_array= NULL; + int node_count= 0, node_idx; + + /* Avoiding large local memory objects in order to save stack space */ + sfe= malloc(5*SfileadrL); + sub_path= malloc(2*SfileadrL); + if(sfe==NULL || sub_path==NULL) { + Xorriso_no_malloc_memory(xorriso, &sfe, 0); + {ret= -1; goto ex;} + } + +#ifndef Libisofs_iso_dir_iter_sufficienT + /* Ticket 127: A80301 - A80302 + I do not not deem IsoDirIter safe for node list manipulations. + The parameter boss_iter once was intended to allow such but + has now been downgraded to a mere check for eventual programming bugs. + */ + if(boss_iter!=NULL) { + sprintf(xorriso->info_text, + "Program error: Xorriso_rmi() was requested to delete iterated node %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + ret= -1; goto ex; + } +#endif /* Libisofs_iso_dir_iter_sufficienT */ + + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + goto ex; + + if(Xorriso_much_too_long(xorriso, strlen(path), 0)<=0) + {ret= 0; goto ex;} + ret= Xorriso_node_from_path(xorriso, volume, path, &victim_node, 0); + if(ret<=0) + goto ex; + root_dir= iso_image_get_root(volume); + if(((void *) root_dir) == ((void *) victim_node)) { + sprintf(xorriso->info_text, "May not delete root directory"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + + if(LIBISO_ISDIR(victim_node)) + is_dir= 1; + if(!is_dir) { + if(flag&2) { /* rmdir */ + sprintf(xorriso->info_text, "%s in loaded ISO image is not a directory", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + } else { + if(flag&1) { /* rm -r */ + if((xorriso->do_reassure==1 && !xorriso->request_not_to_ask) || + (flag&32)) { + /* Iterate over subordinates and delete them */ + mem= boss_mem; + + ret= Xorriso_findi_iter(xorriso, (IsoDir *) victim_node, &mem, + &iter, &node_array, &node_count, &node_idx, + &node, 1|2); + if(ret<=0) { +cannot_create_iter:; + Xorriso_cannot_create_iter(xorriso, ret, 0); + ret= -1; goto ex; + } + pl= strlen(path); + strcpy(sub_path, path); + if(pl==0 || sub_path[pl-1]!='/') { + sub_path[pl++]= '/'; + sub_path[pl]= 0; + } + sub_name= sub_path+pl; + while(1) { + ret= Xorriso_findi_iter(xorriso, (IsoDir *) victim_node, &mem, &iter, + &node_array, &node_count, &node_idx, &node, 0); + if(ret<0) + goto ex; + if(ret==0 || xorriso->request_to_abort) + break; + name= (char *) iso_node_get_name(node); + if(Xorriso_much_too_long(xorriso, pl+1+strlen(name), 0)<=0) + {ret= 0; goto rm_r_problem_handler;} + strcpy(sub_name, name); + ret= Xorriso_rmi(xorriso, iter, mem, sub_path, + (flag & ( 1 | 2 | 8 | 16 | 64)) | 4); + if(ret==3 || ret<=0 || xorriso->request_to_abort) { +rm_r_problem_handler:; + not_removed= 1; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret<0) + goto dir_not_removed; + } + } + if(flag&32) + {ret= 2; goto ex;} + + if(not_removed) { +dir_not_removed:; + sprintf(xorriso->info_text, "Directory not removed: %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + if(ret>0) + ret= 3; + goto ex; + } + } + } else { + if(!(flag&2)) { /* not rmdir */ + sprintf(xorriso->info_text, "%s in loaded ISO image is a directory", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + + ret= iso_dir_get_children((IsoDir *) victim_node, &iter); + Xorriso_process_msg_queues(xorriso,0); + if(ret<0) + goto cannot_create_iter; + if(ret>0) { + if(iso_dir_iter_next(iter, &node) == 1) { + sprintf(xorriso->info_text, + "Directory not empty on attempt to delete: %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + } + } + } + + if(xorriso->request_to_abort) + {ret= 3; goto ex;} + boss_node= iso_node_get_parent(victim_node); + Xorriso_process_msg_queues(xorriso,0); + if(boss_node==NULL) { + sprintf(xorriso->info_text, + "Cannot find parent node of %s in loaded ISO image", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + + while((xorriso->do_reassure==1 || (xorriso->do_reassure==2 && !(flag&4))) + && !xorriso->request_not_to_ask) { + /* ls -ld */ + Xorriso_ls_filev(xorriso, xorriso->wdi, 1, &path, (off_t) 0, 1|2|8); + if(is_dir) /* du -s */ + Xorriso_ls_filev(xorriso, xorriso->wdi, 1, &path, (off_t) 0, 2|4); + if(flag&8) + sprintf(xorriso->info_text, + "File exists. Remove ? n= keep old, y= remove, x= abort, @= stop asking\n"); + else + sprintf(xorriso->info_text, + "Remove above file ? n= keep it, y= remove it, x= abort, @= stop asking\n"); + Xorriso_info(xorriso, 4); + ret= Xorriso_request_confirmation(xorriso, 1|2|4|16); + if(ret<=0) + goto ex; + if(xorriso->request_to_abort) { + sprintf(xorriso->info_text, + "Removal operation aborted by user before file: %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + ret= 3; goto ex; + } + if(ret==3) + continue; + if(ret==6) /* yes */ + break; + if(ret==4) { /* yes, do not ask again */ + xorriso->request_not_to_ask= 1; + break; + } + if(ret==1) { /* no */ + sprintf(xorriso->info_text, "Kept in existing state: %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + ret= 3; goto ex; + } + } + + if(!(flag & 64)) + Xorriso_invalidate_di_item(xorriso, victim_node, 0); + +#ifdef Libisofs_iso_dir_iter_sufficienT + + if(boss_iter!=NULL) { + ret= iso_dir_iter_remove((IsoDirIter *) boss_iter); + if(ret<0) + ret= -1; + } else + ret= iso_node_remove(victim_node); + +#else /* ! Libisofs_iso_dir_iter_sufficienT */ + + ret= iso_node_remove(victim_node); + +#endif /* Libisofs_iso_dir_iter_sufficienT */ + + Xorriso_process_msg_queues(xorriso,0); + if(ret<0) { + Xorriso_report_iso_error(xorriso, path, ret, "Cannot remove node", 0, + "FATAL", 1); + sprintf(xorriso->info_text, + "Internal failure to remove %s from loaded ISO image", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + ret= -1; goto ex; + } + + if(flag&16) + xorriso->pacifier_count++; + Xorriso_set_change_pending(xorriso, 0); + ret= 1+!!is_dir; +ex:; + if(sfe!=NULL) + free(sfe); + if(sub_path!=NULL) + free(sub_path); + Xorriso_findi_iter(xorriso, (IsoDir *) victim_node, &mem, &iter, + &node_array, &node_count, &node_idx, &node, (1<<31)); + return(ret); +} + + +int Xorriso__node_name_cmp(const void *node1, const void *node2) +{ + char *name1, *name2; + + name1= (char *) iso_node_get_name(*((IsoNode **) node1)); + name2= (char *) iso_node_get_name(*((IsoNode **) node2)); + return(strcmp(name1,name2)); +} + + +/* @param flag bit0= only accept directory nodes + bit1= do not report memory usage as DEBUG + bit2= do not apply search pattern but accept any node +*/ +int Xorriso_sorted_node_array(struct XorrisO *xorriso, + IsoDir *dir_node, + int *nodec, IsoNode ***node_array, + off_t boss_mem, int flag) +{ + int i, ret, failed_at; + char *npt; + IsoDirIter *iter= NULL; + IsoNode *node; + off_t mem; + + mem= ((*nodec)+1)*sizeof(IsoNode *); + ret= Xorriso_check_temp_mem_limit(xorriso, mem+boss_mem, flag&2); + if(ret<=0) + return(ret); + + *node_array= calloc(sizeof(IsoNode *), (*nodec)+1); + if(*node_array==NULL) { + sprintf(xorriso->info_text, + "Cannot allocate memory for %d directory entries", *nodec); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(-1); + } + + ret= iso_dir_get_children(dir_node, &iter); + if(ret<0) { + Xorriso_cannot_create_iter(xorriso, ret, 0); + return(-1); + } + + for(i= 0; iso_dir_iter_next(iter, &node) == 1 && i<*nodec; ) { + npt= (char *) iso_node_get_name(node); + if(!(flag&4)) { + ret= Xorriso_regexec(xorriso, npt, &failed_at, 0); + if(ret) + continue; /* no match */ + } + if(flag&1) + if(!LIBISO_ISDIR(node)) + continue; + (*node_array)[i++]= node; + } + iso_dir_iter_free(iter); + *nodec= i; + if(*nodec<=0) + return(1); + qsort(*node_array, *nodec, sizeof(IsoNode *), Xorriso__node_name_cmp); + return(1); +} + + +/* @param flag bit0= do not only sum up sizes but also print subdirs +*/ +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) +{ + int i, ret, no_sort= 0, filec= 0, l; + IsoDirIter *iter= NULL; + IsoNode *node, **node_array= NULL; + char *name; + off_t sub_size, report_size, mem= 0; + char *path= NULL, *show_path= NULL, *sfe= NULL; + + sfe= malloc(5*SfileadrL); + path= malloc(SfileadrL); + show_path= malloc(SfileadrL); + if(path==NULL || show_path==NULL || sfe==NULL) { + Xorriso_no_malloc_memory(xorriso, &sfe, 0); + {ret= -1; goto ex;} + } + + *size= 0; + ret= iso_dir_get_children(dir_node, &iter); + if(ret<0) { +cannot_create_iter:; + Xorriso_cannot_create_iter(xorriso, ret, 0); + {ret= -1; goto ex;} + } + for(i= 0; iso_dir_iter_next(iter, &node) == 1; ) { + sub_size= 0; + name= (char *) iso_node_get_name(node); + strcpy(show_path, rel_path); + if(Sfile_add_to_path(show_path, name, 0)<=0) + goto much_too_long; + if(LIBISO_ISDIR(node)) { + strcpy(path, abs_path); + if(Sfile_add_to_path(path, name, 0)<=0) { +much_too_long:; + Xorriso_much_too_long(xorriso, strlen(path)+strlen(name)+1, 2); + {ret= -1; goto ex;} + } + filec++; + l= strlen(rel_path)+1; + mem+= l; + if(l % sizeof(char *)) + mem+= sizeof(char *)-(l % sizeof(char *)); + if(flag&1) /* diving and counting is done further below */ + continue; + ret= Xorriso_show_du_subs(xorriso, (IsoDir *) node, + path, show_path, &sub_size, boss_mem, 0); + if(ret<0) + goto ex; + if(ret==0) + continue; + } + + if(LIBISO_ISREG(node)) { + sub_size+= iso_file_get_size((IsoFile *) node)+2048; +/* + sub_size+= iso_file_get_size((IsoFile *) node)+strlen(name)+1; +*/ + } + + if(sub_size>0) + (*size)+= sub_size; + Xorriso_process_msg_queues(xorriso,0); + } + + if(filec<=0 || !(flag&1)) + {ret= 1; goto ex;} + + /* Reset iteration */ + iso_dir_iter_free(iter); + iter= NULL; + Xorriso_process_msg_queues(xorriso,0); + + ret= Xorriso_sorted_node_array(xorriso, dir_node, &filec, &node_array, + boss_mem, 1|2|4); + if(ret<0) + goto ex; + if(ret==0) { + no_sort= 1; + ret= iso_dir_get_children(dir_node, &iter); + if(ret<0) + goto cannot_create_iter; + } + + for(i= 0; (no_sort || irequest_to_abort); i++) { + if(no_sort) { + ret= iso_dir_iter_next(iter, &node); + if(ret!=1) + break; + if(!LIBISO_ISDIR(node)) + continue; + } else + node= node_array[i]; + + sub_size= 0; + name= (char *) iso_node_get_name(node); + strcpy(show_path, rel_path); + if(Sfile_add_to_path(show_path, name, 0)<=0) + goto much_too_long; + strcpy(path, abs_path); + if(Sfile_add_to_path(path, name, 0)<=0) + goto much_too_long; + ret= Xorriso_show_du_subs(xorriso, (IsoDir *) node, + path, show_path, &sub_size, boss_mem+mem, flag&1); + if(ret<0) + goto ex; + + if(LIBISO_ISREG(node)) { + sub_size+= iso_file_get_size((IsoFile *) node)+2048; +/* + sub_size+= iso_tree_node_get_size((IsoFile *) node)+strlen(name)+1; +*/ + } + if(sub_size>0) + (*size)+= sub_size; + report_size= sub_size/1024; + if(report_size*1024result_line, "%7.f ",(double) (report_size)); + sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s\n", + Text_shellsafe(show_path, sfe, 0)); + Xorriso_result(xorriso, 0); + } + ret= 1; +ex:; + if(sfe!=NULL) + free(sfe); + if(path!=NULL) + free(path); + if(show_path!=NULL) + free(show_path); + if(iter!=NULL) + iso_dir_iter_free(iter); + if(node_array!=NULL) + free((char *) node_array); + Xorriso_process_msg_queues(xorriso,0); + return(ret); +} + + +int Xorriso_sorted_dir_i(struct XorrisO *xorriso, IsoDir *dir_node, + int *filec, char ***filev, off_t boss_mem, int flag) +{ + int i,j,ret; + IsoDirIter *iter= NULL; + IsoNode *node; + char *name; + off_t mem; + + (*filec)= 0; + (*filev)= NULL; + + ret= iso_dir_get_children(dir_node, &iter); + if(ret<0) { +cannot_iter:; + Xorriso_cannot_create_iter(xorriso, ret, 0); + {ret= -1; goto ex;} + } + mem= 0; + for(i= 0; iso_dir_iter_next(iter, &node) == 1; ) { + name= (char *) iso_node_get_name(node); + mem+= sizeof(char *)+strlen(name)+8; + (*filec)++; + } + iso_dir_iter_free(iter); + iter= NULL; + if(*filec==0) + {ret= 1; goto ex;} + + ret= Xorriso_check_temp_mem_limit(xorriso, mem+boss_mem, 2); + if(ret<=0) + goto ex; + (*filev)= (char **) calloc(*filec, sizeof(char *)); + if(*filev==NULL) + {ret= -1; goto ex; } + ret= iso_dir_get_children(dir_node, &iter); + if(ret<0) + goto cannot_iter; + for(i= 0; i<*filec; i++) { + ret= iso_dir_iter_next(iter, &node); + if(ret!=1) + break; + name= (char *) iso_node_get_name(node); + (*filev)[i]= strdup(name); + if((*filev)[i]==NULL) { + for(j= 0; jresult_line; + + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(ret); + + Sort_argv(filec, filev, 0); + + /* Count valid nodes, warn of invalid ones */ + for(i= 0; iinfo_text, "Not found in ISO image: %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + was_error++; + continue; + } + } + + if((flag&8) && !(flag&(2|4))) { + sprintf(xorriso->info_text, "Valid ISO nodes found: %d\n", filec-was_error); + Xorriso_info(xorriso,1); + if(filec-was_error<=0) + return(!was_error); + } + + passes= 1+!(flag&(4|8)); + for(pass= 0; passrequest_to_abort); i++) { + rpt[0]= 0; + ret= Xorriso_make_abs_adr(xorriso, wd, filev[i], path, 1|2|4); + if(ret<=0) + continue; + ret= Xorriso_fake_stbuf(xorriso, path, &stbuf, &node, ((flag&4) >> 1) | 16); + if(ret<=0) + continue; + if(LIBISO_ISDIR(node) && !(flag&(4|8))) { + if(pass==0) + continue; + if(filec>1) { + strcpy(xorriso->result_line, "\n"); + Xorriso_result(xorriso,0); + sprintf(xorriso->result_line, "%s:\n", Text_shellsafe(filev[i], sfe,0)); + Xorriso_result(xorriso,0); + } + ret= Xorriso_sorted_dir_i(xorriso, + (IsoDir *) node, &dfilec, &dfilev, boss_mem, 0); + if(ret<=0) { + + /* >>> libisofs iterator loop and single item Xorriso_lsx_filev() */; + + } else { + if(flag&1) { + sprintf(xorriso->result_line, "total %d\n", dfilec); + Xorriso_result(xorriso,0); + } + Xorriso_ls_filev(xorriso, path, + dfilec, dfilev, boss_mem, (flag&1)|2|8); + } + if(dfilec>0) + Sfile_destroy_argv(&dfilec, &dfilev, 0); + continue; + } else + if(pass>0) + continue; + link_target[0]= 0; + if((flag&5)==1) { /* -ls_l */ + iso_node_get_acl_text(node, &a_text, &d_text, 16); + ret= Xorriso_format_ls_l(xorriso, &stbuf, + 1 | ((a_text != NULL || d_text != NULL) << 1)); + iso_node_get_acl_text(node, &a_text, &d_text, 1 << 15); + if(ret<=0) + continue; + if(LIBISO_ISLNK(node)) { + if(Sfile_str(link_target, (char *) iso_symlink_get_dest( + (IsoSymlink *) node), 0)<=0) + link_target[0]= 0; + } + } else if(flag&4) { /* -du or -dus */ + size= stbuf.st_size; + if(S_ISDIR(stbuf.st_mode)) { + ret= Xorriso_show_du_subs(xorriso, (IsoDir *) node, + path, filev[i], &size, boss_mem, flag&1); + if(ret<0) + return(-1); + if(ret==0) + continue; + } + sprintf(rpt, "%7.f ",(double) (size/1024)); + } + if(link_target[0] && (flag&5)==1) + sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s -> %s\n", + Text_shellsafe(filev[i], sfe, 0), + Text_shellsafe(link_target, sfe2, 0)); + else + sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s\n", + Text_shellsafe(filev[i], sfe, 0)); + Xorriso_result(xorriso, 0); + } + return(!was_error); +} + + +/* This function needs less buffer memory than Xorriso_ls_filev() but cannot + perform structured pattern matching as done by Xorriso_expand_pattern() + for subsequent Xorriso_ls_filev(). + @param flag bit0= long format + bit1= only check for directory existence + bit2= do not apply search pattern but accept any file + bit3= just count nodes and return number +*/ +int Xorriso_ls(struct XorrisO *xorriso, int flag) +{ + int ret, is_dir= 0, i, filec= 0, failed_at, no_sort= 0; + IsoNode *node, **node_array= NULL; + IsoDir *dir_node; + IsoImage *volume; + IsoDirIter *iter= NULL; + char sfe[5*SfileadrL], sfe2[5*SfileadrL], link_target[SfileadrL], *npt, *rpt; + struct stat stbuf; + + rpt= xorriso->result_line; + + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(ret); + + ret= Xorriso_node_from_path(xorriso, volume, xorriso->wdi, &node, 0); + if(ret<=0) + goto wdi_is_not_a_dir; + if(LIBISO_ISDIR(node)) + is_dir= 1; + if(!is_dir) { +wdi_is_not_a_dir:; + sprintf(xorriso->info_text, + "Working directory path does not lead to a directory in ISO image"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + if(flag&2) + {ret= 1; goto ex;} + + dir_node= (IsoDir *) node; + ret= iso_dir_get_children(dir_node, &iter); + if(ret<0) { +cannot_create_iter:; + Xorriso_cannot_create_iter(xorriso, ret, 0); + {ret= -1; goto ex;} + } + Xorriso_process_msg_queues(xorriso,0); + + for(i= 0; iso_dir_iter_next(iter, &node) == 1; ) { + npt= (char *) iso_node_get_name(node); + if(!(flag&4)) { + ret= Xorriso_regexec(xorriso, npt, &failed_at, 0); + if(ret) + continue; /* no match */ + } + filec++; + } + /* Reset iteration */ + iso_dir_iter_free(iter); + iter= NULL; + Xorriso_process_msg_queues(xorriso,0); + if(flag&8) + {ret= filec; goto ex;} + sprintf(xorriso->info_text, "Valid ISO nodes found: %d\n", filec); + Xorriso_info(xorriso,1); + + ret= Xorriso_sorted_node_array(xorriso, dir_node, &filec, &node_array, 0, + flag&4); + if(ret<0) + goto ex; + if(ret==0) { + no_sort= 1; + ret= iso_dir_get_children(dir_node, &iter); + if(ret<0) + goto cannot_create_iter; + } + + for(i= 0; irequest_to_abort); i++) { + if(no_sort) { + ret= iso_dir_iter_next(iter, &node); + if(ret!=1) + break; + npt= (char *) iso_node_get_name(node); + if(!(flag&4)) { + ret= Xorriso_regexec(xorriso, npt, &failed_at, 0); + if(ret) + continue; /* no match */ + } + } else + node= node_array[i]; + + npt= (char *) iso_node_get_name(node); + link_target[0]= 0; + if(LIBISO_ISLNK(node)) { + if(Sfile_str(link_target, (char *) iso_symlink_get_dest( + (IsoSymlink *) node), 0)<=0) + link_target[0]= 0; + } + rpt[0]= 0; + if(flag&1) { + ret= Xorriso_fake_stbuf(xorriso, "", &stbuf, &node, 1); + if(ret<=0) + continue; + ret= Xorriso_format_ls_l(xorriso, &stbuf, 1); + if(ret<=0) + continue; + } + if(link_target[0] && (flag&1)) + sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s -> %s\n", + Text_shellsafe(npt, sfe, 0), + Text_shellsafe(link_target, sfe2, 0)); + else + sprintf(xorriso->result_line+strlen(xorriso->result_line), "%s\n", + Text_shellsafe(npt, sfe, 0)); + Xorriso_result(xorriso, 0); + } + + ret= 1; +ex:; + if(iter!=NULL) + iso_dir_iter_free(iter); + Xorriso_process_msg_queues(xorriso,0); + if(node_array!=NULL) + free((char *) node_array); + return(ret); +} + + +/* @param boss_iter Opaque handle to be forwarded to actions in ISO image + Set to NULL if calling this function from outside ISO world +*/ +int Xorriso_rename(struct XorrisO *xorriso, void *boss_iter, + char *origin, char *dest, int flag) +{ + int ret, ol, dest_ret; + char sfe[5*SfileadrL], eff_dest[SfileadrL], dir_adr[SfileadrL], *cpt; + char *leafname, eff_origin[SfileadrL], sfe2[5*SfileadrL], *old_leafname; + IsoImage *volume; + IsoDir *origin_dir, *dest_dir; + IsoNode *node, *iso_node; + +#ifndef Libisofs_iso_dir_iter_sufficienT + /* Ticket 127: A80301 - A80302 + I do not not deem IsoDirIter safe for node list manipulations. + The parameter boss_iter once was intended to allow such but + has now been downgraded to a mere check for eventual programming bugs. + */ + if(boss_iter!=NULL) { + sprintf(xorriso->info_text, + "Program error: Xorriso_rename() was requested to delete iterated node %s", + Text_shellsafe(origin, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(-1); + } +#endif /* Libisofs_iso_dir_iter_sufficienT */ + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, origin, eff_origin, 0); + if(ret<=0) + return(ret); + dest_ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, dest, eff_dest,1); + if(dest_ret<0) + return(dest_ret); + if(dest_ret==0) { /* obtain eff_dest address despite it does not exist */ + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, dest, eff_dest, 2); + if(ret<=0) + return(ret); + } + + /* Prevent that destination is a subordinate of origin + (that would be a black hole plopping out of the universe) */ + ol= strlen(eff_origin); + if(ol==0) { + sprintf(xorriso->info_text, "May not rename root directory"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } else if(strcmp(eff_origin, eff_dest)==0) { + sprintf(xorriso->info_text, "Ignored attempt to rename %s to itself", + Text_shellsafe(eff_origin,sfe,0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + return(0); + } else if(strncmp(eff_origin, eff_dest, ol)==0 && + (eff_dest[ol]==0 || eff_dest[ol]=='/')) { + sprintf(xorriso->info_text, + "May not rename %s to its own sub address %s", + Text_shellsafe(eff_origin,sfe,0), Text_shellsafe(eff_dest,sfe2,0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + + /* Check whether destination exists and may be not overwriteable */ + if(dest_ret==2 && xorriso->do_overwrite!=1) { + sprintf(xorriso->info_text, "Renaming may not overwrite directory: %s", + Text_shellsafe(eff_dest, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } else if (dest_ret==1 && !xorriso->do_overwrite) { + sprintf(xorriso->info_text, "Renaming may not overwite: %s", + Text_shellsafe(eff_dest, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } else if(dest_ret>0) { + ret= Xorriso_rmi(xorriso, boss_iter, (off_t) 0, eff_dest, 1|8); + if(ret<=0) + return(0); + if(ret==3) { + sprintf(xorriso->info_text, "User revoked renaming of: %s", + Text_shellsafe(eff_origin, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(0); + } + } + + /* Ensure existence of destination directory */ + strcpy(dir_adr, eff_dest); + cpt= strrchr(dir_adr, '/'); + if(cpt==NULL) + cpt= dir_adr+strlen(dir_adr); + *cpt= 0; + if(dir_adr[0]!=0) { + ret= Xorriso_graft_in(xorriso, boss_iter, NULL, dir_adr, + (off_t) 0, (off_t) 0, 1); + if(ret<=0) + return(ret); + } + + /* Move node */ + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(ret); + Xorriso_node_from_path(xorriso, volume, dir_adr, &iso_node, 0); + dest_dir= (IsoDir *) iso_node; + strcpy(dir_adr, eff_origin); + cpt= strrchr(dir_adr, '/'); + if(cpt==NULL) + cpt= dir_adr+strlen(dir_adr); + *cpt= 0; + Xorriso_node_from_path(xorriso, volume, dir_adr, &iso_node, 0); + origin_dir= (IsoDir *) iso_node; + Xorriso_node_from_path(xorriso, volume, eff_origin, &node, 0); + if(dest_dir==NULL || origin_dir==NULL || node==NULL) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "Internal error on rename: confirmed node turns out as NULL"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(-1); + } + ret= iso_node_take(node); + if(ret<0) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_report_iso_error(xorriso, eff_dest, 0, "Cannot take", 0, "FATAL",1); + sprintf(xorriso->info_text, + "Internal error on rename: failed to take node"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(-1); + } + leafname= strrchr(eff_dest, '/'); + if(leafname==NULL) + leafname= eff_dest; + else + leafname++; + + old_leafname= (char *) iso_node_get_name(node); + if(strcmp(leafname, old_leafname)!=0) + ret= iso_node_set_name(node, leafname); + else + ret= 1; + if(ret<0) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_report_iso_error(xorriso, eff_dest, 0, "Cannot set name", 0, + "FAILURE", 1); + return(-1); + } + Xorriso_process_msg_queues(xorriso,0); + ret= iso_dir_add_node(dest_dir, node, 0); + if(ret<0) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_report_iso_error(xorriso, eff_dest, 0, "Cannot add", 0, "FATAL", 1); + sprintf(xorriso->info_text, + "Internal error on rename: failed to insert node"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(-1); + } + return(1); +} + + +/* @param flag bit0= do not produce info message on success + @return 1=success, + 0=was already directory, -1=was other type, -2=other error +*/ +int Xorriso_mkdir(struct XorrisO *xorriso, char *path, int flag) +{ + int ret; + char eff_path[SfileadrL], sfe[5*SfileadrL]; + + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 1); + if(ret<0) + return(-2); + if(ret>0) { + sprintf(xorriso->info_text,"-mkdir: Address already existing %s", + Text_shellsafe(eff_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, + (ret==2 ? "WARNING" : "FAILURE"), 0); + return(-1+(ret==2)); + } + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 2); + if(ret<0) + return(-2); + ret= Xorriso_graft_in(xorriso, NULL, NULL, eff_path, (off_t) 0, (off_t) 0, 1); + if(ret<=0) + return(-2); + if(!(flag&1)) { + sprintf(xorriso->info_text, "Created directory in ISO image: %s\n", + Text_shellsafe(eff_path,sfe,0)); + Xorriso_info(xorriso, 0); + } + return(1); +} + + +/* @param flag bit0= count results rather than storing them + bit1= this is a recursion + bit2= prepend wd (automatically done if wd[0]!=0) +*/ +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) +{ + int ret, failed_at; + IsoDirIter *iter= NULL; + IsoNode *node; + char *name; + char *adr= NULL; + + adr= malloc(SfileadrL); + if(adr==NULL) { + Xorriso_no_malloc_memory(xorriso, &adr, 0); + {ret= -1; goto ex;} + } + + if(!(flag&2)) + *dive_count= 0; + else + (*dive_count)++; + ret= Xorriso_check_for_root_pattern(xorriso, filec, filev, count_limit, + mem, (flag&1)|2); + if(ret!=2) + goto ex; + + ret= iso_dir_get_children(dir, &iter); + if(ret<0) { + Xorriso_cannot_create_iter(xorriso, ret, 0); + {ret= -1; goto ex;} + } + while(iso_dir_iter_next(iter, &node) == 1) { + name= (char *) iso_node_get_name(node); + ret= Xorriso_make_abs_adr(xorriso, wd, name, adr, flag&4); + if(ret<=0) + goto ex; + ret= Xorriso_regexec(xorriso, adr, &failed_at, 1); + if(ret) { /* no match */ + if(failed_at <= *dive_count) /* no hope for a match */ + continue; + + if(!LIBISO_ISDIR(node)) { + + /* >>> How to deal with softlinks ? */ + + continue; + } + /* dive deeper */ + ret= Xorriso_obtain_pattern_files_i( + xorriso, adr, (IsoDir *) node, + filec, filev, count_limit, mem, dive_count, flag|2); + if(ret<=0) + goto ex; + } else { + ret= Xorriso_register_matched_adr(xorriso, adr, count_limit, + filec, filev, mem, (flag&1)|2); + if(ret<=0) + goto ex; + } + } + ret= 1; +ex:; + if(adr!=NULL) + free(adr); + if(flag&2) + (*dive_count)--; + if(iter != NULL) + iso_dir_iter_free(iter); + return(ret); +} + + +/* @param flag bit0= a match count !=1 is a FAILURE event + bit1= with bit0 tolerate 0 matches if pattern is a constant +*/ +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 ret, count= 0, abs_adr= 0, i, was_count, was_filec; + int nonconst_mismatches= 0, dive_count= 0; + char sfe[5*SfileadrL]; + IsoImage *volume; + IsoDir *dir= NULL, *root_dir; + IsoNode *iso_node; + + *filec= 0; + *filev= NULL; + + xorriso->search_mode= 3; + xorriso->structured_search= 1; + + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(ret); + root_dir= iso_image_get_root(volume); + if(root_dir==NULL) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "While expanding pattern : Cannot obtain root node of ISO image"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + ret= -1; goto ex; + } + + for(i= 0; iwdi does not exist yet, but one may + not use it as base for relative address searches. + */ + ret= Xorriso_node_from_path(xorriso, volume, xorriso->wdi, &iso_node, 1); + dir= (IsoDir *) iso_node; + if(ret<=0) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "While expanding pattern %s : Working directory does not exist in ISO image", + Text_shellsafe(patterns[i], sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + if(!LIBISO_ISDIR((IsoNode *) dir)) { + sprintf(xorriso->info_text, + "Working directory path does not lead to a directory in ISO image"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + } + + /* count the matches */ + was_count= count; + ret= Xorriso_obtain_pattern_files_i(xorriso, "", dir, &count, NULL, 0, + mem, &dive_count, 1 | abs_adr); + if(ret<=0) + goto ex; + if(was_count==count && strcmp(patterns[i],"*")!=0 && (flag&3)!=1) { + count++; + Xorriso_eval_nonmatch(xorriso, patterns[i], &nonconst_mismatches, mem, 0); + } + } + + ret= Xorriso_check_matchcount(xorriso, count, nonconst_mismatches, + num_patterns, patterns, (flag&1)|2); + if(ret<=0) + goto ex; + count+= extra_filec; + mem+= extra_filec*sizeof(char *); + if(count<=0) + {ret= 0; goto ex;} + ret= Xorriso_alloc_pattern_mem(xorriso, *mem, count, filev, 0); + if(ret<=0) + goto ex; + /* now store addresses */ + for(i= 0; iinfo_text,"Permissions now: %-5.5o %s", + (unsigned int) (mode & 0xffff), Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + Xorriso_set_change_pending(xorriso, 0); + Xorriso_process_msg_queues(xorriso,0); + return(1); +} + + +int Xorriso_set_uid(struct XorrisO *xorriso, char *in_path, uid_t uid, + int flag) +{ + int ret; + IsoNode *node; + + ret= Xorriso_get_node_by_path(xorriso, in_path, NULL, &node, 0); + if(ret<=0) + return(ret); + iso_node_set_uid(node, uid); + iso_node_set_ctime(node, time(NULL)); + Xorriso_set_change_pending(xorriso, 0); + Xorriso_process_msg_queues(xorriso,0); + return(1); +} + + +int Xorriso_set_gid(struct XorrisO *xorriso, char *in_path, gid_t gid, + int flag) +{ + int ret; + IsoNode *node; + + ret= Xorriso_get_node_by_path(xorriso, in_path, NULL, &node, 0); + if(ret<=0) + return(ret); + iso_node_set_gid(node, gid); + iso_node_set_ctime(node, time(NULL)); + Xorriso_set_change_pending(xorriso, 0); + Xorriso_process_msg_queues(xorriso,0); + return(1); +} + + +/* @parm flag bit0= atime, bit1= ctime, bit2= mtime, bit8=no auto ctime */ +int Xorriso_set_time(struct XorrisO *xorriso, char *in_path, time_t t, + int flag) +{ + int ret; + IsoNode *node; + + ret= Xorriso_get_node_by_path(xorriso, in_path, NULL, &node, 0); + if(ret<=0) + return(ret); + if(flag&1) + iso_node_set_atime(node, t); + if(flag&2) + iso_node_set_ctime(node, t); + if(flag&4) + iso_node_set_mtime(node, t); + if(!(flag&(2|256))) + iso_node_set_ctime(node, time(NULL)); + Xorriso_set_change_pending(xorriso, 0); + Xorriso_process_msg_queues(xorriso,0); + return(1); +} + + +int Xorriso__start_end_lbas(IsoNode *node, + int *lba_count, int **start_lbas, int **end_lbas, + off_t *size, int flag) +{ + int section_count= 0, ret, i; + struct iso_file_section *sections= NULL; + + *lba_count= 0; + *start_lbas= *end_lbas= NULL; + *size= 0; + if(!LIBISO_ISREG(node)) + return(0); + *size= iso_file_get_size((IsoFile *) node); + ret= iso_file_get_old_image_sections((IsoFile *) node, §ion_count, + §ions, 0); + if(ret < 0) + {ret= -1; goto ex;} + if(ret != 1 || section_count <= 0) + {ret= 0; goto ex;} + *start_lbas= calloc(section_count, sizeof(int)); + *end_lbas= calloc(section_count, sizeof(int)); + if(*start_lbas == NULL || *end_lbas == NULL) + {ret= -1; goto ex;} + for(i= 0; i < section_count; i++) { + (*start_lbas)[i]= sections[i].block; + (*end_lbas)[i]= sections[i].block + sections[i].size / 2048 - 1; + if(sections[i].size % 2048) + (*end_lbas)[i]++; + } + *lba_count= section_count; + ret= 1; +ex:; + if(sections != NULL) + free((char *) sections); + if(ret <= 0) { + if((*start_lbas) != NULL) + free((char *) *start_lbas); + if((*end_lbas) != NULL) + free((char *) *end_lbas); + *start_lbas= *end_lbas= NULL; + *lba_count= 0; + } + return(ret); +} + + +int Xorriso__file_start_lba(IsoNode *node, + int *lba, int flag) +{ + int *start_lbas= NULL, *end_lbas= NULL, lba_count= 0, i, ret; + off_t size; + + *lba= -1; + ret= Xorriso__start_end_lbas(node, &lba_count, &start_lbas, &end_lbas, + &size, 0); + if(ret <= 0) + return(ret); + for(i= 0; i < lba_count; i++) { + if(*lba < 0 || start_lbas[i] < *lba) + *lba= start_lbas[i]; + } + if(start_lbas != NULL) + free((char *) start_lbas); + if(end_lbas != NULL) + free((char *) end_lbas); + if(*lba < 0) + return(0); + return(1); +} + + +/* @param damage_start Returns first damaged byte address + @param damage_end Returns first byte address after last damaged byte + @return <0 error, 0=undamaged , 1=damaged +*/ +int Xorriso_file_eval_damage(struct XorrisO *xorriso, IsoNode *node, + off_t *damage_start, off_t *damage_end, + int flag) +{ + int *start_lbas= NULL, *end_lbas= NULL, lba_count= 0, sect; + int i, sectors, sector_size, ret; + off_t sect_base= 0, size= 0, byte; + struct SectorbitmaP *map; + + *damage_start= *damage_end= -1; + map= xorriso->in_sector_map; + if(map == NULL) + return(0); + Sectorbitmap_get_layout(map, §ors, §or_size, 0); + sector_size/= 2048; + + ret= Xorriso__start_end_lbas(node, &lba_count, &start_lbas, &end_lbas, + &size, 0); + if(ret <= 0) { + Xorriso_process_msg_queues(xorriso, 0); + return(ret); + } + for(sect= 0; sect < lba_count; sect++) { + for(i= start_lbas[sect]; i <= end_lbas[sect]; i+= sector_size) { + if(Sectorbitmap_is_set(map, i / sector_size, 0) == 0) { + byte= ((off_t) 2048) * ((off_t) (i - start_lbas[sect])) + sect_base; + if(*damage_start < 0 || byte < *damage_start) + *damage_start= byte; + if(byte + (off_t) 2048 > *damage_end) + *damage_end= byte + (off_t) 2048; + } + } + sect_base+= ((off_t) 2048) * + ((off_t) (end_lbas[sect] - start_lbas[sect] + 1)); + } + if(*damage_end > size) + *damage_end= size; + if(start_lbas != NULL) + free((char *) start_lbas); + if(end_lbas != NULL) + free((char *) end_lbas); + if(*damage_start < 0) + return(0); + return(1); +} + + +int Xorriso_report_lba(struct XorrisO *xorriso, char *show_path, + IsoNode *node, int flag) +{ + int ret, *start_lbas= NULL, *end_lbas= NULL, lba_count, i; + off_t size; + char sfe[5*SfileadrL]; + + ret= Xorriso__start_end_lbas(node, &lba_count, &start_lbas, &end_lbas, + &size, 0); + if(ret < 0) { + Xorriso_process_msg_queues(xorriso, 0); + {ret= -1; goto ex;} + } + if(ret == 0) + {ret= 1; goto ex;} /* it is ok to ignore other types */ + for(i= 0; i < lba_count; i++) { + sprintf(xorriso->result_line, + "File data lba: %2d , %8d , %8d , %8.f , %s\n", + i, start_lbas[i], end_lbas[i] + 1 - start_lbas[i], (double) size, + Text_shellsafe(show_path, sfe, 0)); + Xorriso_result(xorriso, 0); + } + ret= 1; +ex:; + if(start_lbas != NULL) + free((char *) start_lbas); + if(end_lbas != NULL) + free((char *) end_lbas); + return(ret); +} + + +int Xorriso_report_damage(struct XorrisO *xorriso, char *show_path, + IsoNode *node, int flag) +{ + int ret; + off_t size= 0, damage_start, damage_end; + char sfe[5*SfileadrL]; + + ret= Xorriso_file_eval_damage(xorriso, node, &damage_start, &damage_end, 0); + if(ret < 0) + return(0); + + if(LIBISO_ISREG(node)) + size= iso_file_get_size((IsoFile *) node); + if(ret > 0) { + sprintf(xorriso->result_line, "File damaged : %8.f , %8.f , %8.f , %s\n", + (double) damage_start, (double) (damage_end - damage_start) , + (double) size, Text_shellsafe(show_path, sfe, 0)); + Xorriso_result(xorriso, 0); + } else { + sprintf(xorriso->result_line, "File seems ok: %8.f , %8.f , %8.f , %s\n", + -1.0, -1.0, (double) size, Text_shellsafe(show_path, sfe, 0)); + Xorriso_result(xorriso, 0); + } + return(1); +} + + +/* @return see Xorriso_update_interpreter() +*/ +int Xorriso_widen_hardlink(struct XorrisO *xorriso, void * boss_iter, + IsoNode *node, + char *abs_path, char *iso_prefix, char *disk_prefix, + int flag) +{ + int ret= 0, idx, low, high, i, do_widen= 0, compare_result= 0; + char disk_path[SfileadrL]; + + /* Lookup all di_array instances of node */ + if(LIBISO_ISDIR(node)) + return(1); + ret= Xorriso_search_di_range(xorriso, node, &idx, &low, &high, 2); + if(ret <= 0) + return(1); + /* Check and reset di_do_widen bits */ + for(i= low; i <= high; i++) { + if(node != xorriso->di_array[i]) /* might be NULL */ + continue; + if(xorriso->di_do_widen[i / 8] & (1 << (i % 8))) + do_widen= 1; + xorriso->di_do_widen[i / 8]&= ~(1 << (i % 8)); + } + if(idx < 0 || !do_widen) + return(1); + + ret= Xorriso_pfx_disk_path(xorriso, abs_path, iso_prefix, disk_prefix, + disk_path, 0); + if(ret <= 0) + return(ret); + + /* >>> compare_result bit17 = is_split */; + + ret= Xorriso_update_interpreter(xorriso, boss_iter, compare_result, disk_path, + abs_path, 1); + if(ret <= 0) + return(ret); + return(ret); +} + + +/* @param flag bit0= not a command parameter (directory iteration or recursion) + bit1= do not count deleted files with rm and rm_r + @return <=0 error, + 1=ok + 2=ok, node has been deleted, + 3=ok, do not dive into directory (e.g. because it is a split file) +*/ +int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job, + IsoDirIter *boss_iter, off_t boss_mem, + char *abs_path, char *show_path, + IsoNode *node, int depth, int flag) +{ + int ret= 0, type, action= 0, hflag, deleted= 0, no_dive= 0; + uid_t user= 0; + gid_t group= 0; + time_t date= 0; + mode_t mode_or= 0, mode_and= ~1; + char *target, *text_2, sfe[5*SfileadrL], *iso_prefix, md5[16]; + struct FindjoB *subjob; + struct stat dir_stbuf; + + action= Findjob_get_action_parms(job, &target, &text_2, &user, &group, + &mode_and, &mode_or, &type, &date, &subjob, 0); + if(action<0) + action= 0; + + hflag= 16*!(flag&2); + ret= 1; + if(action==1) { /* rm (including rmdir) */ + ret= Xorriso_fake_stbuf(xorriso, abs_path, &dir_stbuf, &node, 1); + if(ret>0) { + if(S_ISDIR(dir_stbuf.st_mode)) + hflag= 2; + ret= Xorriso_rmi(xorriso, boss_iter, boss_mem, abs_path, hflag); + deleted= 1; + } + } else if(action==2) { /* rm_r */ + ret= Xorriso_rmi(xorriso, boss_iter, boss_mem, abs_path, 1|hflag); + deleted= 1; + } else if(action==3) { + + /* >>> mv target */; + + } else if(action==4) { /* chown */ + ret= Xorriso_set_uid(xorriso, abs_path, user, 0); + } else if(action==5) { /* chgrp */ + ret= Xorriso_set_gid(xorriso, abs_path, group, 0); + } else if(action==6) { /* chmod */ + ret= Xorriso_set_st_mode(xorriso, abs_path, mode_and, mode_or, 0); + } else if(action==7) { /* alter_date */ + ret= Xorriso_set_time(xorriso, abs_path, date, type&7); + } else if(action==8) { /* lsdl */ + ret= Xorriso_ls_filev(xorriso, "", 1, &abs_path, (off_t) 0, 1|2|8); + } else if(action>=9 && action<=13) { /* actions which have own findjobs */ + Findjob_set_start_path(subjob, abs_path, 0); + ret= Xorriso_findi(xorriso, subjob, boss_iter, boss_mem, NULL, + abs_path, &dir_stbuf, depth, 1); + } else if(action==14 || action==17) { /* compare , update */ + Findjob_get_start_path(job, &iso_prefix, 0); + ret= Xorriso_find_compare(xorriso, (void *) boss_iter, abs_path, + iso_prefix, target, (action==17)|((flag&1)<<1)); + if(ret==2) + deleted= 1; + if(ret==3) + no_dive= 1; + if(ret>=0) + ret= 1; + } else if(action==16 || action==18) { /* not_in_iso , add_missing */ + ; + } else if(action == 21) { /* report_damage */ + ret= Xorriso_report_damage(xorriso, show_path, node, 0); + } else if(action == 22) { + ret= Xorriso_report_lba(xorriso, show_path, node, 0); + } else if(action == 23) { /* internal: memorize path of last matching node */ + ret= Findjob_set_found_path(job, show_path, 0); + } else if(action == 24) { + ret= Xorriso_getfacl(xorriso, (void *) node, show_path, NULL, 0); + } else if(action == 25) { + if(target == NULL || target[0] || text_2 == NULL || text_2[0]) + ret= Xorriso_setfacl(xorriso, (void *) node, show_path, target, text_2,0); + } else if(action == 26) { + ret= Xorriso_getfattr(xorriso, (void *) node, show_path, NULL, 0); + } else if(action == 27) { + ret= Xorriso_path_setfattr(xorriso, (void *) node, show_path, + target, strlen(text_2), text_2, 0); + } else if(action == 28) { /* set_filter */ + ret= Xorriso_set_filter(xorriso, (void *) node, show_path, target, 1 | 2); + } else if(action == 29) { /* show_stream */ + ret= Xorriso_show_stream(xorriso, (void *) node, show_path, 1 | 2); + } else if(action == 30) { /* internal: count */ + xorriso->node_counter++; + } else if(action == 31) { /* internal: register */ + if(xorriso->node_counter < xorriso->node_array_size) { + xorriso->node_array[xorriso->node_counter++]= (void *) node; + iso_node_ref(node); /* In case node gets deleted from tree during + the lifetime of xorriso->node_array */ + } + } else if(action == 32) { /* internal: widen_hardlinks disk_equiv */ + Findjob_get_start_path(job, &iso_prefix, 0); + ret= Xorriso_widen_hardlink(xorriso, (void *) boss_iter, node, abs_path, + iso_prefix, target, 0); + if(ret==2) + deleted= 1; + } else if(action == 33) { /* get_any_xattr */ + ret= Xorriso_getfattr(xorriso, (void *) node, show_path, NULL, 8); + } else if(action == 34) { /* get_md5 */ + ret= Xorriso_get_md5(xorriso, (void *) node, show_path, md5, 0); + if(ret >= 0) + ret= 1; + } else if(action == 35) { /* check_md5 */ + ret= Xorriso_check_md5(xorriso, (void *) node, show_path, 2); + if(ret == 0) + xorriso->find_check_md5_result|= 1; + else if(ret < 0) + xorriso->find_check_md5_result|= 2; + else if(ret == 1) + xorriso->find_check_md5_result|= 8; + else if(ret == 2) + xorriso->find_check_md5_result|= 4; + if(ret >= 0) + ret= 1; + } else if(action == 36) { /* make_md5 */ + ret = Xorriso_make_md5(xorriso, (void *) node, show_path, 0); + if(ret >= 0) + ret= 1; + } else { /* includes : 15 in_iso */ + sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0)); + Xorriso_result(xorriso, 0); + ret= 1; + } + if(ret<=0) + return(ret); + if(deleted) + return(2); + if(no_dive) + return(3); + return(1); +} + + +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) +/* +return: + <0 = error + 0 = does not match + 1 = does match + 2 = immediate decision : does not match + 3 = immediate decision : does match +*/ +{ + int value=0, ret, start_lba, end_lba; + int lba_count, *file_end_lbas= NULL, *file_start_lbas= NULL, i; + void *arg1, *arg2; + char ft, *decision, md5[16]; + regmatch_t name_match; + off_t damage_start, damage_end, size; + void *xinfo_dummy; + IsoNode *node; + IsoStream *stream; + + if(ftest == NULL) + return(1); + + node= (IsoNode *) node_pt; + arg1= ftest->arg1; + arg2= ftest->arg2; + + if(node == NULL) { + if(ftest->test_type > 2 && ftest->test_type != 4) { + value= 0; + goto ex; + } + } + + switch(ftest->test_type) { + case 0: /* -false */ + value= 0; + + break; case 1: /* -name *arg1 (regex in *arg2) */ + ret= regexec(arg2, name, 1, &name_match, 0); + value= !ret; + + break; case 2: /* -type *arg1 */ + value= 1; + ft= *((char *) arg1); + if(ft!=0) { + if(S_ISBLK(stbuf->st_mode)) { + if(ft!='b') + value= 0; + } else if(S_ISCHR(stbuf->st_mode)) { + if(ft!='c') + value= 0; + } else if(S_ISDIR(stbuf->st_mode)) { + if(ft=='m') { + if(node != NULL) + value= 0; + else if(boss_stbuf==NULL) + value= 0; + else if(boss_stbuf->st_dev == stbuf->st_dev) + value= 0; + } else if(ft!='d') + value= 0; + } else if(S_ISFIFO(stbuf->st_mode)) { + if(ft!='p') + value= 0; + } else if(S_ISREG(stbuf->st_mode)) { + if(ft!='f' && ft!='-') + value= 0; + } else if(((stbuf->st_mode)&S_IFMT)==S_IFLNK) { + if(ft!='l') + value= 0; + } else if(((stbuf->st_mode)&S_IFMT)==S_IFSOCK) { + if(ft!='s') + value= 0; + } else if((flag & 1) && ((stbuf->st_mode) & S_IFMT) == Xorriso_IFBOOT) { + if(ft!='e' || node == NULL) + value= 0; + } else { + if(ft!='X') + value= 0; + } + } + + break; case 3: /* -damaged */; + value= Xorriso_file_eval_damage(xorriso, node, &damage_start, &damage_end, + 0); + if(value > 0) + value= 1; + + break; case 4: /* -lba_range *arg1 *arg2 */ + if(node == NULL) { + value= !(start_lba >= 0); + goto ex; + } + value= 1; + start_lba= *((int *) ftest->arg1); + end_lba= *((int *) ftest->arg2); + ret= Xorriso__start_end_lbas(node, &lba_count, + &file_start_lbas, &file_end_lbas, &size, 0); + if(ret <= 0) { + if(ret < 0) + Xorriso_process_msg_queues(xorriso, 0); + if(start_lba >= 0) + value= 0; + } else { + for(i= 0; i < lba_count; i++) { + if(start_lba >= 0) { + if(file_end_lbas[i] < start_lba || file_start_lbas[i] > end_lba) + value= 0; + } else { + if(file_end_lbas[i] >= -start_lba && file_start_lbas[i] <= -end_lba) + value= 0; + } + } + } + + break; case 5: /* -has_acl */ + ret = Xorriso_getfacl(xorriso, (void *) node, "", NULL, 2); + if(ret <= 0) { + value= -1; + Xorriso_process_msg_queues(xorriso, 0); + goto ex; + } + value= (ret == 1); + + break; case 6: /* -has_xattr */ + case 14: /* -has_any_xattr */ + ret = Xorriso_getfattr(xorriso, (void *) node, "", NULL, + 64 | (8 * (ftest->test_type == 14))); + if(ret < 0) { + value= -1; + Xorriso_process_msg_queues(xorriso, 0); + goto ex; + } + value= (ret > 0); + + break; case 7: /* -has_aaip */ + ret= iso_node_get_xinfo(node, aaip_xinfo_func, &xinfo_dummy); + if(ret < 0) { + value= -1; + Xorriso_process_msg_queues(xorriso, 0); + goto ex; + } + value= (ret > 0); + + break; case 8: /* -has_filter */ + value= 0; + if(LIBISO_ISREG(node)) { + stream= iso_file_get_stream((IsoFile *) node); + if(iso_stream_get_input_stream(stream, 0) != NULL) + value= 1; + } + + break; case 9: /* -wanted_node arg1 (for internal use) */ + value= (((IsoNode *) arg1) == node); + + break; case 10: /* -pending_data */ + value= 1; + if(!LIBISO_ISREG(node)) { + value= 0; + } else { + ret= Xorriso__file_start_lba(node, &start_lba, 0); + if(ret > 0 && start_lba >= 0) + value= 0; + } + + break; case 11: /* -decision */ + value= 2; + decision= (char *) arg1; + if(strcmp(decision, "yes") == 0 || strcmp(decision, "true") == 0) + value= 3; + + break; case 12: /* -prune */ + value= 1; + ftest->boss->prune= 1; + + break; case 13: /* -wholename *arg1 (regex in *arg2) */ + ret= regexec(arg2, path, 1, &name_match, 0); + value= !ret; + + break; case 15: /* -has_md5 */ + ret= Xorriso_get_md5(xorriso, node, path, md5, 1); + value= (ret > 0); + + break; default: + + /* >>> complain about unknown test type */; + + value= -1; + + } + +ex:; + if(ftest->invert && value<=1 && value>=0) + value= !value; + if(file_start_lbas != NULL) + free((char *) file_start_lbas); + if(file_end_lbas != NULL) + free((char *) file_end_lbas); + return(value); +} + + +/* @return <0 = error , 0 = no match , 1 = match */ +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) +{ + int ret; + + job->prune= 0; + ret= Findjob_test_2(xorriso, job, node, name, path, boss_stbuf, stbuf, 1); + if(ret <= 0) + return(ret); + return(1); +} + + +/* @param flag bit0= recursion + bit1= do not count deleted files with rm and rm_r + @return <=0 error, 1= ok , 2= dir node and path has been deleted +*/ +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 ret, action= 0, hflag, deleted= 0, no_dive= 0; + IsoDirIter *iter= NULL; + IsoDir *dir_node= NULL; + IsoNode *node, *iso_node; + IsoImage *volume= NULL; + struct stat stbuf; + char *name; + off_t mem; + IsoNode **node_array= NULL; + int node_count, node_idx; + char *path= NULL, *abs_path= NULL; + + if(xorriso->request_to_abort) + {ret= 0; goto ex;} + + path= malloc(SfileadrL); + abs_path= malloc(SfileadrL); + if(path==NULL || abs_path==NULL) { + Xorriso_no_malloc_memory(xorriso, &path, 0); + {ret= -1; goto ex;} + } + + action= Findjob_get_action(job, 0); + if(action<0) + action= 0; + if(!(flag & 1)) { + if(action == 21) { + sprintf(xorriso->result_line, "Report layout: %8s , %8s , %8s , %s\n", + "at byte", "Range", "Filesize", "ISO image path"); + Xorriso_result(xorriso, 0); + } else if(action == 22) { + sprintf(xorriso->result_line, + "Report layout: %2s , %8s , %8s , %8s , %s\n", + "xt", "Startlba", "Blocks", "Filesize", "ISO image path"); + Xorriso_result(xorriso, 0); + } + } + + dir_node= (IsoDir *) dir_node_generic; + if(dir_node==NULL) { + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + {ret= -1; goto ex;} + ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, dir_path, path, 1|2|4); + if(ret<=0) + goto ex; + ret= Xorriso_node_from_path(xorriso, volume, path, &iso_node, 0); + dir_node= (IsoDir *) iso_node; + if(ret<=0) + {ret= 0; goto ex;} + ret= Xorriso_fake_stbuf(xorriso, "", dir_stbuf, &iso_node, 1); + if(ret<=0) + goto ex; + + name= strrchr(dir_path, '/'); + if(name==NULL) + name= dir_path; + else + name++; + + ret= Xorriso_findi_test(xorriso, job, iso_node, name, path, NULL, dir_stbuf, + depth, 0); + if(ret<0) + goto ex; + if(job->prune) + no_dive= 1; + if(ret>0) { + ret= Xorriso_findi_action(xorriso, job, + (IsoDirIter *) boss_iter, boss_mem, + path, dir_path, (IsoNode *) dir_node, depth, + flag&(1|2)); + if(ret<=0) + goto ex; + if(xorriso->request_to_abort) + {ret= 0; goto ex;} + if(ret==2) { + /* re-determine dir_node in case it has a new persona */ + ret= Xorriso_node_from_path(xorriso, volume, path, &iso_node, 1); + if(ret==0) { + deleted= 1; + {ret= 2; goto ex;} + } + if(ret<0) + {ret= 0; goto ex;} + dir_node= (IsoDir *) iso_node; + ret= Xorriso_fake_stbuf(xorriso, "", dir_stbuf, &iso_node, 1); + if(ret<=0) + goto ex; + } + if(ret==3) + no_dive= 1; + } + } + if(no_dive || !LIBISO_ISDIR((IsoNode *) dir_node)) + {ret= 1; goto ex;} + if(Xorriso_is_split(xorriso, dir_path, (IsoNode *) dir_node, 1)>0) + {ret= 1; goto ex;} + + mem= boss_mem; + hflag= 1; + if(action==1 || action==2 || action==3 || action==17 || action == 28 || + action == 32) + hflag|= 2; /* need freedom to manipulate image */ + if(action==14 || action==17 || action == 28 || action == 35 || action == 36) + hflag|= 4; /* need LBA sorted iteration for good data reading performance */ + ret= Xorriso_findi_iter(xorriso, dir_node, &mem, + &iter, &node_array, &node_count, &node_idx, + &node, hflag); + if(ret<=0) + goto ex; + while(1) { + ret= Xorriso_findi_iter(xorriso, dir_node, &mem, &iter, + &node_array, &node_count, &node_idx, &node, 0); + if(ret<0) + goto ex; + if(ret==0) + break; + name= (char *) iso_node_get_name(node); + ret= Xorriso_make_abs_adr(xorriso, dir_path, name, path, 4); + if(ret<=0) + goto ex; + ret= Xorriso_fake_stbuf(xorriso, "", &stbuf, &node, 1); + if(ret<0) + goto ex; + if(ret==0) + continue; + +/* ??? This seems to be redundant with the single test above + ??? Should i dive in unconditionally and leave out test and action here ? + ??? Then do above test unconditionally ? + --- Seems that the current configuration represents the special + handling of the find start path with mount points. Dangerous to change. +*/ + + ret= Xorriso_findi_test(xorriso, job, node, name, path, dir_stbuf, &stbuf, + depth, 0); + if(ret<0) + goto ex; + if(job->prune) + no_dive= 1; + if(ret>0) { + ret= Xorriso_make_abs_adr(xorriso, xorriso->wdi, path, abs_path, 1|2|4); + if(ret<=0) + goto ex; + ret= Xorriso_findi_action(xorriso, job, iter, mem, + abs_path, path, node, depth, 1|(flag&2)); + if(xorriso->request_to_abort) + {ret= 0; goto ex;} + if(ret==2) { /* node has been deleted */ + /* re-determine node in case it has a new persona */ + if(volume==NULL) { + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + {ret= -1; goto ex;} + } + ret= Xorriso_node_from_path(xorriso, volume, abs_path, &node, 1); + if(ret==0) + continue; + if(ret<0) + {ret= 0; goto ex;} + ret= Xorriso_fake_stbuf(xorriso, "", &stbuf, &node, 1); + if(ret<0) + goto ex; + if(ret==0) + continue; + } + no_dive= (ret==3); + if(ret<=0) { + if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0) + goto ex; + } + } + + if(S_ISDIR(stbuf.st_mode) && !no_dive) { + ret= Xorriso_findi(xorriso, job, (void *) iter, mem, + (void *) node, path, &stbuf, depth+1, flag|1); + if(ret<0) + goto ex; + } + } + + ret= 1; +ex:; + if(path!=NULL) + free(path); + if(abs_path!=NULL) + free(abs_path); + Xorriso_process_msg_queues(xorriso,0); + + Xorriso_findi_iter(xorriso, dir_node, &mem, &iter, &node_array, &node_count, + &node_idx, &node, (1<<31)); + if(ret<=0) + return(ret); + if(deleted) + return(2); + return(1); +} + + +int Xorriso_node_is_valid(struct XorrisO *xorriso, IsoNode *in_node, int flag) +{ + IsoNode *node, *parent; + + for(node= in_node; 1; node= parent) { + parent= (IsoNode *) iso_node_get_parent(node); + if(parent == node) + break; + if(parent == NULL) + return(0); /* Node is not in the tree (any more) */ + } + return(1); +} + + +int Xorriso_path_from_node(struct XorrisO *xorriso, IsoNode *in_node, + char path[SfileadrL], int flag) +{ + int ret, i, comp_count= 0; + IsoNode *node, *parent, **components= NULL; + char *wpt, *npt; + + for(node= in_node; 1; node= parent) { + parent= (IsoNode *) iso_node_get_parent(node); + if(parent == node) + break; + if(parent == NULL) + return(0); /* Node is not in the tree (any more) */ + comp_count++; + } + if(comp_count == 0) { + strcpy(path, "/"); + return(1); + } + components= calloc(comp_count, sizeof(IsoNode *)); + if(components == NULL) { + Xorriso_no_malloc_memory(xorriso, NULL, 0); + ret= -1; goto ex; + } + i= comp_count; + for(node= in_node; 1; node= parent) { + parent= (IsoNode *) iso_node_get_parent(node); + if(parent == node) + break; + components[--i]= node; + } + + wpt= path; + for(i= 0; i < comp_count; i++) { + npt= (char *) iso_node_get_name(components[i]); + if((wpt - path) + strlen(npt) + 1 >= SfileadrL) { + + /* >>> path is getting much too long */; + + ret= -1; goto ex; + } + *(wpt++)= '/'; + strcpy(wpt, npt); + wpt+= strlen(npt); + *wpt= 0; + } + ret= 1; +ex:; + if(components != NULL) + free(components); + return(ret); +} + + +/* <<< The lookup from node pointer will be done by Xorriso_path_from_node() + (Currently it runs a full tree traversal) + Parameter node and flag bit0 will vanish then +*/ +/* @param flag bit0= use lba rather than node pointer +*/ +int Xorriso_path_from_lba(struct XorrisO *xorriso, IsoNode *node, int lba, + char path[SfileadrL], int flag) +{ + int ret; + struct FindjoB *job= NULL; + struct stat dir_stbuf; + char *found_path; + + path[0]= 0; + if((flag & 1) && lba <= 0) + return(0); + + ret= Findjob_new(&job, "/", 0); + if(ret <= 0) { + Xorriso_no_findjob(xorriso, "path_from_node", 0); + return(ret); + } + if(flag & 1) + Findjob_set_lba_range(job, lba, 1, 0); + else + Findjob_set_wanted_node(job, (void *) node, 0); + Findjob_set_action_found_path(job, 0); + ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0, + NULL, "/", &dir_stbuf, 0, 0); + if(ret > 0) { + ret= 1; + Findjob_get_found_path(job, &found_path, 0); + if(found_path == NULL) + ret= 0; + else if(Sfile_str(path, found_path, 0) <= 0) + ret= -1; + } + Findjob_destroy(&job, 0); + return(ret); +} + + +/* @param flag bit0= do not dive into trees + bit1= do not perform job->action on resulting node array + bit2= do not free node_array after all actions are done +*/ +int Xorriso_findi_sorted(struct XorrisO *xorriso, struct FindjoB *job, + off_t boss_mem, int filec, char **filev, int flag) +{ + int i, ret; + struct FindjoB array_job, *proxy_job= NULL, *hindmost= NULL, *hmboss= NULL; + struct stat dir_stbuf; + IsoNode *node; + char abs_path[SfileadrL]; + off_t mem_needed= 0; + + array_job.start_path= NULL; + + if(job->action>=9 && job->action<=13) { /* actions which have own findjobs */ + /* array_job replaces the hindmost job in the chain */ + for(hindmost= job; hindmost->subjob != NULL; hindmost= hindmost->subjob) + hmboss= hindmost; + if(hmboss == NULL) + {ret= -1; goto ex;} + memcpy(&array_job, hindmost, sizeof(struct FindjoB)); + hmboss->subjob= &array_job; + proxy_job= job; + } else { + memcpy(&array_job, job, sizeof(struct FindjoB)); + proxy_job= &array_job; + hindmost= job; + } + array_job.start_path= NULL; /* is owned by the original, not by array_job */ + + /* Count matching nodes */ + Xorriso_destroy_node_array(xorriso, 0); + array_job.action= 30; /* internal: count */ + for(i= 0; i < filec; i++) { + if(flag & 1) { + xorriso->node_counter++; + continue; + } + ret= Findjob_set_start_path(proxy_job, filev[i], 0); + if(ret <= 0) + goto ex; + ret= Xorriso_findi(xorriso, proxy_job, NULL, boss_mem, NULL, + filev[i], &dir_stbuf, 0, 0); + if(ret <= 0) + goto ex; + } + if(xorriso->node_counter <= 0) + {ret= 1; goto ex;} + + mem_needed= boss_mem + xorriso->node_counter * sizeof(IsoNode *); + if(!(flag &1)) { + ret= Xorriso_check_temp_mem_limit(xorriso, mem_needed, 0); + if(ret <= 0) { + /* Memory curbed : Perform unsorted find jobs */ + if(hmboss != NULL) + hmboss->subjob= hindmost; + for(i= 0; i < filec; i++) { + ret= Findjob_set_start_path(job, filev[i], 0); + if(ret <= 0) + goto ex; + ret= Xorriso_findi(xorriso, job, NULL, boss_mem, NULL, + filev[i], &dir_stbuf, 0, 0); + if(ret <= 0) + if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0) + goto ex; + } + {ret= 1; goto ex;} + } + } + + /* Copy matching nodes into allocated array */ + ret= Xorriso_new_node_array(xorriso, xorriso->temp_mem_limit, 0, 0); + if(ret <= 0) + goto ex; + array_job.action= 31; /* internal: register */ + xorriso->node_counter= 0; + for(i= 0; i < filec; i++) { + if(flag & 1) { + ret= Xorriso_get_node_by_path(xorriso, filev[i], NULL, &node, 0); + if(ret <= 0) + goto ex; + if(xorriso->node_counter < xorriso->node_array_size) { + xorriso->node_array[xorriso->node_counter++]= (void *) node; + iso_node_ref(node); + } + continue; + } + ret= Findjob_set_start_path(proxy_job, filev[i], 0); + if(ret <= 0) + goto ex; + ret= Xorriso_findi(xorriso, proxy_job, NULL, mem_needed, NULL, + filev[i], &dir_stbuf, 0, 0); + if(ret <= 0) + goto ex; + } + + Xorriso_sort_node_array(xorriso, 0); + if(flag & 2) + {ret= 1; goto ex;} + + /* Perform job->action on xorriso->node_array */ + for(i= 0; i < xorriso->node_counter; i++) { + node= xorriso->node_array[i]; + ret= Xorriso_path_from_node(xorriso, node, abs_path, 0); + if(ret < 0) + goto ex; + if(ret == 0) + continue; /* node is deleted from tree meanwhile */ + + ret= Xorriso_findi_action(xorriso, hindmost, NULL, (off_t) 0, + abs_path, abs_path, node, 0, 1); + if(ret <= 0 || xorriso->request_to_abort) + if(Xorriso_eval_problem_status(xorriso, ret, 1|2)<0) + goto ex; + } + + ret= 1; +ex:; + if(!(flag & (2 | 4))) + Xorriso_destroy_node_array(xorriso, 0); + if(hmboss != NULL) + hmboss->subjob= hindmost; + if(array_job.start_path != NULL) + free(array_job.start_path); + return(ret); +} + + +/* @param flag bit0= do not mark image as changed */ +int Xorriso_set_volid(struct XorrisO *xorriso, char *volid, int flag) +{ + int ret; + IsoImage *volume; + + if(xorriso->in_volset_handle == NULL) + return(2); + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(ret); + iso_image_set_volume_id(volume, volid); + if(!(flag&1)) + Xorriso_set_change_pending(xorriso, 0); + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text,"Volume ID: '%s'",iso_image_get_volume_id(volume)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + return(1); +} + + +int Xorriso_get_volid(struct XorrisO *xorriso, char volid[33], int flag) +{ + int ret; + IsoImage *volume; + + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(ret); + strncpy(volid, iso_image_get_volume_id(volume), 32); + volid[32]= 0; + return(1); +} + + +/* @param flag bit0=prepare for a burn run */ +int Xorriso_set_abort_severity(struct XorrisO *xorriso, int flag) +{ + int ret, abort_on_number; + char *sev_text; + static int note_number= -1, failure_number= -1; + + if(note_number==-1) + Xorriso__text_to_sev("NOTE", ¬e_number, 0); + if(failure_number==-1) + Xorriso__text_to_sev("FAILURE", &failure_number, 0); + sev_text= xorriso->abort_on_text; + ret= Xorriso__text_to_sev(xorriso->abort_on_text, &abort_on_number, 0); + if(ret<=0) + return(ret); + if(abort_on_numberfailure_number) + sev_text= "FAILURE"; + ret= iso_set_abort_severity(sev_text); + return(ret>=0); +} + + +int Xorriso_report_lib_versions(struct XorrisO *xorriso, int flag) +{ + int major, minor, micro; + int req_major, req_minor, req_micro; + + iso_lib_version(&major, &minor, µ); + isoburn_libisofs_req(&req_major, &req_minor, &req_micro); + sprintf(xorriso->result_line, + "libisofs in use : %d.%d.%d (min. %d.%d.%d)\n", + major, minor, micro, req_major, req_minor, req_micro); + Xorriso_result(xorriso, 0); + burn_version(&major, &minor, µ); + isoburn_libburn_req(&req_major, &req_minor, &req_micro); + sprintf(xorriso->result_line, + "libburn in use : %d.%d.%d (min. %d.%d.%d)\n", + major, minor, micro, req_major, req_minor, req_micro); + Xorriso_result(xorriso, 0); + isoburn_version(&major, &minor, µ); + sprintf(xorriso->result_line, + "libisoburn in use : %d.%d.%d (min. %d.%d.%d)\n", + major, minor, micro, + isoburn_header_version_major, isoburn_header_version_minor, + isoburn_header_version_micro); + Xorriso_result(xorriso, 0); + return(1); +} + + +/* @param flag bit0= -inq + bit1= -checkdrive +*/ +int Xorriso_atip(struct XorrisO *xorriso, int flag) +{ + int ret, profile_number= 0; + char *respt, profile_name[80]; + double x_speed_max, x_speed_min= -1.0; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + enum burn_disc_status s; + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to print drive and media info", 2); + if(ret<=0) + return(0); + respt= xorriso->result_line; + sprintf(respt, "Device type : "); + ret= burn_drive_get_drive_role(drive); + if(ret==0) + sprintf(respt+strlen(respt), "%s\n", "Emulated (null-drive)"); + else if(ret==2) + sprintf(respt+strlen(respt), "%s\n", + "Emulated (stdio-drive, 2k random read-write)"); + else if(ret==3) + sprintf(respt+strlen(respt), "%s\n", + "Emulated (stdio-drive, sequential write-only)"); + else if(ret!=1) + sprintf(respt+strlen(respt), "%s\n","Emulated (stdio-drive)"); + else + sprintf(respt+strlen(respt), "%s\n","Removable CD-ROM"); + sprintf(respt+strlen(respt), "Vendor_info : '%s'\n",dinfo->vendor); + sprintf(respt+strlen(respt), "Identifikation : '%s'\n",dinfo->product); + sprintf(respt+strlen(respt), "Revision : '%s'\n",dinfo->revision); + Xorriso_result(xorriso,1); + if(flag&1) + return(1); + sprintf(respt, "Driver flags : BURNFREE\n"); + sprintf(respt+strlen(respt), "Supported modes: SAO TAO\n"); + Xorriso_result(xorriso,1); + if(flag&2) + return(1); + + s= burn_disc_get_status(drive); + ret= burn_disc_get_profile(drive,&profile_number,profile_name); + if(ret<=0) { + profile_number= 0; + strcpy(profile_name, "-unidentified-"); + } + if(s != BURN_DISC_UNSUITABLE) { + ret= burn_disc_read_atip(drive); + if(ret>0) { + ret= burn_drive_get_min_write_speed(drive); + x_speed_min= ((double) ret)/176.4; + } + } + if(s==BURN_DISC_EMPTY) { + sprintf(respt, "Current: none\n"); + Xorriso_result(xorriso,1); + return(1); + } else + sprintf(respt, "Current: %s\n",profile_name); + Xorriso_result(xorriso,1); + Xorriso_list_profiles(xorriso, 1 | 2); + if(strstr(profile_name,"DVD")==profile_name) { + sprintf(respt, "book type: %s (emulated booktype)\n", profile_name); + Xorriso_result(xorriso,1); + if(profile_number == 0x13) { + sprintf(respt, "xorriso: message for sdvdbackup: \"(growisofs mode Restricted Overwrite)\"\n"); + Xorriso_result(xorriso,1); + } + } else { + sprintf(respt, "ATIP info from disk:\n"); + Xorriso_result(xorriso,1); + if(burn_disc_erasable(drive)) + sprintf(respt, " Is erasable\n"); + else + sprintf(respt, " Is not erasable\n"); + Xorriso_result(xorriso,1); + { int start_lba,end_lba,min,sec,fr; + ret= burn_drive_get_start_end_lba(drive,&start_lba,&end_lba,0); + if(ret>0) { + burn_lba_to_msf(start_lba,&min,&sec,&fr); + sprintf(respt, " ATIP start of lead in: %d (%-2.2d:%-2.2d/%-2.2d)\n", + start_lba,min,sec,fr); + Xorriso_result(xorriso,1); + burn_lba_to_msf(end_lba,&min,&sec,&fr); + sprintf(respt, " ATIP start of lead out: %d (%-2.2d:%-2.2d/%-2.2d)\n", + end_lba,min,sec,fr); + Xorriso_result(xorriso,1); + } + } + ret= burn_drive_get_write_speed(drive); + x_speed_max= ((double) ret)/176.4; + if(x_speed_min<0) + x_speed_min= x_speed_max; + sprintf(respt, + " 1T speed low: %.f 1T speed high: %.f\n",x_speed_min,x_speed_max); + Xorriso_result(xorriso,1); + } + return(1); +} + + +int Xorriso_update_in_sector_map(struct XorrisO *xorriso, + struct SpotlisT *spotlist, int read_chunk, + struct CheckmediajoB *job, int flag) +{ + int sectors, sector_size, sector_blocks, ret; + struct SectorbitmaP *map; + + Sectorbitmap_destroy(&(xorriso->in_sector_map), 0); + if(job->use_dev == 1) + return(1); + map= job->sector_map; + sectors= Spotlist_block_count(spotlist, 0); + if(sectors <= 0) + return(0); + sector_size= Spotlist_sector_size(spotlist, read_chunk, 0); + sector_blocks= sector_size / 2048; + if(sector_blocks > 1) + sectors= sectors / sector_blocks + !!(sectors % sector_blocks); + ret= Sectorbitmap_new(&(xorriso->in_sector_map), sectors, sector_size, 0); + if(ret <= 0) + return(ret); + if(map != NULL) + Sectorbitmap_copy(map, xorriso->in_sector_map, 0); + ret= Xorriso_spotlist_to_sectormap(xorriso, spotlist, read_chunk, + &(xorriso->in_sector_map), 1); + return(ret); +} + + +/* + @param flag bit0= obtain iso_lba from indev + bit1= head_buffer already contains a valid head + bit2= issue message about success + bit3= check whether source blocks are banned by in_sector_map +*/ +int Xorriso_update_iso_lba0(struct XorrisO *xorriso, int iso_lba, int isosize, + char *head_buffer, struct CheckmediajoB *job, + int flag) +{ + int ret, full_size, i; + char *headpt; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + off_t seek_ret; + + if(flag & 1) { + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to learn current session lba", 1); + if(ret<=0) + return(0); + ret= isoburn_disc_get_msc1(drive, &iso_lba); + if(ret<=0) + return(0); + drive= NULL; /* indev will not be used furtherly */ + } + if(job == NULL) { + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to update at lba 0 to 31", 2); + if(ret<=0) + return(0); + } + if(iso_lba < 32) + return(2); + if(!(flag & 2)) { + /* head_buffer was not filled yet. Read it from output media. */ + if(job != NULL && job->data_to_fd >= 0) { + if((flag & 8) && job->sector_map != NULL) { + ret= Sectorbitmap_bytes_are_set(job->sector_map, + ((off_t) iso_lba) * (off_t) 2048, + ((off_t) (iso_lba + 32)) * ((off_t) 2048) - (off_t) 1, 0); + if(ret <= 0) { + sprintf(xorriso->info_text, + "ISO image head at lba %d is marked as invalid blocks in file copy", + iso_lba); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", + 0); + return(0); + } + } + seek_ret= lseek(job->data_to_fd, ((off_t) 2048) * (off_t) iso_lba, + SEEK_SET); + if(seek_ret == -1) + ret= 0; + else + ret= read(job->data_to_fd, head_buffer, 64 * 1024); + if(ret < 64 * 1024) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "Cannot read ISO image head from file copy"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0); + return(0); + } + } else { + ret= isoburn_read_iso_head(drive, iso_lba, &isosize, head_buffer, 2); + if(ret<=0) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "Cannot read freshly written ISO image head"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + } + } + /* patch ISO header */ + full_size= iso_lba + isosize; + headpt= head_buffer + 32*1024; + for(i=0;i<4;i++) + headpt[87-i]= headpt[80+i]= (full_size >> (8*i)) & 0xff; + + if(job != NULL) { + seek_ret= lseek(job->data_to_fd, (off_t) 0, SEEK_SET); + if(seek_ret == -1) + ret= 0; + else + ret= write(job->data_to_fd, head_buffer, 64 * 1024); + if(ret < 64 * 1024) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "Cannot write ISO image head to file copy"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0); + return(0); + } + } else { + ret= burn_random_access_write(drive, (off_t) 0, head_buffer, + (off_t) (64*1024), 1); + if(ret<=0) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "Cannot write new ISO image head to LBA 0"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + } + if(flag & 4) { + sprintf(xorriso->info_text, + "Overwrote LBA 0 to 31 by 64 KiB from LBA %d", iso_lba); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + return(1); +} + + +/* @param write_start_address is valid if >=0 + @param tsize is valid if >0 + @param flag bit0= grow_overwriteable_iso + bit1= do_isosize +*/ +int Xorriso_burn_track(struct XorrisO *xorriso, off_t write_start_address, + char *track_source, off_t tsize, int flag) +{ + int ret, fd, unpredicted_size, profile_number, is_cd= 0, dummy, nwa= -1; + int isosize= -1, do_isosize, is_bd= 0; + + struct burn_drive_info *dinfo; + struct burn_drive *drive; + struct burn_write_opts *burn_options; + struct burn_disc *disc= NULL; + struct burn_session *session; + struct burn_track *track; + struct stat stbuf; + off_t fixed_size= 0; + struct burn_source *data_src, *fifo_src; + enum burn_disc_status disc_state; + char reasons[BURN_REASONS_LEN], sfe[5*SfileadrL], profile_name[80]; + char head_buffer[64*1024]; + + ret= Xorriso_auto_format(xorriso, 0); + if(ret <=0 ) + return(0); + + do_isosize= !!(flag&2); + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to burn track", 2); + if(ret<=0) + return(0); + ret= Xorriso_make_write_options(xorriso, drive, &burn_options, 0); + if(ret<=0) + goto ex; + + disc= burn_disc_create(); + session= burn_session_create(); + ret= burn_disc_add_session(disc,session,BURN_POS_END); + if(ret==0) { + sprintf(xorriso->info_text, "Cannot add session object to disc object."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + goto ex; + } + track= burn_track_create(); + if(track_source[0] == '-' && track_source[1] == 0) { + fd= 0; + } else { + fd= open(track_source, O_RDONLY); + if(fd>=0) + if(fstat(fd,&stbuf)!=-1) + if((stbuf.st_mode&S_IFMT)==S_IFREG) + fixed_size= stbuf.st_size; + } + if(fixed_size==0) + unpredicted_size= 1; + + data_src= NULL; + if(fd>=0) + data_src= burn_fd_source_new(fd, -1, fixed_size); + if(data_src==NULL) { + sprintf(xorriso->info_text, "Could not open data source %s", + Text_shellsafe(track_source,sfe,0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + ret= 0; goto ex; + } + if(do_isosize && xorriso->fs < 64) + xorriso->fs= 64; + fifo_src= burn_fifo_source_new(data_src, 2048, xorriso->fs, 0); + if(fifo_src == NULL) { + sprintf(xorriso->info_text, "Could not create fifo object of 4 MB"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + ret= 0; goto ex; + } + xorriso->pacifier_fifo= fifo_src; + if(burn_track_set_source(track, fifo_src)!=BURN_SOURCE_OK) { + sprintf(xorriso->info_text, + "Cannot attach source object to track object"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + ret= 0; goto ex; + } + burn_session_add_track(session, track, BURN_POS_END); + burn_source_free(data_src); + + if(flag&1) + /* consider overwriteables with ISO as appendable */ + disc_state= isoburn_disc_get_status(drive); + else + /* handle overwriteables as always blank */ + disc_state= burn_disc_get_status(drive); + + if(disc_state == BURN_DISC_BLANK || disc_state == BURN_DISC_APPENDABLE) { + /* ok */; + } else { + if(disc_state == BURN_DISC_FULL) { + sprintf(xorriso->info_text, + "Closed media with data detected. Need blank or appendable media."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + if(burn_disc_erasable(drive)) { + sprintf(xorriso->info_text, "Try -blank as_needed\n"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0); + } + } else if(disc_state == BURN_DISC_EMPTY) { + sprintf(xorriso->info_text, "No media detected in drive"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + } else { + sprintf(xorriso->info_text, + "Cannot recognize state of drive and media"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + } + ret= 0; goto ex; + } + if(isoburn_needs_emulation(drive)) + burn_write_opts_set_multi(burn_options, 0); + + if(tsize > 0) { + fixed_size= tsize; + burn_track_set_size(track, fixed_size); + } + if(do_isosize) { + ret= burn_fifo_peek_data(xorriso->pacifier_fifo, head_buffer, 64*1024, 0); + if(ret<=0) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "Cannot obtain first 64 kB from input stream."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + /* read isosize from head_buffer, not from media*/ + ret= isoburn_read_iso_head(drive, 0, &isosize, head_buffer, (1<<13)); + if(ret<=0) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "Option -isosize given but data stream seems not to be ISO 9660"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + sprintf(xorriso->info_text, "Size of ISO 9660 image: %ds", isosize); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + fixed_size= ((off_t) (isosize)) * (off_t) 2048; + burn_track_set_size(track, fixed_size); + } + + ret= Xorriso_get_profile(xorriso, &profile_number, profile_name, 2); + is_cd= (ret==2); + is_bd= (ret == 3); + + if(isoburn_needs_emulation(drive)) { + if(flag&1) { + ret= isoburn_disc_track_lba_nwa(drive, burn_options, 0, &dummy, &nwa); + if(ret<=0) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "Cannot obtain next writeable address of emulated multi-session media\n"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + if(nwa==32) + nwa= 0; /* No automatic toc emulation. Formatter might not be aware. */ + burn_write_opts_set_start_byte(burn_options,((off_t) nwa) * (off_t) 2048); + } else { + nwa= 0; + burn_write_opts_set_start_byte(burn_options, (off_t) 0); + } + } + + if(write_start_address>=0) { + nwa= write_start_address / (off_t) 2048; + if(((off_t) nwa) * (off_t) 2048 < write_start_address ) + nwa++; + burn_write_opts_set_start_byte(burn_options, ((off_t) nwa) * (off_t) 2048); + } + + if(burn_write_opts_auto_write_type(burn_options, disc, reasons, 0) == + BURN_WRITE_NONE) { + sprintf(xorriso->info_text, + "Failed to find a suitable write mode with this media.\n"); + sprintf(xorriso->info_text+strlen(xorriso->info_text), + "Reasons given:\n%s", reasons); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + + ret= Xorriso_sanitize_image_size(xorriso, drive, disc, burn_options, 2); + if(ret<=0) + goto ex; + + xorriso->run_state= 1; /* Indicate that burning has started */ + burn_disc_write(burn_options, disc); + + ret= Xorriso_pacifier_loop(xorriso, drive, 2 | (is_cd << 4) | (is_bd << 5)); + if(ret<=0) + goto ex; + if(!burn_drive_wrote_well(drive)) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "libburn indicates failure with writing."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + + if(flag & 1) { + ret= Xorriso_update_iso_lba0(xorriso, nwa, isosize, head_buffer, NULL, + flag & 2); + if(ret <= 0) + goto ex; + } + sprintf(xorriso->info_text, "Writing to %s completed sucessfully.\n\n", + Text_shellsafe(xorriso->outdev,sfe,0)); + Xorriso_info(xorriso, 0); + ret= 1; +ex:; + Xorriso_process_msg_queues(xorriso,0); + if(disc!=NULL) + burn_disc_free(disc); + if(xorriso->pacifier_fifo!=NULL) + burn_source_free(xorriso->pacifier_fifo); + xorriso->pacifier_fifo= NULL; + xorriso->run_state= 0; /* Indicate that burning has ended */ + return(ret); +} + + +/* @param flag bit1= outdev rather than indev + @return <0 error, 0 = no profile to see , 1= ok , 2= ok, is CD profile + 3= ok, is BD profile +*/ +int Xorriso_get_profile(struct XorrisO *xorriso, int *profile_number, + char profile_name[80], int flag) +{ + int ret; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + + *profile_number= 0; + profile_name[0]= 0; + if(((flag&2) && xorriso->out_drive_handle==NULL) || + ((!(flag&2)) && xorriso->in_drive_handle==NULL)) + return(0); + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to determine media type", flag&2); + if(ret<=0) + return(0); + ret=burn_disc_get_profile(drive, profile_number, profile_name); + if(ret<=0) + return(ret); + if(*profile_number==0x08 || *profile_number==0x09 || *profile_number==0x0a) + return(2); + if(*profile_number == 0x40 || *profile_number == 0x41 || + *profile_number == 0x42 || *profile_number == 0x43) + return(3); + return(0); +} + + + +int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname, + void *node_pt, void **stream, int flag) +{ + int ret; + char eff_path[SfileadrL]; + IsoNode *node= NULL; + IsoFile *filenode= NULL; + IsoStream *iso_stream= NULL, *input_stream; + + *stream= NULL; + if(flag&1) { + node= (IsoNode *) node_pt; + } else { + ret= Xorriso_get_node_by_path(xorriso, pathname, eff_path, &node, 0); + if(ret<=0) + return(ret); + } + if(!LIBISO_ISREG(node)) { + sprintf(xorriso->info_text, + "Given path does not lead to a regular data file in the image"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + + filenode= (IsoFile *) node; + iso_stream= iso_file_get_stream(filenode); + if(iso_stream==NULL) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "Could not obtain source stream of file in the image for reading"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if(flag & 2) { + /* Dig out the most original stream */ + while(1) { + input_stream= iso_stream_get_input_stream(iso_stream, 0); + if(input_stream == NULL) + break; + iso_stream= input_stream; + } + } + if(!iso_stream_is_repeatable(iso_stream)) { + sprintf(xorriso->info_text, + "The data production of the file in the image is one-time only"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + ret= iso_stream_open(iso_stream); + if(ret<0) { + sprintf(xorriso->info_text, + "Could not open data file in the image for reading"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + Xorriso_process_msg_queues(xorriso,0); + *stream= iso_stream; + +#ifdef NIX + /* <<< */ + { + unsigned int fs_id; + dev_t dev_id; + ino_t ino; + + iso_stream_get_id(iso_stream, &fs_id, &dev_id, &ino); + fprintf(stderr, "xorriso_debug: iso_ino= %ld\n", (long int) ino); + } +#endif + + return(1); +} + + +int Xorriso_iso_file_read(struct XorrisO *xorriso, void *stream, char *buf, + int count, int flag) +{ + int ret, rcnt= 0; + IsoStream *stream_pt; + + stream_pt= (IsoStream *) stream; + + while(rcntcovered) + incomplete= 1; + else if(offset covered) + covered= offset+bytes; + } + if(total_bytes>covered) + incomplete= 1; + memcpy(total_stbuf, &first_stbuf, sizeof(struct stat)); + total_stbuf->st_size= total_bytes; + ret= !(overlapping || ((flag&2)&&incomplete)); +ex:; + if(iter!=NULL) + iso_dir_iter_free(iter); + return(ret); +} + + +/* @param flag bit0= node is valid, do not resolve path + bit1= insist in complete collection of part files +*/ +int Xorriso_is_split(struct XorrisO *xorriso, char *path, void *node, + int flag) +{ + struct SplitparT *split_parts= NULL; + int split_count= 0, ret; + struct stat stbuf; + + ret= Xorriso_identify_split(xorriso, path, node, &split_parts, + &split_count, &stbuf, flag & 3); + if(split_parts!=NULL) + Splitparts_destroy(&split_parts, split_count, 0); + return(ret>0); +} + + +/* @param flag bit0= grow_overwriteable_iso + bit1= obtain info from outdev +*/ +int Xorriso_msinfo(struct XorrisO *xorriso, int *msc1, int *msc2, int flag) +{ + int ret, dummy; + struct burn_drive *drive; + struct burn_drive_info *dinfo; + enum burn_disc_status disc_state; + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to obtain msinfo", flag&2); + if(ret<=0) + return(ret); + + if(flag&1) + disc_state= isoburn_disc_get_status(drive); + else + disc_state= burn_disc_get_status(drive); + if(disc_state != BURN_DISC_APPENDABLE) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "%s media is not appendable. Cannot obtain -msinfo.", + (flag&2) ? "Output" : "Input"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + ret= isoburn_disc_get_msc1(drive, msc1); + if(ret<=0) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, "Cannot obtain address of most recent session"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + ret= isoburn_disc_track_lba_nwa(drive, NULL, 0, &dummy, msc2); + if(ret<0) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, "Cannot obtain next writeable address on media"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + return(1); +} + +/* @param flag bit0= this is a follow-up session (i.e. on CD: TAO) + bit1= no pacifier messages + bit2= compute stream MD5 and look out for checksum tag + @return <=0 error, 1= done, 2= aborted due to limit +*/ +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) +{ + int i, j, ret, total_count= 0, sectors= -1, sector_size= -1, skip_reading; + int prev_quality= -1, quality= -1, retry= 0, profile_no, is_cd= 0; + int start_sec, end_sec, first_value, fret; + char profile_name[80]; + int start_lba= 0; + struct burn_drive *drive; + struct burn_drive_info *dinfo; + char data[64*1024], sfe[5*SfileadrL]; + off_t data_count, to_read, read_count= 0, write_amount; + double pre_read_time, post_read_time, time_diff, total_time_diff= 0; + double last_abort_file_time= 0; + struct stat stbuf; + void *ctx= NULL, *cloned_ctx= NULL; + char md5[16], tag_md5[16]; + uint32_t pos, range_start, range_size, next_tag= 0, lba, md5_spot_lba= 0; + int md5_spot_value= Xorriso_read_quality_untesteD, chain_broken= 0; + int tag_type= 0, valid, was_sb_tag= 0, in_track_gap= 0; + char *comparison= "", *sev_text= "DEBUG", *tag_type_name= ""; + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to check media readability", + 2 * !!job->use_dev); + if(ret<=0) + goto ex; + ret= burn_disc_get_profile(drive, &profile_no, profile_name); + if(ret > 0) + if(profile_no >= 0x08 && profile_no <= 0x0a) + is_cd= 1; + + if(job->sector_map != NULL) { + Sectorbitmap_get_layout(job->sector_map, §ors, §or_size, 0); + sector_size/= 2048; + } + + if(job->retry > 0) + retry= 1; + else if(job->retry == 0 && is_cd) + retry= 1; + + if(flag & 4) { + ret= iso_md5_start(&ctx); + if(ret < 0) { + Xorriso_no_malloc_memory(xorriso, NULL, 0); + ret= -1; goto ex; + } + } + + start_lba= from_lba; + to_read= read_chunk; + post_read_time= Sfile_microtime(0); + for(i= 0; i < block_count; i+= to_read) { + skip_reading= 0; + + if(job->abort_file_path[0]) { + if(post_read_time - last_abort_file_time >= 0.1) { + if(stat(job->abort_file_path, &stbuf) != -1) { + if(stbuf.st_mtime >= xorriso->start_time) { + sprintf(xorriso->info_text, + "-check_media: Found fresh abort_file=%s", + job->abort_file_path); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + goto abort_check; + } + } + last_abort_file_time= post_read_time; + } + } + if(job->item_limit > 0 && + Spotlist_count(spotlist, 0) + 2 >= job->item_limit) { + sprintf(xorriso->info_text, "-check_media: Reached item_limit=%d", + job->item_limit); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + goto abort_check; + } + pre_read_time= Sfile_microtime(0); + if(job->time_limit > 0 + && job->start_time + job->time_limit < pre_read_time) { + sprintf(xorriso->info_text, "-check_media: Reached time_limit=%d", + job->time_limit); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); +abort_check:; + if(prev_quality >= 0) { + ret= Spotlist_add_item(spotlist, start_lba, i + from_lba - start_lba, + prev_quality, 0); + if(ret <= 0) + goto ex; + } + ret= Spotlist_add_item(spotlist, i + from_lba, block_count - i, + Xorriso_read_quality_untesteD, 0); + if(ret > 0) + ret= 2; + goto ex; + } + + to_read= read_chunk; + if(i + to_read > block_count) + to_read= block_count - i; + if(is_cd && i + to_read + 2 >= block_count) { + /* Read last 2 blocks of CD track separately, because with TAO tracks + they are always unreadable but with SAO tracks they contain data. + */ + if(to_read > 2) + to_read-= 2; + else if(to_read > 1) { + if(flag & 1) { + quality= Xorriso_read_quality_tao_enD; + skip_reading= 1; + } else + to_read--; + } + } + + if(sector_size == read_chunk && from_lba % read_chunk == 0 + && !skip_reading) { + if(Sectorbitmap_is_set(job->sector_map, (i + from_lba) / sector_size, 0)){ + quality= Xorriso_read_quality_valiD; + skip_reading= 1; + } + } else if(sector_size > 0 && !skip_reading) { + start_sec= (i + from_lba) / sector_size; + end_sec= (i + to_read + from_lba) / sector_size; + first_value= Sectorbitmap_is_set(job->sector_map, start_sec, 0); + for(j= start_sec; j < end_sec; j++) + if(Sectorbitmap_is_set(job->sector_map, j, 0) != first_value) + break; + to_read= j * sector_size - i - from_lba; + skip_reading= !!first_value; + if(skip_reading) + quality= Xorriso_read_quality_valiD; + } + + if(skip_reading) { + pre_read_time= post_read_time= Sfile_microtime(0); + } else { + data_count= 0; + pre_read_time= Sfile_microtime(0); + ret= burn_read_data(drive, ((off_t) (i + from_lba)) * (off_t) 2048, data, + to_read * (off_t) 2048, &data_count, 4 * !retry); + post_read_time= Sfile_microtime(0); + time_diff= post_read_time - pre_read_time; + total_time_diff+= time_diff; + total_count++; + if(ret <= 0) { + Xorriso_process_msg_queues(xorriso,0); + if(data_count / 2048 < to_read) { + if(data_count > 0 && retry) { + if(prev_quality >= 0) { + ret= Spotlist_add_item(spotlist, start_lba, + i + from_lba - start_lba, prev_quality, 0); + if(ret <= 0) + goto ex; + } + ret= Spotlist_add_item(spotlist, i + from_lba, data_count / 2048, + Xorriso_read_quality_partiaL, 0); + if(ret <= 0) + goto ex; + start_lba= i + from_lba + data_count / 2048; + prev_quality= Xorriso_read_quality_unreadablE; + } + quality= Xorriso_read_quality_unreadablE; + if(retry) + to_read= data_count / 2048 + 1; + } else + quality= Xorriso_read_quality_partiaL; + fret= Xorriso_eval_problem_status(xorriso, ret, 1|2); + if(fret<0) + goto ex; + } else { + quality= Xorriso_read_quality_gooD; + + /* >>> find better threshold than 1.0 */ + + if(time_diff > 1.0 && i > 0) + quality= Xorriso_read_quality_sloW; + } + + /* MD5 checksumming */ + if(ctx != NULL) { + for(j= 0; j < to_read; j++) { + lba= i + j + from_lba; + if(lba < md5_start) + continue; + ret= 0; + if(lba > md5_start + 16 && + (next_tag == 0 || chain_broken || lba == next_tag)) { + ret= iso_util_decode_md5_tag(data + j * 2048, &tag_type, + &pos, &range_start, &range_size, + &next_tag, tag_md5, !!chain_broken); + } + valid= (ret == 1 || ret == ISO_MD5_AREA_CORRUPTED) && pos == lba; + if(valid && tag_type == 2 && (lba < md5_start + 32 || in_track_gap)) { + tag_type_name= "superblock"; + was_sb_tag= 1; + if(in_track_gap && range_start != md5_start && range_start < lba && + lba - range_start <= j) { + /* Looking for next session : start computing in hindsight. + Session start and superblock tag are supposed to be in the + same 64 kB chunk. + */ + iso_md5_end(&ctx, md5); + ret= iso_md5_start(&ctx); + if(ret < 0) { + Xorriso_no_malloc_memory(xorriso, NULL, 0); + ret= -1; goto ex; + } + iso_md5_compute(&ctx, data + (j - (lba - range_start)) * 2048, + (lba - range_start) * 2048); + md5_start= range_start; + in_track_gap= 0; + } + } else if(valid && tag_type == 4 && lba < 32) { + tag_type_name= "relocated 64kB superblock"; + }else if(valid && tag_type == 3 && was_sb_tag) { + tag_type_name= "tree"; + }else if(valid && tag_type == 1) { + + /* >>> ??? allow this without superblock and tree tag ? */ + + tag_type_name= "session"; + } else { + tag_type_name= ""; + } + if (tag_type_name[0]) { + if(range_start != md5_start) { + sprintf(xorriso->info_text, + "Found MD5 %s tag which covers different data range", + tag_type_name); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE",0); + sprintf(xorriso->info_text, + " Expected: %u Found: %u", + (unsigned int) md5_start, range_start); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE",0); + chain_broken= 1; + valid= 0; + } else { + ret= iso_md5_clone(ctx, &cloned_ctx); + if(ret <= 0) { + Xorriso_no_malloc_memory(xorriso, NULL, 0); + ret= -1; goto ex; + } + iso_md5_end(&cloned_ctx, md5); + + if(ret == ISO_MD5_AREA_CORRUPTED) { + comparison= "CORRUPTED"; + sev_text= "WARNING"; + md5_spot_value= Xorriso_read_quality_md5_mismatcH; + chain_broken= 1; + } else if(! iso_md5_match(tag_md5, md5)) { + comparison= "NON-MATCHING"; + sev_text= "WARNING"; + md5_spot_value= Xorriso_read_quality_md5_mismatcH; + chain_broken= 1; + } else { + comparison= "matching"; + sev_text= "UPDATE"; + md5_spot_value= Xorriso_read_quality_md5_matcH; + } + md5_spot_lba= lba; + sprintf(xorriso->info_text, + "Found %s MD5 %s tag: start=%d size=%d", + comparison, tag_type_name, md5_start, lba - md5_start); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, + sev_text, 0); + } + if(valid && (tag_type == 1 || + (tag_type == 4 && pos == lba && lba < 32))) { + if(md5_spot_value != Xorriso_read_quality_untesteD) { + ret= Spotlist_add_item(spotlist, md5_start, + md5_spot_lba - md5_start, md5_spot_value, 0); + if(ret <= 0) + goto ex; + } + md5_spot_value= Xorriso_read_quality_untesteD; + md5_start = lba + 1; + if (md5_start % 32) + md5_start= md5_start + (32 - (md5_start % 32)); + next_tag= 0; + + iso_md5_end(&ctx, md5); + ret= iso_md5_start(&ctx); + if(ret < 0) { + Xorriso_no_malloc_memory(xorriso, NULL, 0); + ret= -1; goto ex; + } + if(tag_type == 1) + in_track_gap= 1; + continue; + } + } + iso_md5_compute(ctx, data + j * 2048, 2048); + } + } + + write_amount= data_count; + if(data_count > 0) { + read_count+= data_count; + if(job->data_to_limit >= 0 && read_count > job->data_to_limit) + write_amount-= (read_count - job->data_to_limit); + } + if(write_amount > 0) { + if(job->data_to_fd >= 0) { + ret= lseek(job->data_to_fd, + ((off_t) (i + from_lba)) * (off_t) 2048 + job->data_to_offset, + SEEK_SET); + if(ret == -1) { +failed_to_write:; + sprintf(xorriso->info_text, "Cannot write %d bytes to lba %d of %s", + (int) data_count, i + from_lba, + Text_shellsafe(job->data_to_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, + "FAILURE", 0); + {ret= 0; goto ex;} + } + ret= write(job->data_to_fd, data, write_amount); + if(ret == -1) + goto failed_to_write; + } + } + } + if(quality != prev_quality) { + if(prev_quality >= 0) { + ret= Spotlist_add_item(spotlist, start_lba, i + from_lba - start_lba, + prev_quality, 0); + if(ret <= 0) + goto ex; + } + start_lba= i + from_lba; + prev_quality= quality; + } + if(!(flag & 2)) { + xorriso->pacifier_count+= to_read; + if(post_read_time - xorriso->last_update_time >= + xorriso->pacifier_interval) + Xorriso_pacifier_callback(xorriso, "sectors examined", + xorriso->pacifier_count, xorriso->pacifier_total, "", 0); + } + } + if(prev_quality >= 0) { + ret= Spotlist_add_item(spotlist, start_lba, + block_count + from_lba - start_lba, prev_quality, 0); + if(ret <= 0) + goto ex; + } + + /* <<< for calibration of quality */ + if(total_count > 0) { + sprintf(xorriso->info_text, "Xorriso_check_interval: %.1f s / %d = %f", + total_time_diff, total_count, total_time_diff / total_count); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + } + + + /* MD5 checksumming : register result */ + + /* >>> ??? allow chain_broken to be a match ? */ + + if(next_tag > 0) { + sprintf(xorriso->info_text, "Missing announced MD5 tag: start=%d pos=%d", + md5_start, next_tag); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + md5_spot_value= Xorriso_read_quality_md5_mismatcH; + md5_spot_lba= next_tag; + } + if(md5_spot_value != Xorriso_read_quality_untesteD) { + ret= Spotlist_add_item(spotlist, md5_start, md5_spot_lba - md5_start, + md5_spot_value, 0); + if(ret <= 0) + goto ex; + } + + ret= 1; +ex: + if(ctx != NULL) + iso_md5_end(&ctx, md5); + return(ret); +} + + +int Xorriso_check_media(struct XorrisO *xorriso, struct SpotlisT **spotlist, + struct CheckmediajoB *job, int flag) +{ + int media_blocks= 0, read_chunk= 16, ret, mode, start_lba= 0; + int blocks, os_errno, i, j, last_track_end= -1, track_blocks, track_lba; + int num_sessions, num_tracks, declare_untested= 0, md5_start; + char *toc_info= NULL; + struct burn_drive *drive; + struct burn_drive_info *dinfo; + struct isoburn_toc_disc *isoburn_disc= NULL; + struct isoburn_toc_session **isoburn_sessions; + struct isoburn_toc_track **iso_burn_tracks; + struct burn_toc_entry isoburn_entry; + struct stat stbuf; + struct burn_multi_caps *caps= NULL; + + *spotlist= NULL; + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to check media readability", + 2 * !!job->use_dev); + if(ret<=0) + goto ex; + + /* >>> determine media type dependent blocking factor: + 32 kB for CD (with 2kB retry) and DVD, 64 kB for BD + eventually adjust read_chunk + */; + + ret= Spotlist_new(spotlist, 0); + if(ret <= 0) + {ret= -1; goto ex;} + + if(job->sector_map_path[0]) { + Sectorbitmap_destroy(&(job->sector_map), 0); + if(stat(job->sector_map_path, &stbuf) != -1) { + ret= Sectorbitmap_from_file(&(job->sector_map), job->sector_map_path, + xorriso->info_text, &os_errno, 0); + if(ret <= 0) { + if(xorriso->info_text[0]) + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, os_errno, + "FAILURE", 0); + goto ex; + } + } + Xorriso_toc_to_string(xorriso, &toc_info, 4 * !job->map_with_volid); + } + ret= Xorriso_open_job_data_to(xorriso, job, 0); + if(ret <= 0) + goto ex; + Xorriso_pacifier_reset(xorriso, 0); + job->start_time= time(NULL); + mode= job->mode; + if(job->min_lba > 0) { + start_lba= job->min_lba; + ret= Spotlist_add_item(*spotlist, 0, job->min_lba, + Xorriso_read_quality_untesteD, 0); + if(ret <= 0) + goto ex; + } + if(job->max_lba >= 0) { + blocks= job->max_lba + 1 - start_lba; + xorriso->pacifier_total= blocks; + ret= Xorriso_check_interval(xorriso, *spotlist, job, start_lba, blocks, + read_chunk, 0, 0); + if(ret <= 0) + goto ex; + + } else if(mode == 0) { /* track by track */ + isoburn_disc= isoburn_toc_drive_get_disc(drive); + if(isoburn_disc == NULL) + goto no_content_visible; + isoburn_sessions= + isoburn_toc_disc_get_sessions(isoburn_disc, &num_sessions); + for(i= 0; i < num_sessions; i++) { + iso_burn_tracks= isoburn_toc_session_get_tracks(isoburn_sessions[i], + &num_tracks); + for(j= 0; j < num_tracks; j++) { + isoburn_toc_track_get_entry(iso_burn_tracks[j], &isoburn_entry); + if(!(isoburn_entry.extensions_valid & 1)) /* should not happen */ + continue; + track_lba= isoburn_entry.start_lba; + track_blocks= isoburn_entry.track_blocks; + md5_start= track_lba; + if(i == 0 && j == 0) { + if(track_lba == 32) { + ret= burn_disc_get_multi_caps(drive, BURN_WRITE_NONE, &caps, 0); + if(ret > 0) { + if(caps->start_adr) { + /* block 0 to 31 are the overall mount entry of overwriteable */ + track_lba= 0; + track_blocks+= 32; + } + } + } + } + if(last_track_end >= 0 && last_track_end < track_lba && + last_track_end >= start_lba) { + ret= Spotlist_add_item(*spotlist, last_track_end, + track_lba - last_track_end, + Xorriso_read_quality_off_tracK, 0); + if(ret <= 0) + goto ex; + xorriso->pacifier_count+= track_lba - last_track_end; + } + last_track_end= track_lba + track_blocks; + + if(track_lba < start_lba) { + track_blocks-= start_lba - track_lba; + track_lba= start_lba; + } + if(track_blocks <= 0) + continue; + if(declare_untested) { + ret= Spotlist_add_item(*spotlist, track_lba, track_blocks, + Xorriso_read_quality_untesteD, 0); + if(ret <= 0) + goto ex; + } else { + ret= Xorriso_check_interval(xorriso, *spotlist, job, track_lba, + track_blocks, read_chunk, md5_start, + (i > 0) | (4 * (xorriso->do_md5 & 1))); + if(ret <= 0) + goto ex; + if(ret == 2) + declare_untested= 1; + } + } + } + + } else if(mode == 1) { /* isoburn disc capacity */ + isoburn_disc= isoburn_toc_drive_get_disc(drive); + if(isoburn_disc == NULL) { +no_content_visible:; + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, "No content detected on media"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + {ret= 0; goto ex;} + } + blocks= media_blocks= isoburn_toc_disc_get_sectors(isoburn_disc); + if(start_lba >= 0) + blocks-= start_lba; + if(media_blocks <= 0) + goto no_content_visible; + xorriso->pacifier_total= blocks; + ret= Xorriso_check_interval(xorriso, *spotlist, job, start_lba, blocks, + read_chunk, 0, 0); + if(ret <= 0) + goto ex; + } else if(mode == 2) { + + /* >>> single sweep over libburn media capacity */; + + } + + Xorriso_pacifier_callback(xorriso, "sectors examined", + xorriso->pacifier_count, xorriso->pacifier_total, "", 1); + ret= 1; +ex:; + + if(job->data_to_fd != -1) + close(job->data_to_fd); + job->data_to_fd= -1; + + if(ret > 0) + ret= Xorriso_update_in_sector_map(xorriso, *spotlist, read_chunk, job, 0); + + if(ret > 0) { + ret= Xorriso_spotlist_to_sectormap(xorriso, *spotlist, read_chunk, + &(job->sector_map), 0); + if(ret > 0 && job->sector_map_path[0]) { + ret= Sectorbitmap_to_file(job->sector_map, job->sector_map_path, toc_info, + xorriso->info_text, &os_errno, 0); + if(ret <= 0) { + if(xorriso->info_text[0]) + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, os_errno, + "FAILURE", 0); + } + } + } + if(toc_info != NULL) + free(toc_info); + if(ret <= 0) + Spotlist_destroy(spotlist, 0); + if(caps!=NULL) + burn_disc_free_multi_caps(&caps); + return(ret); +} + + +/* @param flag bit1= for Xorriso_check_interval(): no pacifier messages +*/ +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) +{ + int ret, i, lba_count= 0, *start_lbas= NULL, *end_lbas= NULL, read_chunk= 16; + int lba, count, blocks, quality, spot, bad_extract= 0; + off_t size= 0, file_base_bytes= 0, file_processed_bytes= 0, img_adr; + off_t new_file_base_bytes, upto_file_bytes, start_byte= 0; + char sfe[5*SfileadrL]; + struct SpotlisT *spotlist= NULL; + struct CheckmediajoB *job= NULL; + + upto_file_bytes= img_offset + bytes; + + /* >>> make Xorriso_check_interval() ready for copying in byte granularity */ + if(img_offset % (off_t) 2048) { + sprintf(xorriso->info_text, + "Image address offset is not a multiple of 2048"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + + ret= Xorriso__start_end_lbas(node, &lba_count, &start_lbas, &end_lbas, &size, + 0); + if(ret <= 0) { + Xorriso_process_msg_queues(xorriso,0); + sprintf(xorriso->info_text, + "File object %s is currently not a data file from the loaded image", + Text_shellsafe(img_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + goto ex; + } + if(img_offset + bytes < size && bytes > 0) + size= img_offset + bytes; + + ret= Checkmediajob_new(&job, 0); + if(ret <= 0) + goto ex; + if(xorriso->check_media_default != NULL) + Checkmediajob_copy(xorriso->check_media_default, job, 0); + job->min_lba= -1; + job->max_lba= -1; + job->sector_map_path[0]= 0; + + ret= Spotlist_new(&spotlist, 0); + if(ret <= 0) + {ret= -1; goto ex;} + + if(Sfile_str(job->data_to_path, disk_path, 0) <= 0) + {ret= -1; goto ex;} + Xorriso_open_job_data_to(xorriso, job, 0); + if(ret <= 0) + goto ex; + + for(i= 0; i < lba_count && file_base_bytes < upto_file_bytes; i++) { + lba= start_lbas[i]; + count= end_lbas[i] + 1 - start_lbas[i]; + new_file_base_bytes= file_base_bytes + ((off_t) count) * (off_t) 2048; + + /* skip intervals before img_offset */ + if(new_file_base_bytes <= img_offset) { + file_base_bytes= new_file_base_bytes; + continue; + } + /* Eventually adjust first interval start */ + img_adr= ((off_t) lba) * (off_t) 2048; + if(file_base_bytes < img_offset) { + img_adr+= img_offset - file_base_bytes; + lba= img_adr / (off_t) 2048; + count= end_lbas[i] + 1 - lba; + file_base_bytes= img_offset; + } + + /* Eventually omit surplus blocks */ + if(new_file_base_bytes > upto_file_bytes) + count-= (new_file_base_bytes - upto_file_bytes) / (off_t) 2048; + /* Adjust job */ + job->data_to_offset= file_processed_bytes - img_adr + disk_offset; + job->data_to_limit= size - file_base_bytes; + + file_processed_bytes+= ((off_t) count) * (off_t) 2048; + ret= Xorriso_check_interval(xorriso, spotlist, job, lba, count, read_chunk, + 0, (flag & 2)); + if(ret <= 0) + goto ex; + if (ret == 2) { + sprintf(xorriso->info_text, "Attempt aborted to extract data from %s", + Text_shellsafe(img_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + file_base_bytes= new_file_base_bytes; + } + + /* Use spotlist to evaluate damage */ + file_base_bytes= 0; + count= Spotlist_count(spotlist, 0); + for(spot= 0; spot < count; spot++) { + ret= Spotlist_get_item(spotlist, spot, &lba, &blocks, &quality, 0); + if(ret <= 0) + continue; + if(quality < Xorriso_read_quality_valiD) { + for(i= 0; i < lba_count; i++) { + if(start_lbas[i] <= lba && end_lbas[i] >= lba) { + start_byte= (lba - start_lbas[i]) * (off_t) 2048 + file_base_bytes; + break; + } + file_base_bytes+= ((off_t) (end_lbas[i] + 1 - start_lbas[i])) + * (off_t) 2048; + } + if(i < lba_count) { + sprintf(xorriso->info_text, "Bad extract : %14.f , %14.f , %s\n", + (double) start_byte, ((double) blocks) * 2048.0, + Text_shellsafe(disk_path, sfe, 0)); + Xorriso_info(xorriso, 0); + bad_extract= 1; + } + } + } + + ret= !bad_extract; +ex:; + if(start_lbas != NULL) + free((char *) start_lbas); + if(end_lbas != NULL) + free((char *) end_lbas); + Spotlist_destroy(&spotlist, 0); + Checkmediajob_destroy(&job, 0); + return(ret); +} + + +int Xorriso_extract_cut(struct XorrisO *xorriso, + char *img_path, char *disk_path, + off_t img_offset, off_t bytes, int flag) +{ + int ret, stbuf_ret, read_raw; + double mem_lut= 0.0; + char eff_img_path[SfileadrL], eff_disk_path[SfileadrL], sfe[SfileadrL*5]; + IsoImage *volume; + IsoNode *node; + + ret= Xorriso_get_volume(xorriso, &volume, 0); + if(ret<=0) + return(ret); + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, + img_path, eff_img_path, 0); + if(ret<=0) + return(ret); + ret= Xorriso_node_from_path(xorriso, volume, eff_img_path, &node, 0); + if(ret<=0) + return(ret); + ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, + disk_path, eff_disk_path, 2 | 4); + if(ret<=0) + return(ret); + Xorriso_pacifier_reset(xorriso, 0); + mem_lut= xorriso->last_update_time; + + ret= Xorriso_handle_collision(xorriso, node, img_path, eff_disk_path, + disk_path, &stbuf_ret, 0); + if(ret<=0 || ret==3) + return(0); + + /* If it is a non-filtered stream from the ISO image + and img_offset is a multiple of 2048 + then use Xorriso_read_file_data() for random access offset. + */ + if(!LIBISO_ISREG(node)) { + Xorriso_msgs_submit(xorriso, 0, eff_disk_path, 0, "ERRFILE", 0); + sprintf(xorriso->info_text, "-extract_cut: ISO file %s is not a data file", + Text_shellsafe(eff_img_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + read_raw= 0; + if((img_offset % 2048) == 0) { + ret= Xorriso_is_plain_image_file(xorriso, node, 0); + if(ret > 0) + read_raw= 1; + } + if (read_raw) { + ret= Xorriso_read_file_data(xorriso, node, eff_img_path, eff_disk_path, + img_offset, (off_t) 0, bytes, 0); + if(ret<=0) + return(ret); + } else { + ret= Xorriso_tree_restore_node(xorriso, node, eff_img_path, img_offset, + eff_disk_path, (off_t) 0, bytes, 2 | 8); + if(ret<=0) + return(ret); + } + + ret= Xorriso_restore_properties(xorriso, eff_disk_path, node, 0); + if(ret<=0) + return(ret); + + if(mem_lut != xorriso->last_update_time) + Xorriso_pacifier_callback(xorriso, "sectors examined", + xorriso->pacifier_count, 0, "", 1); + return(1); +} + + +int Xorriso_get_local_charset(struct XorrisO *xorriso, char **name, int flag) +{ + (*name)= iso_get_local_charset(0); + return(1); +} + + +int Xorriso_set_local_charset(struct XorrisO *xorriso, char *name, int flag) +{ + int ret; + char *nl_charset, sfe[5 * SfileadrL]; + iconv_t iconv_ret= (iconv_t) -1; + + nl_charset= nl_langinfo(CODESET); + if(name == NULL) + name= nl_charset; + + if(name != NULL) { + iconv_ret= iconv_open(nl_charset, name); + if(iconv_ret == (iconv_t) -1) + goto cannot; + else + iconv_close(iconv_ret); + } + ret= iso_set_local_charset(name, 0); + if(ret <= 0) { +cannot:; + sprintf(xorriso->info_text, + "-local_charset: Cannot assume as local character set: %s", + Text_shellsafe(name, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(0); + } + sprintf(xorriso->info_text, "Local character set is now assumed as: %s", + Text_shellsafe(name, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + return(1); +} + + +int Xorriso_relax_compliance(struct XorrisO *xorriso, char *mode, + int flag) +{ + char *npt, *cpt; + int l, was; + + was= xorriso->relax_compliance; + npt= cpt= mode; + for(; npt!=NULL; cpt= npt+1) { + npt= strchr(cpt,':'); + if(npt==NULL) + l= strlen(cpt); + else + l= npt-cpt; + if(l == 0) + continue; + if((l == 6 && strncmp(cpt, "strict", l) == 0) || + (l == 5 && strncmp(cpt, "clear", l) == 0)) { + xorriso->relax_compliance= 0; + } else if(l == 7 && strncmp(cpt, "default", l) == 0) { + xorriso->relax_compliance= Xorriso_relax_compliance_defaulT; + + } else if((l == 12 && strncmp(cpt, "omit_version", l) == 0) || + (l == 15 && strncmp(cpt, "omit_version_on", l) == 0) ) { + xorriso->relax_compliance|= isoburn_igopt_omit_version_numbers; + } else if((l == 16 && strncmp(cpt, "omit_version_off", l) == 0)) { + xorriso->relax_compliance&= ~isoburn_igopt_omit_version_numbers; + + } else if((l == 10 && strncmp(cpt, "deep_paths", l) == 0) || + (l == 13 && strncmp(cpt, "deep_paths_on", l) == 0)) { + xorriso->relax_compliance|= isoburn_igopt_allow_deep_paths; + } else if(l == 14 && strncmp(cpt, "deep_paths_off", l) == 0) { + xorriso->relax_compliance&= ~isoburn_igopt_allow_deep_paths; + + } else if((l == 10 && strncmp(cpt, "long_paths", l) == 0) || + (l == 13 && strncmp(cpt, "long_paths_on", l) == 0) ) { + xorriso->relax_compliance|= isoburn_igopt_allow_longer_paths; + } else if(l == 14 && strncmp(cpt, "long_paths_off", l) == 0) { + xorriso->relax_compliance&= ~isoburn_igopt_allow_longer_paths; + + } else if((l == 10 && strncmp(cpt, "long_names", l) == 0) || + (l == 13 && strncmp(cpt, "long_names_on", l) == 0)) { + xorriso->relax_compliance|= isoburn_igopt_max_37_char_filenames; + } else if(l == 14 && strncmp(cpt, "long_names_off", l) == 0) { + xorriso->relax_compliance&= ~isoburn_igopt_max_37_char_filenames; + + } else if((l == 13 && strncmp(cpt, "no_force_dots", l) == 0) || + (l == 16 && strncmp(cpt, "no_force_dots_on", l) == 0)) { + xorriso->relax_compliance|= isoburn_igopt_no_force_dots; + } else if(l == 17 && strncmp(cpt, "no_force_dots_off", l) == 0) { + xorriso->relax_compliance&= ~isoburn_igopt_no_force_dots; + + } else if((l == 9 && strncmp(cpt, "lowercase", l) == 0) || + (l == 12 && strncmp(cpt, "lowercase_on", l) == 0)) { + xorriso->relax_compliance|= isoburn_igopt_allow_lowercase; + } else if(l == 13 && strncmp(cpt, "lowercase_off", l) == 0) { + xorriso->relax_compliance&= ~isoburn_igopt_allow_lowercase; + + } else if((l == 10 && strncmp(cpt, "full_ascii", l) == 0) || + (l == 13 && strncmp(cpt, "full_ascii_on", l) == 0)) { + xorriso->relax_compliance|= isoburn_igopt_allow_full_ascii; + } else if(l == 14 && strncmp(cpt, "full_ascii_off", l) == 0) { + xorriso->relax_compliance&= ~isoburn_igopt_allow_full_ascii; + + } else if((l == 17 && strncmp(cpt, "joliet_long_paths", l) == 0) || + (l == 20 && strncmp(cpt, "joliet_long_paths_on", l) == 0)) { + xorriso->relax_compliance|= isoburn_igopt_joliet_longer_paths; + } else if(l == 21 && strncmp(cpt, "joliet_long_paths_off", l) == 0) { + xorriso->relax_compliance&= ~isoburn_igopt_joliet_longer_paths; + + } else if((l == 10 && strncmp(cpt, "always_gmt", l) == 0) || + (l == 13 && strncmp(cpt, "always_gmt_on", l) == 0)) { + xorriso->relax_compliance|= isoburn_igopt_always_gmt; + } else if(l == 14 && strncmp(cpt, "always_gmt_off", l) == 0) { + xorriso->relax_compliance&= ~isoburn_igopt_always_gmt; + + } else if((l == 9 && strncmp(cpt, "rec_mtime", l) == 0) || + (l == 12 && strncmp(cpt, "rec_mtime_on", l) == 0)) { + xorriso->relax_compliance|= isoburn_igopt_dir_rec_mtime; + } else if(l == 13 && strncmp(cpt, "rec_mtime_off", l) == 0) { + xorriso->relax_compliance&= ~isoburn_igopt_dir_rec_mtime; + + } else if((l == 6 && strncmp(cpt, "old_rr", l) == 0) || + (l == 9 && strncmp(cpt, "old_rr_on", l) == 0) || + (l == 10 && strncmp(cpt, "new_rr_off", l) == 0)) { + xorriso->relax_compliance|= + isoburn_igopt_rrip_version_1_10 | isoburn_igopt_aaip_susp_1_10; + } else if((l == 10 && strncmp(cpt, "old_rr_off", l) == 0) || + (l == 9 && strncmp(cpt, "new_rr_on", l) == 0) || + (l == 6 && strncmp(cpt, "new_rr", l) == 0)) { + xorriso->relax_compliance&= + ~(isoburn_igopt_rrip_version_1_10 | isoburn_igopt_aaip_susp_1_10); + + } else if((l == 14 && strncmp(cpt, "aaip_susp_1_10", l) == 0) || + (l == 17 && strncmp(cpt, "aaip_susp_1_10_on", l) == 0) || + (l == 18 && strncmp(cpt, "aaip_susp_1_12_off", l) == 0)) { + xorriso->relax_compliance|= isoburn_igopt_aaip_susp_1_10; + } else if((l == 18 && strncmp(cpt, "aaip_susp_1_10_off", l) == 0) || + (l == 17 && strncmp(cpt, "aaip_susp_1_12_on", l) == 0) || + (l == 14 && strncmp(cpt, "aaip_susp_1_12", l) == 0)) { + xorriso->relax_compliance&= ~isoburn_igopt_aaip_susp_1_10; + + } else if((l == 8 && strncmp(cpt, "iso_9660", l) == 0) || + (l == 11 && strncmp(cpt, "iso_9660_on", l) == 0)) { + /* may have a meaning in future */; + } else if(l == 12 && strncmp(cpt, "iso_9660_off", l) == 0) { + /* may have a meaning in future */; + Xorriso_msgs_submit(xorriso, 0, + "-compliance -iso_9660_off : Cannot do anything else but ISO 9660", + 0, "FAILURE", 0); + + } else { + if(linfo_text, "-compliance: unknown rule '%s'", + cpt); + else + sprintf(xorriso->info_text, + "-compliance: oversized rule parameter (%d)", l); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + xorriso->relax_compliance= was; + return(0); + } + } + return(1); +} + + +/* @return 1=ok 2=ok, is default setting */ +int Xorriso_get_relax_text(struct XorrisO *xorriso, char mode[1024], + int flag) +{ + int r; + + r= xorriso->relax_compliance; + if(r == 0) { + strcpy(mode, "strict"); + return(1); + } + strcpy(mode, "clear"); + if(r & isoburn_igopt_omit_version_numbers) + strcat(mode, ":omit_version"); + if(r & isoburn_igopt_allow_deep_paths) + strcat(mode, ":deep_paths"); + if(r & isoburn_igopt_allow_longer_paths) + strcat(mode, ":long_paths"); + if(r & isoburn_igopt_max_37_char_filenames) + strcat(mode, ":long_names"); + if(r & isoburn_igopt_no_force_dots) + strcat(mode, ":no_force_dots"); + if(r & isoburn_igopt_allow_lowercase) + strcat(mode, ":lowercase"); + if(r & isoburn_igopt_allow_full_ascii) + strcat(mode, ":full_ascii"); + if(r & isoburn_igopt_joliet_longer_paths) + strcat(mode, ":joliet_long_paths"); + if(r & isoburn_igopt_always_gmt) + strcat(mode, ":always_gmt"); + if(r & isoburn_igopt_dir_rec_mtime) + strcat(mode, ":rec_mtime"); + if(r & isoburn_igopt_rrip_version_1_10) { + strcat(mode, ":old_rr"); + if(!(r & isoburn_igopt_aaip_susp_1_10)) + strcat(mode, ":aaip_susp_1_10_off"); + } else { + strcat(mode, ":new_rr"); + if(r & isoburn_igopt_aaip_susp_1_10) + strcat(mode, ":aaip_susp_1_10"); + } + + return(1 + (r == Xorriso_relax_compliance_defaulT)); +} + + +/** + @param flag bit0= print mount command to result channel rather than + performing it + bit1= do not allow prefixes with cmd + bit2= interpret unprefixed cmd as shell: +*/ +int Xorriso_mount(struct XorrisO *xorriso, char *dev, int adr_mode, + char *adr_value, char *cmd, int flag) +{ + int ret, lba, track, session, params_flag= 0, is_safe= 0, is_extra_drive= 0; + int give_up= 0, mount_chardev= 0, status; + char volid[33], *devadr, mount_command[SfileadrL], adr_data[163], *adr_pt; + char *dev_path, libburn_adr[BURN_DRIVE_ADR_LEN + SfileadrL]; + char sfe[5 * SfileadrL], *dpt, *sysname= ""; + struct stat stbuf; + struct burn_drive_info *dinfo= NULL; + struct burn_drive *drive= NULL; + + devadr= dev; + adr_pt= adr_value; + if(strcmp(dev, "indev") == 0) { + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to perform -mount \"indev\"", 0); + if(ret<=0) + goto ex; + dev_path= devadr= xorriso->indev; + if(strncmp(dev_path, "stdio:", 6) == 0) + dev_path+= 6; + if(xorriso->in_drive_handle == xorriso->out_drive_handle) + give_up= 3; + else + give_up= 1; + } else if(strcmp(dev, "outdev") == 0) { + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to perform -mount \"outdev\"", + 2); + if(ret<=0) + goto ex; + dev_path= devadr= xorriso->outdev; + if(strncmp(dev_path, "stdio:", 6) == 0) + dev_path+= 6; + if(xorriso->in_drive_handle == xorriso->out_drive_handle) + give_up= 3; + else + give_up= 2; + } else { + is_extra_drive= 1; + dev_path= dev; + if(strncmp(dev_path, "stdio:", 6) == 0) + dev_path+= 6; + + /* do only accept regular files and block devices */ + ret= stat(dev_path, &stbuf); + if(ret == -1) { + sprintf(xorriso->info_text, "Cannot determine properties of file %s", + Text_shellsafe(dev_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + ret= System_uname(&sysname, NULL, NULL, NULL, 0); + if(ret > 0 && strcmp(sysname, "FreeBSD") == 0) + mount_chardev= 1; + if(!(S_ISREG(stbuf.st_mode) || (S_ISBLK(stbuf.st_mode) && !mount_chardev) + || (S_ISCHR(stbuf.st_mode) && !mount_chardev))) { + sprintf(xorriso->info_text, + "File object is not suitable as mount device: %s", + Text_shellsafe(dev_path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + + /* Aquire drive as direct libburn address or via stdio: prefix */ + ret= burn_drive_convert_fs_adr(dev, libburn_adr); + Xorriso_process_msg_queues(xorriso,0); + if(ret < 0) + {ret= -1; goto ex;} + if(ret == 0 && strncmp(dev, "stdio:", 6) != 0) + sprintf(libburn_adr, "stdio:%s", dev); + ret= isoburn_drive_aquire(&dinfo, libburn_adr, 1); + Xorriso_process_msg_queues(xorriso,0); + if(ret <= 0) + {ret= 0; goto ex;} + drive= dinfo[0].drive; + } + + if(adr_mode == 4 && strlen(adr_pt) <= 80) { + ret= Xorriso__bourne_to_reg(adr_pt, adr_data, 0); + if(ret == 1) { + params_flag|= 4; + adr_pt= adr_data; + } + } + ret= isoburn_get_mount_params(drive, adr_mode, adr_pt, &lba, &track, + &session, volid, params_flag); + Xorriso_process_msg_queues(xorriso,0); + if(ret <= 0) + goto ex; + if(session <= 0 || track <= 0 || ret == 2) { + Xorriso_msgs_submit(xorriso, 0, + "-mount : Given address does not point to an ISO 9660 session", + 0, "FAILURE", 0); + ret= 0; goto ex; + } + if(strstr(devadr, "stdio:") == devadr) + devadr+= 6; + ret= Xorriso_make_mount_cmd(xorriso, cmd, lba, track, session, volid, devadr, + mount_command, flag & (2 | 4)); + if(ret <= 0) + goto ex; + if(ret == 2) + is_safe= 1; + + if(is_extra_drive) { + isoburn_drive_release(drive, 0); + burn_drive_info_free(dinfo); + drive= NULL; + } else if(give_up > 0 && !(flag & 1)) { + Xorriso_give_up_drive(xorriso, give_up); + if(ret <= 0) + goto ex; + } + Xorriso_process_msg_queues(xorriso,0); + + sprintf(xorriso->info_text, "Volume id : %s\n", + Text_shellsafe(volid, sfe, 0)); + Xorriso_info(xorriso, 0); + if(flag & 1) { + sprintf(xorriso->result_line, "%s\n", mount_command); + Xorriso_result(xorriso,0); + } else { + sprintf(xorriso->info_text, "Mount command: %s\n", mount_command); + Xorriso_info(xorriso, 0); + if(!is_safe) { + Xorriso_msgs_submit(xorriso, 0, + "-mount : Will not perform mount command which stems from command template.", + 0, "SORRY", 0); + sprintf(xorriso->result_line, "%s\n", mount_command); + Xorriso_result(xorriso,0); + } else { + ret= Xorriso_execv(xorriso, mount_command, "/bin:/sbin", &status, 1); + if(WIFEXITED(status) && WEXITSTATUS(status) != 0) { + sprintf(xorriso->info_text, + "-mount : mount command failed with exit value %d", + (int) WEXITSTATUS(ret)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + sprintf(xorriso->info_text, "\nMounted session %d of device %s", + session, Text_shellsafe(dev_path, sfe, 0)); + dpt= strchr(cmd, ':'); + if(dpt == NULL) + dpt= cmd ; + else + dpt++; + sprintf(xorriso->info_text + strlen(xorriso->info_text), + " as directory %s\n", Text_shellsafe(dpt, sfe, 0)); + Xorriso_info(xorriso, 0); + } + } + ret= 1; +ex:; + if(is_extra_drive && drive != NULL) { + isoburn_drive_release(drive, 0); + burn_drive_info_free(dinfo); + Xorriso_process_msg_queues(xorriso,0); + } + return(ret); +} + + +int Xorriso_auto_driveadr(struct XorrisO *xorriso, char *adr, char *result, + int flag) +{ + int ret, is_known_mmc= 0; + char *path_pt, libburn_adr[BURN_DRIVE_ADR_LEN + SfileadrL]; + char *abs_pt, abs_adr[SfileadrL]; + + path_pt= adr; + if(strncmp(adr, "stdio:", 6) == 0) + path_pt= adr + 6; + else if(strncmp(adr, "mmc:", 4) == 0) + path_pt= adr + 4; + + + /* <<< replace by Xorriso_normalize_img_path() ? */; + + if(path_pt[0] != '/') { + abs_pt= getcwd(abs_adr, SfileadrL - 1); + if(abs_pt == NULL) { + Xorriso_msgs_submit(xorriso, 0, + "Relative drive path given. Cannot determine working directory.", + errno, "FAILURE", 0); + return(-1); + } + ret= Sfile_add_to_path(abs_adr, path_pt, 0); + if(ret <= 0) + return(-1); + } + + is_known_mmc= burn_drive_convert_fs_adr(path_pt, libburn_adr); + Xorriso_process_msg_queues(xorriso,0); + + ret= Xorriso_is_in_patternlist(xorriso, xorriso->drive_whitelist, path_pt, 0); + if(ret > 0) + goto ok; + ret= Xorriso_is_in_patternlist(xorriso, xorriso->drive_blacklist, path_pt, 0); + if(ret < 0) + return(ret); + if(ret) { + strcpy(xorriso->info_text, "Drive address "); + Text_shellsafe(adr, xorriso->info_text, 1); + strcat(xorriso->info_text, + " rejected because: -drive_class 'banned' "); + Text_shellsafe(Xorriso_get_pattern(xorriso, xorriso->drive_blacklist, + ret - 1, 0), + xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + /* if in greylist and not MMC and not stdio prefix: reject */ + if(is_known_mmc < 0) + return(ret); + if(adr == path_pt && !is_known_mmc) { /* no prefix, no MMC */ + ret= Xorriso_is_in_patternlist(xorriso, xorriso->drive_greylist, path_pt,0); + if(ret < 0) + return(ret); + if(ret) { + strcpy(xorriso->info_text, "Drive address "); + Text_shellsafe(adr, xorriso->info_text, 1); + strcat(xorriso->info_text, + " rejected because: not MMC and -drive_class 'risky' "); + Text_shellsafe(Xorriso_get_pattern(xorriso,xorriso->drive_greylist, + ret - 1, 0), + xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + Xorriso_msgs_submit(xorriso, 0, + "If the address is a legitimate target, prepend \"stdio:\"", + 0, "HINT", 0); + return(0); + } + } +ok:; + if(strncmp(adr, "mmc:", 4) == 0) { + if(Sfile_str(result, path_pt, 0) <= 0) + return(0); + } else if(adr == path_pt && is_known_mmc <= 0) { + Sfile_str(result, "stdio:", 0); + if(Sfile_str(result, adr, 1) <= 0) + return(0); + } else { + if(Sfile_str(result, adr, 0) <= 0) + return(0); + } + if(strncmp(result, "stdio:", 6)==0) { + if(xorriso->ban_stdio_write) { + strcpy(xorriso->info_text, "Drive address banned by -ban_stdio_write : "); + Text_shellsafe(result, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + } + return(1); +} + + +/* + @param flag bit0= do not remove leading slash + bit1= append flatly to result_line and put out +*/ +int Xorriso_getfname(struct XorrisO *xorriso, char *path, int flag) +{ + int ret, path_offset= 0, bsl_mem; + char *bsl_path= NULL; + + if(path[0] == '/' && !(flag & 1)) + path_offset= 1; + + /* backslash escaped path rather than shellsafe path */ + ret= Sfile_bsl_encoder(&bsl_path, path + path_offset, + strlen(path + path_offset), 8); + if(ret <= 0) + return(-1); + if(flag & 2) { + sprintf(xorriso->result_line + strlen(xorriso->result_line), + "%s\n", bsl_path[0] ? bsl_path : "."); + } else { + sprintf(xorriso->result_line, "# file: %s\n", bsl_path[0] ? bsl_path : "."); + } + free(bsl_path); + bsl_path= NULL; + /* temporarily disable -backslash_codes with result output */ + bsl_mem= xorriso->bsl_interpretation; + xorriso->bsl_interpretation= 0; + Xorriso_result(xorriso, 0); + xorriso->bsl_interpretation= bsl_mem; + return(1); +} + + +/* @param node Opaque handle to IsoNode which is to be inquired instead of path if it is not NULL. + @param path is used as address if node is NULL. + @param acl_text if acl_text is not NULL, then *acl_text will be set to the + ACL text (without comments) of the file object. In this + case it finally has to be freed by the caller. + @param flag bit0= do not report to result but only retrieve ACL text + bit1= check for existence of true ACL (not fabricated), + do not allocate and set acl_text but return 1 or 2 + bit2-3: what ALC to retrieve: + 0= "access" and "default", mark "default:" + 1= "access" only + 2= "default" only, do not mark "default:" + bit4= get "access" ACL only if not trivial + @return 2 ok, no ACL available, eventual *acl_text will be NULL + 1 ok, ACL available, eventual *acl_text stems from malloc() + <=0 error +*/ +int Xorriso_getfacl(struct XorrisO *xorriso, void *in_node, char *path, + char **acl_text, int flag) +{ + int ret, d_ret, result_len= 0, pass, what; + IsoNode *node; + char *text= NULL, *d_text= NULL, *cpt, *npt; + uid_t uid; + gid_t gid; + struct passwd *pwd; + struct group *grp; + + what= (flag >> 2) & 3; + if(acl_text != NULL) + *acl_text= NULL; + + node= (IsoNode *) in_node; + if(node == NULL) { + ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0); + if(ret<=0) + goto ex; + } + ret= iso_node_get_acl_text(node, &text, &d_text, flag & 16); + d_ret= (d_text != NULL); + if(ret < 0 || d_ret < 0) { + if(path != NULL && path[0] != 0) { + strcpy(xorriso->info_text, "Error with obtaining ACL of "); + Text_shellsafe(path, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + } + ret= 0; goto ex; + } + if(flag & 2) { + ret= 1 + (ret != 1 && d_ret == 0); + goto ex; + } + if((ret == 0 || ret == 2) && d_ret == 0) { + if(flag & 1) { + ret= 1 + (ret == 0); + goto ex; + } + strcpy(xorriso->info_text, "No ACL associated with "); + Text_shellsafe(path, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + if(ret == 0) + {ret= 2; goto ex;} + } + + if(!(flag & 1)) { + ret= Xorriso_getfname(xorriso, path, 0); + if(ret <= 0) + goto ex; + uid= iso_node_get_uid(node); + pwd= getpwuid(uid); + if(pwd == NULL) + sprintf(xorriso->result_line, "# owner: %.f\n", (double) uid); + else + sprintf(xorriso->result_line, "# owner: %s\n", pwd->pw_name); + Xorriso_result(xorriso, 0); + gid= iso_node_get_gid(node); + grp= getgrgid(gid); + if(grp == NULL) + sprintf(xorriso->result_line, "# group: %.f\n", (double) gid); + else + sprintf(xorriso->result_line, "# group: %s\n", grp->gr_name); + Xorriso_result(xorriso, 0); + } + + for(pass= 0; pass < 1 + (acl_text != NULL && !(flag & 2)); pass++) { + if(pass) { + *acl_text= calloc(result_len + 1, 1); + if(*acl_text == NULL) { + Xorriso_no_malloc_memory(xorriso, NULL, 0); + ret= -1; goto ex; + } + } + if(text != NULL && what <= 1) { + for(npt= cpt= text; npt != NULL; cpt= npt + 1) { + npt= strchr(cpt, '\n'); + if(npt != NULL) + *npt= 0; + if(*cpt == 0) { + if(d_text != NULL || pass) { + if(npt != NULL) + *npt= '\n'; + continue; + } + } else + result_len+= strlen(cpt) + 1; + if(pass) { + sprintf(*acl_text + strlen(*acl_text), "%s\n", cpt); + } else if(!(flag & 1)) { + Sfile_str(xorriso->result_line, cpt, 0); + strcat(xorriso->result_line, "\n"); + Xorriso_result(xorriso, 0); + } + if(npt != NULL) + *npt= '\n'; + } + } + if(d_text != NULL && (what == 0 || what == 2)) { + for(npt= cpt= d_text; npt != NULL; cpt= npt + 1) { + npt= strchr(cpt, '\n'); + if(npt != NULL) + *npt= 0; + if(*cpt != 0) { + if(pass) { + if(what == 0) + sprintf(*acl_text + strlen(*acl_text), "default:%s\n", cpt); + else + sprintf(*acl_text + strlen(*acl_text), "%s\n", cpt); + } else { + xorriso->result_line[0]= 0; + if(what == 0) + Sfile_str(xorriso->result_line, "default:", 0); + Sfile_str(xorriso->result_line, cpt, 1); + result_len+= strlen(cpt) + 9; + } + } else + xorriso->result_line[0]= 0; + if(pass== 0 && !(flag & 1)) { + strcat(xorriso->result_line, "\n"); + Xorriso_result(xorriso, 0); + } + if(npt != NULL) + *npt= '\n'; + } + } + } + ret= 1; +ex:; + iso_node_get_acl_text(node, &text, &d_text, 1 << 15); + return(ret); +} + + +int Xorriso_set_ignore_aclea(struct XorrisO *xorriso, int flag) +{ + int ret, hflag; + IsoImage *volume; + + ret= Xorriso_get_volume(xorriso, &volume, 1); + if(ret<=0) + return(ret); + hflag= (~xorriso->do_aaip) & 1; + if((xorriso->ino_behavior & (1 | 2)) && !(xorriso->do_aaip & (4 | 16))) + hflag|= 2; + iso_image_set_ignore_aclea(volume, hflag); + return(1); +} + + +/* @param node Opaque handle to IsoNode which is to be manipulated + instead of path if it is not NULL. + @param path is used as address if node is NULL. + @param access_text "access" ACL in long text form + @param default_text "default" ACL in long text form + @param flag bit0= do not warn of root directory if not capable of AAIP + @return >0 success , <=0 failure +*/ +int Xorriso_setfacl(struct XorrisO *xorriso, void *in_node, char *path, + char *access_text, char *default_text, int flag) +{ + int ret; + IsoNode *node; + + node= (IsoNode *) in_node; + if(node == NULL) { + ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0); + if(ret<=0) + goto ex; + } + ret= iso_node_set_acl_text(node, access_text, default_text, 0); + if(ret <= 0) { + if(path != NULL && path[0] != 0) { + strcpy(xorriso->info_text, "Error with setting ACL of "); + Text_shellsafe(path, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + } + ret= 0; goto ex; + } + Xorriso_set_change_pending(xorriso, 0); + ret= 1; +ex:; + Xorriso_process_msg_queues(xorriso,0); + return(ret); +} + + +/* + @param flag bit0= do not report to result but only retrieve attr text + bit1= path is disk_path + bit3= do not ignore eventual non-user attributes. + 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) +*/ +int Xorriso_getfattr(struct XorrisO *xorriso, void *in_node, char *path, + char **attr_text, int flag) +{ + int ret= 1, i, bsl_mem, result_len= 0, pass; + size_t num_attrs= 0, *value_lengths= NULL; + char **names= NULL, **values= NULL, *bsl; + + if(attr_text != NULL) + *attr_text= NULL; + ret= Xorriso_get_attrs(xorriso, in_node, path, &num_attrs, &names, + &value_lengths, &values, flag & (2 | 8 | 32)); + if(ret <= 0) + goto ex; + if(flag & 64) { + ret= (num_attrs > 0); + goto ex; + } + if(num_attrs == 0) + {ret= 2; goto ex;} + + if(!(flag & 1)) { + ret= Xorriso_getfname(xorriso, path, 0); + if(ret <= 0) + goto ex; + } + for(pass= 0; pass < 1 + (attr_text != NULL); pass++) { + if(pass) { + *attr_text= calloc(result_len + 1, 1); + if(*attr_text == NULL) { + Xorriso_no_malloc_memory(xorriso, NULL, 0); + ret= -1; goto ex; + } + } + for(i= 0; i < num_attrs; i++) { + if(strlen(names[i]) + value_lengths[i] >= SfileadrL) { + sprintf(xorriso->result_line, "# oversized: name %d , value %d bytes\n", + (int) strlen(names[i]), (int) value_lengths[i]); + } else { + ret= Sfile_bsl_encoder(&bsl, names[i], strlen(names[i]), 8); + if(ret <= 0) + {ret= -1; goto ex;} + strcpy(xorriso->result_line, bsl); + free(bsl); + ret= Sfile_bsl_encoder(&bsl, values[i], value_lengths[i], 8); + if(ret <= 0) + {ret= -1; goto ex;} + sprintf(xorriso->result_line + strlen(xorriso->result_line), + "=\"%s\"\n", bsl); + free(bsl); + } + /* temporarily disable -backslash_codes with result output */ + result_len+= strlen(xorriso->result_line); + if(pass) { + strcat(*attr_text, xorriso->result_line); + } else if(!(flag & 1)) { + bsl_mem= xorriso->bsl_interpretation; + xorriso->bsl_interpretation= 0; + Xorriso_result(xorriso, 0); + xorriso->bsl_interpretation= bsl_mem; + } + } + } + if(!(flag & 1)) { + strcpy(xorriso->result_line, "\n"); + Xorriso_result(xorriso, 0); + } + ret= 1; +ex:; + Xorriso_get_attrs(xorriso, in_node, path, &num_attrs, &names, + &value_lengths, &values, 1 << 15); + return(ret); +} + + +/* @param in_node Opaque handle to IsoNode which is to be manipulated + instead of path if it is not NULL. + @param path is used as address if node is NULL. + @param num_attrs Number of attributes + @param names Array of pointers to 0 terminated name strings + @param value_lengths Array of byte lengths for each attribute payload + @param values Array of pointers to the attribute payload bytes + @param flag bit0= Do not maintain eventual existing ACL of the node + bit1= Do not clear the existing attribute list + bit2= Delete the attributes with the given names + bit3= Allow non-user attributes. + bit4= do not warn of root if incapable of AAIP + @return >0 success , <=0 failure +*/ +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 ret; + IsoNode *node; + + node= (IsoNode *) in_node; + if(node == NULL) { + ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0); + if(ret<=0) + goto ex; + } + ret= iso_node_set_attrs(node, num_attrs, names, value_lengths, values, + flag & (1 | 2 | 4 | 8)); + Xorriso_process_msg_queues(xorriso,0); + if(ret <= 0) { + Xorriso_report_iso_error(xorriso, "", ret, + "Error when setting ACL and xattr to image node", + 0, "FAILURE", 1); + if(path != NULL && path[0] != 0) { + strcpy(xorriso->info_text, "Error with setting xattr of "); + Text_shellsafe(path, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + } + ret= 0; goto ex; + } + Xorriso_set_change_pending(xorriso, 0); + ret= 1; +ex:; + Xorriso_process_msg_queues(xorriso,0); + return(ret); +} + + +/* + @param flag + Bitfield for control purposes + bit0= get default ACL rather than access ACL + bit4= set *text = NULL and return 2 + if the ACL matches st_mode permissions. + bit5= in case of symbolic link: inquire link target + bit15= free text and return 1 + @return + 1 ok + 2 ok, trivial ACL found while bit4 is set, *text is NULL + 0 no ACL manipulation adapter available + -1 failure of system ACL service (see errno) + -2 attempt to inquire ACL of a symbolic link without bit4 or bit5 + resp. with no suitable link target +*/ +int Xorriso_local_getfacl(struct XorrisO *xorriso, char *disk_path, + char **text, int flag) +{ + int ret, skip= 0, colons= 0, countdown= 0; + char *acl= NULL, *cpt, *wpt; + + if(flag & (1 << 15)) { + if(*text != NULL) + free(*text); + *text= NULL; + return(1); + } + *text= NULL; + ret= iso_local_get_acl_text(disk_path, &acl, flag & (1 | 16 | 32)); + Xorriso_process_msg_queues(xorriso,0); + if(ret < 0 || ret == 2) + return(ret); + if(acl == NULL) + return(0); + *text= strdup(acl); + iso_local_get_acl_text(disk_path, &acl, 1 << 15); + if(*text == NULL) { + Xorriso_no_malloc_memory(xorriso, NULL, 0); + return(-1); + } + + /* Garbage collection about trailing remarks after 3 permission chars */ + wpt= *text; + for(cpt= *text; *cpt; cpt++) { + if(skip) { + if(*cpt == '\n') + skip= 0; + else + continue; + } + if(*cpt == ':' && !countdown) { + colons++; + if(colons == 2) { + countdown= 4; + colons= 0; + } + } + if(countdown > 0) { + countdown--; + if(countdown == 0) + skip= 1; + } + *wpt= *cpt; + wpt++; + } + *wpt= 0; + + return(1); +} + + +/* + @param flag + bit1= path is disk_path + bit3= do not ignore eventual non-user attributes. + bit5= in case of symbolic link on disk: inquire link target + bit15= free memory +*/ +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 ret, i, widx; + IsoNode *node; + + if(flag & (1 << 15)) { + if(flag & 2) { + iso_local_get_attrs(NULL, num_attrs, names, value_lengths, values, + 1 << 15); + } else { + iso_node_get_attrs(NULL, num_attrs, names, value_lengths, values, + 1 << 15); + } + return(1); + } + + *num_attrs= 0; + if(flag & 2) { + ret= iso_local_get_attrs(path, num_attrs, names, value_lengths, values, + flag & (8 | 32)); + if(ret < 0) { + strcpy(xorriso->info_text, "Error with reading xattr of disk file "); + Text_shellsafe(path, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); + } + } else { + node= (IsoNode *) in_node; + if(node == NULL) { + ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0); + if(ret<=0) + goto ex; + } + ret= iso_node_get_attrs(node, num_attrs, names, value_lengths, values, + 0); + if(ret < 0) { + Xorriso_report_iso_error(xorriso, "", ret, + "Error when obtaining xattr of ISO node", 0, "FAILURE", 1); + goto ex; + } + + if(!(flag & 8)) { + /* Filter away any non-userspace xattr */; + widx= 0; + for(i= 0; i < *num_attrs; i++) { + if(strncmp((*names)[i], "user.", 5) != 0) { + free((*names)[i]); + (*names)[i]= NULL; + if((*values)[i] != NULL) { + free((*values)[i]); + (*values)[i]= NULL; + } + } else { + if(widx != i) { + (*names)[widx]= (*names)[i]; + (*value_lengths)[widx]= (*value_lengths)[i]; + (*values)[widx]= (*values)[i]; + (*names)[i]= NULL; + (*value_lengths)[i]= 0; + (*values)[i]= NULL; + } + widx++; + } + } + *num_attrs= widx; + } + } + ret= 1; +ex:; + Xorriso_process_msg_queues(xorriso,0); + return(ret); +} + + +int Xorriso_get_attr_value(struct XorrisO *xorriso, void *in_node, char *path, + char *name, size_t *value_length, char **value, int flag) +{ + int ret; + size_t num_attrs= 0, *value_lengths= NULL, i; + char **names = NULL, **values= NULL; + + *value= NULL; + *value_length= 0; + ret= Xorriso_get_attrs(xorriso, in_node, path, &num_attrs, &names, + &value_lengths, &values, 8); + if(ret <= 0) + goto ex; + + for(i= 0; i < num_attrs; i++) { + if(strcmp(name, names[i]) != 0) + continue; + *value= calloc(value_lengths[i] + 1, 1); + if(*value == NULL) + {ret= -1; goto ex;} + memcpy(*value, values[i], value_lengths[i]); + (*value)[value_lengths[i]]= 0; + *value_length= value_lengths[i]; + ret= 1; goto ex; + } + ret= 0; +ex: + Xorriso_get_attrs(xorriso, in_node, path, &num_attrs, &names, + &value_lengths, &values, 1 << 15); + return(ret); +} + + +/* + @param flag bit0= use parameters dev,ino rather than disk_path + bit1= compare attribute rather than setting it + return: 0=dev,ino match, 1=mismatch, 2=no node attribute + -1=error + bit5= if not bit0: + transfer dev,inode from eventual link target + bit7= omit dev check mit bit1 +*/ +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) +{ + size_t l, di_l= 0; + int i, ret; + dev_t hdev; + ino_t hino; + char buf[66], *bufpt, *wpt, *di= NULL; + static char *name= "isofs.di"; + struct stat stbuf; + + if(!(flag & 1)) { + if(flag & 32) { + if(stat(disk_path, &stbuf) == -1) + return(-1); + } else { + if(lstat(disk_path, &stbuf) == -1) + return(-1); + } + dev= stbuf.st_dev; + ino= stbuf.st_ino; + } + + wpt= buf; + hdev= dev; + for(i= 0; hdev != 0; i++) + hdev= hdev >> 8; + l= i; + *(wpt++)= l; + for(i= 0; i < l; i++) + *(wpt++)= dev >> (8 * (l - i - 1)); + hino= ino; + for(i= 0; hino != 0; i++) + hino= hino >> 8; + l= i; + *(wpt++)= l; + for(i= 0; i < l; i++) + *(wpt++)= ino >> (8 * (l - i - 1)); + l= wpt - buf; + bufpt= buf; + + if(flag & 2) { + /* Compare node attribute with bufpt,l */ + ret= Xorriso_get_attr_value(xorriso, in_node, iso_path, + "isofs.di", &di_l, &di, 0); + if(ret < 0) + goto ex; + if(ret == 0) + {ret= 2; goto ex;} + if(flag & 128) { + if(di_l <= 0) + {ret= 1; goto ex;} + hino= 0; + for(i= di[0] + 2; i < di_l && i - di[0] - 2 < di[(int) di[0] + 1]; i++) + hino= (hino << 8) | ((unsigned char *) di)[i]; + if(hino != ino) + {ret= 1; goto ex;} + } else { + if(l != di_l) + {ret= 1; goto ex;} + for(i= 0; i < l; i++) + if(di[i] != buf[i]) + {ret= 1; goto ex;} + } + ret= 0; + } else { + ret= Xorriso_setfattr(xorriso, in_node, iso_path, + (size_t) 1, &name, &l, &bufpt, 2 | 8); + } +ex:; + if(di != NULL) + free(di); + return(ret); +} + + +struct Xorriso_extF { + + int flag; /* unused yet */ + + IsoExternalFilterCommand *cmd; + +}; + +int Xorriso_extf_destroy(struct XorrisO *xorriso, struct Xorriso_extF **filter, + int flag); + + +/* @param flag see struct Xorriso_extF.flag */ +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) +{ + int i; + struct Xorriso_extF *o= NULL; + IsoExternalFilterCommand *cmd; + + *filter= o= calloc(sizeof(struct Xorriso_extF), 1); + if(o == NULL) + goto failure; + o->flag= flag; + o->cmd= NULL; + o->cmd= cmd= calloc(sizeof(IsoExternalFilterCommand), 1); + if(cmd == NULL) + goto failure; + cmd->version= 0; + cmd->refcount= 0; + cmd->name= NULL; + cmd->path= NULL; + cmd->argv= NULL; + cmd->argc= argc + 1; + cmd->behavior= behavior; + cmd->suffix= NULL; + cmd->suffix= strdup(suffix); + if(cmd->suffix == NULL) + goto failure; + + cmd->path= strdup(path); + if(cmd->path == NULL) + goto failure; + cmd->argv= calloc(sizeof(char *), argc + 2); + if(cmd->argv == NULL) + goto failure; + for(i= 0; i < argc + 2; i++) + cmd->argv[i]= NULL; + cmd->argv[0]= strdup(path); + if(cmd->argv[0] == NULL) + goto failure; + for(i= 0; i < argc; i++) { + cmd->argv[i + 1]= strdup(argv[i]); + if(cmd->argv[i] == NULL) + goto failure; + } + cmd->name= strdup(name); + if(cmd->name == NULL) + goto failure; + return(1); +failure:; + Xorriso_extf_destroy(xorriso, filter, 0); + return(-1); +} + + +int Xorriso_extf_destroy(struct XorrisO *xorriso, struct Xorriso_extF **filter, + int flag) +{ + int i; + IsoExternalFilterCommand *cmd; + + if(*filter == NULL) + return(0); + cmd= (*filter)->cmd; + if(cmd != NULL) { + if(cmd->refcount > 0) + return(0); + if(cmd->suffix != NULL) + free(cmd->suffix); + if(cmd->argv != NULL) { + for(i= 0; i < cmd->argc; i++) + if(cmd->argv[i] != NULL) + free(cmd->argv[i]); + free((char *) cmd->argv); + } + if(cmd->name != NULL) + free(cmd->name); + } + free((char *) *filter); + *filter= NULL; + return(1); +} + + +int Xorriso_lookup_extf(struct XorrisO *xorriso, char *name, + struct Xorriso_lsT **found_lst, int flag) +{ + struct Xorriso_extF *filter; + struct Xorriso_lsT *lst; + + for(lst= xorriso->filters; lst != NULL; lst= Xorriso_lst_get_next(lst, 0)) { + filter= (struct Xorriso_extF *) Xorriso_lst_get_text(lst, 0); + if(strcmp(filter->cmd->name, name) == 0) { + *found_lst= lst; + return(1); + } + } + return(0); +} + + +int Xorriso_destroy_all_extf(struct XorrisO *xorriso, int flag) +{ + struct Xorriso_extF *filter; + struct Xorriso_lsT *lst, *next_lst; + + for(lst= xorriso->filters; lst != NULL; lst= next_lst) { + filter= (struct Xorriso_extF *) Xorriso_lst_get_text(lst, 0); + Xorriso_lst_detach_text(lst, 0); + next_lst= Xorriso_lst_get_next(lst, 0); + Xorriso_lst_destroy(&lst, 0); + Xorriso_extf_destroy(xorriso, &filter, 0); + } + xorriso->filters= NULL; + return(1); +} + + +/* + @param flag bit0= return 2 if renaming is not possible by libisofs + (always: if demanded strip suffix is missing + or if suffix makes name length > 255) + bit1= strip suffix rather than appending it +*/ +int Xorriso_rename_suffix(struct XorrisO *xorriso, IsoNode *node, char *suffix, + char *show_path, char new_name[], int flag) +{ + int ret, lo= 0, ls= 0, strip_suffix; + char *old_name= NULL, *show_name; + + strip_suffix= !!(flag & 2); + + old_name= strdup((char *) iso_node_get_name(node)); + show_name= old_name; + if(show_path != NULL) + if(show_path[0] != 0) + show_name= show_path; + lo= strlen(old_name); + ls= strlen(suffix); + if(strip_suffix) { + if(lo <= ls) { + /* refuse gracefully */ + ret= 2; goto ex; + } + if(strcmp(old_name + lo - ls, suffix) != 0) { + ret= 2; goto ex; + } + if(lo >= SfileadrL) + goto cannot_remove_suffix; + strcpy(new_name, old_name); + new_name[lo - ls]= 0; + ret = iso_node_set_name(node, new_name); + if (ret < 0) { + Xorriso_process_msg_queues(xorriso,0); + if (!(flag & 1)) + Xorriso_report_iso_error(xorriso, "", ret, + "Error when renaming ISO node", 0, "FAILURE", 1); +cannot_remove_suffix:; + strcpy(xorriso->info_text, "-set_filter: Cannot remove suffix from "); + Text_shellsafe(show_name, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, + (flag & 1) ? "WARNING" : "FAILURE", 0); + ret= 2 * (flag & 1); goto ex; + } + } else { + /* check whether suffix already present */ + if(lo >= ls) + if(strcmp(old_name + lo - ls, suffix) == 0) { + /* refuse gracefully */ + ret= 2; goto ex; + } + if(lo + ls > 255) { +cannot_append_suffix:; + strcpy(xorriso->info_text, "-set_filter: Cannot append suffix to "); + Text_shellsafe(show_name, xorriso->info_text, 1); + strcat(xorriso->info_text, ". Left unfiltered."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, + (flag & 1) ? "WARNING" : "FAILURE", 0); + ret= 2 * (flag & 1); goto ex; + } + sprintf(new_name, "%s%s", old_name, suffix); + ret = iso_node_set_name(node, new_name); + if (ret < 0) { + Xorriso_process_msg_queues(xorriso,0); + if (!(flag & 1)) + Xorriso_report_iso_error(xorriso, "", ret, + "Error when renaming ISO node", 0, "FAILURE", 1); + goto cannot_append_suffix; + } + } + + ret= 1; +ex:; + if(old_name != NULL) + free(old_name); + Xorriso_process_msg_queues(xorriso,0); + return(ret); +} + + +/* + @param flag bit0= return 2 if renaming is not possible + bit1= print pacifier messages + */ +int Xorriso_set_filter(struct XorrisO *xorriso, void *in_node, + char *path, char *filter_name, int flag) +{ + int ret, strip_suffix= 0, strip_filter= 0, filter_ret= 0; + int explicit_suffix= 0, internal_filter= 0; + IsoNode *node; + IsoFile *file; + struct Xorriso_lsT *found_lst; + struct Xorriso_extF *found_filter; + IsoExternalFilterCommand *cmd = NULL; + char *old_name= NULL, new_name[SfileadrL], *suffix= ""; + IsoStream *stream; + int is_renamed= 0; + + new_name[0]= 0; + + node= (IsoNode *) in_node; + if(node == NULL) { + ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0); + if(ret <= 0) + goto ex; + } + if(!LIBISO_ISREG(node)) { + strcpy(xorriso->info_text, "-set_filter: Not a regular data file node "); + Text_shellsafe(path, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + ret= 0; goto ex; + } + file= (IsoFile *) node; + + if(strncmp(filter_name, "--remove-all-filters", 20) == 0) { + strip_filter= 1; + strip_suffix= 1; + if(strlen(filter_name) > 21) { + strip_suffix= (filter_name[20] != '+'); + suffix= filter_name + 21; + explicit_suffix= 1; + } + } else if(strcmp(filter_name, "--zisofs") == 0) { + internal_filter= 1; + } else if(strcmp(filter_name, "--zisofs-decode") == 0) { + internal_filter= 2; + } else if(strcmp(filter_name, "--gzip") == 0) { + internal_filter= 3; + suffix= ".gz"; + strip_suffix= 0; + explicit_suffix= 1; + } else if(strcmp(filter_name, "--gunzip") == 0 || + strcmp(filter_name, "--gzip-decode") == 0) { + internal_filter= 4; + suffix= ".gz"; + strip_suffix= 1; + explicit_suffix= 1; + } else { + ret= Xorriso_lookup_extf(xorriso, filter_name, &found_lst, 0); + if(ret < 0) + goto ex; + if(ret == 0) { + strcpy(xorriso->info_text, "-set_filter: Not a registered filter name "); + Text_shellsafe(filter_name, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + found_filter= (struct Xorriso_extF *) Xorriso_lst_get_text(found_lst, 0); + cmd= found_filter->cmd; + suffix= cmd->suffix; + strip_suffix= cmd->behavior & 8; + } + + if(suffix[0]) { + + /* >>> would need full iso_rr_path of node for showing */; + + old_name= strdup((char *) iso_node_get_name(node)); + ret= Xorriso_rename_suffix(xorriso, node, suffix, path, new_name, + (flag & 1) | (strip_suffix ? 2 : 0)); + if(ret <= 0 || ret == 2) + goto ex; + is_renamed= 1; + } + + if(strip_filter) { + while(1) { + if(!explicit_suffix) { + stream= iso_file_get_stream(file); + + if(strncmp(stream->class->type, "gzip", 4) == 0) { + suffix= ".gz"; + strip_suffix= 1; + } else if(strncmp(stream->class->type, "pizg", 4) == 0) { + suffix= ".gz"; + strip_suffix= 0; + } else { + ret= iso_stream_get_external_filter(stream, &cmd, 0); + if(ret > 0) { + suffix= cmd->suffix; + strip_suffix= !(cmd->behavior & 8); + } + } + if(suffix[0]) { + + /* >>> would need the current renaming state of path */; + + ret= Xorriso_rename_suffix(xorriso, node, suffix, NULL, new_name, + (flag & 1) | (strip_suffix << 1)); + if(ret <= 0 || ret == 2) + goto ex; + } + } + ret= iso_file_remove_filter(file, 0); + if(ret != 1) + break; + } + filter_ret= 1; + } else if (internal_filter == 1 || internal_filter == 2) { + filter_ret = iso_file_add_zisofs_filter(file, 1 | (internal_filter & 2)); + if(filter_ret < 0) { + Xorriso_process_msg_queues(xorriso,0); + if(!(internal_filter == 2 && filter_ret == ISO_ZISOFS_WRONG_INPUT)) + Xorriso_report_iso_error(xorriso, "", filter_ret, + "Error when setting filter to ISO node", 0, "FAILURE", 1); + } + } else if (internal_filter == 3 || internal_filter == 4) { + filter_ret = iso_file_add_gzip_filter(file, + 1 | ((internal_filter == 4) << 1)); + if(filter_ret < 0) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_report_iso_error(xorriso, "", filter_ret, + "Error when setting filter to ISO node", 0, "FAILURE", 1); + } + } else { + +#ifndef Xorriso_allow_extf_suiD + /* This is a final safety precaution before iso_file_add_external_filter() + performs fork() and executes the alleged filter program. + */ + if(getuid() != geteuid()) { + sprintf(xorriso->info_text, + "-set_filter: UID and EUID differ. Will not run external programs."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(0); + } +#endif /* ! Xorriso_allow_extf_suiD */ + + filter_ret = iso_file_add_external_filter(file, cmd, 0); + if(filter_ret < 0) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_report_iso_error(xorriso, "", filter_ret, + "Error when setting filter to ISO node", 0, "FAILURE", 1); + } + } + if(filter_ret != 1 && new_name[0] && old_name != NULL) { + ret = iso_node_set_name(node, old_name); + if (ret < 0) { + Xorriso_process_msg_queues(xorriso,0); + if (!(flag & 1)) + Xorriso_report_iso_error(xorriso, "", ret, + "Error when renaming ISO node", 0, "FAILURE", 1); + } + } + if(flag & 2) { + xorriso->pacifier_count++; + Xorriso_pacifier_callback(xorriso, "file filters processed", + xorriso->pacifier_count, xorriso->pacifier_total, "", 0); + } + if(filter_ret < 0) { + ret= 0; goto ex; + } + + ret= filter_ret; +ex:; + if(old_name != NULL) + free(old_name); + Xorriso_process_msg_queues(xorriso,0); + return(ret); +} + + +/* @param flag bit0= delete filter with the given name +*/ +int Xorriso_external_filter(struct XorrisO *xorriso, + char *name, char *options, char *path, + int argc, char **argv, int flag) +{ + int ret, delete= 0, behavior= 0, extf_flag= 0, is_banned= 0; + char *what, *what_next, *suffix= ""; + struct Xorriso_lsT *lst; + struct Xorriso_extF *found_filter, *new_filter= NULL; + +#ifndef Xorriso_allow_external_filterS + /* To be controlled by: configure --enable-external-filters */ + + sprintf(xorriso->info_text, "%s : Banned at compile time.", + flag & 1 ? "-unregister_filter" : "-external_filter"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + sprintf(xorriso->info_text, +"This may be changed at compile time by ./configure option --enable-external-filters"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0); + is_banned= 1; + +#endif /* ! Xorriso_allow_external_filterS */ + +#ifndef Xorriso_allow_extf_suiD + /* To be controlled by: configure --enable-external-filters-setuid */ + + if(getuid() != geteuid()) { + sprintf(xorriso->info_text, + "-set_filter: UID and EUID differ. Will not run external programs."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + sprintf(xorriso->info_text, +"This may be changed at compile time by ./configure option --enable-external-filters-setuid"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0); + is_banned= 1; + } +#endif /* ! Xorriso_allow_extf_suiD */ + + if(is_banned) + return(0); + + if(xorriso->filter_list_closed) { + sprintf(xorriso->info_text, + "%s : Banned by previous command -close_filter_list", + flag & 1 ? "-unregister_filter" : "-external_filter"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if((!(flag & 1)) && path[0] != '/') { + sprintf(xorriso->info_text, + "-external_filter : Given command path does not begin by '/' : "); + Text_shellsafe(path, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + + + delete= flag & 1; + ret= Xorriso_lookup_extf(xorriso, name, &lst, 0); + if(ret < 0) + return(ret); + if(ret > 0) { + if(delete) { + found_filter= (struct Xorriso_extF *) Xorriso_lst_get_text(lst, 0); + if(found_filter->cmd->refcount > 0) { + sprintf(xorriso->info_text, + "-external_filter: Cannot remove filter because it is in use by %.f nodes : ", + (double) found_filter->cmd->refcount); + Text_shellsafe(name, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + Xorriso_lst_detach_text(lst, 0); + if(xorriso->filters == lst) + xorriso->filters= Xorriso_lst_get_next(lst, 0); + Xorriso_lst_destroy(&lst, 0); + Xorriso_extf_destroy(xorriso, &found_filter, 0); + ret= 1; goto ex; + } + strcpy(xorriso->info_text, + "-external_filter: filter with given name already existing: "); + Text_shellsafe(name, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + if(delete) { + strcpy(xorriso->info_text, + "-external_filter: filter with given name does not exist: "); + Text_shellsafe(name, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + + for(what= options; what!=NULL; what= what_next) { + what_next= strchr(what, ':'); + if(what_next!=NULL) { + *what_next= 0; + what_next++; + } + if(strncmp(what, "default", 7) == 0) { + suffix= ""; + behavior= 0; + } else if(strncmp(what, "suffix=", 7) == 0) { + suffix= what + 7; + } else if(strcmp(what, "remove_suffix") == 0) { + behavior|= 8; + } else if(strcmp(what, "if_nonempty") == 0) { + behavior|= 1; + } else if(strcmp(what, "if_reduction") == 0) { + behavior|= 2; + } else if(strcmp(what, "if_block_reduction") == 0) { + behavior|= 4; + } else if(strncmp(what, "used=", 5) == 0) { + ; /* this is informational output from -status */ + } else if(what[0]) { + strcpy(xorriso->info_text, + "-external_filter: unknown option "); + Text_shellsafe(what, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + ret= 0; goto ex; + } + } + + ret= Xorriso_extf_new(xorriso, &new_filter, path, argc, argv, behavior, + suffix, name, extf_flag); + if(ret <= 0) { +could_not_create:; + strcpy(xorriso->info_text, + "-external_filter: Could not create filter object"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + goto ex; + } + ret= Xorriso_lst_append_binary(&(xorriso->filters), (char *) new_filter,0, 4); + if(ret <= 0) + goto could_not_create; + ret= 1; +ex:; + if(ret <= 0) { + if(new_filter != NULL) + Xorriso_extf_destroy(xorriso, &new_filter, 0); + } + return(ret); +} + + +int Xorriso_status_extf(struct XorrisO *xorriso, char *filter, FILE *fp, + int flag) +/* + bit1= do only report to fp +*/ +{ + int i, maxl= 4 * SfileadrL; + struct Xorriso_extF *extf; + struct Xorriso_lsT *lst; + char *line; + + line= xorriso->result_line; + for(lst= xorriso->filters; lst != NULL; lst= Xorriso_lst_get_next(lst, 0)) { + extf= (struct Xorriso_extF *) Xorriso_lst_get_text(lst, 0); + + strcpy(xorriso->result_line, "-external_filter "); + Text_shellsafe(extf->cmd->name, line, 1); + if(strlen(line) > maxl) + continue; + strcat(line, " "); + if(extf->cmd->suffix[0]) { + strcat(line, "suffix="); + Text_shellsafe(extf->cmd->suffix, line, 1); + if(strlen(line) > maxl) + continue; + strcat(line, ":"); + } + if(extf->cmd->behavior & 8) + strcat(line, "remove_suffix:"); + if(extf->cmd->behavior & 1) + strcat(line, "if_nonempty:"); + if(extf->cmd->behavior & 2) + strcat(line, "if_reduction:"); + if(extf->cmd->behavior & 4) + strcat(line, "if_block_reduction:"); + sprintf(line + strlen(line), "used=%.f ", (double) extf->cmd->refcount); + if(strlen(line) > maxl) + continue; + Text_shellsafe(extf->cmd->path, line, 1); + if(strlen(line) > maxl) + continue; + for(i= 1; i < extf->cmd->argc; i++) { + strcat(line, " "); + Text_shellsafe(extf->cmd->argv[i], line, 1); + if(strlen(line) > maxl) + break; + } + if(i < extf->cmd->argc) + continue; + strcat(line, " --\n"); + Xorriso_status_result(xorriso, filter, fp, flag&2); + } + if(xorriso->filter_list_closed) { + strcpy(line, "-close_filter_list\n"); + Xorriso_status_result(xorriso, filter, fp, flag&2); + } + return(1); +} + + +int Xorriso_stream_type(struct XorrisO *xorriso, IsoNode *node, + IsoStream *stream, char type_text[], int flag) +{ + int ret, lba; + char text[5]; + + strncpy(text, stream->class->type, 4); + text[4]= 0; + if(strcmp(text, "fsrc") == 0) { + ret= Xorriso__file_start_lba(node, &lba, 0); + if(ret > 0 && lba > 0) + strcpy(type_text, "image"); + else + strcpy(type_text, "disk"); + } else if(strcmp(text, "ziso") == 0) { + strcpy(type_text, "--zisofs"); + } else if(strcmp(text, "osiz") == 0) { + strcpy(type_text, "--zisofs-decode"); + } else if(strcmp(text, "gzip") == 0) { + strcpy(type_text, "--gzip"); + } else if(strcmp(text, "pizg") == 0) { + strcpy(type_text, "--gunzip"); + } else if(strcmp(text, "cout") == 0 || strcmp(text, "boot") == 0 || + strcmp(text, "user") == 0 || strcmp(text, "extf") == 0) { + strcpy(type_text, text); + } else { + Text_shellsafe(text, type_text, 0); + } + return(1); +} + +int Xorriso_show_stream(struct XorrisO *xorriso, void *in_node, + char *path, int flag) +{ + int ret; + IsoNode *node; + IsoFile *file; + IsoStream *stream= NULL, *input_stream; + IsoExternalFilterCommand *cmd; + char type_text[16], *source_path= NULL; + + node= (IsoNode *) in_node; + if(node == NULL) { + ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0); + if(ret <= 0) + goto ex; + } + if(!LIBISO_ISREG(node)) + {ret= 2; goto ex;} + file= (IsoFile *) node; + input_stream= iso_file_get_stream(file); + Text_shellsafe(path, xorriso->result_line, 0); + while(1) { + stream= input_stream; + input_stream= iso_stream_get_input_stream(stream, 0); + if(input_stream == NULL) + break; + strcat(xorriso->result_line, " < "); + Xorriso_stream_type(xorriso, node, stream, type_text, 0); + strcat(xorriso->result_line, type_text); + ret= iso_stream_get_external_filter(stream, &cmd, 0); + if(ret < 0) { + Xorriso_process_msg_queues(xorriso,0); + Xorriso_report_iso_error(xorriso, "", ret, + "Error when inquiring filter command of node", 0, "FAILURE", 1); + ret= 0; goto ex; + } + if(ret > 0) { + strcat(xorriso->result_line, ":"); + Text_shellsafe(cmd->name, xorriso->result_line, 1); + } + if(strlen(xorriso->result_line) > SfileadrL) { + Xorriso_result(xorriso, 0); + xorriso->result_line[0]= 0; + } + } + strcat(xorriso->result_line, " < "); + Xorriso_stream_type(xorriso, node, stream, type_text, 0); + strcat(xorriso->result_line, type_text); + + source_path= iso_stream_get_source_path(stream, 0); + if(source_path != NULL) { + strcat(xorriso->result_line, ":"); + Text_shellsafe(source_path, xorriso->result_line, 1); + } + + strcat(xorriso->result_line, "\n"); + Xorriso_result(xorriso, 0); + ret= 1; +ex:; + if(source_path != NULL) + free(source_path); + return(ret); +} + + +int Xorriso_set_zisofs_params(struct XorrisO *xorriso, int flag) +{ + int ret; + struct iso_zisofs_ctrl ctrl; + + ctrl.version= 0; + ctrl.compression_level= xorriso->zlib_level; + if(xorriso->zisofs_block_size == (1 << 16)) + ctrl.block_size_log2= 16; + else if(xorriso->zisofs_block_size == (1 << 17)) + ctrl.block_size_log2= 17; + else + ctrl.block_size_log2= 15; + ret= iso_zisofs_set_params(&ctrl, 0); + Xorriso_process_msg_queues(xorriso,0); + if(ret < 0) { + Xorriso_report_iso_error(xorriso, "", ret, + "Error when setting zisofs parameters", 0, "FAILURE", 1); + return(0); + } + return(1); +} + + +int Xorriso_status_zisofs(struct XorrisO *xorriso, char *filter, FILE *fp, + int flag) +/* + bit0= do only report non-default settings + bit1= do only report to fp +*/ +{ + off_t ziso_count= 0, osiz_count= 0; + off_t gzip_count= 0, gunzip_count= 0; + + iso_zisofs_get_refcounts(&ziso_count, &osiz_count, 0); + iso_gzip_get_refcounts(&gzip_count, &gunzip_count, 0); + if((flag & 1) && xorriso->zlib_level == xorriso->zlib_level_default && + xorriso->zisofs_block_size == xorriso->zisofs_block_size_default && + xorriso->zisofs_by_magic == 0 && + ziso_count == 0 && osiz_count == 0 && + gzip_count == 0 && gunzip_count == 0) { + if(filter == NULL) + return(2); + if(filter[0] == 0) + return 2; + } + sprintf(xorriso->result_line, + "-zisofs level=%d:block_size=%dk:by_magic=%s:ziso_used=%.f:osiz_used=%.f", + xorriso->zlib_level, xorriso->zisofs_block_size / 1024, + xorriso->zisofs_by_magic ? "on" : "off", + (double) ziso_count, (double) osiz_count); + sprintf(xorriso->result_line + strlen(xorriso->result_line), + ":gzip_used=%.f:gunzip_used=%.f\n", + (double) gzip_count, (double) gunzip_count); + Xorriso_status_result(xorriso, filter, fp, flag&2); + return(1); +} + + +int Xorriso_all_node_array(struct XorrisO *xorriso, int addon_nodes, int flag) +{ + int ret; + struct FindjoB *job= NULL; + struct stat dir_stbuf; + + ret= Findjob_new(&job, "/", 0); + if(ret<=0) { + Xorriso_no_findjob(xorriso, "xorriso", 0); + {ret= -1; goto ex;} + } + Findjob_set_action_target(job, 30, NULL, 0); + Xorriso_destroy_node_array(xorriso, 0); + ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0, NULL, "/", + &dir_stbuf, 0, 0); + if(ret <= 0) + goto ex; + ret= Xorriso_new_node_array(xorriso, xorriso->temp_mem_limit, addon_nodes, 0); + if(ret <= 0) + goto ex; + Findjob_set_action_target(job, 31, NULL, 0); + ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0, NULL, "/", + &dir_stbuf, 0, 0); + if(ret <= 0) + goto ex; + ret= 1; +ex:; + Findjob_destroy(&job, 0); + return(ret); +} + + +int Xorriso_remake_hln_array(struct XorrisO *xorriso, int flag) +{ + int ret, addon_nodes= 0, i, old_count, old_pt, new_pt; + IsoNode **old_nodes; + char **old_targets; + + /* Count hln_targets of which the node has been deleted meanwhile */ + for(i= 0; i < xorriso->hln_count; i++) { + if(xorriso->hln_targets[i] == NULL) + continue; + if(Xorriso_node_is_valid(xorriso, xorriso->hln_array[i], 0)) + continue; + addon_nodes++; + } + ret= Xorriso_all_node_array(xorriso, addon_nodes, 0); + if(ret <= 0) + goto ex; + if(addon_nodes > 0) { + /* Transfer delete nodes with hln_target to node array */ + for(i= 0; i < xorriso->hln_count; i++) { + if(xorriso->hln_targets[i] == NULL) + continue; + if(Xorriso_node_is_valid(xorriso, xorriso->hln_array[i], 0)) + continue; + if(xorriso->node_counter < xorriso->node_array_size) { + xorriso->node_array[xorriso->node_counter++]= xorriso->hln_array[i]; + iso_node_ref(xorriso->node_array[xorriso->node_counter - 1]); + } + } + } + + Xorriso_sort_node_array(xorriso, 0); + old_nodes= (IsoNode **) xorriso->hln_array; + old_targets= (char **) xorriso->hln_targets; + old_count= xorriso->hln_count; + xorriso->hln_array= 0; + xorriso->hln_targets= NULL; + + /* Transfer node_array to di_array without unrefering nodes */ + xorriso->hln_count= xorriso->node_counter; + xorriso->hln_array= xorriso->node_array; + xorriso->node_counter= 0; + xorriso->node_array_size= 0; + xorriso->node_array= NULL; + + /* Allocate hln_targets */ + ret= Xorriso_new_hln_array(xorriso, xorriso->temp_mem_limit, 1); + if(ret<=0) + goto ex; + xorriso->node_targets_availmem= xorriso->temp_mem_limit; + if(old_targets != NULL) { + /* Transfer targets from old target array */; + new_pt= old_pt= 0; + while(new_pt < xorriso->hln_count && old_pt < old_count) { + ret= Xorriso__hln_cmp(xorriso->hln_array[new_pt], old_nodes[old_pt]); + if(ret < 0) { + new_pt++; + } else if(ret > 0) { + old_pt++; + } else { + xorriso->hln_targets[new_pt]= old_targets[old_pt]; + if(old_targets[old_pt] != NULL) + xorriso->temp_mem_limit-= strlen(old_targets[old_pt]) + 1; + old_targets[old_pt]= NULL; + new_pt++; + old_pt++; + } + } + for(old_pt= 0; old_pt < old_count; old_pt++) + if(old_targets[old_pt] != NULL) /* (should not happen) */ + free(old_targets[old_pt]); + free((char *) old_targets); + } + if(old_nodes != NULL) { + for(old_pt= 0; old_pt < old_count; old_pt++) + if(old_nodes[old_pt] != NULL) + iso_node_unref(old_nodes[old_pt]); + free((char *) old_nodes); + } + xorriso->hln_change_pending= 0; + ret= 1; +ex:; + return(ret); +} + + +/* @param flag bit0= overwrite existing hln_array (else return 2) +*/ +int Xorriso_make_hln_array(struct XorrisO *xorriso, int flag) +{ + int ret; + + if(xorriso->hln_array != NULL && !(flag & 1)) { + /* If no fresh image manipulations occured: keep old array */ + if(!xorriso->hln_change_pending) + return(2); + ret= Xorriso_remake_hln_array(xorriso, 0); + return(ret); + } + Xorriso_destroy_hln_array(xorriso, 0); + + ret= Xorriso_all_node_array(xorriso, 0, 0); + if(ret <= 0) + goto ex; + Xorriso_sort_node_array(xorriso, 0); + + /* Transfer node_array to di_array without unrefering nodes */ + xorriso->hln_count= xorriso->node_counter; + xorriso->hln_array= xorriso->node_array; + xorriso->node_counter= 0; + xorriso->node_array_size= 0; + xorriso->node_array= NULL; + + /* Allocate hln_targets */ + ret= Xorriso_new_hln_array(xorriso, xorriso->temp_mem_limit, 1); + if(ret<=0) { + Xorriso_destroy_hln_array(xorriso, 0); + goto ex; + } + xorriso->node_targets_availmem= xorriso->temp_mem_limit; + xorriso->hln_change_pending= 0; + ret= 1; +ex:; + return(ret); +} + + +/* @param flag bit0= overwrite existing di_array (else return 2) + bit1= make di_array despite xorriso->ino_behavior bit 3 +*/ +int Xorriso_make_di_array(struct XorrisO *xorriso, int flag) +{ + int ret, bytes; + +#ifdef NIX + /* <<< */ + unsigned long old_gdic; + old_gdic= Xorriso_get_di_counteR; +#endif /* NIX */ + + if((xorriso->ino_behavior & 8 ) && !(flag & 2)) + return(2); + if(xorriso->di_array != NULL && !(flag & 1)) + return(2); + Xorriso_finish_hl_update(xorriso, 0); + + ret= Xorriso_all_node_array(xorriso, 0, 0); + if(ret <= 0) + goto ex; + bytes= xorriso->node_array_size / 8 + 1; + xorriso->di_do_widen= calloc(bytes, 1); + if(xorriso->di_do_widen == NULL) { + Xorriso_no_malloc_memory(xorriso, NULL, 0); + ret= -1; goto ex; + } + + /* Transfer node_array to di_array without unrefering nodes */ + xorriso->di_count= xorriso->node_counter; + xorriso->di_array= xorriso->node_array; + xorriso->node_counter= 0; + xorriso->node_array_size= 0; + xorriso->node_array= NULL; + + Xorriso__sort_di((void *) xorriso->di_array, xorriso->di_count, 0); + + ret= 1; +ex:; + +#ifdef NIX +/* <<< */ + fprintf(stderr, "xorriso_DEBUG: sort_count= %lu\n", + Xorriso_get_di_counteR - old_gdic); +#endif /* NIX */ + + return(ret); +} + + +/* + @param flag bit0= iso_rr_path is freshly added and up to date + bit2= -follow: this is not a command parameter + @return -1= severe error + 0= not applicable for hard links + 1= go on with processing + 2= iso_rr_path is fully updated + */ +int Xorriso_hardlink_update(struct XorrisO *xorriso, int *compare_result, + char *disk_path, char *iso_rr_path, int flag) +{ + int ret, hret, idx, low, high, i, do_overwrite= 0, did_fake_di= 0; + int follow_links, old_idx= -1; + IsoNode *node; + struct stat stbuf; + dev_t old_dev; + ino_t old_ino; + + if(xorriso->di_array == NULL) + return(1); + follow_links= xorriso->do_follow_links || + (xorriso->do_follow_param && !(flag & 4)); + ret= Xorriso_node_from_path(xorriso, NULL, iso_rr_path, &node, 0); + if(ret <= 0) + return(ret); + if(LIBISO_ISDIR(node)) + return(1); + + /* Handle eventual hardlink split : */ + /* This is achieved by setting the content change bit. Reason: + The node needs to be removed from di_array because its di is + not matching its array index any more. So it becomes invisible for + the join check of eventual later hardlink siblings. Therefore + it must be updated now, even if it has currently no siblings + which it leaves or which it joins. + */ + if(!(flag & 1)) + do_overwrite= 1; + + Xorriso__get_di(node, &old_dev, &old_ino, 0); + ret= Xorriso__search_node(xorriso->di_array, xorriso->di_count, + Xorriso__di_cmp, node, &idx, 0); + if(ret < 0) + {ret= 0; goto ex;} + if(ret > 0) + old_idx= idx; + + /* Handle eventual hardlink joining : */ + + if(follow_links) + ret= stat(disk_path, &stbuf); + else + ret= lstat(disk_path, &stbuf); + if(ret==-1) + {ret= 0; goto ex;} + + /* Are there new dev-ino-siblings in the image ? */ + /* Fake isofs.di */ + if(!(flag & 1)) { + ret= Xorriso_record_dev_inode(xorriso, disk_path, stbuf.st_dev, + stbuf.st_ino, node, iso_rr_path, 1); + if(ret <= 0) + {ret= -1; goto ex;} + did_fake_di= 1; + /* temporarily remove node from di_array so it does not disturb + search by its fake di info */; + if(old_idx >= 0) + xorriso->di_array[old_idx]= NULL; + } + ret= Xorriso_search_di_range(xorriso, node, &idx, &low, &high, 1); + if(did_fake_di) { + /* Revoke fake of isofs.di */ + hret= Xorriso_record_dev_inode(xorriso, disk_path, old_dev, old_ino, + node, iso_rr_path, 1); + if(hret <= 0) + {ret= -1; goto ex;} + if(old_idx >= 0) + xorriso->di_array[old_idx]= node; + } + if(ret == 0) + {ret= 1; goto ex;} + if(ret < 0) + {ret= 0; goto ex;} + + +#ifdef Xorriso_hardlink_update_debuG + /* <<< */ + if(low < high || idx < 0) { + fprintf(stderr, + "xorriso_DEBUG: old_idx= %d , low= %d , high= %d , iso= '%s' , disk='%s'\n", + old_idx, low, high, iso_rr_path, disk_path); + fprintf(stderr, + "xorriso_DEBUG: old_dev= %lu , old_ino= %lu , dev= %lu , ino= %lu\n", + (unsigned long) old_dev, (unsigned long) old_ino, + (unsigned long) stbuf.st_dev, (unsigned long) stbuf.st_ino); + + if(idx >= 0 && idx != old_idx) + fprintf(stderr, "xorriso_DEBUG: idx= %d , old_idx = %d\n", idx, old_idx); + } +#endif /* Xorriso_hardlink_update_debuG */ + + /* Overwrite all valid siblings : */ + for(i= low; i <= high; i++) { + if(i == idx || xorriso->di_array[i] == NULL) + continue; + +#ifdef Xorriso_hardlink_update_debuG + /* <<< */ +{ + ino_t ino; + dev_t dev; + + Xorriso__get_di(xorriso->di_array[i], &dev, &ino, 0); + fprintf(stderr, "xorriso_DEBUG: iso_sibling= '%s' , dev= %lu , ino= %lu\n", + node_path, (unsigned long) dev, (unsigned long) ino); +} +#endif /* Xorriso_hardlink_update_debuG */ + + xorriso->di_do_widen[i / 8]|= 1 << (i % 8); + } + + ret= 1; +ex:; + if(do_overwrite) + *compare_result|= (1<<15); + if(old_idx >= 0 && (*compare_result & (3 << 21))) { + /* The old di info is obsolete */ + if(xorriso->di_array[old_idx] != NULL) + iso_node_unref(xorriso->di_array[old_idx]); + xorriso->di_array[old_idx]= NULL; + } + return(ret); +} + + +/* @param flag bit0= do not destroy di_array +*/ +int Xorriso_finish_hl_update(struct XorrisO *xorriso, int flag) +{ + int ret, zero= 0; + char *argv[4]; + struct Xorriso_lsT *disk_lst, *iso_lst; + + if(xorriso->di_array == NULL) + {ret= 1; goto ex;} + disk_lst= xorriso->di_disk_paths; + iso_lst= xorriso->di_iso_paths; + while(disk_lst != NULL && iso_lst != NULL) { + argv[0]= Xorriso_lst_get_text(iso_lst, 0); + argv[1]= "-exec"; + argv[2]= "widen_hardlinks"; + argv[3]= Xorriso_lst_get_text(disk_lst, 0); + zero= 0; + ret= Xorriso_option_find(xorriso, 4, argv, &zero, 0); /* -findi */ + if(ret < 0) + goto ex; + disk_lst= Xorriso_lst_get_next(disk_lst, 0); + iso_lst= Xorriso_lst_get_next(iso_lst, 0); + } + ret= 1; +ex:; + if(!(flag & 1)) + Xorriso_destroy_di_array(xorriso, 0); + return(ret); +} + + +/* + @param flag bit0= do not report to result but only retrieve md5 text + @return 1= ok, 0= no md5 available, <0= other error +*/ +int Xorriso_get_md5(struct XorrisO *xorriso, void *in_node, char *path, + char md5[16], int flag) +{ + int ret= 1, i; + char *wpt; + IsoImage *image; + IsoNode *node; + + ret= Xorriso_get_volume(xorriso, &image, 0); + if(ret <= 0) + goto ex; + node= (IsoNode *) in_node; + if(node == NULL) { + ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0); + if(ret<=0) + goto ex; + } + if(!LIBISO_ISREG(node)) + return(0); + ret= iso_file_get_md5(image, (IsoFile *) node, md5, 0); + Xorriso_process_msg_queues(xorriso,0); + if(ret <= 0) + goto ex; + if(flag & 1) + {ret= 1; goto ex;} + + wpt= xorriso->result_line; + for(i= 0; i < 16; i++) { + sprintf(wpt, "%2.2x", ((unsigned char *) md5)[i]); + wpt+= 2; + } + strcpy(wpt, " "); + wpt+= 2; + Xorriso_getfname(xorriso, path, 1 | 2); + ret= 1; +ex:; + return(ret); +} + + +int Xorriso_make_md5(struct XorrisO *xorriso, void *in_node, char *path, + int flag) +{ + int ret; + off_t size; + IsoNode *node; + + node= (IsoNode *) in_node; + if(node == NULL) { + ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0); + if(ret <= 0) + return(ret); + } + if(!LIBISO_ISREG(node)) + return(0); + ret= iso_file_make_md5((IsoFile *) node, 0); + size= iso_file_get_size((IsoFile *) node); + xorriso->pacifier_count+= size; + xorriso->pacifier_byte_count+= size; + Xorriso_pacifier_callback(xorriso, "content bytes read", + xorriso->pacifier_count, 0, "", 0); + Xorriso_process_msg_queues(xorriso, 0); + if(ret < 0) { + Xorriso_report_iso_error(xorriso, "", ret, + "Error when computing MD5", 0, "FAILURE", 1); + return(0); + } + Xorriso_set_change_pending(xorriso, 1); + return(1); +} + + +/* @param node Opaque handle to IsoNode which is to be inquired instead of path if it is not NULL. + @param path is used as address if node is NULL. + @param flag bit0= do not report to result but only indicate outcome + by return value + bit1= silently ignore nodes without MD5 + bit2= do not only report mismatches but also matches + @return 3= not a data file + 2= no MD5 attached to node + 1= ok, MD5 compared and matching + 0= not ok, MD5 mismatch + <0= other error +*/ +int Xorriso_check_md5(struct XorrisO *xorriso, void *in_node, char *path, + int flag) +{ + int ret, wanted, rret; + IsoImage *image; + IsoNode *node; + IsoFile *file; + char node_md5[16], data_md5[16], buffer[64 * 1024]; + void *stream= NULL, *ctx= NULL; + off_t todo; + + node= (IsoNode *) in_node; + if(node == NULL) { + ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0); + if(ret<=0) + {ret= -1; goto ex;} + } + if(!LIBISO_ISREG(node)) { + strcpy(xorriso->info_text, "-check_md5: Not a data file: "); + Text_shellsafe(path, xorriso->info_text, 1); + if(!(flag & 2)) + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + ret= 3; goto ex; + } + file= (IsoFile *) node; + + /* obtain MD5 */ + ret= Xorriso_get_volume(xorriso, &image, 0); + if(ret <= 0) + {ret= -1; goto ex;} + ret= iso_file_get_md5(image, file, node_md5, 0); + Xorriso_process_msg_queues(xorriso,0); + if(ret < 0) + {ret= -1; goto ex;} + if(ret == 0) { + strcpy(xorriso->info_text, "-check_md5: No MD5 recorded with file: "); + Text_shellsafe(path, xorriso->info_text, 1); + if(!(flag & 2)) + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + ret= 2; goto ex; + } + + /* Read file and compute MD5 */; + ret= Xorriso_iso_file_open(xorriso, path, (void *) node, &stream, 1 | 2); + if(ret <= 0) + {ret= -1; goto ex;} + ret= iso_md5_start(&ctx); + if(ret < 0) + goto ex; + todo= iso_stream_get_size(stream); + while(todo > 0) { + if(todo < sizeof(buffer)) + wanted= todo; + else + wanted= sizeof(buffer); + rret = Xorriso_iso_file_read(xorriso, stream, buffer, wanted, 0); + if(rret <= 0) + {ret= -1; goto ex;} + todo-= rret; + ret = iso_md5_compute(ctx, buffer, rret); + if(ret < 0) + goto ex; + xorriso->pacifier_count+= rret; + xorriso->pacifier_byte_count+= rret; + Xorriso_pacifier_callback(xorriso, "content bytes read", + xorriso->pacifier_count, 0, "", 0); + } + ret= iso_md5_end(&ctx, data_md5); + if(ret < 0) + goto ex; + + /* Report outcome */ + Xorriso_process_msg_queues(xorriso,0); + if(! iso_md5_match(node_md5, data_md5)) { + sprintf(xorriso->result_line, "MD5 MISMATCH: "); + Text_shellsafe(path, xorriso->result_line, 1); + strcat(xorriso->result_line, "\n"); + if(!(flag & 1)) + Xorriso_result(xorriso,0); + ret= 0; + } else { + sprintf(xorriso->result_line, "md5 match : "); + Text_shellsafe(path, xorriso->result_line, 1); + strcat(xorriso->result_line, "\n"); + if(flag & 4) + Xorriso_result(xorriso,0); + ret= 1; + } + +ex:; + Xorriso_process_msg_queues(xorriso,0); + Xorriso_iso_file_close(xorriso, &stream, 0); + if(ctx != NULL) + iso_md5_end(&ctx, data_md5); + return(ret); +} + + +int Xorriso_check_md5_range(struct XorrisO *xorriso, off_t start_lba, + off_t end_lba, char md5[16], int flag) +{ + int ret; + struct burn_drive_info *dinfo= NULL; + struct burn_drive *drive= NULL; + off_t pos, data_count, to_read; + char data[64 * 1024], data_md5[16]; + void *ctx = NULL; + + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to check session MD5 checksum", 0); + if(ret <= 0) + goto ex; + ret= iso_md5_start(&ctx); + if(ret <= 0) { + Xorriso_no_malloc_memory(xorriso, NULL, 0); + goto ex; + } + for(pos= start_lba; pos < end_lba; pos+= 32) { + to_read= 32; + if(pos + to_read > end_lba) + to_read= end_lba - pos; + ret= burn_read_data(drive, pos * (off_t) 2048, data, + to_read * (off_t) 2048, &data_count, 0); + if(ret <= 0) + goto ex; + iso_md5_compute(ctx, data, (int) data_count); + xorriso->pacifier_count+= data_count; + xorriso->pacifier_byte_count+= data_count; + Xorriso_pacifier_callback(xorriso, "content bytes read", + xorriso->pacifier_count, 0, "", 0); + } + iso_md5_end(&ctx, data_md5); + ret= 1; + if(! iso_md5_match(md5, data_md5)) + ret= 0; +ex:; + Xorriso_process_msg_queues(xorriso,0); + if(ctx != NULL) + iso_md5_end(&ctx, data_md5); + return(ret); +} + + +int Xorriso_check_session_md5(struct XorrisO *xorriso, char *severity, + int flag) +{ + int ret, i; + IsoImage *image; + uint32_t start_lba, end_lba; + char md5[16], md5_text[33]; + + ret= Xorriso_get_volume(xorriso, &image, 0); + if(ret<=0) + return(ret); + ret= iso_image_get_session_md5(image, &start_lba, &end_lba, md5, 0); + Xorriso_process_msg_queues(xorriso,0); + if(ret < 0) + return(ret); + if(ret == 0) { + sprintf(xorriso->info_text, + "No session MD5 is recorded with the loaded session"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0); + return(0); + } + + sprintf(xorriso->info_text, "Checking loaded session by its recorded MD5.\n"); + Xorriso_info(xorriso, 0); + for(i= 0; i < 16; i++) + sprintf(md5_text + 2 * i, "%2.2x", ((unsigned char *) md5)[i]); + sprintf(xorriso->result_line, + "Session MD5 %s , LBA %.f , %.f blocks\n", + md5_text, (double) start_lba, (double) end_lba - start_lba); + Xorriso_result(xorriso,0); + ret= Xorriso_check_md5_range(xorriso, (off_t) start_lba, (off_t) end_lba, + md5, 0); + return(ret); +} + + +int Xorriso_image_has_md5(struct XorrisO *xorriso, int flag) +{ + int ret; + IsoImage *image; + uint32_t start_lba, end_lba; + char md5[16]; + + ret= Xorriso_get_volume(xorriso, &image, 0); + if(ret<=0) + return(ret); + ret= iso_image_get_session_md5(image, &start_lba, &end_lba, md5, 0); + Xorriso_process_msg_queues(xorriso,0); + if(ret <= 0) + return(0); + return(1); +} + + +int Xorriso_md5_start(struct XorrisO *xorriso, void **ctx, int flag) +{ + int ret; + + ret= iso_md5_start(ctx); + if(ret == 1) + return(1); + Xorriso_no_malloc_memory(xorriso, NULL, 0); + return(-1); +} + + +int Xorriso_md5_compute(struct XorrisO *xorriso, void *ctx, + char *data, int datalen, int flag) +{ + iso_md5_compute(ctx, data, datalen); + return(1); +} + + +int Xorriso_md5_end(struct XorrisO *xorriso, void **ctx, char md5[16], + int flag) +{ + int ret; + + ret= iso_md5_end(ctx, md5); + Xorriso_process_msg_queues(xorriso,0); + if(ret <= 0) + return(0); + return(1); +} + + +/* @param flag bit0=input drive + bit1=output drive +*/ +int Xorriso_drive_snooze(struct XorrisO *xorriso, int flag) +{ + int in_is_out_too, ret; + struct burn_drive_info *dinfo; + struct burn_drive *drive; + + in_is_out_too= (xorriso->in_drive_handle == xorriso->out_drive_handle); + if((flag & 1) && xorriso->in_drive_handle != NULL) { + Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to calm drive", 0); + burn_drive_snooze(drive, 0); + if(in_is_out_too) + {ret= 1; goto ex;} + } + if((flag&2) && xorriso->out_drive_handle!=NULL) { + Xorriso_get_drive_handles(xorriso, &dinfo, &drive, + "on attempt to calm drive", 2); + burn_drive_snooze(drive, 0); + } + ret= 1; +ex:; + Xorriso_process_msg_queues(xorriso,0); + return(ret); +} + + diff --git a/libisoburn/branches/ZeroFourTwo/xorriso/xorrisoburn.h b/libisoburn/branches/ZeroFourTwo/xorriso/xorrisoburn.h new file mode 100644 index 00000000..37153cf5 --- /dev/null +++ b/libisoburn/branches/ZeroFourTwo/xorriso/xorrisoburn.h @@ -0,0 +1,491 @@ + + +/* Adapter to libisoburn, libisofs and libburn for xorriso, + a command line oriented batch and dialog tool which creates, loads, + manipulates and burns ISO 9660 filesystem images. + + Copyright 2007-2009 Thomas Schmitt, + + Provided under GPL version 2. + + This file contains the inner isofs- and burn-library interface of xorriso. +*/ + +#ifndef Xorrisoburn_includeD +#define Xorrisoburn_includeD yes + + +/* The minimum version of libisoburn to be used with this version of xorriso +*/ +#define xorriso_libisoburn_req_major 0 +#define xorriso_libisoburn_req_minor 4 +#define xorriso_libisoburn_req_micro 1 + + +struct SpotlisT; /* List of intervals with different read qualities */ +struct CheckmediajoB; /* Parameters for Xorriso_check_media() */ + + +int Xorriso_startup_libraries(struct XorrisO *xorriso, int flag); + +/* @param flag bit0= global shutdown of libraries */ +int Xorriso_detach_libraries(struct XorrisO *xorriso, int flag); + +int Xorriso_create_empty_iso(struct XorrisO *xorriso, int flag); + +/* @param flag bit0=aquire as isoburn input drive + bit1=aquire as libburn output drive (as isoburn drive if bit0) + @return <=0 failure , 1=success , 2=neither readable or writeable +*/ +int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag); + +int Xorriso_give_up_drive(struct XorrisO *xorriso, int flag); + +int Xorriso_write_session(struct XorrisO *xorriso, int flag); + +/* @param boss_iter Opaque handle to be forwarded to actions in ISO image + Set to NULL if calling this function from outside ISO world + @param flag bit0= mkdir: graft in as empty directory, not as copy from disk + bit1= do not report added files + @return <=0 = error , 1 = added simple node , 2 = added directory +*/ +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); + +/* @param flag bit0=report about output drive + bit1=short report form + bit2=do not try to read ISO heads + bit3=report to info channel (else to result channel) +*/ +int Xorriso_toc(struct XorrisO *xorriso, int flag); + +/* @param flag bit0= no output if no boot record was found + bit3= report to info channel (else to result channel) +*/ +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); + +/* @param flag bit0=fast , bit1=deformat + @return 0=failure, did not touch media , -1=failure, altered media + 1=success, altered media , 2=success, did not touch media +*/ +int Xorriso_blank_media(struct XorrisO *xorriso, int flag); + +/* @param flag bit0= try to achieve faster formatting + bit1= use parameter size (else use default size) + bit2= do not re-aquire drive + bit7= by_index mode: + bit8 to bit15 contain the index of the format to use. + @return 0=failure, did not touch media , -1=failure, altered media + 1=success, altered media , 2=success, did not touch media +*/ +int Xorriso_format_media(struct XorrisO *xorriso, off_t size, int flag); + +/* @return <=0 error, 1 success +*/ +int Xorriso_list_formats(struct XorrisO *xorriso, int flag); + +/* @param flag bit1= obtain outdrive, else indrive + @return <=0 error, 1 success +*/ +int Xorriso_list_profiles(struct XorrisO *xorriso, int flag); + +/* @param flag bit2= formatting rather than blanking + @return 0=failure, did not touch media , -1=failure, altered media + 1=success, altered media , 2=success, did not touch media +*/ +int Xorriso_blank_as_needed(struct XorrisO *xorriso, int flag); + + +/* @param boss_iter Opaque internal handle. Use NULL outside xorrisoburn.c : + If not NULL then this is an iterator suitable for + iso_dir_iter_remove() which is then to be used instead + of iso_node_remove(). + @param flag bit0= remove whole sub tree: rm -r + bit1= remove empty directory: rmdir + bit2= recursion: do not reassure in mode 2 "tree" + bit3= this is for overwriting and not for plain removal + @return <=0 = error + 1 = removed simple node + 2 = removed directory or tree + 3 = did not remove on user revocation +*/ +int Xorriso_rmi(struct XorrisO *xorriso, void *boss_iter, off_t boss_mem, + char *path, int flag); + +/* @param flag bit0= long format + bit1= do not print count of nodes + bit2= du format + bit3= print directories as themselves (ls -d) +*/ +int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd, + int filec, char **filev, off_t boss_mem, int flag); + +/* This function needs less buffer memory than Xorriso_ls_filev() but cannot + perform structured pattern matching. + @param flag bit0= long format + bit1= only check for directory existence + bit2= do not apply search pattern but accept any file + bit3= just count nodes and return number +*/ +int Xorriso_ls(struct XorrisO *xorriso, int flag); + +/* @param wd Path to prepend in case img_path is not absolute + @param img_path Absolute or relative path to be normalized + @param eff_path returns resulting effective path. + Must provide at least SfileadrL bytes of storage. + @param flag bit0= do not produce problem events (unless faulty path format) + bit1= work purely literally, do not use libisofs + bit2= (with bit1) this is an address in the disk world + @return -1 = faulty path format, 0 = not found , + 1 = found simple node , 2 = found directory +*/ +int Xorriso_normalize_img_path(struct XorrisO *xorriso, char *wd, + char *img_path, char eff_path[], int flag); + +/* @param boss_iter Opaque handle to be forwarded to actions in ISO image + Set to NULL if calling this function from outside ISO world +*/ +int Xorriso_rename(struct XorrisO *xorriso, void *boss_iter, + char *origin, char *dest, int flag); + +/* @param flag bit0= do not produce info message on success + @return 1=success, 0=was already directory, -1=was other type, -2=bad path +*/ +int Xorriso_mkdir(struct XorrisO *xorriso, char *img_path, int flag); + +/* @param flag bit0= a match count !=1 is a SORRY event */ +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); + +/* @parm flag bit0= atime, bit1= ctime, bit2= mtime, bit8=no auto ctime */ +int Xorriso_set_time(struct XorrisO *xorriso, char *in_path, time_t t, + int flag); + +/* @param flag bit0= recursion + bit1= do not count deleted files with rm and rm_r +*/ +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); + +/* @param flag bit0= do not dive into trees + bit1= do not perform job->action on resulting node array +*/ +int Xorriso_findi_sorted(struct XorrisO *xorriso, struct FindjoB *job, + off_t boss_mem, int filec, char **filev, int flag); + +/* @param flag bit0= do not mark image as changed */ +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); + +/* @return 0= stbuf content is valid , + -1 = path not found , -2 = severe error occured +*/ +int Xorriso_iso_lstat(struct XorrisO *xorriso, char *path, struct stat *stbuf, + int flag); + +/* @param flag bit0= -inq + bit1= -checkdrive +*/ +int Xorriso_atip(struct XorrisO *xorriso, int flag); + +/* @param write_start_address is valid if >=0 + @param tsize is valid if >0 + @param flag bit0= grow_overwriteable_iso + bit1= do_isosize +*/ +int Xorriso_burn_track(struct XorrisO *xorriso, off_t write_start_address, + char *track_source, off_t tsize, int flag); + +/* @param flag bit1= outdev rather than indev + @return <=0 = failure , 1= ok , 2= ok, is CD profile +*/ +int Xorriso_get_profile(struct XorrisO *xorriso, int *profile_number, + char profile_name[80], int flag); + +/* @param flag bit0= node_pt is a valid ISO object handle, ignore pathname + bit1= dig out the most original stream for reading +*/ +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); + +/* @param bit0= copy link target properties rather than link properties +*/ +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); + +struct SplitparT; + +/* @param flag bit0= in_node is valid, do not resolve iso_adr +*/ +int Xorriso_identify_split(struct XorrisO *xorriso, char *iso_adr, + void *in_node, + struct SplitparT **parts, int *count, + struct stat *total_stbuf, int flag); + +/* @param flag bit0= node is valid, do not resolve path + bit1= insist in complete collection of part files +*/ +int Xorriso_is_split(struct XorrisO *xorriso, char *path, void *node, + int flag); + + +/* @param flag + >>> bit0= mkdir: graft in as empty directory, not as copy from iso + bit1= do not report copied files + bit2= -follow, -not_*: this is not a command parameter + bit3= use offset and cut_size for -paste_in + bit4= return 3 on rejection by exclusion or user + bit5= if directory then do not add sub tree + bit6= this is a copy action: do not fake times and ownership + @return <=0 = error , 1 = added leaf file object , 2 = added directory , + 3 = rejected +*/ +int Xorriso_restore(struct XorrisO *xorriso, + char *img_path, char *disk_path, + off_t offset, off_t cut_size, int flag); + + +/* @param flag bit0= in_node is valid, do not resolve img_path +*/ +int Xorriso_restore_is_identical(struct XorrisO *xorriso, void *in_node, + char *img_path, char *disk_path, + char type_text[5], int flag); + + +/* Return the official libburn address of an address string. This may fail + if the string does not constitute a valid drive address. + @param official_adr must offer SfileadrL bytes of reply buffer + @return 1 = success , 0 = failure , -1 = severe error +*/ +int Xorriso_libburn_adr(struct XorrisO *xorriso, char *address_string, + char official_adr[], int flag); + + +/* @param flag bit1= obtain info from outdev +*/ +int Xorriso_msinfo(struct XorrisO *xorriso, int *msc1, int *msc2, int flag); + +/* + @param flag bit0= obtain iso_lba from indev + bit1= head_buffer already contains a valid head + bit2= issue message about success + bit3= check whether source blocks are banned by in_sector_map +*/ +int Xorriso_update_iso_lba0(struct XorrisO *xorriso, int iso_lba, int isosize, + char *head_buffer, struct CheckmediajoB *job, + 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); + +/* @param flag bit0= allocate xorriso->node_targets too +*/ +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_relax_compliance(struct XorrisO *xorriso, char *mode, + int flag); + +/* @return 1=ok 2=ok, is default setting */ +int Xorriso_get_relax_text(struct XorrisO *xorriso, char mode[1024], + int flag); + + +/** + @param flag bit0= print mount command to result channel rather than + performing it +*/ +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); + + +/* @param node Opaque handle to IsoNode which is to be inquired instead of + path if it is not NULL. + @param path is used as address if node is NULL. + @param acl_text if acl_text is not NULL, then *acl_text will be set to the + ACL text (without comments) of the file object. In this + case it finally has to be freed by the caller. + @param flag bit0= do not report to result but only retrieve ACL text + bit1= just check for existence of ACL, do not allocate and + set acl_text but return 1 or 2 + @return 2 ok, no ACL available, eventual *acl_text will be NULL + 1 ok, ACL available, eventual *acl_text stems from malloc() + <=0 error +*/ +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); + +/* Calls iso_image_set_ignore_aclea() according to xorriso->do_aaip */ +int Xorriso_set_ignore_aclea(struct XorrisO *xorriso, int flag); + + +/* @param node Opaque handle to IsoNode which is to be manipulated + instead of path if it is not NULL. + @param path is used as address if node is NULL. + @param access_text "access" ACL in long text form + @param default_text "default" ACL in long text form + @param flag Unused yet, submit 0 + @return >0 success , <=0 failure +*/ +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_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); + +/* @param flag bit0= delete filter with the given name +*/ +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); + +/* @param flag bit0= overwrite existing di_array (else return 2) +*/ +int Xorriso_make_di_array(struct XorrisO *xorriso, int flag); + +/* @param flag bit0= overwrite existing hln_array (else return 2) +*/ +int Xorriso_make_hln_array(struct XorrisO *xorriso, int flag); + +/* + @param flag bit2= -follow: this is not a command parameter + @return -1= severe error + 0= not applicable for hard links + 1= go on with processing + 2= iso_rr_path is fully updated +*/ +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); + +/* @param flag bit0=input drive + bit1=output drive +*/ +int Xorriso_drive_snooze(struct XorrisO *xorriso, int flag); + + +/* A pseudo file type for El-Torito bootsectors as in man 2 stat : + For now take the highest possible value. +*/ +#define Xorriso_IFBOOT S_IFMT + + +#endif /* Xorrisoburn_includeD */ +