summaryrefslogtreecommitdiff
path: root/vmwgfx/vmwgfx_dri2.c
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom@vmware.com>2011-11-28 14:51:36 +0100
committerThomas Hellstrom <thellstrom@vmware.com>2011-11-28 19:36:26 +0100
commit995d86ceb0ae8cf2904100405ba6710c89f7f1b7 (patch)
treee5b3666e1123976e1808718bfe03795e01bef832 /vmwgfx/vmwgfx_dri2.c
parent08ca819238f2c2a0494b0bd8452393fc62907cc1 (diff)
vmwgfx: Make the drm device name persistent
The DRI2 code doesn't copy the device name, but assumes the storage is persistent. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Jakob Bornecrantz <jakob@vmware.com> Reviewed-by: Alan Hourihane <alanh@vmware.com>
Diffstat (limited to 'vmwgfx/vmwgfx_dri2.c')
-rw-r--r--vmwgfx/vmwgfx_dri2.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/vmwgfx/vmwgfx_dri2.c b/vmwgfx/vmwgfx_dri2.c
index cca686a..3f9d00a 100644
--- a/vmwgfx/vmwgfx_dri2.c
+++ b/vmwgfx/vmwgfx_dri2.c
@@ -44,6 +44,8 @@
#include "wsbm_util.h"
#include <unistd.h>
+#define VMWGFX_FD_PATH_LEN 80
+
typedef struct {
int refcount;
PixmapPtr pPixmap;
@@ -364,8 +366,7 @@ xorg_dri2_init(ScreenPtr pScreen)
modesettingPtr ms = modesettingPTR(pScrn);
DRI2InfoRec dri2info;
int major, minor;
- char deviceName[80];
- char fdPath[80];
+ char fdPath[VMWGFX_FD_PATH_LEN];
ssize_t numChar;
if (xf86LoaderCheckSymbol("DRI2Version")) {
@@ -385,17 +386,18 @@ xorg_dri2_init(ScreenPtr pScreen)
* os-specific. It would be better to obtain it from
* drmOpen. Currently this works only for Linux.
*/
- snprintf(fdPath, 80, "/proc/self/fd/%d", ms->fd);
- numChar = readlink(fdPath, deviceName, 80);
- if (numChar <= 0 || numChar >= 80) {
+ memset(fdPath, 0, VMWGFX_FD_PATH_LEN);
+ snprintf(fdPath, VMWGFX_FD_PATH_LEN - 1, "/proc/self/fd/%d", ms->fd);
+ numChar = readlink(fdPath, ms->dri2_device_name, VMWGFX_DRI_DEVICE_LEN);
+ if (numChar <= 0 || numChar >= VMWGFX_DRI_DEVICE_LEN) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Could not find the drm device name. Disabling dri2.\n");
return FALSE;
}
- deviceName[numChar] = 0;
- dri2info.deviceName = deviceName;
+ ms->dri2_device_name[numChar] = 0;
+ dri2info.deviceName = ms->dri2_device_name;
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Path of drm device is \"%s\".\n", deviceName);
+ "Path of drm device is \"%s\".\n", ms->dri2_device_name);
dri2info.CreateBuffer = dri2_create_buffer;
dri2info.DestroyBuffer = dri2_destroy_buffer;