diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2019-03-01 15:21:45 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2019-03-01 15:21:45 +0100 |
commit | 5e50f591ff3c0df55fc39192e82cced9c137f2ca (patch) | |
tree | c753c0df1c3ed26b8b8228b670705fde68b3752b /kbd.c | |
parent | 568029f176168fe9c0718b37767bc69587e92eca (diff) | |
download | fbida-5e50f591ff3c0df55fc39192e82cced9c137f2ca.tar.gz |
implement logind_close
Diffstat (limited to 'kbd.c')
-rw-r--r-- | kbd.c | 32 |
1 files changed, 31 insertions, 1 deletions
@@ -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 |