Home | History | Annotate | Download | only in pax
History log of /src/bin/pax/ftree.c
RevisionDateAuthorComments
 1.46  08-Sep-2024  rillig s/effect/affect/ in a few places
 1.45  08-Sep-2024  rillig fix a/an grammar in obvious cases
 1.44  05-Aug-2024  riastradh pax(1): Nix trailing whitespace.

No functional change intended.
 1.43  28-May-2023  lukem branches: 1.43.2;
pax: exit 0 if stdin filelist is used and empty

If copying a list of files from stdin, exit zero instead of non-zero
if there are no files supplied.

AFAICT, POSIX doesn't require a non-zero an error in this situation,
since there are no files to not match.

Fix from PR bin/41736 by Lloyd Parkes.
 1.42  27-Sep-2012  christos branches: 1.42.32; 1.42.34; 1.42.42;
deal properly with empty lines in spec file
 1.41  20-Mar-2012  matt branches: 1.41.2;
Use C89 function definitions
 1.40  14-Feb-2009  lukem branches: 1.40.6; 1.40.8;
fix -Wsign-compare issues
 1.39  28-Apr-2008  martin branches: 1.39.6; 1.39.8;
Remove clause 3 and 4 from TNF licenses
 1.38  24-Feb-2008  joerg branches: 1.38.2;
Kill pre-4.4BSD compat code.
 1.37  18-Feb-2008  simonb branches: 1.37.2;
Set "ftent" to NULL in in ftree_arg() after we call fts_close(), so that
it isn't used later on in ftree_sel() after it's been free'd.

OK christos@ (and for the interesting test case).
 1.36  10-Jan-2008  tls Teach set_ftime about symbolic links, because it has to know: on some
Linux systems, when we build as a tool we think we have lutimes but it
doesn't work on some filesystems at runtime. A bit ugly but effective
and without use of AC_TRY_RUN in the tool build. Tidier (than mine)
set_ftime reorganization from christos.
 1.35  29-Apr-2007  msaitoh branches: 1.35.4;
fix typos
 1.34  11-Feb-2006  dsl branches: 1.34.4;
Change all the 'return(x)' to 'return c'.
Makes some other searches I want to do a bit easier.
 1.33  24-Sep-2005  dsl Don't leave arcn->org_name pointing to ftent->fts_path, if we being cpio
then ftent is freed just below. Take a copy of the name and point org_name
at the copy.
Should fix PR/30627 (the fix in the PR will break pax and tar!)
 1.32  02-Jul-2004  christos remove stray debugging left from last commit.
 1.31  20-Jun-2004  jmc Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.30  19-Jun-2004  christos add -0 argument to handle nul separated file lists.
 1.29  27-Oct-2003  lukem branches: 1.29.2;
Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.28  13-Oct-2003  agc Move Keith Muller's code from a 4-clause to a 3-clause licence by removing
the advertising clause. Diffs provided in PR 22397 by Joel Baker, confirmed
to the board by Keith Muller.
 1.27  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22249, verified by myself.
 1.26  23-Jun-2003  christos spelling
 1.25  09-May-2003  itojun use sizeof for safety
 1.24  21-Apr-2003  christos PR/21253: Manuel Bouyer: cpio should never descend on a directory; even on
the first one.
 1.23  19-Oct-2002  provos use readlink with bufsize - 1; approved thorpej.
 1.22  12-Oct-2002  christos merge OpenBSD changes:
- correct -C processing
- add ability to read filenames and flags from a file
- don't print dangerous escape sequences to the terminal
- use strlcpy/strncpy properly.
- handle tmpfile creation better.
- improve documentation of options.
- handle stdout/stderr list selection correctly.
- kill gzip when we get interrupted.
- simplify gzip setup.
- add more flags to programs.

additional changes:
- librmt processing.
- set POSIXLY_CORRECT in options parsing.
- prevent more string overruns.
- support -T

we don't turn the switch on to replace tar and cpio yet.
 1.21  28-Jun-2002  lukem Change how "cd .." is handled in next_file() with -M, to ensure that curdir[]
isn't addressed with a negative offset when back at the top of the tree.
This caused pax -M on sparc64 to generate corrupt tar files.
Problem found by Tim Goodwin <tjg@star.le.ac.uk> in [bin/17412].
 1.20  20-Apr-2002  lukem branches: 1.20.2;
- Directories marked `optional' won't be stored, even though their
contents will be.
- Document that `optional' faked-up entries won't be created.
 1.19  12-Apr-2002  lukem If an entry is in the specfile but not in the underlying file system, and it's
marked "optional", don't add it.
 1.18  02-Feb-2002  lukem - don't compile in support for -M (mtree specfile input) or -N dbdir
(alternate directory for id info) if SMALL is defined
- enable -DSMALL and remove unused objects if CRUNCHEDPROG is defined
- minor cleanup in next_file() (preparation for future work)
 1.17  31-Jan-2002  tv Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.
 1.16  29-Jan-2002  tv Make almost all tools compile and run properly on non-NetBSD hosts. (In
particular, most tools now run correctly on Solaris 7.)
 1.15  26-Oct-2001  lukem improve previous; use %lu and (u_long) to print size_t
 1.14  26-Oct-2001  lukem Cast size_t's to (int) when printing as %d; appeases the sparc port.
Found by Rob Windsor in [bin/14362].
 1.13  25-Oct-2001  lukem minor improvements in wording and flag testing
 1.12  25-Oct-2001  lukem Implement -M flag: During a write or copy operation, treat the list of
files on standard input as an mtree(8) `specfile' specification, and
write or copy only those items in the specfile.

If the file exists in the underlying file system, its permissions and
modification time will be used unless specifically overridden by the
specfile. An error will be raised if the type of entry in the specfile
conflicts with that of an existing file.

Otherwise, it is necessary to specify at least the following parameters
in the specfile: type, mode, gname or gid, and uname or uid, device
(in the case of block or character devices), and link (in the case of
symbolic links). If time isn't provided, the current time will be used.
 1.11  25-Oct-2001  lukem - ansi KNF (just remove all the #ifndef __STDC__ prototype junk,
leaving the ansi stuff)
- use longlong_t instead of quad_t (etc), and rename *uqd*() -> *ull*()
- clean up the NET2_STAT stuff similar to ftpd; provide #defines and
macros which select which cast to use, etc
- clean up the NET2_FTS and NET2_REGEX #define use
 1.10  17-Feb-2000  itohy Cleanup and fix typos.
Partially from FreeBSD.
 1.9  22-Oct-1999  is Implement positional -C argument to tar.
 1.8  28-Jul-1998  mycroft branches: 1.8.4;
Use the uid/gid caching moved into libc. Fixed a memory leak!
 1.7  06-Mar-1998  mrg - implement -C and -l for pax-as-tar, as inspried by GNU tar.
- minor cleanups to the options parsing code.
- add a cpio frontend.

note: a few GNU/svr4 cpio options are not supported yet (#ifdef
notyet), however all x/open ones are.
 1.6  20-Jul-1997  christos - Rename local warn so tty_warn that we can include <err.h> since this program
uses err() and errx().
- Fix printf format strings.
- Added WARNS=1; note
- Added missing prototypes.
- Split overloaded trail function into trail() and subtrail().
 1.5  11-Jan-1997  tls kill 'register'
 1.4  21-Mar-1995  cgd convert to new RCS id conventions.
 1.3  14-Jun-1994  mycroft Fix up RCS ids.
 1.2  13-Jun-1994  jtc Add RCS ID's
 1.1  13-Jun-1994  jtc branches: 1.1.1;
Initial revision
 1.1.1.1  13-Jun-1994  jtc From 4.4 lite
 1.8.4.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.20.2.3  16-Jun-2004  jmc fix botched pullup from ticket #1021 and make sure this compiles on
non-NetBSD hosts again. Also fixes PR#24481
 1.20.2.2  07-Apr-2004  jmc Pullup rev 1.22-1.29 (requested by rafal in ticket #1021)

Pullup pax to current version on trunk. Includes many fixes.
 1.20.2.1  28-Jun-2002  lukem Pull up revision 1.21 (requested by lukem in ticket #388):
Change how "cd .." is handled in next_file() with -M, to ensure that curdir[]
isn't addressed with a negative offset when back at the top of the tree.
This caused pax -M on sparc64 to generate corrupt tar files.
Problem found by Tim Goodwin <tjg@star.le.ac.uk> in [bin/17412].
 1.29.2.1  22-Jun-2004  tron branches: 1.29.2.1.2;
Pull up revision 1.31 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.29.2.1.2.1  23-Jul-2005  snj Apply patch (requested by riz in ticket #5512):
Sync pax with HEAD of 2005-07-22.
 1.34.4.1  23-Oct-2012  riz Pull up following revision(s) (requested by msaitoh in ticket #1459):
bin/pax/ftree.c: revision 1.42
deal properly with empty lines in spec file
 1.35.4.1  23-Mar-2008  matt sync with HEAD
 1.37.2.1  24-Mar-2008  keiichi sync with head.
 1.38.2.1  18-May-2008  yamt sync with head.
 1.39.8.1  13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.39.6.1  17-Oct-2012  bouyer Pull up following revision(s) (requested by msaitoh in ticket #1799):
bin/pax/ftree.c: revision 1.42
deal properly with empty lines in spec file
 1.40.8.1  17-Oct-2012  riz Pull up following revision(s) (requested by msaitoh in ticket #586):
bin/pax/ftree.c: revision 1.42
deal properly with empty lines in spec file
 1.40.6.2  30-Oct-2012  yamt sync with head
 1.40.6.1  17-Apr-2012  yamt sync with head
 1.41.2.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.42.42.1  07-Aug-2024  martin Pull up following revision(s) (requested by riastradh in ticket #776):

bin/pax/buf_subs.c: revision 1.31
tests/bin/pax/t_pax.sh: revision 1.3
tests/bin/pax/t_pax.sh: revision 1.4
tests/bin/pax/t_pax.sh: revision 1.5
tests/bin/pax/t_pax.sh: revision 1.6
tests/bin/pax/t_pax.sh: revision 1.7
bin/pax/extern.h: revision 1.61
bin/pax/pax.c: revision 1.50
bin/pax/pax.c: revision 1.51
bin/pax/file_subs.c: revision 1.65
bin/pax/ftree.c: revision 1.43
bin/pax/ar_subs.c: revision 1.58

pax: exit 0 if stdin filelist is used and empty

If copying a list of files from stdin, exit zero instead of non-zero
if there are no files supplied.

AFAICT, POSIX doesn't require a non-zero an error in this situation,
since there are no files to not match.

Fix from PR bin/41736 by Lloyd Parkes.

pax: don't overwrite destination if -r -w copy fails

Add more error handling to pax -r -w so that any failure
during the copy to the temporary file (including a failed flush)
prevents any existing destination file from being replaced
with the partial (including possibly empty) temporary file.

The partial temporary file is removed. pax still exists non-zero.
Thanks to Michael van Elst (mlelstv@) for the analysis
of the problem in the PR.
Should fix PR misc/33753.

tests/bin/pax: Add test for pax list in an ungettable cwd.
The list operation has no need to touch the file system, so it should
have no need for open(".") or getcwd() to succeed.

PR bin/44498: tar(1) unnecessarily demands that getcwd() work
(The PR was filed about tar(1), which is now bsdtar by default, but
the issue applies to pax(1) too and would continue to apply to tar(1)
if you set MKBSDTAR=no.)
pax(1): Don't require open(".") or getcwd to work for list operation.

PR 44498: tar(1) unnecessarily demands that getcwd() work
tests/bin/pax: Test pax(1) succeeds with empty file list on stdin.

PR bin/41736: pax reports an error when copying zero files
tests/bin/pax: Add some more cwd-related test cases.

PR bin/44498: tar(1) unnecessarily demands that getcwd() work
pax(1): Only require getcwd if we're reading without --insecure.

No other paths use the result of getcwd.

PR bin/44498: tar(1) unnecessarily demands that getcwd() work
 1.42.34.1  07-Aug-2024  martin Pull up following revision(s) (requested by riastradh in ticket #1863):

bin/pax/buf_subs.c: revision 1.31
tests/bin/pax/t_pax.sh: revision 1.3
tests/bin/pax/t_pax.sh: revision 1.4
tests/bin/pax/t_pax.sh: revision 1.5
tests/bin/pax/t_pax.sh: revision 1.6
tests/bin/pax/t_pax.sh: revision 1.7
bin/pax/extern.h: revision 1.61
bin/pax/pax.c: revision 1.50
bin/pax/pax.c: revision 1.51
bin/pax/file_subs.c: revision 1.65
bin/pax/ftree.c: revision 1.43
bin/pax/ar_subs.c: revision 1.58

pax: exit 0 if stdin filelist is used and empty

If copying a list of files from stdin, exit zero instead of non-zero
if there are no files supplied.

AFAICT, POSIX doesn't require a non-zero an error in this situation,
since there are no files to not match.

Fix from PR bin/41736 by Lloyd Parkes.

pax: don't overwrite destination if -r -w copy fails

Add more error handling to pax -r -w so that any failure
during the copy to the temporary file (including a failed flush)
prevents any existing destination file from being replaced
with the partial (including possibly empty) temporary file.

The partial temporary file is removed. pax still exists non-zero.
Thanks to Michael van Elst (mlelstv@) for the analysis
of the problem in the PR.
Should fix PR misc/33753.

tests/bin/pax: Add test for pax list in an ungettable cwd.
The list operation has no need to touch the file system, so it should
have no need for open(".") or getcwd() to succeed.

PR bin/44498: tar(1) unnecessarily demands that getcwd() work
(The PR was filed about tar(1), which is now bsdtar by default, but
the issue applies to pax(1) too and would continue to apply to tar(1)
if you set MKBSDTAR=no.)
pax(1): Don't require open(".") or getcwd to work for list operation.

PR 44498: tar(1) unnecessarily demands that getcwd() work
tests/bin/pax: Test pax(1) succeeds with empty file list on stdin.

PR bin/41736: pax reports an error when copying zero files
tests/bin/pax: Add some more cwd-related test cases.

PR bin/44498: tar(1) unnecessarily demands that getcwd() work
pax(1): Only require getcwd if we're reading without --insecure.

No other paths use the result of getcwd.

PR bin/44498: tar(1) unnecessarily demands that getcwd() work
 1.42.32.2  21-Apr-2020  martin Ooops, restore accidently removed files from merge mishap
 1.42.32.1  21-Apr-2020  martin Sync with HEAD
 1.43.2.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed