X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Ftar.c;h=1e0f95ddd8f42117dd1701f9d642e5538ff0ce33;hb=5addfdcb03a710d220d0d38262b106b99268b2ec;hp=3ef89ba931a7513ebb5b0ccdc50b18fce7521457;hpb=ab1964205372c8a1e85fd7576966869a2d50d141;p=chaz%2Ftar diff --git a/src/tar.c b/src/tar.c index 3ef89ba..1e0f95d 100644 --- a/src/tar.c +++ b/src/tar.c @@ -301,6 +301,7 @@ enum SHOW_DEFAULTS_OPTION, SHOW_OMITTED_DIRS_OPTION, SHOW_TRANSFORMED_NAMES_OPTION, + SPARSE_VERSION_OPTION, STRIP_COMPONENTS_OPTION, SUFFIX_OPTION, TEST_LABEL_OPTION, @@ -382,6 +383,8 @@ static struct argp_option options[] = { {"sparse", 'S', 0, 0, N_("handle sparse files efficiently"), GRID+1 }, + {"sparse-version", SPARSE_VERSION_OPTION, N_("MAJOR[.MINOR]"), 0, + N_("set version of the sparse format to use (implies --sparse)"), GRID+1}, {"incremental", 'G', 0, 0, N_("handle old GNU-format incremental backup"), GRID+1 }, {"listed-incremental", 'g', N_("FILE"), 0, @@ -400,7 +403,7 @@ static struct argp_option options[] = { #define GRID 30 {NULL, 0, NULL, 0, - N_("Overwrite control:\n"), GRID+1 }, + N_("Overwrite control:"), GRID+1 }, {"verify", 'W', 0, 0, N_("attempt to verify the archive after writing it"), GRID+1 }, @@ -627,7 +630,7 @@ static struct argp_option options[] = { N_("strip NUMBER leading components from file names on extraction"), GRID+1 }, {"transform", TRANSFORM_OPTION, N_("EXPRESSION"), 0, - N_("Use sed replace EXPRESSION to transform file names"), GRID+1 }, + N_("use sed replace EXPRESSION to transform file names"), GRID+1 }, #undef GRID #define GRID 95 @@ -1324,7 +1327,7 @@ parse_opt (int key, char *arg, struct argp_state *state) /* Print block numbers for debugging bad tar archives. */ /* It would surely make sense to exchange -B and -R, but it seems - that -B has been used for a long while in Sun tar ans most + that -B has been used for a long while in Sun tar and most BSD-derived systems. This is a consequence of the block/record terminology confusion. */ @@ -1332,7 +1335,7 @@ parse_opt (int key, char *arg, struct argp_state *state) break; case 's': - /* Names to extr are sorted. */ + /* Names to extract are sorted. */ same_order_option = true; break; @@ -1341,6 +1344,22 @@ parse_opt (int key, char *arg, struct argp_state *state) sparse_option = true; break; + case SPARSE_VERSION_OPTION: + sparse_option = true; + { + char *p; + tar_sparse_major = strtoul (arg, &p, 10); + if (*p) + { + if (*p != '.') + USAGE_ERROR ((0, 0, _("Invalid sparse version value"))); + tar_sparse_minor = strtoul (p + 1, &p, 10); + if (*p) + USAGE_ERROR ((0, 0, _("Invalid sparse version value"))); + } + } + break; + case 't': set_subcommand_option (LIST_SUBCOMMAND); verbose_option++; @@ -1885,7 +1904,7 @@ decode_options (int argc, char **argv) args.backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX"); args.version_control_string = 0; args.input_files = false; - + subcommand_option = UNKNOWN_SUBCOMMAND; archive_format = DEFAULT_FORMAT; blocking_factor = DEFAULT_BLOCKING; @@ -1895,7 +1914,9 @@ decode_options (int argc, char **argv) newer_mtime_option.tv_nsec = -1; recursion_option = FNM_LEADING_DIR; unquote_option = true; - + tar_sparse_major = 1; + tar_sparse_minor = 0; + owner_option = -1; group_option = -1; @@ -2177,6 +2198,16 @@ decode_options (int argc, char **argv) break; } + /* Initialize stdlis */ + if (index_file_name) + { + stdlis = fopen (index_file_name, "w"); + if (! stdlis) + open_error (index_file_name); + } + else + stdlis = to_stdout_option ? stderr : stdout; + archive_name_cursor = archive_name_array; /* Prepare for generating backup names. */ @@ -2219,6 +2250,9 @@ main (int argc, char **argv) /* Make sure we have first three descriptors available */ stdopen (); + /* Close all inherited open descriptors, except for the first three */ + closeopen (); + /* Pre-allocate a few structures. */ allocated_archive_names = 10;