diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2003-11-15 23:44:31 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2003-11-15 23:44:31 +0000 |
commit | 8dc8cb133c482441f45aebb63376702d152b52ba (patch) | |
tree | 3ca108a13ddc8f7557143ea726810fb68549da47 /archival | |
parent | 5699b8525e855a0e851725980964e8755e365f5b (diff) | |
download | busybox-w32-8dc8cb133c482441f45aebb63376702d152b52ba.tar.gz busybox-w32-8dc8cb133c482441f45aebb63376702d152b52ba.tar.bz2 busybox-w32-8dc8cb133c482441f45aebb63376702d152b52ba.zip |
Fix a bug where cpio wouldnt work unless -u was specified
Diffstat (limited to 'archival')
-rw-r--r-- | archival/libunarchive/data_extract_all.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/archival/libunarchive/data_extract_all.c b/archival/libunarchive/data_extract_all.c index 7349339d3..1a6b6244b 100644 --- a/archival/libunarchive/data_extract_all.c +++ b/archival/libunarchive/data_extract_all.c | |||
@@ -49,18 +49,20 @@ extern void data_extract_all(archive_handle_t *archive_handle) | |||
49 | else if (archive_handle->flags & ARCHIVE_EXTRACT_NEWER) { | 49 | else if (archive_handle->flags & ARCHIVE_EXTRACT_NEWER) { |
50 | /* Remove the existing entry if its older than the extracted entry */ | 50 | /* Remove the existing entry if its older than the extracted entry */ |
51 | struct stat statbuf; | 51 | struct stat statbuf; |
52 | if ((lstat(file_header->name, &statbuf) == -1) && (errno != ENOENT)) { | 52 | if (lstat(file_header->name, &statbuf) == -1) { |
53 | bb_perror_msg_and_die("Couldnt stat old file"); | 53 | if (errno != ENOENT) { |
54 | bb_perror_msg_and_die("Couldnt stat old file"); | ||
55 | } | ||
54 | } | 56 | } |
55 | if (statbuf.st_mtime <= file_header->mtime) { | 57 | else if (statbuf.st_mtime <= file_header->mtime) { |
56 | if (!(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) { | 58 | if (!(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) { |
57 | bb_error_msg("%s not created: newer or same age file exists", file_header->name); | 59 | bb_error_msg("%s not created: newer or same age file exists", file_header->name); |
58 | } | 60 | } |
59 | data_skip(archive_handle); | 61 | data_skip(archive_handle); |
60 | return; | 62 | return; |
61 | } | 63 | } |
62 | if ((unlink(file_header->name) == -1) && (errno != ENOENT)) { | 64 | else if ((unlink(file_header->name) == -1) && (errno != EISDIR)) { |
63 | bb_perror_msg_and_die("Couldnt remove old file"); | 65 | bb_perror_msg_and_die("Couldnt remove old file %s", file_header->name); |
64 | } | 66 | } |
65 | } | 67 | } |
66 | 68 | ||
@@ -76,22 +78,19 @@ extern void data_extract_all(archive_handle_t *archive_handle) | |||
76 | switch(file_header->mode & S_IFMT) { | 78 | switch(file_header->mode & S_IFMT) { |
77 | case S_IFREG: { | 79 | case S_IFREG: { |
78 | /* Regular file */ | 80 | /* Regular file */ |
79 | unlink(file_header->name); | ||
80 | dst_fd = bb_xopen(file_header->name, O_WRONLY | O_CREAT | O_EXCL); | 81 | dst_fd = bb_xopen(file_header->name, O_WRONLY | O_CREAT | O_EXCL); |
81 | archive_copy_file(archive_handle, dst_fd); | 82 | archive_copy_file(archive_handle, dst_fd); |
82 | close(dst_fd); | 83 | close(dst_fd); |
83 | break; | 84 | break; |
84 | } | 85 | } |
85 | case S_IFDIR: | 86 | case S_IFDIR: |
86 | unlink(file_header->name); | ||
87 | res = mkdir(file_header->name, file_header->mode); | 87 | res = mkdir(file_header->name, file_header->mode); |
88 | if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) { | 88 | if ((errno != EISDIR) && (res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) { |
89 | bb_perror_msg("extract_archive: %s", file_header->name); | 89 | bb_perror_msg("extract_archive: %s", file_header->name); |
90 | } | 90 | } |
91 | break; | 91 | break; |
92 | case S_IFLNK: | 92 | case S_IFLNK: |
93 | /* Symlink */ | 93 | /* Symlink */ |
94 | unlink(file_header->name); | ||
95 | res = symlink(file_header->link_name, file_header->name); | 94 | res = symlink(file_header->link_name, file_header->name); |
96 | if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) { | 95 | if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) { |
97 | bb_perror_msg("Cannot create symlink from %s to '%s'", file_header->name, file_header->link_name); | 96 | bb_perror_msg("Cannot create symlink from %s to '%s'", file_header->name, file_header->link_name); |
@@ -101,7 +100,6 @@ extern void data_extract_all(archive_handle_t *archive_handle) | |||
101 | case S_IFBLK: | 100 | case S_IFBLK: |
102 | case S_IFCHR: | 101 | case S_IFCHR: |
103 | case S_IFIFO: | 102 | case S_IFIFO: |
104 | unlink(file_header->name); | ||
105 | res = mknod(file_header->name, file_header->mode, file_header->device); | 103 | res = mknod(file_header->name, file_header->mode, file_header->device); |
106 | if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) { | 104 | if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) { |
107 | bb_perror_msg("Cannot create node %s", file_header->name); | 105 | bb_perror_msg("Cannot create node %s", file_header->name); |