X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Fincremen.c;h=ebcf80801465381dab2183f8b3c65fa7ae5008ba;hb=220ffceb4418c85c024265f4ed3ffecf6ecc7bdd;hp=1ef55e55add66cd85ae86324e836639fdc29dc98;hpb=f94cf6216bdbd93ff7a178d5da15aa47934422df;p=chaz%2Ftar diff --git a/src/incremen.c b/src/incremen.c index 1ef55e5..ebcf808 100644 --- a/src/incremen.c +++ b/src/incremen.c @@ -1,7 +1,7 @@ /* GNU dump extensions to tar. Copyright (C) 1988, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001, - 2003, 2004 Free Software Foundation, Inc. + 2003, 2004, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -15,16 +15,13 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., - 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "system.h" +#include #include #include #include #include "common.h" -#define obstack_chunk_alloc xmalloc -#define obstack_chunk_free free -#include /* Incremental dump specialities. */ @@ -53,8 +50,8 @@ static Hash_table *directory_table; #endif /* Calculate the hash of a directory. */ -static unsigned -hash_directory (void const *entry, unsigned n_buckets) +static size_t +hash_directory (void const *entry, size_t n_buckets) { struct directory const *directory = entry; return hash_string (directory->name, n_buckets); @@ -347,16 +344,19 @@ read_directory_file (void) char *ebuf; int n; long lineno = 1; - unsigned long u = (errno = 0, strtoul (buf, &ebuf, 10)); + uintmax_t u = (errno = 0, strtoumax (buf, &ebuf, 10)); time_t t = u; + if (buf == ebuf || (u == 0 && errno == EINVAL)) ERROR ((0, 0, "%s:1: %s", quotearg_colon (listed_incremental_option), _("Invalid time stamp"))); - else if (t != u || (u == -1 && errno == ERANGE)) + else if (t != u) ERROR ((0, 0, "%s:1: %s", quotearg_colon (listed_incremental_option), _("Time stamp out of range"))); else { + /* FIXME: This should also input nanoseconds, but that will be a + change in file format. */ newer_mtime_option.tv_sec = t; newer_mtime_option.tv_nsec = 0; } @@ -374,24 +374,24 @@ read_directory_file (void) buf[n - 1] = '\0'; errno = 0; - dev = u = strtoul (strp, &ebuf, 10); - if (strp == ebuf || (u == 0 && errno == EINVAL)) + dev = u = strtoumax (strp, &ebuf, 10); + if (!isspace (*ebuf)) ERROR ((0, 0, "%s:%ld: %s", quotearg_colon (listed_incremental_option), lineno, _("Invalid device number"))); - else if (dev != u || (u == -1 && errno == ERANGE)) + else if (dev != u) ERROR ((0, 0, "%s:%ld: %s", quotearg_colon (listed_incremental_option), lineno, _("Device number out of range"))); strp = ebuf; errno = 0; - ino = u = strtoul (strp, &ebuf, 10); - if (strp == ebuf || (u == 0 && errno == EINVAL)) + ino = u = strtoumax (strp, &ebuf, 10); + if (!isspace (*ebuf)) ERROR ((0, 0, "%s:%ld: %s", quotearg_colon (listed_incremental_option), lineno, _("Invalid inode number"))); - else if (ino != u || (u == -1 && errno == ERANGE)) + else if (ino != u) ERROR ((0, 0, "%s:%ld: %s", quotearg_colon (listed_incremental_option), lineno, _("Inode number out of range"))); @@ -420,11 +420,15 @@ write_directory_file_entry (void *entry, void *data) if (directory->found) { int e; + char buf[UINTMAX_STRSIZE_BOUND]; char *str = quote_copy_string (directory->name); - fprintf (fp, "+%lu %lu %s\n" + ! directory->nfs, - (unsigned long) directory->device_number, - (unsigned long) directory->inode_number, - str ? str : directory->name); + + if (directory->nfs) + fprintf (fp, "+"); + fprintf (fp, "%s ", umaxtostr (directory->device_number, buf)); + fprintf (fp, "%s ", umaxtostr (directory->inode_number, buf)); + fprintf (fp, "%s\n", str ? str : directory->name); + e = errno; if (str) free (str); @@ -447,7 +451,9 @@ write_directory_file (void) if (sys_truncate (fileno (fp)) != 0) truncate_error (listed_incremental_option); - fprintf (fp, "%lu\n", (unsigned long) start_time); + /* FIXME: This should also output nanoseconds, but that will be a + change in file format. */ + fprintf (fp, "%lu\n", (unsigned long int) start_time.tv_sec); if (! ferror (fp) && directory_table) hash_do_for_each (directory_table, write_directory_file_entry, fp); if (ferror (fp)) @@ -521,18 +527,18 @@ purge_directory (char const *directory_name) if (deref_stat (true, p, &st)) { stat_diag (p); - WARN((0, 0, _("%s: Not purging directory %s: unable to stat"), + WARN((0, 0, _("%s: Not purging directory: unable to stat"), quotearg_colon (p))); - continue; + continue; } else if (one_file_system_option && st.st_dev != root_device) { WARN((0, 0, - _("%s: directory %s is on a different device: not purging"), + _("%s: directory is on a different device: not purging"), quotearg_colon (p))); continue; } - + if (! interactive_option || confirm ("delete", p)) { if (verbose_option)