summaryrefslogtreecommitdiffstats
path: root/sbin/newfs/newfs.c
Commit message (Collapse)AuthorAgeFilesLines
* Code cleanup unused-but-set-variable spotted by gcc.araujo2015-08-251-2/+0
| | | | | Approved by: bapt (mentor) Differential Revision: D3475
* Remove old ioctl use and support, once and for all.imp2015-01-061-30/+0
|
* The purpose of this change to the FFS layout policy is to reduce themckusick2013-03-221-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+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
* Add the -j option to enable soft updates journaling when creatingmckusick2011-02-161-2/+11
| | | | | | a new file system. Reviewed by: Kostik Belousov <kostikbel@gmail.com>
* Add support for FS_TRIM to user-mode UFS utilities.kib2010-12-291-1/+6
| | | | | | Reviewed by: mckusick, pjd, pho Tested by: pho MFC after: 1 month
* Add the missed 'p' flag to getopt() optstring argument.kib2010-12-151-1/+1
| | | | MFC after: 1 week
* o bdeficize expand_number_int() function;sobomax2010-03-091-20/+20
| | | | | o revert most of the recent changes (int -> int64_t conversion) by using this functon for parsing all options.
* Change secrorsize back to int, since that's the data type expected by thesobomax2010-03-091-2/+20
| | | | | | | ioctl(DIOCGSECTORSIZE). It creates issues on some architectures. MFC after: 1 week Reported by: Jayachandran C.
* Use expand_number(3) from libutil instead of home-grown function to parsesobomax2010-03-031-80/+22
| | | | | | | human-friendly power-of-two numbers (i.e. 2k, 5M etc). Suggested by: many MFC after: 1 week
* Teach newfs(8) to understand size modifiers for all options takingsobomax2010-03-031-11/+84
| | | | | | | | | size or size-like argument. I.e. "-s 32k" instead of "-s 32768". Size parsing function has been shamelessly stolen from the truncate(1). I'm sure many sysadmins out there will appreciate this small improvement. MFC after: 1 week
* Ensure that newfs will never create a filesystem with more than 2^32mckusick2010-02-101-46/+0
| | | | | | | | | | | | | | | | 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
* Correct two typos.delphij2010-02-061-2/+2
| | | | | Reported by: Brandon Falk <falkman gamozo org> MFC after: 1 week
* Don't add a bwrite() symbol, it breaks the build when building newfscognet2009-02-121-10/+0
| | | | | | statically. Instead, bring in a stripped down version of sbwrite(), and add the offset to every bwrite() calls.
* Move the check for the ending char in the partition name whereluigi2008-12-121-5/+6
| | | | | | | | | it was before -- the check is only made when getdisklabel() returns valid info. On passing, use MAXPARTITIONS to identify the max partition number, instead of the hardwired 'h' MFC after: 4 weeks
* Enable operation of newfs on plain files, which is useful when youluigi2008-12-031-11/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Rename the undocumented -E option to -X.phk2007-12-161-3/+8
| | | | | | | | | | 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.
* - Pay attention to the fact that ioctl(2) is only known toyar2007-11-281-4/+5
| | | | | | | | | return -1 on error while any other return value from it can indicate success. (See RETURN VALUE in our ioctl(2) manpage and the POSIX spec.) - Avoid assumptions about the state of the data buffer after ioctl(2) failure.
* MFp4:yar2007-11-281-18/+37
| | | | | | | | | | | | | | | | | | | | | | Add a new option to newfs(8), -r, to specify reserved space at the end of the device. It can be useful, e.g., when the device is to become a member of a gmirror array later w/o losing the file system on it. Document the new option in the manpage. While I'm here, improve error handling for -s option, which is syntactically similar to -r; and document the fact that -s0 selects the default fs size explicitly, which can be useful, e.g., in a menu-based wrapper around newfs(8) requiring some value be entered for the fs size. Also fix a small typo in the help line for -s (missing space). Idea and initial implementation by: marck Discussed on: -fs Critical review by: bde Tested with: cmp(1)
* Document -J in usage.pjd2007-03-021-0/+1
| | | | Submitted by: Eric Anderson <anderson@freebsd.org>
* Add -J flag to both newfs(8) and tunefs(8) which allows to enable gjournalpjd2006-10-311-1/+5
| | | | | | | | support. I left -j flag for UFS journal implementation which we may gain at some point. Sponsored by: home.pl
* Document -l and -n options in usage().ru2005-01-221-0/+2
|
* Add an option to suppress the creation of the .snap directory inwes2005-01-211-1/+5
| | | | | | | | 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
* Cast to intmax_t when using %jd format.pjd2005-01-081-1/+1
| | | | MFC after: 3 days
* Fix '-s' option for large disks and fix printing maximum file system size.pjd2004-09-191-4/+7
|
* 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-1/+5
| | | | | | | | 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
* Add the -E command line option to force error conditions for testing.wes2003-11-161-1/+5
| | | | Sponsord by: St. Bernard Software
* Use __FBSDID() to quiet GCC 3.3 warnings.obrien2003-05-031-4/+4
|
* Throw the switch--change to UFS2 as our default file system format forrwatson2003-04-201-1/+1
| | | | | | | | | | | | | | | | | | | | FreeBSD 5.1-RELEASE and later: - newfs(8) will now create UFS2 file systems unless UFS1 is specifically requested (-O1). To do this, I just twiddled the Oflag default. - sysinstall(8) will now select UFS2 as the default layout for new file systems unless specifically requested (use '1' and '2' to change the file system layout in the disk labeler). To do this, I inverted the ufs2 flag into a ufs1 flag, since ufs2 is now the default and ufs1 is the edge case. There's a slight semantic change in the key behavior: '2' no longer toggles, it changes the selection to UFS2. This is very similar to a patch David O'Brien sent me at one point, and that I couldn't find. Approved by: re (telecon) Reviewed by: mckusick, phk, bmah
* 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-11/+15
| | | | | | | 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-2/+18
| | | | Reviewed by: mckusick
* Back out conversion to libufs, for now. It seems to cause problems.jmallett2003-01-291-13/+11
| | | | Reported by: phk
* Convert newfs to use libufs. I've tested this on md filesystems, as hasjmallett2003-01-271-11/+13
| | | | keramida, and all seems well.
* Add some more checks to newfs so that it will not build filesystemsmckusick2002-11-301-1/+5
| | | | | | | | | | 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.
* Remove a comma trailing an if clause.phk2002-10-011-1/+1
| | | | | | According to Kirk: "Luckily, the statement is usually true". Spotted by: FlexeLint
* Failure to rewrite the disklabel should not be fatal.phk2002-09-221-4/+2
| | | | Sponsored by: DARPA & NAI Labs.
* s/filesystem/file system/g as discussed on -developerstrhodes2002-08-211-13/+13
|
* This commit adds basic support for the UFS2 filesystem. The UFS2mckusick2002-06-211-56/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* more file system > filesystemtrhodes2002-05-161-9/+9
|
* Remove the -v option, it is now default behaviour.phk2002-04-241-10/+5
| | | | Sponsored by: DARPA & NAI Labs
* Continue the cleanup preparations for UFS2 (& GEOM):phk2002-04-241-152/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | Use only one filedescriptor. Open in R/O or R/W based in the '-N' option. Make the filedescriptor a global variable instead of passing it around as semi-global variable(s). Remove the undocumented ability to specify type without '-T' option. Replace fatal() with straight err(3)/errx(3). Save calls to strerror() where applicable. Loose the progname variable. Get the sense of the cpgflag test correct so we only issue warnings if people specify cpg and can't get that. It can be argued that this should be an error. Remove the check to see if the disk is mounted: Open for writing would fail if it were mounted. Attempt to get the sectorsize and mediasize with the generic disk ioctls, fall back to disklabel and /etc/disktab as we can. Notice that on-disk labels still take precedence over /etc/disktab, this is probably wrong, but not as wrong as the entire concept of /etc/disktab is. Sponsored by: DARPA & NAI Labs.
* bbsize and sbsize cannot ever be trusted from the disklabel, inphk2002-04-071-6/+0
| | | | | | | | | particular as there may not be one. Remove #if 0'ed code which might mislead people to think otherwise. unifdef -ULOSTDIR, fsck can make lost+found on the fly. Sponsored by: DARPA & NAI Labs
* Fixed some style bugs in axings. Whitespace before __P was not axed whenbde2002-04-041-6/+6
| | | | | __P was axed. The ordering of several things was bogotified by axing ifdefs.
* Unifdef -DCOMPATphk2002-04-031-22/+0
|
* Swing the axe and remove some archaic features from newfs which modernphk2002-03-201-141/+14
| | | | | | | | | | | | | | | | | | | diskdrives do neither need nor want: -O create a 4.3BSD format filesystem -d rotational delay between contiguous blocks -k sector 0 skew, per track -l hardware sector interleave -n number of distinguished rotational positions -p spare sectors per track -r revolutions/minute -t tracks/cylinder -x spare sectors per cylinder No change in the produced filesystem image unless one or more of these options were used. Approved by: mckusick
* Add the undocumented -R option to disable randomness for regression-testing.phk2002-03-191-1/+6
| | | | | | | | Add a couple of simple regression tests accessible with "make test", they depend on the md(4) driver. FYI I have also tried running the test against a week old newfs and it passed.
* Further cleanups.phk2002-03-191-6/+7
|
* Complete the ANSIfication of newfs by converting function declarationsiedowse2002-03-191-30/+4
| | | | to C89 style.
OpenPOWER on IntegriCloud