diff --git a/lib/libsysdecode/Makefile b/lib/libsysdecode/Makefile --- a/lib/libsysdecode/Makefile +++ b/lib/libsysdecode/Makefile @@ -121,6 +121,11 @@ CFLAGS+=-DPF .endif +ZFSINC= ${SRCTOP}/sys/contrib/openzfs/include +.if ${MK_ZFS} != "no" +CFLAGS+=-DZFS -I${ZFSINC} +.endif + # Workaround duplicate declarations in CFLAGS.gcc.ioctl.c+= -Wno-redundant-decls @@ -139,6 +144,7 @@ .endif ioctl.c.tmp: mkioctls .META env CPP="${CPP}" MK_PF="${MK_PF}" \ + MK_ZFS="${MK_ZFS}" ZFSINC="${ZFSINC}" \ /bin/sh ${.CURDIR}/mkioctls ${SYSROOT:U${DESTDIR}}${INCLUDEDIR} > ${.TARGET} ioctl.c: ioctl.c.tmp diff --git a/lib/libsysdecode/mkioctls b/lib/libsysdecode/mkioctls --- a/lib/libsysdecode/mkioctls +++ b/lib/libsysdecode/mkioctls @@ -75,6 +75,11 @@ print "#include " print "#include " print "#include " + print "#ifdef ZFS" + print "#define boolean_t int" + print "#define hrtime_t int" + print "#include " + print "#endif" print "" print ioctl_includes print "" @@ -99,9 +104,17 @@ printf("if (val == %s)\n", $i); printf("\t\tstr = \"%s\";\n", $i); } -END { - print "" - print "\treturn (str);" - print "}" -} ' +# ZFS is special +if [ "${MK_ZFS}" = "yes" ]; then + sed -nE 's/^ (ZFS_IOC_[A-Z0-9_]+).*$/\1/p' ${ZFSINC}/sys/fs/zfs.h | + sort -u | grep -vE 'ZFS_IOC_(FIRST|LAST)' | + while read ioc; do + printf "\telse if ((val & 0xffff) == $ioc + ('Z' << 8))\n" + printf "\t\tstr = \"$ioc\";\n" + done +fi + +printf "\n" +printf "\treturn (str);\n" +printf "}\n"