Fixed bug 4624 - KMS/DRM fails on FreeBSD because /dev/dri/card* nodes are symlinks
authorSam Lantinga <slouken@libsdl.org>
Tue, 18 Jun 2019 14:15:10 -0700
changeset 12884e490856ac51c
parent 12883 72ab279ffcaa
child 12885 3a80ee66f621
Fixed bug 4624 - KMS/DRM fails on FreeBSD because /dev/dri/card* nodes are symlinks

Jan Martin Mikkelsen

Patch to scan /dev/dri based on names rather than file type

Loading KMS/DRM on FreeBSD fails because the "available" code in the driver checks for character device nodes under /dev/dri and the /dev/dri/card* files are symlinks rather than device nodes nodes on FreeBSD. The symlink points to /dev/drm/0.

The attached patch counts /dev/dri/card* entries rather than directory entries which are character devices.
src/video/kmsdrm/SDL_kmsdrmvideo.c
     1.1 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c	Tue Jun 18 16:53:49 2019 -0400
     1.2 +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c	Tue Jun 18 14:15:10 2019 -0700
     1.3 @@ -101,7 +101,7 @@
     1.4      folder = opendir(KMSDRM_DRI_PATH);
     1.5      if (folder) {
     1.6          while ((res = readdir(folder))) {
     1.7 -            if (res->d_type == DT_CHR) {
     1.8 +            if (res->d_namlen > 4 && strncmp(res->d_name, "card", 4)) {
     1.9                  devcount++;
    1.10              }
    1.11          }