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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1929>
This commit is contained in:
Jonas Ådahl 2021-07-13 10:27:20 +02:00 committed by Marge Bot
parent 0555a5bbc1
commit 23b79f33fa
2 changed files with 0 additions and 121 deletions

View File

@ -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)
{

View File

@ -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);