From: Bdale Garbee Date: Mon, 11 Aug 2008 20:51:53 +0000 (-0300) Subject: Merge branch 'upstream' X-Git-Tag: debian/20090728-1~21 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=a547751988577b94d9cefd260173ec7e69b8669c;hp=636335dbb356165e1d3e7cf91c416696d8b93910;p=debian%2Fpax Merge branch 'upstream' Conflicts: Makefile ar_io.c cpio.1 options.c pat_rep.c pax.1 pax.c tar.1 tar.c --- diff --git a/.gbp.conf b/.gbp.conf new file mode 100644 index 0000000..dd2ff23 --- /dev/null +++ b/.gbp.conf @@ -0,0 +1,46 @@ +# Configuration file for git-buildpackage and friends + +[DEFAULT] +# the default build command: +#builder = debuild -i\.git/ -I.git +# the default clean command: +#cleaner = debuild clean +# the default branch for upstream sources: +upstream-branch = upstream +# the default branch for the debian patch: +debian-branch = master +# the default tag formats used: +#upstream-tag = upstream/%(version)s +#debian-tag = debian/%(version)s +# use pristine-tar: +pristine-tar = True + +# Options only affecting git-buildpackage +[git-buildpackage] +#upstream-branch = dfsgclean +# uncomment this to automatically GPG sign tags +#sign-tags = True +# keyid to GPG sign tags with +#keyid = 0xdeadbeef +# push to a remote repository after a successful tag: +#posttag = git-push git.example.com +# use this for more svn-buildpackage like behaviour: +export-dir = ../build-area/$PKG/ +#tarball-dir = ../tarballs/ + +# Options only affecting git-import-orig +[git-import-orig] +#upstream-branch = newupstream +#debian-branch = dfsgclean +#filter = .svn + +# Options only affecting git-import-dsc +[git-import-dsc] +#upstream-branch = svn-upstream +#filter = [ 'CVS', '.cvsignore' ] + +# Options only affecting git-dch +[git-dch] +#git-log = --no-merges +#snapshot-number = snapshot + 1 + diff --git a/Makefile b/Makefile index 9ea2e86..72f59b1 100644 --- a/Makefile +++ b/Makefile @@ -14,8 +14,25 @@ PROG= pax SRCS= ar_io.c ar_subs.c buf_subs.c cache.c cpio.c file_subs.c ftree.c\ gen_subs.c getoldopt.c options.c pat_rep.c pax.c sel_subs.c tables.c\ - tar.c tty_subs.c -MAN= pax.1 tar.1 cpio.1 -LINKS= ${BINDIR}/pax ${BINDIR}/tar ${BINDIR}/pax ${BINDIR}/cpio + tar.c tty_subs.c fgetln.c strmode.c +OBJS= $(SRCS:.c=.o) +MAN= pax.1 -.include +CFLAGS= -Wall -O2 -g\ + -DNET2_STAT -D_PATH_DEFTAPE=\"/dev/rmt0\" -DDEBIAN -D_GNU_SOURCE + +prefix=/usr/local + +pax: $(OBJS) + $(CC) $(CFLAGS) $(OBJS) -o $@ $(LIBS) + +clean: + $(RM) *.o + +realclean: clean + $(RM) $(PROG) + +install: + install -d -m 755 $(prefix)/bin $(prefix)/share/man/man1 + install -s -m 755 $(PROG) $(prefix)/bin + install -m 644 $(MAN) $(prefix)/share/man/man1 diff --git a/Makefile.bsd b/Makefile.bsd new file mode 100644 index 0000000..e8affe5 --- /dev/null +++ b/Makefile.bsd @@ -0,0 +1,34 @@ +# $OpenBSD: Makefile,v 1.9 1997/09/21 11:35:28 deraadt Exp $ + +# To install on versions prior to BSD 4.4 the following may have to be +# defined with CFLAGS += +# +# -DNET2_STAT Use NET2 or older stat structure. The version of the +# stat structure is easily determined by looking at the +# basic type of an off_t (often defined in the file: +# /usr/include/sys/types.h). If off_t is a long (and is +# NOT A quad) then you must define NET2_STAT. +# This define is important, as if you do have a quad_t +# off_t and define NET2_STAT, pax will compile but will +# NOT RUN PROPERLY. +# +# -DNET2_FTS Use the older NET2 fts. To identify the version, +# examine the file: /usr/include/fts.h. If FTS_COMFOLLOW +# is not defined then you must define NET2_FTS. +# Pax may not compile if this not (un)defined properly. +# +# -DNET2_REGEX Use the older regexp.h not regex.h. The regex version +# is determined by looking at the value returned by +# regexec() (man 3 regexec). If regexec return a 1 for +# success (and NOT a 0 for success) you have the older +# regex routines and must define NET2_REGEX. +# Pax may not compile if this not (un)defined properly. + +PROG= pax +SRCS= ar_io.c ar_subs.c buf_subs.c cache.c cpio.c file_subs.c ftree.c\ + gen_subs.c getoldopt.c options.c pat_rep.c pax.c sel_subs.c tables.c\ + tar.c tty_subs.c +MAN= pax.1 tar.1 cpio.1 +LINKS= ${BINDIR}/pax ${BINDIR}/tar ${BINDIR}/pax ${BINDIR}/cpio + +.include diff --git a/ar_io.c b/ar_io.c index 2a833bb..6679547 100644 --- a/ar_io.c +++ b/ar_io.c @@ -1248,8 +1248,9 @@ ar_next(void) /* * ar_start_gzip() - * starts the gzip compression/decompression process as a child, using magic - * to keep the fd the same in the calling function (parent). + * starts the compress, gzip or bzip2 compression/decompression process + * as a child, using magic to keep the fd the same in the calling function + * (parent). */ void ar_start_gzip(int fd, const char *gzip_program, int wr) diff --git a/ar_subs.c b/ar_subs.c index 73aefda..382462c 100644 --- a/ar_subs.c +++ b/ar_subs.c @@ -44,6 +44,7 @@ static const char rcsid[] = "$OpenBSD: ar_subs.c,v 1.32 2008/05/06 06:54:28 henn #include #include +#include #include #include #include diff --git a/cache.c b/cache.c index 44eda1f..4f80b7c 100644 --- a/cache.c +++ b/cache.c @@ -200,7 +200,11 @@ name_uid(uid_t uid, int frc) * No entry for this uid, we will add it */ if (!pwopn) { +#ifdef DEBIAN + setpwent(); +#else setpassent(1); +#endif ++pwopn; } if (ptr == NULL) @@ -266,7 +270,11 @@ name_gid(gid_t gid, int frc) * No entry for this gid, we will add it */ if (!gropn) { +#ifdef DEBIAN + setgrent(); +#else setgroupent(1); +#endif ++gropn; } if (ptr == NULL) @@ -333,7 +341,11 @@ uid_name(char *name, uid_t *uid) } if (!pwopn) { +#ifdef DEBIAN + setpwent(); +#else setpassent(1); +#endif ++pwopn; } @@ -396,7 +408,11 @@ gid_name(char *name, gid_t *gid) } if (!gropn) { +#ifdef DEBIAN + setgrent(); +#else setgroupent(1); +#endif ++gropn; } if (ptr == NULL) diff --git a/cpio.c b/cpio.c index 4a97960..2019e6d 100644 --- a/cpio.c +++ b/cpio.c @@ -43,6 +43,7 @@ static const char rcsid[] = "$OpenBSD: cpio.c,v 1.18 2008/01/01 16:22:44 tobias #endif /* not lint */ #include +#include #include #include #include diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..71abf20 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,116 @@ +pax (1:1.5-16) unstable; urgency=low + + * patch for -s irregularities from Stephane Chazelas, closes: #451361 + * clean up various lintian warnings + + -- Bdale Garbee Tue, 11 Dec 2007 23:13:03 -0700 + +pax (1:1.5-15) unstable; urgency=low + + * update priority in control file to match override + * patch to fix archiving of 100 byte pathnames, closes: #191127 + * patch to fix full prefix field in ustar format, closes: #201768 + + -- Bdale Garbee Sun, 30 May 2004 00:48:29 -0300 + +pax (1:1.5-14) unstable; urgency=low + + * merge bzip2 support patch from Stephen Williams, closes: #178995 + + -- Bdale Garbee Tue, 18 Feb 2003 01:20:50 -0700 + +pax (1:1.5-13) unstable; urgency=low + + * apply patch from Anthony Towns to fix minor POSIX incompliance observed + during LSB certification work, closes: #139943 + + -- Bdale Garbee Thu, 15 Aug 2002 14:56:57 -0600 + +pax (1:1.5-12) unstable; urgency=low + + * apply patch from Adam Heath for off-by-one error in tar.c when a file + has a long name, and the prefix is being filled for a posix tar header. + The last byte in the prefix wasn't being set to \0, closes: #128980 + * minor cosmetic changes to debian/ files + + -- Bdale Garbee Mon, 14 Jan 2002 13:58:46 -0700 + +pax (1:1.5-11) unstable; urgency=low + + * change man page to fix references to POSIX standard, closes: #97839 + + -- Bdale Garbee Tue, 1 Jan 2002 09:43:00 -0700 + +pax (1:1.5-10) unstable; urgency=low + + * undo #if DEBIAN clause in file_subs.c that forced used of chown instead + of lchown, since it's not necessary with modern kernels and causes other + problems, closes: #110253 + * get rid of suidregister stuff, update standards version, etc + + -- Bdale Garbee Sun, 30 Dec 2001 20:42:33 -0700 + +pax (1:1.5-9) unstable; urgency=low + + * trim extended description since paxutils is still not out, closes: #79035 + * fix sys/time.h + time.h inclusion problems, closes: #100790, #105191 + + -- Bdale Garbee Sun, 22 Jul 2001 23:20:46 -0600 + +pax (1:1.5-8) stable unstable; urgency=low + + * oops. rebuild with appropriate libraries for potato, closes: #75012 + + -- Bdale Garbee Fri, 20 Oct 2000 12:16:17 -0600 + +pax (1:1.5-7) stable unstable; urgency=low + + * apply patch from Geoff Clare that fixes problem with + "full" name fields in ustar format. Target stable since this can cause + file loss under some circumstances. Closes: #71644 + + -- Bdale Garbee Sun, 15 Oct 2000 23:25:49 -0600 + +pax (1:1.5-6) unstable; urgency=low + + * update to latest standards, add Build-Depends, get FHS'ed + + -- Bdale Garbee Fri, 7 Jan 2000 20:39:46 -0700 + +pax (1:1.5-5) unstable; urgency=low + + * patches from Roman Hodek to include for glibc2.1, + closes 41656. + + -- Bdale Garbee Mon, 2 Aug 1999 01:51:03 -0600 + +pax (1:1.5-4) unstable; urgency=low + + * hack to fix compile problems with glibc-2.1, closes 34668 + + -- Bdale Garbee Mon, 24 May 1999 23:45:16 -0600 + +pax (1:1.5-3) unstable; urgency=low + + * new maintainer + * freshen to pick up changes in latest OpenBSD pax source, and to get back + to an upstream orig and Debian diffs configuration + * rewrite rules file to use debhelper + * update long description to indicate that this package will eventually + be obsoleted by paxutils, a pre-release of which I'm working with now + + -- Bdale Garbee Wed, 2 Dec 1998 21:21:57 -0700 + +pax (1:1.5-2) unstable; urgency=low + + * changed Maintainer address to official and working Debian address + + * renamed md5sum to md5sums. + + -- David Frey Fri, 13 Feb 1998 23:15:39 +0100 + +pax (1:1.5-1) unstable; urgency=low + + * Initial Release of the OpenBSD's pax program from Keith Muller + + -- David Frey Wed, 10 Dec 1997 12:57:48 +0100 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..3cc53b2 --- /dev/null +++ b/debian/control @@ -0,0 +1,20 @@ +Source: pax +Section: utils +Priority: optional +Maintainer: Bdale Garbee +Build-Depends: debhelper +Standards-Version: 3.7.3 + +Package: pax +Architecture: any +Depends: ${shlibs:Depends} +Description: Portable Archive Interchange + Pax is an archiving utility that reads and writes tar and cpio formats, + both the traditional ones and the extended formats specified in IEEE 1003.1. + It handles multi-volume archives and automatically determines the format + of an archive while reading it. Three user interfaces are + supported: tar, cpio, and pax. The pax interface was designed by IEEE + 1003.2 as a compromise in the chronic controversy over which of tar or + cpio is best. + . + This is the free OpenBSD's version written by Keith Muller. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..a31eaa8 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,87 @@ +This package was debianized by David Frey on +Wed Dec 10 19:01:25 CET 1997. + +Pax was downloaded from ftp://ftp.openbsd.org/pub/OpenBSD/src/bin/pax/ + +Copyright: + +the pax program: + * Copyright (c) 1992 Keith Muller. + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Keith Muller of the University of California, San Diego. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + +strmode.c was copied from FreeBSD 2.1.5: + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + +fgetln.c was donated by Andrew Dougherty and has the following +copyright notice (the original BSD fgetln is not portable): + + This fgetline implementation was written by Andrew Dougherty + . I hearby place it in the public domain. + As a courtesy, please leave my name attached to the source. + + This code comes with no warranty whatsoever, and I take no + responsibility for any consequences of its use. + +The rest (adding the packaging information, rewriting the Makefile etc) +was done by me, David Frey and is in the public domain. diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..7b91107 --- /dev/null +++ b/debian/rules @@ -0,0 +1,61 @@ +#!/usr/bin/make -f + +# comment this to turn off verbose mode. +export DH_VERBOSE=1 + +build: build-stamp +build-stamp: + dh_testdir + + $(MAKE) + + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp install-stamp + + [ ! -f Makefile ] || $(MAKE) realclean + + dh_clean + +install: install-stamp +install-stamp: build-stamp + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + $(MAKE) prefix=`pwd`/debian/pax/usr install + + touch install-stamp + +# Build architecture-independent files here. +binary-indep: build install + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installdocs + dh_installexamples + dh_installmenu + dh_installcron + dh_installmanpages cpio.1 tar.1 + dh_installchangelogs + dh_link + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +source diff: + @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install diff --git a/fgetln.c b/fgetln.c new file mode 100644 index 0000000..03afbb0 --- /dev/null +++ b/fgetln.c @@ -0,0 +1,134 @@ +/* fgetline: Read one line of input and return a pointer to + that line. Necessary space is obtained from malloc. + (char *) NULL is returned on EOF. + + Andy Dougherty doughera@lafcol.lafayette.edu + Dept. of Physics + Lafayette College, Easton PA 18042 + + Successive calls to fgetline() overwrite the original buffer. + If you want to preserve the data, you must do something like + the following (the +1's are for '\0' characters): + + tmp = fgetline(fp); + ntmp = Ealloc(strlen(tmp)+1, sizeof(char)); + strncpy(ntmp, tmp, strlen(tmp)+1); + + A line is defined as all characters up to (and including) the next + newline character or end of file. + The string is terminated by a NULL character. + + * Version 1.1 A. Dougherty 2/7/94 + Don't call realloc() just to save a few bytes. + Check return value from realloc(). (NULL is allowed under POSIX, + though I've never hit it.) + + * Version 1.0 A. Dougherty 2/27/91 + + This fgetline implementation was written by Andrew Dougherty + . I hearby place it in the public domain. + As a courtesy, please leave my name attached to the source. + + This code comes with no warranty whatsoever, and I take no + responsibility for any consequences of its use. +*/ + +/* Algorithm: A local static buffer "buf" is maintained. The current + length (space available) is in the static variable "avail". + Read in characters into this buffer. If need more space, call + malloc(). + + Aside: We have computed strlen(buf) in this function. It + seems a shame to throw it away. +*/ + +#include +#include +#include + +#define LINELEN 128 /* A decent guess that should only rarely be + overwritten. + */ +#define OK_TO_WASTE 512 /* Don't bother trying to realloc() back to + a smaller buffer if you'd only end up + wasting OK_TO_WASTE bytes. + */ + +void *Emalloc(size_t len) /* David */ +{ + char *p; + + p=malloc(len); + if (p == NULL) { + perror("out of memory (Emalloc)"); + exit(2); + + } + return p; +} + +void *Erealloc(char *p, size_t len) /* David */ +{ + p=realloc(p, len); + if (p == NULL) { + perror("out of memory (Erealloc)"); + exit(2); + + } + return p; +} + +char * +fgetln(FILE *fp, size_t *length) + { + static char *buf = NULL; + static size_t avail = 0; + int c; + char *p; /* Temporary used for reducing length. */ + int len; + + if (avail == 0) + { + buf = (char *) Emalloc(LINELEN * sizeof(char)); + avail = LINELEN; + } + + len = 0; /* Current length */ + + while ((c=getc(fp)) != EOF) + { + if (len >= avail) /* Need to ask for space */ + { + avail += LINELEN; /* Maybe avail *= 2 would be better */ + buf = (char *) Erealloc((void *) buf, avail * sizeof(char)); + } + buf[len] = c; + len++; + if (c == '\n') + break; + } + + if (c == EOF && len == 0) + return (char *) NULL; + + /* Add terminating '\0' character */ + if (len >= avail) /* Need 1 more space */ + buf = (char *) Erealloc((void *) buf, (len+1) * sizeof(char)); + buf[len] = '\0'; + + /* Should we bother to try reclaiming memory? (Otherwise, this + function will hold onto enough memory to hold the longest + line for the entire duration of the program.) + */ + if (avail - len > OK_TO_WASTE) + { + p = (char *) Erealloc((void *) buf, (len+1) * sizeof(char)); + if (p != NULL) + { + buf = p; + avail = len + 1; + } + } + *length=len-1; + return buf; + } diff --git a/fgetln.h b/fgetln.h new file mode 100644 index 0000000..1598757 --- /dev/null +++ b/fgetln.h @@ -0,0 +1,17 @@ +/* fgetline: Read one line of input and return a pointer to + that line. Necessary space is obtained from malloc. + (char *) NULL is returned on EOF. + + Andy Dougherty doughera@lafcol.lafayette.edu + Dept. of Physics + Lafayette College, Easton PA 18042 + + This fgetline implementation was written by Andrew Dougherty + . I hearby place it in the public domain. + As a courtesy, please leave my name attached to the source. + + This code comes with no warranty whatsoever, and I take no + responsibility for any consequences of its use. +*/ + +char *fgetln(FILE *fp, size_t *length); diff --git a/gen_subs.c b/gen_subs.c index 7e66f62..07c9e96 100644 --- a/gen_subs.c +++ b/gen_subs.c @@ -43,11 +43,13 @@ static const char rcsid[] = "$OpenBSD: gen_subs.c,v 1.19 2007/04/04 21:55:10 mil #endif /* not lint */ #include +#include #include +#include #include #include #include -#include +#include "tzfile.h" #include #include #include @@ -56,6 +58,8 @@ static const char rcsid[] = "$OpenBSD: gen_subs.c,v 1.19 2007/04/04 21:55:10 mil #include "pax.h" #include "extern.h" +#include "strmode.h" + /* * a collection of general purpose subroutines used by pax */ diff --git a/options.c b/options.c index fa19889..4cc16d7 100644 --- a/options.c +++ b/options.c @@ -60,6 +60,8 @@ static const char rcsid[] = "$OpenBSD: options.c,v 1.70 2008/06/11 00:49:08 pval #include "tar.h" #include "extern.h" +#include "fgetln.h" /* added, David */ + /* * Routines which handle command line options */ diff --git a/sel_subs.c b/sel_subs.c index 55d3a00..b12c3ed 100644 --- a/sel_subs.c +++ b/sel_subs.c @@ -44,6 +44,7 @@ static const char rcsid[] = "$OpenBSD: sel_subs.c,v 1.18 2004/04/16 22:50:23 der #include #include +#include #include #include #include diff --git a/strmode.c b/strmode.c new file mode 100644 index 0000000..651b263 --- /dev/null +++ b/strmode.c @@ -0,0 +1,147 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)strmode.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include + +void +strmode(mode, p) + register mode_t mode; + register char *p; +{ + /* print type */ + switch (mode & S_IFMT) { + case S_IFDIR: /* directory */ + *p++ = 'd'; + break; + case S_IFCHR: /* character special */ + *p++ = 'c'; + break; + case S_IFBLK: /* block special */ + *p++ = 'b'; + break; + case S_IFREG: /* regular */ + *p++ = '-'; + break; + case S_IFLNK: /* symbolic link */ + *p++ = 'l'; + break; + case S_IFSOCK: /* socket */ + *p++ = 's'; + break; +#ifdef S_IFIFO + case S_IFIFO: /* fifo */ + *p++ = 'p'; + break; +#endif + default: /* unknown */ + *p++ = '?'; + break; + } + /* usr */ + if (mode & S_IRUSR) + *p++ = 'r'; + else + *p++ = '-'; + if (mode & S_IWUSR) + *p++ = 'w'; + else + *p++ = '-'; + switch (mode & (S_IXUSR | S_ISUID)) { + case 0: + *p++ = '-'; + break; + case S_IXUSR: + *p++ = 'x'; + break; + case S_ISUID: + *p++ = 'S'; + break; + case S_IXUSR | S_ISUID: + *p++ = 's'; + break; + } + /* group */ + if (mode & S_IRGRP) + *p++ = 'r'; + else + *p++ = '-'; + if (mode & S_IWGRP) + *p++ = 'w'; + else + *p++ = '-'; + switch (mode & (S_IXGRP | S_ISGID)) { + case 0: + *p++ = '-'; + break; + case S_IXGRP: + *p++ = 'x'; + break; + case S_ISGID: + *p++ = 'S'; + break; + case S_IXGRP | S_ISGID: + *p++ = 's'; + break; + } + /* other */ + if (mode & S_IROTH) + *p++ = 'r'; + else + *p++ = '-'; + if (mode & S_IWOTH) + *p++ = 'w'; + else + *p++ = '-'; + switch (mode & (S_IXOTH | S_ISVTX)) { + case 0: + *p++ = '-'; + break; + case S_IXOTH: + *p++ = 'x'; + break; + case S_ISVTX: + *p++ = 'T'; + break; + case S_IXOTH | S_ISVTX: + *p++ = 't'; + break; + } + *p++ = ' '; /* will be a '+' if ACL's implemented */ + *p = '\0'; +} diff --git a/strmode.h b/strmode.h new file mode 100644 index 0000000..722832e --- /dev/null +++ b/strmode.h @@ -0,0 +1,34 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +void strmode(mode_t mode, char *p); diff --git a/tar.c b/tar.c index 6a0b3b3..9763934 100644 --- a/tar.c +++ b/tar.c @@ -43,6 +43,7 @@ static const char rcsid[] = "$OpenBSD: tar.c,v 1.41 2006/03/04 20:24:55 otto Exp #endif /* not lint */ #include +#include #include #include #include @@ -763,6 +764,12 @@ ustar_rd(ARCHD *arcn, char *buf) /* * see if the filename is split into two parts. if, so joint the parts. * we copy the prefix first and add a / between the prefix and name. + * + * the length passed to l_strncpy must be the length of the field + * being copied *from*, since these fields are NOT null terminated + * when full. the destination buffer is plenty big enough to hold + * the longest supported ustar path length, so there's no need + * to check against that. */ dest = arcn->name; if (*(hd->prefix) != '\0') { diff --git a/types.h b/types.h new file mode 100644 index 0000000..a38bb39 --- /dev/null +++ b/types.h @@ -0,0 +1,169 @@ +/*- + * Copyright (c) 1982, 1986, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)types.h 8.4 (Berkeley) 1/21/94 + * $Id: types.h,v 1.1 2001-07-23 05:20:01 bdale Exp $ + */ + +#ifndef _SYS_TYPES_H_ +#define _SYS_TYPES_H_ + +#include + +/* Machine type dependent parameters. */ +#include + +#ifndef _POSIX_SOURCE +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +typedef unsigned long u_long; +typedef unsigned short ushort; /* Sys V compatibility */ +typedef unsigned int uint; /* Sys V compatibility */ +#endif + +typedef unsigned long long u_quad_t; /* quads */ +typedef long long quad_t; +typedef quad_t * qaddr_t; + +typedef char * caddr_t; /* core address */ +typedef long daddr_t; /* disk address */ +typedef unsigned long dev_t; /* device number */ +typedef unsigned long fixpt_t; /* fixed point number */ +typedef unsigned long gid_t; /* group id */ +typedef unsigned long ino_t; /* inode number */ +typedef unsigned short mode_t; /* permissions */ +typedef unsigned short nlink_t; /* link count */ +typedef quad_t off_t; /* file offset */ +typedef long pid_t; /* process id */ +typedef long segsz_t; /* segment size */ +typedef long swblk_t; /* swap offset */ +typedef unsigned long uid_t; /* user id */ + +/* + * This belongs in unistd.h, but is placed here to ensure that programs + * casting the second parameter of lseek to off_t will get the correct + * version of lseek. + */ +#ifndef KERNEL +__BEGIN_DECLS +off_t lseek __P((int, off_t, int)); +__END_DECLS +#endif + +#ifndef _POSIX_SOURCE +/* + * minor() gives a cookie instead of an index since we don't want to + * change the meanings of bits 0-15 or waste time and space shifting + * bits 16-31 for devices that don't use them. + */ +#define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */ +#define minor(x) ((int)((x)&0xffff00ff)) /* minor number */ +#define makedev(x,y) ((dev_t)(((x)<<8) | (y))) /* create dev_t */ +#endif + +#include +#include + +#ifdef _BSD_CLOCK_T_ +typedef _BSD_CLOCK_T_ clock_t; +#undef _BSD_CLOCK_T_ +#endif + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +#ifdef _BSD_SSIZE_T_ +typedef _BSD_SSIZE_T_ ssize_t; +#undef _BSD_SSIZE_T_ +#endif + +#ifdef _BSD_TIME_T_ +typedef _BSD_TIME_T_ time_t; +#undef _BSD_TIME_T_ +#endif + +#ifndef _POSIX_SOURCE +#define NBBY 8 /* number of bits in a byte */ + +/* + * Select uses bit masks of file descriptors in longs. These macros + * manipulate such bit fields (the filesystem macros use chars). + * FD_SETSIZE may be defined by the user, but the default here should + * be enough for most uses. + */ +#ifndef FD_SETSIZE +#define FD_SETSIZE 256 +#endif + +typedef long fd_mask; +#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ + +#ifndef howmany +#define howmany(x, y) (((x)+((y)-1))/(y)) +#endif + +typedef struct fd_set { + fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; +} fd_set; + +#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) +#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) +#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) +#define FD_COPY(f, t) bcopy(f, t, sizeof(*(f))) +#define FD_ZERO(p) bzero(p, sizeof(*(p))) + +#if defined(__STDC__) && defined(KERNEL) +/* + * Forward structure declarations for function prototypes. We include the + * common structures that cross subsystem boundaries here; others are mostly + * used in the same place that the structure is defined. + */ +struct proc; +struct pgrp; +struct ucred; +struct rusage; +struct file; +struct buf; +struct tty; +struct uio; +#endif + +#endif /* !_POSIX_SOURCE */ +#endif /* !_SYS_TYPES_H_ */ diff --git a/tzfile.h b/tzfile.h new file mode 100644 index 0000000..a5dbe83 --- /dev/null +++ b/tzfile.h @@ -0,0 +1,158 @@ +/* + * Ported to Linux's Second Extended File System as part of the + * dump and restore backup suit + * Remy Card , 1994, 1995 + * + */ + +/* + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Arthur David Olson of the National Cancer Institute. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)tzfile.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _TZFILE_H_ +#define _TZFILE_H_ + +/* + * Information about time zone files. + */ + /* Time zone object file directory */ +#define TZDIR "/usr/share/zoneinfo" +#define TZDEFAULT "/etc/localtime" +#define TZDEFRULES "posixrules" + +/* +** Each file begins with. . . +*/ + +struct tzhead { + char tzh_reserved[24]; /* reserved for future use */ + char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ + char tzh_leapcnt[4]; /* coded number of leap seconds */ + char tzh_timecnt[4]; /* coded number of transition times */ + char tzh_typecnt[4]; /* coded number of local time types */ + char tzh_charcnt[4]; /* coded number of abbr. chars */ +}; + +/* +** . . .followed by. . . +** +** tzh_timecnt (char [4])s coded transition times a la time(2) +** tzh_timecnt (unsigned char)s types of local time starting at above +** tzh_typecnt repetitions of +** one (char [4]) coded GMT offset in seconds +** one (unsigned char) used to set tm_isdst +** one (unsigned char) that's an abbreviation list index +** tzh_charcnt (char)s '\0'-terminated zone abbreviations +** tzh_leapcnt repetitions of +** one (char [4]) coded leap second transition times +** one (char [4]) total correction after above +** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition +** time is standard time, if FALSE, +** transition time is wall clock time +** if absent, transition times are +** assumed to be wall clock time +*/ + +/* +** In the current implementation, "tzset()" refuses to deal with files that +** exceed any of the limits below. +*/ + +/* +** The TZ_MAX_TIMES value below is enough to handle a bit more than a +** year's worth of solar time (corrected daily to the nearest second) or +** 138 years of Pacific Presidential Election time +** (where there are three time zone transitions every fourth year). +*/ +#define TZ_MAX_TIMES 370 + +#define NOSOLAR /* 4BSD doesn't currently handle solar time */ + +#ifndef NOSOLAR +#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ +#else +#define TZ_MAX_TYPES 10 /* Maximum number of local time types */ +#endif + +#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ + +#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ + +#define SECSPERMIN 60 +#define MINSPERHOUR 60 +#define HOURSPERDAY 24 +#define DAYSPERWEEK 7 +#define DAYSPERNYEAR 365 +#define DAYSPERLYEAR 366 +#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) +#define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY) +#define MONSPERYEAR 12 + +#define TM_SUNDAY 0 +#define TM_MONDAY 1 +#define TM_TUESDAY 2 +#define TM_WEDNESDAY 3 +#define TM_THURSDAY 4 +#define TM_FRIDAY 5 +#define TM_SATURDAY 6 + +#define TM_JANUARY 0 +#define TM_FEBRUARY 1 +#define TM_MARCH 2 +#define TM_APRIL 3 +#define TM_MAY 4 +#define TM_JUNE 5 +#define TM_JULY 6 +#define TM_AUGUST 7 +#define TM_SEPTEMBER 8 +#define TM_OCTOBER 9 +#define TM_NOVEMBER 10 +#define TM_DECEMBER 11 + +#define TM_YEAR_BASE 1900 + +#define EPOCH_YEAR 1970 +#define EPOCH_WDAY TM_THURSDAY + +/* +** Accurate only for the past couple of centuries; +** that will probably do. +*/ + +#define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0) + +#endif /* !_TZFILE_H_ */