summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJocelyn Falempe <jfalempe@redhat.com>2022-04-14 14:39:37 +0200
committerJocelyn Falempe <jfalempe@redhat.com>2022-10-27 00:15:32 +0200
commitf1895cc6dfdfcb0ac3b1250e88596938a5a664be (patch)
tree32a79cff8219f1c4d0dca9c54d0f2e9f4050aa1c
parente285658e60d9cf772dda4b2c713ad2a0d4cef569 (diff)
downloadxorg-driver-xf86-video-vesa-f1895cc6dfdfcb0ac3b1250e88596938a5a664be.tar.gz
Refuse to run if framebuffer or dri devices are present
The simpledrm driver, introduced in kernel 5.14, can replace efifb to provide the efi framebuffer. This fixes a bug on Fedora 36 (first version to use simpledrm driver): https://bugzilla.redhat.com/show_bug.cgi?id=2074789 v2: check for framebuffer or dri devices instead of efi framebuffer interface. Reviewed-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
-rw-r--r--src/vesa.c39
1 files changed, 34 insertions, 5 deletions
diff --git a/src/vesa.c b/src/vesa.c
index a8cc4a6..d510faf 100644
--- a/src/vesa.c
+++ b/src/vesa.c
@@ -44,6 +44,7 @@
#include <string.h>
#include <unistd.h>
+#include <dirent.h>
#include "vesa.h"
/* All drivers initialising the SW cursor need this */
@@ -437,12 +438,40 @@ VESAInitScrn(ScrnInfoPtr pScrn)
pScrn->FreeScreen = VESAFreeScreen;
}
+#ifdef XSERVER_LIBPCIACCESS
+#ifdef __linux__
+/*
+ * check if a file exist in directory
+ * should be equivalent to a glob ${directory}/${prefix}*
+ */
+
+static Bool
+VESAFileExistsPrefix(const char *directory, const char *prefix) {
+ DIR *dir;
+ struct dirent *entry;
+ Bool found = FALSE;
+ int len = strlen(prefix);
+
+ dir = opendir(directory);
+ if (!dir)
+ return FALSE;
+
+ while ((entry = readdir(dir)) != NULL) {
+ if (strlen(entry->d_name) > len &&
+ !memcmp(entry->d_name, prefix, len)) {
+ found = TRUE;
+ break;
+ }
+ }
+ closedir(dir);
+ return found;
+}
+#endif
+
/*
* This function is called once, at the start of the first server generation to
* do a minimal probe for supported hardware.
*/
-
-#ifdef XSERVER_LIBPCIACCESS
static Bool
VESAPciProbe(DriverPtr drv, int entity_num, struct pci_device *dev,
intptr_t match_data)
@@ -450,9 +479,9 @@ VESAPciProbe(DriverPtr drv, int entity_num, struct pci_device *dev,
ScrnInfoPtr pScrn;
#ifdef __linux__
- if (access("/sys/devices/platform/efi-framebuffer.0", F_OK) == 0 ||
- access("/sys/devices/platform/efifb.0", F_OK) == 0) {
- ErrorF("vesa: Refusing to run on UEFI\n");
+ if (VESAFileExistsPrefix("/dev", "fb") ||
+ VESAFileExistsPrefix("/dev/dri", "card")) {
+ ErrorF("vesa: Refusing to run, Framebuffer or dri device present\n");
return FALSE;
}
#endif