Home | History | Annotate | only in /src/sbin/restore
History log of /src/sbin/restore
RevisionDateAuthorComments
 1.28 03-Jun-2023  lukem bsd.own.mk: rename GCC_NO_* to CC_WNO_*

Rename compiler-warning-disable variables from
GCC_NO_warning
to
CC_WNO_warning
where warning is the full warning name as used by the compiler.

GCC_NO_IMPLICIT_FALLTHRU is CC_WNO_IMPLICIT_FALLTHROUGH

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
 1.27 13-Oct-2019  mrg introduce some common variables for use in GCC warning disables:

GCC_NO_FORMAT_TRUNCATION -Wno-format-truncation (GCC 7/8)
GCC_NO_STRINGOP_TRUNCATION -Wno-stringop-truncation (GCC 8)
GCC_NO_STRINGOP_OVERFLOW -Wno-stringop-overflow (GCC 8)
GCC_NO_CAST_FUNCTION_TYPE -Wno-cast-function-type (GCC 8)

use these to turn off warnings for most GCC-8 complaints. many
of these are false positives, most of the real bugs are already
commited, or are yet to come.


we plan to introduce versions of (some?) of these that use the
"-Wno-error=" form, which still displays the warnings but does
not make it an error, and all of the above will be re-considered
as either being "fix me" (warning still displayed) or "warning
is wrong."
 1.26 06-Aug-2011  dholland branches: 1.26.42;
Add wrapper functions around hash algorithm operations to avoid
undefined behavior arising from illegal function casts. As a side
effect, no longer need -Wno-pointer-sign either.
 1.25 20-Jun-2011  mrg remove most of the remaining HAVE_GCC tests that are always true in
the modern world.
 1.24 29-Aug-2008  gmcgarry branches: 1.24.16;
Wrap compiler-specific flags with HAVE_GCC and HAVE_PCC as necessary. Add a few flags for PCC.
 1.23 11-May-2006  mrg branches: 1.23.20; 1.23.24;
sprinkle some -fno-strict-aliasing and -Wno-pointer-sign with GCC4.
 1.22 19-Aug-2002  lukem Use ${NETBSDSRCDIR}/some/path instead of ${.CURDIR}/../../some/path
 1.21 04-Feb-2001  christos revert previous change; not needed.
 1.20 04-Feb-2001  christos fix nested extern
 1.19 10-Oct-1997  christos CFLAGS->CPPFLAGS
 1.18 30-Jun-1997  lukem There's no need to install restore(8) setgid tty.
 1.17 27-May-1997  mrg remove the setuid bit.
 1.16 08-May-1997  gwr Back out the .PATH.c changes. The .depend problem (and others)
will be fixed using the new .NOPATH make feature instead.
 1.15 06-May-1997  gwr Use .PATH.c: ...
 1.14 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.13 22-Dec-1994  cgd specify man pages the new way.
 1.12 17-Jun-1994  mycroft Fix a couple of Makefile bogons.
 1.11 08-Jun-1994  mycroft Update from 4.4-Lite, with local changes.
 1.10 22-Dec-1993  cgd new version from CSRG, via BSDI, with fixes
 1.9 14-Nov-1993  cgd from Thomas Eberhardt <thomas@mathematik.uni-Bremen.de>:
Some reordering and modifications in the Makefiles for sh, dump,
restore to get dependicies right. The README in /usr/share/mk
states that it's a Bad Thing(tm) to add something after
.include <bsd.prog.mk>, but this seems the only way to get the
dependencies right.
 1.8 12-Nov-1993  cgd oops; fix that last
 1.7 12-Nov-1993  cgd add LDSTATIC
 1.6 01-Aug-1993  mycroft Add RCS identifiers.
 1.5 18-Jul-1993  mycroft Use ${COPY}, not -c for install.
 1.4 18-Apr-1993  mycroft Okay, so I was confused (but only a little).
 1.3 18-Apr-1993  mycroft Make rrestore target match normal program target.
(This should be in a separate directory, no?)
 1.2 08-Apr-1993  cgd make it copy when installing
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 13-Jun-1994  mycroft Import 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.23.24.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.23.20.1 28-Sep-2008  mjf Sync with HEAD.
 1.24.16.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.26.42.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.55 12-Dec-2022  chs apply this commit from FreeBSD:

commit 9dda00df7e8f9279a43d92758df6a7e10a9aed95
Author: Chuck Silvers <chs@FreeBSD.org>
Date: Mon Dec 12 08:14:17 2022 -0800

restore: fix restore of NFS4 ACLs

Changing the mode bits on a file with an NFS4 ACL results in the
NFS4 ACL being replaced by one matching the new mode bits being set,
so when restoring a file with an NFS4 ACL, set the owner/group/mode first
and then set the NFS4 ACL, so that setting the mode does not throw away
the ACL that we just set.

Reviewed by: mckusick
Differential Revision: https://reviews.freebsd.org/D37618
 1.54 10-Dec-2022  chs apply this change from FreeBSD:

commit c028393d7072f1f88efd8d6e6c77bb9b15b3f3b6
Author: Kirk McKusick <mckusick@FreeBSD.org>
Date: Fri Apr 11 21:48:14 2008 +0000

Correctly set file group when restore is run by a user other than root.
 1.53 23-Jun-2021  riastradh restore(8): Mark fail_dirtmp __dead to fix clang build.
 1.52 19-Jun-2021  christos Add external attribute dumping and restoring support from FreeBSD.
Does not fully work yet, attributes are being saved and restored correctly,
but don't appear in the restored files somehow.
 1.51 02-Mar-2015  enami Don't truncate at microseconds while preserving timestamps.

One of motivation of this change is to make the behavior of test(1)
-nt/ot with preserved copy (like cp -p) closer to the NetBSD 6.
Of course whether full timestamps are kept or not depends also on
underlying file system.

The ifdef added in mv(1) since existing ifdefs was our local change
to compile it on solaris (though I couldn't test it):
http://mail-index.netbsd.org/tech-userlevel/2014/11/28/msg008831.html
 1.50 09-Jun-2013  dholland branches: 1.50.6; 1.50.8;
Stick UFS_ in front of these symbols:
DIRBLKSIZ
DIRECTSIZ
DIRSIZ
OLDDIRFMT
NEWDIRFMT

Part of PR 47909.
 1.49 22-Jan-2013  dholland Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.
 1.48 07-Apr-2009  lukem branches: 1.48.6; 1.48.12;
fix sign-compare issues
 1.47 18-Feb-2009  yamt remove a useless cast.
 1.46 19-Aug-2005  christos branches: 1.46.30;
64 bit inode changes
 1.45 27-Jun-2005  christos add const
 1.44 27-Jun-2005  christos sprinkle const.
 1.43 17-Feb-2005  xtraeme Kill __P(), use ANSI function declarations.
 1.42 08-Jan-2005  fredb Make a judicious choice as to whether to apply the permissions
of the root inode of the dump to the current working directory,
rather than interrogate the user. Closes PR bin/24690. Reviewed
by bouyer, tron, imp.
 1.41 22-Oct-2004  bouyer Add an option (-M) to write a mtree specification (which needs to be passed
through sort before being feed to mtree) with file flags, instead of restoring
file flags at the same time as other attributes. Fix various issue with
schg, uchg, sappnd or uappnd flags which cause restore to fail in some case.
Discussed on tech-userlevel:
http://mail-index.netbsd.org/tech-userlevel/2004/10/12/0000.html
 1.40 05-Nov-2003  fvdl Fix byteswapping a direntry. From Wolfgang Solfrank.
 1.39 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.38 02-Apr-2003  fvdl Add support for UFS2. UFS2 is an enhanced FFS, adding support for
64 bit block pointers, extended attribute storage, and a few
other things.

This commit does not yet include the code to manipulate the extended
storage (for e.g. ACLs), this will be done later.

Originally written by Kirk McKusick and Network Associates Laboratories for
FreeBSD.
 1.37 09-May-2002  simonb Don't bother testing if a uint8_t is > 256 -- that test is always false.
 1.36 04-Jan-2002  lukem oops; another minor fix from rev 1.34 noticed by Simon Gerraty
 1.35 01-Nov-2001  lukem oops, remove temporary comment
 1.34 01-Nov-2001  lukem fix -Wshadow warnings
 1.33 12-May-1998  enami Don't actually set attributes of directory if -N flag is given.
 1.32 18-Mar-1998  bouyer Update for new headers.
 1.31 19-Oct-1997  mycroft Use futimes(2). Do {f,}utimes(2) *before* {f,}chflags(2), for obvious
reasons.
 1.30 16-Sep-1997  lukem resolve conflicts from lite-2 merge
 1.29 16-Sep-1997  mrg make these compile on the alpha after WARNS=1.
 1.28 15-Sep-1997  lukem * cleanup for WARNS=1
* fix use of .Nm
 1.27 06-Jul-1997  lukem as inspired by a commit message of Todd Miller <millert@cvs.openbsd.org>:
* cleanup a bit for -Wall
* use __progname instead of "restore"
 1.26 01-Jul-1997  lukem Support using $TMPDIR for rst{dir,modes}* files, so that large
restores can be done on machines with small /tmp's by setting TMPDIR
elsewhere. This shouldn't be a security issue as restore(8) isn't
set?id anymore.
 1.25 03-Jun-1997  lukem explicitly \0 terminate locname[] in treescan(). should fix [bin/2093]
 1.24 17-May-1997  pk * NULL => 0 (Arne Juul; PR#3629)
* Nuke spacoids
 1.23 15-Apr-1997  lukem use _PATH_DEFTAPE from <paths.h> instead of "pathnames.h"
cleanup references/examples to use /dev/rst* instead of /dev/rmt*
minor .Nm usage cleanup in man page
 1.22 19-Mar-1997  lukem * use mkstemp() instead of mktemp()
* remove "register" qualifiers
 1.21 30-Nov-1996  cgd patches from Tom I Helbekkmo <tih@nhh.no> to deal with type-size issues,
so this works (better, at least) on 64-bit machines (e.g. alpha).
 1.20 24-Oct-1996  lukem use unique temporary files for all operations except 'r' and 'R', which still
base temp files on dumpdate. explain why in the man page. fixes [bin/2870]
 1.19 27-Sep-1996  thorpej Use snprintf() rather than sprintf().
 1.18 27-Sep-1996  thorpej Back out last change (and re-open PR); the patch is incomplete, and
I realized it _just_ as CVS checked the file back in.
 1.17 27-Sep-1996  thorpej Make unique temporary file names.
From Luke Mewburn <lukem@supp.cpr.itg.telecom.com.au>, PR #2544.
 1.16 19-Jun-1995  cgd branches: 1.16.6;
stat structure POSIXification
 1.15 11-Jun-1995  mycroft Back out previous change.
 1.14 07-Jun-1995  cgd typeof(timeval.tv_sec) != time_t
 1.13 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.12 20-Feb-1995  mycroft Use atexit() rather than tweaking every exit() to call the cleanup function.
 1.11 28-Dec-1994  mycroft Mostly sync with CSRG.
 1.10 23-Sep-1994  mycroft Eliminate uses of some obsolete functions.
 1.9 18-Jun-1994  mycroft Simplify that code a little.
 1.8 18-Jun-1994  mycroft Fix a byte-order problem when reading directory entries from old file systems
that were on little-endian machines.
 1.7 08-Jun-1994  mycroft Update from 4.4-Lite, with local changes.
 1.6 17-May-1994  cgd copyright foo
 1.5 25-Apr-1994  cgd kill some #ifndefs
 1.4 22-Dec-1993  cgd new version from CSRG, via BSDI, with fixes
 1.3 03-Aug-1993  mycroft Add an #endif I forgot.
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 16-Sep-1997  lukem imported from lite-2
 1.1.1.2 13-Jun-1994  mycroft Import 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.16.6.1 06-Dec-1996  rat Pullup request from Chris G Demetriou <Chris_G_Demetriou@ux2.sp.cs.cmu.edu>

>Make dump and restore usable on the alpha
 1.46.30.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.48.12.2 23-Jun-2013  tls resync from head
 1.48.12.1 25-Feb-2013  tls resync with head
 1.48.6.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.48.6.1 23-Jan-2013  yamt sync with head
 1.50.8.1 03-Mar-2016  martin Pull up following revision(s) (requested by nakayama in ticket #1096):
bin/mv/mv.c: revision 1.44
bin/cp/utils.c: revision 1.43-1.44
lib/librumphijack/hijack.c: revision 1.112-1.115
usr.bin/touch/touch.c: revision 1.33
sbin/restore/tape.c: revision 1.68
sbin/restore/dirs.c: revision 1.51
Don't truncate at sub-microsecond while preserving timestamps.

One of motivation of this change is to make the behavior of test(1)
-nt/ot with preserved copy (like cp -p) closer to the NetBSD 6.
Of course whether full timestamps are kept or not depends also on
underlying file system.

The ifdef added in mv(1) since existing ifdefs was our local change
to compile it on solaris (though I couldn't test it):
http://mail-index.netbsd.org/tech-userlevel/2014/11/28/msg008831.html

Fix the name of failed function in warning message.

Hijack utimensat(2) so that t_vfs test passes after cp(1)/mv(1) are
changed to use the system call. Linux also has this system call, but
not tested this on linux.

Also hijack futimens(2) so that t_sh test passes.

Define a generic ATCALL() and use it to implement utimensat()
Make ATCALL() behave for absolute paths too.
 1.50.6.1 03-Mar-2016  martin Pull up following revision(s) (requested by nakayama in ticket #1096):
bin/mv/mv.c: revision 1.44
bin/cp/utils.c: revision 1.43-1.44
lib/librumphijack/hijack.c: revision 1.112-1.115
usr.bin/touch/touch.c: revision 1.33
sbin/restore/tape.c: revision 1.68
sbin/restore/dirs.c: revision 1.51
Don't truncate at sub-microsecond while preserving timestamps.

One of motivation of this change is to make the behavior of test(1)
-nt/ot with preserved copy (like cp -p) closer to the NetBSD 6.
Of course whether full timestamps are kept or not depends also on
underlying file system.

The ifdef added in mv(1) since existing ifdefs was our local change
to compile it on solaris (though I couldn't test it):
http://mail-index.netbsd.org/tech-userlevel/2014/11/28/msg008831.html

Fix the name of failed function in warning message.

Hijack utimensat(2) so that t_vfs test passes after cp(1)/mv(1) are
changed to use the system call. Linux also has this system call, but
not tested this on linux.

Also hijack futimens(2) so that t_sh test passes.

Define a generic ATCALL() and use it to implement utimensat()
Make ATCALL() behave for absolute paths too.
 1.16 19-Jun-2021  christos Add external attribute dumping and restoring support from FreeBSD.
Does not fully work yet, attributes are being saved and restored correctly,
but don't appear in the restored files somehow.
 1.15 16-Feb-2008  matt Fix some inconsisent/conflicting definitions and missing parameters
 1.14 27-Jun-2005  christos branches: 1.14.10; 1.14.12;
add const
 1.13 27-Jun-2005  christos sprinkle const.
 1.12 17-Feb-2005  xtraeme Kill __P(), use ANSI function declarations.
 1.11 22-Oct-2004  bouyer Add an option (-M) to write a mtree specification (which needs to be passed
through sort before being feed to mtree) with file flags, instead of restoring
file flags at the same time as other attributes. Fix various issue with
schg, uchg, sappnd or uappnd flags which cause restore to fail in some case.
Discussed on tech-userlevel:
http://mail-index.netbsd.org/tech-userlevel/2004/10/12/0000.html
 1.10 27-Jul-2004  enami Add -D flag which computes the digest of each regular files in the archive
using specified algorithm (currently md5, rmd160 or sha1) and write them
to standard output.
 1.9 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.8 01-Nov-2001  lukem remove arg name in prototype decl
 1.7 10-Oct-2000  is Format string cleanups by Bill Sommerfeld.
 1.6 15-Sep-1997  lukem branches: 1.6.4; 1.6.12;
* cleanup for WARNS=1
* fix use of .Nm
 1.5 06-Jul-1997  lukem as inspired by a commit message of Todd Miller <millert@cvs.openbsd.org>:
* cleanup a bit for -Wall
* use __progname instead of "restore"
 1.4 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.3 20-Feb-1995  mycroft Use atexit() rather than tweaking every exit() to call the cleanup function.
 1.2 08-Jun-1994  mycroft Update from 4.4-Lite, with local changes.
 1.1 22-Dec-1993  cgd branches: 1.1.1;
new version from CSRG, via BSDI, with fixes
 1.1.1.1 13-Jun-1994  mycroft Import 4.4-Lite version.
 1.6.12.1 18-Oct-2000  tv Pullup sbin string format fixes [is].
See "cvs log" for explicit revision numbers per file, from sommerfeld.
 1.6.4.1 10-Oct-2000  he Pull up revision 1.7 (requested by is):
Format string cleanup.
 1.14.12.1 18-Feb-2008  mjf Sync with HEAD.
 1.14.10.1 23-Mar-2008  matt sync with HEAD
 1.31 29-Aug-2021  christos Fix reversed test (thanks phone@)
 1.30 29-Aug-2021  christos fix wrong size (thanks mlelstv@)
 1.29 19-Jun-2021  christos Add external attribute dumping and restoring support from FreeBSD.
Does not fully work yet, attributes are being saved and restored correctly,
but don't appear in the restored files somehow.
 1.28 03-Feb-2019  mrg - add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
this case, and thus can't be marked __dead easily
 1.27 22-Jan-2013  dholland branches: 1.27.30;
Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.
 1.26 07-Apr-2009  lukem branches: 1.26.6; 1.26.12;
fix sign-compare issues
 1.25 18-Dec-2006  christos branches: 1.25.22;
Convert a couple of "(void)&" constructs to volatile.
Flag various unused parameters in restore and dump so that these will
compile with -Wextra. (Note: restore uses some stuff from dump.)
 1.24 19-Aug-2005  christos use d_fileno instead of d_ino for consistency
 1.23 19-Aug-2005  christos 64 bit inode changes
 1.22 27-Jun-2005  christos sprinkle const.
 1.21 17-Feb-2005  xtraeme Kill __P(), use ANSI function declarations.
 1.20 08-Jan-2005  fredb Make a judicious choice as to whether to apply the permissions
of the root inode of the dump to the current working directory,
rather than interrogate the user. Closes PR bin/24690. Reviewed
by bouyer, tron, imp.
 1.19 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.18 19-Feb-2001  cgd convert to use getprogname()
 1.17 04-Feb-2001  christos fix nested extern
 1.16 09-Feb-1999  erh Make quoted strings work. (don't set the high bit of each character)
 1.15 03-Jan-1999  lukem user friendly enhancments.
reworked from [bin/6710] by Brian Grayson <bgrayson@ece.utexas.edu>
 1.14 10-Jan-1998  enami Document some undocumented options (-d and -N) and commands
in interactive mode (?, xit and Debug).
 1.13 16-Sep-1997  lukem resolve conflicts from lite-2 merge
 1.12 15-Sep-1997  lukem * cleanup for WARNS=1
* fix use of .Nm
 1.11 06-Jul-1997  lukem as inspired by a commit message of Todd Miller <millert@cvs.openbsd.org>:
* cleanup a bit for -Wall
* use __progname instead of "restore"
 1.10 19-Mar-1997  lukem * use mkstemp() instead of mktemp()
* remove "register" qualifiers
 1.9 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.8 20-Feb-1995  mycroft Use atexit() rather than tweaking every exit() to call the cleanup function.
 1.7 30-Jan-1995  mycroft Don't mix stat flags and inode flags.
 1.6 28-Dec-1994  mycroft Mostly sync with CSRG.
 1.5 23-Sep-1994  mycroft Eliminate uses of some obsolete functions.
 1.4 08-Jun-1994  mycroft Update from 4.4-Lite, with local changes.
 1.3 22-Dec-1993  cgd new version from CSRG, via BSDI, with fixes
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 16-Sep-1997  lukem imported from lite-2
 1.1.1.2 13-Jun-1994  mycroft Import 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.25.22.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.26.12.1 25-Feb-2013  tls resync with head
 1.26.6.1 23-Jan-2013  yamt sync with head
 1.27.30.1 10-Jun-2019  christos Sync with HEAD
 1.37 19-Jun-2021  christos Add external attribute dumping and restoring support from FreeBSD.
Does not fully work yet, attributes are being saved and restored correctly,
but don't appear in the restored files somehow.
 1.36 05-Apr-2020  joerg Fix depenency on common symbols in sbin.
 1.35 22-Jan-2013  dholland branches: 1.35.30;
Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.
 1.34 29-Aug-2011  joerg branches: 1.34.2; 1.34.8;
Use __dead
 1.33 20-Jul-2008  lukem Remove the \n and tabs from the __COPYRIGHT() strings.
(Tweak some to use a consistent format.)
 1.32 20-Mar-2006  christos branches: 1.32.20; 1.32.24;
Coverity CID 2305: Fix memory leak.
 1.31 27-Jun-2005  christos sprinkle const.
 1.30 17-Feb-2005  xtraeme Kill __P(), use ANSI function declarations.
 1.29 08-Jan-2005  fredb Make a judicious choice as to whether to apply the permissions
of the root inode of the dump to the current working directory,
rather than interrogate the user. Closes PR bin/24690. Reviewed
by bouyer, tron, imp.
 1.28 24-Oct-2004  wiz Sort options in usage.
 1.27 22-Oct-2004  bouyer Add an option (-M) to write a mtree specification (which needs to be passed
through sort before being feed to mtree) with file flags, instead of restoring
file flags at the same time as other attributes. Fix various issue with
schg, uchg, sappnd or uappnd flags which cause restore to fail in some case.
Discussed on tech-userlevel:
http://mail-index.netbsd.org/tech-userlevel/2004/10/12/0000.html
 1.26 27-Jul-2004  wiz Add -D to usage; shorten -b argument for usage's sake; format usage.
Man page nits.
 1.25 27-Jul-2004  enami Whitespace nits.
 1.24 27-Jul-2004  enami Add -D flag which computes the digest of each regular files in the archive
using specified algorithm (currently md5, rmd160 or sha1) and write them
to standard output.
 1.23 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.22 18-Nov-2002  enami Don't allocate struct entry one by one; it just wastes memory.
 1.21 19-Feb-2001  cgd convert to use getprogname()
 1.20 09-Jun-2000  enami Force -t or -N flag disables -u flag (but -t case is just for sanity).
 1.19 09-Nov-1999  drochner branches: 1.19.2;
Since our gcc doesn't warn about NULL format strings anymore, we can
fix the incorrect err(1, "%s", "") et al.
Closes PR bin/7592 by cgd.
 1.18 24-Jun-1998  christos branches: 1.18.6;
Add an unlink (-u) flag so that we can use this for installs.
 1.17 10-Jan-1998  enami Document some undocumented options (-d and -N) and commands
in interactive mode (?, xit and Debug).
 1.16 16-Sep-1997  lukem resolve conflicts from lite-2 merge
 1.15 15-Sep-1997  lukem * cleanup for WARNS=1
* fix use of .Nm
 1.14 06-Jul-1997  lukem as inspired by a commit message of Todd Miller <millert@cvs.openbsd.org>:
* cleanup a bit for -Wall
* use __progname instead of "restore"
 1.13 01-Jul-1997  lukem Support using $TMPDIR for rst{dir,modes}* files, so that large
restores can be done on machines with small /tmp's by setting TMPDIR
elsewhere. This shouldn't be a security issue as restore(8) isn't
set?id anymore.
 1.12 15-Apr-1997  lukem use _PATH_DEFTAPE from <paths.h> instead of "pathnames.h"
cleanup references/examples to use /dev/rst* instead of /dev/rmt*
minor .Nm usage cleanup in man page
 1.11 15-Mar-1996  scottr Be more paranoid with our effective uid.
 1.10 06-Feb-1996  mrg support $TAPE.
 1.9 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.8 21-Feb-1995  mycroft Document the getopt(3) option syntax, and some other documentation cleanup.
 1.7 20-Feb-1995  mycroft Use atexit() rather than tweaking every exit() to call the cleanup function.
 1.6 20-Feb-1995  mycroft Fix core dumps on certain types of invalid options.
 1.5 28-Dec-1994  mycroft Mostly sync with CSRG.
 1.4 08-Jun-1994  mycroft Update from 4.4-Lite, with local changes.
 1.3 22-Dec-1993  cgd new version from CSRG, via BSDI, with fixes
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 16-Sep-1997  lukem imported from lite-2
 1.1.1.2 13-Jun-1994  mycroft Import 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.18.6.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.19.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.32.24.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.32.20.1 28-Sep-2008  mjf Sync with HEAD.
 1.34.8.1 25-Feb-2013  tls resync with head
 1.34.2.1 23-Jan-2013  yamt sync with head
 1.35.30.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.7 15-Apr-1997  lukem use _PATH_DEFTAPE from <paths.h> instead of "pathnames.h"
cleanup references/examples to use /dev/rst* instead of /dev/rmt*
minor .Nm usage cleanup in man page
 1.6 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.5 08-Jun-1994  mycroft Update from 4.4-Lite, with local changes.
 1.4 17-May-1994  cgd copyright foo
 1.3 22-Dec-1993  cgd new version from CSRG, via BSDI, with fixes
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 13-Jun-1994  mycroft Import 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.56 18-Jul-2018  wiz Remove superfluous macro.
 1.55 15-Jul-2018  dholland Document what rrestore is (was once) for. PR 53442.
CVS: ----------------------------------------------------------------------
 1.54 03-Jul-2017  wiz branches: 1.54.4; 1.54.6;
Remove workaround for ancient HTML generation code.
 1.53 30-Mar-2013  rodent s/user code/user mode/1
 1.52 30-Jan-2009  enami branches: 1.52.8; 1.52.14;
Use indent-synopsis instead of iS register. The latter is a register
used in BSD derived .Nm implementation.
 1.51 30-Apr-2007  tron Bump date because of last change.
 1.50 30-Apr-2007  tron Improve example of restoring a complete filesystem with "restore -r":
- NetBSD's "newfs" doesn't accept a second (non-option) argument.
Patch provided by Jeff Ito in PR bin/36241.
- Use "sd0" instead of "rp0" because NetBSD's doesnt have a disk driver
called "rp".
- Use "/dev/rst0" instead of "/dev/rst8". With NetBSD's device numbering
scheme a system would have to have 9 tape drives to get "/dev/rst8".
 1.49 11-Jan-2005  wiz branches: 1.49.2; 1.49.10;
Bump date for recent changes.
 1.48 08-Jan-2005  fredb Make a judicious choice as to whether to apply the permissions
of the root inode of the dump to the current working directory,
rather than interrogate the user. Closes PR bin/24690. Reviewed
by bouyer, tron, imp.
 1.47 24-Oct-2004  wiz Sort options.
 1.46 23-Oct-2004  snj Kill trailing whitespace introduced in the last revision.
 1.45 23-Oct-2004  snj Bump date for last, fix a spelling error, sprinkle some Dq, change
some wording.
 1.44 22-Oct-2004  bouyer Add an option (-M) to write a mtree specification (which needs to be passed
through sort before being feed to mtree) with file flags, instead of restoring
file flags at the same time as other attributes. Fix various issue with
schg, uchg, sappnd or uappnd flags which cause restore to fail in some case.
Discussed on tech-userlevel:
http://mail-index.netbsd.org/tech-userlevel/2004/10/12/0000.html
 1.43 27-Jul-2004  wiz Add -D to usage; shorten -b argument for usage's sake; format usage.
Man page nits.
 1.42 27-Jul-2004  enami Add -D flag which computes the digest of each regular files in the archive
using specified algorithm (currently md5, rmd160 or sha1) and write them
to standard output.
 1.41 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.40 30-Jun-2003  wiz Quote punctuation so it gets marked up.
 1.39 26-May-2003  lukem * Document $RCMD_CMD in environ(7).
* Cross-reference rcmd(1), rcmd(3), and environ(7) as appropriate.

Should fix [bin/21670] from Geoff Wing.
 1.38 25-Feb-2003  wiz .Nm does not need a dummy argument ("") before punctuation or
for correct formatting of the SYNOPSIS any longer.
 1.37 04-Feb-2003  perry "Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".
 1.36 21-Dec-2002  wiz system with two ss, from Adrian Mrva.
 1.35 08-Feb-2002  ross Generate <>& symbolically. I'm avoiding .../dist/... directories for now.
 1.34 07-Dec-2001  wiz One '\' too many.
 1.33 16-Nov-2001  wiz Sort sections, use .Ic for a non-NetBSD program instead of .Xr.
 1.32 05-Jun-2001  wiz Drop arguments of .Os.
 1.31 09-Jun-2000  enami Force -t or -N flag disables -u flag (but -t case is just for sanity).
 1.30 23-May-2000  enami branches: 1.30.2;
Make sure that sentences end at the end of source line for better
formatted output.
 1.29 19-Nov-1999  enami Keep SEE ALSO list in alphabetical order.
 1.28 19-Nov-1999  enami Use .Ar macro for the files to be extracted.
 1.27 19-Nov-1999  enami Don't pass so many args to .Nd macro. It just overflows.
 1.26 01-Jul-1999  abs branches: 1.26.4;
Note the default tape device is taken from _PATH_DEFTAPE in /usr/include/paths.h
 1.25 28-Jun-1999  abs Default device is nrst0 not rst0
 1.24 27-Jul-1998  msaitoh branches: 1.24.2;
fix a small bug.
 1.23 24-Jun-1998  christos Add an unlink (-u) flag so that we can use this for installs.
 1.22 29-Apr-1998  fair fix bad .Xr references
 1.21 10-Jan-1998  enami Document some undocumented options (-d and -N) and commands
in interactive mode (?, xit and Debug).
 1.20 10-Jan-1998  enami Fix a typo; s/Complaints/Complains/ (pointed by Mike Long).
 1.19 11-Nov-1997  mrg add missing .Nm sections.
 1.18 20-Oct-1997  enami branches: 1.18.2;
Fix .Nm usage.
 1.17 16-Sep-1997  lukem resolve conflicts from lite-2 merge
 1.16 15-Sep-1997  lukem * cleanup for WARNS=1
* fix use of .Nm
 1.15 01-Jul-1997  lukem Support using $TMPDIR for rst{dir,modes}* files, so that large
restores can be done on machines with small /tmp's by setting TMPDIR
elsewhere. This shouldn't be a security issue as restore(8) isn't
set?id anymore.
 1.14 15-Apr-1997  lukem use _PATH_DEFTAPE from <paths.h> instead of "pathnames.h"
cleanup references/examples to use /dev/rst* instead of /dev/rmt*
minor .Nm usage cleanup in man page
 1.13 24-Dec-1996  mikel remove mkfs(8) xref; PR 3041
 1.12 24-Oct-1996  lukem use unique temporary files for all operations except 'r' and 'R', which still
base temp files on dumpdate. explain why in the man page. fixes [bin/2870]
 1.11 02-Feb-1996  phil Add /dev/rst* to FILES section. (pr 601) (Matches mt man page.)
 1.10 02-Feb-1996  phil Change default tape name in documentation from /dev/rmt? to /dev/rmt8 to
match pathnames.h. (pr #601)
 1.9 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.8 21-Feb-1995  mycroft Document the getopt(3) option syntax, and some other documentation cleanup.
 1.7 28-Dec-1994  mycroft Mostly sync with CSRG.
 1.6 08-Jun-1994  mycroft Update from 4.4-Lite, with local changes.
 1.5 14-Jan-1994  jtc Fix spelling errors
 1.4 22-Dec-1993  cgd new version from CSRG, via BSDI, with fixes
 1.3 05-Oct-1993  jtc Make sure all items in the SEE ALSO list are comma separated
 1.2 01-Aug-1993  mycroft Add RCS indentifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 16-Sep-1997  lukem imported from lite-2
 1.1.1.2 13-Jun-1994  mycroft Import 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.18.2.1 11-Nov-1997  mrg pull up from trunk: add missing .Nm sections.
 1.24.2.1 02-Jul-1999  perry pullup 1.24->1.25 (abs): Correct default device from /dev/rst0 to /dev/nrst0
 1.26.4.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.30.2.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.49.10.1 30-Apr-2007  bouyer Pull up following revision(s) (requested by tron in ticket #600):
sbin/restore/restore.8: revisions 1.50, 1.51
Improve example of restoring a complete filesystem with "restore -r":
- NetBSD's "newfs" doesn't accept a second (non-option) argument.
Patch provided by Jeff Ito in PR bin/36241.
- Use "sd0" instead of "rp0" because NetBSD's doesnt have a disk driver
called "rp".
- Use "/dev/rst0" instead of "/dev/rst8". With NetBSD's device numbering
scheme a system would have to have 9 tape drives to get "/dev/rst8".
Bump date because of last change.
 1.49.2.1 27-May-2007  bouyer Pull up following revision(s) (requested by tron in ticket #1771):
sbin/restore/restore.8: revisions 1.50 - 1.51
Improve example of restoring a complete filesystem with "restore -r":
- NetBSD's "newfs" doesn't accept a second (non-option) argument.
Patch provided by Jeff Ito in PR bin/36241.
- Use "sd0" instead of "rp0" because NetBSD's doesnt have a disk driver
called "rp".
- Use "/dev/rst0" instead of "/dev/rst8". With NetBSD's device numbering
scheme a system would have to have 9 tape drives to get "/dev/rst8".
Bump date because of last change.
 1.52.14.1 23-Jun-2013  tls resync from head
 1.52.8.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.54.6.1 10-Jun-2019  christos Sync with HEAD
 1.54.4.1 28-Jul-2018  pgoyette Sync with HEAD
 1.22 19-Jun-2021  christos Add external attribute dumping and restoring support from FreeBSD.
Does not fully work yet, attributes are being saved and restored correctly,
but don't appear in the restored files somehow.
 1.21 22-Jan-2013  dholland Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.
 1.20 18-Dec-2006  christos branches: 1.20.36; 1.20.42;
Convert a couple of "(void)&" constructs to volatile.
Flag various unused parameters in restore and dump so that these will
compile with -Wextra. (Note: restore uses some stuff from dump.)
 1.19 19-Aug-2005  christos 64 bit inode changes
 1.18 27-Jun-2005  christos add const
 1.17 27-Jun-2005  christos sprinkle const.
 1.16 17-Feb-2005  xtraeme Kill __P(), use ANSI function declarations.
 1.15 21-Oct-2003  fvdl Don't use NULL as a case value.
 1.14 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.13 18-Jan-2001  enami If possible, detect more case that file is missing on the tape.
XXX we still may lose if a file of highest inode number requested
XXX to extract was missing or one of multiple dump tape is lost.
 1.12 15-Sep-1997  lukem * cleanup for WARNS=1
* fix use of .Nm
 1.11 06-Jul-1997  lukem as inspired by a commit message of Todd Miller <millert@cvs.openbsd.org>:
* cleanup a bit for -Wall
* use __progname instead of "restore"
 1.10 04-Jul-1997  pk NULL => 0 (from Arne Juul; addendum to PR#3237)
 1.9 18-Jun-1997  lukem Fix problem with duplicate entries when changing from LEAF to NODE;
only the first link of a inode was being removed, not all of them.
From Kirk McKusick <mckusick@McKusick.COM> via thorpej
 1.8 19-Mar-1997  lukem * use mkstemp() instead of mktemp()
* remove "register" qualifiers
 1.7 27-Sep-1996  thorpej Use snprintf() rather than sprintf().
 1.6 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.5 28-Dec-1994  mycroft Mostly sync with CSRG.
 1.4 08-Jun-1994  mycroft Update from 4.4-Lite, with local changes.
 1.3 22-Dec-1993  cgd new version from CSRG, via BSDI, with fixes
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 16-Sep-1997  lukem imported from lite-2
 1.1.1.2 13-Jun-1994  mycroft Import 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.20.42.1 25-Feb-2013  tls resync with head
 1.20.36.1 23-Jan-2013  yamt sync with head
 1.23 19-Jun-2021  christos Add external attribute dumping and restoring support from FreeBSD.
Does not fully work yet, attributes are being saved and restored correctly,
but don't appear in the restored files somehow.
 1.22 05-Apr-2020  joerg Fix depenency on common symbols in sbin.
 1.21 27-Dec-2019  msaitoh s/opration/operation/
 1.20 06-Aug-2011  dholland branches: 1.20.42;
Add wrapper functions around hash algorithm operations to avoid
undefined behavior arising from illegal function casts. As a side
effect, no longer need -Wno-pointer-sign either.
 1.19 06-Aug-2011  dholland Simplify silly code and make it closer to type-safe. This causes amd64
gcc to reorder two pairs of instructions for some reason but the object
files are otherwise unchanged.
 1.18 27-Jun-2005  christos sprinkle const.
 1.17 08-Jan-2005  fredb Make a judicious choice as to whether to apply the permissions
of the root inode of the dump to the current working directory,
rather than interrogate the user. Closes PR bin/24690. Reviewed
by bouyer, tron, imp.
 1.16 22-Oct-2004  bouyer Add an option (-M) to write a mtree specification (which needs to be passed
through sort before being feed to mtree) with file flags, instead of restoring
file flags at the same time as other attributes. Fix various issue with
schg, uchg, sappnd or uappnd flags which cause restore to fail in some case.
Discussed on tech-userlevel:
http://mail-index.netbsd.org/tech-userlevel/2004/10/12/0000.html
 1.15 27-Jul-2004  enami Add -D flag which computes the digest of each regular files in the archive
using specified algorithm (currently md5, rmd160 or sha1) and write them
to standard output.
 1.14 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.13 02-Apr-2003  fvdl Add support for UFS2. UFS2 is an enhanced FFS, adding support for
64 bit block pointers, extended attribute storage, and a few
other things.

This commit does not yet include the code to manipulate the extended
storage (for e.g. ACLs), this will be done later.

Originally written by Kirk McKusick and Network Associates Laboratories for
FreeBSD.
 1.12 18-Nov-2002  enami Don't allocate struct entry one by one; it just wastes memory.
 1.11 24-Aug-2001  wiz heirarchy -> hierarchy
 1.10 24-Jun-1998  christos Add an unlink (-u) flag so that we can use this for installs.
 1.9 15-Sep-1997  lukem * cleanup for WARNS=1
* fix use of .Nm
 1.8 01-Jul-1997  lukem Support using $TMPDIR for rst{dir,modes}* files, so that large
restores can be done on machines with small /tmp's by setting TMPDIR
elsewhere. This shouldn't be a security issue as restore(8) isn't
set?id anymore.
 1.7 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.6 28-Dec-1994  mycroft Mostly sync with CSRG.
 1.5 08-Jun-1994  mycroft Update from 4.4-Lite, with local changes.
 1.4 17-May-1994  cgd copyright foo
 1.3 22-Dec-1993  cgd new version from CSRG, via BSDI, with fixes
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 16-Sep-1997  lukem imported from lite-2
 1.1.1.2 13-Jun-1994  mycroft Import 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.20.42.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.3 22-Dec-1993  mycroft Clean up deleted files.
 1.2 01-Aug-1993  mycroft Add RCS indentifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 08-Jun-1994  mycroft Clean up deleted files.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.31 10-Feb-2024  andvar s/indicies/indices/ in comments.
 1.30 19-Jun-2021  christos Add external attribute dumping and restoring support from FreeBSD.
Does not fully work yet, attributes are being saved and restored correctly,
but don't appear in the restored files somehow.
 1.29 22-Jan-2013  dholland Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.
 1.28 16-Sep-2011  plunky branches: 1.28.2; 1.28.8;
NULL does not need a cast, here
 1.27 04-Jan-2011  wiz Fix fd leak. Found by cppcheck.
 1.26 12-May-2010  mbalmer Fix grammar in a line of output.
From Hywel Mallett via FreeBSD.
 1.25 07-Apr-2009  lukem fix sign-compare issues
 1.24 22-Feb-2009  yamt remove a useless cast.
 1.23 19-Aug-2005  christos branches: 1.23.28; 1.23.30;
64 bit inode changes
 1.22 27-Jun-2005  christos add const
 1.21 27-Jun-2005  christos sprinkle const.
 1.20 17-Feb-2005  xtraeme Kill __P(), use ANSI function declarations.
 1.19 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.18 25-Nov-2002  enami Also, don't allocate string entries one by one. Instead, allocate one page
and divide it, to reduce memory usage.
 1.17 18-Nov-2002  enami Typo in comment.
 1.16 18-Nov-2002  enami Don't allocate struct entry one by one; it just wastes memory.
 1.15 12-Aug-2002  itojun calloc() arg mistake. it's (nelem, size). from openbsd
 1.14 19-Jun-2001  wiz `existent', not `existant'
 1.13 16-Sep-1997  lukem resolve conflicts from lite-2 merge
 1.12 16-Sep-1997  mrg make these compile on the alpha after WARNS=1.
 1.11 15-Sep-1997  lukem * cleanup for WARNS=1
* fix use of .Nm
 1.10 19-Mar-1997  lukem * use mkstemp() instead of mktemp()
* remove "register" qualifiers
 1.9 30-Nov-1996  cgd patches from Tom I Helbekkmo <tih@nhh.no> to deal with type-size issues,
so this works (better, at least) on 64-bit machines (e.g. alpha).
 1.8 18-Mar-1995  cgd branches: 1.8.6;
convert to new RCS Id conventions; reduce my headache
 1.7 20-Feb-1995  mycroft Use atexit() rather than tweaking every exit() to call the cleanup function.
 1.6 28-Dec-1994  mycroft Mostly sync with CSRG.
 1.5 23-Sep-1994  mycroft Eliminate uses of some obsolete functions.
 1.4 08-Jun-1994  mycroft Update from 4.4-Lite, with local changes.
 1.3 22-Dec-1993  cgd new version from CSRG, via BSDI, with fixes
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 16-Sep-1997  lukem imported from lite-2
 1.1.1.2 13-Jun-1994  mycroft Import 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.8.6.1 06-Dec-1996  rat Pullup request from Chris G Demetriou <Chris_G_Demetriou@ux2.sp.cs.cmu.edu>

>Make dump and restore usable on the alpha
 1.23.30.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.23.28.1 21-Nov-2010  riz Pull up following revision(s) (requested by mbalmer in ticket #1397):
sbin/restore/symtab.c: revision 1.26
Fix grammar in a line of output.
From Hywel Mallett via FreeBSD.
 1.28.8.1 25-Feb-2013  tls resync with head
 1.28.2.1 23-Jan-2013  yamt sync with head
 1.75 05-Feb-2024  andvar triple "r" typos, mainly s/interrrupt/interrupt/ in comments and one definition.
 1.74 12-Dec-2022  chs apply this commit from FreeBSD:

commit 9dda00df7e8f9279a43d92758df6a7e10a9aed95
Author: Chuck Silvers <chs@FreeBSD.org>
Date: Mon Dec 12 08:14:17 2022 -0800

restore: fix restore of NFS4 ACLs

Changing the mode bits on a file with an NFS4 ACL results in the
NFS4 ACL being replaced by one matching the new mode bits being set,
so when restoring a file with an NFS4 ACL, set the owner/group/mode first
and then set the NFS4 ACL, so that setting the mode does not throw away
the ACL that we just set.

Reviewed by: mckusick
Differential Revision: https://reviews.freebsd.org/D37618
 1.73 10-Dec-2022  chs apply this change from FreeBSD:

commit c028393d7072f1f88efd8d6e6c77bb9b15b3f3b6
Author: Kirk McKusick <mckusick@FreeBSD.org>
Date: Fri Apr 11 21:48:14 2008 +0000

Correctly set file group when restore is run by a user other than root.
 1.72 05-May-2022  mrg include the filename in the panic message for missing data.

instead of merely seeing:
getfile: lost data
now this is seen:
getfile: lost data: ./usr/libdata/debug/usr/libexec/cc1.debug
 1.71 19-Jun-2021  christos Add external attribute dumping and restoring support from FreeBSD.
Does not fully work yet, attributes are being saved and restored correctly,
but don't appear in the restored files somehow.
 1.70 11-Mar-2021  msaitoh s/skiping/skipping/
 1.69 03-Sep-2020  bouyer If we hit an unknown header type (likely to be a corrupt record), and
the user choose to not abort, skip to the next header instead of trying
to use it.
This allowed me to recover files from a corrupt dump, instead of
getting a segfault.
 1.68 02-Mar-2015  enami Don't truncate at microseconds while preserving timestamps.

One of motivation of this change is to make the behavior of test(1)
-nt/ot with preserved copy (like cp -p) closer to the NetBSD 6.
Of course whether full timestamps are kept or not depends also on
underlying file system.

The ifdef added in mv(1) since existing ifdefs was our local change
to compile it on solaris (though I couldn't test it):
http://mail-index.netbsd.org/tech-userlevel/2014/11/28/msg008831.html
 1.67 22-Jan-2013  dholland branches: 1.67.8; 1.67.10;
Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.
 1.66 29-Aug-2011  joerg branches: 1.66.2; 1.66.8;
Use __dead
 1.65 06-Aug-2011  dholland Add wrapper functions around hash algorithm operations to avoid
undefined behavior arising from illegal function casts. As a side
effect, no longer need -Wno-pointer-sign either.
 1.64 06-Aug-2011  dholland Simplify silly code and make it closer to type-safe. This causes amd64
gcc to reorder two pairs of instructions for some reason but the object
files are otherwise unchanged.
 1.63 07-Apr-2009  lukem fix sign-compare issues
 1.62 18-Feb-2009  yamt remove a useless cast.
 1.61 26-Dec-2008  hannken branches: 1.61.2;
Make restore work for Linux dump volumes by ignoring extended attribute
records on these volumes. Tested with Centos 5.2.

Reviewed by: Manuel Bouyer <bouyer@netbsd.org>
 1.60 16-Feb-2008  matt branches: 1.60.4; 1.60.10;
Fix some inconsisent/conflicting definitions and missing parameters
 1.59 09-Feb-2007  hannken branches: 1.59.4; 1.59.6;
Add support for Solaris ufsdump volumes with more than 512*1024 inodes.
Here the bitmaps are written as

CLRI or BITS with c_count <= 512
ADDR* for the remaining blocks

Remove the bitmap handling from getfile(), remove xtrmap() and xtrmapskip().
Add new function getbitmap() modeled after getfile() that does bitmap
allocation, bitmap expansion and sets maxino.

Reviewed by: Manuel Bouyer <bouyer@netbsd.org>
 1.58 18-Dec-2006  christos Convert a couple of "(void)&" constructs to volatile.
Flag various unused parameters in restore and dump so that these will
compile with -Wextra. (Note: restore uses some stuff from dump.)
 1.57 30-Oct-2006  christos branches: 1.57.2;
find rmd160.h
 1.56 16-Oct-2006  christos c99 iniitializer
 1.55 25-Sep-2005  elad Use crypto/rmd160.h.
 1.54 19-Aug-2005  christos 64 bit inode changes
 1.53 27-Jun-2005  christos sprinkle const.
 1.52 17-Feb-2005  xtraeme branches: 1.52.2;
Kill __P(), use ANSI function declarations.
 1.51 22-Oct-2004  bouyer Add an option (-M) to write a mtree specification (which needs to be passed
through sort before being feed to mtree) with file flags, instead of restoring
file flags at the same time as other attributes. Fix various issue with
schg, uchg, sappnd or uappnd flags which cause restore to fail in some case.
Discussed on tech-userlevel:
http://mail-index.netbsd.org/tech-userlevel/2004/10/12/0000.html
 1.50 27-Jul-2004  enami Add -D flag which computes the digest of each regular files in the archive
using specified algorithm (currently md5, rmd160 or sha1) and write them
to standard output.
 1.49 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.48 02-Apr-2003  fvdl Add support for UFS2. UFS2 is an enhanced FFS, adding support for
64 bit block pointers, extended attribute storage, and a few
other things.

This commit does not yet include the code to manipulate the extended
storage (for e.g. ACLs), this will be done later.

Originally written by Kirk McKusick and Network Associates Laboratories for
FreeBSD.
 1.47 27-Mar-2003  taca Since "host" is used when RRESTORE is defined, enclose variable definition
with "#ifdef RRESTORE" and "#endif".
 1.46 25-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.45 19-Feb-2002  perseant Don't forget to update curfile, if tape begins with TS_ADDR type block.
In particular, this means that if one member (say the last member) of a tape
set begins with continuation blocks, restore will not consider that tape
to contain all the inodes (curfile.ino==0 at the beginning of the tape).

Close PR #15545.
 1.44 23-Dec-2001  lukem fix compile issues now that on-tape times are int32_t instead of time_t
 1.43 24-Jan-2001  enami Remove incorrect advice for lint; the control may return from panic().
 1.42 07-Jul-2000  enami Extract file flags of symbolic link.
 1.41 23-May-2000  enami Add comment and sanity check about why we need not to skip remaining
blocks if we are reading inode bitmaps.
 1.40 19-May-2000  enami Correctly extract the inode maps bigger than 512 tape blocks.
 1.39 27-Jan-2000  sommerfeld Fix PR9282: restore doesn't print dump header on dumps from host with
unset hostname.
 1.38 03-Jan-1999  lukem branches: 1.38.2;
user friendly enhancments.
reworked from [bin/6710] by Brian Grayson <bgrayson@ece.utexas.edu>
 1.37 24-Jun-1998  christos Add an unlink (-u) flag so that we can use this for installs.
 1.36 01-Apr-1998  kleink Need <time.h> for ctime() prototype.
 1.35 30-Mar-1998  mrg use static int, not just static
 1.34 13-Dec-1997  enami Fix the bug introduced in last change; pass IFCHR or IFBLK bit to
mknod(2) via mode.
 1.33 18-Nov-1997  enami Use file mode 0600 when creating special file or fifo.
Suggested by Charles M. Hannum.
 1.32 18-Nov-1997  enami Restore file attributes after extracting regular file. Fixes PR#4515
from stephen.ma@jtec.com.au:

- call getfile() before altering file attributes.
- open file with mode 0600 instead of 0666 so that file won't remain
group or world readable/writable even if getfile() terminated.
- also, move skipfile() before altering file attributes in IF{CHR,BLK} and
IFIFO case for symmetry (suggested by Charles M. Hannum).
 1.31 19-Oct-1997  mycroft branches: 1.31.2;
Use futimes(2). Do {f,}utimes(2) *before* {f,}chflags(2), for obvious
reasons.
 1.30 08-Oct-1997  enami Restore owner/group/mode/atime/mtime of symbolic links.
 1.29 16-Sep-1997  lukem resolve conflicts from lite-2 merge
 1.28 15-Sep-1997  lukem * cleanup for WARNS=1
* fix use of .Nm
 1.27 06-Jul-1997  lukem as inspired by a commit message of Todd Miller <millert@cvs.openbsd.org>:
* cleanup a bit for -Wall
* use __progname instead of "restore"
 1.26 15-Apr-1997  lukem use _PATH_DEFTAPE from <paths.h> instead of "pathnames.h"
cleanup references/examples to use /dev/rst* instead of /dev/rmt*
minor .Nm usage cleanup in man page
 1.25 19-Mar-1997  lukem * use mkstemp() instead of mktemp()
* remove "register" qualifiers
 1.24 26-Dec-1996  cjs Fix typo: PR bin/3059
 1.23 04-Dec-1996  mycroft Make sure to byte-swap all of the relevant fields; especially c_flags.
 1.22 30-Nov-1996  cgd When initializing 'fssize,' the size of the data buffer to be used when
writing data to the file system, if the "optimal" file system I/O
operation block size is less than TP_BSIZE, leave fssize alone (i.e.
at its default setting of MAXBSIZE). This was causing restore's
stack to be trashed, because the end-of-buffer checking/flushing code
around line 680 would never notice that the buffer was full (because
it'd be comparing a buffer segment index, which would always be >= 1, to
fssize / TP_BSIZE, which could be zero in that case), and would keep
filling and filling and filling...
 1.21 30-Nov-1996  cgd patches from Tom I Helbekkmo <tih@nhh.no> to deal with type-size issues,
so this works (better, at least) on 64-bit machines (e.g. alpha).
 1.20 15-Mar-1996  scottr branches: 1.20.4;
Be more paranoid with our effective uid.
 1.19 19-Jun-1995  cgd stat structure POSIXification
 1.18 11-Jun-1995  mycroft Back out previous change.
 1.17 07-Jun-1995  cgd typeof(timeval.tv_sec) != time_t
 1.16 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.15 20-Feb-1995  mycroft Use atexit() rather than tweaking every exit() to call the cleanup function.
 1.14 28-Dec-1994  mycroft Mostly sync with CSRG.
 1.13 23-Sep-1994  mycroft Eliminate uses of some obsolete functions.
 1.12 18-Sep-1994  mycroft Allow extracting FIFOs.
 1.11 08-Jun-1994  mycroft Update from 4.4-Lite, with local changes.
 1.10 17-May-1994  cgd copyright foo
 1.9 25-Apr-1994  cgd kill some #ifndefs
 1.8 02-Apr-1994  cgd just kill the cast completely
 1.7 01-Apr-1994  cgd bad cast
 1.6 01-Mar-1994  cgd Check correct header when looking at tape number.
from thomas@mathematik.uni-Bremen.de
 1.5 22-Dec-1993  cgd new version from CSRG, via BSDI, with fixes
 1.4 01-Aug-1993  mycroft Add RCS identifiers.
 1.3 20-Apr-1993  mycroft Fix message.
 1.2 25-Mar-1993  cgd restore didn't understand dirs which spanned more than one volume.
fixed by patch from Gene Stark (gene@stark.uucp).
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 16-Sep-1997  lukem imported from lite-2
 1.1.1.2 13-Jun-1994  mycroft Import 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.20.4.2 10-Dec-1996  mycroft From trunk:
Add some missing byte-swaps, so this works across endians.
 1.20.4.1 06-Dec-1996  rat Pullup request from Chris G Demetriou <Chris_G_Demetriou@ux2.sp.cs.cmu.edu>

>Make dump and restore usable on the alpha
 1.31.2.2 14-Dec-1997  mellon Pull rev 1.34 up from trunk (enami)
 1.31.2.1 18-Nov-1997  mellon Pull rev 1.32 and 1.33 up from trunk (enami)
 1.38.2.2 11-Oct-2000  he Pull up revisions 1.40-1.41 (requested by enami):
Make restore correctly handle large dumps with large inode maps.
Fixes PR#11188.
 1.38.2.1 31-Jan-2000  he Pull up revision 1.39 (requested by sommerfeld):
Print the header even on dumps from a system with an unset
host name. Fixes PR#9282.
 1.52.2.1 03-Mar-2007  bouyer Pull up following revision(s) (requested by hannken in ticket #1674):
sbin/restore/tape.c: revision 1.59
Add support for Solaris ufsdump volumes with more than 512*1024 inodes.
Here the bitmaps are written as
CLRI or BITS with c_count <= 512
ADDR* for the remaining blocks
Remove the bitmap handling from getfile(), remove xtrmap() and xtrmapskip().
Add new function getbitmap() modeled after getfile() that does bitmap
allocation, bitmap expansion and sets maxino.
Reviewed by: Manuel Bouyer <bouyer@netbsd.org>
 1.57.2.1 04-Mar-2007  bouyer Pull up following revision(s) (requested by hannken in ticket #483):
sbin/restore/tape.c: revision 1.59 via patch
Add support for Solaris ufsdump volumes with more than 512*1024 inodes.
Here the bitmaps are written as
CLRI or BITS with c_count <= 512
ADDR* for the remaining blocks
Remove the bitmap handling from getfile(), remove xtrmap() and xtrmapskip().
Add new function getbitmap() modeled after getfile() that does bitmap
allocation, bitmap expansion and sets maxino.
Reviewed by: Manuel Bouyer <bouyer@netbsd.org>
 1.59.6.1 18-Feb-2008  mjf Sync with HEAD.
 1.59.4.1 23-Mar-2008  matt sync with HEAD
 1.60.10.1 02-Jan-2009  snj Pull up following revision(s) (requested by hannken in ticket #210):
include/protocols/dumprestore.h: revision 1.15
sbin/restore/tape.c: revision 1.61
Make restore work for Linux dump volumes by ignoring extended attribute
records on these volumes. Tested with Centos 5.2.
Reviewed by: Manuel Bouyer <bouyer@netbsd.org>
 1.60.4.1 17-Jan-2009  mjf Sync with HEAD.
 1.61.2.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.66.8.1 25-Feb-2013  tls resync with head
 1.66.2.1 23-Jan-2013  yamt sync with head
 1.67.10.1 03-Mar-2016  martin Pull up following revision(s) (requested by nakayama in ticket #1096):
bin/mv/mv.c: revision 1.44
bin/cp/utils.c: revision 1.43-1.44
lib/librumphijack/hijack.c: revision 1.112-1.115
usr.bin/touch/touch.c: revision 1.33
sbin/restore/tape.c: revision 1.68
sbin/restore/dirs.c: revision 1.51
Don't truncate at sub-microsecond while preserving timestamps.

One of motivation of this change is to make the behavior of test(1)
-nt/ot with preserved copy (like cp -p) closer to the NetBSD 6.
Of course whether full timestamps are kept or not depends also on
underlying file system.

The ifdef added in mv(1) since existing ifdefs was our local change
to compile it on solaris (though I couldn't test it):
http://mail-index.netbsd.org/tech-userlevel/2014/11/28/msg008831.html

Fix the name of failed function in warning message.

Hijack utimensat(2) so that t_vfs test passes after cp(1)/mv(1) are
changed to use the system call. Linux also has this system call, but
not tested this on linux.

Also hijack futimens(2) so that t_sh test passes.

Define a generic ATCALL() and use it to implement utimensat()
Make ATCALL() behave for absolute paths too.
 1.67.8.1 03-Mar-2016  martin Pull up following revision(s) (requested by nakayama in ticket #1096):
bin/mv/mv.c: revision 1.44
bin/cp/utils.c: revision 1.43-1.44
lib/librumphijack/hijack.c: revision 1.112-1.115
usr.bin/touch/touch.c: revision 1.33
sbin/restore/tape.c: revision 1.68
sbin/restore/dirs.c: revision 1.51
Don't truncate at sub-microsecond while preserving timestamps.

One of motivation of this change is to make the behavior of test(1)
-nt/ot with preserved copy (like cp -p) closer to the NetBSD 6.
Of course whether full timestamps are kept or not depends also on
underlying file system.

The ifdef added in mv(1) since existing ifdefs was our local change
to compile it on solaris (though I couldn't test it):
http://mail-index.netbsd.org/tech-userlevel/2014/11/28/msg008831.html

Fix the name of failed function in warning message.

Hijack utimensat(2) so that t_vfs test passes after cp(1)/mv(1) are
changed to use the system call. Linux also has this system call, but
not tested this on linux.

Also hijack futimens(2) so that t_sh test passes.

Define a generic ATCALL() and use it to implement utimensat()
Make ATCALL() behave for absolute paths too.
 1.24 19-Jun-2021  christos Add external attribute dumping and restoring support from FreeBSD.
Does not fully work yet, attributes are being saved and restored correctly,
but don't appear in the restored files somehow.
 1.23 22-Jan-2013  dholland Stuff UFS_ in front of a few of ufs's symbols to reduce namespace
pollution. Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN -> UFS_MAXSYMLINKLEN
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Sort out ext2fs's misuse of NDADDR and NIADDR; fortunately, these have
the same values in ext2fs and ffs.

No functional change intended.
 1.22 19-Aug-2005  christos branches: 1.22.44; 1.22.50;
64 bit inode changes
 1.21 27-Jun-2005  christos add const
 1.20 27-Jun-2005  christos sprinkle const.
 1.19 17-Feb-2005  xtraeme Kill __P(), use ANSI function declarations.
 1.18 22-Oct-2004  bouyer Add an option (-M) to write a mtree specification (which needs to be passed
through sort before being feed to mtree) with file flags, instead of restoring
file flags at the same time as other attributes. Fix various issue with
schg, uchg, sappnd or uappnd flags which cause restore to fail in some case.
Discussed on tech-userlevel:
http://mail-index.netbsd.org/tech-userlevel/2004/10/12/0000.html
 1.17 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.16 25-May-2002  wiz __STDC__ is always defined on NetBSD.
 1.15 01-Nov-2001  lukem fix -Wshadow warnings
 1.14 24-Sep-2001  wiz va_{start,end} audit:
Make sure that each va_start has one and only one matching va_end,
especially in error cases.
If the va_list is used multiple times, do multiple va_starts/va_ends.
If a function gets va_list as argument, don't let it use va_end (since
it's the callers responsibility).

Improved by comments from enami and christos -- thanks!

Heimdal/krb4/KAME changes already fed back, rest to follow.

Inspired by, but not not based on, OpenBSD.
 1.13 16-Sep-1997  lukem resolve conflicts from lite-2 merge
 1.12 15-Sep-1997  lukem * cleanup for WARNS=1
* fix use of .Nm
 1.11 19-Mar-1997  lukem * use mkstemp() instead of mktemp()
* remove "register" qualifiers
 1.10 27-Sep-1996  thorpej Use snprintf() rather than sprintf().
 1.9 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.8 20-Feb-1995  mycroft Use atexit() rather than tweaking every exit() to call the cleanup function.
 1.7 28-Dec-1994  mycroft Mostly sync with CSRG.
 1.6 23-Sep-1994  mycroft Eliminate uses of some obsolete functions.
 1.5 08-Jun-1994  mycroft Update from 4.4-Lite, with local changes.
 1.4 19-Feb-1994  cgd light clean and check error codes
 1.3 22-Dec-1993  cgd new version from CSRG, via BSDI, with fixes
 1.2 01-Aug-1993  mycroft Add RCS identifiers.
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 16-Sep-1997  lukem imported from lite-2
 1.1.1.2 13-Jun-1994  mycroft Import 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.22.50.1 25-Feb-2013  tls resync with head
 1.22.44.1 23-Jan-2013  yamt sync with head

RSS XML Feed