summaryrefslogtreecommitdiff
path: root/sbin/dump/main.c
Commit message (Collapse)AuthorAgeFilesLines
* Clean up global variable declarations in the dump and restoreKirk McKusick2020-04-041-7/+29
| | | | | | | | | | | | utilities so that they will compile with -fno-common. Started by: Kyle Evans (kevans) Reviewed by: Kyle Evans (kevans) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D24210 Notes: svn path=/head/; revision=359627
* Normally when an attempt is made to mount a UFS/FFS filesystem whoseKirk McKusick2018-12-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | superblock has a check-hash error, an error message noting the superblock check-hash failure is printed and the mount fails. The administrator then runs fsck to repair the filesystem and when successful, the filesystem can once again be mounted. This approach fails if the filesystem in question is a root filesystem from which you are trying to boot. Here, the loader fails when trying to access the filesystem to get the kernel to boot. So it is necessary to allow the loader to ignore the superblock check-hash error and make a best effort to read the kernel. The filesystem may be suffiently corrupted that the read attempt fails, but there is no harm in trying since the loader makes no attempt to write to the filesystem. Once the kernel is loaded and starts to run, it attempts to mount its root filesystem. Once again, failure means that it breaks to its prompt to ask where to get its root filesystem. Unless you have an alternate root filesystem, you are stuck. Since the root filesystem is initially mounted read-only, it is safe to make an attempt to mount the root filesystem with the failed superblock check-hash. Thus, when asked to mount a root filesystem with a failed superblock check-hash, the kernel prints a warning message that the root filesystem superblock check-hash needs repair, but notes that it is ignoring the error and proceeding. It does mark the filesystem as needing an fsck which prevents it from being enabled for writing until fsck has been run on it. The net effect is that the reboot fails to single user, but at least at that point the administrator has the tools at hand to fix the problem. Reported by: Rick Macklem (rmacklem@) Discussed with: Warner Losh (imp@) Sponsored by: Netflix Notes: svn path=/head/; revision=341608
* Fix build break from dump incompatibility I introduced in -r340411Kirk McKusick2018-11-141-2/+2
| | | | | | | Pointy-hat to: mckusick Notes: svn path=/head/; revision=340422
* Plug build break after r340411.Gleb Smirnoff2018-11-131-2/+2
| | | | Notes: svn path=/head/; revision=340416
* Revert size limits.Warner Losh2018-06-111-4/+1
| | | | | | | | | The size limits came from a flawed understanding of dump records. The real issue was that dump was bogusly interpreting c_count sometimes. r334978 fixes that. Notes: svn path=/head/; revision=334980
* Don't initialize c_count. We don't need to.Warner Losh2018-06-111-2/+2
| | | | Notes: svn path=/head/; revision=334974
* Minor style polishing.Warner Losh2018-06-111-2/+1
| | | | | | | | | Declare c_count and initialize it with other ints. Reported by: mjg@ Notes: svn path=/head/; revision=334972
* Large file systems with inodes > 512K have been silently overflowingDiane Bruce2018-06-111-1/+4
| | | | | | | | | | | | | c_addr in spcl. So check before we start dumping otherwise we can end up with a corrupted dump. PR: 228807 Submitted by: db Reviewed by: imp Approved by: imp Notes: svn path=/head/; revision=334968
* Ensure proper initialization of superblock.Kirk McKusick2018-06-071-0/+1
| | | | | | | Submitted by: Diane Bruce Notes: svn path=/head/; revision=334814
* Revert r313780 (UFS_ prefix)Ed Maste2018-03-171-2/+2
| | | | Notes: svn path=/head/; revision=331095
* Prefix UFS symbols with UFS_ to reduce namespace pollutionEd Maste2018-03-171-2/+2
| | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=331083
* Refactoring of reading and writing of the UFS/FFS superblock.Kirk McKusick2018-01-261-18/+11
| | | | | | | | | | | | | | | Specifically reading is done if ffs_sbget() and writing is done in ffs_sbput(). These functions are exported to libufs via the sbget() and sbput() functions which then used in the various filesystem utilities. This work is in preparation for adding subperblock check hashes. No functional change intended. Reviewed by: kib Notes: svn path=/head/; revision=328426
* In preparation for converting to libufs to read the superblock,Kirk McKusick2017-12-271-4/+4
| | | | | | | | | | | | change conflicting function names: getino => getinode bread => blkread No functional change. Notes: svn path=/head/; revision=327253
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-0/+2
| | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=326025
* Renumber copyright clause 4Warner Losh2017-02-281-1/+1
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=314436
* sbin: ake use of our rounddown() macro when sys/param.h is available.Pedro F. Giffuni2016-05-011-1/+1
| | | | | | | No functional change. Notes: svn path=/head/; revision=298872
* dump: use NULL instead of zero for pointers.Pedro F. Giffuni2016-04-191-1/+1
| | | | | | | Clean out the casts from calloc(3) while here. Notes: svn path=/head/; revision=298288
* Replace index() and rindex() calls with strchr() and strrchr().Ed Schouten2012-01-031-1/+1
| | | | | | | | | | | | | The index() and rindex() functions were marked LEGACY in the 2001 revision of POSIX and were subsequently removed from the 2008 revision. The strchr() and strrchr() functions are part of the C standard. This makes the source code a lot more consistent, as most of these C files also call into other str*() routines. In fact, about a dozen already perform strchr() calls. Notes: svn path=/head/; revision=229403
* The dump, fsck_ffs, fsdb, fsirand, newfs, makefs, and quot utilitiesKirk McKusick2011-01-241-1/+1
| | | | | | | | | | | | | | | | | include sys/time.h instead of time.h. This include is incorrect as per the manpages for the APIs and the POSIX definitions. This commit replaces sys/time.h where necessary with time.h. The commit also includes some minor style(9) header fixup in newfs. This commit is part of a larger effort by Garrett Cooper started in //depot/user/gcooper/posix-conformance-work/ -- to make FreeBSD more POSIX compliant. Submitted by: Garrett Cooper yanegomi at gmail dot com Notes: svn path=/head/; revision=217769
* Plug two memory leaks in error case.Xin LI2010-02-031-1/+2
| | | | | | | MFC after: 1 month Notes: svn path=/head/; revision=203459
* Expand dump to allow MAX_INT dump levels.Kirk McKusick2008-05-241-7/+10
| | | | | | | | PR: bin/100732 Submitted by: Matthew Vincenz <msvincen@midway.uchicago.edu> Notes: svn path=/head/; revision=179275
* When using dump to generate level 0 dumps which are then rsync'edKirk McKusick2008-05-231-3/+23
| | | | | | | | | | | | | | | 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> Notes: svn path=/head/; revision=179267
* Make "dump /filesystem" (without options) work.Ruslan Ermilov2006-10-121-2/+5
| | | | | | | | PR: docs/84408 MFC after: 3 days Notes: svn path=/head/; revision=163280
* If rawname returns NULL, deal with it appropriately.Matt Jacob2006-08-151-0/+2
| | | | | | | | | PR: 94045 Submitted by: Andrey Elsukov MFC after: 1 week Notes: svn path=/head/; revision=161333
* 'r' disk devices no longer exist, so don't try to create a pathnameWarner Losh2005-04-181-20/+10
| | | | | | | | | | that has an 'r' in it. This also eliminates a bogus use of strlcat. PR: 80064 Notes: svn path=/head/; revision=145238
* Sync program's usage() with manpage's SYNOPSIS.Ruslan Ermilov2005-02-101-2/+2
| | | | Notes: svn path=/head/; revision=141611
* Improved error checking for existence of a .snap directory toWes Peters2005-01-211-15/+26
| | | | | | | | | | | generate snapshots in when -L is requested. If the .snap directory does not exist, or is not a directory, issue a warning and revert to the non- live behavior. Obtained from: St. Bernard Software RAPID Notes: svn path=/head/; revision=140602
* Add -P arguments for dump(8) and restore(8) which allow the user toBrian Feldman2004-04-131-7/+21
| | | | | | | | | | | | | | use backup methods other than files and tapes. The -P argument is a normal sh(1) pipeline with either $DUMP_VOLUME or $RESTORE_VOLUME defined in the environment, respectively. For example, I can back up my home to three DVD+R[W]s as so: Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/ad0s2e 40028550 10093140 26733126 27% /home green# dump -0 -L -C16 -B4589840 -P 'growisofs -Z /dev/cd0=/dev/fd/0' /home Notes: svn path=/head/; revision=128175
* Improve the warnings for dump -L and do not bother doing the snapshot ifBrian Feldman2004-04-121-3/+10
| | | | | | | | | | it is specified for read-only filesystems. Submitted by: Jason Young <jyoung8607@hotmail.com> PR: 46672 Notes: svn path=/head/; revision=128166
* Remove advertising clause from University of California Regent's license,Mark Murray2004-04-091-4/+0
| | | | | | | | | per letter dated July 22, 1999. Approved by: core, imp Notes: svn path=/head/; revision=128073
* Define _PATH_MKSNAP_FFS and use it in dump(8) instead of assumingIan Dowse2004-01-041-2/+2
| | | | | | | | | that mksnap_ffs(8) can be found using the current $PATH. Reviewed by: mckusick Notes: svn path=/head/; revision=124132
* Convert the live dump command (`dump -L') to use mksnap_ffs insteadKirk McKusick2003-11-161-12/+8
| | | | | | | | | | | | | | | | | | of trying to directly create the snapshot itself. This change allows users logged into the system as operator to run live dumps. Note that dump no longer tries to create the snapshot in the root of the filesystem, but rather in a .snap directory in the root of the filesystem. The reason is that the operator is usually not permitted to write into the root of the filesystem. The newfs command and background fsck have both been modified to create a .snap directory in the root of the filesystem, but if neither of these have been run, then the .snap directory must be created manually by the superuser before a live dump can be run. The .snap directory should be owned by user root and group operator and set to mode 770. Notes: svn path=/head/; revision=122787
* Make this WARNS=2 clean byJohan Karlsson2003-11-141-3/+4
| | | | | | | | | | | | | - using (intmax_t) and %j - giving a non-empty format string to msg() Include <stdint.h> directly instead of depending on <inttypes.h> to do it. Tested by: make universe Notes: svn path=/head/; revision=122669
* Dump is hard-wired to believe that it can read disks onKirk McKusick2003-05-071-0/+1
| | | | | | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=114810
* Removed all vestiges of KerberosIV.Ruslan Ermilov2003-05-011-5/+3
| | | | Notes: svn path=/head/; revision=114463
* De-Kerberise (KerberosIV). KerberosIV is no longer present, andMark Murray2003-05-011-14/+0
| | | | | | | | remote backups can still be done with Kerberos authentication using SSH and Kerberos 5. Notes: svn path=/head/; revision=114452
* Avoid a name conflict with future functionality:Matthew N. Dodd2003-04-071-1/+1
| | | | | | | getfstab() -> dump_getfstab() Notes: svn path=/head/; revision=113214
* Sort options.Ruslan Ermilov2003-02-231-17/+17
| | | | Notes: svn path=/head/; revision=111287
* really, this time for sure. Fix formatting in usage().Matthew Dillon2003-01-131-2/+2
| | | | Notes: svn path=/head/; revision=109190
* Grr. I keep forgetting things. Include -C in dump's usage() .Matthew Dillon2003-01-131-1/+1
| | | | Notes: svn path=/head/; revision=109189
* Add support for obsolete option form for -CMatthew Dillon2003-01-131-0/+1
| | | | Notes: svn path=/head/; revision=109188
* Add a caching option to dump. Use -C. Note that NetBSD has a caching optionMatthew Dillon2003-01-131-2/+7
| | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=109187
* Add the `L' option to dump to notify it that it is dumping aKirk McKusick2002-12-031-14/+81
| | | | | | | | | | | | | | | | | | live filesystem. To obtain a consistent dump image, dump takes a snapshot of the filesystem and then does a dump of the snapshot. The snapshot is removed when the dump is complete. Also add an operator warning that the `L' option should be used if dump is run on a live filesystem without the `L' option being specified. The alternative would be to silently use a snapshot any time that a live filesystem is dumped, but this change in dump semantics seemed too drastic at this time. Sponsored by: DARPA & NAI Labs. Approved by: re Notes: svn path=/head/; revision=107559
* Create a new 32-bit fs_flags word in the superblock. Add code to moveKirk McKusick2002-11-271-2/+1
| | | | | | | | | | | | | | | | | | | | the old 8-bit fs_old_flags to the new location the first time that the filesystem is mounted by a new kernel. One of the unused flags in fs_old_flags is used to indicate that the flags have been moved. Leave the fs_old_flags word intact so that it will work properly if used on an old kernel. Change the fs_sblockloc superblock location field to be in units of bytes instead of in units of filesystem fragments. The old units did not work properly when the fragment size exceeeded the superblock size (8192). Update old fs_sblockloc values at the same time that the flags are moved. Suggested by: BOUWSMA Barry <freebsd-misuser@netscum.dyndns.dk> Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=107294
* Changed "file system" back to "filesystem" in the usage message. EnglishBruce Evans2002-10-011-3/+3
| | | | | | | | | | | rules don't apply to tokens that are supposed to represent single args. This was only fixed in the man page. Fixed other differences between the man page and the usage message (1 formatting bug and 1 syntax bug). Notes: svn path=/head/; revision=104290
* Use the standardized CHAR_BIT constant instead of NBBY in userland.Mike Barcroft2002-09-251-3/+4
| | | | Notes: svn path=/head/; revision=103949
* s/filesystem/file system/g as discussed on -developersTom Rhodes2002-08-211-6/+6
| | | | Notes: svn path=/head/; revision=102231
* Replace the use of %qd with intmax_t/%jd and fix a number of -WallIan Dowse2002-07-081-8/+9
| | | | | | | | | | 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. Notes: svn path=/head/; revision=99562
* This commit adds basic support for the UFS2 filesystem. The UFS2Kirk McKusick2002-06-211-25/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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> Notes: svn path=/head/; revision=98542
* more file system > filesystemTom Rhodes2002-05-161-3/+3
| | | | Notes: svn path=/head/; revision=96707