50 |
{ |
{ |
51 |
dev_t dev; |
dev_t dev; |
52 |
ino_t ino; |
ino_t ino; |
53 |
|
size_t nlink; |
54 |
char name[1]; |
char name[1]; |
55 |
}; |
}; |
56 |
|
|
848 |
return ((link1->dev ^ link2->dev) | (link1->ino ^ link2->ino)) == 0; |
return ((link1->dev ^ link2->dev) | (link1->ino ^ link2->ino)) == 0; |
849 |
} |
} |
850 |
|
|
851 |
|
/* Table of all non-directories that we've written so far. Any time |
852 |
|
we see another, we check the table and avoid dumping the data |
853 |
|
again if we've done it once already. */ |
854 |
|
static Hash_table *link_table; |
855 |
|
|
856 |
/* Dump a single file, recursing on directories. P is the file name |
/* Dump a single file, recursing on directories. P is the file name |
857 |
to dump. TOP_LEVEL tells whether this is a top-level call; zero |
to dump. TOP_LEVEL tells whether this is a top-level call; zero |
858 |
means no, positive means yes, and negative means the top level |
means no, positive means yes, and negative means the top level |
875 |
struct utimbuf restore_times; |
struct utimbuf restore_times; |
876 |
off_t block_ordinal = -1; |
off_t block_ordinal = -1; |
877 |
|
|
|
/* Table of all non-directories that we've written so far. Any time |
|
|
we see another, we check the table and avoid dumping the data |
|
|
again if we've done it once already. */ |
|
|
static Hash_table *link_table; |
|
|
|
|
878 |
/* FIXME: `header' might be used uninitialized in this |
/* FIXME: `header' might be used uninitialized in this |
879 |
function. Reported by Bruno Haible. */ |
function. Reported by Bruno Haible. */ |
880 |
|
|
1116 |
/* We found a link. */ |
/* We found a link. */ |
1117 |
char const *link_name = safer_name_suffix (dup->name, 1); |
char const *link_name = safer_name_suffix (dup->name, 1); |
1118 |
|
|
1119 |
|
dup->nlink--; |
1120 |
|
|
1121 |
block_ordinal = current_block_ordinal (); |
block_ordinal = current_block_ordinal (); |
1122 |
if (NAME_FIELD_SIZE <= strlen (link_name)) |
if (NAME_FIELD_SIZE <= strlen (link_name)) |
1123 |
write_long (link_name, GNUTYPE_LONGLINK); |
write_long (link_name, GNUTYPE_LONGLINK); |
1524 |
+ strlen (p) + 1); |
+ strlen (p) + 1); |
1525 |
lp->ino = current_stat.st_ino; |
lp->ino = current_stat.st_ino; |
1526 |
lp->dev = current_stat.st_dev; |
lp->dev = current_stat.st_dev; |
1527 |
|
lp->nlink = current_stat.st_nlink; |
1528 |
strcpy (lp->name, p); |
strcpy (lp->name, p); |
1529 |
|
|
1530 |
if (! ((link_table |
if (! ((link_table |
1535 |
|
|
1536 |
if (dup != lp) |
if (dup != lp) |
1537 |
abort (); |
abort (); |
1538 |
|
lp->nlink--; |
1539 |
} |
} |
1540 |
|
|
1541 |
} |
} |
1542 |
|
|
1543 |
|
/* For each dumped file, check if all its links were dumped. Emit |
1544 |
|
warnings if it is not so. */ |
1545 |
|
void |
1546 |
|
check_links () |
1547 |
|
{ |
1548 |
|
struct link *lp; |
1549 |
|
|
1550 |
|
if (!link_table) |
1551 |
|
return; |
1552 |
|
|
1553 |
|
for (lp = hash_get_first (link_table); lp; |
1554 |
|
lp = hash_get_next (link_table, lp)) |
1555 |
|
{ |
1556 |
|
if (lp->nlink) |
1557 |
|
{ |
1558 |
|
WARN ((0, 0, _("Missing links to '%s'.\n"), lp->name)); |
1559 |
|
} |
1560 |
|
} |
1561 |
|
} |