libdrm: drmGetDeviceNameFromFd: Always return /dev/dri/ node for FreeBSD
Since we now always returns the /dev/dri/ node for drmGet<nodetype>DeviceNameFromFd, be consistant with the names returned in drmGetDeviceNameFromFd. Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> Signed-off-by: Emmanuel Vadot <manu@FreeBSD.org>main
parent
f52e2b20ed
commit
5aa83dd6fa
15
xf86drm.c
15
xf86drm.c
|
@ -122,6 +122,7 @@ struct drm_pciinfo {
|
||||||
static drmServerInfoPtr drm_server_info;
|
static drmServerInfoPtr drm_server_info;
|
||||||
|
|
||||||
static bool drmNodeIsDRM(int maj, int min);
|
static bool drmNodeIsDRM(int maj, int min);
|
||||||
|
static char *drmGetMinorNameForFD(int fd, int type);
|
||||||
|
|
||||||
drm_public void drmSetServerInfo(drmServerInfoPtr info)
|
drm_public void drmSetServerInfo(drmServerInfoPtr info)
|
||||||
{
|
{
|
||||||
|
@ -2776,24 +2777,16 @@ drm_public char *drmGetDeviceNameFromFd(int fd)
|
||||||
{
|
{
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
struct stat sbuf;
|
struct stat sbuf;
|
||||||
char dname[SPECNAMELEN];
|
|
||||||
char name[SPECNAMELEN];
|
|
||||||
int maj, min;
|
int maj, min;
|
||||||
|
int nodetype;
|
||||||
|
|
||||||
if (fstat(fd, &sbuf))
|
if (fstat(fd, &sbuf))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
maj = major(sbuf.st_rdev);
|
maj = major(sbuf.st_rdev);
|
||||||
min = minor(sbuf.st_rdev);
|
min = minor(sbuf.st_rdev);
|
||||||
|
nodetype = drmGetMinorType(maj, min);
|
||||||
if (!drmNodeIsDRM(maj, min) || !S_ISCHR(sbuf.st_mode))
|
return drmGetMinorNameForFD(fd, nodetype);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!devname_r(sbuf.st_rdev, S_IFCHR, dname, sizeof(dname)))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
snprintf(name, sizeof(name), "/dev/%s", dname);
|
|
||||||
return strdup(name);
|
|
||||||
#else
|
#else
|
||||||
char name[128];
|
char name[128];
|
||||||
struct stat sbuf;
|
struct stat sbuf;
|
||||||
|
|
Loading…
Reference in New Issue