Bug#909436: libdrm 2.4.102-1: FTBFS on hurd-i386 (updated patches)
found 909436 2.4.102-1
thanks
Hello again,
libdrm still FTBFS on GNU/Hurd now due to bug #970304 and still missing
support for Hurd in drm.h and xf86drm.h. Attached is a patch, hurd-
port.diff, to fix this. The rest of that patch address PATH_MAX issues
in xf86dri.c as PATH_MAX is not defined for GNU/Hurd.
Note: hurd-port.diff depends on that xf86drm.c.diff in #970304 is
applied before!
Additionally the patches debian_rules.diff and debian_control.diff adds
Hurd to the architecture list.
Thanks!
Index: libdrm-2.4.102/include/drm/drm.h
===================================================================
--- libdrm-2.4.102.orig/include/drm/drm.h
+++ libdrm-2.4.102/include/drm/drm.h
@@ -42,6 +42,22 @@
#include <asm/ioctl.h>
typedef unsigned int drm_handle_t;
+#elif defined(__GNU__)
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <mach/i386/ioccom.h>
+typedef __int8_t __s8;
+typedef __uint8_t __u8;
+typedef __int16_t __s16;
+typedef __uint16_t __u16;
+typedef __int32_t __s32;
+typedef __uint32_t __u32;
+typedef __int64_t __s64;
+typedef __uint64_t __u64;
+typedef size_t __kernel_size_t;
+typedef unsigned int drm_handle_t;
+
#else /* One of the BSDs */
#include <stdint.h>
Index: libdrm-2.4.102/xf86drm.h
===================================================================
--- libdrm-2.4.102.orig/xf86drm.h
+++ libdrm-2.4.102/xf86drm.h
@@ -56,6 +56,16 @@ extern "C" {
#define DRM_IOC_READWRITE _IOC_READ|_IOC_WRITE
#define DRM_IOC(dir, group, nr, size) _IOC(dir, group, nr, size)
+#elif defined(__GNU__)
+#include <mach/port.h>
+#include <hurd/ioctl.h>
+#define DRM_IOCTL_NR(n) ((n) & 0xff)
+#define DRM_IOC_VOID IOC_VOID
+#define DRM_IOC_READ IOC_OUT
+#define DRM_IOC_WRITE IOC_IN
+#define DRM_IOC_READWRITE IOC_INOUT
+#define DRM_IOC(dir, group, nr, size) _IOC(dir, group, nr, size)
+
#else /* One of the *BSDs */
#include <sys/ioccom.h>
Index: libdrm-2.4.102/xf86drm.c
===================================================================
--- libdrm-2.4.102.orig/xf86drm.c
+++ libdrm-2.4.102/xf86drm.c
@@ -2980,7 +2980,8 @@ static char *drmGetMinorNameForFD(int fd
return strdup(name);
#else
struct stat sbuf;
- char buf[PATH_MAX + 1];
+ char *buf = NULL;
+ int len = 0;
const char *dev_name = drmGetDeviceName(type);
unsigned int maj, min;
int n;
@@ -2997,11 +2998,18 @@ static char *drmGetMinorNameForFD(int fd
if (!dev_name)
return NULL;
- n = snprintf(buf, sizeof(buf), dev_name, DRM_DIR_NAME, min);
- if (n == -1 || n >= (int)sizeof(buf))
+ len = snprintf(NULL, 0, dev_name, DRM_DIR_NAME, min);
+ if (len < 0)
return NULL;
+ len++;
+ buf = malloc(len);
+ n = snprintf(buf, len, dev_name, DRM_DIR_NAME, min);
+ if (n == -1 || n >= len) {
+ free(buf);
+ return NULL;
+ }
- return strdup(buf);
+ return buf;
#endif
}
@@ -3947,17 +3955,30 @@ process_device(drmDevicePtr *device, con
bool fetch_deviceinfo, uint32_t flags)
{
struct stat sbuf;
- char node[PATH_MAX + 1];
+ char *node = NULL;
int node_type, subsystem_type;
+ int len = 0, n, ret = 0;
unsigned int maj, min;
node_type = drmGetNodeType(d_name);
if (node_type < 0)
return -1;
- snprintf(node, PATH_MAX, "%s/%s", DRM_DIR_NAME, d_name);
- if (stat(node, &sbuf))
+ len = snprintf(NULL, 0, "%s/%s", DRM_DIR_NAME, d_name);
+ if (len < 0)
+ return -1;
+ len++;
+ node = malloc(len);
+ n = snprintf(node, len, "%s/%s", DRM_DIR_NAME, d_name);
+ if (n == -1 || n >= len) {
+ free(node);
return -1;
+ }
+
+ if (stat(node, &sbuf)) {
+ free(node);
+ return -1;
+ }
maj = major(sbuf.st_rdev);
min = minor(sbuf.st_rdev);
@@ -3972,18 +3993,27 @@ process_device(drmDevicePtr *device, con
switch (subsystem_type) {
case DRM_BUS_PCI:
case DRM_BUS_VIRTIO:
- return drmProcessPciDevice(device, node, node_type, maj, min,
+ ret = drmProcessPciDevice(device, node, node_type, maj, min,
fetch_deviceinfo, flags);
+ free(node);
+ return ret;
case DRM_BUS_USB:
- return drmProcessUsbDevice(device, node, node_type, maj, min,
+ ret = drmProcessUsbDevice(device, node, node_type, maj, min,
fetch_deviceinfo, flags);
+ free(node);
+ return ret;
case DRM_BUS_PLATFORM:
- return drmProcessPlatformDevice(device, node, node_type, maj, min,
+ ret = drmProcessPlatformDevice(device, node, node_type, maj, min,
fetch_deviceinfo, flags);
+ free(node);
+ return ret;
case DRM_BUS_HOST1X:
- return drmProcessHost1xDevice(device, node, node_type, maj, min,
+ ret = drmProcessHost1xDevice(device, node, node_type, maj, min,
fetch_deviceinfo, flags);
+ free(node);
+ return ret;
default:
+ free(node);
return -1;
}
}
@@ -4306,10 +4336,10 @@ drm_public char *drmGetDeviceNameFromFd2
return drmGetDeviceNameFromFd(fd);
#else
struct stat sbuf;
- char node[PATH_MAX + 1];
+ char *node = NULL;
const char *dev_name;
int node_type;
- int maj, min, n;
+ int maj, min, n, len = 0;
if (fstat(fd, &sbuf))
return NULL;
@@ -4328,11 +4358,16 @@ drm_public char *drmGetDeviceNameFromFd2
if (!dev_name)
return NULL;
- n = snprintf(node, PATH_MAX, dev_name, DRM_DIR_NAME, min);
- if (n == -1 || n >= PATH_MAX)
+ len = snprintf(NULL, 0, dev_name, DRM_DIR_NAME, min);
+ if (len < 0)
+ return NULL;
+ len++;
+ node = malloc(len);
+ n = snprintf(node, len, dev_name, DRM_DIR_NAME, min);
+ if (n == -1 || n >= len)
return NULL;
- return strdup(node);
+ return node;
#endif
}
--- a/debian/rules 2018-08-31 15:01:29.000000000 +0200
+++ b/debian/rules 2018-09-01 00:16:08.000000000 +0200
@@ -31,7 +31,7 @@
# Intel is only on x86:
ifneq (,$(filter amd64 i386,$(DEB_HOST_ARCH_CPU)))
-ifneq (,$(filter linux kfreebsd,$(DEB_HOST_ARCH_OS)))
+ifneq (,$(filter linux kfreebsd hurd,$(DEB_HOST_ARCH_OS)))
INTEL = yes
endif
endif
--- a/debian/control 2018-09-16 23:01:56.000000000 +0200
+++ b/debian/control 2018-09-16 23:03:11.000000000 +0200
@@ -22,10 +22,10 @@
Package: libdrm-dev
Section: libdevel
-Architecture: linux-any kfreebsd-any
+Architecture: linux-any kfreebsd-any hurd-any
Depends:
libdrm2 (= ${binary:Version}),
- libdrm-intel1 (= ${binary:Version}) [amd64 i386 kfreebsd-amd64 kfreebsd-i386 x32],
+ libdrm-intel1 (= ${binary:Version}) [amd64 i386 kfreebsd-amd64 kfreebsd-i386 hurd-i386 x32],
libdrm-radeon1 (= ${binary:Version}),
libdrm-nouveau2 (= ${binary:Version}) [linux-any],
libdrm-amdgpu1 (= ${binary:Version}),
@@ -46,7 +46,7 @@
This package provides the development environment for libdrm.
Package: libdrm2
-Architecture: linux-any kfreebsd-any
+Architecture: linux-any kfreebsd-any hurd-any
Depends:
libdrm-common (>= ${source:Version}),
${shlibs:Depends},
@@ -95,7 +95,7 @@
Package: libdrm2-udeb
Package-Type: udeb
Section: debian-installer
-Architecture: linux-any kfreebsd-any
+Architecture: linux-any kfreebsd-any hurd-any
Depends:
${shlibs:Depends},
${misc:Depends},
@@ -103,7 +103,7 @@
This is a udeb, or a microdeb, for the debian-installer.
Package: libdrm-intel1
-Architecture: amd64 i386 kfreebsd-amd64 kfreebsd-i386 x32
+Architecture: amd64 i386 kfreebsd-amd64 kfreebsd-i386 hurd-i386 x32
Depends:
${shlibs:Depends},
${misc:Depends},
@@ -130,7 +130,7 @@
OpenGL drivers.
Package: libdrm-radeon1
-Architecture: linux-any kfreebsd-any
+Architecture: linux-any kfreebsd-any hurd-any
Depends:
${shlibs:Depends},
${misc:Depends},
@@ -200,7 +200,7 @@
OpenGL drivers.
Package: libdrm-amdgpu1
-Architecture: linux-any kfreebsd-any
+Architecture: linux-any kfreebsd-any hurd-any
Depends:
${shlibs:Depends},
${misc:Depends},
Reply to: