diff options
author | Hans de Goede <hdegoede@redhat.com> | 2014-01-14 15:37:33 +0100 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2014-03-03 08:13:55 +0100 |
commit | cac39219898f5e5a59ff8d8d6524f5fe0d111469 (patch) | |
tree | 326e66b8ebd539e0bd27a74c66da76b45d0356a2 /config | |
parent | 82863656ec449644cd34a86388ba40f36cea11e9 (diff) |
systemd-logind: Hookup systemd-logind integration
This commits makes the changes necessary outside of the systemd-logind core
to make the server use systemd-logind managed fds for input devices and drm
nodes.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'config')
-rw-r--r-- | config/config.c | 13 | ||||
-rw-r--r-- | config/udev.c | 39 |
2 files changed, 48 insertions, 4 deletions
diff --git a/config/config.c b/config/config.c index ea2f744fa..7971b8740 100644 --- a/config/config.c +++ b/config/config.c @@ -27,10 +27,12 @@ #include <dix-config.h> #endif +#include <unistd.h> #include "os.h" #include "inputstr.h" #include "hotplug.h" #include "config-backends.h" +#include "systemd-logind.h" void config_pre_init(void) @@ -235,10 +237,21 @@ void config_odev_free_attributes(struct OdevAttributes *attribs) { struct OdevAttribute *iter, *safe; + int major = 0, minor = 0, fd = -1; xorg_list_for_each_entry_safe(iter, safe, &attribs->list, member) { + switch (iter->attrib_id) { + case ODEV_ATTRIB_MAJOR: major = iter->attrib_value; break; + case ODEV_ATTRIB_MINOR: minor = iter->attrib_value; break; + case ODEV_ATTRIB_FD: fd = iter->attrib_value; break; + } xorg_list_del(&iter->member); free(iter->attrib_name); free(iter); } + + if (fd != -1) { + systemd_logind_release_fd(major, minor); + close(fd); + } } diff --git a/config/udev.c b/config/udev.c index 68ed34843..208518572 100644 --- a/config/udev.c +++ b/config/udev.c @@ -29,6 +29,7 @@ #include <libudev.h> #include <ctype.h> +#include <unistd.h> #include "input.h" #include "inputstr.h" @@ -36,6 +37,7 @@ #include "config-backends.h" #include "os.h" #include "globals.h" +#include "systemd-logind.h" #define UDEV_XKB_PROP_KEY "xkb" @@ -55,9 +57,18 @@ static struct udev_monitor *udev_monitor; #ifdef CONFIG_UDEV_KMS static Bool config_udev_odev_setup_attribs(const char *path, const char *syspath, + int major, int minor, config_odev_probe_proc_ptr probe_callback); #endif +static char itoa_buf[16]; + +static const char *itoa(int i) +{ + snprintf(itoa_buf, sizeof(itoa_buf), "%d", i); + return itoa_buf; +} + static void device_added(struct udev_device *udev_device) { @@ -73,6 +84,7 @@ device_added(struct udev_device *udev_device) struct udev_device *parent; int rc; const char *dev_seat; + dev_t devnum; path = udev_device_get_devnode(udev_device); @@ -91,6 +103,8 @@ device_added(struct udev_device *udev_device) if (!SeatId && strcmp(dev_seat, "seat0")) return; + devnum = udev_device_get_devnum(udev_device); + #ifdef CONFIG_UDEV_KMS if (!strcmp(udev_device_get_subsystem(udev_device), "drm")) { const char *sysname = udev_device_get_sysname(udev_device); @@ -100,7 +114,8 @@ device_added(struct udev_device *udev_device) LogMessage(X_INFO, "config/udev: Adding drm device (%s)\n", path); - config_udev_odev_setup_attribs(path, syspath, NewGPUDeviceRequest); + config_udev_odev_setup_attribs(path, syspath, major(devnum), + minor(devnum), NewGPUDeviceRequest); return; } #endif @@ -153,6 +168,8 @@ device_added(struct udev_device *udev_device) input_options = input_option_new(input_options, "name", name); input_options = input_option_new(input_options, "path", path); input_options = input_option_new(input_options, "device", path); + input_options = input_option_new(input_options, "major", itoa(major(devnum))); + input_options = input_option_new(input_options, "minor", itoa(minor(devnum))); if (path) attrs.device = strdup(path); @@ -270,6 +287,7 @@ device_removed(struct udev_device *device) if (!strcmp(udev_device_get_subsystem(device), "drm")) { const char *sysname = udev_device_get_sysname(device); const char *path = udev_device_get_devnode(device); + dev_t devnum = udev_device_get_devnum(device); if (strncmp(sysname,"card", 4) != 0) return; @@ -277,7 +295,10 @@ device_removed(struct udev_device *device) if (!path) return; - config_udev_odev_setup_attribs(path, syspath, DeleteGPUDeviceRequest); + config_udev_odev_setup_attribs(path, syspath, major(devnum), + minor(devnum), DeleteGPUDeviceRequest); + /* Retry vtenter after a drm node removal */ + systemd_logind_vtenter(); return; } #endif @@ -427,6 +448,7 @@ config_udev_fini(void) static Bool config_udev_odev_setup_attribs(const char *path, const char *syspath, + int major, int minor, config_odev_probe_proc_ptr probe_callback) { struct OdevAttributes *attribs = config_odev_allocate_attribute_list(); @@ -443,6 +465,14 @@ config_udev_odev_setup_attribs(const char *path, const char *syspath, if (ret == FALSE) goto fail; + ret = config_odev_add_int_attribute(attribs, ODEV_ATTRIB_MAJOR, major); + if (ret == FALSE) + goto fail; + + ret = config_odev_add_int_attribute(attribs, ODEV_ATTRIB_MINOR, minor); + if (ret == FALSE) + goto fail; + /* ownership of attribs is passed to probe layer */ probe_callback(attribs); return TRUE; @@ -477,6 +507,7 @@ config_udev_odev_probe(config_odev_probe_proc_ptr probe_callback) struct udev_device *udev_device = udev_device_new_from_syspath(udev, syspath); const char *path = udev_device_get_devnode(udev_device); const char *sysname = udev_device_get_sysname(udev_device); + dev_t devnum = udev_device_get_devnum(udev_device); if (!path || !syspath) goto no_probe; @@ -485,8 +516,8 @@ config_udev_odev_probe(config_odev_probe_proc_ptr probe_callback) else if (strncmp(sysname, "card", 4) != 0) goto no_probe; - config_udev_odev_setup_attribs(path, syspath, probe_callback); - + config_udev_odev_setup_attribs(path, syspath, major(devnum), + minor(devnum), probe_callback); no_probe: udev_device_unref(udev_device); } |