Bug 283583 - makefs(8) -t zfs Assertion on unexpected devfs mount in directory
Summary: makefs(8) -t zfs Assertion on unexpected devfs mount in directory
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 14.2-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: Mark Johnston
URL:
Keywords: crash
: 283888 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-12-25 00:28 UTC by Michael Dexter
Modified: 2025-01-07 21:22 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Dexter freebsd_triage 2024-12-25 00:28:41 UTC
While experimenting with PkgBase and makefs(8) -t zfs VM-IMAGES, I inadvertently left a devfs mount in the directory that would become the rootfs image using the soon-to-be-replaced release engineering VM-IMAGE tools in /usr/src/release

Surprisingly, makefs(8) is devfs(8)-friendly:

'makefs -s 1g img.raw /dev'
Calculated size of `img.raw': 1073741824 bytes, 423 inodes
Extent size set to 32768
density reduced from 2538397 to 8192
img.raw: 1024.0MB (2097152 sectors) block size 32768, fragment size 4096
	using 2 cylinder groups of 626.00MB, 20032 blks, 80128 inodes.
super-block backups (for fsck -b #) at:
      64, 1282112
Populating `img.raw'
Image `img.raw' complete

However mounting devfs(8) on /tmp/test/devfs and making an image of the parent directory /tmp/test results in:

'makefs -t zfs -s 1g -B little -o 'poolname=foo' img.raw /tmp/test/dev'
Assertion failed: (cur->type == S_IFREG || cur->type == S_IFDIR || cur->type == S_IFLNK), function fsnode_foreach, file /home/pkgbuild/worktrees/releng/14.2/usr.sbin/makefs/zfs/fs.c, line 190.
Abort trap (core dumped)

The goal is not necessarily the ability to create a disk image containing devfs(8), but rather to not core dump or provide the user a warning as appropriate.

Tested on 14.2-RELEASE and I can provide the core file if this cannot be reproduced.
Comment 1 Michael Dexter freebsd_triage 2025-01-07 09:04:52 UTC
*** Bug 283888 has been marked as a duplicate of this bug. ***
Comment 2 Mark Johnston freebsd_committer freebsd_triage 2025-01-07 14:24:07 UTC
There's no real way for makefs to handle device nodes except to skip them or create dummy files.  I think printing a warning and skipping is probably the more useful behaviour.
Comment 3 commit-hook freebsd_committer freebsd_triage 2025-01-07 14:33:27 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=ce878284318e71217d8d8f43f7d590b6c338d3aa

commit ce878284318e71217d8d8f43f7d590b6c338d3aa
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-01-07 14:31:02 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-01-07 14:32:20 +0000

    makefs: Handle special file types when creating a zpool

    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

 usr.sbin/makefs/tests/makefs_zfs_tests.sh | 22 +++++++++++++++++
 usr.sbin/makefs/zfs/fs.c                  | 39 +++++++++++++++++++++++++------
 2 files changed, 54 insertions(+), 7 deletions(-)
Comment 4 Michael Dexter freebsd_triage 2025-01-07 21:22:26 UTC
THANK YOU!!!