LinuxKPI debugfs Port

From: Jake Freeland <jake_at_technologyfriends.net>
Date: Tue, 28 Jun 2022 20:38:48 UTC
Hi there,

I am working on porting Intel's igt-gpu-tools drm graphics driver testing
suite to FreeBSD and I ran into some issues regarding debugfs. I spoke
to manu@ who told me that CONFIG_DEBUG_FS is required for the
testing to work properly. I started working on a debugfs port and quickly
got confused about what manu@ meant by implementing "CONFIG_DEBUG_FS".

Some quick internet searching says that CONFIG_DEBUG_FS is a
Linux kernel configuration flag. I am curious how I would go about
implementing this into FreeBSD. I copied the Linux debugfs source
code into a new repository and attempted to compile it on FreeBSD
as a kernel module:

https://github.com/jakesfreeland/debugfs-freebsd

Of course I was met with many, many incompatibility errors. I proceeded
to copy the required `sys/compat/linuxkpi/common/include/linux` headers
into my repository and I was met with two options:

1. continue modifying the LinuxKPI headers and commit my modifications
to src.

2. re-engineer the debugfs source code to comply with the preexisting
LinuxKPI headers.

Many problems come with both approaches. First, if I modify the LinuxKPI
headers, I'd be "copying" over some code from Linux's GPLv2 headers.
I do not know how much I can "copy" before legal issues arise. Second,
if I re-engineer the debugfs source code, I am revolting against what
LinuxKPI
stands for: running Linux code with little-to-no modification. I don't know
what the correct approach is here.

I also discovered that lindebugfs, a curtailed version of Linux's debugfs,
already exists in FreeBSD's src. I am led to believe that this is
exclusively
used under the Linuxulator so it wouldn't help me. Is this correct?

Thank you so much,
Jake Freeland