On 6/30/20 11:53 AM, Gerd Hoffmann wrote:
-util-obj-$(CONFIG_POSIX) += drm.o
+util-obj-$(CONFIG_LINUX) += drm.o
Can't see anything linux-specific there. Also note that FreeBSD (and
possibly other *BSDs too) have drm support. So CONFIG_POSIX looks
correct to me.
This change was my suggestion; I assumed that "open /dev/dri/whatever"
was Linux-specific. The specific thing that doesn't work on
Haiku, or on Solaris for that matter, is that the code uses
DT_CHR, which isn't in POSIX but is a Linux-and-BSDism.
Ah, that is the problem. Yes, DT_CHR is an non-posix optimization which
allows to get the file type directly, without another round-trip to the
kernel. If that isn't available you can stat() the file and check
((st_mode & S_IFMT) == S_IFCHR) instead.
Even when d_type and DT_CHR is available, there are filesystems where
the Linux kernel reports d_type of DT_UNKNOWN, and where you are best
having that code also falling back to an fstat(). In short, any
portable code that uses d_type should have fallback code for DT_UNKNOWN,
at which point porting to systems without d_type is as easy as writing
an accessor macro that returns d_type when it exists and DT_UNKNOWN
where it doesn't.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org