tar: Directory Modification Times and Permissions

1 
1 Directory Modification Times and Permissions
1 ............................................
1 
1 After successfully extracting a file member, GNU 'tar' normally restores
1 its permissions and modification times, as described in the previous
1 sections.  This cannot be done for directories, because after extracting
1 a directory 'tar' will almost certainly extract files into that
1 directory and this will cause the directory modification time to be
1 updated.  Moreover, restoring that directory permissions may not permit
1 file creation within it.  Thus, restoring directory permissions and
1 modification times must be delayed at least until all files have been
1 extracted into that directory.  GNU 'tar' restores directories using the
1 following approach.
1 
1    The extracted directories are created with the mode specified in the
1 archive, as modified by the umask of the user, which gives sufficient
1 permissions to allow file creation.  The meta-information about the
1 directory is recorded in the temporary list of directories.  When
1 preparing to extract next archive member, GNU 'tar' checks if the
1 directory prefix of this file contains the remembered directory.  If it
1 does not, the program assumes that all files have been extracted into
1 that directory, restores its modification time and permissions and
1 removes its entry from the internal list.  This approach allows to
1 correctly restore directory meta-information in the majority of cases,
1 while keeping memory requirements sufficiently small.  It is based on
1 the fact, that most 'tar' archives use the predefined order of members:
1 first the directory, then all the files and subdirectories in that
1 directory.
1 
1    However, this is not always true.  The most important exception are
1 incremental archives (⇒Incremental Dumps).  The member order in
1 an incremental archive is reversed: first all directory members are
1 stored, followed by other (non-directory) members.  So, when extracting
1 from incremental archives, GNU 'tar' alters the above procedure.  It
1 remembers all restored directories, and restores their meta-data only
1 after the entire archive has been processed.  Notice, that you do not
1 need to specify any special options for that, as GNU 'tar' automatically
1 detects archives in incremental format.
1 
1    There may be cases, when such processing is required for normal
1 archives too.  Consider the following example:
1 
1      $ tar --no-recursion -cvf archive \
1          foo foo/file1 bar bar/file foo/file2
1      foo/
1      foo/file1
1      bar/
1      bar/file
1      foo/file2
1 
1    During the normal operation, after encountering 'bar' GNU 'tar' will
1 assume that all files from the directory 'foo' were already extracted
1 and will therefore restore its timestamp and permission bits.  However,
1 after extracting 'foo/file2' the directory timestamp will be offset
1 again.
1 
1    To correctly restore directory meta-information in such cases, use
1 the '--delay-directory-restore' command line option:
1 
1 '--delay-directory-restore'
1      Delays restoring of the modification times and permissions of
1      extracted directories until the end of extraction.  This way,
1      correct meta-information is restored even if the archive has
1      unusual member ordering.
1 
1 '--no-delay-directory-restore'
1      Cancel the effect of the previous '--delay-directory-restore'.  Use
1      this option if you have used '--delay-directory-restore' in
1      'TAR_OPTIONS' variable (⇒TAR_OPTIONS) and wish to
1      temporarily disable it.
1