[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-tar] merge of gnulib changes into tar, plus some lint cleanup
From: |
Paul Eggert |
Subject: |
[Bug-tar] merge of gnulib changes into tar, plus some lint cleanup |
Date: |
Sun, 04 Apr 2004 19:35:04 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
I installed the following patch to merge the last few months' worth of
gnulib updates into GNU tar. You need to fetch the latest gnulib and
then do a bootstrap after upgrading to this patch.
This patch also removes some lint I found, part due to the gnulib
update and part that was lying around waiting to be discovered.
The only user-visible changes are somewhat-better support for
nanosecond-resolution time stamps. However, this isn't fully done yet
(e.g., incremental dumps still use 1-second time stamps, for backward
compatibility) so I didn't change the documentation or NEWS.
2004-04-04 Paul Eggert <address@hidden>
Merge recent gnulib changes, and remove some lint.
Improve support for nanosecond-resolution time stamps.
* bootstrap: Add gettime, timespec modules.
* configure.ac (gl_GETTIME, gl_TIMESPEC): Add.
* lib/.cvsignore (getopt_int.h, gettime.c, gettimeofday.c,
timespec.h): Add.
* lib/Makefile.am (libtar_a_SOURCES): Add gettime.c, timespec.h.
* m4/.cvsignore: Add clock_time.m4, gettime.m4, gettimeofday.m4,
st_mtim.m4, timespec.m4. Remove malloc.m4, realloc.m4.
* src/common.h (newer_mtime_option): Now a struct timespec, not
time_t. All uses changed.
(NEWER_OPTION_INITIALIZED, OLDER_STAT_MTIME): New macros.
* src/create.c (dump_file0): Use OLDER_STAT_TIME to compare times.
* src/incremen.c (scan_path): Likewise.
* src/list.c (read_and): Likewise.
* src/list.c (read_and): Use NEWER_OPTION_INITIALIZED to decide
whether newer_mtime_option is initialized.
* src/tar.c (decode_options): Likewise.
* src/tar.c (decode_options): Adjust to new signature for get_date.
* src/buffer.c (short_read, flush_read): Use size_t, not ssize_t, for
result of safe_read, full_write, and similar functions.
Detect safe_read error by comparing to SAFE_READ_ERROR;
detect full_write error by comparing to 0.
All uses changed.
* src/common.h (write_error_details, sys_write_archive_buffer):
Likewise.
* src/misc.c (write_error_details): Likewise.
* src/rmt.c (main): Likewise.
* src/rmt.h (rmt_read__, rmt_write__): Likewise.
* src/rtapelib.c (rmt_read__, rmt_write__, rmt_ioctl__): Likewise.
* src/sparse.c (sparse_scan_file, sparse_dump_region,
check_sparse_region, check_data_region): Likewise.
* src/system.c (sys_write_archive_buffer, sys_drain_input_pipe,
sys_child_open_for_compress, sys_child_open_for_uncompress): Likewise.
* src/update.c (append_file): Likewise.
* src/buffer.c (clear_read_error_count): Use explicit (void)
to indicate a function with no arguments.
* src/create.c (check_links): Likewise.
* src/system.c (sys_get_archive_stat, sys_save_archive_dev_ino,
sys_detect_dev_null_output, sys_drain_input_pipe, sys_spawn_shell,
sys_reset_uid_gid, sys_get_archive_stat, sys_save_archive_dev_ino,
sys_detect_dev_null_output, sys_drain_input_pipe, sys_spawn_shell):
Likewise.
* src/utf8.c (get_input_charset): Likewise.
* src/xheader.c (xheader_ghdr_name, xheader_write_global,
xheader_decode_global, extended_header_init): Likewise.
* tests/mksparse.c (usage): Likewise.
* src/buffer.c (new_volume): Rename local variables to avoid
shadowing warnings.
* src/common.h (file_dumpable_p, sys_stat_nanoseconds,
sparse_file_p, sparse_member_p, sparse_fixup_header,
sparse_dump_file, sparce_extract_file, sparse_skip_file,
sparse_diff_file): Likewise.
* src/compare.c (diff_archive): Likewise.
* src/create.c (file_dumpable_p, dump_regular_file, dump_dir0,
dump_dir, dump_hard_link, file_count_links, dump_file0, dump_file):
Likewise.
* src/extract.c (repair_delayed_set_stat): Likewise.
* src/misc.c (maybe_backup_file, add_hierarchy_to_namelist):
Likewise.
* src/sparse.c (struct tar_sparse_optab, tar_sparse_dump_region,
tar_sparse_extract_region, sparse_dump_region, sparse_extract_region,
sparse_dump_file, sparse_file_p, sparse_member_p,
sparse_fixup_header, sparse_extract_file, sparse_skip_file,
check_data_region, sparse_diff_file): Likewise.
* src/system.c (sys_stat_nanoseconds): Likewise.
* src/xheader.c (xheader_format_name): Likewise.
* src/common.h (enum old_files): Remove comma before }; not portable.
* src/common.h (read_fatal_details): Add __attribute__ ((noreturn)).
* src/rmt.c (usage): Likewise.
* src/xheader.c (xheader_set_single_keyword): Likewise.
* tests/genfile.c (usage): Likewise.
* tests/mksparse.c (die, usage): Likewise. Also add printf attribute
to die.
* src/common.h (gname_to_gid, uname_to_uid): Add const to avoid
some gcc warnings.
* src/names.c (uname_to_uid, gname_to_gid): Likewise.
* src/utf8.c (struct langtab.lang, struct langtab.terr, struct
langtab.charset, charset_lookup): Likewise.
* src/common.h (name_init): Remove unused args. All callers changed.
* src/names.c (name_init): Likewise.
* src/common.h (usage, xheader_write, xheader_write_global,
sys_reset_uid_gid): New decls.
* src/compare.c (report_difference, process_noop): Add
__attribute__ ((unused)) for unused attributes.
* src/sparse.c (oldgnu_sparse_member_p, star_sparse_member_p):
Likewise.
* src/xheader.c (dummy_coder, dummy_decoder, atime_coder,
gid_coder, gname_coder, linkpath_coder, ctime_coder, mtime_coder,
path_coder, size_coder, uid_coder, uname_coder,
sparse_numblocks_coder): Likewise.
* src/create.c (dump_regular_finish, dump_dir0, dump_dir,
dump_file0): Now static.
* src/utf8.c (charset_lookup): Likewise.
* src/xheader.c (xheader_protected_pattern_p,
xheader_protected_keyword_p, xheader_set_single_keyword,
xheader_keyword_deleted_p, xheader_keyword_override_p,
xheader_list_append, xheader_list_destroy, xheader_set_keyword_equal):
Likewise.
* tests/genfile.c (usage): Likewise.
* tests/mksparse.c (die, mkhole, mksparse, usage, xlat_suffix):
Likewise.
* src/create.c (hash_link): Rewrite to avoid cast.
* src/extract.c (file_newer_p): Use parameter, not global var.
* src/misc.c (write_error_details): Likewise.
* src/extract.c (prepare_to_extract): Remove directory arg; not
used. All callers changed.
* src/misc.c (close_fatal): Remove; not used.
* src/system.c (sys_utimes): Likewise.
* src/rmt.c (get_string): Avoid buffer overrun (off by 1 error).
* src/rmt.c (main): Update copyright date to 2004.
* src/tar.c (decode_options): Likewise.
* src/rtapelib.c (get_status_string): Don't lose errno when
skipping the error messages.
(get_status): Report an error if atol returns a negative number.
* src/utf8.c (struct langtab, langtab, charset_lookup,
get_input_charset) [!defined HAVE_LIBCONV]: Omit unused
definitions.
(iconv_open, iconv, iconv_close) [!defined HAVE_LIBCONV]:
Use macros, not definitions, to avoid type clashes with system
headers.
(charset_lookup): Local var is now auto, not static.
(utf8_convert): Use ICONV_CONST instead of const, to avoid
type clashes.
* src/utf8.c (langtab): Initialize all elements of struct, to
avoid gcc warning.
* src/xheader.c (xhdr_tab): Likewise.
* src/xheader.c: Include fnmatch.h, since we use fnmatch.
* tests/mksparse.c (mkhole): Fix typo: bool was assigned to off_t.
Index: bootstrap
===================================================================
RCS file: /cvsroot/tar/tar/bootstrap,v
retrieving revision 1.12
diff -p -b -u -r1.12 bootstrap
--- bootstrap 18 Feb 2004 14:39:24 -0000 1.12
+++ bootstrap 5 Apr 2004 02:20:46 -0000
@@ -2,7 +2,7 @@
# Bootstrap 'tar' from CVS.
-# Copyright (C) 2003 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2004 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -133,6 +133,7 @@ getdate
getline
getopt
gettext
+gettime
hash
human
lchown
@@ -149,6 +150,7 @@ stdbool
stpcpy
strtol
strtoul
+timespec
unlocked-io
utime
xalloc
Index: configure.ac
===================================================================
RCS file: /cvsroot/tar/tar/configure.ac,v
retrieving revision 1.33
diff -p -b -u -r1.33 configure.ac
--- configure.ac 4 Apr 2004 13:30:42 -0000 1.33
+++ configure.ac 5 Apr 2004 02:20:46 -0000
@@ -119,6 +119,7 @@ gl_FUNC_STRTOIMAX
gl_FUNC_STRTOUMAX
gl_GETDATE
gl_GETOPT
+gl_GETTIME
gl_HASH
gl_HUMAN
gl_MODECHANGE
@@ -132,6 +133,7 @@ gl_SAVE_CWD
gl_SAVEDIR
gl_STRCASE
gl_TIME_R
+gl_TIMESPEC
gl_XALLOC
gl_XGETCWD
gl_XSTRTOL
Index: lib/.cvsignore
===================================================================
RCS file: /cvsroot/tar/tar/lib/.cvsignore,v
retrieving revision 1.5
diff -p -b -u -r1.5 .cvsignore
--- lib/.cvsignore 18 Feb 2004 14:49:08 -0000 1.5
+++ lib/.cvsignore 5 Apr 2004 02:20:46 -0000
@@ -37,7 +37,10 @@ getndelim2.h
getopt.c
getopt.h
getopt1.c
+getopt_int.h
gettext.h
+gettime.c
+gettimeofday.c
hash.c
hash.h
human.c
@@ -68,6 +71,8 @@ savedir.c
savedir.h
stdbool.h
stdbool_.h
+stpcpy.c
+stpcpy.h
strcase.h
strcasecmp.c
stripslash.c
@@ -78,10 +83,9 @@ strtoll.c
strtoul.c
strtoull.c
strtoumax.c
-stpcpy.c
-stpcpy.h
time_r.c
time_r.h
+timespec.h
unlocked-io.h
utime.c
xalloc.h
Index: lib/Makefile.am
===================================================================
RCS file: /cvsroot/tar/tar/lib/Makefile.am,v
retrieving revision 1.19
diff -p -b -u -r1.19 Makefile.am
--- lib/Makefile.am 18 Feb 2004 14:39:24 -0000 1.19
+++ lib/Makefile.am 5 Apr 2004 02:20:46 -0000
@@ -1,7 +1,7 @@
# Makefile for GNU tar library.
-# Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2003 Free
-# Software Foundation, Inc.
+# Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2003, 2004
+# Free Software Foundation, Inc.
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@@ -103,6 +103,9 @@ libtar_a_SOURCES += getopt.h getopt.c ge
# gettext
libtar_a_SOURCES += gettext.h
+# gettime
+libtar_a_SOURCES += gettime.c
+
# hash
libtar_a_SOURCES += hash.h hash.c
@@ -120,6 +123,9 @@ libtar_a_SOURCES += pathmax.h
# time_r
EXTRA_DIST += time_r.h
+
+# timespec
+libtar_a_SOURCES += timespec.h
# quote
libtar_a_SOURCES += quote.h quote.c
Index: m4/.cvsignore
===================================================================
RCS file: /cvsroot/tar/tar/m4/.cvsignore,v
retrieving revision 1.6
diff -p -b -u -r1.6 .cvsignore
--- m4/.cvsignore 18 Feb 2004 14:44:53 -0000 1.6
+++ m4/.cvsignore 5 Apr 2004 02:20:46 -0000
@@ -4,6 +4,7 @@ alloca.m4
backupfile.m4
bison.m4
chown.m4
+clock_time.m4
codeset.m4
d-ino.m4
dirname.m4
@@ -21,6 +22,8 @@ getline.m4
getndelim2.m4
getopt.m4
gettext.m4
+gettime.m4
+gettimeofday.m4
glibc21.m4
hash.m4
human.m4
@@ -39,7 +42,6 @@ lib-link.m4
lib-prefix.m4
longdouble.m4
longlong.m4
-malloc.m4
mbrtowc.m4
mbstate_t.m4
memset.m4
@@ -54,7 +56,6 @@ printf-posix.m4
progtest.m4
quote.m4
quotearg.m4
-realloc.m4
restrict.m4
rmdir.m4
safe-read.m4
@@ -64,8 +65,10 @@ savedir.m4
signed.m4
size_max.m4
ssize_t.m4
+st_mtim.m4
stdbool.m4
stdint_h.m4
+stpcpy.m4
strcase.m4
strerror_r.m4
strtoimax.m4
@@ -74,8 +77,8 @@ strtoll.m4
strtoul.m4
strtoull.m4
strtoumax.m4
-stpcpy.m4
time_r.m4
+timespec.m4
tm_gmtoff.m4
uintmax_t.m4
ulonglong.m4
Index: src/buffer.c
===================================================================
RCS file: /cvsroot/tar/tar/src/buffer.c,v
retrieving revision 1.65
diff -p -b -u -r1.65 buffer.c
--- src/buffer.c 22 Mar 2004 11:59:35 -0000 1.65
+++ src/buffer.c 5 Apr 2004 02:20:47 -0000
@@ -109,7 +109,7 @@ static off_t real_s_sizeleft;
/* Functions. */
void
-clear_read_error_count ()
+clear_read_error_count (void)
{
read_error_count = 0;
}
@@ -600,7 +600,7 @@ archive_read_error (void)
}
static void
-short_read (ssize_t status)
+short_read (size_t status)
{
size_t left; /* bytes left */
char *more; /* pointer to next byte to read */
@@ -612,7 +612,7 @@ short_read (ssize_t status)
|| (left && status && read_full_records_option))
{
if (status)
- while ((status = rmtread (archive, more, left)) < 0)
+ while ((status = rmtread (archive, more, left)) == SAFE_READ_ERROR)
archive_read_error ();
if (status == 0)
@@ -646,7 +646,7 @@ short_read (ssize_t status)
about the problem. */
if (!read_full_records_option && verbose_option > 1
- && record_start_block == 0 && status > 0)
+ && record_start_block == 0 && status != 0)
{
unsigned long rsize = (record_size - left) / BLOCKSIZE;
WARN ((0, 0,
@@ -664,7 +664,7 @@ short_read (ssize_t status)
void
flush_read (void)
{
- ssize_t status; /* result from system call */
+ size_t status; /* result from system call */
if (checkpoint_option && !(++checkpoint % 10))
WARN ((0, 0, _("Read checkpoint %d"), checkpoint));
@@ -713,7 +713,7 @@ flush_read (void)
already read in the buffer, so the processing will fail */
if ((status == 0
- || (status < 0 && errno == ENOSPC))
+ || (status == SAFE_READ_ERROR && errno == ENOSPC))
&& multi_volume_option)
{
union block *cursor;
@@ -734,8 +734,8 @@ flush_read (void)
break;
}
- while ((status =
- rmtread (archive, record_start->buffer, record_size)) < 0)
+ while ((status = rmtread (archive, record_start->buffer, record_size))
+ == SAFE_READ_ERROR)
archive_read_error ();
if (status != record_size)
@@ -807,7 +807,7 @@ flush_read (void)
records_read++;
return;
}
- else if (status < 0)
+ else if (status == SAFE_READ_ERROR)
{
archive_read_error ();
goto error_loop; /* try again */
@@ -957,7 +957,7 @@ closeout_volume_number (void)
Return nonzero on success.
*/
static bool
-new_volume (enum access_mode access)
+new_volume (enum access_mode mode)
{
static FILE *read_file;
static int looped;
@@ -1086,7 +1086,7 @@ new_volume (enum access_mode access)
archive = rmtopen (*archive_name_cursor, O_RDWR | O_CREAT, MODE_RW,
rsh_command_option);
else
- switch (access)
+ switch (mode)
{
case ACCESS_READ:
archive = rmtopen (*archive_name_cursor, O_RDONLY, MODE_RW,
@@ -1109,7 +1109,7 @@ new_volume (enum access_mode access)
if (archive < 0)
{
open_warn (*archive_name_cursor);
- if (!verify_option && access == ACCESS_WRITE && backup_option)
+ if (!verify_option && mode == ACCESS_WRITE && backup_option)
undo_last_backup ();
goto tryagain;
}
Index: src/common.h
===================================================================
RCS file: /cvsroot/tar/tar/src/common.h,v
retrieving revision 1.32
diff -p -b -u -r1.32 common.h
--- src/common.h 4 Apr 2004 09:25:01 -0000 1.32
+++ src/common.h 5 Apr 2004 02:20:48 -0000
@@ -1,7 +1,7 @@
/* Common declarations for the tar program.
Copyright (C) 1988, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001,
- 2003 Free Software Foundation, Inc.
+ 2003, 2004 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -85,6 +85,7 @@ GLOBAL int exit_status;
#include <modechange.h>
#include <quote.h>
#include <safe-read.h>
+#include <timespec.h>
/* Log base 2 of common values. */
#define LG_8 3
@@ -189,7 +190,7 @@ enum old_files
OVERWRITE_OLD_FILES, /* --overwrite */
UNLINK_FIRST_OLD_FILES, /* --unlink-first */
KEEP_OLD_FILES, /* --keep-old-files */
- KEEP_NEWER_FILES, /* --keep-newer-files */
+ KEEP_NEWER_FILES /* --keep-newer-files */
};
GLOBAL enum old_files old_files_option;
@@ -201,13 +202,23 @@ GLOBAL struct mode_change *mode_option;
GLOBAL bool multi_volume_option;
-/* The same variable hold the time, whether mtime or ctime. Just fake a
+/* The same variable holds 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
/* Specified threshold date and time. Files having an older time stamp
do not get archived (also see after_date_option above). */
-GLOBAL time_t newer_mtime_option;
+GLOBAL struct timespec newer_mtime_option;
+
+/* Return true if newer_mtime_option is initialized. */
+#define NEWER_OPTION_INITIALIZED(opt) (0 <= (opt).tv_nsec)
+
+/* Return true if the struct stat ST's M time is less than
+ newer_mtime_option. */
+#define OLDER_STAT_TIME(st, m) \
+ ((st).st_##m##time < newer_mtime_option.tv_sec \
+ || ((st).st_##m##time == newer_mtime_option.tv_sec \
+ && TIMESPEC_NS ((st).st_##m##tim) < newer_mtime_option.tv_nsec))
/* Zero if there is no recursion, otherwise FNM_LEADING_DIR. */
GLOBAL int recursion_option;
@@ -367,7 +378,7 @@ enum dump_status
dump_status_not_implemented
};
-bool file_dumpable_p (struct tar_stat_info *stat);
+bool file_dumpable_p (struct tar_stat_info *);
void create_archive (void);
void pad_archive (off_t size_left);
void dump_file (char *, int, dev_t);
@@ -535,7 +546,7 @@ void open_diag (char const *name);
void read_error (char const *);
void read_error_details (char const *, off_t, size_t);
void read_fatal (char const *) __attribute__ ((noreturn));
-void read_fatal_details (char const *, off_t, size_t);
+void read_fatal_details (char const *, off_t, size_t) __attribute__
((noreturn));
void read_warn_details (char const *, off_t, size_t);
void read_diag_details (char const *name, off_t offset, size_t size);
void readlink_error (char const *);
@@ -559,7 +570,7 @@ void unlink_error (char const *);
void utime_error (char const *);
void waitpid_error (char const *);
void write_error (char const *);
-void write_error_details (char const *, ssize_t, size_t);
+void write_error_details (char const *, size_t, size_t);
void write_fatal (char const *) __attribute__ ((noreturn));
void write_fatal_details (char const *, ssize_t, size_t)
__attribute__ ((noreturn));
@@ -572,13 +583,13 @@ void xpipe (int[2]);
extern struct name *gnu_list_name;
void gid_to_gname (gid_t, char **gname);
-int gname_to_gid (char *gname, gid_t *);
+int gname_to_gid (char const *, gid_t *);
void uid_to_uname (uid_t, char **uname);
-int uname_to_uid (char *uname, uid_t *);
+int uname_to_uid (char const *, uid_t *);
void init_names (void);
void name_add (const char *);
-void name_init (int, char *const *);
+void name_init (void);
void name_term (void);
char *name_next (int);
void name_close (void);
@@ -609,6 +620,8 @@ bool contains_dot_dot (char const *);
/* Module tar.c. */
+void usage (int);
+
int confirm (const char *, const char *);
void request_stdin (const char *);
@@ -634,11 +647,13 @@ void xheader_finish (struct xheader *);
void xheader_destroy (struct xheader *);
char *xheader_xhdr_name (struct tar_stat_info *st);
char *xheader_ghdr_name (void);
+void xheader_write (char, char *, struct xheader *);
+void xheader_write_global (void);
void xheader_set_option (char *string);
/* Module system.c */
-void sys_stat_nanoseconds (struct tar_stat_info *stat);
+void sys_stat_nanoseconds (struct tar_stat_info *);
void sys_detect_dev_null_output (void);
void sys_save_archive_dev_ino (void);
void sys_drain_input_pipe (void);
@@ -652,7 +667,8 @@ int sys_truncate (int fd);
void sys_reset_uid_gid (void);
pid_t sys_child_open_for_compress (void);
pid_t sys_child_open_for_uncompress (void);
-ssize_t sys_write_archive_buffer (void);
+void sys_reset_uid_gid (void);
+size_t sys_write_archive_buffer (void);
bool sys_get_archive_stat (void);
void sys_reset_uid_gid (void);
@@ -660,14 +676,14 @@ void sys_reset_uid_gid (void);
void report_difference (struct tar_stat_info *st, const char *message, ...);
/* Module sparse.c */
-bool sparse_file_p (struct tar_stat_info *stat);
-bool sparse_member_p (struct tar_stat_info *stat);
-bool sparse_fixup_header (struct tar_stat_info *stat);
-enum dump_status sparse_dump_file (int fd, struct tar_stat_info *stat);
-enum dump_status sparse_extract_file (int fd, struct tar_stat_info *stat,
off_t *size);
-enum dump_status sparse_skip_file (struct tar_stat_info *stat);
-bool sparse_diff_file (int fd, struct tar_stat_info *stat);
+bool sparse_file_p (struct tar_stat_info *);
+bool sparse_member_p (struct tar_stat_info *);
+bool sparse_fixup_header (struct tar_stat_info *);
+enum dump_status sparse_dump_file (int, struct tar_stat_info *);
+enum dump_status sparse_extract_file (int, struct tar_stat_info *, off_t *);
+enum dump_status sparse_skip_file (struct tar_stat_info *);
+bool sparse_diff_file (int, struct tar_stat_info *);
/* Module utf8.c */
bool string_ascii_p (const char *str);
-bool utf8_convert(bool to_utf, const char *input, char **output);
+bool utf8_convert (bool to_utf, char const *input, char **output);
Index: src/compare.c
===================================================================
RCS file: /cvsroot/tar/tar/src/compare.c,v
retrieving revision 1.19
diff -p -b -u -r1.19 compare.c
--- src/compare.c 4 Apr 2004 09:25:30 -0000 1.19
+++ src/compare.c 5 Apr 2004 02:20:49 -0000
@@ -1,7 +1,7 @@
/* Diff files from a tar archive.
Copyright (C) 1988, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001,
- 2003 Free Software Foundation, Inc.
+ 2003, 2004 Free Software Foundation, Inc.
Written by John Gilmore, on 1987-04-30.
@@ -62,7 +62,8 @@ diff_init (void)
/* Sigh about something that differs by writing a MESSAGE to stdlis,
given MESSAGE is nonzero. Also set the exit status if not already. */
void
-report_difference (struct tar_stat_info *st, const char *fmt, ...)
+report_difference (struct tar_stat_info *st __attribute__ ((unused)),
+ const char *fmt, ...)
{
if (fmt)
{
@@ -81,21 +82,20 @@ report_difference (struct tar_stat_info
/* Take a buffer returned by read_and_process and do nothing with it. */
static int
-process_noop (size_t size, char *data)
+process_noop (size_t size __attribute__ ((unused)),
+ char *data __attribute__ ((unused)))
{
- /* Yes, I know. SIZE and DATA are unused in this function. Some
- compilers may even report it. That's OK, just relax! */
return 1;
}
static int
process_rawdata (size_t bytes, char *buffer)
{
- ssize_t status = safe_read (diff_handle, diff_buffer, bytes);
+ size_t status = safe_read (diff_handle, diff_buffer, bytes);
if (status != bytes)
{
- if (status < 0)
+ if (status == SAFE_READ_ERROR)
{
read_error (current_stat_info.file_name);
report_difference (¤t_stat_info, NULL);
@@ -308,13 +308,14 @@ diff_archive (void)
case LNKTYPE:
{
- struct stat link_data, stat_data;
+ struct stat file_data;
+ struct stat link_data;
- if (!get_stat_data (current_stat_info.file_name, &stat_data))
+ if (!get_stat_data (current_stat_info.file_name, &file_data))
break;
if (!get_stat_data (current_stat_info.link_name, &link_data))
break;
- if (!sys_compare_links (&stat_data, &link_data))
+ if (!sys_compare_links (&file_data, &link_data))
report_difference (¤t_stat_info,
_("Not linked to %s"),
quote (current_stat_info.link_name));
Index: src/create.c
===================================================================
RCS file: /cvsroot/tar/tar/src/create.c,v
retrieving revision 1.83
diff -p -b -u -r1.83 create.c
--- src/create.c 4 Apr 2004 09:25:48 -0000 1.83
+++ src/create.c 5 Apr 2004 02:20:51 -0000
@@ -337,11 +337,11 @@ string_to_chars (char *str, char *p, siz
b) current archive is /dev/null */
bool
-file_dumpable_p (struct tar_stat_info *stat)
+file_dumpable_p (struct tar_stat_info *st)
{
return !(dev_null_output
- || (stat->archive_file_size == 0
- && (stat->stat.st_mode & MODE_R) == MODE_R));
+ || (st->archive_file_size == 0
+ && (st->stat.st_mode & MODE_R) == MODE_R));
}
@@ -805,22 +805,22 @@ pad_archive (off_t size_left)
}
static enum dump_status
-dump_regular_file (int fd, struct tar_stat_info *stat)
+dump_regular_file (int fd, struct tar_stat_info *st)
{
- off_t size_left = stat->stat.st_size;
+ off_t size_left = st->stat.st_size;
off_t block_ordinal;
union block *blk;
block_ordinal = current_block_ordinal ();
- blk = start_header (stat);
+ blk = start_header (st);
if (!blk)
return dump_status_fail;
/* Mark contiguous files, if we support them. */
- if (archive_format != V7_FORMAT && S_ISCTG (stat->stat.st_mode))
+ if (archive_format != V7_FORMAT && S_ISCTG (st->stat.st_mode))
blk->header.typeflag = CONTTYPE;
- finish_header (stat, blk, block_ordinal);
+ finish_header (st, blk, block_ordinal);
while (size_left > 0)
{
@@ -828,9 +828,9 @@ dump_regular_file (int fd, struct tar_st
if (multi_volume_option)
{
- assign_string (&save_name, stat->file_name);
+ assign_string (&save_name, st->file_name);
save_sizeleft = size_left;
- save_totsize = stat->stat.st_size;
+ save_totsize = st->stat.st_size;
}
blk = find_next_block ();
@@ -846,10 +846,10 @@ dump_regular_file (int fd, struct tar_st
}
count = (fd < 0) ? bufsize : safe_read (fd, blk->buffer, bufsize);
- if (count < 0)
+ if (count == SAFE_READ_ERROR)
{
- read_diag_details (stat->orig_file_name,
- stat->stat.st_size - size_left, bufsize);
+ read_diag_details (st->orig_file_name,
+ st->stat.st_size - size_left, bufsize);
pad_archive (size_left);
return dump_status_short;
}
@@ -865,7 +865,7 @@ dump_regular_file (int fd, struct tar_st
ngettext ("%s: File shrank by %s byte; padding with zeros",
"%s: File shrank by %s bytes; padding with zeros",
size_left),
- quotearg_colon (stat->orig_file_name),
+ quotearg_colon (st->orig_file_name),
STRINGIFY_BIGINT (size_left, buf)));
if (! ignore_failed_read_option)
exit_status = TAREXIT_FAILURE;
@@ -876,7 +876,7 @@ dump_regular_file (int fd, struct tar_st
return dump_status_ok;
}
-void
+static void
dump_regular_finish (int fd, struct tar_stat_info *st, time_t original_ctime)
{
if (fd >= 0)
@@ -903,19 +903,19 @@ dump_regular_finish (int fd, struct tar_
}
}
-void
+static void
dump_dir0 (char *directory,
- struct tar_stat_info *stat, int top_level, dev_t parent_device)
+ struct tar_stat_info *st, int top_level, dev_t parent_device)
{
- dev_t our_device = stat->stat.st_dev;
+ dev_t our_device = st->stat.st_dev;
- if (!is_avoided_name (stat->orig_file_name))
+ if (!is_avoided_name (st->orig_file_name))
{
union block *blk = NULL;
off_t block_ordinal = current_block_ordinal ();
- stat->stat.st_size = 0; /* force 0 size on dir */
+ st->stat.st_size = 0; /* force 0 size on dir */
- blk = start_header (stat);
+ blk = start_header (st);
if (!blk)
return;
@@ -927,7 +927,7 @@ dump_dir0 (char *directory,
/* If we're gnudumping, we aren't done yet so don't close it. */
if (!incremental_option)
- finish_header (stat, blk, block_ordinal);
+ finish_header (st, blk, block_ordinal);
else if (gnu_list_name->dir_contents)
{
off_t size_left;
@@ -935,8 +935,8 @@ dump_dir0 (char *directory,
size_t bufsize;
ssize_t count;
const char *buffer, *p_buffer;
- off_t block_ordinal = current_block_ordinal ();
+ block_ordinal = current_block_ordinal ();
buffer = gnu_list_name->dir_contents; /* FOO */
totsize = 0;
if (buffer)
@@ -948,14 +948,14 @@ dump_dir0 (char *directory,
}
totsize++;
OFF_TO_CHARS (totsize, blk->header.size);
- finish_header (stat, blk, block_ordinal);
+ finish_header (st, blk, block_ordinal);
p_buffer = buffer;
size_left = totsize;
while (size_left > 0)
{
if (multi_volume_option)
{
- assign_string (&save_name, stat->orig_file_name);
+ assign_string (&save_name, st->orig_file_name);
save_sizeleft = size_left;
save_totsize = totsize;
}
@@ -984,19 +984,19 @@ dump_dir0 (char *directory,
if (one_file_system_option
&& !top_level
- && parent_device != stat->stat.st_dev)
+ && parent_device != st->stat.st_dev)
{
if (verbose_option)
WARN ((0, 0,
_("%s: file is on a different filesystem; not dumped"),
- quotearg_colon (stat->orig_file_name)));
+ quotearg_colon (st->orig_file_name)));
return;
}
{
char const *entry;
size_t entry_len;
- char *name_buf = strdup (stat->orig_file_name);
+ char *name_buf = strdup (st->orig_file_name);
size_t name_size = strlen (name_buf);
size_t name_len = name_size;
@@ -1033,22 +1033,22 @@ ensure_slash (char **pstr)
(*pstr)[len] = '\0';
}
-bool
-dump_dir (struct tar_stat_info *stat, int top_level, dev_t parent_device)
+static bool
+dump_dir (struct tar_stat_info *st, int top_level, dev_t parent_device)
{
char *directory;
- directory = savedir (stat->orig_file_name);
+ directory = savedir (st->orig_file_name);
if (!directory)
{
- savedir_diag (stat->orig_file_name);
+ savedir_diag (st->orig_file_name);
return false;
}
- ensure_slash (&stat->orig_file_name);
- ensure_slash (&stat->file_name);
+ ensure_slash (&st->orig_file_name);
+ ensure_slash (&st->file_name);
- dump_dir0 (directory, stat, top_level, parent_device);
+ dump_dir0 (directory, st, top_level, parent_device);
free (directory);
return true;
@@ -1131,8 +1131,9 @@ create_archive (void)
static unsigned
hash_link (void const *entry, unsigned n_buckets)
{
- struct link const *link = entry;
- return (uintmax_t) (link->dev ^ link->ino) % n_buckets;
+ struct link const *l = entry;
+ uintmax_t num = l->dev ^ l->ino;
+ return num % n_buckets;
}
/* Compare two links for equality. */
@@ -1164,41 +1165,41 @@ static Hash_table *link_table;
/* Try to dump stat as a hard link to another file in the archive. If
succeeded returns true */
static bool
-dump_hard_link (struct tar_stat_info *stat)
+dump_hard_link (struct tar_stat_info *st)
{
- if (link_table && stat->stat.st_nlink > 1)
+ if (link_table && st->stat.st_nlink > 1)
{
struct link lp;
- struct link *dup;
+ struct link *duplicate;
off_t block_ordinal;
union block *blk;
- lp.ino = stat->stat.st_ino;
- lp.dev = stat->stat.st_dev;
+ lp.ino = st->stat.st_ino;
+ lp.dev = st->stat.st_dev;
- if ((dup = hash_lookup (link_table, &lp)))
+ if ((duplicate = hash_lookup (link_table, &lp)))
{
/* We found a link. */
- char const *link_name = safer_name_suffix (dup->name, true);
+ char const *link_name = safer_name_suffix (duplicate->name, true);
- dup->nlink--;
+ duplicate->nlink--;
block_ordinal = current_block_ordinal ();
- assign_string (&stat->link_name, link_name);
+ assign_string (&st->link_name, link_name);
if (NAME_FIELD_SIZE < strlen (link_name))
- write_long_link (stat);
+ write_long_link (st);
- stat->stat.st_size = 0;
- blk = start_header (stat);
+ st->stat.st_size = 0;
+ blk = start_header (st);
if (!blk)
return true;
tar_copy_str (blk->header.linkname, link_name, NAME_FIELD_SIZE);
blk->header.typeflag = LNKTYPE;
- finish_header (stat, blk, block_ordinal);
+ finish_header (st, blk, block_ordinal);
- if (remove_files_option && unlink (stat->orig_file_name) != 0)
- unlink_error (stat->orig_file_name);
+ if (remove_files_option && unlink (st->orig_file_name) != 0)
+ unlink_error (st->orig_file_name);
return true;
}
@@ -1207,25 +1208,25 @@ dump_hard_link (struct tar_stat_info *st
}
static void
-file_count_links (struct tar_stat_info *stat)
+file_count_links (struct tar_stat_info *st)
{
- if (stat->stat.st_nlink > 1)
+ if (st->stat.st_nlink > 1)
{
- struct link *dup;
+ struct link *duplicate;
struct link *lp = xmalloc (offsetof (struct link, name)
- + strlen (stat->orig_file_name) + 1);
- lp->ino = stat->stat.st_ino;
- lp->dev = stat->stat.st_dev;
- lp->nlink = stat->stat.st_nlink;
- strcpy (lp->name, stat->orig_file_name);
+ + strlen (st->orig_file_name) + 1);
+ lp->ino = st->stat.st_ino;
+ lp->dev = st->stat.st_dev;
+ lp->nlink = st->stat.st_nlink;
+ strcpy (lp->name, st->orig_file_name);
if (! ((link_table
|| (link_table = hash_initialize (0, 0, hash_link,
compare_links, 0)))
- && (dup = hash_insert (link_table, lp))))
+ && (duplicate = hash_insert (link_table, lp))))
xalloc_die ();
- if (dup != lp)
+ if (duplicate != lp)
abort ();
lp->nlink--;
}
@@ -1234,7 +1235,7 @@ file_count_links (struct tar_stat_info *
/* For each dumped file, check if all its links were dumped. Emit
warnings if it is not so. */
void
-check_links ()
+check_links (void)
{
struct link *lp;
@@ -1261,8 +1262,8 @@ check_links ()
/* FIXME: One should make sure that for *every* path leading to setting
exit_status to failure, a clear diagnostic has been issued. */
-void
-dump_file0 (struct tar_stat_info *stat, char *p,
+static void
+dump_file0 (struct tar_stat_info *st, char *p,
int top_level, dev_t parent_device)
{
union block *header;
@@ -1274,22 +1275,22 @@ dump_file0 (struct tar_stat_info *stat,
if (interactive_option && !confirm ("add", p))
return;
- assign_string (&stat->orig_file_name, p);
- assign_string (&stat->file_name, safer_name_suffix (p, false));
+ assign_string (&st->orig_file_name, p);
+ assign_string (&st->file_name, safer_name_suffix (p, false));
- if (deref_stat (dereference_option, p, &stat->stat) != 0)
+ if (deref_stat (dereference_option, p, &st->stat) != 0)
{
stat_diag (p);
return;
}
- stat->archive_file_size = stat->stat.st_size;
- sys_stat_nanoseconds(stat);
- original_ctime = stat->stat.st_ctime;
- restore_times.actime = stat->stat.st_atime;
- restore_times.modtime = stat->stat.st_mtime;
+ st->archive_file_size = st->stat.st_size;
+ sys_stat_nanoseconds (st);
+ original_ctime = st->stat.st_ctime;
+ restore_times.actime = st->stat.st_atime;
+ restore_times.modtime = st->stat.st_mtime;
#ifdef S_ISHIDDEN
- if (S_ISHIDDEN (stat->stat.st_mode))
+ if (S_ISHIDDEN (st->stat.st_mode))
{
char *new = (char *) alloca (strlen (p) + 2);
if (new)
@@ -1304,9 +1305,9 @@ dump_file0 (struct tar_stat_info *stat,
/* See if we want only new files, and check if this one is too old to
put in the archive. */
- 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 (!S_ISDIR (st->stat.st_mode)
+ && OLDER_STAT_TIME (st->stat, m)
+ && (!after_date_option || OLDER_STAT_TIME (st->stat, c)))
{
if (0 < top_level) /* equivalent to !incremental_option */
WARN ((0, 0, _("%s: file is unchanged; not dumped"),
@@ -1316,16 +1317,16 @@ dump_file0 (struct tar_stat_info *stat,
}
/* See if we are trying to dump the archive. */
- if (sys_file_is_archive (stat))
+ if (sys_file_is_archive (st))
{
WARN ((0, 0, _("%s: file is the archive; not dumped"),
quotearg_colon (p)));
return;
}
- if (S_ISDIR (stat->stat.st_mode))
+ if (S_ISDIR (st->stat.st_mode))
{
- dump_dir (stat, top_level, parent_device);
+ dump_dir (st, top_level, parent_device);
if (atime_preserve_option)
utime (p, &restore_times);
return;
@@ -1335,49 +1336,49 @@ dump_file0 (struct tar_stat_info *stat,
else
{
/* Check for multiple links. */
- if (dump_hard_link (stat))
+ if (dump_hard_link (st))
return;
/* This is not a link to a previously dumped file, so dump it. */
- if (S_ISREG (stat->stat.st_mode)
- || S_ISCTG (stat->stat.st_mode))
+ if (S_ISREG (st->stat.st_mode)
+ || S_ISCTG (st->stat.st_mode))
{
int fd;
enum dump_status status;
- if (file_dumpable_p (stat))
+ if (file_dumpable_p (st))
{
- fd = open (stat->orig_file_name,
+ fd = open (st->orig_file_name,
O_RDONLY | O_BINARY);
if (fd < 0)
{
if (!top_level && errno == ENOENT)
WARN ((0, 0, _("%s: File removed before we read it"),
- quotearg_colon (stat->orig_file_name)));
+ quotearg_colon (st->orig_file_name)));
else
- open_diag (stat->orig_file_name);
+ open_diag (st->orig_file_name);
return;
}
}
else
fd = -1;
- if (sparse_option && sparse_file_p (stat))
+ if (sparse_option && sparse_file_p (st))
{
- status = sparse_dump_file (fd, stat);
+ status = sparse_dump_file (fd, st);
if (status == dump_status_not_implemented)
- status = dump_regular_file (fd, stat);
+ status = dump_regular_file (fd, st);
}
else
- status = dump_regular_file (fd, stat);
+ status = dump_regular_file (fd, st);
switch (status)
{
case dump_status_ok:
if (multi_volume_option)
assign_string (&save_name, 0);
- dump_regular_finish (fd, stat, original_ctime);
+ dump_regular_finish (fd, st, original_ctime);
break;
case dump_status_short:
@@ -1395,17 +1396,17 @@ dump_file0 (struct tar_stat_info *stat,
}
if (atime_preserve_option)
- utime (stat->orig_file_name, &restore_times);
- file_count_links (stat);
+ utime (st->orig_file_name, &restore_times);
+ file_count_links (st);
return;
}
#ifdef HAVE_READLINK
- else if (S_ISLNK (stat->stat.st_mode))
+ else if (S_ISLNK (st->stat.st_mode))
{
char *buffer;
int size;
- size_t linklen = stat->stat.st_size;
- if (linklen != stat->stat.st_size || linklen + 1 == 0)
+ size_t linklen = st->stat.st_size;
+ if (linklen != st->stat.st_size || linklen + 1 == 0)
xalloc_die ();
buffer = (char *) alloca (linklen + 1);
size = readlink (p, buffer, linklen + 1);
@@ -1415,18 +1416,18 @@ dump_file0 (struct tar_stat_info *stat,
return;
}
buffer[size] = '\0';
- assign_string (&stat->link_name, buffer);
+ assign_string (&st->link_name, buffer);
if (size > NAME_FIELD_SIZE)
- write_long_link (stat);
+ write_long_link (st);
block_ordinal = current_block_ordinal ();
- stat->stat.st_size = 0; /* force 0 size on symlink */
- header = start_header (stat);
+ st->stat.st_size = 0; /* force 0 size on symlink */
+ header = start_header (st);
if (!header)
return;
tar_copy_str (header->header.linkname, buffer, NAME_FIELD_SIZE);
header->header.typeflag = SYMTYPE;
- finish_header (stat, header, block_ordinal);
+ finish_header (st, header, block_ordinal);
/* nothing more to do to it */
if (remove_files_option)
@@ -1434,22 +1435,22 @@ dump_file0 (struct tar_stat_info *stat,
if (unlink (p) == -1)
unlink_error (p);
}
- file_count_links (stat);
+ file_count_links (st);
return;
}
#endif
- else if (S_ISCHR (stat->stat.st_mode))
+ else if (S_ISCHR (st->stat.st_mode))
type = CHRTYPE;
- else if (S_ISBLK (stat->stat.st_mode))
+ else if (S_ISBLK (st->stat.st_mode))
type = BLKTYPE;
- else if (S_ISFIFO (stat->stat.st_mode))
+ else if (S_ISFIFO (st->stat.st_mode))
type = FIFOTYPE;
- else if (S_ISSOCK (stat->stat.st_mode))
+ else if (S_ISSOCK (st->stat.st_mode))
{
WARN ((0, 0, _("%s: socket ignored"), quotearg_colon (p)));
return;
}
- else if (S_ISDOOR (stat->stat.st_mode))
+ else if (S_ISDOOR (st->stat.st_mode))
{
WARN ((0, 0, _("%s: door ignored"), quotearg_colon (p)));
return;
@@ -1468,21 +1469,21 @@ dump_file0 (struct tar_stat_info *stat,
}
block_ordinal = current_block_ordinal ();
- stat->stat.st_size = 0; /* force 0 size */
- header = start_header (stat);
+ st->stat.st_size = 0; /* force 0 size */
+ header = start_header (st);
if (!header)
return;
header->header.typeflag = type;
if (type != FIFOTYPE)
{
- MAJOR_TO_CHARS (major (stat->stat.st_rdev),
+ MAJOR_TO_CHARS (major (st->stat.st_rdev),
header->header.devmajor);
- MINOR_TO_CHARS (minor (stat->stat.st_rdev),
+ MINOR_TO_CHARS (minor (st->stat.st_rdev),
header->header.devminor);
}
- finish_header (stat, header, block_ordinal);
+ finish_header (st, header, block_ordinal);
if (remove_files_option)
{
if (unlink (p) == -1)
@@ -1493,8 +1494,8 @@ dump_file0 (struct tar_stat_info *stat,
void
dump_file (char *p, int top_level, dev_t parent_device)
{
- struct tar_stat_info stat;
- tar_stat_init (&stat);
- dump_file0 (&stat, p, top_level, parent_device);
- tar_stat_destroy (&stat);
+ struct tar_stat_info st;
+ tar_stat_init (&st);
+ dump_file0 (&st, p, top_level, parent_device);
+ tar_stat_destroy (&st);
}
Index: src/extract.c
===================================================================
RCS file: /cvsroot/tar/tar/src/extract.c,v
retrieving revision 1.58
diff -p -b -u -r1.58 extract.c
--- src/extract.c 4 Apr 2004 09:26:11 -0000 1.58
+++ src/extract.c 5 Apr 2004 02:20:52 -0000
@@ -1,7 +1,7 @@
/* Extract files from a tar archive.
Copyright (C) 1988, 1992, 1993, 1994, 1996, 1997, 1998, 1999, 2000,
- 2001, 2003 Free Software Foundation, Inc.
+ 2001, 2003, 2004 Free Software Foundation, Inc.
Written by John Gilmore, on 1985-11-19.
@@ -315,11 +315,11 @@ delay_set_stat (char const *file_name, s
}
/* Update the delayed_set_stat info for an intermediate directory
- created on the path to DIR_NAME. The intermediate directory turned
+ created on the path to DIR. The intermediate directory turned
out to be the same as this directory, e.g. due to ".." or symbolic
links. *DIR_STAT_INFO is the status of the directory. */
static void
-repair_delayed_set_stat (char const *dir_name,
+repair_delayed_set_stat (char const *dir,
struct stat const *dir_stat_info)
{
struct delayed_set_stat *data;
@@ -344,7 +344,7 @@ repair_delayed_set_stat (char const *dir
}
ERROR ((0, 0, _("%s: Unexpected inconsistency when making directory"),
- quotearg_colon (dir_name)));
+ quotearg_colon (dir)));
}
/* After a file/link/symlink/directory creation has failed, see if
@@ -430,7 +430,7 @@ file_newer_p (const char *file_name, str
return true; /* Be on the safe side */
}
if (!S_ISDIR (st.st_mode)
- && st.st_mtime >= current_stat_info.stat.st_mtime)
+ && st.st_mtime >= tar_stat->stat.st_mtime)
{
return true;
}
@@ -441,7 +441,7 @@ file_newer_p (const char *file_name, str
Return zero if extraction should not proceed. */
static int
-prepare_to_extract (char const *file_name, bool directory)
+prepare_to_extract (char const *file_name)
{
if (to_stdout_option)
return 0;
@@ -679,7 +679,7 @@ extract_archive (void)
goto extract_file;
}
- if (! prepare_to_extract (file_name, 0))
+ if (! prepare_to_extract (file_name))
{
skip_member ();
if (backup_option)
@@ -794,7 +794,7 @@ extract_archive (void)
case SYMTYPE:
#ifdef HAVE_SYMLINK
- if (! prepare_to_extract (file_name, 0))
+ if (! prepare_to_extract (file_name))
break;
if (absolute_names_option
@@ -899,7 +899,7 @@ extract_archive (void)
#endif
case LNKTYPE:
- if (! prepare_to_extract (file_name, 0))
+ if (! prepare_to_extract (file_name))
break;
again_link:
@@ -963,7 +963,7 @@ extract_archive (void)
#if S_IFCHR || S_IFBLK
make_node:
- if (! prepare_to_extract (file_name, 0))
+ if (! prepare_to_extract (file_name))
break;
status = mknod (file_name, current_stat_info.stat.st_mode,
@@ -984,7 +984,7 @@ extract_archive (void)
#if HAVE_MKFIFO || defined mkfifo
case FIFOTYPE:
- if (! prepare_to_extract (file_name, 0))
+ if (! prepare_to_extract (file_name))
break;
while (status = mkfifo (file_name, current_stat_info.stat.st_mode),
@@ -1021,7 +1021,7 @@ extract_archive (void)
| (we_are_root ? 0 : MODE_WXUSR))
& MODE_RWX);
- status = prepare_to_extract (file_name, 1);
+ status = prepare_to_extract (file_name);
if (status == 0)
break;
if (status < 0)
Index: src/incremen.c
===================================================================
RCS file: /cvsroot/tar/tar/src/incremen.c,v
retrieving revision 1.19
diff -p -b -u -r1.19 incremen.c
--- src/incremen.c 21 Feb 2004 09:35:10 -0000 1.19
+++ src/incremen.c 5 Apr 2004 02:20:52 -0000
@@ -209,9 +209,9 @@ scan_path (struct obstack *stk, char *pa
stat_data.st_ino, nfs, 1);
directory->children =
((listed_incremental_option
- || newer_mtime_option <= stat_data.st_mtime
- || (after_date_option &&
- newer_ctime_option <= stat_data.st_ctime))
+ || OLDER_STAT_TIME (stat_data, m)
+ || (after_date_option
+ && OLDER_STAT_TIME (stat_data, c)))
? ALL_CHILDREN
: CHANGED_CHILDREN);
}
@@ -239,9 +239,8 @@ scan_path (struct obstack *stk, char *pa
else
if (children == CHANGED_CHILDREN
- && stat_data.st_mtime < newer_mtime_option
- && (!after_date_option
- || stat_data.st_ctime < newer_ctime_option))
+ && OLDER_STAT_TIME (stat_data, m)
+ && (!after_date_option || OLDER_STAT_TIME (stat_data, c)))
obstack_1grow (stk, 'N');
else
obstack_1grow (stk, 'Y');
@@ -357,7 +356,10 @@ read_directory_file (void)
ERROR ((0, 0, "%s:1: %s", quotearg_colon (listed_incremental_option),
_("Time stamp out of range")));
else
- newer_mtime_option = t;
+ {
+ newer_mtime_option.tv_sec = t;
+ newer_mtime_option.tv_nsec = 0;
+ }
while (0 < (n = getline (&buf, &bufsize, fp)))
{
Index: src/list.c
===================================================================
RCS file: /cvsroot/tar/tar/src/list.c,v
retrieving revision 1.70
diff -p -b -u -r1.70 list.c
--- src/list.c 4 Apr 2004 09:31:44 -0000 1.70
+++ src/list.c 5 Apr 2004 02:20:54 -0000
@@ -1,7 +1,7 @@
/* List a tar archive, with support routines for reading a tar archive.
Copyright (C) 1988, 1992, 1993, 1994, 1996, 1997, 1998, 1999, 2000,
- 2001, 2003 Free Software Foundation, Inc.
+ 2001, 2003, 2004 Free Software Foundation, Inc.
Written by John Gilmore, on 1985-08-26.
@@ -92,12 +92,17 @@ read_and (void (*do_something) (void))
Ensure incoming names are null terminated. */
if (! name_match (current_stat_info.file_name)
- || (newer_mtime_option != TYPE_MINIMUM (time_t)
+ || (NEWER_OPTION_INITIALIZED (newer_mtime_option)
/* FIXME: We get mtime now, and again later; this causes
duplicate diagnostics if header.mtime is bogus. */
&& ((current_stat_info.stat.st_mtime
- = TIME_FROM_HEADER (current_header->header.mtime))
- < newer_mtime_option))
+ = TIME_FROM_HEADER (current_header->header.mtime)),
+#ifdef ST_MTIM_NSEC
+ /* FIXME: Grab fractional time stamps from
+ extended header. */
+ current_stat_info.stat.st_mtim.ST_MTIM_NSEC = 0,
+#endif
+ OLDER_STAT_TIME (current_stat_info.stat, m)))
|| excluded_name (current_stat_info.file_name))
{
switch (current_header->header.typeflag)
Index: src/misc.c
===================================================================
RCS file: /cvsroot/tar/tar/src/misc.c,v
retrieving revision 1.16
diff -p -b -u -r1.16 misc.c
--- src/misc.c 3 Jan 2004 22:24:35 -0000 1.16
+++ src/misc.c 5 Apr 2004 02:20:54 -0000
@@ -1,7 +1,7 @@
/* Miscellaneous functions, not really specific to GNU tar.
Copyright (C) 1988, 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2001,
- 2003 Free Software Foundation, Inc.
+ 2003, 2004 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -331,16 +331,17 @@ remove_any_file (const char *path, enum
/* Check if PATH already exists and make a backup of it right now.
Return success (nonzero) only if the backup is either unneeded, or
successful. For now, directories are considered to never need
- backup. If ARCHIVE is nonzero, this is the archive and so, we do
- not have to backup block or character devices, nor remote entities. */
+ backup. If THIS_IS_THE_ARCHIVE is nonzero, this is the archive and
+ so, we do not have to backup block or character devices, nor remote
+ entities. */
bool
-maybe_backup_file (const char *path, int archive)
+maybe_backup_file (const char *path, int this_is_the_archive)
{
struct stat file_stat;
/* Check if we really need to backup the file. */
- if (archive && _remdev (path))
+ if (this_is_the_archive && _remdev (path))
return true;
if (stat (path, &file_stat))
@@ -355,7 +356,8 @@ maybe_backup_file (const char *path, int
if (S_ISDIR (file_stat.st_mode))
return true;
- if (archive && (S_ISBLK (file_stat.st_mode) || S_ISCHR (file_stat.st_mode)))
+ if (this_is_the_archive
+ && (S_ISBLK (file_stat.st_mode) || S_ISCHR (file_stat.st_mode)))
return true;
assign_string (&before_backup_name, path);
@@ -587,12 +589,6 @@ close_error (char const *name)
}
void
-close_fatal (char const *name)
-{
- call_arg_fatal ("close", name);
-}
-
-void
close_warn (char const *name)
{
call_arg_warn ("close", name);
@@ -875,16 +871,16 @@ write_error (char const *name)
}
void
-write_error_details (char const *name, ssize_t status, size_t size)
+write_error_details (char const *name, size_t status, size_t size)
{
- if (status < 0)
+ if (status == 0)
write_error (name);
else
ERROR ((0, 0,
ngettext ("%s: Wrote only %lu of %lu byte",
"%s: Wrote only %lu of %lu bytes",
- record_size),
- name, (unsigned long) status, (unsigned long) record_size));
+ size),
+ name, (unsigned long int) status, (unsigned long int) size));
}
void
Index: src/names.c
===================================================================
RCS file: /cvsroot/tar/tar/src/names.c,v
retrieving revision 1.37
diff -p -b -u -r1.37 names.c
--- src/names.c 25 Dec 2003 10:19:40 -0000 1.37
+++ src/names.c 5 Apr 2004 02:20:55 -0000
@@ -1,7 +1,7 @@
/* Various processing of names.
Copyright (C) 1988, 1992, 1994, 1996, 1997, 1998, 1999, 2000, 2001,
- 2003 Free Software Foundation, Inc.
+ 2003, 2004 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -118,7 +118,7 @@ gid_to_gname (gid_t gid, char **gname)
/* Given UNAME, set the corresponding UID and return 1, or else, return 0. */
int
-uname_to_uid (char *uname, uid_t *uidp)
+uname_to_uid (char const *uname, uid_t *uidp)
{
struct passwd *passwd;
@@ -148,7 +148,7 @@ uname_to_uid (char *uname, uid_t *uidp)
/* Given GNAME, set the corresponding GID and return 1, or else, return 0. */
int
-gname_to_gid (char *gname, gid_t *gidp)
+gname_to_gid (char const *gname, gid_t *gidp)
{
struct group *group;
@@ -227,7 +227,7 @@ is_pattern (const char *string)
/* Set up to gather file names for tar. They can either come from a
file or were saved from decoding arguments. */
void
-name_init (int argc, char *const *argv)
+name_init (void)
{
name_buffer = xmalloc (NAME_FIELD_SIZE + 2);
name_buffer_length = NAME_FIELD_SIZE;
@@ -759,18 +759,18 @@ add_hierarchy_to_namelist (struct name *
size_t allocated_length = (name_length >= NAME_FIELD_SIZE
? name_length + NAME_FIELD_SIZE
: NAME_FIELD_SIZE);
- char *name_buffer = xmalloc (allocated_length + 1);
+ char *namebuf = xmalloc (allocated_length + 1);
/* FIXME: + 2 above? */
char *string;
size_t string_length;
int change_dir = name->change_dir;
name->dir_contents = buffer;
- strcpy (name_buffer, path);
- if (! ISSLASH (name_buffer[name_length - 1]))
+ strcpy (namebuf, path);
+ if (! ISSLASH (namebuf[name_length - 1]))
{
- name_buffer[name_length++] = '/';
- name_buffer[name_length] = '\0';
+ namebuf[name_length++] = '/';
+ namebuf[name_length] = '\0';
}
for (string = buffer; *string; string += string_length + 1)
@@ -788,15 +788,15 @@ add_hierarchy_to_namelist (struct name *
}
while (allocated_length <= name_length + string_length);
- name_buffer = xrealloc (name_buffer, allocated_length + 1);
+ namebuf = xrealloc (namebuf, allocated_length + 1);
}
- strcpy (name_buffer + name_length, string + 1);
- add_hierarchy_to_namelist (addname (name_buffer, change_dir),
+ strcpy (namebuf + name_length, string + 1);
+ add_hierarchy_to_namelist (addname (namebuf, change_dir),
device);
}
}
- free (name_buffer);
+ free (namebuf);
}
}
Index: src/rmt.c
===================================================================
RCS file: /cvsroot/tar/tar/src/rmt.c,v
retrieving revision 1.30
diff -p -b -u -r1.30 rmt.c
--- src/rmt.c 13 Nov 2003 06:23:23 -0000 1.30
+++ src/rmt.c 5 Apr 2004 02:20:55 -0000
@@ -1,7 +1,7 @@
/* Remote connection server.
- Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2003 Free
- Software Foundation, Inc.
+ Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2003, 2004
+ Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -117,12 +117,12 @@ get_string (char *string)
{
int counter;
- for (counter = 0; counter < STRING_SIZE; counter++)
+ for (counter = 0; ; counter++)
{
if (safe_read (STDIN_FILENO, string + counter, 1) != 1)
exit (EXIT_SUCCESS);
- if (string[counter] == '\n')
+ if (string[counter] == '\n' || counter == STRING_SIZE - 1)
break;
}
string[counter] = '\0';
@@ -247,6 +247,8 @@ static struct option const long_opts[] =
{0, 0, 0, 0}
};
+static void usage (int) __attribute__ ((noreturn));
+
static void
usage (int status)
{
@@ -272,7 +274,7 @@ int
main (int argc, char *const *argv)
{
char command;
- ssize_t status;
+ size_t status;
/* FIXME: Localization is meaningless, unless --help and --version are
locally used. Localization would be best accomplished by the calling
@@ -294,7 +296,7 @@ main (int argc, char *const *argv)
case 'v':
{
printf ("rmt (%s) %s\n%s\n", PACKAGE_NAME, PACKAGE_VERSION,
- "Copyright (C) 2003 Free Software Foundation, Inc.");
+ "Copyright (C) 2004 Free Software Foundation, Inc.");
puts (_("\
This program comes with NO WARRANTY, to the extent permitted by law.\n\
You may redistribute it under the terms of the GNU General Public License;\n\
@@ -444,7 +446,7 @@ top:
{
status = safe_read (STDIN_FILENO, &record_buffer[counter],
size - counter);
- if (status <= 0)
+ if (status == SAFE_READ_ERROR || status == 0)
{
DEBUG (_("rmtd: Premature eof\n"));
@@ -453,7 +455,7 @@ top:
}
}
status = full_write (tape, record_buffer, size);
- if (status < 0)
+ if (status != size)
goto ioerror;
goto respond;
}
@@ -469,9 +471,9 @@ top:
size = atol (count_string);
prepare_input_buffer (-1, size);
status = safe_read (tape, record_buffer, size);
- if (status < 0)
+ if (status == SAFE_READ_ERROR)
goto ioerror;
- sprintf (reply_buffer, "A%ld\n", (long) status);
+ sprintf (reply_buffer, "A%lu\n", (unsigned long int) status);
full_write (STDOUT_FILENO, reply_buffer, strlen (reply_buffer));
full_write (STDOUT_FILENO, record_buffer, status);
goto top;
Index: src/rmt.h
===================================================================
RCS file: /cvsroot/tar/tar/src/rmt.h,v
retrieving revision 1.16
diff -p -b -u -r1.16 rmt.h
--- src/rmt.h 5 Jul 2003 07:21:49 -0000 1.16
+++ src/rmt.h 5 Apr 2004 02:20:55 -0000
@@ -1,7 +1,7 @@
/* Definitions for communicating with a remote tape drive.
- Copyright (C) 1988, 1992, 1996, 1997, 2001, 2003 Free Software
- Foundation, Inc.
+ Copyright (C) 1988, 1992, 1996, 1997, 2001, 2003, 2004 Free
+ Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,8 +21,8 @@ extern char *rmt_path__;
int rmt_open__ (const char *, int, int, const char *);
int rmt_close__ (int);
-ssize_t rmt_read__ (int, char *, size_t);
-ssize_t rmt_write__ (int, char *, size_t);
+size_t rmt_read__ (int, char *, size_t);
+size_t rmt_write__ (int, char *, size_t);
off_t rmt_lseek__ (int, off_t, int);
int rmt_ioctl__ (int, int, char *);
Index: src/rtapelib.c
===================================================================
RCS file: /cvsroot/tar/tar/src/rtapelib.c,v
retrieving revision 1.24
diff -p -b -u -r1.24 rtapelib.c
--- src/rtapelib.c 4 Apr 2004 09:32:33 -0000 1.24
+++ src/rtapelib.c 5 Apr 2004 02:20:55 -0000
@@ -1,7 +1,7 @@
/* Functions for communicating with a remote tape drive.
- Copyright 1988, 1992, 1994, 1996, 1997, 1999, 2000, 2001 Free Software
- Foundation, Inc.
+ Copyright 1988, 1992, 1994, 1996, 1997, 1999, 2000, 2001, 2004 Free
+ Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -163,8 +163,6 @@ get_status_string (int handle, char *com
if (*cursor == 'E' || *cursor == 'F')
{
- errno = atoi (cursor + 1);
-
/* Skip the error message line. */
/* FIXME: there is better to do than merely ignoring error messages
@@ -178,6 +176,8 @@ get_status_string (int handle, char *com
break;
}
+ errno = atoi (cursor + 1);
+
if (*cursor == 'F')
_rmt_shutdown (handle, errno);
@@ -199,12 +199,19 @@ get_status_string (int handle, char *com
/* Read and return the status from remote tape connection HANDLE. If
an error occurred, return -1 and set errno. */
-static long
+static long int
get_status (int handle)
{
char command_buffer[COMMAND_BUFFER_SIZE];
const char *status = get_status_string (handle, command_buffer);
- return status ? atol (status) : -1L;
+ if (status)
+ {
+ long int result = atol (status);
+ if (0 <= result)
+ return result;
+ errno = EIO;
+ }
+ return -1;
}
static off_t
@@ -533,7 +540,7 @@ rmt_open__ (const char *path, int open_m
int
rmt_close__ (int handle)
{
- int status;
+ long int status;
if (do_command (handle, "C\n") == -1)
return -1;
@@ -544,26 +551,27 @@ rmt_close__ (int handle)
}
/* Read up to LENGTH bytes into BUFFER from remote tape connection HANDLE.
- Return the number of bytes read on success, -1 on error. */
-ssize_t
+ Return the number of bytes read on success, SAFE_READ_ERROR on error. */
+size_t
rmt_read__ (int handle, char *buffer, size_t length)
{
char command_buffer[COMMAND_BUFFER_SIZE];
- ssize_t status, rlen;
+ size_t status;
+ size_t rlen;
size_t counter;
sprintf (command_buffer, "R%lu\n", (unsigned long) length);
if (do_command (handle, command_buffer) == -1
- || (status = get_status (handle)) == -1)
- return -1;
+ || (status = get_status (handle)) == SAFE_READ_ERROR)
+ return SAFE_READ_ERROR;
for (counter = 0; counter < status; counter += rlen, buffer += rlen)
{
rlen = safe_read (READ_SIDE (handle), buffer, status - counter);
- if (rlen <= 0)
+ if (rlen == SAFE_READ_ERROR || rlen == 0)
{
_rmt_shutdown (handle, EIO);
- return -1;
+ return SAFE_READ_ERROR;
}
}
@@ -571,8 +579,8 @@ rmt_read__ (int handle, char *buffer, si
}
/* Write LENGTH bytes from BUFFER to remote tape connection HANDLE.
- Return the number of bytes written on success, -1 on error. */
-ssize_t
+ Return the number of bytes written. */
+size_t
rmt_write__ (int handle, char *buffer, size_t length)
{
char command_buffer[COMMAND_BUFFER_SIZE];
@@ -581,18 +589,25 @@ rmt_write__ (int handle, char *buffer, s
sprintf (command_buffer, "W%lu\n", (unsigned long) length);
if (do_command (handle, command_buffer) == -1)
- return -1;
+ return 0;
pipe_handler = signal (SIGPIPE, SIG_IGN);
written = full_write (WRITE_SIDE (handle), buffer, length);
signal (SIGPIPE, pipe_handler);
if (written == length)
- return get_status (handle);
+ {
+ long int r = get_status (handle);
+ if (r < 0)
+ return 0;
+ if (r == length)
+ return length;
+ written = r;
+ }
/* Write error. */
_rmt_shutdown (handle, EIO);
- return -1;
+ return written;
}
/* Perform an imitation lseek operation on remote tape connection
@@ -671,7 +686,7 @@ rmt_ioctl__ (int handle, int operation,
case MTIOCGET:
{
ssize_t status;
- ssize_t counter;
+ size_t counter;
/* Grab the status and read it directly into the structure. This
assumes that the status buffer is not padded and that 2 shorts
@@ -686,7 +701,7 @@ rmt_ioctl__ (int handle, int operation,
for (; status > 0; status -= counter, argument += counter)
{
counter = safe_read (READ_SIDE (handle), argument, status);
- if (counter <= 0)
+ if (counter == SAFE_READ_ERROR || counter == 0)
{
_rmt_shutdown (handle, EIO);
return -1;
Index: src/sparse.c
===================================================================
RCS file: /cvsroot/tar/tar/src/sparse.c,v
retrieving revision 1.7
diff -p -b -u -r1.7 sparse.c
--- src/sparse.c 4 Apr 2004 09:33:25 -0000 1.7
+++ src/sparse.c 5 Apr 2004 02:20:55 -0000
@@ -1,6 +1,6 @@
/* Functions for dealing with sparse files
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -39,8 +39,8 @@ struct tar_sparse_optab
bool (*decode_header) (struct tar_sparse_file *);
bool (*scan_block) (struct tar_sparse_file *, enum sparse_scan_state,
void *);
- bool (*dump_region) (struct tar_sparse_file *, size_t index);
- bool (*extract_region) (struct tar_sparse_file *, size_t index);
+ bool (*dump_region) (struct tar_sparse_file *, size_t);
+ bool (*extract_region) (struct tar_sparse_file *, size_t);
};
struct tar_sparse_file
@@ -89,18 +89,18 @@ tar_sparse_scan (struct tar_sparse_file
}
static bool
-tar_sparse_dump_region (struct tar_sparse_file *file, size_t index)
+tar_sparse_dump_region (struct tar_sparse_file *file, size_t i)
{
if (file->optab->dump_region)
- return file->optab->dump_region (file, index);
+ return file->optab->dump_region (file, i);
return false;
}
static bool
-tar_sparse_extract_region (struct tar_sparse_file *file, size_t index)
+tar_sparse_extract_region (struct tar_sparse_file *file, size_t i)
{
if (file->optab->extract_region)
- return file->optab->extract_region (file, index);
+ return file->optab->extract_region (file, i);
return false;
}
@@ -195,7 +195,8 @@ sparse_scan_file (struct tar_sparse_file
if (!tar_sparse_scan (file, scan_begin, NULL))
return false;
- while ((count = safe_read (file->fd, buffer, sizeof buffer)) > 0)
+ while ((count = safe_read (file->fd, buffer, sizeof buffer)) != 0
+ && count != SAFE_READ_ERROR)
{
/* Analize the block */
if (zero_block_p (buffer, count))
@@ -263,28 +264,28 @@ sparse_select_optab (struct tar_sparse_f
}
static bool
-sparse_dump_region (struct tar_sparse_file *file, size_t index)
+sparse_dump_region (struct tar_sparse_file *file, size_t i)
{
union block *blk;
- off_t bytes_left = file->stat_info->sparse_map[index].numbytes;
+ off_t bytes_left = file->stat_info->sparse_map[i].numbytes;
- if (!lseek_or_error (file, file->stat_info->sparse_map[index].offset,
+ if (!lseek_or_error (file, file->stat_info->sparse_map[i].offset,
SEEK_SET))
return false;
while (bytes_left > 0)
{
size_t bufsize = (bytes_left > BLOCKSIZE) ? BLOCKSIZE : bytes_left;
- off_t bytes_read;
+ size_t bytes_read;
blk = find_next_block ();
memset (blk->buffer, 0, BLOCKSIZE);
bytes_read = safe_read (file->fd, blk->buffer, bufsize);
- if (bytes_read < 0)
+ if (bytes_read == SAFE_READ_ERROR)
{
read_diag_details (file->stat_info->orig_file_name,
- file->stat_info->sparse_map[index].offset
- + file->stat_info->sparse_map[index].numbytes
+ file->stat_info->sparse_map[i].offset
+ + file->stat_info->sparse_map[i].numbytes
- bytes_left,
bufsize);
return false;
@@ -299,15 +300,15 @@ sparse_dump_region (struct tar_sparse_fi
}
static bool
-sparse_extract_region (struct tar_sparse_file *file, size_t index)
+sparse_extract_region (struct tar_sparse_file *file, size_t i)
{
size_t write_size;
- if (!lseek_or_error (file, file->stat_info->sparse_map[index].offset,
+ if (!lseek_or_error (file, file->stat_info->sparse_map[i].offset,
SEEK_SET))
return false;
- write_size = file->stat_info->sparse_map[index].numbytes;
+ write_size = file->stat_info->sparse_map[i].numbytes;
if (write_size == 0)
{
@@ -343,12 +344,12 @@ sparse_extract_region (struct tar_sparse
/* Interface functions */
enum dump_status
-sparse_dump_file (int fd, struct tar_stat_info *stat)
+sparse_dump_file (int fd, struct tar_stat_info *st)
{
bool rc;
struct tar_sparse_file file;
- file.stat_info = stat;
+ file.stat_info = st;
file.fd = fd;
if (!sparse_select_optab (&file)
@@ -375,43 +376,43 @@ sparse_dump_file (int fd, struct tar_sta
/* Returns true if the file represented by stat is a sparse one */
bool
-sparse_file_p (struct tar_stat_info *stat)
+sparse_file_p (struct tar_stat_info *st)
{
- return (ST_NBLOCKS (stat->stat)
- < (stat->stat.st_size / ST_NBLOCKSIZE
- + (stat->stat.st_size % ST_NBLOCKSIZE != 0)));
+ return (ST_NBLOCKS (st->stat)
+ < (st->stat.st_size / ST_NBLOCKSIZE
+ + (st->stat.st_size % ST_NBLOCKSIZE != 0)));
}
bool
-sparse_member_p (struct tar_stat_info *stat)
+sparse_member_p (struct tar_stat_info *st)
{
struct tar_sparse_file file;
if (!sparse_select_optab (&file))
return false;
- file.stat_info = stat;
+ file.stat_info = st;
return tar_sparse_member_p (&file);
}
bool
-sparse_fixup_header (struct tar_stat_info *stat)
+sparse_fixup_header (struct tar_stat_info *st)
{
struct tar_sparse_file file;
if (!sparse_select_optab (&file))
return false;
- file.stat_info = stat;
+ file.stat_info = st;
return tar_sparse_fixup_header (&file);
}
enum dump_status
-sparse_extract_file (int fd, struct tar_stat_info *stat, off_t *size)
+sparse_extract_file (int fd, struct tar_stat_info *st, off_t *size)
{
bool rc = true;
struct tar_sparse_file file;
size_t i;
- file.stat_info = stat;
+ file.stat_info = st;
file.fd = fd;
if (!sparse_select_optab (&file)
@@ -426,12 +427,12 @@ sparse_extract_file (int fd, struct tar_
}
enum dump_status
-sparse_skip_file (struct tar_stat_info *stat)
+sparse_skip_file (struct tar_stat_info *st)
{
bool rc = true;
struct tar_sparse_file file;
- file.stat_info = stat;
+ file.stat_info = st;
file.fd = -1;
if (!sparse_select_optab (&file)
@@ -461,7 +462,7 @@ check_sparse_region (struct tar_sparse_f
rdsize = BLOCKSIZE;
clear_block (diff_buffer);
bytes_read = safe_read (file->fd, diff_buffer, rdsize);
- if (bytes_read < 0)
+ if (bytes_read == SAFE_READ_ERROR)
{
read_diag_details (file->stat_info->orig_file_name,
beg,
@@ -481,14 +482,14 @@ check_sparse_region (struct tar_sparse_f
}
static bool
-check_data_region (struct tar_sparse_file *file, size_t index)
+check_data_region (struct tar_sparse_file *file, size_t i)
{
size_t size_left;
- if (!lseek_or_error (file, file->stat_info->sparse_map[index].offset,
+ if (!lseek_or_error (file, file->stat_info->sparse_map[i].offset,
SEEK_SET))
return false;
- size_left = file->stat_info->sparse_map[index].numbytes;
+ size_left = file->stat_info->sparse_map[i].numbytes;
while (size_left > 0)
{
size_t bytes_read;
@@ -502,11 +503,11 @@ check_data_region (struct tar_sparse_fil
}
set_next_block_after (blk);
bytes_read = safe_read (file->fd, diff_buffer, rdsize);
- if (bytes_read < 0)
+ if (bytes_read == SAFE_READ_ERROR)
{
read_diag_details (file->stat_info->orig_file_name,
- file->stat_info->sparse_map[index].offset
- + file->stat_info->sparse_map[index].numbytes
+ file->stat_info->sparse_map[i].offset
+ + file->stat_info->sparse_map[i].numbytes
- size_left,
rdsize);
return false;
@@ -523,14 +524,14 @@ check_data_region (struct tar_sparse_fil
}
bool
-sparse_diff_file (int fd, struct tar_stat_info *stat)
+sparse_diff_file (int fd, struct tar_stat_info *st)
{
bool rc = true;
struct tar_sparse_file file;
size_t i;
off_t offset = 0;
- file.stat_info = stat;
+ file.stat_info = st;
file.fd = fd;
if (!sparse_select_optab (&file)
@@ -581,7 +582,7 @@ enum oldgnu_add_status
};
static bool
-oldgnu_sparse_member_p (struct tar_sparse_file *file_unused)
+oldgnu_sparse_member_p (struct tar_sparse_file *file __attribute__ ((unused)))
{
return current_header->header.typeflag == GNUTYPE_SPARSE;
}
@@ -726,7 +727,7 @@ static struct tar_sparse_optab oldgnu_op
/* Star */
static bool
-star_sparse_member_p (struct tar_sparse_file *file_unused)
+star_sparse_member_p (struct tar_sparse_file *file __attribute__ ((unused)))
{
return current_header->header.typeflag == GNUTYPE_SPARSE;
}
Index: src/system.c
===================================================================
RCS file: /cvsroot/tar/tar/src/system.c,v
retrieving revision 1.6
diff -p -b -u -r1.6 system.c
--- src/system.c 29 Feb 2004 10:16:02 -0000 1.6
+++ src/system.c 5 Apr 2004 02:20:55 -0000
@@ -1,6 +1,6 @@
/* System-dependent calls for tar.
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -23,46 +23,33 @@
#include <signal.h>
void
-sys_stat_nanoseconds(struct tar_stat_info *stat)
+sys_stat_nanoseconds (struct tar_stat_info *st)
{
#if defined(HAVE_STRUCT_STAT_ST_SPARE1)
- stat->atime_nsec = stat->stat.st_spare1 * 1000;
- stat->mtime_nsec = stat->stat.st_spare2 * 1000;
- stat->ctime_nsec = stat->stat.st_spare3 * 1000;
+ st->atime_nsec = st->stat.st_spare1 * 1000;
+ st->mtime_nsec = st->stat.st_spare2 * 1000;
+ st->ctime_nsec = st->stat.st_spare3 * 1000;
#elif defined(HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC)
- stat->atime_nsec = stat->stat.st_atim.tv_nsec;
- stat->mtime_nsec = stat->stat.st_mtim.tv_nsec;
- stat->ctime_nsec = stat->stat.st_ctim.tv_nsec;
+ st->atime_nsec = st->stat.st_atim.tv_nsec;
+ st->mtime_nsec = st->stat.st_mtim.tv_nsec;
+ st->ctime_nsec = st->stat.st_ctim.tv_nsec;
#elif defined(HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC)
- stat->atime_nsec = stat->stat.st_atimespec.tv_nsec;
- stat->mtime_nsec = stat->stat.st_mtimespec.tv_nsec;
- stat->ctime_nsec = stat->stat.st_ctimespec.tv_nsec;
+ st->atime_nsec = st->stat.st_atimespec.tv_nsec;
+ st->mtime_nsec = st->stat.st_mtimespec.tv_nsec;
+ st->ctime_nsec = st->stat.st_ctimespec.tv_nsec;
#elif defined(HAVE_STRUCT_STAT_ST_ATIMENSEC)
- stat->atime_nsec = stat->stat.st_atimensec;
- stat->mtime_nsec = stat->stat.st_mtimensec;
- stat->ctime_nsec = stat->stat.st_ctimensec;
+ st->atime_nsec = st->stat.st_atimensec;
+ st->mtime_nsec = st->stat.st_mtimensec;
+ st->ctime_nsec = st->stat.st_ctimensec;
#else
- stat->atime_nsec = stat->mtime_nsec = stat->ctime_nsec = 0;
-#endif
-}
-
-int
-sys_utimes(char *file_name, struct timeval tvp[3])
-{
-#ifdef HAVE_UTIMES
- return utimes (file_name, tvp);
-#else
- struct utimbuf utimbuf;
- utimbuf.actime = tvp[0].tv_sec;
- utimbuf.modtime = tvp[1].tv_sec;
- return utime (file_name, &utimbuf);
+ st->atime_nsec = st->mtime_nsec = st->ctime_nsec = 0;
#endif
}
#if MSDOS
bool
-sys_get_archive_stat ()
+sys_get_archive_stat (void)
{
return 0;
}
@@ -74,12 +61,12 @@ sys_file_is_archive (struct tar_stat_inf
}
void
-sys_save_archive_dev_ino ()
+sys_save_archive_dev_ino (void)
{
}
void
-sys_detect_dev_null_output ()
+sys_detect_dev_null_output (void)
{
static char const dev_null[] = "nul";
@@ -88,7 +75,7 @@ sys_detect_dev_null_output ()
}
void
-sys_drain_input_pipe ()
+sys_drain_input_pipe (void)
{
}
@@ -98,7 +85,7 @@ sys_wait_for_child (pid_t child_pid)
}
void
-sys_spawn_shell ()
+sys_spawn_shell (void)
{
spawnl (P_WAIT, getenv ("COMSPEC"), "-", 0);
}
@@ -132,25 +119,14 @@ sys_truncate (int fd)
}
void
-sys_reset_uid_gid ()
+sys_reset_uid_gid (void)
{
}
-ssize_t
+size_t
sys_write_archive_buffer (void)
{
- ssize_t status;
- ssize_t written = 0;
-
- while (0 <= (status = full_write (archive, record_start->buffer + written,
- record_size - written)))
- {
- written += status;
- if (written == record_size)
- break;
- }
-
- return written ? written : status;
+ return full_write (archive, record_start->buffer, record_size);
}
/* Set ARCHIVE for writing, then compressing an archive. */
@@ -174,7 +150,7 @@ extern union block *record_start; /* FIX
static struct stat archive_stat; /* stat block for archive file */
bool
-sys_get_archive_stat ()
+sys_get_archive_stat (void)
{
return fstat (archive, &archive_stat) == 0;
}
@@ -187,7 +163,7 @@ sys_file_is_archive (struct tar_stat_inf
/* Save archive file inode and device numbers */
void
-sys_save_archive_dev_ino ()
+sys_save_archive_dev_ino (void)
{
if (!_isrmt (archive) && S_ISREG (archive_stat.st_mode))
{
@@ -200,7 +176,7 @@ sys_save_archive_dev_ino ()
/* Detect if outputting to "/dev/null". */
void
-sys_detect_dev_null_output ()
+sys_detect_dev_null_output (void)
{
static char const dev_null[] = "/dev/null";
struct stat dev_null_stat;
@@ -219,12 +195,15 @@ sys_detect_dev_null_output ()
work to do, we might have to revise this area in such time. */
void
-sys_drain_input_pipe ()
+sys_drain_input_pipe (void)
{
+ size_t r;
+
if (access_mode == ACCESS_READ
&& ! _isrmt (archive)
&& (S_ISFIFO (archive_stat.st_mode) || S_ISSOCK (archive_stat.st_mode)))
- while (rmtread (archive, record_start->buffer, record_size) > 0)
+ while ((r = rmtread (archive, record_start->buffer, record_size)) != 0
+ && r != SAFE_READ_ERROR)
continue;
}
@@ -252,7 +231,7 @@ sys_wait_for_child (pid_t child_pid)
}
void
-sys_spawn_shell ()
+sys_spawn_shell (void)
{
pid_t child;
const char *shell = getenv ("SHELL");
@@ -303,7 +282,7 @@ sys_truncate (int fd)
}
void
-sys_reset_uid_gid ()
+sys_reset_uid_gid (void)
{
setuid (getuid ());
setgid (getgid ());
@@ -322,24 +301,10 @@ is_regular_file (const char *name)
return errno == ENOENT;
}
-ssize_t
+size_t
sys_write_archive_buffer (void)
{
- ssize_t status;
- ssize_t written = 0;
-
- while (0 <= (status = rmtwrite (archive, record_start->buffer + written,
- record_size - written)))
- {
- written += status;
- if (written == record_size
- || _isrmt (archive)
- || ! (S_ISFIFO (archive_stat.st_mode)
- || S_ISSOCK (archive_stat.st_mode)))
- break;
- }
-
- return written ? written : status;
+ return rmtwrite (archive, record_start->buffer, record_size);
}
#define PREAD 0 /* read file descriptor from pipe() */
@@ -471,7 +436,7 @@ sys_child_open_for_compress (void)
while (1)
{
- ssize_t status = 0;
+ size_t status = 0;
char *cursor;
size_t length;
@@ -484,13 +449,12 @@ sys_child_open_for_compress (void)
size_t size = record_size - length;
status = safe_read (STDIN_FILENO, cursor, size);
- if (status <= 0)
+ if (status == SAFE_READ_ERROR)
+ read_fatal (use_compress_program_option);
+ if (status == 0)
break;
}
- if (status < 0)
- read_fatal (use_compress_program_option);
-
/* Copy the record. */
if (status == 0)
@@ -628,13 +592,13 @@ sys_child_open_for_uncompress (void)
char *cursor;
size_t maximum;
size_t count;
- ssize_t status;
+ size_t status;
clear_read_error_count ();
error_loop:
status = rmtread (archive, record_start->buffer, record_size);
- if (status < 0)
+ if (status == SAFE_READ_ERROR)
{
archive_read_error ();
goto error_loop;
Index: src/tar.c
===================================================================
RCS file: /cvsroot/tar/tar/src/tar.c,v
retrieving revision 1.83
diff -p -b -u -r1.83 tar.c
--- src/tar.c 4 Apr 2004 09:47:08 -0000 1.83
+++ src/tar.c 5 Apr 2004 02:20:56 -0000
@@ -1,7 +1,7 @@
/* A tar (tape archiver) program.
Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000,
- 2001, 2003 Free Software Foundation, Inc.
+ 2001, 2003, 2004 Free Software Foundation, Inc.
Written by John Gilmore, starting 1985-08-25.
@@ -595,7 +595,8 @@ decode_options (int argc, char **argv)
blocking_factor = DEFAULT_BLOCKING;
record_size = DEFAULT_BLOCKING * BLOCKSIZE;
excluded = new_exclude ();
- newer_mtime_option = TYPE_MINIMUM (time_t);
+ newer_mtime_option.tv_sec = TYPE_MINIMUM (time_t);
+ newer_mtime_option.tv_nsec = -1;
recursion_option = FNM_LEADING_DIR;
owner_option = -1;
@@ -823,7 +824,7 @@ decode_options (int argc, char **argv)
/* Fall through. */
case NEWER_MTIME_OPTION:
- if (newer_mtime_option != TYPE_MINIMUM (time_t))
+ if (NEWER_OPTION_INITIALIZED (newer_mtime_option))
USAGE_ERROR ((0, 0, _("More than one threshold date")));
if (FILESYSTEM_PREFIX_LEN (optarg) != 0
@@ -836,14 +837,17 @@ decode_options (int argc, char **argv)
stat_error (optarg);
USAGE_ERROR ((0, 0, _("Date file not found")));
}
- newer_mtime_option = st.st_mtime;
+ newer_mtime_option.tv_sec = st.st_mtime;
+ newer_mtime_option.tv_nsec = TIMESPEC_NS (st.st_mtim);
}
else
{
- newer_mtime_option = get_date (optarg, 0);
- if (newer_mtime_option == (time_t) -1)
+ if (! get_date (&newer_mtime_option, optarg, NULL))
+ {
WARN ((0, 0, _("Substituting %s for unknown date format %s"),
- tartime (newer_mtime_option), quote (optarg)));
+ tartime (newer_mtime_option.tv_sec), quote (optarg)));
+ newer_mtime_option.tv_nsec = 0;
+ }
else
textual_date_option = optarg;
}
@@ -1285,7 +1289,7 @@ decode_options (int argc, char **argv)
if (show_version)
{
printf ("tar (%s) %s\n%s\n", PACKAGE_NAME, PACKAGE_VERSION,
- "Copyright (C) 2003 Free Software Foundation, Inc.");
+ "Copyright (C) 2004 Free Software Foundation, Inc.");
puts (_("\
This program comes with NO WARRANTY, to the extent permitted by law.\n\
You may redistribute it under the terms of the GNU General Public License;\n\
@@ -1353,7 +1357,7 @@ see the file named COPYING for details."
_("Multiple archive files require `-M' option")));
if (listed_incremental_option
- && newer_mtime_option != TYPE_MINIMUM (time_t))
+ && NEWER_OPTION_INITIALIZED (newer_mtime_option))
USAGE_ERROR ((0, 0,
_("Cannot combine --listed-incremental with --newer")));
@@ -1455,10 +1459,12 @@ see the file named COPYING for details."
if (verbose_option && textual_date_option)
{
- char const *treated_as = tartime (newer_mtime_option);
+ /* FIXME: tartime should support nanoseconds, too, so that this
+ comparison doesn't complain about lost nanoseconds. */
+ char const *treated_as = tartime (newer_mtime_option.tv_sec);
if (strcmp (textual_date_option, treated_as) != 0)
- WARN ((0, 0, _("Treating date `%s' as %s"),
- textual_date_option, treated_as));
+ WARN ((0, 0, _("Treating date `%s' as %s + %ld nanoseconds"),
+ textual_date_option, treated_as, newer_mtime_option.tv_nsec));
}
}
@@ -1499,7 +1505,7 @@ main (int argc, char **argv)
/* Decode options. */
decode_options (argc, argv);
- name_init (argc, argv);
+ name_init ();
/* Main command execution. */
Index: src/update.c
===================================================================
RCS file: /cvsroot/tar/tar/src/update.c,v
retrieving revision 1.27
diff -p -b -u -r1.27 update.c
--- src/update.c 20 Feb 2004 15:33:12 -0000 1.27
+++ src/update.c 5 Apr 2004 02:20:56 -0000
@@ -1,7 +1,7 @@
/* Update a tar archive.
- Copyright (C) 1988, 1992, 1994, 1996, 1997, 1999, 2000, 2001, 2003
- Free Software Foundation, Inc.
+ Copyright (C) 1988, 1992, 1994, 1996, 1997, 1999, 2000, 2001, 2003,
+ 2004 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -66,7 +66,7 @@ append_file (char *path)
{
union block *start = find_next_block ();
size_t buffer_size = available_space_after (start);
- ssize_t status;
+ size_t status;
char buf[UINTMAX_STRSIZE_BOUND];
if (bytes_left < buffer_size)
@@ -78,7 +78,7 @@ append_file (char *path)
}
status = safe_read (handle, start->buffer, buffer_size);
- if (status < 0)
+ if (status == SAFE_READ_ERROR)
read_fatal_details (path, stat_data.st_size - bytes_left,
buffer_size);
if (status == 0)
Index: src/utf8.c
===================================================================
RCS file: /cvsroot/tar/tar/src/utf8.c,v
retrieving revision 1.3
diff -p -b -u -r1.3 utf8.c
--- src/utf8.c 4 Apr 2004 09:42:27 -0000 1.3
+++ src/utf8.c 5 Apr 2004 02:20:56 -0000
@@ -23,11 +23,13 @@
# include <iconv.h>
#endif
+#ifdef HAVE_LIBICONV
+
struct langtab
{
- char *lang; /* Language code */
- char *terr; /* Territory code */
- char *charset; /* Corresponding charset */
+ char const *lang; /* Language code */
+ char const *terr; /* Territory code */
+ char const *charset; /* Corresponding charset */
};
/* The list of language codes defined in ISO 639 with the corresponding
@@ -216,16 +218,16 @@ static struct langtab langtab[] = {
{ "zh", "TW", "big5"}, /* Chinese */
{ "zh", NULL, "gb2312"}, /* Chinese */
{ "zu", NULL, NULL}, /* Zulu */
- { NULL }
+ { NULL, NULL, NULL}
};
/* Given the language and (optionally) territory code, return the
default character set for that language. See notes above. */
-const char *
-charset_lookup (char *lang, char *terr)
+static char const *
+charset_lookup (char const *lang, char const *terr)
{
- static struct langtab *p;
+ struct langtab const *p;
if (!lang)
return NULL;
@@ -239,7 +241,7 @@ charset_lookup (char *lang, char *terr)
}
static const char *
-get_input_charset ()
+get_input_charset (void)
{
const char *charset = NULL;
char *tmp;
@@ -268,30 +270,18 @@ get_input_charset ()
return charset;
}
+#else /* !defined HAVE_LIBICONV */
+# undef iconv_open
+# define iconv_open(tocode, fromcode) ((iconv_t) -1)
-#ifndef HAVE_LIBICONV
+# undef iconv
+# define iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft) ((size_t) 0)
-iconv_t
-iconv_open (const char *tocode, const char *fromcode)
-{
- return (iconv_t)(-1);
-}
-
-size_t
-iconv (iconv_t cd, ICONV_CONST char **inbuf, size_t *inbytesleft,
- char **outbuf, size_t *outbytesleft)
-{
- return 0;
-}
-
-int
-iconv_close (iconv_t cd)
-{
- return 0;
-}
+# undef iconv_close
+# define iconv_close(cd) 0
-#endif /* !HAVE_LIBICONV */
+#endif /* !defined HAVE_LIBICONV */
@@ -312,9 +302,9 @@ utf8_init (bool to_utf)
}
bool
-utf8_convert(bool to_utf, const char *input, char **output)
+utf8_convert (bool to_utf, char const *input, char **output)
{
- const char *ib;
+ char ICONV_CONST *ib;
char *ob;
size_t inlen;
size_t outlen;
@@ -332,7 +322,7 @@ utf8_convert(bool to_utf, const char *in
inlen = strlen (input) + 1;
outlen = inlen * MB_LEN_MAX + 1;
ob = *output = xmalloc (outlen);
- ib = input;
+ ib = (char ICONV_CONST *) input;
rc = iconv (cd, &ib, &inlen, &ob, &outlen);
*ob = 0;
return rc != -1;
Index: src/xheader.c
===================================================================
RCS file: /cvsroot/tar/tar/src/xheader.c,v
retrieving revision 1.17
diff -p -b -u -r1.17 xheader.c
--- src/xheader.c 4 Apr 2004 09:43:09 -0000 1.17
+++ src/xheader.c 5 Apr 2004 02:20:56 -0000
@@ -18,6 +18,7 @@
#include "system.h"
+#include <fnmatch.h>
#include <hash.h>
#include <quotearg.h>
#include <xstrtol.h>
@@ -30,13 +31,14 @@
#include <fnmatch.h>
-bool xheader_protected_pattern_p (const char *pattern);
-bool xheader_protected_keyword_p (const char *keyword);
+static bool xheader_protected_pattern_p (char const *pattern);
+static bool xheader_protected_keyword_p (char const *keyword);
+static void xheader_set_single_keyword (char *) __attribute__ ((noreturn));
/* Used by xheader_finish() */
static void code_string (char const *string, char const *keyword,
struct xheader *xhdr);
-static void extended_header_init ();
+static void extended_header_init (void);
/* Number of global headers written so far. */
static size_t global_header_count;
@@ -80,7 +82,7 @@ static char *exthdr_name;
/* Template for the name field of a 'g' type header */
static char *globexthdr_name;
-bool
+static bool
xheader_keyword_deleted_p (const char *kw)
{
struct keyword_list *kp;
@@ -91,7 +93,7 @@ xheader_keyword_deleted_p (const char *k
return false;
}
-bool
+static bool
xheader_keyword_override_p (const char *keyword)
{
struct keyword_list *kp;
@@ -102,7 +104,7 @@ xheader_keyword_override_p (const char *
return false;
}
-void
+static void
xheader_list_append (struct keyword_list **root, char const *kw,
char const *value)
{
@@ -113,7 +115,7 @@ xheader_list_append (struct keyword_list
*root = kp;
}
-void
+static void
xheader_list_destroy (struct keyword_list **root)
{
if (root)
@@ -131,14 +133,13 @@ xheader_list_destroy (struct keyword_lis
}
}
-
-void
+static void
xheader_set_single_keyword (char *kw)
{
USAGE_ERROR ((0, 0, _("Keyword %s is unknown or not yet imlemented"), kw));
}
-void
+static void
xheader_set_keyword_equal (char *kw, char *eq)
{
bool global = true;
@@ -232,8 +233,8 @@ xheader_format_name (struct tar_stat_inf
size_t len = strlen (fmt);
char *q;
const char *p;
- char *dirname = NULL;
- char *basename = NULL;
+ char *dir = NULL;
+ char *base = NULL;
char pidbuf[64];
char nbuf[64];
@@ -248,17 +249,16 @@ xheader_format_name (struct tar_stat_inf
case 'd':
if (st)
{
- dirname = safer_name_suffix (dir_name (st->orig_file_name),
- false);
- len += strlen (dirname) - 1;
+ dir = safer_name_suffix (dir_name (st->orig_file_name), false);
+ len += strlen (dir) - 1;
}
break;
case 'f':
if (st)
{
- basename = base_name (st->orig_file_name);
- len += strlen (basename) - 1;
+ base = base_name (st->orig_file_name);
+ len += strlen (base) - 1;
}
break;
@@ -291,14 +291,14 @@ xheader_format_name (struct tar_stat_inf
break;
case 'd':
- if (dirname)
- q = stpcpy (q, dirname);
+ if (dir)
+ q = stpcpy (q, dir);
p += 2;
break;
case 'f':
- if (basename)
- q = stpcpy (q, basename);
+ if (base)
+ q = stpcpy (q, base);
p += 2;
break;
@@ -343,7 +343,7 @@ xheader_xhdr_name (struct tar_stat_info
#define GLOBAL_HEADER_TEMPLATE "/GlobalHead.%p.%n"
char *
-xheader_ghdr_name ()
+xheader_ghdr_name (void)
{
if (!globexthdr_name)
{
@@ -395,7 +395,7 @@ xheader_write (char type, char *name, st
}
void
-xheader_write_global ()
+xheader_write_global (void)
{
char *name;
struct keyword_list *kp;
@@ -444,7 +444,7 @@ locate_handler (char const *keyword)
return NULL;
}
-bool
+static bool
xheader_protected_pattern_p (const char *pattern)
{
struct xhdr_tab const *p;
@@ -455,7 +455,7 @@ xheader_protected_pattern_p (const char
return false;
}
-bool
+static bool
xheader_protected_keyword_p (const char *keyword)
{
struct xhdr_tab const *p;
@@ -566,7 +566,7 @@ decg (void *data, char const *keyword, c
}
void
-xheader_decode_global ()
+xheader_decode_global (void)
{
if (extended_header.size)
{
@@ -581,7 +581,7 @@ xheader_decode_global ()
}
static void
-extended_header_init ()
+extended_header_init (void)
{
if (!extended_header.stk)
{
@@ -783,19 +783,22 @@ code_num (uintmax_t value, char const *k
}
static void
-dummy_coder (struct tar_stat_info const *st, char const *keyword,
- struct xheader *xhdr, void *data)
+dummy_coder (struct tar_stat_info const *st __attribute__ ((unused)),
+ char const *keyword __attribute__ ((unused)),
+ struct xheader *xhdr __attribute__ ((unused)),
+ void *data __attribute__ ((unused)))
{
}
static void
-dummy_decoder (struct tar_stat_info *st, char const *arg)
+dummy_decoder (struct tar_stat_info *st __attribute__ ((unused)),
+ char const *arg __attribute__ ((unused)))
{
}
static void
atime_coder (struct tar_stat_info const *st, char const *keyword,
- struct xheader *xhdr, void *data)
+ struct xheader *xhdr, void *data __attribute__ ((unused)))
{
code_time (st->stat.st_atime, st->atime_nsec, keyword, xhdr);
}
@@ -808,7 +811,7 @@ atime_decoder (struct tar_stat_info *st,
static void
gid_coder (struct tar_stat_info const *st, char const *keyword,
- struct xheader *xhdr, void *data)
+ struct xheader *xhdr, void *data __attribute__ ((unused)))
{
code_num (st->stat.st_gid, keyword, xhdr);
}
@@ -823,7 +826,7 @@ gid_decoder (struct tar_stat_info *st, c
static void
gname_coder (struct tar_stat_info const *st, char const *keyword,
- struct xheader *xhdr, void *data)
+ struct xheader *xhdr, void *data __attribute__ ((unused)))
{
code_string (st->gname, keyword, xhdr);
}
@@ -836,7 +839,7 @@ gname_decoder (struct tar_stat_info *st,
static void
linkpath_coder (struct tar_stat_info const *st, char const *keyword,
- struct xheader *xhdr, void *data)
+ struct xheader *xhdr, void *data __attribute__ ((unused)))
{
code_string (st->link_name, keyword, xhdr);
}
@@ -849,7 +852,7 @@ linkpath_decoder (struct tar_stat_info *
static void
ctime_coder (struct tar_stat_info const *st, char const *keyword,
- struct xheader *xhdr, void *data)
+ struct xheader *xhdr, void *data __attribute__ ((unused)))
{
code_time (st->stat.st_ctime, st->ctime_nsec, keyword, xhdr);
}
@@ -862,7 +865,7 @@ ctime_decoder (struct tar_stat_info *st,
static void
mtime_coder (struct tar_stat_info const *st, char const *keyword,
- struct xheader *xhdr, void *data)
+ struct xheader *xhdr, void *data __attribute__ ((unused)))
{
code_time (st->stat.st_mtime, st->mtime_nsec, keyword, xhdr);
}
@@ -875,7 +878,7 @@ mtime_decoder (struct tar_stat_info *st,
static void
path_coder (struct tar_stat_info const *st, char const *keyword,
- struct xheader *xhdr, void *data)
+ struct xheader *xhdr, void *data __attribute__ ((unused)))
{
code_string (st->file_name, keyword, xhdr);
}
@@ -890,7 +893,7 @@ path_decoder (struct tar_stat_info *st,
static void
size_coder (struct tar_stat_info const *st, char const *keyword,
- struct xheader *xhdr, void *data)
+ struct xheader *xhdr, void *data __attribute__ ((unused)))
{
code_num (st->stat.st_size, keyword, xhdr);
}
@@ -905,7 +908,7 @@ size_decoder (struct tar_stat_info *st,
static void
uid_coder (struct tar_stat_info const *st, char const *keyword,
- struct xheader *xhdr, void *data)
+ struct xheader *xhdr, void *data __attribute__ ((unused)))
{
code_num (st->stat.st_uid, keyword, xhdr);
}
@@ -920,7 +923,7 @@ uid_decoder (struct tar_stat_info *st, c
static void
uname_coder (struct tar_stat_info const *st, char const *keyword,
- struct xheader *xhdr, void *data)
+ struct xheader *xhdr, void *data __attribute__ ((unused)))
{
code_string (st->uname, keyword, xhdr);
}
@@ -948,7 +951,8 @@ sparse_size_decoder (struct tar_stat_inf
static void
sparse_numblocks_coder (struct tar_stat_info const *st, char const *keyword,
- struct xheader *xhdr, void *data)
+ struct xheader *xhdr,
+ void *data __attribute__ ((unused)))
{
code_num (st->sparse_map_avail, keyword, xhdr);
}
@@ -1007,18 +1011,18 @@ sparse_numbytes_decoder (struct tar_stat
}
struct xhdr_tab const xhdr_tab[] = {
- { "atime", atime_coder, atime_decoder },
- { "comment", dummy_coder, dummy_decoder },
- { "charset", dummy_coder, dummy_decoder },
- { "ctime", ctime_coder, ctime_decoder },
- { "gid", gid_coder, gid_decoder },
- { "gname", gname_coder, gname_decoder },
- { "linkpath", linkpath_coder, linkpath_decoder},
- { "mtime", mtime_coder, mtime_decoder },
- { "path", path_coder, path_decoder },
- { "size", size_coder, size_decoder },
- { "uid", uid_coder, uid_decoder },
- { "uname", uname_coder, uname_decoder },
+ { "atime", atime_coder, atime_decoder, false },
+ { "comment", dummy_coder, dummy_decoder, false },
+ { "charset", dummy_coder, dummy_decoder, false },
+ { "ctime", ctime_coder, ctime_decoder, false },
+ { "gid", gid_coder, gid_decoder, false },
+ { "gname", gname_coder, gname_decoder, false },
+ { "linkpath", linkpath_coder, linkpath_decoder, false },
+ { "mtime", mtime_coder, mtime_decoder, false },
+ { "path", path_coder, path_decoder, false },
+ { "size", size_coder, size_decoder, false },
+ { "uid", uid_coder, uid_decoder, false },
+ { "uname", uname_coder, uname_decoder, false },
/* Sparse file handling */
{ "GNU.sparse.size", sparse_size_coder, sparse_size_decoder, true },
@@ -1034,12 +1038,12 @@ struct xhdr_tab const xhdr_tab[] = {
/* The next directory entry actually contains the names of files
that were in the directory at the time the dump was made.
Supersedes GNUTYPE_DUMPDIR header type. */
- { "GNU.dump.name", dump_name_coder, dump_name_decoder },
- { "GNU.dump.status", dump_status_coder, dump_status_decoder },
+ { "GNU.dump.name", dump_name_coder, dump_name_decoder, false },
+ { "GNU.dump.status", dump_status_coder, dump_status_decoder, false },
/* Keeps the tape/volume header. May be present only in the global headers.
Equivalent to GNUTYPE_VOLHDR. */
- { "GNU.volume.header", volume_header_coder, volume_header_decoder },
+ { "GNU.volume.header", volume_header_coder, volume_header_decoder, false },
/* These may be present in a first global header of the archive.
They provide the same functionality as GNUTYPE_MULTIVOL header.
@@ -1047,9 +1051,9 @@ struct xhdr_tab const xhdr_tab[] = {
otherwise kept in the size field of a multivolume header. The
GNU.volume.offset keeps the offset of the start of this volume,
otherwise kept in oldgnu_header.offset. */
- { "GNU.volume.size", volume_size_coder, volume_size_decoder },
- { "GNU.volume.offset", volume_offset_coder, volume_offset_decoder },
+ { "GNU.volume.size", volume_size_coder, volume_size_decoder, false },
+ { "GNU.volume.offset", volume_offset_coder, volume_offset_decoder, false },
#endif
- { NULL, NULL, NULL }
+ { NULL, NULL, NULL, false }
};
Index: tests/genfile.c
===================================================================
RCS file: /cvsroot/tar/tar/tests/genfile.c,v
retrieving revision 1.14
diff -p -b -u -r1.14 genfile.c
--- tests/genfile.c 5 Jul 2003 08:24:55 -0000 1.14
+++ tests/genfile.c 5 Apr 2004 02:20:56 -0000
@@ -1,6 +1,6 @@
/* Generate a file containing some preset patterns.
- Copyright (C) 1995, 1996, 1997, 2001, 2003 Free Software
+ Copyright (C) 1995, 1996, 1997, 2001, 2003, 2004 Free Software
Foundation, Inc.
François Pinard <address@hidden>, 1995.
@@ -54,7 +54,8 @@ static int file_length = 0;
static enum pattern pattern = DEFAULT_PATTERN;
/* Explain how to use the program, then get out. */
-void
+static void usage (int) __attribute__ ((noreturn));
+static void
usage (int status)
{
if (status != EXIT_SUCCESS)
Index: tests/mksparse.c
===================================================================
RCS file: /cvsroot/tar/tar/tests/mksparse.c,v
retrieving revision 1.1
diff -p -b -u -r1.1 mksparse.c
--- tests/mksparse.c 3 Jan 2004 22:27:36 -0000 1.1
+++ tests/mksparse.c 5 Apr 2004 02:20:56 -0000
@@ -30,8 +30,10 @@ char *progname;
char *buffer;
size_t buffer_size;
-void
-die (char *fmt, ...)
+static void die (char const *, ...) __attribute__ ((noreturn,
+ format (printf, 1, 2)));
+static void
+die (char const *fmt, ...)
{
va_list ap;
@@ -40,12 +42,13 @@ die (char *fmt, ...)
vfprintf (stderr, fmt, ap);
va_end (ap);
fprintf (stderr, "\n");
+ exit (1);
}
-void
+static void
mkhole (int fd, off_t displ)
{
- if (displ = lseek (fd, displ, SEEK_CUR) == -1)
+ if (lseek (fd, displ, SEEK_CUR) == -1)
{
perror ("lseek");
exit (1);
@@ -53,11 +56,9 @@ mkhole (int fd, off_t displ)
ftruncate (fd, lseek (fd, 0, SEEK_CUR));
}
-void
+static void
mksparse (int fd, off_t displ, char *marks)
{
- int i;
-
for (; *marks; marks++)
{
memset (buffer, *marks, buffer_size);
@@ -75,14 +76,15 @@ mksparse (int fd, off_t displ, char *mar
}
}
-void
-usage ()
+static void usage (void) __attribute__ ((noreturn));
+static void
+usage (void)
{
printf ("Usage: mksparse filename blocksize disp letters [disp letters...]
[disp]\n");
exit (1);
}
-int
+static int
xlat_suffix (off_t *vp, char *p)
{
if (p[1])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug-tar] merge of gnulib changes into tar, plus some lint cleanup,
Paul Eggert <=