/[tar]/tar/src/create.c
ViewVC logotype

Diff of /tar/src/create.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.57 by eggert, Sat Jul 5 06:43:30 2003 UTC revision 1.58 by gray, Sun Jul 27 12:00:31 2003 UTC
# Line 50  struct link Line 50  struct link
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    
# Line 847  compare_links (void const *entry1, void Line 848  compare_links (void const *entry1, void
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
# Line 869  dump_file (char *p, int top_level, dev_t Line 875  dump_file (char *p, int top_level, dev_t
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    
# Line 1115  dump_file (char *p, int top_level, dev_t Line 1116  dump_file (char *p, int top_level, dev_t
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);
# Line 1521  file_was_dumped: Line 1524  file_was_dumped:
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
# Line 1531  file_was_dumped: Line 1535  file_was_dumped:
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    }

Legend:
Removed from v.1.57  
changed lines
  Added in v.1.58

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26