bug-tar
[Top][All Lists]
Advanced

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

[Bug-tar] Bug/Improvement: Vanishing Directories during incremental dump


From: Jonas Julino
Subject: [Bug-tar] Bug/Improvement: Vanishing Directories during incremental dump: Exit with TAREXIT_DIFFERS
Date: Fri, 28 Apr 2017 11:15:23 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

Hello,

my Team and I found a behaviour of tar which I assume is a bug or a
possibility for an improvement. I tested with tar versions: 1.27
and 1.29.

Current Behaviour (1.27/1.29):
------------------------------
In case a directory in a deep directory is removed during
creation of an incremental tar file, tar exits with a
TAREXIT_FAILURE (==2).

This is the same issue as tested by test-case 'filerem01.at' of
the tar testsuite. However, the test-case tests the deletion of
a file and not of a directory.

Expected Behaviour:
-------------------
Tar should exit with TAREXIT_DIFFERS (==1).

Reason: I have use-cases where not only files, but also complete
        folders vanish during creation of the archive.

        To be able to distinguish these cases from other serious
        issues like actual I/O errors I would like to have the
        same behaviour as for vanishing files
        (i.e., exit-code == 1).



Test-cases:
===========
During my experiments to reproduce the issues I experienced, I
created two test-cases dirrem01.at and dirrem02.at based on the
test-cases filerem01/02.at:


dirrem01.at: Exit with TAREXIT_DIFFERS for the scenario
             described above
dirrem02.at: Still exit with TAREXIT_FAILURE if an explicitly
             named directory vanishes

Attached file: 0002-Test-handling-of-directories-removed-during-incremen.patch



A Trivial Patch Idea:
=====================
Based on these two test-cases I created a patch modifying
create_archive() to produce the behaviour I expected:

Attached file: 0001-Fix-handling-of-directories-removed-during-increment.patch (The patch is based on release_1_29 / 20b55f0679d314568ec21ae6db1ea635494e292b)

This was the first time I took a look into the gnu tar
source-code, therefore I try to provide a rather detailed
explanation on why I assume this patch could be a valid
modification.

If I missed anything I am more than happy to hear your comments.


Behaviour when create_archive(...) fails to open or stat a
directory:
 - Remark: '->' depicts a function call

 - Old Behaviour: open_diag()/stat_diag() is called.
   -------------------------------------------------
   open_diag()/stat_diag():
     if(!ignore_failed_read_option)
     -----------------------------
          -> open_error()/stat_error() -> call_arg_error()
             -> ERROR()<i> -> error()

           => <i>: exit_status = PAXEXIT_FAILURE (==2);
           => processing is continued

           (<i>: call to func ptr error_hook / func
            checkpoint_flush_actions not further discussed here)
     else
     ----
          -> open_warn()/stat_warn() -> call_arg_warn() -> WARN()
             -> error()

          => no modification of exit_status
          => processing is continued

 - New Behaviour: file_removed_diag() is called.
   ---------------------------------------------
   file_removed_diag():
     if(!top_level && errno == ENOENT))
     ----------------------------------
        -> set_exit_status(TAREXIT_DIFFERS) <ii>

        => <ii>: exit_status = TAREXIT_DIFFERS (if not already >=
           TAREXIT_DIFFERS)
        => processing is continued

     else
     ----
        -> open_diag()/stat_diag() [=> old behaviour]


=> Both, the patched and the non-patched code do not immediately
   terminate the execution, the difference is the exit-code.
   As far as I can see, this is the only difference (besides the
   modified text-output).

Table I: Exit-codes of patch / non-patched code
               |Case depicted  | Case depicted in dirrem01.at + |
               |in dirrem01.at |           --ignore-failed-read |
-----------------------------------------------------------------
Non-Patched  : |             2 |                              0 |
-----------------------------------------------------------------
Patched      : |             1 |                              1 |



Open issues I am aware of:
--------------------------
 - Wrong text output (File vs. Directory)
   Output of dirrem01.at: "dir/sub: File removed before we read
                           it"

   I assume a function dir_removed_diag should be added and
   used, similar to file_removed_diag.

 - Test-cases are only executed for gnu

Open questions from my side:
----------------------------
 - Are the modified locations sufficient? (i.e., are there other
   locations in the code which I may have missed; in particular code
   which will be triggered on subsequent incremental tar runs)

 - Assuming I did not miss anything and the only relevant
   difference between the patched / non-patched code is the
   modified exit-code:

   The patch leads to a scenario (dirrem01.at) where tar was
   returning TAREXIT_FAILURE and now returns TAREXIT_DIFFERS
   instead.
   The content of the resulting archive should be the same
   (see assumption).

   Is it save to assume the resulting archive is a valid archive
   (and can be unpacked)?

   An argument supporting the archive should be valid:
   The non-patched tar with option '--ignore-failed-read' leads
   to the same archive and exit-code 0.
   Therefore reporting exit-code 1 for the same archive seems
   not to be completely unreasonable.

 - Should the modified behaviour only be enabled by a command
   line option?
   (Reason: Preserve old behaviour if this report is considered
   to be an improvement and not to be a bug)





Regards and thanks for reading,
Jonas

---
Jonas Julino

1&1 Internet SE

Hauptsitz Montabaur, Amtsgericht Montabaur, HRB 24498
Vorstand: Christian Genis Bigatà Joseph, Robert Hoffmann, Hans-Henning Kettler, Uwe Lamnek
Aufsichtsratsvorsitzender: Michael Scheeren

Attachment: 0002-Test-handling-of-directories-removed-during-incremen.patch
Description: Text Data

Attachment: 0001-Fix-handling-of-directories-removed-during-increment.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]