summaryrefslogtreecommitdiff
path: root/xf86drm.h
diff options
context:
space:
mode:
authorChristopher James Halse Rogers <christopher.halse.rogers@canonical.com>2019-01-23 15:38:45 +1100
committerEmil Velikov <emil.l.velikov@gmail.com>2019-02-07 17:43:01 +0000
commit17dfe3ac93217b43f93bc81d1129bd38a89d0368 (patch)
tree806266c8620e13d8a7dc36a628960a655e1265e1 /xf86drm.h
parent70a1ae89be6b9f9a535f1fbaff3e4b1c4bb46d4a (diff)
downloaddrm-17dfe3ac93217b43f93bc81d1129bd38a89d0368.tar.gz
xf86drm: Add drmIsMaster()
We can't use drmSetMaster to query whether or not a drm fd is master because it requires CAP_SYS_ADMIN, even if the fd *is* a master fd. Pick DRM_IOCTL_MODE_ATTACHMODE as a long-deprecated ioctl that is DRM_MASTER but not DRM_ROOT_ONLY as the probe by which we can detect whether or not the fd is master. This is useful for code that might get master by open()ing the drm device while no other master exists, but can't call drmSetMaster itself because it's not running as root or is in a container, where container-root isn't real-root. v2: Use the AUTH_MAGIC request rather than MODE_ATTACHMODE, as it's more clearly related to master status. v3: [Emil] Don't expose internals, check for -EACCES. Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> (v2) Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Diffstat (limited to 'xf86drm.h')
-rw-r--r--xf86drm.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/xf86drm.h b/xf86drm.h
index 7773d71a..9e920db9 100644
--- a/xf86drm.h
+++ b/xf86drm.h
@@ -37,6 +37,7 @@
#include <stdarg.h>
#include <sys/types.h>
#include <stdint.h>
+#include <stdbool.h>
#include <drm.h>
#if defined(__cplusplus)
@@ -733,6 +734,7 @@ extern void drmMsg(const char *format, ...) DRM_PRINTFLIKE(1, 2);
extern int drmSetMaster(int fd);
extern int drmDropMaster(int fd);
+extern bool drmIsMaster(int fd);
#define DRM_EVENT_CONTEXT_VERSION 4