diff options
author | sobomax <sobomax@FreeBSD.org> | 2002-06-04 17:31:16 +0000 |
---|---|---|
committer | sobomax <sobomax@FreeBSD.org> | 2002-06-04 17:31:16 +0000 |
commit | 64e4db86986a7cd56a202b1bcee6847dc6ac9d46 (patch) | |
tree | d20f718f034395693a8010827e049b54e5763d87 /contrib/tar | |
parent | 4c4cc525a823b444d0fbbc9c0abb98dc943e4e99 (diff) | |
download | FreeBSD-src-64e4db86986a7cd56a202b1bcee6847dc6ac9d46.zip FreeBSD-src-64e4db86986a7cd56a202b1bcee6847dc6ac9d46.tar.gz |
Move patches into the src/contrib/tar.
Requested by: ps
Reviewed by: md5(1)
Diffstat (limited to 'contrib/tar')
-rw-r--r-- | contrib/tar/src/buffer.c | 4 | ||||
-rw-r--r-- | contrib/tar/src/common.h | 8 | ||||
-rw-r--r-- | contrib/tar/src/compare.c | 4 | ||||
-rw-r--r-- | contrib/tar/src/create.c | 4 | ||||
-rw-r--r-- | contrib/tar/src/list.c | 20 | ||||
-rw-r--r-- | contrib/tar/src/misc.c | 8 | ||||
-rw-r--r-- | contrib/tar/src/names.c | 35 | ||||
-rw-r--r-- | contrib/tar/src/rtapelib.c | 11 | ||||
-rw-r--r-- | contrib/tar/src/tar.c | 57 |
9 files changed, 117 insertions, 34 deletions
diff --git a/contrib/tar/src/buffer.c b/contrib/tar/src/buffer.c index 1d164b4..d20f5aa 100644 --- a/contrib/tar/src/buffer.c +++ b/contrib/tar/src/buffer.c @@ -19,6 +19,8 @@ with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* $FreeBSD$ */ + #include "system.h" #include <signal.h> @@ -1540,7 +1542,7 @@ new_volume (enum access_mode access) child = xfork (); if (child == 0) { - execlp (shell, "-sh", "-i", 0); + execlp (shell, "-sh", "-i", (char *) 0); exec_fatal (shell); } else diff --git a/contrib/tar/src/common.h b/contrib/tar/src/common.h index 4ea6a52..40e0ab6 100644 --- a/contrib/tar/src/common.h +++ b/contrib/tar/src/common.h @@ -17,6 +17,8 @@ with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* $FreeBSD$ */ + /* Declare the GNU tar archive format. */ #include "tar.h" @@ -152,6 +154,9 @@ GLOBAL int dereference_option; /* Patterns that match file names to be excluded. */ GLOBAL struct exclude *excluded; +/* Boolean value. */ +GLOBAL int fast_read_option; + /* Specified file containing names to work on. */ GLOBAL const char *files_from_option; @@ -196,6 +201,9 @@ GLOBAL struct mode_change *mode_option; /* Boolean value. */ GLOBAL int multi_volume_option; +/* Boolean value. */ +GLOBAL int namelist_freed; + /* The same variable hold the time, whether mtime or ctime. Just fake a non-existing option, for making the code clearer, elsewhere. */ #define newer_ctime_option newer_mtime_option diff --git a/contrib/tar/src/compare.c b/contrib/tar/src/compare.c index c3b9bb9..aecd6bd 100644 --- a/contrib/tar/src/compare.c +++ b/contrib/tar/src/compare.c @@ -19,6 +19,8 @@ with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* $FreeBSD$ */ + #include "system.h" #if HAVE_UTIME_H @@ -565,7 +567,7 @@ diff_archive (void) size_t len = strlen (current_link_name); char *linkbuf = alloca (len + 1); - status = readlink (current_file_name, linkbuf, len + 1); + status = readlink (current_file_name, linkbuf, len); if (status < 0) { diff --git a/contrib/tar/src/create.c b/contrib/tar/src/create.c index b3de6a8..e1f2dda 100644 --- a/contrib/tar/src/create.c +++ b/contrib/tar/src/create.c @@ -16,6 +16,8 @@ with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* $FreeBSD$ */ + #include "system.h" #if !MSDOS @@ -1473,7 +1475,7 @@ dump_file (char *p, int top_level, dev_t parent_device) if (linklen != current_stat.st_size || linklen + 1 == 0) xalloc_die (); buffer = (char *) alloca (linklen + 1); - size = readlink (p, buffer, linklen + 1); + size = readlink (p, buffer, linklen); if (size < 0) { if (ignore_failed_read_option) diff --git a/contrib/tar/src/list.c b/contrib/tar/src/list.c index e88d53b..9c68ae9 100644 --- a/contrib/tar/src/list.c +++ b/contrib/tar/src/list.c @@ -19,11 +19,16 @@ with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* $FreeBSD$ */ + /* Define to non-zero for forcing old ctime format instead of ISO format. */ #undef USE_OLD_CTIME #include "system.h" #include <quotearg.h> +#ifdef HAVE_LANGINFO_CODESET +#include <langinfo.h> +#endif #include "common.h" @@ -78,6 +83,10 @@ read_and (void (*do_something) ()) { prev_status = status; status = read_header (0); + /* check if the namelist got emptied during the course of reading */ + /* the tape, if so stop by setting status to EOF */ + if (namelist_freed) + status = HEADER_END_OF_FILE; switch (status) { case HEADER_STILL_UNREAD: @@ -832,6 +841,7 @@ stringify_uintmax_t_backwards (uintmax_t o, char *buf) char const * tartime (time_t t) { +#if !defined(__FreeBSD__) || !defined(HAVE_LANGINFO_CODESET) static char buffer[max (UINTMAX_STRSIZE_BOUND + 1, INT_STRLEN_BOUND (int) + 16)]; char *p; @@ -870,6 +880,16 @@ tartime (time_t t) while (buffer + sizeof buffer - 19 - 1 < p) *--p = ' '; return p; +#else /* __FreeBSD__ */ + static char buffer[80]; + static int d_first = -1; + + if (d_first < 0) + d_first = (*nl_langinfo(D_MD_ORDER) == 'd'); + strftime(buffer, sizeof(buffer), d_first ? "%e %b %R %Y" : "%b %e %R %Y", + localtime(&t)); + return buffer; +#endif /* __FreeBSD__ */ } /* Actually print it. diff --git a/contrib/tar/src/misc.c b/contrib/tar/src/misc.c index e90c248..10851fe 100644 --- a/contrib/tar/src/misc.c +++ b/contrib/tar/src/misc.c @@ -17,6 +17,8 @@ with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* $FreeBSD$ */ + #include "system.h" #include "rmt.h" #include "common.h" @@ -549,10 +551,8 @@ void chmod_error_details (char const *name, mode_t mode) { int e = errno; - char buf[10]; - decode_mode (mode, buf); - ERROR ((0, e, _("%s: Cannot change mode to %s"), - quotearg_colon (name), buf)); + ERROR ((0, e, _("%s: Cannot change mode to 0%o"), + quotearg_colon (name), mode)); } void diff --git a/contrib/tar/src/names.c b/contrib/tar/src/names.c index eb17636..2642515 100644 --- a/contrib/tar/src/names.c +++ b/contrib/tar/src/names.c @@ -17,6 +17,8 @@ with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* $FreeBSD$ */ + #include "system.h" #include <fnmatch.h> @@ -549,6 +551,7 @@ name_match (const char *path) while (1) { struct name *cursor = namelist; + struct name *tmpnlp; if (!cursor) return ! files_from_option; @@ -572,6 +575,38 @@ name_match (const char *path) nametail = &namelist; } chdir_do (cursor->change_dir); + if (fast_read_option) + { + /* remove the current entry, since we found a match */ + if (namelist->next == NULL) + { + /* the list contains one element */ + free(namelist); + namelist = 0; + nametail = &namelist; + /* set a boolean to decide wether we started with a */ + /* non-empty namelist, that was emptied */ + namelist_freed = 1; + } + else + { + if (cursor == namelist) + { + /* the first element is the one */ + tmpnlp = namelist->next; + free(namelist); + namelist = tmpnlp; + } + else + { + tmpnlp = namelist; + while (tmpnlp->next != cursor) + tmpnlp = tmpnlp->next; + tmpnlp->next = cursor->next; + free(cursor); + } + } + } /* We got a match. */ return 1; diff --git a/contrib/tar/src/rtapelib.c b/contrib/tar/src/rtapelib.c index ce141b4..295974e 100644 --- a/contrib/tar/src/rtapelib.c +++ b/contrib/tar/src/rtapelib.c @@ -32,6 +32,8 @@ into macros for speed by Jay Fenlason. Use -DWITH_REXEC for rexec code, courtesy of Dan Kegel. */ +/* $FreeBSD$ */ + #include "system.h" #include <safe-read.h> @@ -437,6 +439,9 @@ rmt_open__ (const char *path, int open_mode, int bias, const char *remote_shell) /* Identify the remote command to be executed. */ if (!remote_shell) + remote_shell = getenv("TAR_RSH"); + + if (!remote_shell) { #ifdef REMOTE_SHELL remote_shell = REMOTE_SHELL; @@ -488,10 +493,10 @@ rmt_open__ (const char *path, int open_mode, int bias, const char *remote_shell) #endif if (remote_user) - execl (remote_shell, remote_shell_basename, remote_host, - "-l", remote_user, "/etc/rmt", (char *) 0); + execlp (remote_shell, remote_shell_basename, "-l", remote_user, + remote_host, "/etc/rmt", (char *) 0); else - execl (remote_shell, remote_shell_basename, remote_host, + execlp (remote_shell, remote_shell_basename, remote_host, "/etc/rmt", (char *) 0); /* Bad problems if we get here. */ diff --git a/contrib/tar/src/tar.c b/contrib/tar/src/tar.c index 7d87f80..ab8ca20 100644 --- a/contrib/tar/src/tar.c +++ b/contrib/tar/src/tar.c @@ -19,6 +19,8 @@ with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* $FreeBSD$ */ + #include "system.h" #include <fnmatch.h> @@ -184,7 +186,9 @@ static struct option long_options[] = {"block-number", no_argument, 0, 'R'}, {"block-size", required_argument, 0, OBSOLETE_BLOCKING_FACTOR}, {"blocking-factor", required_argument, 0, 'b'}, + {"bzip", no_argument, 0, 'j'}, {"bzip2", no_argument, 0, 'j'}, + {"bunzip2", no_argument, 0, 'j'}, {"catenate", no_argument, 0, 'A'}, {"checkpoint", no_argument, &checkpoint_option, 1}, {"compare", no_argument, 0, 'd'}, @@ -200,6 +204,7 @@ static struct option long_options[] = {"exclude", required_argument, 0, EXCLUDE_OPTION}, {"exclude-from", required_argument, 0, 'X'}, {"extract", no_argument, 0, 'x'}, + {"fast-read", no_argument, &fast_read_option, 1}, {"file", required_argument, 0, 'f'}, {"files-from", required_argument, 0, 'T'}, {"force-local", no_argument, &force_local_option, 1}, @@ -230,6 +235,7 @@ static struct option long_options[] = {"no-ignore-case", no_argument, 0, NO_IGNORE_CASE_OPTION}, {"no-wildcards", no_argument, 0, NO_WILDCARDS_OPTION}, {"no-wildcards-match-slash", no_argument, 0, NO_WILDCARDS_MATCH_SLASH_OPTION}, + {"norecurse", no_argument, &recursion_option, 0}, {"no-recursion", no_argument, &recursion_option, 0}, {"no-same-owner", no_argument, &same_owner_option, -1}, {"no-same-permissions", no_argument, &same_permissions_option, -1}, @@ -266,6 +272,7 @@ static struct option long_options[] = {"touch", no_argument, 0, 'm'}, {"uncompress", no_argument, 0, 'Z'}, {"ungzip", no_argument, 0, 'z'}, + {"unlink", no_argument, 0, 'U'}, {"unlink-first", no_argument, 0, 'U'}, {"update", no_argument, 0, 'u'}, {"use-compress-program", required_argument, 0, USE_COMPRESS_PROGRAM_OPTION}, @@ -326,15 +333,17 @@ Operation modifiers:\n\ -k, --keep-old-files don't replace existing files when extracting\n\ --overwrite overwrite existing files when extracting\n\ --overwrite-dir overwrite directory metadata when extracting\n\ - -U, --unlink-first remove each file prior to extracting over it\n\ + -U, --unlink,\n\ + --unlink-first remove each file prior to extracting over it\n\ --recursive-unlink empty hierarchies prior to extracting directory\n\ -S, --sparse handle sparse files efficiently\n\ -O, --to-stdout extract files to standard output\n\ -G, --incremental handle old GNU-format incremental backup\n\ -g, --listed-incremental=FILE\n\ handle new GNU-format incremental backup\n\ - --ignore-failed-read do not exit with nonzero on unreadable files\n"), - stdout); + --ignore-failed-read do not exit with nonzero on unreadable files\n\ + --fast-read stop after desired names in archive have been found\n"), + stdout); fputs (_("\ \n\ Handling of file attributes:\n\ @@ -344,6 +353,8 @@ Handling of file attributes:\n\ --atime-preserve don't change access times on dumped files\n\ -m, --modification-time don't extract file modified time\n\ --same-owner try extracting files with the same ownership\n\ + --show-omitted-dirs show omitted directories while processing the\n\ + archive\n\ --no-same-owner extract files as yourself\n\ --numeric-owner always use numbers for user/group names\n\ -p, --same-permissions extract permissions information\n\ @@ -357,7 +368,7 @@ Handling of file attributes:\n\ \n\ Device selection and switching:\n\ -f, --file=ARCHIVE use archive file or device ARCHIVE\n\ - --force-local archive file is local even if has a colon\n\ + --force-local archive file is local even if it has a colon\n\ --rsh-command=COMMAND use remote COMMAND instead of rsh\n\ -[0-7][lmh] specify drive and density\n\ -M, --multi-volume create/list/extract multi-volume archive\n\ @@ -381,7 +392,7 @@ Archive format selection:\n\ PATTERN at list/extract time, a globbing PATTERN\n\ -o, --old-archive, --portability write a V7 format archive\n\ --posix write a POSIX format archive\n\ - -j, --bzip2 filter the archive through bzip2\n\ + -j, -y, --bzip, --bzip2, --bunzip2 filter the archive through bzip2\n\ -z, --gzip, --ungzip filter the archive through gzip\n\ -Z, --compress, --uncompress filter the archive through compress\n\ --use-compress-program=PROG filter through PROG (must accept -d)\n"), @@ -390,9 +401,9 @@ Archive format selection:\n\ \n\ Local file selection:\n\ -C, --directory=DIR change to directory DIR\n\ - -T, --files-from=NAME get names to extract or create from file NAME\n\ + -T, -I, --files-from=NAME get names to extract or create from file NAME\n\ --null -T reads null-terminated names, disable -C\n\ - --exclude=PATTERN exclude files, given as a PATTERN\n\ + --exclude=PATTERN exclude files, given as a a globbing PATTERN\n\ -X, --exclude-from=FILE exclude patterns listed in FILE\n\ --anchored exclude patterns match file name start (default)\n\ --no-anchored exclude patterns match after any /\n\ @@ -404,14 +415,17 @@ Local file selection:\n\ --no-wildcards-match-slash exclude pattern wildcards do not match '/'\n\ -P, --absolute-names don't strip leading `/'s from file names\n\ -h, --dereference dump instead the files symlinks point to\n\ + -n, --norecurse\n\ --no-recursion avoid descending automatically in directories\n\ -l, --one-file-system stay in local file system when creating archive\n\ -K, --starting-file=NAME begin at file NAME in the archive\n"), stdout); #if !MSDOS fputs (_("\ - -N, --newer=DATE only store files newer than DATE\n\ - --newer-mtime=DATE compare date and time when data changed only\n\ + -N, --newer=DATE only store files with creation time newer than\n\ + DATE\n\ + --newer-mtime=DATE only store files with modification time newer\n\ + than DATE\n\ --after-date=DATE same as -N\n"), stdout); #endif @@ -425,7 +439,7 @@ Informative output:\n\ --help print this help, then exit\n\ --version print tar program version number, then exit\n\ -v, --verbose verbosely list files processed\n\ - --checkpoint print directory names while reading the archive\n\ + --checkpoint print number of buffer reads/writes\n\ --totals print total bytes written while creating archive\n\ -R, --block-number show block number within archive with each message\n\ -w, --interactive ask for confirmation for every action\n\ @@ -467,7 +481,7 @@ or a file name starting with `/' or `.', in which case the file's date is used.\ Y per-block gzip compression */ #define OPTION_STRING \ - "-01234567ABC:F:GIK:L:MN:OPRST:UV:WX:Zb:cdf:g:hijklmoprstuvwxyz" + "-01234567ABC:F:GI:K:L:MnN:OPRST:UV:WX:Zb:cdf:g:hijklmoprstuvwxyz" static void set_subcommand_option (enum subcommand subcommand) @@ -507,6 +521,7 @@ decode_options (int argc, char **argv) excluded = new_exclude (); newer_mtime_option = TYPE_MINIMUM (time_t); recursion_option = FNM_LEADING_DIR; + namelist_freed = 0; owner_option = -1; group_option = -1; @@ -691,13 +706,8 @@ decode_options (int argc, char **argv) ignore_zeros_option = 1; break; - case 'I': - USAGE_ERROR ((0, 0, - _("Warning: the -I option is not supported;" - " perhaps you meant -j or -T?"))); - break; - case 'j': + case 'y': set_use_compress_program_option ("bzip2"); break; @@ -744,6 +754,10 @@ decode_options (int argc, char **argv) multi_volume_option = 1; break; + case 'n': + recursion_option = 0; + break; + #if !MSDOS case 'N': after_date_option = 1; @@ -834,6 +848,7 @@ decode_options (int argc, char **argv) break; case 'T': + case 'I': files_from_option = optarg; break; @@ -875,12 +890,6 @@ decode_options (int argc, char **argv) } break; - case 'y': - USAGE_ERROR ((0, 0, - _("Warning: the -y option is not supported;" - " perhaps you meant -j?"))); - break; - case 'z': set_use_compress_program_option ("gzip"); break; @@ -1266,7 +1275,7 @@ main (int argc, char **argv) #endif start_time = time (0); program_name = argv[0]; - setlocale (LC_ALL, ""); + (void) setlocale (LC_ALL, ""); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); |