[BUG+PATCH] Tar sets time on the wrong file when unpacking
Alex Landau
landau_alex at yahoo.com
Tue Jun 19 12:37:59 UTC 2007
Hi,
I noticed a small bug in tar, i.e. a behavior differing from my expectations and from GNU
tar.
When you unpack a tar file containing a symlink, tar runs utime on it to update its time.
This changes the time on the file the link is pointing to.
Unfortunately POSIX does not define (and Linux does not have) a syscall like lutime (ala
lchown) that can handle that.
GNU tar handles this by not changing the time on symlinks, which results in extracted
symlinks having always the time of extraction. rsync has the same problem, by the way.
The patch below does NOT set the time on an extracted symlink.
Alex
Index: archival/libunarchive/data_extract_all.c
===================================================================
--- archival/libunarchive/data_extract_all.c (revision 18847)
+++ archival/libunarchive/data_extract_all.c (working copy)
@@ -119,7 +119,7 @@
chmod(file_header->name, file_header->mode);
}
- if (archive_handle->flags & ARCHIVE_PRESERVE_DATE) {
+ if (archive_handle->flags & ARCHIVE_PRESERVE_DATE && !S_ISLNK(file_header->mode)) {
struct utimbuf t;
t.actime = t.modtime = file_header->mtime;
utime(file_header->name, &t);
____________________________________________________________________________________
Choose the right car based on your needs. Check out Yahoo! Autos new Car Finder tool.
http://autos.yahoo.com/carfinder/
More information about the busybox
mailing list