Commit Graph

254 Commits

Author SHA1 Message Date
Paul Eggert
4dd9bd50bd (append_file): Open the file before statting it, to avoid a race.
Complain about file shrinkage only when we reach EOF.
1999-07-12 13:03:58 +00:00
Paul Eggert
d100b4033b Include safe-read.h. 1999-07-08 03:45:21 +00:00
Paul Eggert
8bbacf0b4f Include basename.h, save-read.h.
(rmt_open__): Use base_name to compute base name.
1999-07-08 03:45:21 +00:00
Paul Eggert
7962e1901b (read_and): Use excluded_filename instead of check_exclude.
Check base name of incoming file name, not entire file name, when
deciding whether to exclude it.
1999-07-08 03:45:21 +00:00
Paul Eggert
0a42307c1d (finish_sparse_file): Use excluded_filename instead of check_exclude.
Don't bother to stat excluded file names.
1999-07-08 03:45:21 +00:00
Paul Eggert
8e8acfbc97 (exclude_pool, exclude_pool_size, allocated_exclude_pool_size,
simple_exclude_array, simple_excludes, allocated_simple_excludes,
pattern_exclude_array, pattern_excludes, allocated_pattern_excludes,
add_exclude, add_exclude_file, check_exclude): Remove; now done in
../lib/exclude.c.
1999-07-08 03:45:21 +00:00
Paul Eggert
07f380748c (decode_options): Initialize `excluded'.
Use new add_exclude_file and add_exclude functions.
1999-07-08 03:45:21 +00:00
Paul Eggert
d46735235b Rename full_read to safe_read. 1999-07-05 06:47:59 +00:00
Paul Eggert
a8c32ecff2 Include signal.h.
(SIGCHLD): Define to SIGCLD if SIGCLD is defined but SIGCHLD is not.
(main): Ensure SIGCHLD is not ignored, so that we can fork and wait.
1999-07-03 00:00:19 +00:00
Paul Eggert
6f1783ad43 (BACKUP_OPTION, DELETE_OPTION, EXCLUDE_OPTION, GROUP_OPTION,
MODE_OPTION, NEWER_MTIME_OPTION, NO_RECURSE_OPTION, NULL_OPTION,
OWNER_OPTION, POSIX_OPTION, PRESERVE_OPTION, RECORD_SIZE_OPTION,
RSH_COMMAND_OPTION, SUFFIX_OPTION, USE_COMPRESS_PROGRAM_OPTION,
VOLNO_FILE_OPTION, OBSOLETE_ABSOLUTE_NAMES, OBSOLETE_BLOCK_COMPRESS,
OBSOLETE_BLOCKING_FACTOR, OBSOLETE_BLOCK_NUMBER,
OBSOLETE_READ_FULL_RECORDS, OBSOLETE_TOUCH, OBSOLETE_VERSION_CONTROL):
Make sure they can't be valid chars, so they don't overlap with char codes.
Use an enum instead of a lot of #defines.
(long_options, main, usage): Remove --ending-file option.
(OPTION_STRING): Remove -E.
1999-07-02 21:33:51 +00:00
Paul Eggert
bc88be110b Don't include <ctype.h>; system.h already does this.
(ISODIGIT, ISSPACE): Remove; now in system.h.
(read_and): Excise ending_file_option.
(decode_header): No need to AND mode with 07777; MODE_FROM_OCT
does this now.
(from_oct): Cast ISSPACE arg to unsigned char.
(mode_from_oct): Translate modes from external to internal form.
Do not complain about unrecognized mode bits.
(decode_mode): Do not assume mode bits have traditional Unix values.
1999-07-02 21:25:09 +00:00
Paul Eggert
db6dc02fa8 (rmt_lseek__): Convert lseek whence values to portable integers on the wire. 1999-07-02 21:25:09 +00:00
Paul Eggert
d091cd947a (main): Convert lseek whence values to portable integers on the wire.
Check for whence values out of range.
1999-07-02 21:25:09 +00:00
Paul Eggert
0f32adce25 (extr_init, make_directories, extract_archive):
Do not assume mode bits have traditional Unix values.
(set_mode): Use %04 not %0.4 format.
(extract_sparse_file): Do not use data_block uninitialized.
Check for lseek failures; use portable lseek whence values.
1999-07-02 21:25:09 +00:00
Paul Eggert
6eafcf3c9d Add braces to pacify gcc -Wall. 1999-07-02 21:05:50 +00:00
Paul Eggert
66e89f0fa5 (mode_to_oct): Do not assume internal mode_t and external octal modes
have the same bit patterns.
(start_header): Do not assume mode bits have traditional Unix values.
(finish_sparse_file): Use lseek whence macros instead of integers.
(dump_file): Do not assume mode bits have traditional Unix values.
Do not invoke finish_sparse_file on a negative file descriptor.
1999-07-02 21:05:50 +00:00
Paul Eggert
99dc4251f9 (child_open_for_compress): Use portable modes.
(child_open_for_uncompress, open_archive): Likewise.
(backspace_output): Use portable whence values.
(close_archive): Likewise.  Remove ending_file_option.
1999-07-02 06:08:46 +00:00
Paul Eggert
aa985330d5 \a doesn't work with msgfmt.
Fix copyright notice.
1999-07-01 21:01:44 +00:00
Paul Eggert
6290150c47 Fix copyright notice. 1999-07-01 21:01:44 +00:00
Paul Eggert
1521a94b11 Handle EINTR correctly; use STDIN_FILENO instead of 0, etc. 1999-06-29 02:26:25 +00:00
Paul Eggert
ee734033e8 (write_archive_buffer): New function.
(child_open_for_compress, flush_write, flush_read): Use it to write
buffers.
(open_archive): Report error if fstat of archive fails.
Improve efficiency of check for /dev/null.
Also, fix some corner cases with remote archives and /dev/null checking.
(close_archive): Test for input fifo only if not remote.
Truncate output archive only if it's not remote.
1999-06-25 23:28:08 +00:00
Paul Eggert
805b08cf02 (to_oct): Prepend leading zeros, not spaces.
Output a trailing NUL unless the value won't fit without it;
this is backward compatible with Unix tar (and with GNU Emacs).
(finish_header): No need to append NUL to chksum, now that
to_oct is doing it.
1999-06-19 06:19:27 +00:00
Paul Eggert
ec424c77a9 Move include of backupfile.h to common.h. 1999-06-16 12:44:52 +00:00
Paul Eggert
72adbbda36 (backup_type): Remove decl; backupfile.h now has it.
(intconv): Remove; use xstrto* fns instead.
("xstrtol.h"): Include.
(check_decimal): Remove.
(long_options, usage, OPTION_STRING, decode_options):
Remove -y, --bzip2, --unbzip2.
(decode_options): Use xget_version instead of get_version.
Check for overflow with -b and -L and RECORD_SIZE_OPTION.
Replace invocations of check_decimal  with xstrtoumax.
1999-06-16 11:14:15 +00:00
Paul Eggert
69e400d4e0 (print_header): Change sizes of uform and gform from 11 to
UINTMAX_STRSIZE_BOUND.
1999-06-16 11:04:02 +00:00
Paul Eggert
f31b9d842b Include <quotearg.h>.
(from_oct): Add forward decl.
(read_header): Return HEADER_FAILURE if we can't parse the checksum.
(from_oct): Report an error only if TYPE is nonzero.
Quote any funny characters in bad header.
1999-03-22 22:06:22 +00:00
Paul Eggert
13617c42d8 (to_oct): New parameter substitute, giving a substitute value to use
when the original value is out of range.  Do not append a space to the
output; modern tars don't.  When a value is out of range, specify the
maximum value, not the number of bits.
(GID_NOBODY, UID_NOBODY): New macros.
(gid_to_oct, uid_to_oct): Use them as substitutes.
(finish_header): Do not assume that UINTMAX_TO_OCT appends a space.
(dump_file): Check whether the file changed as we read it.
1999-03-02 00:10:11 +00:00
Paul Eggert
00a2b4708f (main): Remove suspicious AIX/386 code. 1999-03-02 00:10:11 +00:00
Paul Eggert
545ec1a3fa (gid_from_oct, major_from_oct, minor_from_oct, mode_from_oct, off_from_oct,
size_from_oct, time_from_oct, uid_from_oct, uintmax_from_oct):
Use TYPE_MAXIMUM instead of macros like OFF_MAX, which are not reliable
(e.g. OFF_MAX in AIX 4.2 is incorrect).
1999-03-02 00:10:11 +00:00
Paul Eggert
f561403bad (long_options, usage): Prefer --unbzip2 to --bunzip2. 1999-02-20 06:04:28 +00:00
Paul Eggert
16368da655 Update copyright. 1999-02-01 08:10:25 +00:00
Paul Eggert
6ccb513321 (long_options, usage, OPTION_STRING, decode_options):
Add -y or --bzip2 or --bunzip2 option.
1999-02-01 07:51:19 +00:00
Paul Eggert
7381ee26dd (extract_archive): Fix bug when extracting sparse files: they were
trashing the tar file header.
1999-02-01 07:51:19 +00:00
Paul Eggert
2e4d78d856 (cached_no_such_uname, cached_no_such_gname, cached_no_such_uid,
cached_no_such_gid): New vars.
(uid_to_uname, gid_to_gname, uname_to_uid, gname_to_gid):
Cache failures, too.
1999-01-31 02:53:47 +00:00
Paul Eggert
562d543b2d (decode_options): Don't pass names longer than UNAME_FIELD_SIZE to
uname_to_uid, as it messes up the cache.  Similarly for gname_to_uid.
1999-01-31 02:52:16 +00:00
Paul Eggert
5019d3b2d9 (backspace_output, close_archive): Cast rmtlseek position arg to off_t,
for benefit of K&R compilers with long long.
1999-01-28 00:28:41 +00:00
Paul Eggert
3ca6dbbb22 (gid_to_oct, major_to_oct, minor_to_oct, mode_to_oct, off_to_oct,
size_to_oct, time_to_oct, uid_to_oct): Cast value to uintmax_t, for
benefit of pre-ANSI compilers with long long.
1999-01-27 20:42:30 +00:00
Paul Eggert
c7f56e640d (gid_from_oct, major_from_oct, minor_from_oct, mode_from_oct,
off_from_oct, size_from_oct, time_from_oct, uid_from_oct):
Cast limit to uintmax_t, for
benefit of pre-ANSI compilers with long long.
1999-01-27 20:42:30 +00:00
Paul Eggert
e1ac06bcca (read_header): Accept file names as specified by POSIX.1-1996 section 10.1.1. 1998-12-07 22:36:22 +00:00
Paul Eggert
53a5ac41d2 (set_stat): chmod after chown even when not root; if we are using
--same-owner this is needed e.g. on Solaris 2.5.1.
1998-11-30 22:17:11 +00:00
Paul Eggert
b9ca9399a1 Don't use rexec code unless compiled with WITH_REXEC. On many
installations, rexec is disabled.
1998-10-29 02:22:34 +00:00
Paul Eggert
b21cfb5780 Ghostscript 6.0 1998-09-09 23:52:32 +00:00
Paul Eggert
887188311d (uid_to_uname, gid_to_gname): Don't used cached name for nameless
users and groups.
1998-08-07 19:09:15 +00:00
junio
4559fdbfb1 Implement -E (ending-file) option. 1997-12-04 07:07:11 +00:00
junio
d1f1e3a189 Implement -E (ending-file) option. 1997-12-04 06:37:52 +00:00
Paul Eggert
56569a0f75 (main): Don't assume mt_count is of type daddr_t. 1997-11-10 19:13:12 +00:00
Paul Eggert
48be206fbf (to_oct): Now static. Value arg is now uintmax_t. Accept new args
giving name of type of octal field, for error messages.  Report an
error if the value is too large to fit in the field.
(gid_to_oct, major_to_oct, minor_to_oct, mode_to_oct, off_to_oct,
size_to_oct, time_to_oct, uid_to_oct, uintmax_to_oct): New functions.

(write_eot, write_long, finish_header, deal_with_sparse,
finish_sparse_file, dump_file): Use dev_t, off_t, ssize_t, size_t when
appropriate.  Remove now-useless casts.  Use unsigned long to print
*_t types, except use STRINGIFY_BIGINT for off_t.

(find_new_file_size): 1st arg is now off_t*.
(finish_sparse_file): Args now use off_t, not long.
Check for lseek error.
(create_archive, dump_file): Cast -1 to dev_t when necessary.
(dump_file): Device arg is now dev_t.
Avoid overflow when testing whether file has holes
by using the new ST_NBLOCKSIZE macro.
1997-10-31 00:58:55 +00:00
Paul Eggert
293c604c5d (rmt_read__, rmt_write__): Now returns ssize_t.
(rmt_lseek): Now returns off_t.
1997-10-31 00:58:55 +00:00
Paul Eggert
ac8cfdacf6 (record_start_block, save_totsize, save_sizeleft, real_s_totsize,
real_s_sizeleft, current_block_ordinal): Now off_t.
(write_error): Arg is now ssize_t.
(child_pid): Now pid_t.
(available_space_after): Now size_t.

(child_open_for_compress, child_open_for_uncompress, flush_write,
open_archive, flush_write, write_error, flush_read, close_archive):
Use pid_t, ssize_t, size_t when appropriate.  Remove now-useless
casts.  Use unsigned long to print *_t types, except use
STRINGIFY_BIGINT for off_t.
1997-10-31 00:58:55 +00:00
Paul Eggert
241bbee81b (read_and, list_archive, read_header, decode_mode, print_header,
print_for_mkdir): Use mode_t, off_t, size_t when appropriate.  Remove
now-useless casts.  Use unsigned long to print *_t types, except use
STRINGIFY_BIGINT for off_t.

(read_header): Check for overflow when converting header size.

(from_oct): Now static.  Now returns uintmax_t.  `where' arg is now
const char *.  Size arg is now size_t.  Now takes new type and maxval
args.  Compute result using uintmax_t, not long.  Report error if
field does not contain octal number in range.
(gid_from_oct, major_from_oct, minor_from_oct, mode_from_oct,
off_from_oct, size_from_oct, time_from_oct, uid_from_oct,
uintmax_from_oct): New functions.

(stringify_uintmax_t_backwards): New function.

(decode_mode, print_for_mkdir): Mode arg is now mode_t.
(skip_file): Offset arg is now off_t.
1997-10-31 00:58:55 +00:00