X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Fcreate.c;h=71bacc4058751133b7665cd8e776a4f16cf78742;hb=15a607fc11d8563fe471924fb6e718ceb9adfce4;hp=cc75bb8bf059d90906ff365d6188db687faea592;hpb=93a4273b66545b6c072567d01c8846dc0840d2ed;p=chaz%2Ftar diff --git a/src/create.c b/src/create.c index cc75bb8..71bacc4 100644 --- a/src/create.c +++ b/src/create.c @@ -1,7 +1,7 @@ /* Create a tar archive. Copyright (C) 1985, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001, - 2003 Free Software Foundation, Inc. + 2003, 2004 Free Software Foundation, Inc. Written by John Gilmore, on 1985-08-25. @@ -519,7 +519,16 @@ write_long_name (struct tar_stat_info *st) xheader_store ("path", st, NULL); break; - case V7_FORMAT: + case V7_FORMAT: + if (strlen (st->file_name) > NAME_FIELD_SIZE-1) + { + WARN ((0, 0, _("%s: file name is too long (max %d); not dumped"), + quotearg_colon (st->file_name), + NAME_FIELD_SIZE - 1)); + return NULL; + } + break; + case USTAR_FORMAT: case STAR_FORMAT: return write_ustar_long_name (st->file_name); @@ -539,7 +548,6 @@ static union block * write_extended (struct tar_stat_info *st, union block *old_header) { union block *header, hp; - size_t size; char *p; if (extended_header.buffer || extended_header.stk == NULL) @@ -558,7 +566,12 @@ write_extended (struct tar_stat_info *st, union block *old_header) static union block * write_header_name (struct tar_stat_info *st) { - if (NAME_FIELD_SIZE < strlen (st->file_name)) + if (archive_format == POSIX_FORMAT && !string_ascii_p (st->file_name)) + { + xheader_store ("path", st, NULL); + return write_short_name (st); + } + else if (NAME_FIELD_SIZE < strlen (st->file_name)) return write_long_name (st); else return write_short_name (st); @@ -663,7 +676,7 @@ start_header (struct tar_stat_info *st) xheader_store ("ctime", st, NULL); } else if (incremental_option) - if (archive_format == OLDGNU_FORMAT) + if (archive_format == OLDGNU_FORMAT || archive_format == GNU_FORMAT) { TIME_TO_CHARS (st->stat.st_atime, header->oldgnu_header.atime); TIME_TO_CHARS (st->stat.st_ctime, header->oldgnu_header.ctime); @@ -702,13 +715,15 @@ start_header (struct tar_stat_info *st) gid_to_gname (st->stat.st_gid, &st->gname); if (archive_format == POSIX_FORMAT - && strlen (st->uname) > UNAME_FIELD_SIZE) + && (strlen (st->uname) > UNAME_FIELD_SIZE + || !string_ascii_p (st->uname))) xheader_store ("uname", st, NULL); else UNAME_TO_CHARS (st->uname, header->header.uname); if (archive_format == POSIX_FORMAT - && strlen (st->gname) > GNAME_FIELD_SIZE) + && (strlen (st->gname) > GNAME_FIELD_SIZE + || !string_ascii_p (st->gname))) xheader_store ("gname", st, NULL); else GNAME_TO_CHARS (st->gname, header->header.gname); @@ -755,10 +770,6 @@ void finish_header (struct tar_stat_info *st, union block *header, off_t block_ordinal) { - size_t i; - int sum; - char *p; - /* Note: It is important to do this before the call to write_extended(), so that the actual ustar header is printed */ if (verbose_option @@ -972,8 +983,8 @@ dump_dir0 (char *directory, return; if (one_file_system_option - && !top_level - && parent_device != stat->stat.st_dev) + && !top_level + && parent_device != stat->stat.st_dev) { if (verbose_option) WARN ((0, 0, @@ -1293,12 +1304,11 @@ dump_file0 (struct tar_stat_info *stat, char *p, /* See if we want only new files, and check if this one is too old to put in the archive. */ - if ((0 < top_level || !incremental_option) - && !S_ISDIR (stat->stat.st_mode) + if (!S_ISDIR (stat->stat.st_mode) && stat->stat.st_mtime < newer_mtime_option && (!after_date_option || stat->stat.st_ctime < newer_ctime_option)) { - if (0 < top_level) + if (0 < top_level) /* equivalent to !incremental_option */ WARN ((0, 0, _("%s: file is unchanged; not dumped"), quotearg_colon (p))); /* FIXME: recheck this return. */