- /* Not found. Add it to the list of possible links. */
- lp = (struct link *)malloc((unsigned)(sizeof(struct link)+strlen(p)));
- if (!lp) {
- if (!nolinks) {
- msg(
- "no memory for links, they will be dumped as separate files");
- nolinks++;
- }
+ /* First quick and dirty. Hashing, etc later FIXME */
+ for (lp = linklist; lp; lp = lp->next)
+ {
+ if (lp->ino == hstat.st_ino &&
+ lp->dev == hstat.st_dev)
+ {
+ char *link_name = lp->name;
+
+ /* We found a link. */
+ while (!f_absolute_paths && *link_name == '/')
+ {
+ static int link_warn = 0;
+
+ if (!link_warn)
+ {
+ msg ("Removing leading / from absolute links");
+ link_warn++;
+ }
+ link_name++;
+ }
+ if (link_name - lp->name >= NAMSIZ)
+ write_long (link_name, LF_LONGLINK);
+ current_link_name = link_name;
+
+ hstat.st_size = 0;
+ header = start_header (p, &hstat);
+ if (header == NULL)
+ {
+ critical_error = 1;
+ goto badfile;
+ }
+ strncpy (header->header.arch_linkname,
+ link_name, NAMSIZ);
+
+ /* Force null truncated */
+ header->header.arch_linkname[NAMSIZ - 1] = 0;
+
+ header->header.linkflag = LF_LINK;
+ finish_header (header);
+ /* FIXME: Maybe remove from list after all links found? */
+ if (f_remove_files)
+ {
+ if (unlink (p) == -1)
+ msg_perror ("cannot remove %s", p);