libdrm/libdrm-2.4.0-no-freaking-mknod.patch

95 lines
2.9 KiB
Diff
Raw Normal View History

diff -up libdrm-2.4.0/libdrm/xf86drm.c.mknod libdrm-2.4.0/libdrm/xf86drm.c
--- libdrm-2.4.0/libdrm/xf86drm.c.mknod 2007-10-30 20:10:10.000000000 -0400
+++ libdrm-2.4.0/libdrm/xf86drm.c 2007-11-12 19:26:12.000000000 -0500
@@ -266,64 +266,12 @@ static int drmMatchBusID(const char *id1
*/
static int drmOpenDevice(long dev, int minor)
{
- stat_t st;
char buf[64];
int fd;
- mode_t devmode = DRM_DEV_MODE, serv_mode;
- int isroot = !geteuid();
- uid_t user = DRM_DEV_UID;
- gid_t group = DRM_DEV_GID, serv_group;
sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, minor);
drmMsg("drmOpenDevice: node name is %s\n", buf);
- if (drm_server_info) {
- drm_server_info->get_perms(&serv_group, &serv_mode);
- devmode = serv_mode ? serv_mode : DRM_DEV_MODE;
- devmode &= ~(S_IXUSR|S_IXGRP|S_IXOTH);
- group = (serv_group >= 0) ? serv_group : DRM_DEV_GID;
- }
-
- if (stat(DRM_DIR_NAME, &st)) {
- if (!isroot)
- return DRM_ERR_NOT_ROOT;
- mkdir(DRM_DIR_NAME, DRM_DEV_DIRMODE);
- chown(DRM_DIR_NAME, 0, 0); /* root:root */
- chmod(DRM_DIR_NAME, DRM_DEV_DIRMODE);
- }
-
- /* Check if the device node exists and create it if necessary. */
- if (stat(buf, &st)) {
- if (!isroot)
- return DRM_ERR_NOT_ROOT;
- remove(buf);
- mknod(buf, S_IFCHR | devmode, dev);
- }
-
- if (drm_server_info) {
- chown(buf, user, group);
- chmod(buf, devmode);
- }
-
- fd = open(buf, O_RDWR, 0);
- drmMsg("drmOpenDevice: open result is %d, (%s)\n",
- fd, fd < 0 ? strerror(errno) : "OK");
- if (fd >= 0)
- return fd;
-
- /* Check if the device node is not what we expect it to be, and recreate it
- * and try again if so.
- */
- if (st.st_rdev != dev) {
- if (!isroot)
- return DRM_ERR_NOT_ROOT;
- remove(buf);
- mknod(buf, S_IFCHR | devmode, dev);
- if (drm_server_info) {
- chown(buf, user, group);
- chmod(buf, devmode);
- }
- }
fd = open(buf, O_RDWR, 0);
drmMsg("drmOpenDevice: open result is %d, (%s)\n",
fd, fd < 0 ? strerror(errno) : "OK");
@@ -331,7 +279,6 @@ static int drmOpenDevice(long dev, int m
return fd;
drmMsg("drmOpenDevice: Open failed\n");
- remove(buf);
return -errno;
}
diff -up libdrm-2.4.0/libdrm/xf86drm.h.mknod libdrm-2.4.0/libdrm/xf86drm.h
--- libdrm-2.4.0/libdrm/xf86drm.h.mknod 2007-07-19 00:27:52.000000000 -0400
+++ libdrm-2.4.0/libdrm/xf86drm.h 2007-11-12 19:27:51.000000000 -0500
@@ -39,14 +39,6 @@
#include <stdint.h>
#include <drm.h>
- /* Defaults, if nothing set in xf86config */
-#define DRM_DEV_UID 0
-#define DRM_DEV_GID 0
-/* Default /dev/dri directory permissions 0755 */
-#define DRM_DEV_DIRMODE \
- (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
-#define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
-
#define DRM_DIR_NAME "/dev/dri"
#define DRM_DEV_NAME "%s/card%d"
#define DRM_PROC_NAME "/proc/dri/" /* For backward Linux compatibility */