aboutsummaryrefslogtreecommitdiff
path: root/sbin/fsirand/fsirand.c
Commit message (Collapse)AuthorAgeFilesLines
* Continuing efforts to provide hardening of FFS. This change adds aKirk McKusick2018-12-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | check hash to the filesystem inodes. Access attempts to files associated with an inode with an invalid check hash will fail with EINVAL (Invalid argument). Access is reestablished after an fsck is run to find and validate the inodes with invalid check-hashes. This check avoids a class of filesystem panics related to corrupted inodes. The hash is done using crc32c. Note this check-hash is for the inode itself and not any of its indirect blocks. Check-hash validation may be extended to also cover indirect block pointers, but that will be a separate (and more costly) feature. Check hashes are added only to UFS2 and not to UFS1 as UFS1 is primarily used in embedded systems with small memories and low-powered processors which need as light-weight a filesystem as possible. Reviewed by: kib Tested by: Peter Holm Sponsored by: Netflix Notes: svn path=/head/; revision=341836
* 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
* In preparation for adding inode check-hashes, clean up andKirk McKusick2018-11-131-16/+17
| | | | | | | | | | | | | | | | | | | document the libufs interface for fetching and storing inodes. The undocumented getino / putino interface has been replaced with a new getinode / putinode interface. Convert the utilities that had been using the undocumented interface to use the new documented interface. No functional change (as for now the libufs library does not do inode check-hashes). Reviewed by: kib Tested by: Peter Holm Sponsored by: Netflix Notes: svn path=/head/; revision=340411
* Refactoring of reading and writing of the UFS/FFS superblock.Kirk McKusick2018-01-261-82/+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
* various: general adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-1/+3
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. 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. No functional change intended. Notes: svn path=/head/; revision=326276
* prefix UFS symbols with UFS_ to reduce namespace pollutionEd Maste2017-02-151-1/+1
| | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=313780
* Remove old ioctl use and support, once and for all.Warner Losh2015-01-061-11/+0
| | | | Notes: svn path=/head/; revision=276737
* Fix sbin/ build with a 64-bit ino_t.Matthew D Fleming2012-09-271-2/+2
| | | | | | | Original code by: Gleb Kurtsou Notes: svn path=/head/; revision=241013
* Fix warning when compiling with gcc46:Eitan Adler2012-01-101-2/+1
| | | | | | | | | | error: variable 'inumber' set but not used Approved by: dim MFC after: 3 days Notes: svn path=/head/; revision=229917
* Add missing static keywords for global variables to tools in sbin/.Ed Schouten2011-11-041-1/+1
| | | | | | | | | These tools declare global variables without using the static keyword, even though their use is limited to a single C-file, or without placing an extern declaration of them in the proper header file. Notes: svn path=/head/; revision=227081
* The dump, fsck_ffs, fsdb, fsirand, newfs, makefs, and quot utilitiesKirk McKusick2011-01-241-2/+2
| | | | | | | | | | | | | | | | | 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
* fsirand(8): make WARNS=3 cleanUlrich Spörlein2010-05-141-17/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Drop bogus quad_t cast for di_gen, it is a 32bit type - Print di_gen with leading zeros, to get consistent output Before this change, amd64 would print: ino 18 gen 616ca2bd ino 19 gen ffffffff95c2a3ff ino 20 gen 25c3a3d5 ino 21 gen 8dc1472 ino 22 gen 3797056b ino 23 gen 1d47853a ino 24 gen ffffffff82d26995 After the change ino 18 gen 616ca2bd ino 19 gen 95c2a3ff ino 20 gen 25c3a3d5 ino 21 gen 08dc1472 ino 22 gen 3797056b ino 23 gen 1d47853a ino 24 gen 82d26995 PR: bin/139994 (sort of) Reviewed by: mckusick Notes: svn path=/head/; revision=208074
* Avoid casts as lvalues.Alexander Kabaev2004-07-281-2/+3
| | | | Notes: svn path=/head/; revision=132762
* 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
* s/filesystem/file system/g as discussed on -developersTom Rhodes2002-08-211-4/+4
| | | | Notes: svn path=/head/; revision=102231
* This commit adds basic support for the UFS2 filesystem. The UFS2Kirk McKusick2002-06-211-47/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* o __P removal.Warner Losh2002-03-211-8/+5
| | | | | | | | | o ansi function definitions. o main prototype removal o unifdef __STDC__ Notes: svn path=/head/; revision=92881
* Remove unused include.Jeroen Ruigrok van der Werven2000-05-011-1/+0
| | | | Notes: svn path=/head/; revision=59871
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50476
* Do not dot terminate SEE ALSO list. Add rcsid, remove unused #includes. Err(3)Philippe Charnier1998-06-301-35/+33
| | | | | | | messages should start with a lowercase letter. Notes: svn path=/head/; revision=37275
* Remove srandomdev fallbackAndrey A. Chernov1997-06-141-2/+1
| | | | Notes: svn path=/head/; revision=26625
* Add Id. Staticize usage function. Typo in usage string.Philippe Charnier1997-06-111-3/+3
| | | | Notes: svn path=/head/; revision=26558
* Get rid of __progname. I thought I already did that...Guido van Rooij1997-03-261-4/+2
| | | | Notes: svn path=/head/; revision=24303
* Include missing <time.h>Andrey A. Chernov1997-03-241-0/+4
| | | | | | | | Add missing RNG initialization Use srandomdev() for RNG initialization Notes: svn path=/head/; revision=24216
* Add generation number randomization. Newly created filesystems wil nowGuido van Rooij1997-03-231-0/+292
automatically have random generation numbers. The kenel way of handling those also changed. Further it is advised to run fsirand on all your nfs exported filesystems. the code is mostly copied from OpenBSD, with the randomization chanegd to use /dev/urandom Reviewed by: Garrett Obtained from: OpenBSD Notes: svn path=/head/; revision=24149