diff options
Diffstat (limited to 'bin/pax')
-rw-r--r-- | bin/pax/Makefile | 27 | ||||
-rw-r--r-- | bin/pax/Makefile.depend | 2 | ||||
-rw-r--r-- | bin/pax/ar_io.c | 34 | ||||
-rw-r--r-- | bin/pax/ar_subs.c | 13 | ||||
-rw-r--r-- | bin/pax/buf_subs.c | 10 | ||||
-rw-r--r-- | bin/pax/cache.c | 16 | ||||
-rw-r--r-- | bin/pax/cache.h | 3 | ||||
-rw-r--r-- | bin/pax/cpio.c | 56 | ||||
-rw-r--r-- | bin/pax/cpio.h | 3 | ||||
-rw-r--r-- | bin/pax/extern.h | 5 | ||||
-rw-r--r-- | bin/pax/file_subs.c | 19 | ||||
-rw-r--r-- | bin/pax/ftree.c | 33 | ||||
-rw-r--r-- | bin/pax/ftree.h | 3 | ||||
-rw-r--r-- | bin/pax/gen_subs.c | 19 | ||||
-rw-r--r-- | bin/pax/getoldopt.c | 3 | ||||
-rw-r--r-- | bin/pax/options.c | 23 | ||||
-rw-r--r-- | bin/pax/options.h | 3 | ||||
-rw-r--r-- | bin/pax/pat_rep.c | 98 | ||||
-rw-r--r-- | bin/pax/pat_rep.h | 7 | ||||
-rw-r--r-- | bin/pax/pax.1 | 30 | ||||
-rw-r--r-- | bin/pax/pax.c | 18 | ||||
-rw-r--r-- | bin/pax/pax.h | 3 | ||||
-rw-r--r-- | bin/pax/sel_subs.c | 134 | ||||
-rw-r--r-- | bin/pax/sel_subs.h | 5 | ||||
-rw-r--r-- | bin/pax/tables.c | 22 | ||||
-rw-r--r-- | bin/pax/tables.h | 3 | ||||
-rw-r--r-- | bin/pax/tar.c | 64 | ||||
-rw-r--r-- | bin/pax/tar.h | 3 | ||||
-rw-r--r-- | bin/pax/tests/Makefile | 2 | ||||
-rw-r--r-- | bin/pax/tests/Makefile.depend | 1 | ||||
-rw-r--r-- | bin/pax/tests/legacy_test.pl | 1 | ||||
-rw-r--r-- | bin/pax/tty_subs.c | 8 |
32 files changed, 126 insertions, 545 deletions
diff --git a/bin/pax/Makefile b/bin/pax/Makefile index d0772ee49766..abcfe61c7da6 100644 --- a/bin/pax/Makefile +++ b/bin/pax/Makefile @@ -1,32 +1,5 @@ -# @(#)Makefile 8.1 (Berkeley) 5/31/93 -# $FreeBSD$ - .include <src.opts.mk> -# 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. - PACKAGE=runtime PROG= pax SRCS= ar_io.c ar_subs.c buf_subs.c cache.c cpio.c file_subs.c ftree.c \ diff --git a/bin/pax/Makefile.depend b/bin/pax/Makefile.depend index 6cfaab1c3644..6ef78fac5cbf 100644 --- a/bin/pax/Makefile.depend +++ b/bin/pax/Makefile.depend @@ -1,8 +1,6 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - gnu/lib/csu \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git a/bin/pax/ar_io.c b/bin/pax/ar_io.c index 6271944703ff..c595870aaa5e 100644 --- a/bin/pax/ar_io.c +++ b/bin/pax/ar_io.c @@ -33,14 +33,6 @@ * SUCH DAMAGE. */ -#ifndef lint -#if 0 -static char sccsid[] = "@(#)ar_io.c 8.2 (Berkeley) 4/18/94"; -#endif -#endif /* not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <sys/ioctl.h> #include <sys/mtio.h> @@ -206,7 +198,7 @@ ar_open(const char *name) * set default blksz on read. APPNDs writes rdblksz on the last volume * On all new archive volumes, we shift to wrblksz (if the user * specified one, otherwise we will continue to use rdblksz). We - * must to set blocksize based on what kind of device the archive is + * must set blocksize based on what kind of device the archive is * stored. */ switch(artyp) { @@ -286,7 +278,7 @@ ar_open(const char *name) break; default: /* - * should never happen, worse case, slow... + * should never happen, worst case, slow... */ blksz = rdblksz = BLKMULT; break; @@ -386,13 +378,8 @@ ar_close(void) * could have written anything yet. */ if (frmt == NULL) { -# ifdef NET2_STAT - (void)fprintf(listf, "%s: unknown format, %lu bytes skipped.\n", - argv0, rdcnt); -# else (void)fprintf(listf, "%s: unknown format, %ju bytes skipped.\n", argv0, (uintmax_t)rdcnt); -# endif (void)fflush(listf); flcnt = 0; return; @@ -403,14 +390,9 @@ ar_close(void) (unsigned long long)((rdcnt ? rdcnt : wrcnt) / 5120)); else if (strcmp(NM_TAR, argv0) != 0) (void)fprintf(listf, -# ifdef NET2_STAT - "%s: %s vol %d, %lu files, %lu bytes read, %lu bytes written.\n", - argv0, frmt->name, arvol-1, flcnt, rdcnt, wrcnt); -# else "%s: %s vol %d, %ju files, %ju bytes read, %ju bytes written.\n", argv0, frmt->name, arvol-1, (uintmax_t)flcnt, (uintmax_t)rdcnt, (uintmax_t)wrcnt); -# endif (void)fflush(listf); flcnt = 0; } @@ -543,10 +525,10 @@ ar_read(char *buf, int cnt) io_ok = 1; if (res != rdblksz) { /* - * Record size changed. If this is happens on + * Record size changed. If this happens on * any record after the first, we probably have * a tape drive which has a fixed record size - * we are getting multiple records in a single + * (we are getting multiple records in a single * read). Watch out for record blocking that * violates pax spec (must be a multiple of * BLKMULT). @@ -726,7 +708,7 @@ ar_rdsync(void) struct mtop mb; /* - * Fail resync attempts at user request (done) or this is going to be + * Fail resync attempts at user request (done) or if this is going to be * an update/append to an existing archive. If last i/o hit media end, * we need to go to the next volume not try a resync. */ @@ -932,12 +914,12 @@ ar_rev(off_t sksz) break; case ISTAPE: /* - * Calculate and move the proper number of PHYSICAL tape + * Calculate and move the proper number of PHYSICAL tape * blocks. If the sksz is not an even multiple of the physical * tape size, we cannot do the move (this should never happen). - * (We also cannot handler trailers spread over two vols). + * (We also cannot handle trailers spread over two vols). * get_phys() also makes sure we are in front of the filemark. - */ + */ if ((phyblk = get_phys()) <= 0) { lstrval = -1; return(-1); diff --git a/bin/pax/ar_subs.c b/bin/pax/ar_subs.c index b18dc3710942..8f8a5b842626 100644 --- a/bin/pax/ar_subs.c +++ b/bin/pax/ar_subs.c @@ -33,14 +33,6 @@ * SUCH DAMAGE. */ -#ifndef lint -#if 0 -static char sccsid[] = "@(#)ar_subs.c 8.2 (Berkeley) 4/18/94"; -#endif -#endif /* not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <sys/time.h> #include <sys/stat.h> @@ -202,7 +194,7 @@ extract(void) /* * with -u or -D only extract when the archive member is newer - * than the file with the same name in the file system (nos + * than the file with the same name in the file system (no * test of being the same type is required). * NOTE: this test is done BEFORE name modifications as * specified by pax. this operation can be confusing to the @@ -387,7 +379,8 @@ wr_archive(ARCHD *arcn, int is_app) return; /* - * if this not append, and there are no files, we do no write a trailer + * if this is not append, and there are no files, we do not write a + * trailer */ wr_one = is_app; diff --git a/bin/pax/buf_subs.c b/bin/pax/buf_subs.c index 6d50a280f29c..7f9b31881d56 100644 --- a/bin/pax/buf_subs.c +++ b/bin/pax/buf_subs.c @@ -33,14 +33,6 @@ * SUCH DAMAGE. */ -#ifndef lint -#if 0 -static char sccsid[] = "@(#)buf_subs.c 8.2 (Berkeley) 4/18/94"; -#endif -#endif /* not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <sys/stat.h> #include <errno.h> @@ -199,7 +191,7 @@ cp_start(void) * A major problem is rewriting this last record. For archives stored * on disk files, this is trivial. However, many devices are really picky * about the conditions under which they will allow a write to occur. - * Often devices restrict the conditions where writes can be made writes, + * Often devices restrict the conditions where writes can be made, * so it may not be feasible to append archives stored on all types of * devices. * Return: diff --git a/bin/pax/cache.c b/bin/pax/cache.c index 980d7bccc217..d15c9c223447 100644 --- a/bin/pax/cache.c +++ b/bin/pax/cache.c @@ -33,14 +33,6 @@ * SUCH DAMAGE. */ -#ifndef lint -#if 0 -static char sccsid[] = "@(#)cache.c 8.1 (Berkeley) 5/31/93"; -#endif -#endif /* not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <sys/stat.h> #include <string.h> @@ -211,12 +203,8 @@ name_uid(uid_t uid, int frc) return(""); ptr->uid = uid; ptr->valid = INVALID; -# ifdef NET2_STAT - (void)snprintf(ptr->name, sizeof(ptr->name), "%u", uid); -# else (void)snprintf(ptr->name, sizeof(ptr->name), "%lu", (unsigned long)uid); -# endif if (frc == 0) return(""); } else { @@ -282,12 +270,8 @@ name_gid(gid_t gid, int frc) return(""); ptr->gid = gid; ptr->valid = INVALID; -# ifdef NET2_STAT - (void)snprintf(ptr->name, sizeof(ptr->name), "%u", gid); -# else (void)snprintf(ptr->name, sizeof(ptr->name), "%lu", (unsigned long)gid); -# endif if (frc == 0) return(""); } else { diff --git a/bin/pax/cache.h b/bin/pax/cache.h index 8a7cca9f457a..266aacbe7ce9 100644 --- a/bin/pax/cache.h +++ b/bin/pax/cache.h @@ -31,9 +31,6 @@ * 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. - * - * @(#)cache.h 8.1 (Berkeley) 5/31/93 - * $FreeBSD$ */ /* diff --git a/bin/pax/cpio.c b/bin/pax/cpio.c index a47b7fd7a823..8108dd11731f 100644 --- a/bin/pax/cpio.c +++ b/bin/pax/cpio.c @@ -33,14 +33,6 @@ * SUCH DAMAGE. */ -#ifndef lint -#if 0 -static char sccsid[] = "@(#)cpio.c 8.1 (Berkeley) 5/31/93"; -#endif -#endif /* not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <sys/time.h> #include <sys/stat.h> @@ -149,7 +141,7 @@ com_rd(ARCHD *arcn) } /* - * cpio_end_wr() + * cpio_endwr() * write the special file with the name trailer in the proper format * Return: * result of the write of the trailer from the cpio specific write func @@ -216,13 +208,8 @@ rd_ln_nm(ARCHD *arcn) */ if ((arcn->sb.st_size == 0) || ((size_t)arcn->sb.st_size >= sizeof(arcn->ln_name))) { -# ifdef NET2_STAT - paxwarn(1, "Cpio link name length is invalid: %lu", - arcn->sb.st_size); -# else paxwarn(1, "Cpio link name length is invalid: %ju", (uintmax_t)arcn->sb.st_size); -# endif return(-1); } @@ -287,13 +274,13 @@ cpio_rd(ARCHD *arcn, char *buf) */ if (cpio_id(buf, sizeof(HD_CPIO)) < 0) return(-1); + memset(arcn, 0, sizeof *arcn); hd = (HD_CPIO *)buf; /* * byte oriented cpio (posix) does not have padding! extract the octal * ascii fields from the header */ - arcn->pad = 0L; arcn->sb.st_dev = (dev_t)asc_ul(hd->c_dev, sizeof(hd->c_dev), OCT); arcn->sb.st_ino = (ino_t)asc_ul(hd->c_ino, sizeof(hd->c_ino), OCT); arcn->sb.st_mode = (mode_t)asc_ul(hd->c_mode, sizeof(hd->c_mode), OCT); @@ -302,21 +289,11 @@ cpio_rd(ARCHD *arcn, char *buf) arcn->sb.st_nlink = (nlink_t)asc_ul(hd->c_nlink, sizeof(hd->c_nlink), OCT); arcn->sb.st_rdev = (dev_t)asc_ul(hd->c_rdev, sizeof(hd->c_rdev), OCT); -#ifdef NET2_STAT - arcn->sb.st_mtime = (time_t)asc_ul(hd->c_mtime, sizeof(hd->c_mtime), - OCT); -#else arcn->sb.st_mtime = (time_t)asc_uqd(hd->c_mtime, sizeof(hd->c_mtime), OCT); -#endif arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime; -#ifdef NET2_STAT - arcn->sb.st_size = (off_t)asc_ul(hd->c_filesize,sizeof(hd->c_filesize), - OCT); -#else arcn->sb.st_size = (off_t)asc_uqd(hd->c_filesize,sizeof(hd->c_filesize), OCT); -#endif /* * check name size and if valid, read in the name of this entry (name @@ -332,8 +309,6 @@ cpio_rd(ARCHD *arcn, char *buf) /* * no link name to read for this file */ - arcn->ln_nlen = 0; - arcn->ln_name[0] = '\0'; return(com_rd(arcn)); } @@ -411,13 +386,8 @@ cpio_wr(ARCHD *arcn) /* * set data size for file data */ -# ifdef NET2_STAT - if (ul_asc((u_long)arcn->sb.st_size, hd->c_filesize, - sizeof(hd->c_filesize), OCT)) { -# else if (uqd_asc((u_quad_t)arcn->sb.st_size, hd->c_filesize, sizeof(hd->c_filesize), OCT)) { -# endif paxwarn(1,"File is too large for cpio format %s", arcn->org_name); return(1); @@ -583,8 +553,8 @@ vcpio_rd(ARCHD *arcn, char *buf) return(-1); } + memset(arcn, 0, sizeof *arcn); hd = (HD_VCPIO *)buf; - arcn->pad = 0L; /* * extract the hex ascii fields from the header @@ -593,19 +563,10 @@ vcpio_rd(ARCHD *arcn, char *buf) arcn->sb.st_mode = (mode_t)asc_ul(hd->c_mode, sizeof(hd->c_mode), HEX); arcn->sb.st_uid = (uid_t)asc_ul(hd->c_uid, sizeof(hd->c_uid), HEX); arcn->sb.st_gid = (gid_t)asc_ul(hd->c_gid, sizeof(hd->c_gid), HEX); -#ifdef NET2_STAT - arcn->sb.st_mtime = (time_t)asc_ul(hd->c_mtime,sizeof(hd->c_mtime),HEX); -#else arcn->sb.st_mtime = (time_t)asc_uqd(hd->c_mtime,sizeof(hd->c_mtime),HEX); -#endif arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime; -#ifdef NET2_STAT - arcn->sb.st_size = (off_t)asc_ul(hd->c_filesize, - sizeof(hd->c_filesize), HEX); -#else arcn->sb.st_size = (off_t)asc_uqd(hd->c_filesize, sizeof(hd->c_filesize), HEX); -#endif arcn->sb.st_nlink = (nlink_t)asc_ul(hd->c_nlink, sizeof(hd->c_nlink), HEX); devmajor = (dev_t)asc_ul(hd->c_maj, sizeof(hd->c_maj), HEX); @@ -640,8 +601,6 @@ vcpio_rd(ARCHD *arcn, char *buf) /* * we have a valid header (not a link) */ - arcn->ln_nlen = 0; - arcn->ln_name[0] = '\0'; arcn->pad = VCPIO_PAD(arcn->sb.st_size); return(com_rd(arcn)); } @@ -740,13 +699,8 @@ vcpio_wr(ARCHD *arcn) * much to pad. */ arcn->pad = VCPIO_PAD(arcn->sb.st_size); -# ifdef NET2_STAT - if (ul_asc((u_long)arcn->sb.st_size, hd->c_filesize, - sizeof(hd->c_filesize), HEX)) { -# else if (uqd_asc((u_quad_t)arcn->sb.st_size, hd->c_filesize, sizeof(hd->c_filesize), HEX)) { -# endif paxwarn(1,"File is too large for sv4cpio format %s", arcn->org_name); return(1); @@ -893,7 +847,7 @@ bcpio_rd(ARCHD *arcn, char *buf) if (bcpio_id(buf, sizeof(HD_BCPIO)) < 0) return(-1); - arcn->pad = 0L; + memset(arcn, 0, sizeof *arcn); hd = (HD_BCPIO *)buf; if (swp_head) { /* @@ -955,8 +909,6 @@ bcpio_rd(ARCHD *arcn, char *buf) /* * we have a valid header (not a link) */ - arcn->ln_nlen = 0; - arcn->ln_name[0] = '\0'; arcn->pad = BCPIO_PAD(arcn->sb.st_size); return(com_rd(arcn)); } diff --git a/bin/pax/cpio.h b/bin/pax/cpio.h index e5d61dea36fb..fba965f64a82 100644 --- a/bin/pax/cpio.h +++ b/bin/pax/cpio.h @@ -31,9 +31,6 @@ * 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. - * - * @(#)cpio.h 8.1 (Berkeley) 5/31/93 - * $FreeBSD$ */ /* diff --git a/bin/pax/extern.h b/bin/pax/extern.h index ec171f2d177c..26e5f6b6151b 100644 --- a/bin/pax/extern.h +++ b/bin/pax/extern.h @@ -31,9 +31,6 @@ * 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. - * - * @(#)extern.h 8.2 (Berkeley) 4/18/94 - * $FreeBSD$ */ /* @@ -169,10 +166,8 @@ void ls_tty(ARCHD *); int l_strncpy(char *, const char *, int); u_long asc_ul(char *, int, int); int ul_asc(u_long, char *, int, int); -#ifndef NET2_STAT u_quad_t asc_uqd(char *, int, int); int uqd_asc(u_quad_t, char *, int, int); -#endif /* * getoldopt.c diff --git a/bin/pax/file_subs.c b/bin/pax/file_subs.c index 31fb9112c586..06602c12db2c 100644 --- a/bin/pax/file_subs.c +++ b/bin/pax/file_subs.c @@ -33,14 +33,6 @@ * SUCH DAMAGE. */ -#ifndef lint -#if 0 -static char sccsid[] = "@(#)file_subs.c 8.1 (Berkeley) 5/31/93"; -#endif -#endif /* not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <sys/time.h> #include <sys/stat.h> @@ -563,7 +555,12 @@ chk_path( char *name, uid_t st_uid, gid_t st_gid) * work forward from the first / and check each part of the path */ spt = strchr(spt, '/'); - if (spt == NULL) + + /* + * skip creating a leaf dir (with an ending '/') as we only want + * to create parents here + */ + if ((spt == NULL) || (*(spt + 1) == '\0')) break; *spt = '\0'; @@ -623,7 +620,7 @@ chk_path( char *name, uid_t st_uid, gid_t st_gid) * non-zero we force these times to be set even if the user did not * request access and/or modification time preservation (this is also * used by -t to reset access times). - * When ign is zero, only those times the user has asked for are set, the + * When frc is zero, only those times the user has asked for are set, the * other ones are left alone. We do not assume the un-documented feature * of many lutimes() implementations that consider a 0 time value as a do * not set request. @@ -724,7 +721,7 @@ set_pmode(char *fnm, mode_t mode) * block boundaries significantly reduces the overhead when copying files * that are NOT very sparse. This overhead (when compared to a write) is * almost below the measurement resolution on many systems. Without it, - * files with holes cannot be safely copied. It does has a side effect as + * files with holes cannot be safely copied. It does have a side effect as * it can put holes into files that did not have them before, but that is * not a problem since the file contents are unchanged (in fact it saves * file space). (Except on paging files for diskless clients. But since we diff --git a/bin/pax/ftree.c b/bin/pax/ftree.c index 26df8164bc2d..400eb2faad30 100644 --- a/bin/pax/ftree.c +++ b/bin/pax/ftree.c @@ -33,14 +33,6 @@ * SUCH DAMAGE. */ -#ifndef lint -#if 0 -static char sccsid[] = "@(#)ftree.c 8.2 (Berkeley) 4/18/94"; -#endif -#endif /* not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <sys/time.h> #include <sys/stat.h> @@ -115,11 +107,7 @@ ftree_start(void) else ftsopts |= FTS_PHYSICAL; if (Hflag) -# ifdef NET2_FTS - paxwarn(0, "The -H flag is not supported on this version"); -# else ftsopts |= FTS_COMFOLLOW; -# endif if (Xflag) ftsopts |= FTS_XDEV; @@ -402,13 +390,8 @@ next_file(ARCHD *arcn) * remember to force the time (this is -t on a read * directory, not a created directory). */ -# ifdef NET2_FTS - if (!tflag || (get_atdir(ftent->fts_statb.st_dev, - ftent->fts_statb.st_ino, &mtime, &atime) < 0)) -# else if (!tflag || (get_atdir(ftent->fts_statp->st_dev, ftent->fts_statp->st_ino, &mtime, &atime) < 0)) -# endif continue; set_ftime(ftent->fts_path, mtime, atime, 1); continue; @@ -419,28 +402,16 @@ next_file(ARCHD *arcn) paxwarn(1,"File system cycle found at %s",ftent->fts_path); continue; case FTS_DNR: -# ifdef NET2_FTS - syswarn(1, errno, -# else syswarn(1, ftent->fts_errno, -# endif "Unable to read directory %s", ftent->fts_path); continue; case FTS_ERR: -# ifdef NET2_FTS - syswarn(1, errno, -# else syswarn(1, ftent->fts_errno, -# endif "File system traversal error"); continue; case FTS_NS: case FTS_NSOK: -# ifdef NET2_FTS - syswarn(1, errno, -# else syswarn(1, ftent->fts_errno, -# endif "Unable to access %s", ftent->fts_path); continue; } @@ -453,11 +424,7 @@ next_file(ARCHD *arcn) arcn->pad = 0; arcn->ln_nlen = 0; arcn->ln_name[0] = '\0'; -# ifdef NET2_FTS - arcn->sb = ftent->fts_statb; -# else arcn->sb = *(ftent->fts_statp); -# endif /* * file type based set up and copy into the arcn struct diff --git a/bin/pax/ftree.h b/bin/pax/ftree.h index 8e0a710e4ca9..500893096599 100644 --- a/bin/pax/ftree.h +++ b/bin/pax/ftree.h @@ -31,9 +31,6 @@ * 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. - * - * @(#)ftree.h 8.1 (Berkeley) 5/31/93 - * $FreeBSD$ */ /* diff --git a/bin/pax/gen_subs.c b/bin/pax/gen_subs.c index f91aaff7b809..a92303f63106 100644 --- a/bin/pax/gen_subs.c +++ b/bin/pax/gen_subs.c @@ -33,14 +33,6 @@ * SUCH DAMAGE. */ -#ifndef lint -#if 0 -static char sccsid[] = "@(#)gen_subs.c 8.1 (Berkeley) 5/31/93"; -#endif -#endif /* not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <sys/time.h> #include <sys/stat.h> @@ -119,19 +111,10 @@ ls_list(ARCHD *arcn, time_t now, FILE *fp) * print device id's for devices, or sizes for other nodes */ if ((arcn->type == PAX_CHR) || (arcn->type == PAX_BLK)) -# ifdef NET2_STAT - (void)fprintf(fp, "%4u,%4u ", MAJOR(sbp->st_rdev), - MINOR(sbp->st_rdev)); -# else (void)fprintf(fp, "%4lu,%4lu ", (unsigned long)MAJOR(sbp->st_rdev), (unsigned long)MINOR(sbp->st_rdev)); -# endif else { -# ifdef NET2_STAT - (void)fprintf(fp, "%9lu ", sbp->st_size); -# else (void)fprintf(fp, "%9ju ", (uintmax_t)sbp->st_size); -# endif } /* @@ -300,7 +283,6 @@ ul_asc(u_long val, char *str, int len, int base) return(0); } -#ifndef NET2_STAT /* * asc_uqd() * convert hex/octal character string into a u_quad_t. We do not have to @@ -396,4 +378,3 @@ uqd_asc(u_quad_t val, char *str, int len, int base) return(-1); return(0); } -#endif diff --git a/bin/pax/getoldopt.c b/bin/pax/getoldopt.c index 838ff54d4a88..6b0e83c23a24 100644 --- a/bin/pax/getoldopt.c +++ b/bin/pax/getoldopt.c @@ -10,9 +10,6 @@ * in the Public Domain for your edification and enjoyment. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> diff --git a/bin/pax/options.c b/bin/pax/options.c index 4ec02d80d55c..3567820acced 100644 --- a/bin/pax/options.c +++ b/bin/pax/options.c @@ -33,15 +33,6 @@ * SUCH DAMAGE. */ -#if 0 -#ifndef lint -static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 4/18/94"; -#endif /* not lint */ -#endif - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <sys/stat.h> #include <sys/mtio.h> @@ -87,7 +78,7 @@ char *chdname; #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 gzip */ +#define BZIP2_CMD "bzip2" /* command to run as bzip2 */ /* * Format specific routine table - MUST BE IN SORTED ORDER BY NAME @@ -131,17 +122,18 @@ FSUB fsub[] = { }; #define F_OCPIO 0 /* format when called as cpio -6 */ #define F_ACPIO 1 /* format when called as cpio -c */ +#define F_SCPIO 2 /* format when called with -x sv4cpio */ #define F_CPIO 3 /* format when called as cpio */ #define F_OTAR 4 /* format when called as tar -o */ #define F_TAR 5 /* format when called as tar */ -#define DEFLT 5 /* default write format from list above */ +#define DEFLT F_TAR /* default write format from list above */ /* * ford is the archive search order used by get_arc() to determine what kind * of archive we are dealing with. This helps to properly id archive formats * some formats may be subsets of others.... */ -int ford[] = {5, 4, 3, 2, 1, 0, -1 }; +int ford[] = {F_TAR, F_OTAR, F_CPIO, F_SCPIO, F_ACPIO, F_OCPIO, -1 }; /* * options() @@ -308,7 +300,7 @@ pax_options(int argc, char **argv) break; case 'p': /* - * preserver file mode bits + * preserve file mode bits */ pmode = 1; break; @@ -1434,13 +1426,8 @@ str_offt(char *val) char *expr; off_t num, t; -# ifdef NET2_STAT - num = strtol(val, &expr, 0); - if ((num == LONG_MAX) || (num <= 0) || (expr == val)) -# else num = strtoq(val, &expr, 0); if ((num == QUAD_MAX) || (num <= 0) || (expr == val)) -# endif return(0); switch(*expr) { diff --git a/bin/pax/options.h b/bin/pax/options.h index 973ea0bd5467..49fef7bb7531 100644 --- a/bin/pax/options.h +++ b/bin/pax/options.h @@ -31,9 +31,6 @@ * 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. - * - * @(#)options.h 8.2 (Berkeley) 4/18/94 - * $FreeBSD$ */ /* diff --git a/bin/pax/pat_rep.c b/bin/pax/pat_rep.c index 0dfa630050ea..0c416741f5d8 100644 --- a/bin/pax/pat_rep.c +++ b/bin/pax/pat_rep.c @@ -33,24 +33,12 @@ * SUCH DAMAGE. */ -#ifndef lint -#if 0 -static char sccsid[] = "@(#)pat_rep.c 8.2 (Berkeley) 4/18/94"; -#endif -#endif /* not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> #include <string.h> #include <stdlib.h> -#ifdef NET2_REGEX -#include <regexp.h> -#else #include <regex.h> -#endif #include "pax.h" #include "pat_rep.h" #include "extern.h" @@ -73,11 +61,7 @@ static int tty_rename(ARCHD *); static int fix_path(char *, int *, char *, int); static int fn_match(char *, char *, char **); static char * range_match(char *, int); -#ifdef NET2_REGEX -static int resub(regexp *, char *, char *, char *); -#else static int resub(regex_t *, regmatch_t *, char *, char *, char *, char *); -#endif /* * rep_add() @@ -101,10 +85,8 @@ rep_add(char *str) char *pt1; char *pt2; REPLACE *rep; -# ifndef NET2_REGEX int res; char rebuf[BUFSIZ]; -# endif /* * throw out the bad parameters @@ -133,13 +115,9 @@ rep_add(char *str) } *pt1 = '\0'; -# ifdef NET2_REGEX - if ((rep->rcmp = regcomp(str+1)) == NULL) { -# else if ((res = regcomp(&(rep->rcmp), str+1, 0)) != 0) { regerror(res, &(rep->rcmp), rebuf, sizeof(rebuf)); paxwarn(1, "%s while compiling regular expression %s", rebuf, str); -# endif free(rep); return(-1); } @@ -151,11 +129,7 @@ rep_add(char *str) */ *pt1++ = *str; if ((pt2 = strchr(pt1, *str)) == NULL) { -# ifdef NET2_REGEX - free(rep->rcmp); -# else regfree(&rep->rcmp); -# endif free(rep); paxwarn(1, "Invalid replacement string %s", str); return(-1); @@ -180,11 +154,7 @@ rep_add(char *str) rep->flgs |= PRNT; break; default: -# ifdef NET2_REGEX - free(rep->rcmp); -# else regfree(&rep->rcmp); -# endif free(rep); *pt1 = *str; paxwarn(1, "Invalid replacement string option %s", str); @@ -865,9 +835,7 @@ rep_name(char *name, int *nlen, int prnt) char *rpt; int found = 0; int res; -# ifndef NET2_REGEX regmatch_t pm[MAXSUBEXP]; -# endif char nname[PAXPATHLEN+1]; /* final result of all replacements */ char buf1[PAXPATHLEN+1]; /* where we work on the name */ @@ -894,11 +862,7 @@ rep_name(char *name, int *nlen, int prnt) * check for a successful substitution, if not go to * the next pattern, or cleanup if we were global */ -# ifdef NET2_REGEX - if (regexec(pt->rcmp, inpt) == 0) -# else if (regexec(&(pt->rcmp), inpt, MAXSUBEXP, pm, 0) != 0) -# endif break; /* @@ -909,11 +873,7 @@ rep_name(char *name, int *nlen, int prnt) * do not create a string too long). */ found = 1; -# ifdef NET2_REGEX - rpt = pt->rcmp->startp[0]; -# else rpt = inpt + pm[0].rm_so; -# endif while ((inpt < rpt) && (outpt < endpt)) *outpt++ = *inpt++; @@ -926,12 +886,8 @@ rep_name(char *name, int *nlen, int prnt) * replacement string and place it the prefix in the * final output. If we have problems, skip it. */ -# ifdef NET2_REGEX - if ((res = resub(pt->rcmp,pt->nstr,outpt,endpt)) < 0) { -# else if ((res = resub(&(pt->rcmp),pm,inpt,pt->nstr,outpt,endpt)) < 0) { -# endif if (prnt) paxwarn(1, "Replacement name error %s", name); @@ -949,11 +905,7 @@ rep_name(char *name, int *nlen, int prnt) * the final result. Make sure we do not overrun the * output buffer */ -# ifdef NET2_REGEX - inpt = pt->rcmp->endp[0]; -# else inpt += pm[0].rm_eo - pm[0].rm_so; -# endif if ((outpt == endpt) || (*inpt == '\0')) break; @@ -1012,55 +964,6 @@ rep_name(char *name, int *nlen, int prnt) return(0); } -#ifdef NET2_REGEX -/* - * resub() - * apply the replacement to the matched expression. expand out the old - * style ed(1) subexpression expansion. - * Return: - * -1 if error, or the number of characters added to the destination. - */ - -static int -resub(regexp *prog, char *src, char *dest, char *destend) -{ - char *spt; - char *dpt; - char c; - int no; - int len; - - spt = src; - dpt = dest; - while ((dpt < destend) && ((c = *spt++) != '\0')) { - if (c == '&') - no = 0; - else if ((c == '\\') && (*spt >= '0') && (*spt <= '9')) - no = *spt++ - '0'; - else { - if ((c == '\\') && ((*spt == '\\') || (*spt == '&'))) - c = *spt++; - *dpt++ = c; - continue; - } - if ((prog->startp[no] == NULL) || (prog->endp[no] == NULL) || - ((len = prog->endp[no] - prog->startp[no]) <= 0)) - continue; - - /* - * copy the subexpression to the destination. - * fail if we run out of space or the match string is damaged - */ - if (len > (destend - dpt)) - len = destend - dpt; - if (l_strncpy(dpt, prog->startp[no], len) != len) - return(-1); - dpt += len; - } - return(dpt - dest); -} - -#else /* * resub() @@ -1127,4 +1030,3 @@ resub(regex_t *rp, regmatch_t *pm, char *orig, char *src, char *dest, } return(dpt - dest); } -#endif diff --git a/bin/pax/pat_rep.h b/bin/pax/pat_rep.h index 7def28d36e30..8560bfb77cf1 100644 --- a/bin/pax/pat_rep.h +++ b/bin/pax/pat_rep.h @@ -31,9 +31,6 @@ * 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. - * - * @(#)pat_rep.h 8.1 (Berkeley) 5/31/93 - * $FreeBSD$ */ /* @@ -41,11 +38,7 @@ */ typedef struct replace { char *nstr; /* the new string we will substitute with */ -# ifdef NET2_REGEX - regexp *rcmp; /* compiled regular expression used to match */ -# else regex_t rcmp; /* compiled regular expression used to match */ -# endif int flgs; /* print conversions? global in operation? */ #define PRNT 0x1 #define GLOB 0x2 diff --git a/bin/pax/pax.1 b/bin/pax/pax.1 index 2cc7a694a710..0981e9c0ae77 100644 --- a/bin/pax/pax.1 +++ b/bin/pax/pax.1 @@ -30,10 +30,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)pax.1 8.4 (Berkeley) 4/18/94 -.\" $FreeBSD$ -.\" -.Dd December 29, 2018 +.Dd October 19, 2022 .Dt PAX 1 .Os .Sh NAME @@ -800,7 +797,7 @@ option is also used, the resulting file may contain fewer .Ar bytes , according to the compressibility of the archive contents. See -.Xr zip 1 +.Xr zip 1 Pq Pa ports/archivers/zip if compressed volumes of predictable size are required. .Pp .Em Warning : @@ -933,28 +930,31 @@ changed during a specified time range will be archived). A time range is made up of six different fields and each field must contain two digits. The format is: -.Dl [yy[mm[dd[hh]]]]mm[.ss] +.Pp +.Dl [[[[[cc]yy]mm]dd]HH]MM[.SS] +.Pp Where -.Cm yy +.Ar cc +is the first two digits of the year (the century), +.Ar yy is the last two digits of the year, the first -.Cm mm +.Ar mm is the month (from 01 to 12), -.Cm dd +.Ar dd is the day of the month (from 01 to 31), -.Cm hh +.Ar HH is the hour of the day (from 00 to 23), -the second -.Cm mm +.Ar MM is the minute (from 00 to 59), and -.Cm ss +.Ar SS is the seconds (from 00 to 59). The minute field -.Cm mm +.Ar MM is required, while the other fields are optional and must be added in the following order: -.Dl Cm hh , dd , mm , yy . +.Ar HH , dd , mm , yy , cc . The .Cm ss field may be added independently of the other fields. diff --git a/bin/pax/pax.c b/bin/pax/pax.c index 4f7456f31a78..e8e758f16650 100644 --- a/bin/pax/pax.c +++ b/bin/pax/pax.c @@ -33,20 +33,6 @@ * SUCH DAMAGE. */ -#if 0 -#ifndef lint -static char const copyright[] = -"@(#) Copyright (c) 1992, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)pax.c 8.2 (Berkeley) 4/18/94"; -#endif /* not lint */ -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <sys/stat.h> #include <sys/time.h> @@ -83,7 +69,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 Dflag; /* same as uflag except inode change time */ +int Dflag; /* same as uflag except for inode change time */ int Hflag; /* follow command line symlinks (write only) */ int Lflag; /* follow symlinks when writing */ int Oflag; /* limit to single volume */ @@ -392,7 +378,7 @@ gen_init(void) /* * signal handling to reset stored directory times and modes. Since * we deal with broken pipes via failed writes we ignore it. We also - * deal with any file size limit thorough failed writes. Cpu time + * deal with any file size limit through failed writes. Cpu time * limits are caught and a cleanup is forced. */ if ((sigemptyset(&s_mask) < 0) || (sigaddset(&s_mask, SIGTERM) < 0) || diff --git a/bin/pax/pax.h b/bin/pax/pax.h index 530f8aa0d33d..a50da55a921c 100644 --- a/bin/pax/pax.h +++ b/bin/pax/pax.h @@ -31,9 +31,6 @@ * 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. - * - * @(#)pax.h 8.2 (Berkeley) 4/18/94 - * $FreeBSD$ */ /* diff --git a/bin/pax/sel_subs.c b/bin/pax/sel_subs.c index 4c0d09e4eb7f..ccbb77ccbb5c 100644 --- a/bin/pax/sel_subs.c +++ b/bin/pax/sel_subs.c @@ -33,28 +33,23 @@ * SUCH DAMAGE. */ -#ifndef lint -#if 0 -static char sccsid[] = "@(#)sel_subs.c 8.1 (Berkeley) 5/31/93"; -#endif -#endif /* not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <sys/time.h> #include <sys/stat.h> -#include <pwd.h> + +#include <ctype.h> #include <grp.h> +#include <pwd.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <strings.h> -#include <stdlib.h> + #include "pax.h" #include "sel_subs.h" #include "extern.h" -static int str_sec(char *, time_t *); +static int str_sec(const char *, time_t *); static int usr_match(ARCHD *); static int grp_match(ARCHD *); static int trng_match(ARCHD *); @@ -89,7 +84,7 @@ sel_chk(ARCHD *arcn) * User/group selection routines * * Routines to handle user selection of files based on the file uid/gid. To - * add an entry, the user supplies either then name or the uid/gid starting with + * add an entry, the user supplies either the name or the uid/gid starting with * a # on the command line. A \# will escape the #. */ @@ -134,11 +129,7 @@ usr_add(char *str) } uid = (uid_t)pw->pw_uid; } else -# ifdef NET2_STAT - uid = (uid_t)atoi(str+1); -# else uid = (uid_t)strtoul(str+1, NULL, 10); -# endif endpwent(); /* @@ -235,11 +226,7 @@ grp_add(char *str) } gid = gr->gr_gid; } else -# ifdef NET2_STAT - gid = (gid_t)atoi(str+1); -# else gid = (gid_t)strtoul(str+1, NULL, 10); -# endif endgrent(); /* @@ -317,7 +304,7 @@ grp_match(ARCHD *arcn) * trng_add() * add a time range match to the time range list. * This is a non-standard pax option. Lower and upper ranges are in the - * format: [yy[mm[dd[hh]]]]mm[.ss] and are comma separated. + * format: [[[[[cc]yy]mm]dd]HH]MM[.SS] and are comma separated. * Time ranges are based on current time, so 1234 would specify a time of * 12:34 today. * Return: @@ -454,7 +441,7 @@ trng_add(char *str) return(0); out: - paxwarn(1, "Time range format is: [yy[mm[dd[hh]]]]mm[.ss][/[c][m]]"); + paxwarn(1, "Time range format is: [[[[[cc]yy]mm]dd]HH]MM[.SS][/[c][m]]"); return(-1); } @@ -528,80 +515,87 @@ trng_match(ARCHD *arcn) /* * str_sec() - * Convert a time string in the format of [yy[mm[dd[hh]]]]mm[.ss] to gmt - * seconds. Tval already has current time loaded into it at entry. + * Convert a time string in the format of [[[[[cc]yy]mm]dd]HH]MM[.SS] to + * seconds UTC. Tval already has current time loaded into it at entry. * Return: * 0 if converted ok, -1 otherwise */ static int -str_sec(char *str, time_t *tval) +str_sec(const char *p, time_t *tval) { struct tm *lt; - char *dot = NULL; + const char *dot, *t; + size_t len; + int bigyear; + int yearset; + + yearset = 0; + len = strlen(p); + + for (t = p, dot = NULL; *t; ++t) { + if (isdigit((unsigned char)*t)) + continue; + if (*t == '.' && dot == NULL) { + dot = t; + continue; + } + return(-1); + } lt = localtime(tval); - if ((dot = strchr(str, '.')) != NULL) { - /* - * seconds (.ss) - */ - *dot++ = '\0'; - if (strlen(dot) != 2) + + if (dot != NULL) { /* .SS */ + if (strlen(++dot) != 2) return(-1); - if ((lt->tm_sec = ATOI2(dot)) > 61) + lt->tm_sec = ATOI2(dot); + if (lt->tm_sec > 61) return(-1); + len -= 3; } else lt->tm_sec = 0; - switch (strlen(str)) { - case 10: - /* - * year (yy) - * watch out for year 2000 - */ - if ((lt->tm_year = ATOI2(str)) < 69) - lt->tm_year += 100; - str += 2; + switch (len) { + case 12: /* cc */ + bigyear = ATOI2(p); + lt->tm_year = (bigyear * 100) - 1900; + yearset = 1; /* FALLTHROUGH */ - case 8: - /* - * month (mm) - * watch out months are from 0 - 11 internally - */ - if ((lt->tm_mon = ATOI2(str)) > 12) + case 10: /* yy */ + if (yearset) { + lt->tm_year += ATOI2(p); + } else { + lt->tm_year = ATOI2(p); + if (lt->tm_year < 69) /* hack for 2000 ;-} */ + lt->tm_year += (2000 - 1900); + } + /* FALLTHROUGH */ + case 8: /* mm */ + lt->tm_mon = ATOI2(p); + if ((lt->tm_mon > 12) || !lt->tm_mon) return(-1); - --lt->tm_mon; - str += 2; + --lt->tm_mon; /* time struct is 0 - 11 */ /* FALLTHROUGH */ - case 6: - /* - * day (dd) - */ - if ((lt->tm_mday = ATOI2(str)) > 31) + case 6: /* dd */ + lt->tm_mday = ATOI2(p); + if ((lt->tm_mday > 31) || !lt->tm_mday) return(-1); - str += 2; /* FALLTHROUGH */ - case 4: - /* - * hour (hh) - */ - if ((lt->tm_hour = ATOI2(str)) > 23) + case 4: /* HH */ + lt->tm_hour = ATOI2(p); + if (lt->tm_hour > 23) return(-1); - str += 2; /* FALLTHROUGH */ - case 2: - /* - * minute (mm) - */ - if ((lt->tm_min = ATOI2(str)) > 59) + case 2: /* MM */ + lt->tm_min = ATOI2(p); + if (lt->tm_min > 59) return(-1); break; default: return(-1); } - /* - * convert broken-down time to GMT clock time seconds - */ + + /* convert broken-down time to UTC clock time seconds */ if ((*tval = mktime(lt)) == -1) return(-1); return(0); diff --git a/bin/pax/sel_subs.h b/bin/pax/sel_subs.h index 7e1ddeedcb87..55f672b4eed3 100644 --- a/bin/pax/sel_subs.h +++ b/bin/pax/sel_subs.h @@ -31,9 +31,6 @@ * 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. - * - * @(#)sel_subs.h 8.1 (Berkeley) 5/31/93 - * $FreeBSD$ */ /* @@ -57,7 +54,7 @@ typedef struct grpt { * data structure for storing user supplied time ranges (-T option) */ -#define ATOI2(s) ((((s)[0] - '0') * 10) + ((s)[1] - '0')) +#define ATOI2(ar) ((ar)[0] - '0') * 10 + ((ar)[1] - '0'); (ar) += 2; typedef struct time_rng { time_t low_time; /* lower inclusive time limit */ diff --git a/bin/pax/tables.c b/bin/pax/tables.c index 97d430cb742f..e1e7b7d6d43e 100644 --- a/bin/pax/tables.c +++ b/bin/pax/tables.c @@ -33,14 +33,6 @@ * SUCH DAMAGE. */ -#ifndef lint -#if 0 -static char sccsid[] = "@(#)tables.c 8.1 (Berkeley) 5/31/93"; -#endif -#endif /* not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <sys/time.h> #include <sys/stat.h> @@ -65,7 +57,7 @@ __FBSDID("$FreeBSD$"); * large archives. These database routines carefully combine memory usage and * temporary file storage in ways which will not significantly impact runtime * performance while allowing the largest possible archives to be handled. - * Trying to force the fit to the POSIX databases routines was not considered + * Trying to force the fit to the POSIX database routines was not considered * time well spent. */ @@ -311,9 +303,9 @@ lnk_end(void) * are stored in a scratch file and indexed by an in memory hash table. The * hash table is indexed by hashing the file path. The nodes in the table store * the length of the filename and the lseek offset within the scratch file - * where the actual name is stored. Since there are never any deletions to this - * table, fragmentation of the scratch file is never an issue. Lookups seem to - * not exhibit any locality at all (files in the database are rarely + * where the actual name is stored. Since there are never any deletions from + * this table, fragmentation of the scratch file is never an issue. Lookups + * seem to not exhibit any locality at all (files in the database are rarely * looked up more than once...). So caching is just a waste of memory. The * only limitation is the amount of scratch file space available to store the * path names. @@ -880,14 +872,14 @@ map_dev(ARCHD *arcn, u_long dev_mask, u_long ino_mask) /* * directory access/mod time reset table routines (for directories READ by pax) * - * The pax -t flag requires that access times of archive files to be the same + * The pax -t flag requires that access times of archive files be the same * before being read by pax. For regular files, access time is restored after * the file has been copied. This database provides the same functionality for * directories read during file tree traversal. Restoring directory access time * is more complex than files since directories may be read several times until * all the descendants in their subtree are visited by fts. Directory access * and modification times are stored during the fts pre-order visit (done - * before any descendants in the subtree is visited) and restored after the + * before any descendants in the subtree are visited) and restored after the * fts post-order visit (after all the descendants have been visited). In the * case of premature exit from a subtree (like from the effects of -n), any * directory entries left in this database are reset during final cleanup @@ -966,7 +958,7 @@ add_atdir(char *fname, dev_t dev, ino_t ino, time_t mtime, time_t atime) * return (the older entry always has the correct time). The only * way this will happen is when the same subtree can be traversed by * different args to pax and the -n option is aborting fts out of a - * subtree before all the post-order visits have been made). + * subtree before all the post-order visits have been made. */ indx = ((unsigned)ino) % A_TAB_SZ; if ((pt = atab[indx]) != NULL) { diff --git a/bin/pax/tables.h b/bin/pax/tables.h index fb5bc437b0a0..9c6f2f48ba89 100644 --- a/bin/pax/tables.h +++ b/bin/pax/tables.h @@ -31,9 +31,6 @@ * 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. - * - * @(#)tables.h 8.1 (Berkeley) 5/31/93 - * $FreeBSD$ */ /* diff --git a/bin/pax/tar.c b/bin/pax/tar.c index 3a458223bddd..8b551d84ccc3 100644 --- a/bin/pax/tar.c +++ b/bin/pax/tar.c @@ -33,14 +33,6 @@ * SUCH DAMAGE. */ -#ifndef lint -#if 0 -static char sccsid[] = "@(#)tar.c 8.2 (Berkeley) 4/18/94"; -#endif -#endif /* not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <sys/time.h> #include <sys/stat.h> @@ -57,9 +49,7 @@ __FBSDID("$FreeBSD$"); static u_long tar_chksm(char *, int); static char *name_split(char *, int); static int ul_oct(u_long, char *, int, int); -#ifndef NET2_STAT static int uqd_oct(u_quad_t, char *, int, int); -#endif /* * Routines common to all versions of tar @@ -190,7 +180,6 @@ ul_oct(u_long val, char *str, int len, int term) return(0); } -#ifndef NET2_STAT /* * uqd_oct() * convert an u_quad_t to an octal string. one of many oddball field @@ -244,7 +233,6 @@ uqd_oct(u_quad_t val, char *str, int len, int term) return(-1); return(0); } -#endif /* * tar_chksm() @@ -379,9 +367,9 @@ tar_rd(ARCHD *arcn, char *buf) */ if (tar_id(buf, BLKMULT) < 0) return(-1); + memset(arcn, 0, sizeof *arcn); arcn->org_name = arcn->name; arcn->sb.st_nlink = 1; - arcn->pat = NULL; /* * copy out the name and values in the stat buffer @@ -399,13 +387,8 @@ tar_rd(ARCHD *arcn, char *buf) 0xfff); arcn->sb.st_uid = (uid_t)asc_ul(hd->uid, sizeof(hd->uid), OCT); arcn->sb.st_gid = (gid_t)asc_ul(hd->gid, sizeof(hd->gid), OCT); -#ifdef NET2_STAT - arcn->sb.st_size = (off_t)asc_ul(hd->size, sizeof(hd->size), OCT); - arcn->sb.st_mtime = (time_t)asc_ul(hd->mtime, sizeof(hd->mtime), OCT); -#else arcn->sb.st_size = (off_t)asc_uqd(hd->size, sizeof(hd->size), OCT); arcn->sb.st_mtime = (time_t)asc_uqd(hd->mtime, sizeof(hd->mtime), OCT); -#endif arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime; /* @@ -413,8 +396,6 @@ tar_rd(ARCHD *arcn, char *buf) * to encode this as a directory */ pt = &(arcn->name[arcn->nlen - 1]); - arcn->pad = 0; - arcn->skip = 0; switch(hd->linkflag) { case SYMTYPE: /* @@ -451,8 +432,6 @@ tar_rd(ARCHD *arcn, char *buf) arcn->type = PAX_DIR; arcn->sb.st_mode |= S_IFDIR; arcn->sb.st_nlink = 2; - arcn->ln_name[0] = '\0'; - arcn->ln_nlen = 0; break; case AREGTYPE: case REGTYPE: @@ -460,8 +439,6 @@ tar_rd(ARCHD *arcn, char *buf) /* * If we have a trailing / this is a directory and NOT a file. */ - arcn->ln_name[0] = '\0'; - arcn->ln_nlen = 0; if (*pt == '/') { /* * it is a directory, set the mode for -v printing @@ -562,12 +539,12 @@ tar_wr(ARCHD *arcn) } /* - * copy the data out of the ARCHD into the tar header based on the type - * of the file. Remember many tar readers want the unused fields to be - * padded with zero. We set the linkflag field (type), the linkname - * (or zero if not used),the size, and set the padding (if any) to be - * added after the file data (0 for all other types, as they only have - * a header) + * Copy the data out of the ARCHD into the tar header based on the type + * of the file. Remember, many tar readers want all fields to be + * padded with zero so we zero the header first. We then set the + * linkflag field (type), the linkname, the size, and set the padding + * (if any) to be added after the file data (0 for all other types, + * as they only have a header). */ hd = &hdblk; l_strncpy(hd->name, arcn->name, sizeof(hd->name) - 1); @@ -609,13 +586,8 @@ tar_wr(ARCHD *arcn) */ hd->linkflag = AREGTYPE; memset(hd->linkname, 0, sizeof(hd->linkname)); -# ifdef NET2_STAT - if (ul_oct((u_long)arcn->sb.st_size, hd->size, - sizeof(hd->size), 1)) { -# else if (uqd_oct((u_quad_t)arcn->sb.st_size, hd->size, sizeof(hd->size), 1)) { -# endif paxwarn(1,"File is too large for tar %s", arcn->org_name); return(1); } @@ -743,10 +715,9 @@ ustar_rd(ARCHD *arcn, char *buf) */ if (ustar_id(buf, BLKMULT) < 0) return(-1); + memset(arcn, 0, sizeof *arcn); arcn->org_name = arcn->name; arcn->sb.st_nlink = 1; - arcn->pat = NULL; - arcn->nlen = 0; hd = (HD_USTAR *)buf; /* @@ -776,13 +747,8 @@ ustar_rd(ARCHD *arcn, char *buf) */ arcn->sb.st_mode = (mode_t)(asc_ul(hd->mode, sizeof(hd->mode), OCT) & 0xfff); -#ifdef NET2_STAT - arcn->sb.st_size = (off_t)asc_ul(hd->size, sizeof(hd->size), OCT); - arcn->sb.st_mtime = (time_t)asc_ul(hd->mtime, sizeof(hd->mtime), OCT); -#else arcn->sb.st_size = (off_t)asc_uqd(hd->size, sizeof(hd->size), OCT); arcn->sb.st_mtime = (time_t)asc_uqd(hd->mtime, sizeof(hd->mtime), OCT); -#endif arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime; /* @@ -799,15 +765,6 @@ ustar_rd(ARCHD *arcn, char *buf) arcn->sb.st_uid = (uid_t)asc_ul(hd->uid, sizeof(hd->uid), OCT); /* - * set the defaults, these may be changed depending on the file type - */ - arcn->ln_name[0] = '\0'; - arcn->ln_nlen = 0; - arcn->pad = 0; - arcn->skip = 0; - arcn->sb.st_rdev = (dev_t)0; - - /* * set the mode and PAX type according to the typeflag in the header */ switch(hd->typeflag) { @@ -1011,13 +968,8 @@ ustar_wr(ARCHD *arcn) memset(hd->devmajor, 0, sizeof(hd->devmajor)); memset(hd->devminor, 0, sizeof(hd->devminor)); arcn->pad = TAR_PAD(arcn->sb.st_size); -# ifdef NET2_STAT - if (ul_oct((u_long)arcn->sb.st_size, hd->size, - sizeof(hd->size), 3)) { -# else if (uqd_oct((u_quad_t)arcn->sb.st_size, hd->size, sizeof(hd->size), 3)) { -# endif paxwarn(1,"File is too long for ustar %s",arcn->org_name); return(1); } diff --git a/bin/pax/tar.h b/bin/pax/tar.h index 91c2400e35ca..806a9e9ef12c 100644 --- a/bin/pax/tar.h +++ b/bin/pax/tar.h @@ -31,9 +31,6 @@ * 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. - * - * @(#)tar.h 8.2 (Berkeley) 4/18/94 - * $FreeBSD$ */ /* diff --git a/bin/pax/tests/Makefile b/bin/pax/tests/Makefile index 8334fea3c747..1ebe2e3f7c9d 100644 --- a/bin/pax/tests/Makefile +++ b/bin/pax/tests/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - .include <bsd.own.mk> TAP_TESTS_PERL= legacy_test diff --git a/bin/pax/tests/Makefile.depend b/bin/pax/tests/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/bin/pax/tests/Makefile.depend +++ b/bin/pax/tests/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/bin/pax/tests/legacy_test.pl b/bin/pax/tests/legacy_test.pl index dabba42b3f31..1f41e93e5969 100644 --- a/bin/pax/tests/legacy_test.pl +++ b/bin/pax/tests/legacy_test.pl @@ -1,4 +1,3 @@ -# $FreeBSD$ use strict; use warnings; diff --git a/bin/pax/tty_subs.c b/bin/pax/tty_subs.c index ea524c451007..73424e12389a 100644 --- a/bin/pax/tty_subs.c +++ b/bin/pax/tty_subs.c @@ -33,14 +33,6 @@ * SUCH DAMAGE. */ -#ifndef lint -#if 0 -static char sccsid[] = "@(#)tty_subs.c 8.2 (Berkeley) 4/18/94"; -#endif -#endif /* not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> |