[BusyBox-cvs] busybox/archival/libunarchive get_header_tar.c, 1.19, 1.20 data_extract_all.c, 1.10, 1.11
Glenn McGrath
bug1 at busybox.net
Thu Aug 14 02:55:18 UTC 2003
Update of /var/cvs/busybox/archival/libunarchive
In directory winder:/tmp/cvs-serv15167
Modified Files:
get_header_tar.c data_extract_all.c
Log Message:
Change hardlink handling for tar to work the same way as cpio
Index: data_extract_all.c
===================================================================
RCS file: /var/cvs/busybox/archival/libunarchive/data_extract_all.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- data_extract_all.c 21 Apr 2003 11:03:29 -0000 1.10
+++ data_extract_all.c 14 Aug 2003 02:55:15 -0000 1.11
@@ -39,54 +39,52 @@
free(name);
}
- /* Create the filesystem entry */
- switch(file_header->mode & S_IFMT) {
- case S_IFREG: {
-#ifdef CONFIG_CPIO
- if (file_header->link_name && file_header->size == 0) {
- /* hard link */
- res = link(file_header->link_name, file_header->name);
- if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
- bb_perror_msg("Couldnt create hard link");
- }
- } else
-#endif
- {
+ /* Handle hard links seperately */
+ if (!S_ISLNK(file_header->mode) && (file_header->link_name) && (file_header->size == 0)) {
+ /* hard link */
+ res = link(file_header->link_name, file_header->name);
+ if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
+ bb_perror_msg("Couldnt create hard link");
+ }
+ } else {
+ /* Create the filesystem entry */
+ switch(file_header->mode & S_IFMT) {
+ case S_IFREG: {
/* Regular file */
unlink(file_header->name);
dst_fd = bb_xopen(file_header->name, O_WRONLY | O_CREAT | O_EXCL);
archive_copy_file(archive_handle, dst_fd);
close(dst_fd);
- }
- break;
+ break;
+ }
+ case S_IFDIR:
+ unlink(file_header->name);
+ res = mkdir(file_header->name, file_header->mode);
+ if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
+ bb_perror_msg("extract_archive: %s", file_header->name);
+ }
+ break;
+ case S_IFLNK:
+ /* Symlink */
+ unlink(file_header->name);
+ res = symlink(file_header->link_name, file_header->name);
+ if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
+ bb_perror_msg("Cannot create symlink from %s to '%s'", file_header->name, file_header->link_name);
+ }
+ break;
+ case S_IFSOCK:
+ case S_IFBLK:
+ case S_IFCHR:
+ case S_IFIFO:
+ unlink(file_header->name);
+ res = mknod(file_header->name, file_header->mode, file_header->device);
+ if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
+ bb_perror_msg("Cannot create node %s", file_header->name);
+ }
+ break;
+ default:
+ bb_error_msg_and_die("Unrecognised file type");
}
- case S_IFDIR:
- unlink(file_header->name);
- res = mkdir(file_header->name, file_header->mode);
- if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
- bb_perror_msg("extract_archive: %s", file_header->name);
- }
- break;
- case S_IFLNK:
- /* Symlink */
- unlink(file_header->name);
- res = symlink(file_header->link_name, file_header->name);
- if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
- bb_perror_msg("Cannot create symlink from %s to '%s'", file_header->name, file_header->link_name);
- }
- break;
- case S_IFSOCK:
- case S_IFBLK:
- case S_IFCHR:
- case S_IFIFO:
- unlink(file_header->name);
- res = mknod(file_header->name, file_header->mode, file_header->device);
- if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
- bb_perror_msg("Cannot create node %s", file_header->name);
- }
- break;
- default:
- bb_error_msg_and_die("Unrecognised file type");
}
chmod(file_header->name, file_header->mode);
Index: get_header_tar.c
===================================================================
RCS file: /var/cvs/busybox/archival/libunarchive/get_header_tar.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- get_header_tar.c 16 Jul 2003 06:29:51 -0000 1.19
+++ get_header_tar.c 14 Aug 2003 02:55:15 -0000 1.20
@@ -128,8 +128,12 @@
case '0':
file_header->mode |= S_IFREG;
break;
+#if 0
+ /* hard links are detected as entries with 0 size, a link name,
+ * and not being a symlink, hence we have nothing to do here */
case '1':
- bb_error_msg("WARNING: Converting hard link to symlink");
+ break;
+#endif
case '2':
file_header->mode |= S_IFLNK;
break;
@@ -173,6 +177,7 @@
# endif
}
#endif
+
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
archive_handle->action_header(archive_handle->file_header);
archive_handle->flags |= ARCHIVE_EXTRACT_QUIET;
@@ -185,4 +190,3 @@
return(EXIT_SUCCESS);
}
-
More information about the busybox-cvs
mailing list