device-pool: Only fetch major/minor for taken devices

It's only when we take/release from/to logind we need these two
integers, so only retrieve them when that's done. Making this change
makes it possible to open devices that don't have these parameters.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
This commit is contained in:
Jonas Ådahl 2021-04-06 17:06:38 +02:00
parent e6421dc5da
commit 3d882b6410

View File

@ -211,7 +211,7 @@ meta_device_pool_open (MetaDevicePool *pool,
{
g_autoptr (GMutexLocker) locker = NULL;
MetaDeviceFile *file;
int major, minor;
int major = -1, minor = -1;
int fd;
locker = g_mutex_locker_new (&pool->mutex);
@ -224,15 +224,6 @@ meta_device_pool_open (MetaDevicePool *pool,
return file;
}
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 NULL;
}
if (flags & META_DEVICE_FILE_FLAG_TAKE_CONTROL)
{
if (!pool->session_proxy)
@ -242,6 +233,15 @@ meta_device_pool_open (MetaDevicePool *pool,
return NULL;
}
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 NULL;
}
if (!take_device (pool->session_proxy, major, minor, &fd, NULL, error))
return NULL;
}