mirror of
https://git.savannah.gnu.org/git/tar.git
synced 2026-07-27 15:42:37 +00:00
* src/common.h (transform_symlinks_option): New global.
* src/create.c (dump_file0): Transform symlink targets only if explicitly required. Thanks Cyril Strejc for reporting the problem. * src/tar.c (parse_opt): New options --transform-symlinks and --no-transform-symlinks. New alias --xform to the --transform option. * doc/tar.texi: Document --transform-symlinks * NEWS: Update. * THANKS: Update. * src/names.c (name_gather): Use xzalloc. * src/buffer.c (short_read): Move record size detection before the loop.
This commit is contained in:
+12
-16
@@ -686,6 +686,18 @@ short_read (size_t status)
|
||||
more = record_start->buffer + status;
|
||||
left = record_size - status;
|
||||
|
||||
if (left && left % BLOCKSIZE == 0
|
||||
&& !read_full_records && verbose_option > 1
|
||||
&& record_start_block == 0 && status != 0)
|
||||
{
|
||||
unsigned long rsize = status / BLOCKSIZE;
|
||||
WARN ((0, 0,
|
||||
ngettext ("Record size = %lu block",
|
||||
"Record size = %lu blocks",
|
||||
rsize),
|
||||
rsize));
|
||||
}
|
||||
|
||||
while (left % BLOCKSIZE != 0
|
||||
|| (left && status && read_full_records))
|
||||
{
|
||||
@@ -707,26 +719,10 @@ short_read (size_t status)
|
||||
rest));
|
||||
}
|
||||
|
||||
/* User warned us about this. Fix up. */
|
||||
|
||||
left -= status;
|
||||
more += status;
|
||||
}
|
||||
|
||||
/* FIXME: for size=0, multi-volume support. On the first record, warn
|
||||
about the problem. */
|
||||
|
||||
if (!read_full_records && verbose_option > 1
|
||||
&& record_start_block == 0 && status != 0)
|
||||
{
|
||||
unsigned long rsize = (record_size - left) / BLOCKSIZE;
|
||||
WARN ((0, 0,
|
||||
ngettext ("Record size = %lu block",
|
||||
"Record size = %lu blocks",
|
||||
rsize),
|
||||
rsize));
|
||||
}
|
||||
|
||||
record_end = record_start + (record_size - left) / BLOCKSIZE;
|
||||
records_read++;
|
||||
}
|
||||
|
||||
@@ -346,6 +346,9 @@ GLOBAL bool unquote_option;
|
||||
|
||||
GLOBAL bool test_label_option; /* Test archive volume label and exit */
|
||||
|
||||
/* Apply transformations to symlink targets as well. */
|
||||
GLOBAL bool transform_symlinks_option;
|
||||
|
||||
/* Show file or archive names after transformation.
|
||||
In particular, when creating archive in verbose mode, list member names
|
||||
as stored in the archive */
|
||||
|
||||
+2
-1
@@ -1705,7 +1705,8 @@ dump_file0 (struct tar_stat_info *st, const char *p,
|
||||
}
|
||||
buffer[size] = '\0';
|
||||
assign_string (&st->link_name, buffer);
|
||||
transform_name (&st->link_name);
|
||||
if (transform_symlinks_option)
|
||||
transform_name (&st->link_name);
|
||||
if (NAME_FIELD_SIZE - (archive_format == OLDGNU_FORMAT) < size)
|
||||
write_long_link (st);
|
||||
|
||||
|
||||
+1
-3
@@ -388,9 +388,7 @@ name_gather (void)
|
||||
if (allocated_size == 0)
|
||||
{
|
||||
allocated_size = offsetof (struct name, name) + NAME_FIELD_SIZE + 1;
|
||||
buffer = xmalloc (allocated_size);
|
||||
/* FIXME: This memset is overkill, and ugly... */
|
||||
memset (buffer, 0, allocated_size);
|
||||
buffer = xzalloc (allocated_size);
|
||||
}
|
||||
|
||||
while ((ep = name_next_elt (0)) && ep->type == NELT_CHDIR)
|
||||
|
||||
@@ -287,6 +287,7 @@ enum
|
||||
NO_RECURSION_OPTION,
|
||||
NO_SAME_OWNER_OPTION,
|
||||
NO_SAME_PERMISSIONS_OPTION,
|
||||
NO_TRANSFORM_SYMLINKS_OPTION,
|
||||
NO_UNQUOTE_OPTION,
|
||||
NO_WILDCARDS_MATCH_SLASH_OPTION,
|
||||
NO_WILDCARDS_OPTION,
|
||||
@@ -321,6 +322,7 @@ enum
|
||||
TOTALS_OPTION,
|
||||
TO_COMMAND_OPTION,
|
||||
TRANSFORM_OPTION,
|
||||
TRANSFORM_SYMLINKS_OPTION,
|
||||
UNQUOTE_OPTION,
|
||||
USAGE_OPTION,
|
||||
USE_COMPRESS_PROGRAM_OPTION,
|
||||
@@ -686,6 +688,11 @@ static struct argp_option options[] = {
|
||||
GRID+1 },
|
||||
{"transform", TRANSFORM_OPTION, N_("EXPRESSION"), 0,
|
||||
N_("use sed replace EXPRESSION to transform file names"), GRID+1 },
|
||||
{"xform", 0, 0, OPTION_ALIAS, NULL, GRID+1 },
|
||||
{"transform-symlinks", TRANSFORM_SYMLINKS_OPTION, NULL, 0,
|
||||
N_("apply transformations to symlink targets"), GRID+1 },
|
||||
{"no-transform-symlinks", NO_TRANSFORM_SYMLINKS_OPTION, NULL, 0,
|
||||
N_("cancel effect of the previous --transform-symlinks option"), GRID+1 },
|
||||
#undef GRID
|
||||
|
||||
#define GRID 120
|
||||
@@ -1819,6 +1826,8 @@ parse_opt (int key, char *arg, struct argp_state *state)
|
||||
/* FIXME: What it is good for? */
|
||||
same_permissions_option = true;
|
||||
same_order_option = true;
|
||||
WARN ((0, 0, _("The --preserve option is deprecated, "
|
||||
"use --preserve-permissions --preserve-order instead")));
|
||||
break;
|
||||
|
||||
case RECORD_SIZE_OPTION:
|
||||
@@ -1902,6 +1911,14 @@ parse_opt (int key, char *arg, struct argp_state *state)
|
||||
set_transform_expr (arg);
|
||||
break;
|
||||
|
||||
case TRANSFORM_SYMLINKS_OPTION:
|
||||
transform_symlinks_option = true;
|
||||
break;
|
||||
|
||||
case NO_TRANSFORM_SYMLINKS_OPTION:
|
||||
transform_symlinks_option = false;
|
||||
break;
|
||||
|
||||
case USE_COMPRESS_PROGRAM_OPTION:
|
||||
set_use_compress_program_option (arg);
|
||||
break;
|
||||
@@ -2345,6 +2362,10 @@ decode_options (int argc, char **argv)
|
||||
|
||||
if (tape_length_option && tape_length_option < record_size)
|
||||
USAGE_ERROR ((0, 0, _("Volume length cannot be less than record size")));
|
||||
|
||||
if (same_order_option && listed_incremental_option)
|
||||
USAGE_ERROR ((0, 0, _("--preserve-order is not compatible with "
|
||||
"--listed-incremental")));
|
||||
|
||||
/* Forbid using -c with no input files whatsoever. Check that `-f -',
|
||||
explicit or implied, is used correctly. */
|
||||
|
||||
Reference in New Issue
Block a user