aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt2002-08-08 16:23:46 -0500
committerEric Anholt2002-08-08 16:23:46 -0500
commitd2f2b42f1d206fd248ada48ce2c498e31351ab33 (patch)
tree318d984dcd9a1530e15dcccbbb39753c5fc635ca /libdrm/xf86drm.c
parent977b420d5dc66db3d4335132861a1eff3747b49a (diff)
downloadexternal-libdrm-d2f2b42f1d206fd248ada48ce2c498e31351ab33.tar.gz
external-libdrm-d2f2b42f1d206fd248ada48ce2c498e31351ab33.tar.xz
external-libdrm-d2f2b42f1d206fd248ada48ce2c498e31351ab33.zip
Try to open the /dev/dri/cardX device once, then only if it fails check the
device number and recreate it if necessary. Fixes xf86drm.c to allow linux binaries to be used for emulation on FreeBSD.
Diffstat (limited to 'libdrm/xf86drm.c')
-rw-r--r--libdrm/xf86drm.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c
index b5375ee5..d2ce5e1e 100644
--- a/libdrm/xf86drm.c
+++ b/libdrm/xf86drm.c
@@ -229,7 +229,7 @@ static int drmOpenDevice(long dev, int minor)
229 229
230 sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, minor); 230 sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, minor);
231 drmMsg("drmOpenDevice: node name is %s\n", buf); 231 drmMsg("drmOpenDevice: node name is %s\n", buf);
232 if (stat(buf, &st) || st.st_rdev != dev) { 232 if (stat(buf, &st)) {
233 if (!isroot) return DRM_ERR_NOT_ROOT; 233 if (!isroot) return DRM_ERR_NOT_ROOT;
234 remove(buf); 234 remove(buf);
235 mknod(buf, S_IFCHR | devmode, dev); 235 mknod(buf, S_IFCHR | devmode, dev);
@@ -243,6 +243,16 @@ static int drmOpenDevice(long dev, int minor)
243 drmMsg("drmOpenDevice: open result is %d, (%s)\n", 243 drmMsg("drmOpenDevice: open result is %d, (%s)\n",
244 fd, fd < 0 ? strerror(errno) : "OK"); 244 fd, fd < 0 ? strerror(errno) : "OK");
245 if (fd >= 0) return fd; 245 if (fd >= 0) return fd;
246
247 if (st.st_rdev != dev) {
248 if (!isroot) return DRM_ERR_NOT_ROOT;
249 remove(buf);
250 mknod(buf, S_IFCHR | devmode, dev);
251 }
252 fd = open(buf, O_RDWR, 0);
253 drmMsg("drmOpenDevice: open result is %d, (%s)\n",
254 fd, fd < 0 ? strerror(errno) : "OK");
255
246 drmMsg("drmOpenDevice: Open failed\n"); 256 drmMsg("drmOpenDevice: Open failed\n");
247 remove(buf); 257 remove(buf);
248 return -errno; 258 return -errno;