summaryrefslogtreecommitdiffstats
path: root/sbin/newfs/mkfs.c
Commit message (Collapse)AuthorAgeFilesLines
* Refer newfs and growfs users to fsck_ffs instead ofbrueffer2014-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
* Don't call arc4random_stir() explicitly. To quote arc4random(3)delphij2013-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
* The purpose of this change to the FFS layout policy is to reduce themckusick2013-03-221-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | running time for a full fsck. It also reduces the random access time for large files and speeds the traversal time for directory tree walks. The key idea is to reserve a small area in each cylinder group immediately following the inode blocks for the use of metadata, specifically indirect blocks and directory contents. The new policy is to preferentially place metadata in the metadata area and everything else in the blocks that follow the metadata area. The size of this area can be set when creating a filesystem using newfs(8) or changed in an existing filesystem using tunefs(8). Both utilities use the `-k held-for-metadata-blocks' option to specify the amount of space to be held for metadata blocks in each cylinder group. By default, newfs(8) sets this area to half of minfree (typically 4% of the data area). 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
* Fix problem with geom_label(4) not recognizing UFS labels on filesystemstrasz2012-10-301-0/+1
| | | | | | | | | | | | | | | | | | extended using growfs(8). The problem here is that geom_label checks if the filesystem size recorded in UFS superblock is equal to the provider (i.e. device) size. This check cannot be removed due to backward compatibility. On the other hand, in most cases growfs(8) cannot set fs_size in the superblock to match the provider size, because, differently from newfs(8), it cannot recompute cylinder group sizes. To fix this problem, add another superblock field, fs_providersize, used only for this purpose. The geom_label(4) will attach if either fs_size (filesystem created with newfs(8)) or fs_providersize (filesystem expanded using growfs(8)) matches the device size. PR: kern/165962 Reviewed by: mckusick Sponsored by: FreeBSD Foundation
* Fix sbin/ build with a 64-bit ino_t.mdf2012-09-271-1/+2
| | | | Original code by: Gleb Kurtsou
* Fix warning when compiling with gcc46:eadler2012-01-101-2/+0
| | | | | | | error: variable 'c' set but not used Approved by: dim MFC after: 3 days
* Add missing static keywords for global variables to tools in sbin/.ed2011-11-041-2/+2
| | | | | | 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.
* Stop trying to zero UFS1 superblocks if we fall off the end of the disk.cperciva2011-04-261-1/+4
| | | | | | | | | | This avoids a potentially many-hours-long loop of failed writes if newfs finds a partially-overwritten superblock (or, for that matter, random garbage which happens to have superblock magic bytes); on one occasion I found newfs trying to zero 800 million superblocks on a 50 MB disk. Reviewed by: mckusick MFC after: 1 week
* The dump, fsck_ffs, fsdb, fsirand, newfs, makefs, and quot utilitiesmckusick2011-01-241-10/+9
| | | | | | | | | | | | | | 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
* Add support for FS_TRIM to user-mode UFS utilities.kib2010-12-291-0/+2
| | | | | | Reviewed by: mckusick, pjd, pho Tested by: pho MFC after: 1 month
* Reported problem:mckusick2010-09-241-7/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Large (60GB) filesystems created using "newfs -U -O 1 -b 65536 -f 8192" show incorrect results from "df" for free and used space when mounted immediately after creation. fsck on the new filesystem (before ever mounting it once) gives a "SUMMARY INFORMATION BAD" error in phase 5. This error hasn't occurred in any runs of fsck immediately after "newfs -U -b 65536 -f 8192" (leaving out the "-O 1" option). Solution: The default UFS1 superblock is located at offset 8K in the filesystem partition; the default UFS2 superblock is located at offset 64K in the filesystem partition. For UFS1 filesystems with a blocksize of 64K, the first alternate superblock resides at 64K which is the the location used for the default UFS2 superblock. By default, the system first checks for a valid superblock at the default location for a UFS2 filoesystem. For a UFS1 filesystem with a blocksize of 64K, there is a valid UFS1 superblock at this location. Thus, even though it is expected to be a backup superblock, the system will use it as its default superblock. So, we have to ensure that all the statistcs on usage are correct in this first alternate superblock as it is the superblock that will actually be used. While tracking down this problem, another limitation of UFS1 became evident. For UFS1, the number of inodes per cylinder group is stored in an int16_t. Thus the maximum number of inodes per cylinder group is limited to 2^15 - 1. This limit can easily be exceeded for block sizes of 32K and above. Thus when building UFS1 filesystems, newfs must limit the number of inodes per cylinder group to 2^15 - 1. Reported by: Guy Helmer<ghelmer@palisadesys.com> Followup by: Bruce Cran <brucec@freebsd.org> PR: 107692 MFC after: 4 weeks
* o bdeficize expand_number_int() function;sobomax2010-03-091-9/+7
| | | | | o revert most of the recent changes (int -> int64_t conversion) by using this functon for parsing all options.
* Cast these to intmax_t before printing to fix build bustage. Betterimp2010-03-031-7/+9
| | | | solutions welcome.
* One last pass to get all the unsigned comparisons correct.mckusick2010-02-111-10/+13
|
* Ensure that newfs will never create a filesystem with more than 2^32mckusick2010-02-101-1/+35
| | | | | | | | | | | | | | | | inodes by cutting back on the number of inodes per cylinder group if necessary to stay under the limit. For a default (16K block) file system, this limit begins to take effect for file systems above 32Tb. This fix is in addition to -r203763 which corrected a problem in the kernel that treated large inode numbers as negative rather than unsigned. For a default (16K block) file system, this bug began to show up at a file system size above about 16Tb. Reported by: Scott Burns, John Kilburg, Bruce Evans Followup by: Jeff Roberson PR: 133980 MFC after: 2 weeks
* Fix typo: s/partion/partition/mbr2010-01-021-1/+1
| | | | | Submitted by: Marc Balmer <marc@msys.ch> MFC after: 3 days
* Don't add a bwrite() symbol, it breaks the build when building newfscognet2009-02-121-6/+16
| | | | | | statically. Instead, bring in a stripped down version of sbwrite(), and add the offset to every bwrite() calls.
* Enable operation of newfs on plain files, which is useful when youluigi2008-12-031-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | want to prepare disk images for emulators (though 'makefs' in port can do something similar). This relies on: + minor changes to pass the consistency checks even when working on a file; + an additional option, '-p partition' , to specify the disk partition to initialize; + some changes on the I/O routines to deal with partition offsets. The latter was a bit tricky to implement, see the details in newfs.h: in newfs, I/O is done through libufs which assumes that the file descriptor refers to the whole partition. Introducing support for the offset in libufs would require a non-backward compatible change in the library, to be dealt with a version bump or with symbol versioning. I felt both approaches to be overkill for this specific application, especially because there might be other changes to libufs that might become necessary in the near future. So I used the following trick: - read access is always done by calling bread() directly, so we just add the offset in the (few) places that call bread(); - write access is done through bwrite() and sbwrite(), which in turn calls bwrite(). To avoid rewriting sbwrite(), we supply our own version of bwrite() here, which takes precedence over the version in libufs. MFC after: 4 weeks
* Use calloc().delphij2008-03-051-2/+1
|
* Report erase interval (correctly) in sectors.phk2007-12-161-2/+2
|
* Rename the undocumented -E option to -X.phk2007-12-161-6/+13
| | | | | | | | | | Implement -E option which will erase the filesystem sectors before making the new filesystem. Reserved space in front of the superblock (bootcode) is not erased. NB: Erasing can take as long time as writing every sector sequentially. This is relevant for all flash based disks which use wearlevelling.
* Add -J flag to both newfs(8) and tunefs(8) which allows to enable gjournalpjd2006-10-311-0/+2
| | | | | | | | support. I left -j flag for UFS journal implementation which we may gain at some point. Sponsored by: home.pl
* Explicitly say which gid do we use as a fallback, when operatordelphij2006-09-271-1/+1
| | | | | | is not found. Suggested by: kensmith
* Don't treat failure to find the operator GID as a fatal error; thisiedowse2005-08-141-4/+9
| | | | | made it impossible to use newfs (and mdmfs) when /etc/group is missing and /etc is read-only.
* When creating a new FFS file system, the block size will indirectlydelphij2005-02-201-0/+10
| | | | | | | | | | | | | affect the largest file size that is allowed by the file system. On the other hand, when creating a snapshot, the snapshot file will appear as it is as big as the file system itself. Hence we will not be able to create a file system on large file systems with small block sizes. Add a warning about this, and gives some hints to correct the issue. Reviewed by: mckusick MFC After: 1 week
* Add an option to suppress the creation of the .snap directory inwes2005-01-211-30/+38
| | | | | | | | the new filesystem. This is intended for memory and vnode filesystems that will never be fsck'ed or dumped. Obtained from: St. Bernard Software RAPID MFC after: 2 weeks
* Generalize the UFS bad magic value used to determine when a filesystemjhb2004-08-191-4/+9
| | | | | | | | has only been partly initialized via newfs(8) so that it applies to both UFS1 and UFS2. Submitted by: "Xin LI" delphij at frontfree dot net MFC: maybe?
* Remove advertising clause from University of California Regent's license,markm2004-04-091-4/+0
| | | | | | per letter dated July 22, 1999. Approved by: core, imp
* Add a "-l" flag to newfs, which sets the FS_MULTILABEL flag. Thisrwatson2004-02-261-0/+2
| | | | | | | | permits users of newfs to set the multilabel flag on UFS1 and UFS2 file systems from inception without using tunefs. Obtained from: TrustedBSD Project Sponsored by: DARPA, McAfee Research
* Fix whitespace error in previous commit.wes2003-11-271-1/+1
| | | | Approved by: RE@ (Robert Watson)
* Don't use UFS2_BAD_MAGIC on UFS (v1) filesystems; it is Not Readywes2003-11-231-1/+1
| | | | | | | for Prime Time there. Submitted by: Xin LI <delphij@frontfree.net> Approved by: RE@ (John, Scott)
* Add the -E command line option to force error conditions for testing.wes2003-11-161-1/+12
| | | | Sponsord by: St. Bernard Software
* Write the UFS2 superblock with a 'BAD' magic number at the beginningwes2003-11-161-1/+4
| | | | | | | | of newfs, to signify the newfs operation has not yet completed. Re- write the superblock with the correct magic number once all of the cylinder groups have been created to show the operation has finished. Sponsored by: St. Bernard Software
* Create a .snap directory mode 770 group operator in the root ofmckusick2003-11-041-6/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | a new filesystem. Dump and fsck will create snapshots in this directory rather than in the root for two reasons: 1) For terabyte-sized filesystems, the snapshot may require many minutes to build. Although the filesystem will not be suspended during most of the snapshot build, the snapshot file itself is locked during the entire snapshot build period. Thus, if it is accessed during the period that it is being built, the process trying to access it will block holding its containing directory locked. If the snapshot is in the root, the root will lock and the system will come to a halt until the snapshot finishes. By putting the snapshot in a subdirectory, it is out of the likely path of any process traversing through the root and hence much less likely to cause a lock race to the root. 2) The dump program is usually run by a non-root user running with operator group privilege. Such a user is typically not permitted to create files in the root of a filesystem. By having a directory in group operator with group write access available, such a user will be able to create a snapshot there. Having the dump program create its snapshot in a subdirectory below the root will benefit from point (1) as well. Sponsored by: DARPA & NAI Labs.
* Exit with a non-zero status upon a block allocation failure.yar2003-08-051-3/+3
| | | | | | | | | | The old way of just returning could result in a file system extremely likely to panic the kernel. The warning printed wouldn't help much since tools invoking newfs(8), e.g., mdmfs(8), couldn't detect the error. PR: bin/55078 MFC after: 1 week
* When newfs'ing a partition with UFS2 that had previously been newfs'eddougb2003-05-221-0/+24
| | | | | | | | | | | | | | | | | with UFS1, the UFS1 superblocks were not deleted. This allowed any RELENG_4 (or other non-UFS2-aware) fsck to think it knew how to "fix" the file system, resulting in severe data scrambling. This patch is a more advanced version than the one originally submitted. Lukas improved it based on feedback from Kirk, and testing by me. It blanks all UFS1 superblocks (if any) during a UFS2 newfs, thereby causing fsck's that are not UFS2 aware to generate the "SEARCH FOR ALTERNATE SUPER-BLOCK FAILED" message, and exit without damaging the fs. PR: bin/51619 Submitted by: Lukas Ertl <l.ertl@univie.ac.at> Reviewed by: kirk Approved by: re (scottl)
* Put back the error checking in wtfs() that was lost when newfs wasiedowse2003-05-101-1/+2
| | | | | | | | | | | | | | changed to use libufs in revision 1.71. Without this, any write failures in newfs were silently ignored. Note that this will display a meaningless errno string in the case of a short write as opposed to a write error, since bwrite()'s return value does not allow the caller to determine if errno is valid. Reported by: Lukas Ertl <l.ertl@univie.ac.at> Reviewed by: jmallett Approved by: re (bmah)
* Use __FBSDID() to quiet GCC 3.3 warnings.obrien2003-05-031-4/+4
|
* Fix the -R flag so that it provides sequential "random" numbersmckusick2003-02-221-9/+21
| | | | | | so that the regression test will succeed. Sponsored by: DARPA & NAI Labs.
* Replace use of random() with arc4random() to provide less guessablemckusick2003-02-141-5/+5
| | | | | | | | values for the initial inode generation numbers in newfs and for newly allocated inode generation numbers in the kernel. Submitted by: Theo de Raadt <deraadt@cvs.openbsd.org> Sponsored by: DARPA & NAI Labs.
* Correct lines incorrectly added to the copyright message. Add missing period.mckusick2003-02-141-4/+1
| | | | | Submitted by: Bruce Evans <bde@zeta.org.au> Sponsored by: DARPA & NAI Labs.
* Convert newfs to libufs (really). Solves one real issue with previousjmallett2003-02-111-98/+18
| | | | | | | version of such. Differences in filesystems generated were found to be from 1) sbwrite with the "all" parameter 2) removal of writecache. The sbwrite call was made to perform as the original version, and otherwise this was checked against a version of newfs with the write cache removed.
* Bring in support for volume labels to the filesystem utilities.gordon2003-02-011-0/+2
| | | | Reviewed by: mckusick
* Back out conversion to libufs, for now. It seems to cause problems.jmallett2003-01-291-20/+99
| | | | Reported by: phk
* Convert newfs to use libufs. I've tested this on md filesystems, as hasjmallett2003-01-271-99/+20
| | | | keramida, and all seems well.
* Correctly calculate the initial number of fragments in a filesystemmckusick2002-12-021-2/+2
| | | | | | | | so that fsck does not complain with `SUMMARY BLK COUNT(S) WRONG IN SUPERBLK' the first time it is run on a new filesystem. Reported by: Poul-Henning Kamp <phk@freebsd.org> Sponsored by: DARPA & NAI Labs.
* Add some more checks to newfs so that it will not build filesystemsmckusick2002-11-301-14/+24
| | | | | | | | | | that the kernel will refuse to mount. Specifically it now enforces the MAXBSIZE blocksize limit. This update also fixes a problem where newfs could segment fault if the selected fragment size was too large. PR: bin/30959 Submitted by: Ceri Davies <setantae@submonkey.net> Sponsored by: DARPA & NAI Labs.
* Create a new 32-bit fs_flags word in the superblock. Add code to movemckusick2002-11-271-6/+6
| | | | | | | | | | | | | | | | | 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.
* Properly calculate the initial number of fragments in a large filesystem.mckusick2002-11-151-1/+2
| | | | Sponsored by: DARPA & NAI Labs.
* Bound the size of the superblock to SBLOCKSIZE.mckusick2002-10-181-0/+2
| | | | | Submitted by: BOUWSMA Beery <freebsd-misuser@netscum.dyndns.dk> Sponsored by: DARPA & NAI Labs.
OpenPOWER on IntegriCloud