From 23b79f33fa93c031bcc6bd49222b1a124c10eac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 13 Jul 2021 10:27:20 +0200 Subject: [PATCH] launcher: Remove open/close restricted file API It has since some time been replaced with MetaDevicePool, and isn't used by anything anymore, so remove it. Part-of: --- src/backends/native/meta-launcher.c | 114 ---------------------------- src/backends/native/meta-launcher.h | 7 -- 2 files changed, 121 deletions(-) diff --git a/src/backends/native/meta-launcher.c b/src/backends/native/meta-launcher.c index 013e71cf3..4a63d2feb 100644 --- a/src/backends/native/meta-launcher.c +++ b/src/backends/native/meta-launcher.c @@ -276,120 +276,6 @@ get_seat_proxy (gchar *seat_id, return seat; } -static gboolean -take_device (MetaDbusLogin1Session *session_proxy, - int dev_major, - int dev_minor, - int *out_fd, - GCancellable *cancellable, - GError **error) -{ - g_autoptr (GVariant) fd_variant = NULL; - g_autoptr (GUnixFDList) fd_list = NULL; - int fd = -1; - - if (!meta_dbus_login1_session_call_take_device_sync (session_proxy, - dev_major, - dev_minor, - NULL, - &fd_variant, - NULL, /* paused */ - &fd_list, - cancellable, - error)) - return FALSE; - - fd = g_unix_fd_list_get (fd_list, g_variant_get_handle (fd_variant), error); - if (fd == -1) - return FALSE; - - *out_fd = fd; - return TRUE; -} - -static gboolean -get_device_info_from_path (const char *path, - int *out_major, - int *out_minor) -{ - int r; - struct stat st; - - r = stat (path, &st); - if (r < 0 || !S_ISCHR (st.st_mode)) - return FALSE; - - *out_major = major (st.st_rdev); - *out_minor = minor (st.st_rdev); - return TRUE; -} - -static gboolean -get_device_info_from_fd (int fd, - int *out_major, - int *out_minor) -{ - int r; - struct stat st; - - r = fstat (fd, &st); - if (r < 0 || !S_ISCHR (st.st_mode)) - return FALSE; - - *out_major = major (st.st_rdev); - *out_minor = minor (st.st_rdev); - return TRUE; -} - -int -meta_launcher_open_restricted (MetaLauncher *launcher, - const char *path, - GError **error) -{ - int fd; - int major, minor; - - if (!get_device_info_from_path (path, &major, &minor)) - { - g_set_error (error, - G_IO_ERROR, - G_IO_ERROR_NOT_FOUND, - "Could not get device info for path %s: %m", path); - return -1; - } - - if (!take_device (launcher->session_proxy, major, minor, &fd, NULL, error)) - return -1; - - return fd; -} - -void -meta_launcher_close_restricted (MetaLauncher *launcher, - int fd) -{ - MetaDbusLogin1Session *session_proxy = launcher->session_proxy; - int major, minor; - GError *error = NULL; - - if (!get_device_info_from_fd (fd, &major, &minor)) - { - g_warning ("Could not get device info for fd %d: %m", fd); - goto out; - } - - if (!meta_dbus_login1_session_call_release_device_sync (session_proxy, - major, minor, - NULL, &error)) - { - g_warning ("Could not release device (%d,%d): %s", - major, minor, error->message); - } - -out: - close (fd); -} - static void sync_active (MetaLauncher *self) { diff --git a/src/backends/native/meta-launcher.h b/src/backends/native/meta-launcher.h index 265be958e..267b68337 100644 --- a/src/backends/native/meta-launcher.h +++ b/src/backends/native/meta-launcher.h @@ -34,13 +34,6 @@ gboolean meta_launcher_activate_vt (MetaLauncher *self, const char * meta_launcher_get_seat_id (MetaLauncher *launcher); -int meta_launcher_open_restricted (MetaLauncher *launcher, - const char *path, - GError **error); - -void meta_launcher_close_restricted (MetaLauncher *launcher, - int fd); - MetaDbusLogin1Session * meta_launcher_get_session_proxy (MetaLauncher *launcher);