Currently running Linux GL programs on FreeBSD doesn't work for most people because xf86drm.c checks to see if the dri device has the major number expected. When using linux *_dri.so's (which use this code) they find the FreeBSD dri device, which has a different number, so it either fails if non-root, or deletes it and tries to make a new one with a Linux number (which then fails to work).
This patch first tries to open the device if it exists. If that fails, it checks the major numbers and delete, mknod, and reopens if the number wasn't as expected. Could this be applied? In the meantime I think I'll be making custom linux binaries with this patch for FreeBSD. Joe: I did it this way, because sometimes I've run a linux binary which mangled my /dev/dri/card0, and I've used a FreeBSD binary as root to correct it. It also seemed like an easy fix. -- Eric Anholt <[EMAIL PROTECTED]> http://people.freebsd.org/~anholt/dri/
Index: xf86drm.c =================================================================== RCS file: /cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c,v retrieving revision 1.36 diff -u -r1.36 xf86drm.c --- xf86drm.c 5 Jul 2002 08:31:09 -0000 1.36 +++ xf86drm.c 9 Jul 2002 18:32:25 -0000 @@ -229,7 +229,7 @@ sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, minor); drmMsg("drmOpenDevice: node name is %s\n", buf); - if (stat(buf, &st) || st.st_rdev != dev) { + if (stat(buf, &st)) { if (!isroot) return DRM_ERR_NOT_ROOT; remove(buf); mknod(buf, S_IFCHR | devmode, dev); @@ -243,6 +243,16 @@ drmMsg("drmOpenDevice: open result is %d, (%s)\n", fd, fd < 0 ? strerror(errno) : "OK"); if (fd >= 0) return fd; + + if (st.st_rdev != dev) { + if (!isroot) return DRM_ERR_NOT_ROOT; + remove(buf); + mknod(buf, S_IFCHR | devmode, dev); + } + fd = open(buf, O_RDWR, 0); + drmMsg("drmOpenDevice: open result is %d, (%s)\n", + fd, fd < 0 ? strerror(errno) : "OK"); + drmMsg("drmOpenDevice: Open failed\n"); remove(buf); return -errno; @@ -252,11 +262,13 @@ { int fd; char buf[64]; - - if (create) return drmOpenDevice(makedev(DRM_MAJOR, minor), minor); + + if (create) + return drmOpenDevice(makedev(DRM_MAJOR, minor), minor); sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, minor); - if ((fd = open(buf, O_RDWR, 0)) >= 0) return fd; + if ((fd = open(buf, O_RDWR, 0)) >= 0) + return fd; return -errno; }