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