X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Ftar.c;h=e21a6466f40249ff530ffed978ebc053d43f6b8e;hb=6f929b2c8998bab44ca81b01cd8e1381fb6e9dfe;hp=bd48d7be1f22cc8334d0764de5bb157b697cc741;hpb=b0765e257cf27e5a1fd78715f1b8bef3e30890a5;p=chaz%2Ftar diff --git a/src/tar.c b/src/tar.c index bd48d7b..e21a646 100644 --- a/src/tar.c +++ b/src/tar.c @@ -1,7 +1,7 @@ /* A tar (tape archiver) program. Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000, - 2001, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + 2001, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. Written by John Gilmore, starting 1985-08-25. @@ -41,10 +41,11 @@ #include #include +#include #include #include -#include #include +#include #include #include #include @@ -253,7 +254,12 @@ enum DELAY_DIRECTORY_RESTORE_OPTION, DELETE_OPTION, EXCLUDE_CACHES_OPTION, + EXCLUDE_CACHES_UNDER_OPTION, + EXCLUDE_CACHES_ALL_OPTION, EXCLUDE_OPTION, + EXCLUDE_TAG_OPTION, + EXCLUDE_TAG_UNDER_OPTION, + EXCLUDE_TAG_ALL_OPTION, FORCE_LOCAL_OPTION, GROUP_OPTION, HANG_OPTION, @@ -602,7 +608,20 @@ static struct argp_option options[] = { {"exclude-from", 'X', N_("FILE"), 0, N_("exclude patterns listed in FILE"), GRID+1 }, {"exclude-caches", EXCLUDE_CACHES_OPTION, 0, 0, - N_("exclude directories containing a cache tag"), GRID+1 }, + N_("exclude contents of directories containing CACHEDIR.TAG, " + "except for the tag file itself"), GRID+1 }, + {"exclude-caches-under", EXCLUDE_CACHES_UNDER_OPTION, 0, 0, + N_("exclude everything under directories containing CACHEDIR.TAG"), + GRID+1 }, + {"exclude-caches-all", EXCLUDE_CACHES_ALL_OPTION, 0, 0, + N_("exclude directories containing CACHEDIR.TAG"), GRID+1 }, + {"exclude-tag", EXCLUDE_TAG_OPTION, N_("FILE"), 0, + N_("exclude contents of directories containing FILE, except" + " for FILE itself"), GRID+1 }, + {"exclude-tag-under", EXCLUDE_TAG_UNDER_OPTION, N_("FILE"), 0, + N_("exclude everything under directories containing FILE"), GRID+1 }, + {"exclude-tag-all", EXCLUDE_TAG_ALL_OPTION, N_("FILE"), 0, + N_("exclude directories containing FILE"), GRID+1 }, {"no-recursion", NO_RECURSION_OPTION, 0, 0, N_("avoid descending automatically in directories"), GRID+1 }, {"one-file-system", ONE_FILE_SYSTEM_OPTION, 0, 0, @@ -980,7 +999,7 @@ read_name_from_file (FILE *fp, struct obstack *stk) if (counter == 0 && c != EOF) return file_list_skip; - + obstack_1grow (stk, 0); return (counter == 0 && c == EOF) ? file_list_end : file_list_success; @@ -1068,7 +1087,7 @@ update_argv (const char *filename, struct argp_state *state) case file_list_success: count++; break; - + case file_list_end: /* won't happen, just to pacify gcc */ break; @@ -1093,7 +1112,7 @@ update_argv (const char *filename, struct argp_state *state) filename_terminator = 0; break; } - + case file_list_skip: break; } @@ -1159,11 +1178,11 @@ parse_opt (int key, char *arg, struct argp_state *state) switch (key) { - case ARGP_KEY_ARG: - /* File name or non-parsed option, because of ARGP_IN_ORDER */ - name_add_name (arg, MAKE_INCL_OPTIONS (args)); - args->input_files = true; - break; + case ARGP_KEY_ARG: + /* File name or non-parsed option, because of ARGP_IN_ORDER */ + name_add_name (arg, MAKE_INCL_OPTIONS (args)); + args->input_files = true; + break; case 'A': set_subcommand_option (CAT_SUBCOMMAND); @@ -1503,7 +1522,30 @@ parse_opt (int key, char *arg, struct argp_state *state) break; case EXCLUDE_CACHES_OPTION: - exclude_caches_option = true; + add_exclusion_tag ("CACHEDIR.TAG", exclusion_tag_contents, + cachedir_file_p); + break; + + case EXCLUDE_CACHES_UNDER_OPTION: + add_exclusion_tag ("CACHEDIR.TAG", exclusion_tag_under, + cachedir_file_p); + break; + + case EXCLUDE_CACHES_ALL_OPTION: + add_exclusion_tag ("CACHEDIR.TAG", exclusion_tag_all, + cachedir_file_p); + break; + + case EXCLUDE_TAG_OPTION: + add_exclusion_tag (arg, exclusion_tag_contents, NULL); + break; + + case EXCLUDE_TAG_UNDER_OPTION: + add_exclusion_tag (arg, exclusion_tag_under, NULL); + break; + + case EXCLUDE_TAG_ALL_OPTION: + add_exclusion_tag (arg, exclusion_tag_all, NULL); break; case FORCE_LOCAL_OPTION: @@ -2260,9 +2302,6 @@ 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; @@ -2280,6 +2319,7 @@ main (int argc, char **argv) /* Decode options. */ decode_options (argc, argv); + name_init (); /* Main command execution. */ @@ -2346,7 +2386,7 @@ main (int argc, char **argv) if (stdlis == stdout) close_stdout (); - else if (ferror (stderr) || fclose (stderr) != 0) + else if (ferror (stderr) || fclose (stderr) != 0) exit_status = TAREXIT_FAILURE; return exit_status;