[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-tar] Support for Hurd translators
From: |
Marco Gerards |
Subject: |
Re: [Bug-tar] Support for Hurd translators |
Date: |
31 Jan 2004 00:10:00 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
Sergey Poznyakoff <address@hidden> writes:
Hi Sergey,
> A couple of notices:
>
> * Inclusions of <hurd.h> should be protected by #ifdef #endif
> * A backup definition of O_NOTRANS (#define O_NOTRANS 0) should be
> provided for non-Hurd systems.
> * The system-dependent parts (set_translator,read_trans) should go to
> system.c and should also be protected by #ifdefs.
> * There should be a code in configure.ac that would detect the presence
> of hurd.h and the hurd-specific calls (mach_port_deallocate,
> mach_task_self).
A new patch is added to this mail. It fixes these issues and so other.
> I'll be able to test the code on the live Hurd machine by the end of
> this week.
Did you find the time to do this?
Please let me know what you think of this patch.
Thanks,
Marco
2004-01-31 Marco Gerards <address@hidden>
* configure.ac: Test for the headerfile <hurd.h>. Test for the
functions mach_port_deallocate file_set_translator
file_get_translator.
* src/common.h (noderef_trans_option): New variable.
(translator_error): New prototype.
* src/create.c (start_header): If a translator was set on a node,
write it to the header.
(dump_file0) [HAVE_FILE_GET_TRANSLATOR]: Read the translator.
Read the underlaying node if this node is a translator.
* src/extract.c: Include <hurd.h>.
(extract_archive) [HAVE_FILE_SET_TRANSLATOR]: Set the translator
if there was one in the archive.
* src/incremen.c (get_directory_contents)
[HAVE_FILE_GET_TRANSLATOR]: Do not dereference if a translator was
set on a node.
* src/names.c (collect_and_sort_names) [HAVE_FILE_GET_TRANSLATOR]:
Likewise.
* src/update.c (update_archive) [HAVE_FILE_GET_TRANSLATOR]:
Likewise.
* src/compare.c (get_stat_data) [HAVE_FILE_GET_TRANSLATOR]:
Likewise.
* src/list.c (print_header): Show the translator.
* src/misc.c (translator_error): New function.
* src/system.c [HAVE_UTIME_H]: Include <utime.h>.
(set_translator) [HAVE_FILE_SET_TRANSLATOR]: New function.
(read_trans) [HAVE_FILE_GET_TRANSLATOR]: Likewise.
* src/system.h [HAVE_HURD_H]: Include <hurd.h>.
(O_NOTRANS) [! O_NOTRANS]: New macro.
(set_translator) [HAVE_FILE_SET_TRANSLATOR]: New prototype.
(read_trans) [HAVE_FILE_GET_TRANSLATOR]: Likewise.
* src/tar.c (long_options): All `--no-deref-trans'.
(OPTION_STRING): Add the option `a' for `--no-deref-trans'.
(decode_options): Parse the `--no-deref-trans' option. Do not
dereference if a translator was set on a node.
(tar_stat_destroy): Free the memory used for a translator.
* src/tar.h (tar_stat_info): New member `translator'.
* src/xheader.c (translator_coder): New function.
(translator_decoder): Likewise.
(xhdr_tab): Added option `GNU.translator'.
Index: configure.ac
===================================================================
RCS file: /cvsroot/tar/tar/configure.ac,v
retrieving revision 1.24
diff -u -p -u -p -r1.24 configure.ac
--- configure.ac 21 Jan 2004 10:32:06 -0000 1.24
+++ configure.ac 30 Jan 2004 22:59:25 -0000
@@ -1,7 +1,7 @@
# Configure template for GNU tar.
# Copyright (C) 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-# 2002, 2003 Free Software Foundation, Inc.
+# 2002, 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
@@ -38,7 +38,7 @@ AC_CHECK_HEADERS(fcntl.h linux/fd.h memo
sys/buf.h sys/device.h sys/gentape.h \
sys/inet.h sys/io/trioctl.h \
sys/mtio.h sys/tprintf.h sys/tape.h \
- unistd.h)
+ unistd.h hurd.h)
AC_HEADER_SYS_WAIT
AM_STDBOOL_H
@@ -169,6 +169,7 @@ AC_CHECK_FUNCS(fsync lstat mkfifo readli
AC_CHECK_DECLS([getgrgid],,, [#include <grp.h>])
AC_CHECK_DECLS([getpwuid],,, [#include <pwd.h>])
AC_CHECK_DECLS([valloc])
+AC_CHECK_FUNCS(mach_port_deallocate file_set_translator file_get_translator)
# Set LIB_SETSOCKOPT to -lnsl -lsocket if necessary.
tar_save_LIBS=$LIBS
Index: src/common.h
===================================================================
RCS file: /cvsroot/tar/tar/src/common.h,v
retrieving revision 1.28
diff -u -p -u -p -r1.28 common.h
--- src/common.h 3 Jan 2004 22:24:35 -0000 1.28
+++ src/common.h 30 Jan 2004 22:59:43 -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
@@ -150,6 +150,8 @@ GLOBAL const char *use_compress_program_
GLOBAL bool dereference_option;
+GLOBAL bool noderef_trans_option;
+
/* Print a message if not all links are dumped */
GLOBAL int check_links_option;
@@ -553,6 +555,7 @@ void unlink_error (char const *);
void utime_error (char const *);
void waitpid_error (char const *);
void write_error (char const *);
+void translator_error (char const *);
void write_error_details (char const *, ssize_t, size_t);
void write_fatal (char const *) __attribute__ ((noreturn));
void write_fatal_details (char const *, ssize_t, size_t)
Index: src/compare.c
===================================================================
RCS file: /cvsroot/tar/tar/src/compare.c,v
retrieving revision 1.18
diff -u -p -u -p -r1.18 compare.c
--- src/compare.c 17 Nov 2003 11:05:18 -0000 1.18
+++ src/compare.c 30 Jan 2004 22:59:43 -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.
@@ -179,7 +179,16 @@ read_and_process (off_t size, int (*proc
static int
get_stat_data (char const *file_name, struct stat *stat_data)
{
- int status = deref_stat (dereference_option, file_name, stat_data);
+ int status = 1;
+
+#if HAVE_FILE_SET_TRANSLATOR
+ if (!noderef_trans_option || !read_trans (file_name, stat_data, 0))
+ status = deref_stat (dereference_option, file_name, stat_data);
+ else
+ status = 1;
+#else
+ status = deref_stat (dereference_option, file_name, stat_data);
+#endif
if (status != 0)
{
Index: src/create.c
===================================================================
RCS file: /cvsroot/tar/tar/src/create.c,v
retrieving revision 1.75
diff -u -p -u -p -r1.75 create.c
--- src/create.c 3 Jan 2004 22:25:24 -0000 1.75
+++ src/create.c 30 Jan 2004 22:59:45 -0000
@@ -1,7 +1,7 @@
/* Create a tar archive.
Copyright (C) 1985, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001,
- 2003 Free Software Foundation, Inc.
+ 2003, 2004 Free Software Foundation, Inc.
Written by John Gilmore, on 1985-08-25.
@@ -684,6 +684,8 @@ start_header (struct tar_stat_info *st)
{
xheader_store ("atime", st, NULL);
xheader_store ("ctime", st, NULL);
+ if (st->translator)
+ xheader_store ("GNU.translator", st, NULL);
}
else if (incremental_option)
if (archive_format == OLDGNU_FORMAT)
@@ -1279,11 +1281,17 @@ dump_file0 (struct tar_stat_info *stat,
assign_string (&stat->orig_file_name, p);
assign_string (&stat->file_name, safer_name_suffix (p, false));
- if (deref_stat (dereference_option, p, &stat->stat) != 0)
+#if HAVE_FILE_SET_TRANSLATOR
+ if (!noderef_trans_option || !read_trans (p, &stat->stat, &stat->translator))
+#endif
{
- stat_diag (p);
- return;
+ if (deref_stat (dereference_option, p, &stat->stat) != 0)
+ {
+ stat_diag (p);
+ return;
+ }
}
+
stat->archive_file_size = stat->stat.st_size;
sys_stat_nanoseconds(stat);
original_ctime = stat->stat.st_ctime;
@@ -1351,8 +1359,9 @@ dump_file0 (struct tar_stat_info *stat,
if (file_dumpable_p (stat))
{
+ int tsflags = stat->translator ? O_NOTRANS : 0;
fd = open (stat->orig_file_name,
- O_RDONLY | O_BINARY);
+ O_RDONLY | O_BINARY | tsflags);
if (fd < 0)
{
if (!top_level && errno == ENOENT)
Index: src/extract.c
===================================================================
RCS file: /cvsroot/tar/tar/src/extract.c,v
retrieving revision 1.56
diff -u -p -u -p -r1.56 extract.c
--- src/extract.c 3 Jan 2004 22:25:24 -0000 1.56
+++ src/extract.c 30 Jan 2004 22:59:47 -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.
@@ -747,6 +747,11 @@ extract_archive (void)
? UNKNOWN_PERMSTATUS
: ARCHIVED_PERMSTATUS),
typeflag);
+
+#ifdef HAVE_FILE_SET_TRANSLATOR
+ if (current_stat_info.translator)
+ set_translator (file_name, current_stat_info.translator);
+#endif
break;
case SYMTYPE:
Index: src/incremen.c
===================================================================
RCS file: /cvsroot/tar/tar/src/incremen.c,v
retrieving revision 1.15
diff -u -p -u -p -r1.15 incremen.c
--- src/incremen.c 25 Dec 2003 10:18:48 -0000 1.15
+++ src/incremen.c 30 Jan 2004 22:59:47 -0000
@@ -1,7 +1,7 @@
/* GNU dump extensions to tar.
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
@@ -224,11 +224,15 @@ get_directory_contents (char *path, dev_
{
struct stat stat_data;
- if (deref_stat (dereference_option, name_buffer, &stat_data))
- {
- stat_diag (name_buffer);
- continue;
- }
+#if HAVE_FILE_SET_TRANSLATOR
+ if (!noderef_trans_option
+ || !read_trans (name_buffer, &stat_data, 0))
+#endif
+ if (deref_stat (dereference_option, name_buffer, &stat_data))
+ {
+ stat_diag (name_buffer);
+ continue;
+ }
if (S_ISDIR (stat_data.st_mode))
{
Index: src/list.c
===================================================================
RCS file: /cvsroot/tar/tar/src/list.c,v
retrieving revision 1.64
diff -u -p -u -p -r1.64 list.c
--- src/list.c 25 Dec 2003 10:19:24 -0000 1.64
+++ src/list.c 30 Jan 2004 22:59:48 -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.
@@ -1150,6 +1150,39 @@ print_header (struct tar_stat_info *st,
case FIFOTYPE:
case CONTTYPE:
case GNUTYPE_DUMPDIR:
+ if (st->translator)
+ {
+ char *trans = st->translator;
+ fprintf (stdlis, " => ");
+ while (*trans)
+ {
+ char c;
+
+ if (*trans != '\\')
+ c = *trans;
+ else
+ {
+ trans++;
+ /* XXX: This should not happen. */
+ if (! *trans)
+ break;
+ switch (*trans)
+ {
+ case '\\':
+ c = '\\';
+ break;
+ case 'n':
+ c = ' ';
+ break;
+ case '0':
+ c = ' ';
+ break;
+ }
+ }
+ putc (c, stdlis);
+ trans++;
+ }
+ }
putc ('\n', stdlis);
break;
Index: src/misc.c
===================================================================
RCS file: /cvsroot/tar/tar/src/misc.c,v
retrieving revision 1.16
diff -u -p -u -p -r1.16 misc.c
--- src/misc.c 3 Jan 2004 22:24:35 -0000 1.16
+++ src/misc.c 30 Jan 2004 22:59:49 -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
@@ -872,6 +872,12 @@ void
write_error (char const *name)
{
call_arg_error ("write", name);
+}
+
+void
+translator_error (char const *name)
+{
+ call_arg_error ("translator", name);
}
void
Index: src/names.c
===================================================================
RCS file: /cvsroot/tar/tar/src/names.c,v
retrieving revision 1.37
diff -u -p -u -p -r1.37 names.c
--- src/names.c 25 Dec 2003 10:19:40 -0000 1.37
+++ src/names.c 30 Jan 2004 22:59:50 -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
@@ -831,10 +831,15 @@ collect_and_sort_names (void)
if (name->fake)
continue;
- if (deref_stat (dereference_option, name->name, &statbuf) != 0)
+#if HAVE_FILE_SET_TRANSLATOR
+ if (!noderef_trans_option || !read_trans (name->name, &statbuf, 0))
+#endif
{
- stat_diag (name->name);
- continue;
+ if (deref_stat (dereference_option, name->name, &statbuf) != 0)
+ {
+ stat_diag (name->name);
+ continue;
+ }
}
if (S_ISDIR (statbuf.st_mode))
{
Index: src/system.c
===================================================================
RCS file: /cvsroot/tar/tar/src/system.c,v
retrieving revision 1.5
diff -u -p -u -p -r1.5 system.c
--- src/system.c 25 Dec 2003 10:20:19 -0000 1.5
+++ src/system.c 30 Jan 2004 22:59:53 -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
@@ -21,6 +21,181 @@
#include "common.h"
#include "rmt.h"
#include <signal.h>
+
+#ifdef HAVE_UTIME_H
+# include <utime.h>
+#endif
+
+#ifdef HAVE_FILE_SET_TRANSLATOR
+void
+set_translator (const char *file_name, const char *translator)
+{
+ int transsize;
+ char *transbuf;
+ char *trans;
+ file_t node;
+ int pos = 0;
+ error_t err;
+
+ node = file_name_lookup (file_name, O_NOTRANS, 600);
+ if (node == MACH_PORT_NULL)
+ {
+ open_error (file_name);
+ return;
+ }
+
+ transsize = strlen (translator);
+ transbuf = alloca (transsize + 1);
+
+ trans = (char *) translator;
+ while (*trans)
+ {
+ char c;
+ if (*trans == '\\')
+ {
+ trans++;
+ if (! *trans)
+ break;
+ switch (*trans)
+ {
+ case '\\':
+ c = '\\';
+ break;
+ case 'n':
+ c = '\n';
+ break;
+ case '0':
+ c = '\0';
+ break;
+ default:
+ c = *trans;
+ }
+ }
+ else
+ c = *trans;
+ transbuf[pos++] = c;
+ trans++;
+ }
+
+ err = file_set_translator (node,
+ FS_TRANS_SET | FS_TRANS_EXCL,
+ FS_TRANS_SET | FS_TRANS_EXCL, 0,
+ transbuf, pos, MACH_PORT_NULL,
+ MACH_MSG_TYPE_COPY_SEND);
+ if (err)
+ translator_error (file_name);
+
+#ifdef HAVE_MACH_PORT_DEALLOCATE
+ mach_port_deallocate (mach_task_self (), node);
+#endif
+}
+#endif /* ! HAVE_FILE_SET_TRANSLATOR */
+
+#ifdef HAVE_FILE_GET_TRANSLATOR
+/* Get the stat information of an translator. In case of a
+ translator, return the translator string in a malloced buffer and
+ return the length, else return 0. */
+int
+read_trans (char *const name, struct stat *buf, char **trans)
+{
+ file_t node;
+ error_t err;
+ char tbuf[1024];
+ char *transbuf = tbuf;
+ size_t translen = sizeof (tbuf);
+ int i;
+ char *escbuf;
+ size_t escsize = 0;
+ mode_t oldmode;
+
+ /* Read the translator. */
+ node = file_name_lookup (name, O_NOTRANS, 0);
+ if (node == MACH_PORT_NULL)
+ {
+ open_error (name);
+ return 0;
+ }
+
+ if (io_stat (node, buf) != 0)
+ {
+ mach_port_deallocate (mach_task_self (), node);
+
+ stat_error (name);
+ return 0;
+ }
+
+ err = file_get_translator (node, &transbuf, &translen);
+ mach_port_deallocate (mach_task_self (), node);
+
+ if (err && err != EINVAL)
+ {
+ translator_error (name);
+ return 0;
+ }
+ else if (err == EINVAL)
+ /* No translator was set. */
+ return 0;
+
+ /* Some translator types should not be stored. */
+ if (! strcmp ("/hurd/symlink", transbuf)
+ || ! strcmp ("/hurd/fifo", transbuf))
+ {
+ if (transbuf != tbuf)
+ munmap (transbuf, translen);
+ return 0;
+ }
+ /* Determine the size of the target buffer. */
+ for (i = 0; i < translen; i++)
+ {
+ escsize++;
+ if (transbuf[i] == '\n' || transbuf[i] == '\0'
+ || transbuf[i] == '\\')
+ escsize++;
+ }
+
+ /* Remove the translator mode bits, these will be automatically
+ restored when setting the translator. */
+ buf->st_mode &= ~S_ITRANS;
+
+ /* Remove the bits that indicate a special filetype if it can be
+ described using a translator. */
+ oldmode = buf->st_mode;
+ buf->st_mode &= ~(S_IFBLK | S_IFCHR | S_IFSOCK | S_IFIFO | S_IFLNK);
+ if (oldmode != buf->st_mode && !S_ISDIR (buf->st_mode))
+ buf->st_mode |= S_IFREG;
+
+ if (! trans)
+ return escsize;
+
+ escbuf = xmalloc (escsize + 1);
+
+ escsize = 0;
+ for (i = 0; i < translen; i++)
+ {
+ switch (transbuf[i])
+ {
+ case '\n':
+ escbuf[escsize++] = '\\';
+ escbuf[escsize++] = 'n';
+ break;
+ case '\0':
+ escbuf[escsize++] = '\\';
+ escbuf[escsize++] = '0';
+ break;
+ case '\\':
+ escbuf[escsize++] = '\\';
+ escbuf[escsize++] = '\\';
+ break;
+ default:
+ escbuf[escsize++] = transbuf[i];
+ }
+ }
+ escbuf[escsize++] = '\0';
+ *trans = escbuf;
+
+ return escsize;
+}
+#endif /* ! HAVE_FILE_GET_TRANSLATOR */
void
sys_stat_nanoseconds(struct tar_stat_info *stat)
Index: src/system.h
===================================================================
RCS file: /cvsroot/tar/tar/src/system.h,v
retrieving revision 1.15
diff -u -p -u -p -r1.15 system.h
--- src/system.h 13 Nov 2003 06:23:23 -0000 1.15
+++ src/system.h 30 Jan 2004 22:59:53 -0000
@@ -1,7 +1,7 @@
/* System dependent definitions for GNU tar.
- Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003
- Free Software Foundation, Inc.
+ Copyright (C) 1994, 1995, 1996, 1997, 1998, 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
@@ -478,6 +478,19 @@ char *getenv ();
#include <time.h>
#ifndef time
time_t time ();
+#endif
+
+#ifdef HAVE_HURD_H
+# include <hurd.h>
+#endif
+#ifndef O_NOTRANS
+# define O_NOTRANS 0
+#endif
+#ifdef HAVE_FILE_SET_TRANSLATOR
+void set_translator (const char *file_name, const char *translator);
+#endif
+#ifdef HAVE_FILE_GET_TRANSLATOR
+int read_trans (char *const name, struct stat *buf, char **trans);
#endif
/* Library modules. */
Index: src/tar.c
===================================================================
RCS file: /cvsroot/tar/tar/src/tar.c,v
retrieving revision 1.77
diff -u -p -u -p -r1.77 tar.c
--- src/tar.c 3 Jan 2004 22:26:11 -0000 1.77
+++ src/tar.c 30 Jan 2004 22:59:57 -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.
@@ -283,6 +283,7 @@ static struct option long_options[] =
{"newer-mtime", required_argument, 0, NEWER_MTIME_OPTION},
{"null", no_argument, 0, NULL_OPTION},
{"no-anchored", no_argument, 0, NO_ANCHORED_OPTION},
+ {"no-deref-trans", no_argument, 0, 'a'},
{"no-ignore-case", no_argument, 0, NO_IGNORE_CASE_OPTION},
{"no-overwrite-dir", no_argument, 0, NO_OVERWRITE_DIR_OPTION},
{"no-wildcards", no_argument, 0, NO_WILDCARDS_OPTION},
@@ -473,6 +474,7 @@ Local file selection:\n\
--no-wildcards-match-slash exclude pattern wildcards do not match '/'\n\
-P, --absolute-names don't strip leading `/'s from file names\n\
-h, --dereference dump instead the files symlinks point to\n\
+ -a, --no-deref-trans dump the passive translator\n\
--no-recursion avoid descending automatically in directories\n\
-l, --one-file-system stay in local file system when creating
archive\n\
-K, --starting-file=NAME begin at file NAME in the archive\n\
@@ -534,7 +536,7 @@ or a file name starting with `/' or `.',
/* Parse the options for tar. */
-/* Available option letters are DEHIJQY and aenqy. Some are reserved:
+/* Available option letters are DEHIJQY and enqy. Some are reserved:
e exit immediately with a nonzero exit status if unexpected errors occur
E use extended headers (draft POSIX headers, that is)
@@ -545,7 +547,7 @@ or a file name starting with `/' or `.',
Y per-block gzip compression */
#define OPTION_STRING \
- "-01234567ABC:F:GIK:L:MN:OPRST:UV:WX:Zb:cdf:g:hijklmoprstuvwxyz"
+ "-01234567ABC:F:GIK:L:MN:OPRST:UV:WX:Zab:cdf:g:hijklmoprstuvwxyz"
static void
set_subcommand_option (enum subcommand subcommand)
@@ -673,6 +675,10 @@ decode_options (int argc, char **argv)
input_files++;
break;
+ case 'a':
+ noderef_trans_option = true;
+ break;
+
case 'A':
set_subcommand_option (CAT_SUBCOMMAND);
break;
@@ -821,10 +827,15 @@ decode_options (int argc, char **argv)
|| *optarg == '.')
{
struct stat st;
- if (deref_stat (dereference_option, optarg, &st) != 0)
+#if HAVE_FILE_SET_TRANSLATOR
+ if (!noderef_trans_option || !read_trans (optarg, &st, 0))
+#endif
{
- stat_error (optarg);
- USAGE_ERROR ((0, 0, _("Date file not found")));
+ if (deref_stat (dereference_option, optarg, &st) != 0)
+ {
+ stat_error (optarg);
+ USAGE_ERROR ((0, 0, _("Date file not found")));
+ }
}
newer_mtime_option = st.st_mtime;
}
@@ -837,7 +848,7 @@ decode_options (int argc, char **argv)
else
textual_date_option = optarg;
}
-
+
break;
#endif /* not MSDOS */
@@ -1541,6 +1552,7 @@ tar_stat_destroy (struct tar_stat_info *
free (st->uname);
free (st->gname);
free (st->sparse_map);
+ free (st->translator);
memset (st, 0, sizeof (*st));
}
Index: src/tar.h
===================================================================
RCS file: /cvsroot/tar/tar/src/tar.h,v
retrieving revision 1.23
diff -u -p -u -p -r1.23 tar.h
--- src/tar.h 25 Dec 2003 10:20:32 -0000 1.23
+++ src/tar.h 30 Jan 2004 22:59:57 -0000
@@ -1,7 +1,7 @@
/* GNU tar Archive Format description.
Copyright (C) 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
- 2000, 2001, 2003 Free Software Foundation, Inc.
+ 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
@@ -291,6 +291,9 @@ struct tar_stat_info
not sparse */
size_t sparse_map_size; /* Size of the sparse map */
struct sp_array *sparse_map;
+
+ /* A translator as it is used by the Hurd. */
+ char *translator;
};
union block
Index: src/update.c
===================================================================
RCS file: /cvsroot/tar/tar/src/update.c,v
retrieving revision 1.25
diff -u -p -u -p -r1.25 update.c
--- src/update.c 3 Jan 2004 22:26:30 -0000 1.25
+++ src/update.c 30 Jan 2004 22:59:57 -0000
@@ -1,6 +1,6 @@
/* Update a tar archive.
- Copyright (C) 1988, 1992, 1994, 1996, 1997, 1999, 2000, 2001, 2003
+ 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
@@ -130,12 +130,23 @@ update_archive (void)
{
struct stat s;
enum archive_format unused;
-
+
decode_header (current_header, ¤t_stat_info, &unused, 0);
chdir_do (name->change_dir);
- if (deref_stat (dereference_option,
current_stat_info.file_name, &s) == 0
- && s.st_mtime <= current_stat_info.stat.st_mtime)
+#if HAVE_FILE_SET_TRANSLATOR
+ if (!noderef_trans_option
+ || !read_trans (current_stat_info.file_name, &s, 0))
+#endif
+ {
+ if (deref_stat (dereference_option,
+ current_stat_info.file_name, &s) == 0
+ && s.st_mtime <= current_stat_info.stat.st_mtime)
+ add_avoided_name (current_stat_info.file_name);
+ }
+#if HAVE_FILE_SET_TRANSLATOR
+ else
add_avoided_name (current_stat_info.file_name);
+#endif
}
skip_member ();
break;
Index: src/xheader.c
===================================================================
RCS file: /cvsroot/tar/tar/src/xheader.c,v
retrieving revision 1.12
diff -u -p -u -p -r1.12 xheader.c
--- src/xheader.c 25 Dec 2003 10:20:43 -0000 1.12
+++ src/xheader.c 30 Jan 2004 22:59:57 -0000
@@ -1,6 +1,6 @@
/* POSIX extended and STAR headers.
- 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
@@ -511,6 +511,20 @@ sparse_numbytes_decoder (struct tar_stat
}
}
+
+static void
+translator_coder (struct tar_stat_info const *st, char const *keyword,
+ struct xheader *xhdr, void *data)
+{
+ code_string (st->translator, keyword, xhdr);
+}
+
+static void
+translator_decoder (struct tar_stat_info *st, char const *arg)
+{
+ assign_string (&st->translator, arg);
+}
+
struct xhdr_tab const xhdr_tab[] = {
{ "atime", atime_coder, atime_decoder },
{ "comment", dummy_coder, dummy_decoder },
@@ -530,6 +544,10 @@ struct xhdr_tab const xhdr_tab[] = {
{ "GNU.sparse.numblocks", sparse_numblocks_coder, sparse_numblocks_decoder
},
{ "GNU.sparse.offset", sparse_offset_coder, sparse_offset_decoder },
{ "GNU.sparse.numbytes", sparse_numbytes_coder, sparse_numbytes_decoder },
+
+ /* Extentions for the Hurd. */
+ { "GNU.translator", translator_coder, translator_decoder },
+ /* XXX: missing support for author and the remaining "rwx"-bits. */
#if 0 /* GNU private keywords (not yet implemented) */