aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/makefs
Commit message (Collapse)AuthorAgeFilesLines
* makefs: Add SPDX-License-Identifier tagsTuukka Pasanen2026-02-192-0/+4
| | | | | Reviewed by: emaste Sponsored by: The FreeBSD Foundation
* makefs/zfs/tests: Force-destroy md devicesMark Johnston2026-01-251-2/+2
| | | | | | | | | | | | | | | | | | Most of these tests create a md(4) device backed by a makefs-generated image, then import the pool, using the md device as a pool vdev. When a test finishes, it destroys the pool, then destroys the md device. Once in a while md device destruction fails with EBUSY. This happens when a GEOM consumer is holding the device open; kern_mddetach_locked() simply fails if any consumers are present. zpool destruction is synchronous so ZFS is innocent, rather, the problem seems to be that GEOM re-tastes the device after the zpool reference goes away. This operation creates a transient reference that causes the spurious failure. Use "mdconfig -o force" to work around this. MFC after: 2 weeks
* makefs.8: Cleanup man pageJose Luis Duran2026-01-061-4/+5
| | | | | | Reviewed by: ziaee MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D54538
* makefs: Fix typo 's/mirrorring/mirroring/'Jose Luis Duran2026-01-051-1/+1
| | | | MFC after: 1 week
* makefs: tests: Fix timestamp-related testsJose Luis Duran2026-01-055-34/+25
| | | | | | | | | | | | | | | | | Use a variable for mtree that includes the DEFAULT_MTREE_KEYWORDS, in order to avoid missing the important "time" keyword or passing an unimplemented "nlink" keyword. Unskip the "failing" tests, and comment out the specific failing checks, these will be addressed (or at least discussed) in a different revision. For MS-DOS tests, use an even value timestamp, as precision is 2s. For ZFS tests, use import_image instead of mount_image consistently. Reviewed by: bnovkov, markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D54429
* makefs: tests: Fix -D flag testJose Luis Duran2026-01-053-22/+34
| | | | | | | | | | | | | | | As stated in the manual page: -F is almost certainly not the option you are looking for. To create an image from a list of files in an mtree format manifest, specify it as the last argument on the command line, not as the argument to -F. This change does exactly that. Also bug #192839 has already been fixed. Reviewed by: ngie MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D54428
* makefs: tests: Cleanup and remove default flagsJose Luis Duran2026-01-055-218/+154
| | | | | | | | | | | | | | | | | | | | | | | | | Cleanup and remove default atf_check flags for clarity. The following two lines are equivalent: atf_check $cmd atf_check -s exit:0 -e empty -o empty $cmd Update the links to the reference documents. Remove the D_flag_cleanup function, as common_cleanup() for these particular set of tests does two things: 1. Unmount the md(4) device. 2. Destroy the md(4) device. Essentially, one should only call common_cleanup() if the test body invokes mount_image(). This is not the case for D_flag_body(). No functional changes intended. Reviewed by: ngie MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D54427
* makefs: tests: Double the timeout of ZFS file_extend testJose Luis Duran2026-01-051-0/+6
| | | | | | | | | | The test makefs_zfs_tests:file_extend is timing out on ci.freebsd.org. Double the default timeout to allow it to finish. Reported by: Jenkins Reviewed by: asomers MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D54425
* makefs: tests: Double the timeout of ZFS compression testJose Luis Duran2026-01-051-6/+16
| | | | | | | | | | | | | The test makefs_zfs_tests:compression is timing out on ci.freebsd.org. Double the default timeout to allow it to finish. While here, check if the file exists before cleaning up, otherwise, cat may fail. Reported by: Jenkins Reviewed by: asomers MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D54424
* makefs: avoid warnings about too-long initializer stringsDimitry Andric2025-12-261-1/+1
| | | | | | | | | | | | | | Mark `direntry::deName` as `__non_string`, to avoid warnings from clang 21 similar to: usr.sbin/makefs/msdos/msdosfs_vnops.c:512:4: error: initializer-string for character array is too long, array size is 11 but initializer has size 12 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization] 512 | { ". ", /* the . entry */ | ^~~~~~~~~~~~~ usr.sbin/makefs/msdos/msdosfs_vnops.c:522:4: error: initializer-string for character array is too long, array size is 11 but initializer has size 12 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Werror,-Wunterminated-string-initialization] 522 | { ".. ", /* the .. entry */ | ^~~~~~~~~~~~~ MFC after: 3 days
* makefs/tests: Use require.kmods property instead of ad-hoc checksSiva Mahadevan2025-12-163-27/+2
| | | | | | | Signed-off-by: Siva Mahadevan <me@svmhdvn.name> MFC after: 3 days Sponsored by: The FreeBSD Foundation Pull Request: https://github.com/freebsd/freebsd-src/pull/1870
* makefs: Calculate indirect block count properly for large files on ffsBoris Lytochkin2025-08-271-18/+76
| | | | | | | | | | | | | | | | | When building an ffs image containing large file(s), space requirements were calculated incorrectly yielding a bigger image than necessary. The reason is that amount of indirect blocks estimation was done wrong: - single indirect block was treated as it can hold just 12 data blocks - nested indirect blocks were not taken into account at all Add support for indirect blocks and fix another tiny bug with underestimated space requirement for files with size between (UFS_NDADDR-1)*blksz+fragsz ... (UFS_NDADDR)*blksz requesting N>1 fragments instead of a whole block. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D52120
* makefs: zfs uberblock location is calculated wrongToomas Soome2025-08-152-2/+2
| | | | | | | | | | | The shift used to calculate uberblock location depends both on minimum size (UBERBLOCK_SHIFT) and MAX_UBERBLOCK_SHIFT. Since makefs defaults to use ashift 12, it incidentally does get the correct size, but ashift 9 does not work with current code. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D51860
* makefs: zfs dataset mountpoints are considered non-emptyToomas Soome2025-07-291-15/+27
| | | | | | | | | | | | The dataset mountpoints get link count and size calculated by content of dataset root directory, but this will break libzfs dir_is_empty_stat() test. For fix, we need to check if the directory is mountpoint for dataset, and calculate the link count and size accordingly. Reviewed by: markj Differential revision: https://reviews.freebsd.org/D51593
* makefs: clean up warningsToomas Soome2025-07-295-18/+25
| | | | | | | | | | | | | | | | | | | | | | | | zfs/fs.c: zfs/objset.c: zfs/vdev.c: zfs/zap.c: Add include sys/param.h dsl_dir_alloc() needs to set parent = NULL to silence warning about 'parent' may be used uninitialized. Warning is given because we break the loop when nextdir == NULL and parent was not previously set. (it should not happen, but compiler does not know that). zap_add() and zap_fat_write_array_chunk() takes uint8_t *, use type cast. zap_fat_write_array_chunk() should check sz for 0 to avoid use of uninitialized pointer. unchecked function returns. Reviewed by: markj Differential revision: https://reviews.freebsd.org/D51592
* makefs/zfs tests: Run in parallelMark Johnston2025-07-212-5/+1
| | | | | | | | Use the script PID as a pool GUID. This way, tests running in parallel will have pool GUIDs that won't collide, and the tests no longer need to be serialized. MFC after: 1 month
* makefs/zfs: Allow the user to specify the pool GUIDMark Johnston2025-07-212-1/+11
| | | | | | | This will be used by the test suite to enable running makefs/zfs tests in parallel. MFC after: 1 month
* makefs/zfs: Make it possible to set a compression propertyMark Johnston2025-07-213-7/+137
| | | | | | | | | | | | | | | | | makefs currently does not implement compression for ZFS datasets, as doing so seems somewhat fraught with compatibility issues. As a result, the root dataset has compression disabled, and all others inherit from that. However, it may be useful to enable compression for new files once the generated pool is actually imported. Thus, implement a per-data compression option. By default, compression is inherited from the parent dataset and disabled on the root dataset. Add a regression test. PR: 288241 MFC after: 1 month
* makefs: Correct license text in 'makefs_msdos_tests.sh'Bojan Novković2025-07-161-1/+1
| | | | | Sponsored by: Klara, Inc. Sponsored by: The FreeBSD Foundation
* makefs: Fix undefined behaviour in ffs.cBojan Novković2025-07-161-1/+1
| | | | | | | | | | Fix a UBSAN-reported error in `ffs_make_dirbuf` where a zero offset gets applied to a NULL pointer. Sponsored by: Klara, Inc. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D51037 Reviewed by: emaste, mckusick
* msdosfs: Add _WANT_MSDOSFS_INTERNALS to replace MAKEFS in headersJessica Clarke2025-06-161-1/+1
| | | | | | | | | | | | | | | | | | This lets other bits of userspace expose these various definitions too. In particular, this will be used by libprocstat so it can stop defining _KERNEL. The function prototypes surely won't be useful in other contexts, but the various types are, and it's not worth hiding the prototypes unless they end up causing issues, but so long as they aren't called they shouldn't be a problem. Note the MAKEFS define continues to exist, but only for use in newfs_msdos, as those sources are reused by makefs with some changed behaviour. Reviewed by: imp, markj Differential Revision: https://reviews.freebsd.org/D50718
* makefs: Implement the collision differentiator for micro ZAPsMark Johnston2025-06-161-1/+7
| | | | | | | | | | | | | | | | | | | In the unlikely event of a hash collision, the collision differentiator is used to create a unique lookup key for ZAP entries. While the fat ZAP implementation in makefs implemented this, the micro ZAP implementation did not, so it's possible to end up with collisions in directory entries. These are caught deterministically by OpenZFS, but the result is a panic. Implement a simple differentiator by simply assigning a unique value to each ZAP entry. This scheme works since the 16-bit space of differentiators is larger than the maximum number of entries in a micro ZAP. (While the on-disk encoding provides 32 bits of space for the differentiator, the in-memory representation of micro ZAP entries is smaller.) PR: 287482 MFC after: 1 week
* makefs: Add tests for the -T flagBojan Novković2025-05-206-0/+380
| | | | | | | | | | | Add tests for the -T flag to each makefs backend. This includes tests for both mtree and directory scan options. PR: 285630 Sponsored by: Klara, Inc. Sponsored by: The FreeBSD Foundation Reviewed by: markj, emaste, kevans, jlduran Differential Revision: https://reviews.freebsd.org/D49492
* makefs: Remove redundant 'stampst' checks in several backendsBojan Novković2025-05-202-4/+4
| | | | | | | | PR: 285630 Sponsored by: Klara, Inc. Sponsored by: The FreeBSD Foundation Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D49601
* makefs: Honor -T timestamps when creating images from mtree manifestsBojan Novković2025-05-205-19/+41
| | | | | | | | | | | | | | | | | | makefs backends rely on the fsnode structure to derive most of the information about the underlying filesystem objects. Depending on how the image is built, the fsnode structures are initialized in the walk_dir or read_mtree functions. However, read_mtree fails to take timestamps passed by -T into account, leading to nonreproducible images in backends that do not check for -T. Fix this and make -T backend-agnostic by adding an appropriate check in read_mtree_keywords while making sure that mtree entries can still override -T timestamps. PR: 285630 Sponsored by: Klara, Inc. Sponsored by: The FreeBSD Foundation Reviewed by: markj, emaste Differential Revision: https://reviews.freebsd.org/D49531
* makefs: Use gmtime() instead of localtime for timestampsMark Johnston2025-05-081-1/+1
| | | | | | | | | | | Otherwise the output file's contents will depend on the configured time zone. Reviewed by: emaste MFC after: 1 month Sponsored by: Klara, Inc. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D50198
* makefs: Make sure that directory entry order is consistentMark Johnston2025-05-082-31/+60
| | | | | | | | | | | | | | | | | | | | | | | | | When walking a directory hierarchy (as opposed to reading an mtree), makefs builds up a tree of file nodes. Within a directory, the order of the sibling nodes is determined by the order they're returned by readdir(), which isn't very reproducible (e.g., depends on filesystem, build parallelism). Add a routine which sorts entries within a directory after its contents have been read. This is a bit more expensive, but I wasn't able to measure a significant runtime cost (and I don't think makefs has been optimized very much to begin with), and we avoid this cost in mtree mode anyway. This fixes some sources of reproducibility problems. In mtree mode, for now we let the ordering of METALOG entries determine the ordering in the fsnode tree. It might be worth sorting these too, since with parallel installworld they won't have a consistent ordering, and single-threaded installworld is pretty slow. Reviewed by: emaste MFC after: 1 month Sponsored by: Klara, Inc. Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D50197
* 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
* makefs: Support st_flags even on LinuxJessica Clarke2025-05-064-14/+21
| | | | | | | | | | | | | | | | | Linux's struct stat does not have an st_flags member, but we still want to be able to create FreeBSD disk images with non-zero st_flags. Add a replacement member to struct fsinode to store it on Linux. Note that we add a fallback definition of HAVE_STRUCT_STAT_ST_FLAGS for makefs.h since etdump reaches into makefs and won't have it defined in its CFLAGS like makefs itself does, and on FreeBSD we don't provide an nbtool_config.h. Note also that strtofflags is currently a stub on Linux so this doesn't yet properly mirror the mtree, but that will change in a future commit. Reviewed by: emaste, markj Differential Revision: https://reviews.freebsd.org/D50078
* makefs: Fix a couple of HAVE_STRUCT_STAT_BIRTHTIME checksJessica Clarke2025-05-062-2/+2
| | | | | | | | | | These macros are meant to be 0/1 not undefined/1. Currently we don't actually have nbtool_config.h included for these files so these are always false, but that will change in a future commit and break building on Linux where they are defined to 0. Reviewed by: emaste, markj Differential Revision: https://reviews.freebsd.org/D50077
* makefs: Initialize cd9660 inode map only onceEd Maste2025-03-011-7/+13
| | | | | | | | Error introduced during a refactoring; cd9660_susp_initialize calls itself recursively. Sponsred by: The FreeBSD Foundation Fixes: 35a2e286157a ("makefs: Record inode for all entries in mtree mode")
* makefs: Compare pointer against NULL, not 0Ed Maste2025-02-281-1/+1
| | | | | | Reported by: rpokala Sponsred by: The FreeBSD Foundation Fixes: 35a2e286157a ("makefs: Record inode for all entries in mtree mode")
* makefs: Make cd9660 Rock Ridge inodes reproducibleEd Maste2025-02-283-10/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rock Ridge extensions include an inode field: "POSIX File Serial Number" shall have the same meaning as and may be used for the st_ino field of POSIX:5.6.1. This field shall be recorded according to ISO 9660:7.3.3. Directory Records which share the value of this field are defined as links (see POSIX:2.2.2.17) and, by definition, point to the same file or directory. Previously we'd store the source file's st_ino (except that in metalog mode we'd record 0 for files with nlink = 1). This had two issues: the generated ISO image was nonreproducible due to the arbitrary inode numbers, and files without hard links would falsely be detected (by certain tools) as hard links to each other. Note that the kernel's cd9660(5) file system ignores the Rock Ridge PX File Serial Number, so this issue isn't observed by mounting such a file system. Instead of using the source inode directly, assign target inode numbers sequentially. Use a map so that files with the same source inode (hard links) still receive the same target inode number. PR: 284795 PR: 285027 Reviewed by: brooks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49141
* src: Use gnu17 as the default C standard for userland instead of gnu99Minsoo Choo2025-02-111-1/+0
| | | | | | | | | | | | | | | | | | | | | | Tracking newer versions of C (and C++) permits assuming newer language features in the base system. Some C11 extensions are already used in the base system but implemented on top of GNU C extensions such as _Alignas and _Static_assert. In some cases the fallback versions in cdefs.h are more limited than the native C11 extensions. Even though C11 is the next major version of C, C17 is chosen instead since C17 does not add new features to C but merely fixes defects in C11. It is also well supported by a wide range of clang (7.0.0+) and GCC (8.1+) versions. Along with changing the default, this change also removes explicit requests for c11 via the CSTD variable in various Makefiles. Libraries and binaries for ZFS continue to use c99. PR: 284039 (exp-run) Reviewed by: imp, arichardson, emaste Differential Revision: https://reviews.freebsd.org/D43237
* Standardize the definition of a UFS dinode.Kirk McKusick2025-01-282-54/+49
| | | | | | | | | | | | | | | | 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
* makefs: Handle special file types when creating a zpoolMark Johnston2025-01-072-7/+54
| | | | | | | | | | Previously, anything other than a regular file, directory or symlink would cause makefs to exit with an assertion failure. Make it a bit more resilient to user error: print a warning and skip the file. Add a regression test wherein we create an image from a devfs mount. PR: 283583 MFC after: 2 weeks
* makefs: Remove dead code in inode_type()Mark Johnston2025-01-071-2/+0
| | | | | | No functional change intended. MFC after: 1 week
* makefs: Fix cd9660 duplicate directory namesEd Maste2024-12-303-5/+41
| | | | | | | | | | | | | | | | | | | | | | | | | Previously we could create cd9660 images with duplicate short (level 2) names. cd9660_level2_convert_filename used a 30-character limit (for files and directories), not including the '.' separator. cd9660_rename_filename used a 31-character limit, including the '.'. Directory names 31 characters or longer (without '.') were shortened to 30 characters, and if a collision occurred cd9660_rename_filename uniquified them starting with the 31st character. Unfortunately the directory record's name_len was already set, so the unique part of the name was stripped off. Directories are up to 31 d-characters (i.e., A-Z 0-9 and _); there is no provision for a '.' in a directory name. Increase the name length limit to 31 for directories, and exclude '.'s. This name mapping and deduplication code is still fragile and convoluted and would beenfit from a more holistic effort. PR: 283238, 283112 Reviewed by: imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48251
* makefs: Remove impossible if conditionEd Maste2024-12-291-5/+1
| | | | | | | | | This test is inside the else block for `if (*oldname == '.')`, so *oldname cannot be '.' here. Reviewed by: kevans Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48243
* makefs: Fix cd9660 filename buffer maximum lengthEd Maste2024-12-262-14/+11
| | | | | | | | | | | | | | | | | | | | | The maximum length is 30 characters for name and extension, two separators (. and ;) and 5 characters for file version from 1 to 32767, which is 37 characters. Add one for the null term as we treat these buffers as C strings. This is not an issue in practice, as the file version is always 1 in makefs. While here, drop `_WITH_PADDING` from the macro name and update the previously-unused ISO_FILENAME_MAXLENGTH for the corrected length. A 0x00 padding byte is used by ISO9660 when needed for alignment, which can be the null byte at the end of the string. Use sizeof where appropriate. Reviewed by: kevans Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48193
* makefs: Exit with error if writing cd image failsEd Maste2024-12-231-3/+6
| | | | | Obtained from: OpenBSD c8f48d9b1ea9 Sponsored by: The FreeBSD Foundation
* makefs: Crudely fix a sprintf warningEd Maste2024-12-231-13/+19
| | | | | | | Reviewed by: kevans Obtained from: OpenBSD d95291fdb2dc Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48178
* makefs.8: Clarify that makefs-generated zpools always have the same GUIDMark Johnston2024-11-191-1/+18
| | | | | PR: 282832 MFC after: 1 week
* makefs.8: Remove a warning about makefs -t zfs being experimentalMark Johnston2024-11-191-3/+0
| | | | | | | This should have been done with commit d9fe71828797 but was missed. Fixes: d9fe71828797 ("makefs: Remove the warning printed when makefs -t zfs is used") MFC after: 3 days
* makefs: Remove a stray semicolonZhenlei Huang2024-10-241-1/+1
| | | | MFC after: 1 week
* makefs: Record a larger TXG number in the uberblockMark Johnston2024-10-144-1/+19
| | | | | | | | | | | | | By default, OpenZFS will perform metadata verification of the most recent TXGs, but this can be very slow since all data in a pool generated by makefs was logically written in a single transaction. Avoid triggering this verification by default, but add an option to restore the previous behaviour and enable it in regression test cases. Reported by: cperciva Tested by: cperciva (previous version) MFC after: 2 weeks
* makefs: Remove the warning printed when makefs -t zfs is usedMark Johnston2024-10-043-9/+3
| | | | | | | | We haven't seen bug reports relating to this feature for a while, so stop printing a warning. Reviewed by: cperciva MFC after: 2 weeks
* Explain the relationship between -p and -Z.Greg Lehey2024-09-261-1/+3
|
* Remove residual blank line at start of MakefileWarner Losh2024-07-152-2/+0
| | | | | | | This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
* makefs/zfs: Add a helper function for adding ZAP entriesMark Johnston2024-06-013-3/+11
| | | | | | | | Some ZAPs are used to represent sets, in which keys and values are the same. Add a helper function for this case. No functional change intended. MFC after: 1 week