this off like GNU tar.
-/* $OpenBSD: extern.h,v 1.11 1997/03/02 09:46:43 tholo Exp $ */
+/* $OpenBSD: extern.h,v 1.12 1997/04/05 22:36:12 millert Exp $ */
/* $NetBSD: extern.h,v 1.5 1996/03/26 23:54:16 mrg Exp $ */
/*-
extern int nodirs;
extern int pmode;
extern int pids;
+extern int rmleadslash;
extern int exit_val;
extern int docrc;
extern char *dirptr;
-/* $OpenBSD: options.c,v 1.19 1997/04/04 20:54:50 millert Exp $ */
+/* $OpenBSD: options.c,v 1.20 1997/04/05 22:36:14 millert Exp $ */
/* $NetBSD: options.c,v 1.6 1996/03/26 23:54:18 mrg Exp $ */
/*-
#if 0
static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 4/18/94";
#else
-static char rcsid[] = "$OpenBSD: options.c,v 1.19 1997/04/04 20:54:50 millert Exp $";
+static char rcsid[] = "$OpenBSD: options.c,v 1.20 1997/04/05 22:36:14 millert Exp $";
#endif
#endif /* not lint */
register int c;
int fstdin = 0;
+ /*
+ * Set default values.
+ */
+ rmleadslash = 1;
+
/*
* process option flags
*/
while ((c = getoldopt(argc, argv,
- "b:cef:hmopruts:vwxzBC:HLPXZ014578"))
+ "b:cef:hmopruts:vwxzBC:HLPSXZ014578"))
!= EOF) {
switch(c) {
case 'b':
*/
Lflag = 0;
break;
+ case 'S':
+ /*
+ * do not remove leading '/' from pathnames
+ */
+ rmleadslash = 0;
+ break;
case 'X':
/*
* do not pass over mount points in the file system
-/* $OpenBSD: pat_rep.c,v 1.7 1997/03/30 08:28:10 millert Exp $ */
+/* $OpenBSD: pat_rep.c,v 1.8 1997/04/05 22:36:15 millert Exp $ */
/* $NetBSD: pat_rep.c,v 1.4 1995/03/21 09:07:33 cgd Exp $ */
/*-
#if 0
static char sccsid[] = "@(#)pat_rep.c 8.2 (Berkeley) 4/18/94";
#else
-static char rcsid[] = "$OpenBSD: pat_rep.c,v 1.7 1997/03/30 08:28:10 millert Exp $";
+static char rcsid[] = "$OpenBSD: pat_rep.c,v 1.8 1997/04/05 22:36:15 millert Exp $";
#endif
#endif /* not lint */
{
register int res = 0;
+ /*
+ * Strip off leading '/' if appropriate.
+ * Currently, this option is only set for the tar format.
+ */
+ if (rmleadslash && arcn->name[0] == '/') {
+ if (arcn->name[1] == '\0') {
+ arcn->name[0] = '.';
+ } else {
+ (void)memmove(arcn->name, &arcn->name[1],
+ strlen(arcn->name));
+ arcn->nlen--;
+ }
+ if (rmleadslash < 2) {
+ rmleadslash = 2;
+ paxwarn(0, "Removing leading / from absolute path names in the archive");
+ }
+ }
+ if (rmleadslash && arcn->ln_name[0] == '/' &&
+ (arcn->type == PAX_HLK || arcn->type == PAX_HRG)) {
+ if (arcn->ln_name[1] == '\0') {
+ arcn->ln_name[0] = '.';
+ } else {
+ (void)memmove(arcn->ln_name, &arcn->ln_name[1],
+ strlen(arcn->ln_name));
+ arcn->ln_nlen--;
+ }
+ if (rmleadslash < 2) {
+ rmleadslash = 2;
+ paxwarn(0, "Removing leading / from absolute path names in the archive");
+ }
+ }
+
/*
* IMPORTANT: We have a problem. what do we do with symlinks?
* Modifying a hard link name makes sense, as we know the file it
-/* $OpenBSD: pax.c,v 1.6 1997/03/02 09:46:49 tholo Exp $ */
+/* $OpenBSD: pax.c,v 1.7 1997/04/05 22:36:17 millert Exp $ */
/* $NetBSD: pax.c,v 1.5 1996/03/26 23:54:20 mrg Exp $ */
/*-
#if 0
static char sccsid[] = "@(#)pax.c 8.2 (Berkeley) 4/18/94";
#else
-static char rcsid[] = "$OpenBSD: pax.c,v 1.6 1997/03/02 09:46:49 tholo Exp $";
+static char rcsid[] = "$OpenBSD: pax.c,v 1.7 1997/04/05 22:36:17 millert Exp $";
#endif
#endif /* not lint */
int nodirs; /* do not create directories as needed */
int pmode; /* preserve file mode bits */
int pids; /* preserve file uid/gid */
+int rmleadslash = 0; /* remove leading '/' from pathnames */
int exit_val; /* exit value */
int docrc; /* check/create file crc */
char *dirptr; /* destination dir in a copy */
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $OpenBSD: tar.1,v 1.7 1997/04/04 20:54:52 millert Exp $
+.\" $OpenBSD: tar.1,v 1.8 1997/04/05 22:36:18 millert Exp $
.\"
.Dd June 11, 1996
.Dt TAR 1
.Nm tar
.Nd tape archiver
.Sh SYNOPSIS
-.Nm tar
-.No [-]{crtux}[befhmopvwzHLPXZ014578]
+.Nm
+.No [-]{crtux}[befhmopvwzHLPSXZ014578]
.Op Ar archive
.Op Ar blocksize
.\" XXX how to do this right?
.Op Ar file2...
.Sh DESCRIPTION
The
-.Nm tar
+.Nm
command creates, adds files to, or extracts files from an
archive file in \*Qtar\*U format. A tar archive is often
stored on a magnetic tape, but can be a floppy or a regular
.Bl -tag -width Ar
.It Fl b Ar "blocking factor"
Set blocking factor to use for the archive,
-.Nm tar
+.Nm
uses 512 byte blocks. The default is 20, the maximum is 63.
.It Fl e
Stop after first error.
Do not preserve modification time.
.It Fl o
Don't write directory information that the older (V7) style
-.Nm tar
+.Nm
is enable to decode.
.It Fl p
Preserve user id, group id, file mode, access and modification
Verbose operation mode.
.It Fl w
Interactively rename files. This option causes
-.Nm tar
+.Nm
to prompt the user for the filename to use when storing or
extracting files in an archive.
.It Fl z
Follow all symlinks.
.It Fl P
Do not follow any symlinks.
+.It Fl S
+Do not strip leading slashes (``/'') from pathnames.
+The default is to strip leading slashes.
.It Fl X
Do not cross mount points in the file system.
.It Fl Z
.Sh AUTHOR
Keith Muller at the University of California, San Diego
.Sh ERRORS
-.Nm tar
+.Nm
will exit with one of the following values:
.Bl -tag -width 2n
.It 0
.El
.Pp
Whenever
-.Nm tar
+.Nm
cannot create a file or a link when extracting an archive or cannot
find a file while writing an archive, or cannot preserve the user
ID, group ID, file mode or access and modification times when the
options is specified, a diagnostic message is written to standard
error and a non-zero exit value will be returned, but processing
will continue. In the case where
-.Nm tar
+.Nm
cannot create a link to a file,
-.Nm tar
+.Nm
will not create a second copy of the file.
.Pp
If the extraction of a file from an archive is prematurely terminated
by a signal or error,
-.Nm tar
+.Nm
may have only partially extracted the file the user wanted.
Additionally, the file modes of extracted files and directories may
have incorrect file bits, and the modification and access times may
.Pp
If the creation of an archive is prematurely terminated by a signal
or error,
-.Nm tar
+.Nm
may have only partially created the archive which may violate the
specific archive format specification.
-/* $OpenBSD: tar.c,v 1.8 1997/04/02 00:31:58 millert Exp $ */
+/* $OpenBSD: tar.c,v 1.9 1997/04/05 22:36:19 millert Exp $ */
/* $NetBSD: tar.c,v 1.5 1995/03/21 09:07:49 cgd Exp $ */
/*-
#if 0
static char sccsid[] = "@(#)tar.c 8.2 (Berkeley) 4/18/94";
#else
-static char rcsid[] = "$OpenBSD: tar.c,v 1.8 1997/04/02 00:31:58 millert Exp $";
+static char rcsid[] = "$OpenBSD: tar.c,v 1.9 1997/04/05 22:36:19 millert Exp $";
#endif
#endif /* not lint */
*/
hd = (HD_TAR *)hdblk;
zf_strncpy(hd->name, arcn->name, sizeof(hd->name) - 1);
- arcn->name[sizeof(hd->name) - 1] = '\0';
+ hd->name[sizeof(hd->name) - 1] = '\0';
arcn->pad = 0;
if (arcn->type == PAX_DIR) {