aboutsummaryrefslogtreecommitdiff
path: root/sbin/fsck_ffs/setup.c
Commit message (Collapse)AuthorAgeFilesLines
* fsck_ffs: garbage collect calcsbRyan Libby2025-10-151-47/+0
| | | | | | | | | | calcsb is unused since the logic moved to sbsearch / ffs_sbsearch in e68866164212 ("Move the ability to search for alternate UFS superblocks from fsck_ffs(8) into ffs_sbsearch() to allow use by other parts of the system.") Reviewed by: mckusick Differential Revision: https://reviews.freebsd.org/D53038
* sbin: Automated cleanup of cdefs and other formattingWarner Losh2023-11-271-3/+0
| | | | | | | | | | | | | | | | 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
* sbin: Remove ancient SCCS tags.Warner Losh2023-11-271-3/+0
| | | | | | | | 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
* Ensure I/O buffers in libufs(3) are 128-byte aligned.Kirk McKusick2023-11-171-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Various disk controllers require their buffers to be aligned to a cache-line size (128 bytes). For buffers allocated in structures, ensure that they are 128-byte aligned. Use aligned_malloc to allocate memory to ensure that the returned memory is 128-byte aligned. While we are here, we replace the dynamically allocated inode buffer with a buffer allocated in the uufsd structure just as the superblock and cylinder group buffers do. This can be removed if/when the kernel is fixed. Because this problem has existed on one I/O subsystem or another since the 1990's, we are probably stuck with dealing with it forever. The problem most recent showed up in Azure, see: https://reviews.freebsd.org/D41728 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=267654 Before these fixes were applied, it was confirmed that the changes in this commit also fixed the issue in Azure. Reviewed-by: Warner Losh, kib Tested-by: Souradeep Chakrabarti of Microsoft (earlier version) PR: 267654 Differential Revision: https://reviews.freebsd.org/D41724
* Delete snapshot after opening it when running fsck_ffs(9) in background.Kirk McKusick2023-10-251-4/+4
| | | | | | | | | | | | | | | | | | | | | When fsck_ffs(8) runs in background, it creates a snapshot named fsck_snapshot in the filesystem's .snap directory. The fsck_snapshot file was removed when the background fsck finished. If the system crashed or the fsck exited unexpectedly, the fsck_snapshot file would remain. The snapshot would consume ever more space as the filesystem changed over time until it was removed by a system administrator or a future run of background fsck removed it to create a new snapshot file. This commit unlinks the .snap/fsck_snapshot file immediately after opening it so that it will be reclaimed when fsck closes it at the conclusion of its run. After a system crash, it will be removed as part of the filesystem cleanup because of its zero reference count. As only a few milliseconds pass between its creation and unlinking, there is far less opportunity for it to be accidentally left behind. PR: 106107 MFC-after: 1 week
* Fix a bug in fsck_ffs(8) triggered by corrupted filesystems.Kirk McKusick2023-10-201-0/+2
| | | | | | | | | Add missing check for failed block read when checking information about a snapshot file. Reported-by: Andreas Bock PR: 274404 MFC-after: 1 week
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* When running fsck_ffs(8) in background ensure that a superblock has been read.Kirk McKusick2023-05-261-2/+6
| | | | | | | Reported by: Mikhail T. PR: 271352 MFC after: 1 week Sponsored by: The FreeBSD Foundation
* Correct several bugs in fsck_ffs(8) triggered by corrupted filesystems.Kirk McKusick2023-03-071-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a directory entry has an illegal inode number (less than zero or greater than the last inode in the filesystem) the entry is removed. If a directory '.' or '..' entry had an illegal inode number they were being removed. Since fsck_ffs knows what the correct value is for these two entries fix them rather deleting them. Add much more extensive cylinder group checks and use them to be more careful about rebuilding a cylinder group. Check for out-of-range block numbers before trying to free them. When a directory is deleted also remove its cache entry created in pass1 so that later passes do not try to operate on a deleted directory. Check for ctime(3) returning NULL before trying to use its return. When freeing a directory inode, do not try to interpret it as a directory. Reserve space in the inostatlist to have room to allocate a lost+found directory. If an invalid block number is found past the end of an inode simply remove it rather than clearing and removing the inode. Modernize the inoinfo structure to use queue(3) LIST rather than a handrolled linked list implementation. Reported by: Bob Prohaska, John-Mark Gurney, and Mark Millard Tested by: Peter Holm Reviewed by: Peter Holm MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D38668
* Add support for managing UFS/FFS snapshots to fsck_ffs(8).Kirk McKusick2022-11-091-1/+181
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The kernel handles the managment of UFS/FFS snapshots. Since UFS/FFS updates filesystem data (rather than always writing changes to new locations like ZFS), the kernel must check every filesystem write to see if the block being written is part of a snapshot. If it is part of a snapshot, then the kernel must make a copy of the old block value into a newly allocated block for the snapshot before allowing the write to be done. Similarly, if a block is being freed, the kernel must check to see if it is part of a snapshot and let the snapshot claim the block rather than freeing it for future use. When a snapshot is freed, its blocks need to be offered to older snapshots and freed only if no older snapshots wish to claim them. When snapshots were added to UFS/FFS they were integrated into soft updates and just a small part of the management of snapshots needed to be added to fsck_ffs(8) as soft updates minimized the set of snapshot changes that might need correction. When journaling was added to soft updates a much more complete knowledge of snapshots needed to be added to fsck_ffs(8) for it to be able to properly handle the filesystem changes that a journal rollback needs to do (specifically the freeing and allocation of blocks). Since this functionality was unavailable, the use of snapshots was disabled when running with journaled soft updates. This set of changes imports the kernel code for the management of snapshots to fsck_ffs(8). With this code in place it will become possible to enable snapshots when running with journalled soft updates. The most immediate benefit will be the ability to use snapshots to take consistent filesystem dumps on live filesystems. Future work will be done to update fsck_ffs(8) to be able to use snapshots to run in background on live filesystems running with journaled soft updates. Reviewed by: kib Tested by: Peter Holm Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D36491
* When reading backup UFS superblocks, report reason if they cannot be used.Kirk McKusick2022-08-171-1/+1
| | | | | | | | | When either searching for backup UFS superblocks or when explicitly asked to use one with the -b option, report the reason for failure if it cannot be used. Reported by: Peter Holm Sponsored by: The FreeBSD Foundation
* Correctness cleanups in fsck_ffs(8).Kirk McKusick2022-08-131-1/+1
| | | | | | | | | Allocation or I/O failures in fsck_ffs(8) could cause segment faults because of missing checks or not-yet-initialized data structures. Correct these issues. Reported by: Peter Holm Sponsored by: The FreeBSD Foundation
* Move the ability to search for alternate UFS superblocks from fsck_ffs(8)Kirk McKusick2022-08-131-51/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | into ffs_sbsearch() to allow use by other parts of the system. Historically only fsck_ffs(8), the UFS filesystem checker, had code to track down and use alternate UFS superblocks. Since fsdb(8) used much of the fsck_ffs(8) implementation it had some ability to track down alternate superblocks. This change extracts the code to track down alternate superblocks from fsck_ffs(8) and puts it into a new function ffs_sbsearch() in sys/ufs/ffs/ffs_subr.c. Like ffs_sbget() and ffs_sbput() also found in ffs_subr.c, these functions can be used directly by the kernel subsystems. Additionally they are exported to the UFS library, libufs(8) so that they can be used by user-level programs. The new functions added to libufs(8) are sbfind(3) that is an alternative to sbread(3) and sbsearch(3) that is an alternative to sbget(3). See their manual pages for further details. The utilities that have been changed to search for superblocks are dumpfs(8), fsdb(8), ffsinfo(8), and fsck_ffs(8). Also, the prtblknos(8) tool found in tools/diag/prtblknos searches for superblocks. The UFS specific mount code uses the superblock search interface when mounting the root filesystem and when the administrator doing a mount(8) command specifies the force flag (-f). The standalone UFS boot code (found in stand/libsa/ufs.c) uses the superblock search code in the hope of being able to get the system up and running so that fsck_ffs(8) can be used to get the filesystem cleaned up. The following utilities have not been changed to search for superblocks: clri(8), tunefs(8), snapinfo(8), fstyp(8), quot(8), dump(8), fsirand(8), growfs(8), quotacheck(8), gjournal(8), and glabel(8). When these utilities fail, they do report the cause of the failure. The one exception is the tasting code used to try and figure what a given disk contains. The tasting code will remain silent so as not to put out a slew of messages as it trying to taste every new mass storage device that shows up. Reviewed by: kib Reviewed by: Warner Losh Tested by: Peter Holm Differential Revision: https://reviews.freebsd.org/D36053 Sponsored by: The FreeBSD Foundation
* Drop checks with last alternate superblock in fsck_ffs(8).Kirk McKusick2022-08-041-62/+2
| | | | | | | | | | | The fsck_ffs(8) utility made sanity checks of critical superblock fields by comparing the values of those fields in the standard superblock againt the values of those fields in the last alternate superblock. The code for validating a superblock now cover all the checked fields as well as many more. Further the checks done are far more comprehensive. So we now drop the alternate superblock checks as they no longer provide value. Dropping these checks also eliminates the need to read the alternate superblock.
* Add a flags parameter to the ffs_sbget() function that reads UFS superblocks.Kirk McKusick2022-07-311-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than trying to shoehorn flags into the requested superblock address, create a separate flags parameter to the ffs_sbget() function in sys/ufs/ffs/ffs_subr.c. The ffs_sbget() function is used both in the kernel and in user-level utilities through export to the sbget() function in the libufs(3) library (see sbget(3) for details). The kernel uses ffs_sbget() when mounting UFS filesystems, in the glabel(8) and gjournal(8) GEOM utilities, and in the standalone library used when booting the system from a UFS root filesystem. The ffs_sbget() function reads the superblock located at the byte offset specified by its sblockloc parameter. The value UFS_STDSB may be specified for sblockloc to request that the standard location for the superblock be read. The two existing options are now flags: UFS_NOHASHFAIL will note if the check hash is wrong but will still return the superblock. This is used by the bootstrap code to give the system a chance to come up so that fsck can be run to correct the problem. UFS_NOMSG indicates that superblock inconsistency error messages should not be printed. It is used by programs like fsck that want to print their own error message and programs like glabel(8) that just want to know if a UFS filesystem exists on a partition. One additional flag is added: UFS_NOCSUM causes only the superblock itself to be returned, but does not read in any auxiliary data structures like the cylinder group summary information. It is used by clients like glabel(8) that just want to check for possible filesystem types. Using UFS_NOCSUM skips the superblock checks for csum data which allows superblocks that have corrupted csum data to be read and used. The validate_sblock() function checks that the superblock has not been corrupted in a way that can crash or hang the system. Unless the UFS_NOMSG flag is specified, it will print out any errors that it finds. Prior to this commit, validate_sblock() returned as soon as it found an inconsistency so would print at most one message. It now does all its checks so when UFS_NOMSG has not been specified will print out everything that it finds inconsistent. Sponsored by: The FreeBSD Foundation
* Ensure that fsck(8) / fsck_ffs(8) produces the correct exit codeKirk McKusick2022-03-161-4/+1
| | | | | | | | | | | | | | | | | for missing devices. The fsck_ffs(8) utility uses its internal function openfilesys() when opening a disk to be checked. This change avoids the use of pfatal() in openfilesys() which always exits with failure (exit value 8) so that the caller can choose the correct exit value. In the case of a non-existent device it should exit with value 3 which allows the startup system to wait for drives (such as those attached by USB) to come online. Reported by: karels Tested by: karels PR: 262580 MFC after: 3 days
* Update fsdb(8) to reflect new structure of fsck_ffs(8).Kirk McKusick2022-02-231-0/+39
| | | | | | | | | | The cleanup of fsck_ffs(8) in commit c0bfa109b942659f6 broke fsdb(8). This commit adds the one-line update needed in fsdb(8) to make it work with the new fsck_ffs(8) structure. Reported by: Chuck Silvers Tested by: Chuck Silvers MFC after: 3 days
* Avoid unaligned writes by fsck_ffs(8).Kirk McKusick2022-02-201-13/+17
| | | | | | | | | | | | | | | | | | | | | | | | Normally fsck_ffs never does reads or writes that are not aligned to the size of one of the checked filesystems fragments. The one exception is when it finds that it needs to write the superblock recovery information. Here it will write with the alignment reported by the underlying disk as its sector size as reported by an ioctl(diskfd, DIOCGSECTORSIZE, &secsize). Modern disks have a sector size of 4096, but for backward compatibility with older disks will report that they have a sector size of 512. When presented with a 512 byte write, they have to read the associated 4096 byte sector, replace the 512 bytes to be written, and write the updated 4096 byte sector back to the disk. Unfortunately, some disks report that they have 512 sectors, but fail writes that are not aligned to 4096 boundaries and are a multiple of 4096 bytes in size. This commit updates fsck_ffs(8) so that it uses the filesystem fragment size as the smallest size and alignment for doing writes rather than the disk's reported sector size. Reported by: Andriy Gapon MFC after: 1 week
* Have fsck_ffs(8) properly correct superblock check-hash failures.Kirk McKusick2022-02-041-139/+43
| | | | | | | | | | | | | | Part of the problem was that fsck_ffs would read the superblock multiple times complaining and repairing the superblock check hash each time and then at the end failing to write out the superblock with the corrected check hash. This fix reads the superblock just once and if the check hash is corrected ensures that the fixed superblock gets written. Tested by: Peter Holm PR: 245916 MFC after: 1 week Sponsored by: Netflix
* Revert "Fix fsck_ufs segfaults with gjournal (SU+J)"Robert Wing2021-05-291-0/+1
| | | | | | Fix fsck for 32-bit platforms. This reverts commit f190f9193bc10a8193c87e0a02fa91400e4eb159.
* Fix fsck_ufs segfaults with gjournal (SU+J)Kirk McKusick2021-05-211-1/+0
| | | | | | | | | | | | | | | | The segfault was being hit in ckfini() (sbin/fsck_ffs/fsutil.c) while attempting to traverse the buffer cache to flush dirty buffers. The tail queue used for the buffer cache was not initialized before dropping into gjournal_check(). Move the buffer initialization earlier so that it has been done before calling gjournal_check(). Reported by: crypt47, nvass Fix by: Robert Wing Tested by: Robert Wing PR: 255030 PR: 255979 MFC after: 3 days Sponsored by: Netflix
* Rewrite the disk I/O management system in fsck_ffs(8). Other thanKirk McKusick2021-01-071-14/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | making fsck_ffs(8) run faster, there should be no functional change. The original fsck_ffs(8) had its own disk I/O management system. When gjournal(8) was added to FreeBSD 7, code was added to fsck_ffs(8) to do the necessary gjournal rollback. Rather than use the existing fsck_ffs(8) disk I/O system, it wrote its own from scratch. Similarly when journalled soft updates were added in FreeBSD 9, code was added to fsck_ffs(8) to do the necessary journal rollback. And once again, rather than using either of the existing fsck_ffs(8) disk I/O systems, it wrote its own from scratch. Lastly the fsdb(8) utility uses the fsck_ffs(8) disk I/O management system. In preparation for making the changes necessary to enable snapshots to be taken when using journalled soft updates, it was necessary to have a single disk I/O system used by all the various subsystems in fsck_ffs(8). This commit merges the functionality required by all the different subsystems into a single disk I/O system that supports all of their needs. In so doing it picks up optimizations from each of them with the results that each of the subsystems does fewer reads and writes than it did with its own customized I/O system. It also greatly simplifies making changes to fsck_ffs(8) since everything goes through a single place. For example the ginode() function fetches an inode from the disk. When inode check hashes were added, they previously had to be checked in the code implementing inode fetch in each of the three different disk I/O systems. Now they need only be checked in ginode(). Tested by: Peter Holm Sponsored by: Netflix
* Various new check-hash checks have been added to the UFS filesystemKirk McKusick2020-10-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | over various major releases. Superblock check hashes were added for the 12 release and cylinder-group and inode check hashes will appear in the 13 release. When a disk with a UFS filesystem is writably mounted, the kernel clears the feature flags for anything that it does not support. For example, if a UFS disk from a 12-stable kernel is mounted on an 11-stable system, the 11-stable kernel will clear the flag in the filesystem superblock that indicates that superblock check-hashs are being maintained. Thus if the disk is later moved back to a 12-stable system, the 12-stable system will know to ignore its incorrect check-hash. If the only filesystem modification done on the earlier kernel is to run a utility such as growfs(8) that modifies the superblock but neither updates the check-hash nor clears the feature flag indicating that it does not support the check-hash, the disk will fail to mount if it is moved back to its original newer kernel. This patch moves the code that clears the filesystem feature flags from the mount code (ffs_mountfs()) to the code that reads the superblock (ffs_sbget()). As ffs_sbget() is used by the kernel mount code and is imported into libufs(3), all the filesystem utilities will now also clear these flags when they make modifications to the filesystem. As suggested by John Baldwin, fsck_ffs(8) has been changed to accept and repair bad superblock check-hashes rather than refusing to run. This change allows fsck to recover filesystems that have been impacted by utilities older than those created after this change and is a sensible thing to do in any event. Reported by: John Baldwin (jhb@) MFC after: 2 weeks Sponsored by: Netflix Notes: svn path=/head/; revision=367034
* Move all of the error prints in readsb() from stderr to stdout.Chuck Silvers2020-09-011-3/+3
| | | | | | | | | | | The only output from fsck that should go to stderr is the usage message. if setup() fails then exit with EEXIT rather than 0. Reviewed by: mckusick Sponsored by: Netflix Notes: svn path=/head/; revision=365056
* The libufs library needs to track and free the new fs_si structureKirk McKusick2020-06-231-1/+1
| | | | | | | | | | in addition to the fs_csp structure that it references. PR: 247425 Sponsored by: Netflix Notes: svn path=/head/; revision=362559
* fsck_ffs/fsdb: fix -fno-common buildKyle Evans2020-03-291-0/+2
| | | | | | | | | | | | | | This one is also a small list: - 3x duplicate definition (ufs2_zino, returntosingle, nflag) - 5x 'needs extern', 3/5 of which are referenced in fsdb -fno-common will become the default in GCC10/LLVM11. MFC after: 1 week Notes: svn path=/head/; revision=359427
* fsck_ffs: fix some memory leaks found by Coverity.Eric van Gyzen2019-12-101-3/+12
| | | | | | | | | | Reported by: Coverity CID: 1380549 1380550 1380551 MFC after: 1 week Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=355593
* After a crash, a file that extends into indirect blocks may end upKirk McKusick2019-02-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | shorter than its size resulting in a hole as its final block (which is a violation of the invarients of the UFS filesystem). Soft updates will always ensure that the file size is correct when writing inodes to disk for files that contain only direct block pointers. However soft updates does not roll back sizes for files with indirect blocks that it has set to unallocated because their contents have not yet been written to disk. Hence, the file can appear to have a hole at its end because the block pointer has been rolled back to zero when its inode was written to disk. Thus, fsck_ffs calculates the last allocated block in the file. For files that extend into indirect blocks, fsck_ffs checks for a size past the last allocated block of the file and if that is found, shortens the file to reference the last allocated block thus avoiding having it reference a hole at its end. Submitted by: Chuck Silvers <chs@netflix.com> Tested by: Chuck Silvers <chs@netflix.com> MFC after: 1 week Sponsored by: Netflix Notes: svn path=/head/; revision=344552
* 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
* Ensure that cylinder-group check-hashes are properly updated when firstKirk McKusick2018-12-051-0/+7
| | | | | | | | | | creating them and when correcting them when they are found to be corrupted. Reported by: Don Lewis (truckman@) Sponsored by: Netflix Notes: svn path=/head/; revision=341510
* Properly recover from superblock check-hash failures. Specifically,Kirk McKusick2018-11-251-5/+3
| | | | | | | | | | | | | report the check-hash failure and offer to search for and use alternate superblocks. Prior to this fix fsck_ffs would simply report the check-hash failure and exit. Reported by: Julian H. Stacey <jhs@berklix.com> Tested by: Peter Holm Sponsored by: Netflix Notes: svn path=/head/; revision=340925
* Refactoring of reading and writing of the UFS/FFS superblock.Kirk McKusick2018-01-261-47/+25
| | | | | | | | | | | | | | | 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
* More throughly integrate libufs into fsck_ffs by using its cgput()Kirk McKusick2018-01-241-2/+6
| | | | | | | | | | routine to write out the cylinder groups rather than recreating the calculation of the cylinder-group check hash in fsck_ffs. No functional change intended. Notes: svn path=/head/; revision=328383
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-1/+3
| | | | | | | | | | | | | | | | | 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
* The new fsck recovery information to enable it to find backupKirk McKusick2017-09-041-25/+65
| | | | | | | | | | | | | | | | superblocks created in revision 322297 only works on disks with sector sizes up to 4K. This update allows the recovery information to be created by newfs and used by fsck on disks with sector sizes up to 64K. Note that FFS currently limits filesystem to be mounted from disks with up to 8K sectors. Expanding this limitation will be the subject of another commit. Reported by: Peter Holm Reviewed with: kib Notes: svn path=/head/; revision=323157
* Since the switch to GPT disk labels, fsck for UFS/FFS has beenKirk McKusick2017-08-091-4/+101
| | | | | | | | | | | | | | | | | | | | | unable to automatically find alternate superblocks. This checkin places the information needed to find alternate superblocks to the end of the area reserved for the boot block. Filesystems created with a newfs of this vintage or later will create the recovery information. If you have a filesystem created prior to this change and wish to have a recovery block created for your filesystem, you can do so by running fsck in forground mode (i.e., do not use the -p or -y options). As it starts, fsck will ask ``SAVE DATA TO FIND ALTERNATE SUPERBLOCKS'' to which you should answer yes. Discussed with: kib, imp MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D11589 Notes: svn path=/head/; revision=322297
* Remove now-unused badsb declaration, missed in r322200Ed Maste2017-08-081-2/+0
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=322271
* In debug mode, print the differences between the superblock andWarner Losh2017-08-071-25/+35
| | | | | | | | | | alternate superblock when the values disagree and we're going to reject it. Differential Revision: https://reviews.freebsd.org/D11589 Notes: svn path=/head/; revision=322201
* Make it possible to ignore superblock mismatch. This will not fix suchWarner Losh2017-08-071-36/+13
| | | | | | | | | | | | | | | | a mismatch, but will allow fsck to continue when the last alternate superblock gets corrupted somehow. Also, remove searching for alternate super blocks. It should have been removed two years ago with r276737 by imp@. Leave minor vestiges in place in case someone wants to solve the hard problem of knowing where altnernate superblocks live without access to data formerly stored in disklabels. Differential Revision: https://reviews.freebsd.org/D11589 Notes: svn path=/head/; revision=322200
* fsck_ffs: Unsign some variables and make use of reallocarray(3).Pedro F. Giffuni2017-04-221-6/+3
| | | | | | | | | | | | | Instead of casting listmax and numdirs to unsigned values just define them as unsigned and avoid the casts. Use reallocarray(3). While here, fs_ncg is already unsigned so the cast is unnecessary. Reviewed by: mckusick MFC after: 2 weeks Notes: svn path=/head/; revision=317283
* 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
* Fsck_ufs was using an int rather than a ufs2_daddr_t to store theKirk McKusick2016-08-191-2/+2
| | | | | | | | | | | | alternate superblock location when given in the -b option. When int is 32-bits, block numbers larger than 2^32 would get truncated. This commit changes the storage fpr the alternate superblock location to a ufs2_daddr_t. Submitted by: Dmitry Sivachenko <trtrmitya@gmail.com> Notes: svn path=/head/; revision=304438
* Use MIN/MAX macros from sys/param.h.Marcelo Araujo2016-05-021-2/+1
| | | | | | | MFC after: 2 weeks. Notes: svn path=/head/; revision=298907
* Remove old ioctl use and support, once and for all.Warner Losh2015-01-061-89/+2
| | | | Notes: svn path=/head/; revision=276737
* Revert 248634 and 248643 (e.g., restoring 248625 and 248639).Kirk McKusick2013-03-231-7/+7
| | | | | | | Build verified by: Glen Barber (gjb@) Notes: svn path=/head/; revision=248658
* Revert svn r248625Sean Bruno2013-03-231-7/+7
| | | | | | | | | | | Clang errors around printf could be trivially fixed, but the breakage in sbin/fsdb were to significant for this type of change. Submitter of this changeset has been notified and hopefully this can be restored soon. Notes: svn path=/head/; revision=248634
* Speed up fsck by caching the cylinder group maps in pass1 soKirk McKusick2013-03-221-7/+7
| | | | | | | | | | | | | | | | | | | | | | | that they do not need to be read again in pass5. As this nearly doubles the memory requirement for fsck, the cache is thrown away if other memory needs in fsck would otherwise fail. Thus, the memory footprint of fsck remains unchanged in memory constrained environments. This work was inspired by a paper presented at Usenix's FAST '13: www.usenix.org/conference/fast13/ffsck-fast-file-system-checker Details of this implementation appears in the April 2013 of ;login: www.usenix.org/publications/login/april-2013-volume-38-number-2. A copy of the April 2013 ;login: paper can also be downloaded from: www.mckusick.com/publications/faster_fsck.pdf. Reviewed by: kib Tested by: Peter Holm MFC after: 4 weeks Notes: svn path=/head/; revision=248625
* When running with the -d option, instrument fsck_ffs to track the number,Kirk McKusick2013-02-241-2/+5
| | | | | | | | | data type, and running time of its I/O operations. No functional changes. Notes: svn path=/head/; revision=247212
* Be more helpful about alternate superblocks.Edward Tomasz Napierala2012-02-101-1/+1
| | | | Notes: svn path=/head/; revision=231377
* In checker, read journal by sectors.Konstantin Belousov2011-02-121-1/+1
| | | | | | | | | | | | | | Due to UFS insistence to pretend that device sector size is 512 bytes, sector size is obtained from ioctl(DIOCGSECTORSIZE) for real devices, and from the label otherwise. The file images without label have to be made with 512 sector size. In collaboration with: pho Reviewed by: jeff Tested by: bz, pho Notes: svn path=/head/; revision=218604