From 60d995727a19104a2832d475f5c0861ffbae2c97 Mon Sep 17 00:00:00 2001 From: Ryan Moeller Date: Thu, 8 Sep 2022 13:40:18 -0400 Subject: [PATCH] FreeBSD: Replace legacy make_dev() interface usage The function make_dev_s() was introduced to replace make_dev() in FreeBSD 11.0. It allows further specification of properties and flags and returns an error code on failure. Using this we can fail loading the module more gracefully than a panic in situations such as when a device named zfs already exists. We already use it for zvols. Use make_dev_s() for /dev/zfs. Reviewed-by: Alexander Motin Signed-off-by: Ryan Moeller Closes #13854 --- module/os/freebsd/zfs/kmod_core.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/module/os/freebsd/zfs/kmod_core.c b/module/os/freebsd/zfs/kmod_core.c index 2b808357ec..020ef6a39b 100644 --- a/module/os/freebsd/zfs/kmod_core.c +++ b/module/os/freebsd/zfs/kmod_core.c @@ -219,9 +219,16 @@ static struct cdevsw zfs_cdevsw = { int zfsdev_attach(void) { - zfsdev = make_dev(&zfs_cdevsw, 0x0, UID_ROOT, GID_OPERATOR, 0666, - ZFS_DRIVER); - return (0); + struct make_dev_args args; + + make_dev_args_init(&args); + args.mda_flags = MAKEDEV_CHECKNAME | MAKEDEV_WAITOK; + args.mda_devsw = &zfs_cdevsw; + args.mda_cr = NULL; + args.mda_uid = UID_ROOT; + args.mda_gid = GID_OPERATOR; + args.mda_mode = 0666; + return (make_dev_s(&args, &zfsdev, ZFS_DRIVER)); } void