aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2019-03-01 15:21:45 +0100
committerGerd Hoffmann <kraxel@redhat.com>2019-03-01 15:21:45 +0100
commit5e50f591ff3c0df55fc39192e82cced9c137f2ca (patch)
treec753c0df1c3ed26b8b8228b670705fde68b3752b
parent568029f176168fe9c0718b37767bc69587e92eca (diff)
downloadfbida-5e50f591ff3c0df55fc39192e82cced9c137f2ca.tar.gz
implement logind_close
-rw-r--r--kbd.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/kbd.c b/kbd.c
index c8460a2..9bb0fb5 100644
--- a/kbd.c
+++ b/kbd.c
@@ -282,7 +282,37 @@ int logind_open(const char *path)
void logind_close(int fd)
{
- /* FIXME */
+ sd_bus_error error = SD_BUS_ERROR_NULL;
+ sd_bus_message *m = NULL;
+ struct stat st;
+ unsigned int maj, min;
+ int r;
+
+ r = fstat(fd, &st);
+ if (r < 0) {
+ fprintf(stderr, "fstat failed: %s\n", strerror(errno));
+ return;
+ }
+ close(fd);
+
+ maj = major(st.st_rdev);
+ min = minor(st.st_rdev);
+ r = sd_bus_call_method(dbus,
+ "org.freedesktop.login1",
+ "/org/freedesktop/login1/session/self",
+ "org.freedesktop.login1.Session",
+ "ReleaseDevice",
+ &error,
+ &m,
+ "uu",
+ maj,
+ min);
+ if (r < 0) {
+ fprintf(stderr, "ReleaseDevice failed: %s\n", error.message);
+ sd_bus_error_free(&error);
+ return;
+ }
+ sd_bus_message_unref(m);
}
#else