aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/makefs/ffs
Commit message (Collapse)AuthorAgeFilesLines
* makefs: Ensure that FFS superblocks are reproducibleMark Johnston2025-05-081-2/+10
| | | | | | | | | | | | | | | | The superblock structure has space reserved for a pointer to an in-memory structure that gets created at mount time. makefs populates it since that simplifies code elsewhere. However, the pointer value ends up in the output file, which breaks reproducibility. Zero the field when writing the superblock instead, as its on-disk value is ignored. Reviewed by: emaste MFC after: 2 weeks Sponsored by: Klara, Inc. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D50196
* Standardize the definition of a UFS dinode.Kirk McKusick2025-01-281-43/+38
| | | | | | | | | | | | | | | | Each program that operates on UFS on-disk inodes defines its own version of a dinode. They all (of necessity) define the same layout but use different names. This change adds a definition of a dinode (a union of a UFS1 on-disk inode and a UFS2 on-disk inode) as well as a dinodep (a union of a pointer to a UFS1 on-disk inode and a pointer to a UFS2 on-disk inode) in sys/ufs/ufs/dinode.h. It then deletes the definitions of dinode and dinodep in all the programs that operate on them and instead uses these standard definitions. No functional change intended. MFC-after: 1 week
* usr.sbin: Automated cleanup of cdefs and other formattingWarner Losh2023-11-277-7/+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
* usr.sbin: Remove ancient SCCS tags.Warner Losh2023-11-276-12/+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
* makefs: clean up some leftovers after $FreeBSD$ tag removalEd Maste2023-08-161-2/+0
| | | | Fixes: 2a63c3be1582
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-167-14/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* Remove $FreeBSD$: one-line .h patternWarner Losh2023-08-162-2/+0
| | | | Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-163-6/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* ffs: restore backward compatibility of newfs and makefs with older binariesChuck Silvers2023-05-301-3/+23
| | | | | | | | | | | | | | | | The previous change to CGSIZE had the unintended side-effect of allowing newfs and makefs to create file systems that would fail validation when examined by older commands and kernels, by allowing newfs/makefs to pack slightly more blocks into a CG than those older binaries think is valid. Fix this by having newfs/makefs artificially restrict the number of blocks in a CG to the slightly smaller value that those older binaries will accept. The validation code will continue to accept the slightly larger value that the current newfs/makefs (before this change) could create. Fixes: 0a6e34e950cd5889122a199c34519b67569be9cc Reviewed by: mckusick MFC after: 3 days Sponsored by: Netflix
* Fix size differences between architectures of the UFS/FFS CGSIZE macro value.Kirk McKusick2023-05-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The cylinder group header structure ended with `u_int8_t cg_space[1]' representing the beginning of the inode bitmap array. Some architectures like the i386 rounded this up to a 4-byte boundry while other architectures like the amd64 rounded it up to an 8-byte boundry. Thus sizeof(struct cg) was four bytes bigger on an amd64 machine than on an i386 machine. If a filesystem created on an i386 machine was moved to an amd64 machine, the size of the cylinder group calculated by the CGSIZE macro would appear to grow by four bytes. Filesystems whose cylinder groups were exactly equal to the block size on an i386 machine would appear to have a cylinder group that was four bytes too big when moved to an amd64 machine. Note that although the structure appears to be too big, it in fact is fine. It is just the calaculation of its size that is in error. The fix is to remove the cg_space element from the cylinder-group structure so that the calculated size of the structure is the same size on all architectures. Reported by: Tijl Coosemans Tested by: Tijl Coosemans and Peter Holm MFC after: 1 week Sponsored by: The FreeBSD Foundation
* spdx: The BSD-2-Clause-NetBSD identifier is obsolete, drop -NetBSDWarner Losh2023-05-123-3/+3
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-NetBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* makefs: call brelse from breadEd Maste2023-04-161-10/+15
| | | | | | | | | | | This matches NetBSD and rationalizes makefs with the kernel API. This reverts commit 370e009188ba90c3290b1479aa06ec98b66e140a. Reviewed by: mckusick Sponsored by: The FreeBSD Foundation Obtained from: NetBSD 0a62dad69f62, 0c4125e1a19f, cb6a5a3575fd Differential Revision: https://reviews.freebsd.org/D39070
* makefs: use %s and __func__ in printf messagesEd Maste2023-04-111-6/+7
| | | | | | | For diff reduction against NetBSD. Obtained from: NetBSD 0c4125e1a19f Sponsored by: The FreeBSD Foundation
* makefs: use size_t or ssize_t where appropriateEd Maste2023-04-101-3/+3
| | | | Obtained from: NetBSD af7bc97830ac
* makefs(8): do not print comma after the last super-blockChristos Margiolis2023-04-051-2/+3
| | | | | | Reviewed by: markj, emaste MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D39430
* makefs: do not call brelse if bread returns an errorEd Maste2023-03-141-2/+0
| | | | | | | | | | | If bread returns an error there is no bp to brelse. One of these changes was taken from NetBSD commit 0a62dad69f62 ("This works well enough to populate..."), the rest were found by looking for the same pattern. Reviewed by: imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39069
* makefs: Ignore some sign comparison warnings from GCC.John Baldwin2022-11-231-0/+2
| | | | | Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D37470
* makefs: whitespace cleanup (remove space before tab)Ed Maste2022-09-201-1/+1
| | | | MFC after: 1 week
* makefs(8): Fix a few typos in source code commentsGordon Bergling2022-02-061-3/+3
| | | | | | | | - s/concearned/concerned/ - s/quadradically/quadratically/ Obtained from: NetBSD MFC after: 3 days
* ufs: Rework shortlink handling to avoid subobject overflowsJessica Clarke2022-01-021-2/+2
| | | | | | | | | | | | | | | | | | | | Shortlinks occupy the space of both di_db and di_ib when used. However, everywhere that wants to read or write a shortlink takes a pointer do di_db and promptly runs off the end of it into di_ib. This is fine on most architectures, if a little dodgy. However, on CHERI, the compiler can optionally restrict the bounds on pointers to subobjects to just that subobject, in order to mitigate intra-object buffer overflows, and this is enabled in CheriBSD's pure-capability kernels. Instead, clean this up by inserting a union such that a new di_shortlink can be added with the right size and element type, avoiding the need to cast and allowing the use of the DIP macro to access the field. This also mirrors how the ext2fs code implements extents support, with the exact same structure other than having a uint32_t i_data[] instead of a char di_shortlink[]. Reviewed by: mckusick, jhb Differential Revision: https://reviews.freebsd.org/D33650
* makefs: Cast daddr_t to off_t before multiplicationNathaniel Filardo2021-06-152-4/+4
| | | | | | | | | | | Apparently some large-file systems out there, such as my powerpc64le Linux box, define daddr_t as a 32-bit type, which is sad and stymies cross-building disk images. Cast daddr_t to off_t before doing arithmetic that overflows. Reviewed by: arichardson, jrtc27, imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D27458
* Allocate extra inodes in makefs when leaving free space in UFS images.Nathan Whitehorn2021-04-061-1/+17
| | | | | | | | | | | | | | By default, makefs(8) has very few spare inodes in its output images, which is fine for static filesystems, but not so great for VM images where many more files will be added. Make makefs(8) use the same default settings as newfs(8) when creating images with free space -- there isn't much point to leaving free space on the image if you can't put files there. If no free space is requested, use current behavior of a minimal number of available inodes. Reviewed by: manu MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D29492
* Remove #define _KERNEL hacks from libprocstatKonstantin Belousov2021-02-215-55/+67
| | | | | | | | | | | | | | | | | | Make sys/buf.h, sys/pipe.h, sys/fs/devfs/devfs*.h headers usable in userspace, assuming that the consumer has an idea what it is for. Unhide more material from sys/mount.h and sys/ufs/ufs/inode.h, sys/ufs/ufs/ufsmount.h for consumption of userspace tools, with the same caveat. Remove unacceptable hack from usr.sbin/makefs which relied on sys/buf.h being unusable in userspace, where it override struct buf with its own definition. Instead, provide struct m_buf and struct m_vnode and adapt code to use local variants. Reviewed by: mckusick Tested by: pho Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D28679
* Fix -Wpointer-sign warnings in makefs and mkimgAlex Richardson2021-01-072-2/+3
| | | | | Reviewed By: emaste Differential Revision: https://reviews.freebsd.org/D27175
* Allocate an fs_summary_info structure when creating a UFS filesystemKirk McKusick2020-06-191-0/+1
| | | | | | | | | | needed since introduced in -r362358. PR: 247425 Sponsored by: Netflix Notes: svn path=/head/; revision=362418
* makefs: share denode.h between kernel msdosfs and makefsEd Maste2019-08-211-0/+1
| | | | | | | | | | | There is no need to duplicate this file when it can be trivially shared (just exposing sections previously under #ifdef _KERNEL). MFC with: r351273 Differential Revision: The FreeBSD Foundation Notes: svn path=/head/; revision=351346
* makefs: use `char *` not `void *` for buf b_data, drop casts in msdosEd Maste2019-08-211-1/+1
| | | | | | | | | | | | | (The kernel uses caddr_t.) Suggested by: cem Reviewed by: cem MFC with: r351273 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21348 Notes: svn path=/head/; revision=351319
* makefs: use FreeBSD brelse function signatureEd Maste2018-07-264-25/+25
| | | | | | | | | | | | Although the ffs (and later msdosfs) implementation in makefs is independent of the one in kernel, it makes sense to keep differences to a minimum in order to ease comparison and porting changes across. Submitted by: Siva Mahadevan Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=336736
* makefs: ANSIfyEd Maste2018-05-161-16/+4
| | | | Notes: svn path=/head/; revision=333664
* makefs: tidy up reach-over sourceEd Maste2018-04-201-3/+3
| | | | | | | | | | | | | - cd9660 relies on an #include "iso.h" but does not build any .c files out of source, so remove reach-over .PATH - ffs does not rely on any sys/ headers, so remove -I from CFLAGS. - ffs_tables from sys/ is used by ffs; move the SRCS entry from the top- level Makefile to ffs' Makefile.inc. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=332844
* various: general adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-275-5/+15
| | | | | | | | | | | | | | | | | 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
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-207-6/+20
| | | | | | | | | | | | | | | | | 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
* makefs: rename variable for NetBSD diff reductionEd Maste2017-06-031-2/+2
| | | | Notes: svn path=/head/; revision=319521
* makefs: add -O (offset) optionEd Maste2017-05-262-7/+5
| | | | | | | | | | | | | | | | | | NetBSD revs: ffs.c 1.60 makefs.8 1.44 makefs.c 1.48 makefs.h 1.33 ffs/buf.c 1.20 ffs/mkfs.c 1.27 Obtained from: NetBSD Relnotes: Yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D10780 Notes: svn path=/head/; revision=318951
* makefs: make buf genericEd Maste2017-05-255-41/+36
| | | | | | | | | | | | | | | | | | | | it has nothing to do with ffs and will eventually be moved. gc sectorsize. This is a corrected version of r317744. NetBSD versions: ffs.c 1.58 ffs/buf.c 1.14 1.18 ffs/buf.h 1.8 Submitted by: Siva Mahadevan <smahadevan@freebsdfoundation.org> Obtained from: NetBSD Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D10803 Notes: svn path=/head/; revision=318902
* makefs: Add soft-updates optionEmmanuel Vadot2017-05-181-0/+2
| | | | | | | | | | | | Add the ffs option to enable soft-updates. The option is only processed is ufs2 has been selected. Reviewed by: emaste, bapt (earlier version), allanjude (earlier version) Sponsored by: Gandi.net Differential Revision: https://reviews.freebsd.org/D10773 Notes: svn path=/head/; revision=318452
* makefs: clean up signedness warnings and bump WARNS to 3Ed Maste2017-05-183-12/+14
| | | | | | | | | Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D10650 Notes: svn path=/head/; revision=318451
* Restore `sectorsize` global to unbreak makefs after r317744Enji Cooper2017-05-081-4/+4
| | | | | | | | | | This also unbreaks the fstyp tests. Reported by: Alastair Hogge <agh@fastmail.fm>, Jenkins Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=317967
* makefs: clean up warningsEd Maste2017-05-032-13/+15
| | | | | | | | | | | - make functions and variables static where appropriate - use const char * where appropriate - remove unused variables Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=317746
* makefs: make buf genericEd Maste2017-05-032-19/+8
| | | | | | | | | | | | | | | | it has nothing to do with ffs and will eventually be moved. gc sectorsize. NetBSD versions: ffs.c 1.58 ffs/buf.c 1.14 1.18 ffs/buf.h 1.8 Obtained from: NetBSD Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=317744
* makefs: use emalloc and friendsEd Maste2017-04-062-15/+7
| | | | | | | | | | | | | | | | | | | | | | | The emalloc set of error-checking memory allocation routines were added to libnetbsd in r316572. Use them in makefs to reduce differences with NetBSD. NetBSD revs: cd9660.c 1.39 ffs.c 1.56 makefs.c 1.42 walk.c 1.27 cd9660/cd9660_archimedes.c 1.2 cd9660/cd9660_eltorito.c 1.20 cd9660/cd9660_write.c 1.16 cd9660/iso9660_rrip.c 1.12 ffs/buf.c 1.17 ffs/mkfs.c 1.26 Obtained from: NetBSD Notes: svn path=/head/; revision=316579
* makefs: zero memoryEd Maste2017-04-061-0/+2
| | | | | | | | | | NetBSD revs: ffs/buf.c 1.14 Obtained from: NetBSD Notes: svn path=/head/; revision=316545
* makefs: improve error messagesEd Maste2017-03-152-19/+20
| | | | | | | | | | | | | | | | - remove \n - use __func__ - err adds the error string itself NetBSD revs: cd9660.c 1.48 1.49 ffs/buf.c 1.21 ffs/mkfs.c 1.27 Obtained from: NetBSD Notes: svn path=/head/; revision=315321
* makefs: don't print pointers in debugging messagesEd Maste2017-03-151-8/+6
| | | | | | | | | | NetBSD revisions: ffs/buf.c 1.14 Obtained from: NetBSD Notes: svn path=/head/; revision=315317
* makefs: remove unused variableEd Maste2017-03-141-2/+1
| | | | | | | | | | NetBSD revisions: mkfs.c 1.32 Obtained from: NetBSD Notes: svn path=/head/; revision=315271
* makefs: remove clause 3 & 4 from Manuel Bouyer licenseEd Maste2017-03-022-10/+0
| | | | | | | | | | | ffs_bswap.c 1.34 ufs_bswap.h 1.34 Obtained from: NetBSD Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=314537
* makefs: remove archaic __P prototypes from ufs_bswap.hEd Maste2017-03-021-4/+0
| | | | | | | | | This reduces differences with NetBSD Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=314536
* prefix UFS symbols with UFS_ to reduce namespace pollutionEd Maste2017-02-154-28/+29
| | | | | | | | | | | | | | | | | | | | | 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
* makefs: make the buffer functions look exactly like the kernel onesEd Maste2017-02-114-60/+76
| | | | | | | | | | | | | | | | | | | | | From NetBSD christos Sat Jan 26 00:19:39 2013 +0000 make the buffer functions look exactly like the kernel ones and add other cruft to make the kernel files compile. ffs.c 1.54 ffs/buf.c 1.13 ffs/buf.h 1.3 ffs/ffs_alloc.c 1.21 ffs/ffs_balloc.c 1.15 Reviewed by: marcel, ngie Obtained from: NetBSD Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8404 Notes: svn path=/head/; revision=313575