I have been using the construct described below in a restore script for the last 6 years. On upgrading from GNU tar 1.20, I see an unexpected change in listing/restoring behavior when the --strip-components=N option is used with --occurrence=1 option. I don't know if this is specific to directories in which the file names begin with the same string as the directory requested, but in the past, I would get the entire directory rather than just the first file in the directory when doing a restore. My intent in using the --occurrence=1 is to save time when I know that there will only be one instance of the directory on the tape, often quite near the start of the tape. I have verified that the additional files are on the tape/in the archive by doing a restore without using the --occurrence=1 option.

Please let me know if I can provide additional information and/or build a test version of tar for you. I have access to AIX 5.3 and 6.1 development hosts and Fedora 12 Linux hosts. It would appear that the code which compares the current file to the requested spec does not take into account the fact that the first occurrence is a directory name and the second one a file name. I could build a debug version and step through the code if need be.

Richard Nolde
Systems Programmer

[email protected]

Simple case to reproduce the problem, which I am seeing with GNU tar 1.22 on Linux Fedora 12 and GNU tar 1.25 on AIX 6.1.

On my Linux Fedora 12 host
tar --version
tar (GNU tar) 1.22
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

On my AIX 6.1 host
tar --version
tar (GNU tar) 1.25
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.

Tests on the Fedora box to reproduce the problem.
ls -l /archive/fedora/nmon
total 1056
-rw-rw-rw- 1 nolde nolde 217680 2010-11-18 21:05 nmon_x86_64_fedora14
-rw-rw-rw- 1 nolde nolde 217828 2010-11-23 21:57 nmon_x86_64_rhel4
-rw-rw-rw- 1 nolde nolde 219767 2010-11-24 01:23 nmon_x86_64_rhel5
-rw-rw-rw- 1 nolde nolde 219767 2010-11-23 21:57 nmon_x86_64_rhel54
-rwxrwxrwx 1 nolde nolde 195750 2010-11-18 21:04 nmon_x86_fedora14

tar -cvf /tmp/nmon.tar /archive/fedora/nmon
tar: Removing leading `/' from member names
/archive/fedora/nmon/
/archive/fedora/nmon/nmon_x86_64_rhel4
/archive/fedora/nmon/nmon_x86_64_rhel5
/archive/fedora/nmon/nmon_x86_fedora14
/archive/fedora/nmon/nmon_x86_64_rhel54
/archive/fedora/nmon/nmon_x86_64_fedora14

tar -tvf /tmp/nmon.tar
drwxrwxr-x nolde/nolde       0 2011-01-16 21:54 archive/fedora/nmon/
-rw-rw-rw- nolde/nolde 217828 2010-11-23 21:57 archive/fedora/nmon/nmon_x86_64_rhel4 -rw-rw-rw- nolde/nolde 219767 2010-11-24 01:23 archive/fedora/nmon/nmon_x86_64_rhel5 -rwxrwxrwx nolde/nolde 195750 2010-11-18 21:04 archive/fedora/nmon/nmon_x86_fedora14 -rw-rw-rw- nolde/nolde 219767 2010-11-23 21:57 archive/fedora/nmon/nmon_x86_64_rhel54 -rw-rw-rw- nolde/nolde 217680 2010-11-18 21:05 archive/fedora/nmon/nmon_x86_64_fedora14

tar -tv --strip-components=2 -f /tmp/nmon.tar archive/fedora/nmon
drwxrwxr-x nolde/nolde       0 2011-01-16 21:54 archive/fedora/nmon/
-rw-rw-rw- nolde/nolde 217828 2010-11-23 21:57 archive/fedora/nmon/nmon_x86_64_rhel4 -rw-rw-rw- nolde/nolde 219767 2010-11-24 01:23 archive/fedora/nmon/nmon_x86_64_rhel5 -rwxrwxrwx nolde/nolde 195750 2010-11-18 21:04 archive/fedora/nmon/nmon_x86_fedora14 -rw-rw-rw- nolde/nolde 219767 2010-11-23 21:57 archive/fedora/nmon/nmon_x86_64_rhel54 -rw-rw-rw- nolde/nolde 217680 2010-11-18 21:05 archive/fedora/nmon/nmon_x86_64_fedora14

tar -tv --occurrence=1 --strip-components=2 -f /tmp/nmon.tar archive/fedora/nmon
drwxrwxr-x nolde/nolde       0 2011-01-16 21:54 archive/fedora/nmon/
-rw-rw-rw- nolde/nolde 217828 2010-11-23 21:57 archive/fedora/nmon/nmon_x86_64_rhel4

tar -tv --strip-components=2 --occurrence=1 -f /tmp/nmon.tar archive/fedora/nmon
drwxrwxr-x nolde/nolde       0 2011-01-16 21:54 archive/fedora/nmon/
-rw-rw-rw- nolde/nolde 217828 2010-11-23 21:57 archive/fedora/nmon/nmon_x86_64_rhel4

tar -xv --strip-components=2 --occurrence=1 -f /tmp/nmon.tar archive/fedora/nmon
archive/fedora/nmon/
archive/fedora/nmon/nmon_x86_64_rhel4

[nolde@aeolus tmp]$ ls -l nmon
total 216
-rw-rw-r-- 1 nolde nolde 217828 2010-11-23 21:57 nmon_x86_64_rhel4




Reply via email to