X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Ftar;a=blobdiff_plain;f=src%2Fincremen.c;h=07e757adfa4f97a9313cceb9b4f31ea376d735bf;hp=8aeefbeda86b403cb07399df6bdaba35d42ced6e;hb=751b61ab25ddc03510a695d55a916943aea2f6f0;hpb=738fb9c2f44eee567bb60e22dc011bdfd2f362a8 diff --git a/src/incremen.c b/src/incremen.c index 8aeefbe..07e757a 100644 --- a/src/incremen.c +++ b/src/incremen.c @@ -1268,6 +1268,51 @@ read_incr_db_2 (void) _("Unexpected EOF in snapshot file"))); } +/* Display (to stdout) the range of allowed values for each field + in the snapshot file. The array below should be kept in sync + with any changes made to the read_num() calls in the parsing + loop inside read_incr_db_2(). + + (This function is invoked via the --show-snapshot-field-ranges + command line option.) */ + +struct field_range +{ + char const *fieldname; + intmax_t min_val; + uintmax_t max_val; +}; + +static struct field_range const field_ranges[] = { + { "nfs", 0, 1 }, + { "timestamp_sec", TYPE_MINIMUM (time_t), TYPE_MAXIMUM (time_t) }, + { "timestamp_nsec", 0, BILLION - 1 }, + { "dev", TYPE_MINIMUM (dev_t), TYPE_MAXIMUM (dev_t) }, + { "ino", TYPE_MINIMUM (ino_t), TYPE_MAXIMUM (ino_t) }, + { NULL, 0, 0 } +}; + +void +show_snapshot_field_ranges (void) +{ + struct field_range const *p; + char minbuf[max (SYSINT_BUFSIZE, INT_BUFSIZE_BOUND (intmax_t))]; + char maxbuf[max (SYSINT_BUFSIZE, INT_BUFSIZE_BOUND (uintmax_t))]; + + printf("This tar's snapshot file field ranges are\n"); + printf (" (%-15s => [ %s, %s ]):\n\n", "field name", "min", "max"); + + for (p=field_ranges; p->fieldname != NULL; p++) + { + printf (" %-15s => [ %s, %s ],\n", p->fieldname, + sysinttostr (p->min_val, p->min_val, p->max_val, minbuf), + sysinttostr (p->max_val, p->min_val, p->max_val, maxbuf)); + + } + + printf("\n"); +} + /* Read incremental snapshot file (directory file). If the file has older incremental version, make sure that it is processed correctly and that tar will use the most conservative backup method among