From: Bdale Garbee Date: Sun, 30 May 2004 03:48:29 +0000 (-0300) Subject: Imported Debian patch 1.5-15 X-Git-Tag: debian/1.5-15^0 X-Git-Url: https://git.gag.com/?p=debian%2Fpax;a=commitdiff_plain;h=537d34cbb40c3babaa12ef59cfbb292416ff5c30 Imported Debian patch 1.5-15 --- diff --git a/Makefile b/Makefile index e8affe5..8a94849 100644 --- a/Makefile +++ b/Makefile @@ -1,34 +1,25 @@ -# $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 + tar.c tty_subs.c fgetln.c strmode.c +OBJS= $(SRCS:.c=.o) +MAN= pax.1 + +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) -.include +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 6afe997..4cc4a97 100644 --- a/ar_io.c +++ b/ar_io.c @@ -146,7 +146,7 @@ ar_open(name) break; case APPND: if (zflag) - err(1, "can not gzip while appending"); + err(1, "can not filter through compressor while appending"); if (name == NULL) { arfd = STDOUT_FILENO; arcname = STDO; @@ -1305,8 +1305,9 @@ ar_next() /* * 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 #ifdef __STDC__ diff --git a/ar_subs.c b/ar_subs.c index 4686882..eaf3362 100644 --- a/ar_subs.c +++ b/ar_subs.c @@ -48,6 +48,7 @@ static char rcsid[] = "$OpenBSD: ar_subs.c,v 1.14 1998/09/20 02:22:21 millert Ex #include #include +#include #include #include #include diff --git a/cache.c b/cache.c index 60301d8..0e4730a 100644 --- a/cache.c +++ b/cache.c @@ -231,7 +231,11 @@ name_uid(uid, frc) * No entry for this uid, we will add it */ if (!pwopn) { +#ifdef DEBIAN + setpwent(); +#else setpassent(1); +#endif ++pwopn; } if (ptr == NULL) @@ -309,7 +313,11 @@ name_gid(gid, frc) * No entry for this gid, we will add it */ if (!gropn) { +#ifdef DEBIAN + setgrent(); +#else setgroupent(1); +#endif ++gropn; } if (ptr == NULL) @@ -388,7 +396,11 @@ uid_name(name, uid) } if (!pwopn) { +#ifdef DEBIAN + setpwent(); +#else setpassent(1); +#endif ++pwopn; } @@ -458,7 +470,11 @@ gid_name(name, gid) } if (!gropn) { +#ifdef DEBIAN + setgrent(); +#else setgroupent(1); +#endif ++gropn; } if (ptr == NULL) diff --git a/cpio.1 b/cpio.1 index bbc4ab9..7b65034 100644 --- a/cpio.1 +++ b/cpio.1 @@ -38,7 +38,7 @@ .Sh SYNOPSIS .Nm cpio .Fl o -.Op Fl aABcLvzZ +.Op Fl aABcjLvzZ .Op Fl C Ar bytes .Op Fl F Ar archive .Op Fl H Ar format @@ -47,7 +47,7 @@ .Op Ar "> archive" .Nm cpio .Fl i -.Op Fl bBcdfmrsStuvzZ6 +.Op Fl bBcdfjmrsStuvzZ6 .Op Fl C Ar bytes .Op Fl E Ar file .Op Fl F Ar archive @@ -106,6 +106,10 @@ Old tar format. .It Ar ustar POSIX ustar format. .El +.It Fl j +Compress archive using +.Xr bzip2 1 +format. .It Fl L Follow symbolic links. .It Fl v @@ -165,6 +169,10 @@ Old tar format. .It Ar ustar POSIX ustar format. .El +.It Fl j +Uncompress archive using +.Xr bzip2 1 +format. .It Fl m Restore modification times on files. .It Fl r diff --git a/cpio.c b/cpio.c index 47bf5ca..eb486fe 100644 --- a/cpio.c +++ b/cpio.c @@ -47,6 +47,7 @@ static char rcsid[] = "$OpenBSD: cpio.c,v 1.5 1997/07/25 18:58:28 mickey Exp $"; #endif /* not lint */ #include +#include #include #include #include diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..01f455c --- /dev/null +++ b/debian/changelog @@ -0,0 +1,109 @@ +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/control b/debian/control new file mode 100644 index 0000000..0a5830b --- /dev/null +++ b/debian/control @@ -0,0 +1,20 @@ +Source: pax +Section: utils +Priority: optional +Maintainer: Bdale Garbee +Build-Depends: debhelper +Standards-Version: 3.6.1.0 + +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..9df2b74 --- /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 + + -$(MAKE) realclean + + dh_clean + +install: install-stamp +install-stamp: build-stamp + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + $(MAKE) prefix=`pwd`/debian/tmp/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 6ff16f0..69fe373 100644 --- a/gen_subs.c +++ b/gen_subs.c @@ -47,11 +47,13 @@ static char rcsid[] = "$OpenBSD: gen_subs.c,v 1.8 1997/09/01 18:29:51 deraadt Ex #endif /* not lint */ #include +#include #include +#include #include #include #include -#include +#include "tzfile.h" #include #include #include @@ -59,6 +61,8 @@ static char rcsid[] = "$OpenBSD: gen_subs.c,v 1.8 1997/09/01 18:29:51 deraadt Ex #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 4aea600..49592e6 100644 --- a/options.c +++ b/options.c @@ -64,6 +64,8 @@ static char rcsid[] = "$OpenBSD: options.c,v 1.34 1998/09/20 02:22:22 millert Ex #include "tar.h" #include "extern.h" +#include "fgetln.h" /* added, David */ + /* * Routines which handle command line options */ @@ -85,6 +87,7 @@ static void cpio_usage __P((void)); #define GZIP_CMD "gzip" /* command to run as gzip */ #define COMPRESS_CMD "compress" /* command to run as compress */ +#define BZIP2_CMD "bzip2" /* command to run as bzip2 */ /* * Format specific routine table - MUST BE IN SORTED ORDER BY NAME @@ -204,7 +207,7 @@ pax_options(argc, argv) /* * process option flags */ - while ((c=getopt(argc,argv,"ab:cdf:iklno:p:rs:tuvwx:zB:DE:G:HLPT:U:XYZ")) + while ((c=getopt(argc,argv,"ab:cdf:ijklno:p:rs:tuvwx:zB:DE:G:HLPT:U:XYZ")) != EOF) { switch (c) { case 'a': @@ -251,6 +254,13 @@ pax_options(argc, argv) iflag = 1; flg |= IF; break; + case 'j': + /* + * use bzip2. Non standard option. + */ + zflag = 1; + gzip_program = BZIP2_CMD; + break; case 'k': /* * do not clobber files that exist @@ -613,7 +623,7 @@ tar_options(argc, argv) * process option flags */ while ((c = getoldopt(argc, argv, - "b:cef:hmopruts:vwxzBC:HLOPXZ014578")) + "b:cef:hjmopruts:vwxzBC:HLOPXZ014578")) != EOF) { switch(c) { case 'b': @@ -659,6 +669,13 @@ tar_options(argc, argv) */ Lflag = 1; break; + case 'j': + /* + * use bzip2. Non standard option. + */ + zflag = 1; + gzip_program = BZIP2_CMD; + break; case 'm': /* * do not preserve modification time @@ -938,7 +955,7 @@ cpio_options(argc, argv) dflag = 1; act = -1; nodirs = 1; - while ((c=getopt(argc,argv,"abcdfiklmoprstuvzABC:E:F:H:I:LO:SZ6")) != EOF) + while ((c=getopt(argc,argv,"abcdfijklmoprstuvzABC:E:F:H:I:LO:SZ6")) != EOF) switch (c) { case 'a': /* @@ -975,6 +992,13 @@ cpio_options(argc, argv) */ act = EXTRACT; break; + case 'j': + /* + * use bzip2. Non standard option. + */ + zflag = 1; + gzip_program = BZIP2_CMD; + break; case 'k': break; case 'l': @@ -1452,18 +1476,18 @@ void pax_usage() #endif { - (void)fputs("usage: pax [-cdnv] [-E limit] [-f archive] ", stderr); + (void)fputs("usage: pax [-cdjnvz] [-E limit] [-f archive] ", stderr); (void)fputs("[-s replstr] ... [-U user] ...", stderr); (void)fputs("\n [-G group] ... ", stderr); (void)fputs("[-T [from_date][,to_date]] ... ", stderr); (void)fputs("[pattern ...]\n", stderr); - (void)fputs(" pax -r [-cdiknuvDYZ] [-E limit] ", stderr); + (void)fputs(" pax -r [-cdijknuvzDYZ] [-E limit] ", stderr); (void)fputs("[-f archive] [-o options] ... \n", stderr); (void)fputs(" [-p string] ... [-s replstr] ... ", stderr); (void)fputs("[-U user] ... [-G group] ...\n ", stderr); (void)fputs("[-T [from_date][,to_date]] ... ", stderr); (void)fputs(" [pattern ...]\n", stderr); - (void)fputs(" pax -w [-dituvHLPX] [-b blocksize] ", stderr); + (void)fputs(" pax -w [-dijtuvzHLPX] [-b blocksize] ", stderr); (void)fputs("[ [-a] [-f archive] ] [-x format] \n", stderr); (void)fputs(" [-B bytes] [-s replstr] ... ", stderr); (void)fputs("[-o options] ... [-U user] ...", stderr); @@ -1491,7 +1515,7 @@ void tar_usage() #endif { - (void)fputs("usage: tar -{txru}[cevfbmopswzBHLPXZ014578] [tapefile] ", + (void)fputs("usage: tar -{txru}[cevfbjmopswzBHLPXZ014578] [tapefile] ", stderr); (void)fputs("[blocksize] [replstr] [-C directory] file1 file2...\n", stderr); @@ -1511,9 +1535,9 @@ void cpio_usage() #endif { - (void)fputs("usage: cpio -o [-aABcLvVzZ] [-C bytes] [-H format] [-O archive]\n", stderr); + (void)fputs("usage: cpio -o [-aABcjLvVzZ] [-C bytes] [-H format] [-O archive]\n", stderr); (void)fputs(" [-F archive] < name-list [> archive]\n", stderr); - (void)fputs(" cpio -i [-bBcdfmnrsStuvVzZ6] [-C bytes] [-E file] [-H format]\n", stderr); + (void)fputs(" cpio -i [-bBcdfjmnrsStuvVzZ6] [-C bytes] [-E file] [-H format]\n", stderr); (void)fputs(" [-I archive] [-F archive] [pattern...] [< archive]\n", stderr); (void)fputs(" cpio -p [-adlLmuvV] destination-directory < name-list\n", stderr); exit(1); diff --git a/pax.1 b/pax.1 index acfb489..092b2db 100644 --- a/pax.1 +++ b/pax.1 @@ -46,7 +46,7 @@ .Nd read and write file archives and copy directory hierarchies .Sh SYNOPSIS .Nm pax -.Op Fl cdnv +.Op Fl cdjnvz .Bk -words .Op Fl f Ar archive .Ek @@ -73,7 +73,7 @@ .Op Ar pattern ... .Nm pax .Fl r -.Op Fl cdiknuvDYZ +.Op Fl cdijknuvzDYZ .Bk -words .Op Fl f Ar archive .Ek @@ -109,7 +109,7 @@ .Op Ar pattern ... .Nm pax .Fl w -.Op Fl dituvHLPX +.Op Fl dijtuvzHLPX .Bk -words .Op Fl b Ar blocksize .Ek @@ -480,6 +480,8 @@ will immediately exit with a non-zero exit status if is encountered when reading a response or if .Pa /dev/tty cannot be opened for reading and writing. +.It Fl j +Filter archive through bzip2. .It Fl k Do not overwrite existing files. .It Fl l @@ -695,7 +697,7 @@ currently supports the following formats: .Bl -tag -width "sv4cpio" .It Ar cpio The extended cpio interchange format specified in the -.St -p1003.2 +.St -p1003.1 standard. The default blocksize for this format is 5120 bytes. Inode and device information about a file (used for detecting file hard links @@ -743,7 +745,7 @@ This option takes the form: .Dl Fl o Cm write_opt=nodir .It Ar ustar The extended tar interchange format specified in the -.St -p1003.2 +.St -p1003.1 standard. The default blocksize for this format is 10240 bytes. Pathnames stored by this format must be 250 characters or less in length. @@ -756,6 +758,8 @@ The individual archive formats may impose additional restrictions on use. Typical archive format restrictions include (but are not limited to): file pathname length, file size, link pathname length, and the type of the file. +.It Fl j +Filter archive through bzip2. .It Fl B Ar bytes Limit the number of bytes written to a single archive volume to .Ar bytes . @@ -1098,9 +1102,11 @@ files with the same name found in the source file tree The .Nm pax utility is a superset of the -.St -p1003.2 +.St -p1003.1 standard. The options +.Fl j , +.Fl z , .Fl B , .Fl D , .Fl E , diff --git a/pax.c b/pax.c index 637e2f3..3be04a9 100644 --- a/pax.c +++ b/pax.c @@ -87,7 +87,7 @@ int nflag; /* select first archive member match */ int tflag; /* restore access time after read */ int uflag; /* ignore older modification time files */ int vflag; /* produce verbose output */ -int zflag; /* use gzip */ +int zflag; /* use compress, gzip or bzip2 */ int Dflag; /* same as uflag except inode change time */ int Hflag; /* follow command line symlinks (write only) */ int Lflag; /* follow symlinks when writing */ @@ -107,7 +107,7 @@ char *dirptr; /* destination dir in a copy */ char *ltmfrmt; /* -v locale time format (if any) */ char *argv0; /* root of argv[0] */ sigset_t s_mask; /* signal mask for cleanup critical sect */ -FILE *listf = stderr; /* file pointer to print file list to */ +FILE *listf; /* file pointer to print file list to */ /* * PAX - Portable Archive Interchange @@ -239,6 +239,8 @@ main(argc, argv) char **argv; #endif { + listf = stderr; + /* * Keep a reference to cwd, so we can always come back home. */ diff --git a/sel_subs.c b/sel_subs.c index c5c2253..d11b50c 100644 --- a/sel_subs.c +++ b/sel_subs.c @@ -48,6 +48,7 @@ static char rcsid[] = "$OpenBSD: sel_subs.c,v 1.7 1997/08/17 23:05:09 millert Ex #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.1 b/tar.1 index 907eb46..a57732b 100644 --- a/tar.1 +++ b/tar.1 @@ -37,7 +37,7 @@ .Nd tape archiver .Sh SYNOPSIS .Nm -.No [-]{crtux}[befhmopvwzHLPXZ014578] +.No [-]{crtux}[befhjmopvwzHLPXZ014578] .Op Ar archive .Op Ar blocksize .\" XXX how to do this right? @@ -100,6 +100,8 @@ Filename where the archive is stored. Defaults to .It Fl h Follow symbolic links as if they were normal files or directories. +.It Fl j +Filter archive through bzip2. .It Fl m Do not preserve modification time. .It Fl O @@ -172,7 +174,7 @@ Interactively rename files. This option causes to prompt the user for the filename to use when storing or extracting files in an archive. .It Fl z -Compress archive using gzip. +Filter archive through gzip. .It Fl C Ar directory This is a positional argument which sets the working directory for the following files. When extracting, files will be extracted into @@ -188,7 +190,7 @@ The default is to strip leading slashes. .It Fl X Do not cross mount points in the file system. .It Fl Z -Compress archive using compress. +Filter archive through compress. .El .Pp The options diff --git a/tar.c b/tar.c index c73657d..af7f214 100644 --- a/tar.c +++ b/tar.c @@ -47,6 +47,7 @@ static char rcsid[] = "$OpenBSD: tar.c,v 1.13 1998/09/26 21:29:41 millert Exp $" #endif /* not lint */ #include +#include #include #include #include @@ -841,15 +842,21 @@ ustar_rd(arcn, 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') { - cnt = l_strncpy(dest, hd->prefix, sizeof(arcn->name) - 2); + cnt = l_strncpy(dest, hd->prefix, sizeof(hd->prefix)); dest += cnt; *dest++ = '/'; cnt++; } - arcn->nlen = cnt + l_strncpy(dest, hd->name, sizeof(arcn->name) - cnt); + arcn->nlen = cnt + l_strncpy(dest, hd->name, sizeof(hd->name)); arcn->name[arcn->nlen] = '\0'; /* @@ -936,9 +943,12 @@ ustar_rd(arcn, buf) } /* * copy the link name + * + * see comment above (for hd->name) regarding the length + * passed to l_strncpy */ arcn->ln_nlen = l_strncpy(arcn->ln_name, hd->linkname, - sizeof(arcn->ln_name) - 1); + sizeof(hd->linkname)); arcn->ln_name[arcn->ln_nlen] = '\0'; break; case CONTTYPE: @@ -1020,7 +1030,7 @@ ustar_wr(arcn) * occur, we remove the / and copy the first part to the prefix */ *pt = '\0'; - l_strncpy(hd->prefix, arcn->name, sizeof(hd->prefix) - 1); + l_strncpy(hd->prefix, arcn->name, sizeof(hd->prefix)); *pt++ = '/'; } else memset(hd->prefix, 0, sizeof(hd->prefix)); @@ -1029,8 +1039,7 @@ ustar_wr(arcn) * copy the name part. this may be the whole path or the part after * the prefix */ - l_strncpy(hd->name, pt, sizeof(hd->name) - 1); - hd->name[sizeof(hd->name) - 1] = '\0'; + l_strncpy(hd->name, pt, sizeof(hd->name)); /* * set the fields in the header that are type dependent @@ -1040,7 +1049,9 @@ ustar_wr(arcn) hd->typeflag = DIRTYPE; memset(hd->linkname, 0, sizeof(hd->linkname)); memset(hd->devmajor, 0, sizeof(hd->devmajor)); + hd->devmajor[0] = '0'; memset(hd->devminor, 0, sizeof(hd->devminor)); + hd->devminor[0] = '0'; if (ul_oct((u_long)0L, hd->size, sizeof(hd->size), 3)) goto out; break; @@ -1062,7 +1073,9 @@ ustar_wr(arcn) hd->typeflag = FIFOTYPE; memset(hd->linkname, 0, sizeof(hd->linkname)); memset(hd->devmajor, 0, sizeof(hd->devmajor)); + hd->devmajor[0] = '0'; memset(hd->devminor, 0, sizeof(hd->devminor)); + hd->devminor[0] = '0'; if (ul_oct((u_long)0L, hd->size, sizeof(hd->size), 3)) goto out; break; @@ -1073,10 +1086,11 @@ ustar_wr(arcn) hd->typeflag = SYMTYPE; else hd->typeflag = LNKTYPE; - l_strncpy(hd->linkname,arcn->ln_name, sizeof(hd->linkname) - 1); - hd->linkname[sizeof(hd->linkname) - 1] = '\0'; + l_strncpy(hd->linkname,arcn->ln_name, sizeof(hd->linkname)); memset(hd->devmajor, 0, sizeof(hd->devmajor)); + hd->devmajor[0] = '0'; memset(hd->devminor, 0, sizeof(hd->devminor)); + hd->devminor[0] = '0'; if (ul_oct((u_long)0L, hd->size, sizeof(hd->size), 3)) goto out; break; @@ -1092,7 +1106,9 @@ ustar_wr(arcn) hd->typeflag = REGTYPE; memset(hd->linkname, 0, sizeof(hd->linkname)); memset(hd->devmajor, 0, sizeof(hd->devmajor)); + hd->devmajor[0] = '0'; memset(hd->devminor, 0, sizeof(hd->devminor)); + hd->devminor[0] = '0'; arcn->pad = TAR_PAD(arcn->sb.st_size); # ifdef NET2_STAT if (ul_oct((u_long)arcn->sb.st_size, hd->size, @@ -1174,7 +1190,7 @@ name_split(name, len) * check to see if the file name is small enough to fit in the name * field. if so just return a pointer to the name. */ - if (len < TNMSZ) + if (len <= TNMSZ) return(name); if (len > (TPFSZ + TNMSZ + 1)) return(NULL); diff --git a/types.h b/types.h new file mode 100644 index 0000000..baf4d8d --- /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_ */