]> Dogcows Code - chaz/tar/blobdiff - src/create.c
tar: restore macros that are used in some cases
[chaz/tar] / src / create.c
index fbd7165aceee32e79a193e123148cfddca77dc45..9a4a282b7f09b94180702ee0c044f0447e7d28c2 100644 (file)
@@ -30,7 +30,7 @@ struct link
   {
     dev_t dev;
     ino_t ino;
-    size_t nlink;
+    nlink_t nlink;
     char name[1];
   };
 
@@ -219,7 +219,7 @@ to_base256 (int negative, uintmax_t value, char *where, size_t size)
 #define MINOR_TO_CHARS(val, where) minor_to_chars (val, where, sizeof (where))
 #define MODE_TO_CHARS(val, where) mode_to_chars (val, where, sizeof (where))
 #define UID_TO_CHARS(val, where) uid_to_chars (val, where, sizeof (where))
-#define UINTMAX_TO_CHARS(val, where) uintmax_to_chars (val, where, sizeof (where))
+
 #define UNAME_TO_CHARS(name,buf) string_to_chars (name, buf, sizeof(buf))
 #define GNAME_TO_CHARS(name,buf) string_to_chars (name, buf, sizeof(buf))
 
@@ -440,12 +440,6 @@ off_to_chars (off_t v, char *p, size_t s)
   return to_chars (v < 0, (uintmax_t) v, sizeof v, 0, p, s, "off_t");
 }
 
-bool
-size_to_chars (size_t v, char *p, size_t s)
-{
-  return to_chars (0, (uintmax_t) v, sizeof v, 0, p, s, "size_t");
-}
-
 bool
 time_to_chars (time_t v, char *p, size_t s)
 {
@@ -1265,6 +1259,12 @@ dump_dir (int fd, struct tar_stat_info *st, bool top_level,
   return true;
 }
 
+\f
+/* Number of links a file can have without having to be entered into
+   the link table.  Typically this is 1, but in trickier circumstances
+   it is 0.  */
+static nlink_t trivial_link_count;
+
 \f
 /* Main functions of this module.  */
 
@@ -1273,6 +1273,8 @@ create_archive (void)
 {
   struct name const *p;
 
+  trivial_link_count = name_count <= 1 && ! dereference_option;
+
   open_archive (ACCESS_WRITE);
   buffer_write_global_xheader ();
 
@@ -1380,7 +1382,8 @@ static Hash_table *link_table;
 static bool
 dump_hard_link (struct tar_stat_info *st)
 {
-  if (link_table && (st->stat.st_nlink > 1 || remove_files_option))
+  if (link_table
+      && (trivial_link_count < st->stat.st_nlink || remove_files_option))
     {
       struct link lp;
       struct link *duplicate;
@@ -1427,7 +1430,7 @@ file_count_links (struct tar_stat_info *st)
 {
   if (hard_dereference_option)
     return;
-  if (st->stat.st_nlink > 1)
+  if (trivial_link_count < st->stat.st_nlink)
     {
       struct link *duplicate;
       char *linkname = NULL;
This page took 0.023664 seconds and 4 git commands to generate.