Bug 688567 - option -C (change directory) does not work in combination with -u (update archive)
option -C (change directory) does not work in combination with -u (update arc...
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: tar (Show other bugs)
6.0
Unspecified Linux
low Severity low
: rc
: ---
Assigned To: Pavel Raiskup
Branislav Blaškovič
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-03-17 07:37 EDT by Nicolas Mitsis
Modified: 2012-06-20 09:49 EDT (History)
3 users (show)

See Also:
Fixed In Version: tar-1.23-5.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-06-20 09:49:21 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
strace log from tar -C / -upvf ... (10.72 KB, text/x-log)
2011-04-01 11:36 EDT, Nicolas Mitsis
no flags Details

  None (edit)
Description Nicolas Mitsis 2011-03-17 07:37:20 EDT
Description of problem:

option -C (change directory) does not work in combination with -u (update archive)

Version-Release number of selected component (if applicable):

tar-1.23-3.el6.x86_64

How reproducible:

always

Steps to Reproduce:
1. create archive
2. update archive with options -C and -u
3. update fails
  
Actual results:

update fails

Expected results:

update to succeed

Additional info:

example follows:

[root@void ~]# ls -l /a/
total 0
-rw-r--r--. 1 root root 0 Mar 17 13:07 1
-rw-r--r--. 1 root root 0 Mar 17 13:07 2
[root@void ~]# tar -C / -cpvf a.tar a
a/
a/1
a/2
[root@void ~]# echo $RANDOM > /a/1
[root@void ~]# touch /a/3 
[root@void ~]# tar -C / -upvf a.tar a
tar: a/1: Cannot stat: No such file or directory
tar: a/3: Cannot stat: No such file or directory
tar: a/2: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
[root@void ~]# tar tvf a.tar 
drwxr-xr-x root/root         0 2011-03-17 13:07 a/
-rw-r--r-- root/root         0 2011-03-17 13:07 a/1
-rw-r--r-- root/root         0 2011-03-17 13:07 a/2

From strace it seems fchdir() is called for 2nd time with wrong arguments:

...................................................
open(".", O_RDONLY)                     = 4
dup(4)                                  = 5
close(5)                                = 0
chdir("/")                              = 0
lstat("a", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("a", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 5
fcntl(5, F_GETFD)                       = 0x1 (flags FD_CLOEXEC)
getdents(5, /* 6 entries */, 32768)     = 144
getdents(5, /* 0 entries */, 32768)     = 0
close(5)                                = 0
open(".", O_RDONLY)                     = 5
dup(5)                                  = 6
close(6)                                = 0
fchdir(4)                               = 0
....................................................
Comment 2 RHEL Product and Program Management 2011-03-17 08:07:52 EDT
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unfortunately unable to
address this request at this time. Red Hat invites you to
ask your support representative to propose this request, if
appropriate and relevant, in the next release of Red Hat
Enterprise Linux. If you would like it considered as an
exception in the current release, please ask your support
representative.
Comment 3 Ondrej Vasik 2011-03-31 10:36:07 EDT
Works for me on ext4 and tar-1.23-3.el6.i686 ...

[root@dhcp-24-196 tmp]# ls -l /a/
total 0
-rw-r--r--. 1 root root 0 Mar 31 16:32 1
-rw-r--r--. 1 root root 0 Mar 31 16:30 2
[root@dhcp-24-196 tmp]# tar -C / -cpvf a.tar a
a/
a/2
a/1
[root@dhcp-24-196 tmp]# echo $RANDOM > /a/1
[root@dhcp-24-196 tmp]# touch /a/3
[root@dhcp-24-196 tmp]# tar -C / -upvf a.tar a
a/3
[root@dhcp-24-196 tmp]# tar tvf a.tar
drwxr-xr-x root/root         0 2011-03-31 16:32 a/
-rw-r--r-- root/root         0 2011-03-31 16:30 a/2
-rw-r--r-- root/root         0 2011-03-31 16:32 a/1
-rw-r--r-- root/root         0 2011-03-31 16:30 a/3

Maybe something specific on your side?
Comment 4 Nicolas Mitsis 2011-04-01 11:36:47 EDT
Created attachment 489424 [details]
strace log from tar -C / -upvf ...
Comment 5 Nicolas Mitsis 2011-04-01 11:40:39 EDT
I've tried this in 2 different production systems and 1 clean vmware installation all on 64bit. Maybe the bug is absent from 32 ?

This is the version I've tried:

# tar --version
tar (GNU tar) 1.23

# rpm -q tar
tar-1.23-3.el6.x86_64

I've added also an strace log which shows fchdir() is called twice.
Comment 6 Ondrej Vasik 2011-04-01 12:28:04 EDT
Maybe, I'll check 64bit next week ... thanks for strace...
Comment 7 Ondrej Vasik 2011-06-06 08:31:56 EDT
Sorry for delay, behaviour confirmed on 64-bit RHEL-6 ... strange.
Comment 8 Ondrej Vasik 2011-06-06 09:04:50 EDT
Well, not exactly true, it seems to be reproducible even on 32 bit (but not always) ...
Failed stats:
x86_64:
lstat("a/2", 0x7fff0dcc68b0)            = -1 ENOENT (No such file or directory)
lstat("a/1", 0x7fff0dcc68b0)            = -1 ENOENT (No such file or directory)
lstat("a/3", 0x7fff0dcc6748)            = -1 ENOENT (No such file or directory)
i386:
lstat64("a/2", {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
lstat64("a/1", {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
lstat64("a/4", 0xbf939b44)              = -1 ENOENT (No such file or directory)

Will try to find out what's broken there ...
Comment 11 RHEL Product and Program Management 2011-07-05 20:07:04 EDT
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unfortunately unable to
address this request at this time. Red Hat invites you to
ask your support representative to propose this request, if
appropriate and relevant, in the next release of Red Hat
Enterprise Linux. If you would like it considered as an
exception in the current release, please ask your support
representative.
Comment 13 Pavel Raiskup 2012-02-23 05:20:34 EST
Fix proposed to upstream:

    http://www.mail-archive.com/bug-tar@gnu.org/msg03545.html
Comment 21 errata-xmlrpc 2012-06-20 09:49:21 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0849.html

Note You need to log in before you can comment on or make changes to this bug.