[BusyBox] tar hardlink extract

Bastian Blank waldi at debian.org
Tue Jun 10 10:09:42 UTC 2003


hi folks

this patch adds a hackish support for extracting hardlinks out of tars.

bastian

-- 
Even historians fail to learn from history -- they repeat the same mistakes.
		-- John Gill, "Patterns of Force", stardate 2534.7
-------------- next part --------------
--- busybox-cvs-0.60.99.cvs20030426.orig/archival/libunarchive/data_extract_all.c
+++ busybox-cvs-0.60.99.cvs20030426/archival/libunarchive/data_extract_all.c
@@ -75,6 +75,14 @@
 				bb_perror_msg("Cannot create symlink from %s to '%s'", file_header->name, file_header->link_name);
 			}
 			break;
+		case S_IFHLK:
+			/* Hardlink */
+			unlink(file_header->name);
+			res = link(file_header->link_name, file_header->name);
+			if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
+				bb_perror_msg("Cannot create hardlink from %s to '%s'", file_header->name, file_header->link_name);
+			}
+			break;
 		case S_IFSOCK:
 		case S_IFBLK:
 		case S_IFCHR:
only in patch2:
unchanged:
--- busybox-cvs-0.60.99.cvs20030426.orig/archival/libunarchive/get_header_tar.c
+++ busybox-cvs-0.60.99.cvs20030426/archival/libunarchive/get_header_tar.c
@@ -129,7 +129,8 @@
 		file_header->mode |= S_IFREG;
 		break;
 	case '1':
-		bb_error_msg("Internal hard link not supported");
+		file_header->mode &= ~S_IFMT;
+		file_header->mode |= S_IFHLK;
 		break;
 	case '2':
 		file_header->mode |= S_IFLNK;
only in patch2:
unchanged:
--- busybox-cvs-0.60.99.cvs20030426.orig/include/unarchive.h
+++ busybox-cvs-0.60.99.cvs20030426/include/unarchive.h
@@ -10,6 +10,11 @@
 #include <stdio.h>
 #include "libbb.h"
 
+#undef S_IFMT
+/* extra definitions for hardlink support */
+#define S_IFMT		0370000
+#define S_IFHLK		0200000
+
 typedef struct file_headers_s {
 	char *name;
 	char *link_name;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20030610/ce3c48ec/attachment.pgp 


More information about the busybox mailing list