summaryrefslogtreecommitdiff
path: root/sbin/newfs
Commit message (Collapse)AuthorAgeFilesLines
* Allow dashes as a valid character in UFS labels.Dmitry Morozovsky2019-01-292-4/+4
| | | | | | | | | Reviewed by: mckusick, imp, 0mp MFC after: 2 weeks Differential Revision: D18991 Notes: svn path=/head/; revision=343548
* Update tunefs and newfs error messages for the -L (volume label) optionKirk McKusick2019-01-261-1/+2
| | | | | | | | | | | to note that underscores are valid. PR: 235182 Reported by: Rodney W. Grimes (rgrimes@) Sponsored by: Netflix Notes: svn path=/head/; revision=343483
* Allow tunefs to include '_' as a legal character in label namesKirk McKusick2019-01-251-0/+1
| | | | | | | | | | | | | | to make it consistent with newfs. Document the legality of '_' in label names in both tunefs(8) and newfs(8). PR: 235182 Submitted by: darius@dons.net.au Reviewed by: Conrad Meyer MFC after: 3 days Sponsored by: Netflix Notes: svn path=/head/; revision=343449
* Continuing efforts to provide hardening of FFS. This change adds aKirk McKusick2018-12-111-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* In preparation for adding inode check-hashes, clean up andKirk McKusick2018-11-131-11/+6
| | | | | | | | | | | | | | | | | | | 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
* Continuing efforts to provide hardening of FFS, this change adds aKirk McKusick2018-10-231-1/+3
| | | | | | | | | | | | | | | | | | check hash to the superblock. If a check hash fails when an attempt is made to mount a filesystem, the mount fails with EINVAL (Invalid argument). This avoids a class of filesystem panics related to corrupted superblocks. The hash is done using crc32c. Check hases 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=339671
* newfs: clean up warningsEitan Adler2018-06-241-4/+5
| | | | | | | | | | | | - remove param: unused since r95357. - correct definition of usage - add explicit fallthrough notice. The existing one doesn't work with our selection of "implicit-fallthrough" strictness. This results in WARNS=6 building on amd64, but not other arches Notes: svn path=/head/; revision=335597
* Revert r313780 (UFS_ prefix)Ed Maste2018-03-171-3/+3
| | | | Notes: svn path=/head/; revision=331095
* Prefix UFS symbols with UFS_ to reduce namespace pollutionEd Maste2018-03-171-3/+3
| | | | | | | | | | | | | 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
* The goal of this change is to prevent accidental foot shooting byKirk McKusick2018-02-081-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | folks running filesystems created on check-hash enabled kernels (which I will call "new") on a non-check-hash enabled kernels (which I will call "old). The idea here is to detect when a filesystem is run on an old kernel and flag the filesystem so that when it gets moved back to a new kernel, it will not start getting a slew of check-hash errors. Back when the UFS version 2 filesystem was created, it added a file flag FS_INDEXDIRS that was to be set on any filesystem that kept some sort of on-disk indexing for directories. The idea was precisely to solve the issue we have today. Specifically that a newer kernel that supported indexing would be able to tell that the filesystem had been run on an older non-indexing kernel and that the indexes should not be used until they had been rebuilt. Since we have never implemented on-disk directory indicies, the FS_INDEXDIRS flag is cleared every time any UFS version 2 filesystem ever created is mounted for writing. This commit repurposes the FS_INDEXDIRS flag as the FS_METACKHASH flag. Thus, the FS_METACKHASH is definitively known to have always been cleared. The FS_INDEXDIRS flag has been moved to a new block of flags that will always be cleared starting with this commit (until they get used to implement some future feature which needs to detect that the filesystem was mounted on a kernel that predates the new feature). If a filesystem with check-hashes enabled is mounted on an old kernel the FS_METACKHASH flag is cleared. When that filesystem is mounted on a new kernel it will see that the FS_METACKHASH has been cleared and clears all of the fs_metackhash flags. To get them re-enabled the user must run fsck (in interactive mode without the -y flag) which will ask for each supported check hash whether it should be rebuilt and enabled. When fsck is run in its default preen mode, it will just ignore the check hashes so they will remain disabled. The kernel has always disabled any check hash functions that it does not support, so as more types of check hashes are added, we will get a non-surprising result. Specifically if filesystems get moved to kernels supporting fewer of the check hashes, those that are not supported will be disabled. If the filesystem is moved back to a kernel with more of the check-hashes available and fsck is run interactively to rebuild them, then their checking will resume. Otherwise just the smaller subset will be checked. A side effect of this commit is that filesystems running with cylinder-group check hashes will stop having them checked until fsck is run to re-enable them (since none of them currently have the FS_METACKHASH flag set). So, if you want check hashes enabled on your filesystems after booting a kernel with these changes, you need to run fsck to enable them. Any newly created filesystems will have check hashes enabled. If in doubt as to whether you have check hashes emabled, run dumpfs and look at the list of enabled flags at the end of the superblock details. Notes: svn path=/head/; revision=329051
* Check and report error returns from sbput(3) calls.Kirk McKusick2018-02-021-36/+21
| | | | | | | | | | Convert to using cgput(3) for writing cylinder groups. Check and report error returns from cgput(3). Submitted by: Bruce Evans <bde@freebsd.org> Notes: svn path=/head/; revision=328821
* Refactoring of reading and writing of the UFS/FFS superblock.Kirk McKusick2018-01-261-41/+34
| | | | | | | | | | | | | | | 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
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-203-3/+9
| | | | | | | | | | | | | | | | | 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
* Rename P_OSREL_CK_CLYGRP to P_OSREL_CK_CYLGRPScott Long2017-11-171-1/+1
| | | | Notes: svn path=/head/; revision=325934
* Only try to enable CK_CLYGRP if we're running on kernel newer thanWarner Losh2017-11-162-5/+2
| | | | | | | | | | | | | | 1200046, the first version that supports this feature. If we set it, then use an old kernel, we'll break the 'contract' of having checksummed cylinder groups this flag signifies. To avoid creating something with an inconsistent state, don't turn the flag on in these cases. The first full fsck with a new kernel will turn this on. Spnsored by: Netflix Differential Revision: https://reviews.freebsd.org/D13114 Notes: svn path=/head/; revision=325903
* newfs: warn if newer than kernelEd Maste2017-11-151-0/+4
| | | | | | | | | | | | | | | Creating a UFS filesystem with a newfs newer than the running kernel, and then mounting that filesystem, can lead to interesting failures. Add a safety belt to explicitly warn when newfs is newer than the running kernel. Reviewed by: gjb, jhb, mckusick Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D12765 Notes: svn path=/head/; revision=325860
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-311-1/+0
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* Continuing efforts to provide hardening of FFS, this change adds aKirk McKusick2017-09-221-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | check hash to cylinder groups. If a check hash fails when a cylinder group is read, no further allocations are attempted in that cylinder group until it has been fixed by fsck. This avoids a class of filesystem panics related to corrupted cylinder group maps. The hash is done using crc32c. Check hases 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. Specifics of the changes: sys/sys/buf.h: Add BX_FSPRIV to reserve a set of eight b_xflags that may be used by individual filesystems for their own purpose. Their specific definitions are found in the header files for each filesystem that uses them. Also add fields to struct buf as noted below. sys/kern/vfs_bio.c: It is only necessary to compute a check hash for a cylinder group when it is actually read from disk. When calling bread, you do not know whether the buffer was found in the cache or read. So a new flag (GB_CKHASH) and a pointer to a function to perform the hash has been added to breadn_flags to say that the function should be called to calculate a hash if the data has been read. The check hash is placed in b_ckhash and the B_CKHASH flag is set to indicate that a read was done and a check hash calculated. Though a rather elaborate mechanism, it should also work for check hashing other metadata in the future. A kernel internal API change was to change breada into a static fucntion and add flags and a function pointer to a check-hash function. sys/ufs/ffs/fs.h: Add flags for types of check hashes; stored in a new word in the superblock. Define corresponding BX_ flags for the different types of check hashes. Add a check hash word in the cylinder group. sys/ufs/ffs/ffs_alloc.c: In ffs_getcg do the dance with breadn_flags to get a check hash and if one is provided, check it. sys/ufs/ffs/ffs_vfsops.c: Copy across the BX_FFSTYPES flags in background writes. Update the check hash when writing out buffers that need them. sys/ufs/ffs/ffs_snapshot.c: Recompute check hash when updating snapshot cylinder groups. sys/libkern/crc32.c: lib/libufs/Makefile: lib/libufs/libufs.h: lib/libufs/cgroup.c: Include libkern/crc32.c in libufs and use it to compute check hashes when updating cylinder groups. Four utilities are affected: sbin/newfs/mkfs.c: Add the check hashes when building the cylinder groups. sbin/fsck_ffs/fsck.h: sbin/fsck_ffs/fsutil.c: Verify and update check hashes when checking and writing cylinder groups. sbin/fsck_ffs/pass5.c: Offer to add check hashes to existing filesystems. Precompute check hashes when rebuilding cylinder group (although this will be done when it is written in fsutil.c it is necessary to do it early before comparing with the old cylinder group) sbin/dumpfs/dumpfs.c Print out the new check hash flag(s) sbin/fsdb/Makefile: Needs to add libufs now used by pass5.c imported from fsck_ffs. Reviewed by: kib Tested by: Peter Holm (pho) Notes: svn path=/head/; revision=323923
* The new fsck recovery information to enable it to find backupKirk McKusick2017-09-041-13/+18
| | | | | | | | | | | | | | | | 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-0/+20
| | | | | | | | | | | | | | | | | | | | | 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
* Bump date for today's commit.Warner Losh2017-07-071-1/+1
| | | | Notes: svn path=/head/; revision=320788
* Improve wording for -E and -t flags. -E never writes the entire disk,Warner Losh2017-07-071-8/+8
| | | | | | | | | | so don't imply that. Note that if BIO_DELETE isn't supported, the operation will fail (as opposed to writing the entire disk with zeros). Thin storage also benefits from trim. List more accurate reason why trim helps flash-memory. Notes: svn path=/head/; revision=320787
* Allow '_' in labels when specifying -L to newfs.Kirk McKusick2017-06-201-1/+2
| | | | | | | | | | Reported by: Keve Nagy Reviewed by: kib PR: 220163 MFC after: 5 days Notes: svn path=/head/; revision=320176
* sbin: normalize paths using SRCTOP-relative paths or :H when possibleEnji Cooper2017-03-041-2/+2
| | | | | | | | | | This simplifies make logic/output MFC after: 1 month Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=314656
* Renumber copyright clause 4Warner Losh2017-02-284-4/+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 Notes: svn path=/head/; revision=314436
* prefix UFS symbols with UFS_ to reduce namespace pollutionEd Maste2017-02-151-15/+16
| | | | | | | | | | | | | | | | | | | | | 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
* Use MIN()/MAX() macros from sys/param.h.Marcelo Araujo2016-05-021-5/+3
| | | | | | | | | Reviewed by: trasz MFC after: 2 weeks. Differential Revision: https://reviews.freebsd.org/D6118 Notes: svn path=/head/; revision=298906
* Use NULL instead of 0 for pointers.Marcelo Araujo2016-04-181-1/+1
| | | | | | | | | | strchr(3) will return NULL if the character does not appear in the string. MFC after: 2 weeks. Notes: svn path=/head/; revision=298205
* It's 2015, and some people are still trying to use fdisk and thenEdward Tomasz Napierala2015-09-021-1/+1
| | | | | | | | | | | | | | | | go asking what debug flags to set for GEOM to make it work. Advice them to use gpart(8) instead. Something similar should probably done with disklabel, but I need to rewrite the disklabel examples first. Reviewed by: wblock@ MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3315 Notes: svn path=/head/; revision=287396
* Code cleanup unused-but-set-variable spotted by gcc.Marcelo Araujo2015-08-251-2/+0
| | | | | | | | Approved by: bapt (mentor) Differential Revision: D3475 Notes: svn path=/head/; revision=287131
* fix the docs, the number of frags per inode (NFPI) changed in r228794John-Mark Gurney2015-07-151-4/+4
| | | | | | | | | | | to 2 from 4, but the man page didn't get updated... other minor changes to make igor happy... MFC after: 3 days Notes: svn path=/head/; revision=285615
* Add META_MODE support.Simon J. Gerraty2015-06-131-0/+20
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Off by default, build behaves normally. WITH_META_MODE we get auto objdir creation, the ability to start build from anywhere in the tree. Still need to add real targets under targets/ to build packages. Differential Revision: D2796 Reviewed by: brooks imp Notes: svn path=/head/; revision=284345
| * dirdeps.mk now sets DEP_RELDIRSimon J. Gerraty2015-06-081-2/+0
| | | | | | | | Notes: svn path=/projects/bmake/; revision=284172
| * Merge sync of headSimon J. Gerraty2015-05-273-34/+3
| |\ | |/ |/| | | Notes: svn path=/projects/bmake/; revision=283595
| * Updated dependenciesSimon J. Gerraty2014-05-161-1/+0
| | | | | | | | Notes: svn path=/projects/bmake/; revision=266219
| * Updated dependenciesSimon J. Gerraty2014-05-101-0/+2
| | | | | | | | Notes: svn path=/projects/bmake/; revision=265802
| * Merge headSimon J. Gerraty2014-04-281-5/+3
| |\ | | | | | | | | | Notes: svn path=/projects/bmake/; revision=265044
| * \ Merge head@256284Simon J. Gerraty2013-10-131-3/+3
| |\ \ | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=256424
| * \ \ sync from headSimon J. Gerraty2013-04-124-2/+30
| |\ \ \ | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=249429
| * | | | Updated dependenciesSimon J. Gerraty2013-03-111-0/+1
| | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=248169
| * | | | Updated dependenciesSimon J. Gerraty2013-02-161-2/+0
| | | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=246868
| * | | | Sync from headSimon J. Gerraty2012-11-043-2/+5
| |\ \ \ \ | | | | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=242545
| * | | | | Sync FreeBSD's bmake branch with Juniper's internal bmake branch.Marcel Moolenaar2012-08-221-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Requested by: Simon Gerraty <sjg@juniper.net> Notes: svn path=/projects/bmake/; revision=239572
* | | | | | Remove old ioctl use and support, once and for all.Warner Losh2015-01-061-30/+0
| | | | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/head/; revision=276737
* | | | | | mdoc: improvements to SEE ALSO.Joel Dahl2014-12-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Notes: svn path=/head/; revision=276293
* | | | | | Convert sbin/ to LIBADDBaptiste Daroussin2014-11-251-2/+1
| |_|_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reduce overlinking Notes: svn path=/head/; revision=275030
* | | | | Refer newfs and growfs users to fsck_ffs instead ofChristian Brueffer2014-02-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fsck, the latter does not accept the referred to "-b" flag. This change was accidently committed directly to 9-STABLE in r237505. PR: 82720 Submitted by: David D.W. Downey MFC after: 1 week Notes: svn path=/head/; revision=261655
* | | | | Don't call arc4random_stir() explicitly. To quote arc4random(3)Xin LI2013-10-291-4/+2
| |_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | manual page: There is no need to call arc4random_stir() before using arc4random() functions family, since they automatically initialize themselves. No objection: des MFC after: 2 weeks Notes: svn path=/head/; revision=257348
* | | | Sweep man pages replacing ad -> ada.Sergey Kandaurov2013-10-011-3/+3
| |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | Approved by: re (blackend) MFC after: 1 week X-MFC note: stable/9 only Notes: svn path=/head/; revision=255977
* | | Remove contractions.Joel Dahl2013-04-111-1/+1
| | | | | | | | | | | | Notes: svn path=/head/; revision=249373