[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-tar] hard link extraction
From: |
Sergey Poznyakoff |
Subject: |
Re: [Bug-tar] hard link extraction |
Date: |
Tue, 23 Oct 2007 12:12:55 +0300 |
Dustin J. Mitchell <address@hidden> ha escrit:
> My reading of the documentation, and the lack of a reply to this post:
> http://www.archivum.info/address@hidden/2005-02/msg00011.html
> suggest that this is, more or less, a consequence of tar's design.
Yes, that's right.
> It would seem that supporting restores from an archive containing hard
> links is basically impossible.
Not quite so. I have some ideas in this regard, but I'll need some time
to work on them.
> So I wonder if there's a way to
> convince tar to ignore inode numbers and write each file's data
> independently?
There is no such option currently, but it seems like a good idea to have
one. Enclosed is a patch that implements it (the corresponding option name
is --hard-dereference). Please let me know if it helps you.
Regards,
Sergey
Index: src/common.h
===================================================================
RCS file: /cvsroot/tar/tar/src/common.h,v
retrieving revision 1.100
diff -p -u -r1.100 common.h
--- src/common.h 26 Sep 2007 22:06:43 -0000 1.100
+++ src/common.h 23 Oct 2007 09:05:50 -0000
@@ -143,6 +143,7 @@ GLOBAL enum checkpoint_style checkpoint_
GLOBAL const char *use_compress_program_option;
GLOBAL bool dereference_option;
+GLOBAL bool hard_dereference_option;
/* Print a message if not all links are dumped */
GLOBAL int check_links_option;
Index: src/create.c
===================================================================
RCS file: /cvsroot/tar/tar/src/create.c,v
retrieving revision 1.130
diff -p -u -r1.130 create.c
--- src/create.c 5 Oct 2007 11:20:27 -0000 1.130
+++ src/create.c 23 Oct 2007 09:05:50 -0000
@@ -1422,6 +1422,8 @@ dump_hard_link (struct tar_stat_info *st
static void
file_count_links (struct tar_stat_info *st)
{
+ if (hard_dereference_option)
+ return;
if (st->stat.st_nlink > 1)
{
struct link *duplicate;
Index: src/tar.c
===================================================================
RCS file: /cvsroot/tar/tar/src/tar.c,v
retrieving revision 1.171
diff -p -u -r1.171 tar.c
--- src/tar.c 26 Sep 2007 22:08:36 -0000 1.171
+++ src/tar.c 23 Oct 2007 09:05:50 -0000
@@ -251,6 +251,7 @@ enum
BACKUP_OPTION,
CHECKPOINT_OPTION,
DELAY_DIRECTORY_RESTORE_OPTION,
+ HARD_DEREFERENCE_OPTION,
DELETE_OPTION,
EXCLUDE_CACHES_OPTION,
EXCLUDE_CACHES_UNDER_OPTION,
@@ -634,6 +635,8 @@ static struct argp_option options[] = {
N_("don't strip leading `/'s from file names"), GRID+1 },
{"dereference", 'h', 0, 0,
N_("follow symlinks; archive and dump the files they point to"), GRID+1 },
+ {"hard-dereference", HARD_DEREFERENCE_OPTION, 0, 0,
+ N_("follow hard links; archive and dump the files they refer to"), GRID+1 },
{"starting-file", 'K', N_("MEMBER-NAME"), 0,
N_("begin at member MEMBER-NAME in the archive"), GRID+1 },
{"newer", 'N', N_("DATE-OR-FILE"), 0,
@@ -1292,6 +1295,10 @@ parse_opt (int key, char *arg, struct ar
dereference_option = true;
break;
+ case HARD_DEREFERENCE_OPTION:
+ hard_dereference_option = true;
+ break;
+
case 'i':
/* Ignore zero blocks (eofs). This can't be the default,
because Unix tar writes two blocks of zeros, then pads out