Skip to content

Commit 60d9957

Browse files
author
Ryan Moeller
authored
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 <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #13854
1 parent e27e692 commit 60d9957

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

module/os/freebsd/zfs/kmod_core.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,16 @@ static struct cdevsw zfs_cdevsw = {
219219
int
220220
zfsdev_attach(void)
221221
{
222-
zfsdev = make_dev(&zfs_cdevsw, 0x0, UID_ROOT, GID_OPERATOR, 0666,
223-
ZFS_DRIVER);
224-
return (0);
222+
struct make_dev_args args;
223+
224+
make_dev_args_init(&args);
225+
args.mda_flags = MAKEDEV_CHECKNAME | MAKEDEV_WAITOK;
226+
args.mda_devsw = &zfs_cdevsw;
227+
args.mda_cr = NULL;
228+
args.mda_uid = UID_ROOT;
229+
args.mda_gid = GID_OPERATOR;
230+
args.mda_mode = 0666;
231+
return (make_dev_s(&args, &zfsdev, ZFS_DRIVER));
225232
}
226233

227234
void

0 commit comments

Comments
 (0)