xref: /freebsd/sys/contrib/openzfs/config/kernel-misc-minor.m4 (revision a90b9d0159070121c221b966469c3e36d912bf82)
1dnl #
2dnl # Determine an available miscellaneous minor number which can be used
3dnl # for the /dev/zfs device.  This is needed because kernel module
4dnl # auto-loading depends on registering a reserved non-conflicting minor
5dnl # number.  Start with a large known available unreserved minor and work
6dnl # our way down to lower value if a collision is detected.
7dnl #
8AC_DEFUN([ZFS_AC_KERNEL_MISC_MINOR], [
9	AC_MSG_CHECKING([whether /dev/zfs minor is available])
10
11	for i in $(seq 249 -1 200); do
12		if ! grep -q "^#define\s\+.*_MINOR\s\+.*$i" \
13		    ${LINUX}/include/linux/miscdevice.h; then
14			ZFS_DEVICE_MINOR="$i"
15			AC_MSG_RESULT($ZFS_DEVICE_MINOR)
16			AC_DEFINE_UNQUOTED([ZFS_DEVICE_MINOR],
17			    [$ZFS_DEVICE_MINOR], [/dev/zfs minor])
18			break
19		fi
20	done
21
22	AS_IF([ test -z "$ZFS_DEVICE_MINOR"], [
23		AC_MSG_ERROR([
24	*** No available misc minor numbers available for use.])
25	])
26])
27