History log of /freebsd-current/sbin/dump/traverse.c
Revision Date Author Comments
# 32e86a82 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

sbin: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 51e16cb8 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

sbin: Remove ancient SCCS tags.

Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by: Netflix


# eba230af 25-Sep-2023 John Baldwin <jhb@FreeBSD.org>

Purge more stray embedded $FreeBSD$ strings

These do not use __FBSDID but instead use bare char arrays.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D41957


# 5b13fa79 02-Jan-2022 Jessica Clarke <jrtc27@FreeBSD.org>

ufs: Rework shortlink handling to avoid subobject overflows

Shortlinks occupy the space of both di_db and di_ib when used. However,
everywhere that wants to read or write a shortlink takes a pointer do
di_db and promptly runs off the end of it into di_ib. This is fine on
most architectures, if a little dodgy. However, on CHERI, the compiler
can optionally restrict the bounds on pointers to subobjects to just
that subobject, in order to mitigate intra-object buffer overflows, and
this is enabled in CheriBSD's pure-capability kernels.

Instead, clean this up by inserting a union such that a new di_shortlink
can be added with the right size and element type, avoiding the need to
cast and allowing the use of the DIP macro to access the field. This
also mirrors how the ext2fs code implements extents support, with the
exact same structure other than having a uint32_t i_data[] instead of a
char di_shortlink[].

Reviewed by: mckusick, jhb
Differential Revision: https://reviews.freebsd.org/D33650


# efe145a7 17-May-2021 Kirk McKusick <mckusick@FreeBSD.org>

Correct assert added to dump program.

The dump program was exiting with the message:

Assertion failed: (spcl.c_count + blks < TP_NINDIR), function appendextdata, file /usr/src/sbin/dump/traverse.c, line 759.

The problem arose when dumping external attributes.

This assertion was added in this commit with no review by someone
with expertise in the dump program:

commit 2d518c6518cdb256ff6f2c463e6b115d89c104c3
Author: Warner Losh <imp@FreeBSD.org>
AuthorDate: Mon Jun 11 19:32:36 2018 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: Mon Jun 11 19:32:36 2018 +0000

Add asserts to prevent overflows of c_addr.

It is clearly wrong as the statement immediately above it in the
code which is deciding if the data will fit is:

if (spcl.c_count + blks > TP_NINDIR)
return (0);

As is pointed out in the bug report, the assert should be:

(spcl.c_count + blks <= TP_NINDIR)

This commit corrects the assert. I am sorry that it took so long to
be brought to my attention and get fixed.

Reported by: Hampton Finger
PR: 244470
MFC after: 3 days
Sponsored by: Netflix


# 07436eeb 13-Nov-2018 Kirk McKusick <mckusick@FreeBSD.org>

Fix build break from dump incompatibility I introduced in -r340411

Pointy-hat to: mckusick


# d4f7db47 13-Nov-2018 Gleb Smirnoff <glebius@FreeBSD.org>

Plug build break after r340411.


# 2d518c65 11-Jun-2018 Warner Losh <imp@FreeBSD.org>

Add asserts to prevent overflows of c_addr.

Add some asserts that prevents the overflows of c_addr. This can't
happen, absent bugs. However, certain large filesystems can cause
problems. These have been prevented by r334968, but a solution
is needed. These asserts will help assure that solution is correct.

PR: 228807
Reviewed by: db


# d8ba45e2 16-Mar-2018 Ed Maste <emaste@FreeBSD.org>

Revert r313780 (UFS_ prefix)


# 1e2b9afc 16-Mar-2018 Ed Maste <emaste@FreeBSD.org>

Prefix UFS symbols with UFS_ to reduce namespace pollution

Followup to r313780. Also prefix ext2's and nandfs's versions with
EXT2_ and NANDFS_.

Reported by: kib
Reviewed by: kib, mckusick
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D9623


# a770ae06 27-Dec-2017 Kirk McKusick <mckusick@FreeBSD.org>

In preparation for converting to libufs to read the superblock,
change conflicting function names:

getino => getinode
bread => blkread

No functional change.


# 8a16b7a1 20-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

General further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.


# fbbd9655 28-Feb-2017 Warner Losh <imp@FreeBSD.org>

Renumber copyright clause 4

Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by: Jan Schaumann <jschauma@stevens.edu>
Pull Request: https://github.com/freebsd/freebsd/pull/96


# 1dc349ab 15-Feb-2017 Ed Maste <emaste@FreeBSD.org>

prefix UFS symbols with UFS_ to reduce namespace pollution

Specifically:
ROOTINO -> UFS_ROOTINO
WINO -> UFS_WINO
NXADDR -> UFS_NXADDR
NDADDR -> UFS_NDADDR
NIADDR -> UFS_NIADDR
MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency)

Also prefix ext2's and nandfs's NDADDR and NIADDR with EXT2_ and NANDFS_

Reviewed by: kib, mckusick
Obtained from: NetBSD
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D9536


# 0b410d9c 18-Apr-2016 Marcelo Araujo <araujo@FreeBSD.org>

Use NULL instead of 0.

malloc will return NULL in case it cannot allocate memory.

MFC after: 2 weeks.


# adbc0311 10-Sep-2014 Hiroki Sato <hrs@FreeBSD.org>

Fix a bug which could break extended attributes in a dump output.
This occurred when a file was >892kB long and had a large data (>1kB)
in the extended attributes.

Reported by: Masashi Toriumi
Reviewed by: mckusick


# e25a029e 27-Sep-2012 Matthew D Fleming <mdf@FreeBSD.org>

Fix sbin/ build with a 64-bit ino_t.

Original code by: Gleb Kurtsou


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 693c40a3 23-May-2008 Kirk McKusick <mckusick@FreeBSD.org>

When using dump to generate level 0 dumps which are then rsync'ed
to a remote machine, the fact that the dump date is stored with
each header (inode) record makes rsync significantly less efficient
than necessary. This also applies to inode access times when they
are not important data to retain. When implementing an offsite
backup solution of this type, these dates in particular are not
important, especially if it prevents effective offsite backups.

PR: bin/91049
Submitted by: Forrest W Christian <fwc@mt.net>


# 993425ee 05-Apr-2007 Thomas Quinot <thomas@FreeBSD.org>

(bread): For a read that is contained entirely within a block, never copy
out more than size bytes to the caller's buffer.

PR: bin/111191
Reviewed by: pb
MFC after: 1 week


# 3ec81826 27-Feb-2007 Kirk McKusick <mckusick@FreeBSD.org>

Fix an error in dumping large sparse files containing extended attributes.


# 772ad651 26-Feb-2007 Kirk McKusick <mckusick@FreeBSD.org>

Update the dump program to save extended attributes. Update
the restore program to restore all dumped extended attributes.

If the restore is running as root, it will always be able
to restore all extended attributes. If it is not running
as root, it makes a best effort to set them. Using the -v
command line flag or the `verbose' command in interactive
mode will display all the extended attributes being set on
files (and at the end on directories) that are being restored.
It will note any extended attributes that could not be set.

The extended attributes are placed on the dump image immediately
following each file's data. Older versions of restore can work
with the newer dump images. Old versions of restore will
correctly restore the file data and then (silently) skip
over the extended attribute data and proceed to the next file.

This resolves PR 93085 which will be closed once the code
has been MFC'ed.

Note that this code will not compile until these header
files have been updated: <protocols/dumprestore.h> and
<sys/extattr.h>.

PR: bin/93085
Comments from: Poul-Henning Kamp and Robert Watson
MFC after: 3 weeks


# 0b39291e 11-Apr-2006 David Malone <dwmalone@FreeBSD.org>

Dump keeps a bitmap of the state of various inodes, which is sized
to match the number of inodes on the disk. If we find a directory
entry with a crazy inode number in it, don't look beyond the end
of the bitmap to find that inode's state. Instead skip that directory
entry and print a warning.

Reviewed by: iedowse
MFC after: 3 weeks


# 0c40596c 02-May-2005 Xin LI <delphij@FreeBSD.org>

Make gcc4 happy by making consistent signedness.


# 8518a74a 27-Jul-2004 Alexander Kabaev <kan@FreeBSD.org>

Avoid casts as lvalues.


# 4c723140 09-Apr-2004 Mark Murray <markm@FreeBSD.org>

Remove advertising clause from University of California Regent's license,
per letter dated July 22, 1999.

Approved by: core, imp


# 155ea063 04-Nov-2003 Ian Dowse <iedowse@FreeBSD.org>

In mapdirs(), do not use the `dp' inode pointer after searchdir()
has been called, since it points to a shared inode buffer that may
be overwritten. The two cases where `dp' was used incorrectly appear
to have been overlooked when "nodump" inheritance was first added
in revision 1.12.

This is reported to correct propagation of the nodump flag on
directories that are larger than one block in size.

PR: bin/58912
Submitted by: Volker Paepcke <vpaepcke@incore.de>
MFC after: 1 week


# 924a7003 07-May-2003 Kirk McKusick <mckusick@FreeBSD.org>

Dump is hard-wired to believe that it can read disks on
1024-byte boundaries. For many years this was a reasonable
assumption. However, in recent years we have begun seeing
devices with 2048-byte sectors. These devices return errors
when dump tries to read starting in the middle of a sector
or when it tries to read only the first half of a sector.
Rather than change the native block size used by dump (and
thus create an incompatible dump format), this fix checks
for transfer requests that start and/or end on a non-sector
boundary. When such a read is detected, the new code reads
the entire sector and copies out just the part that dump
needs.

Reviewed by: Poul-Henning Kamp <phk@critter.freebsd.dk>
Approved by: re (John Baldwin <jhb@FreeBSD.org>)
Sponsored by: DARPA & NAI Labs.


# 5941e412 13-Jan-2003 Matthew Dillon <dillon@FreeBSD.org>

Add a caching option to dump. Use -C. Note that NetBSD has a caching option
called -r but it takes 512 byte blocks instead of megabytes, and I felt a
megabytes specification would be far more useful so I did not use the same
option character.

This will *greatly* improve dump performance at the cost of possibly
missing filesystem changes that occur between passes, and does a fairly
good job making up for the loss of buffered block devices. Caching is disabled
by default to retain historical behavior.

In tests, dump performance improved by about 40% when dumping / or /usr.

Beware that dump forks and the cache may wind up being larger then you
specify, but a more complex shared memory implementation would not produce
results that are all that much better so I kept it simple for now.

MFC after: 3 days


# 6bfd0bdc 02-Dec-2002 Kirk McKusick <mckusick@FreeBSD.org>

Correct the estimated block count calculated by dump to account
for the minimal amount of space used by a snapshot.

Sponsored by: DARPA & NAI Labs.


# 69becf4a 02-Dec-2002 Kirk McKusick <mckusick@FreeBSD.org>

Properly handle UFS2 sparsely allocated inodes. The UFS2 filesystem
only preallocates a small number of inodes. The dump program tries
to scan through all the allocated inodes on a filesystem which
causes bad behavior if they have never been allocated. Thus dump
must calculate the set of inodes that have actually been allocated
and scan only those inodes.

Sponsored by: DARPA & NAI Labs.


# be5b1425 30-Nov-2002 Kirk McKusick <mckusick@FreeBSD.org>

Mark snapshots so that dump will dump them as zero length
regular files rather than trying to interpret the snapshot.

Sponsored by: DARPA & NAI Labs.


# 89fdc4e1 24-Sep-2002 Mike Barcroft <mike@FreeBSD.org>

Use the standardized CHAR_BIT constant instead of NBBY in userland.


# 7fed38d0 25-Aug-2002 Philippe Charnier <charnier@FreeBSD.org>

Replace various spelling with FALLTHROUGH which is lint()able


# ce66ddb7 21-Aug-2002 Tom Rhodes <trhodes@FreeBSD.org>

s/filesystem/file system/g as discussed on -developers


# fb36a3d8 16-Jul-2002 Kirk McKusick <mckusick@FreeBSD.org>

Change utimes to set the file creation time (for filesystems that
support creation times such as UFS2) to the value of the
modification time if the value of the modification time is older
than the current creation time. See utimes(2) for further details.

Sponsored by: DARPA & NAI Labs.


# 7680e41c 08-Jul-2002 Ian Dowse <iedowse@FreeBSD.org>

Oops, the previous revision (1.22) introduced a potential alignment
issue, since the MAXBSIZE-sized buffers are accessed as arrays of
block pointers, but were declared as char[] arrays. Use a union to
avoid this, which also makes a number of casts unnecessary.

Pointed out by: bde
Reviewed by: bde


# 1e0276af 07-Jul-2002 Ian Dowse <iedowse@FreeBSD.org>

Use a fixed MAXBSIZE-size auto array instead of a static pointer
to a malloc'd buffer in dmpindir() and dirindir(). These functions
recursively call themselves to handle deeper levels of indirect
blocks, so a single static buffer was not suitable.

Bug tracked down by: Don Lewis <dl-freebsd@catspoiler.org>
Approach suggested by: bde


# 617dbd3c 07-Jul-2002 Ian Dowse <iedowse@FreeBSD.org>

Replace the use of %qd with intmax_t/%jd and fix a number of -Wall
and -Wformat warnings:
o Include timeconv.h for the time conversion functions.
o Remove unused variables.
o Correct a few cases where %d was used when printing longs.


# 325167c3 06-Jul-2002 Ian Dowse <iedowse@FreeBSD.org>

Fix some printf format errors.

Submitted by: Don Lewis <dl-freebsd@catspoiler.org>


# 1c85e6a3 21-Jun-2002 Kirk McKusick <mckusick@FreeBSD.org>

This commit adds basic support for the UFS2 filesystem. The UFS2
filesystem expands the inode to 256 bytes to make space for 64-bit
block pointers. It also adds a file-creation time field, an ability
to use jumbo blocks per inode to allow extent like pointer density,
and space for extended attributes (up to twice the filesystem block
size worth of attributes, e.g., on a 16K filesystem, there is space
for 32K of attributes). UFS2 fully supports and runs existing UFS1
filesystems. New filesystems built using newfs can be built in either
UFS1 or UFS2 format using the -O option. In this commit UFS1 is
the default format, so if you want to build UFS2 format filesystems,
you must specify -O 2. This default will be changed to UFS2 when
UFS2 proves itself to be stable. In this commit the boot code for
reading UFS2 filesystems is not compiled (see /sys/boot/common/ufsread.c)
as there is insufficient space in the boot block. Once the size of the
boot block is increased, this code can be defined.

Things to note: the definition of SBSIZE has changed to SBLOCKSIZE.
The header file <ufs/ufs/dinode.h> must be included before
<ufs/ffs/fs.h> so as to get the definitions of ufs2_daddr_t and
ufs_lbn_t.

Still TODO:
Verify that the first level bootstraps work for all the architectures.
Convert the utility ffsinfo to understand UFS2 and test growfs.
Add support for the extended attribute storage. Update soft updates
to ensure integrity of extended attribute storage. Switch the
current extended attribute interfaces to use the extended attribute
storage. Add the extent like functionality (framework is there,
but is currently never used).

Sponsored by: DARPA & NAI Labs.
Reviewed by: Poul-Henning Kamp <phk@freebsd.org>


# d266a286 06-Jun-2002 Poul-Henning Kamp <phk@FreeBSD.org>

s/daddr_t/ufs_daddr_t/g

This should fix the issues which cropped up after daddr_t grew up.

Sponsored by: DARPA & NAI Labs.


# 2db673ab 20-Mar-2002 Warner Losh <imp@FreeBSD.org>

o remove __P
o Use ANSI function definitions
o unifdef -D__STDC__


# 01629855 05-Dec-2001 David E. O'Brien <obrien@FreeBSD.org>

Files in subdirectories of directories that have the nodump flag set
are sometimes incorrectly being dumped.

The problem arises because the subdirectory only gets its entry
cleared from usedinomap if it is also present in dumpinomap, and it is
the absence of a directory in usedinomap that internally indicates
that the directory is under the effects of UF_NODUMP (either directly
or inherited).

PR: 32414
Submitted by: David C Lawrence <tale@dd.org>


# d2334e27 16-Nov-2001 Ian Dowse <iedowse@FreeBSD.org>

Zap a number of #ifdef sunos blocks, and all of the `register'
keywords.


# be1bf707 30-Jun-2001 Mike Heffner <mikeh@FreeBSD.org>

Convert two instances of a lseek()+read() combination to a pread().

PR: bin/17640
MFC after: 2 weeks


# 2c8094f3 18-Apr-2001 Jordan K. Hubbard <jkh@FreeBSD.org>

Fix bogon with the nodump flag.

Submitted by: Dima Dorfman <dima@unixfreak.org>


# 801382fa 03-Mar-2001 David E. O'Brien <obrien@FreeBSD.org>

Support inheritance of the "nodump" flag down a hierarchy.

Submitted by: Dima Dorfman <dima@unixfreak.org>
Obtained from: NetBSD


# 37736675 14-Apr-2000 Warner Losh <imp@FreeBSD.org>

Add include of errno.h where needed, remove extern int errno where not.

These commits were inspired by a similar commit to netbsd.


# 7f3dea24 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 16c4e408 08-Jul-1999 Bill Fumerola <billf@FreeBSD.org>

Fix nested if/else within an if


# 97b465b1 26-Oct-1998 Dima Ruban <dima@FreeBSD.org>

64bit fixes.
(Note: ``dump'' doesn't work on alpha yet. Apparently there's a problem
somewhere is the physio() area)

Submitted by: myself && Matt Dillon.


# 7580ffbb 15-Jun-1998 Philippe Charnier <charnier@FreeBSD.org>

Correct use of .Nm. Add rcsid. Remove unused #includes.


# a37c38b8 10-Mar-1997 Peter Wemm <peter@FreeBSD.org>

Merge Lite2 changes (rather bigish, the dump/restore folks should check)


# 1811bdf3 11-Mar-1997 Peter Wemm <peter@FreeBSD.org>

Import some CSRG 4.4BSD-Lite2 components for sbin onto vendor branch.
(note that some of these have already been imported, this is a no-op)


# 28ebf214 16-Feb-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Update CHANGEDSINCE macro to conform to -current dinode.h


# 45808359 19-Sep-1996 Nate Williams <nate@FreeBSD.org>

ts_sec -> tv_sec
ts_nsec -> tv_nsec


# d195e6de 24-Jun-1995 Joerg Wunsch <joerg@FreeBSD.org>

When using dump/rdump on large filesytems (my case 3 GB), the lseek
claims multiple times to have failed. The problem is a off_t is
converted into a int and checked for a negative. A true lseek check
should be checking if the off_t is equal to -1 for failure.

(Suggested fix from PR #bin/461)

Submitted by: mark tinguely <tinguely@opus.cs.ndsu.NoDak.edu>


# 5ebc7e62 30-May-1995 Rodney W. Grimes <rgrimes@FreeBSD.org>

Remove trailing whitespace.


# 8fae3551 26-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

BSD 4.4 Lite sbin Sources

Note: XNSrouted and routed NOT imported here, they shall be imported with
usr.sbin.